To compensate fewer FVI runs in lower FPS and wall penetration caused by strong forces allowed fix_illegal_wall_intersection() to move an object out of the wall half it's size improving the collisions once more

This commit is contained in:
zicodxx 2011-05-04 13:06:27 +02:00
parent be253a37f2
commit cdbf6c0485
2 changed files with 10 additions and 3 deletions

View file

@ -6,6 +6,7 @@ editor/segment.c, main/fvi.c, main/gameseg.c, main/physics.c, main/segment.h: Si
main/endlevel.c: Make sure the big explosion at the end of the escape sequence also uses blending if transparency effects are activated
main/multi.c: Fix crash in multi_maybe_disable_friendly_fire() when killer == NULL
2d/font.c: mipmapping was always on for fonts due to changed filtering code in ogl.c
main/physics.c: To compensate fewer FVI runs in lower FPS and wall penetration caused by strong forces allowed fix_illegal_wall_intersection() to move an object out of the wall half it's size improving the collisions once more
20110424
--------

View file

@ -290,7 +290,7 @@ void do_physics_sim_rot(object *obj)
// On joining edges fvi tends to get inaccurate as hell due to object size. And I have no means to fix that - shame on me (that whole code should be rewritten). Approach is to check if the object interects with the wall and if so, move it out towards segment center.
void fix_illegal_wall_intersection(object *obj)
{
int i = 0;
int i = 0, bocount = 1;
vms_vector center,bump_vec;
if ( !(obj->type == OBJ_PLAYER || obj->type == OBJ_ROBOT) )
@ -306,9 +306,15 @@ void fix_illegal_wall_intersection(object *obj)
if ( Segments[Segments[obj->segnum].children[i]].degenerated )
return;
if (obj->size/2 >= F0_1) // at size bigger than bumping distance use multiple runs so we can move at least half the size of the object we want to bump (rounding covered by >= in while below)
bocount = (obj->size/2/F0_1);
compute_segment_center(&center,&Segments[obj->segnum]);
vm_vec_normalized_dir_quick(&bump_vec,&center,&obj->pos);
vm_vec_scale_add2(&obj->pos,&bump_vec,F0_1);
while ( object_intersects_wall(obj) && bocount-- >= 0 )
{
vm_vec_normalized_dir_quick(&bump_vec,&center,&obj->pos);
vm_vec_scale_add2(&obj->pos,&bump_vec,F0_1);
}
}
// -----------------------------------------------------------------------------------------------------------