for fix_illegal_wall_intersection() try using the distance we moved to move out from the wall. Just in case it's a sane value, i.e. > 0 and <= obj->size/2

This commit is contained in:
zicodxx 2011-05-19 11:49:47 +02:00
parent bc47c43c36
commit 1a97660653
2 changed files with 9 additions and 3 deletions

View file

@ -4,6 +4,7 @@ D1X-Rebirth Changelog
--------
main/fvi.c, main/fvi.h, main/physics.c: Improvement for fix_illegal_wall_interesection(): Move away from wall in right angle - not towards center. This improves the bumping in many situations and prevents ship getting stuck in small segments. Simplified and optimized code as well and removed check for degenerated Segments as not needed with this approach; Fixed some compiler warnings regarding set but unused variables
main/multi.c: Reset new_Bounty_target after using it and let host add a number on how often Bounty is reassigned. Both additions should help keeping target correct no matter how if multiple packets of the same type are disordered, delayed or both
main/physics.c: for fix_illegal_wall_intersection() try using the distance we moved to move out from the wall. Just in case it's a sane value, i.e. > 0 and <= obj->size/2
20110516
--------

View file

@ -287,16 +287,21 @@ void do_physics_sim_rot(object *obj)
}
// On joining edges fvi tends to get inaccurate as hell. Approach is to check if the object interects with the wall and if so, move away from it.
void fix_illegal_wall_intersection(object *obj)
void fix_illegal_wall_intersection(object *obj, vms_vector *origin)
{
int hseg = -1, hside = -1, hface = -1;
fix dist;
if (!(obj->type == OBJ_PLAYER || obj->type == OBJ_ROBOT))
return;
dist = vm_vec_dist(&obj->pos, origin);
if (dist <= 0 || dist > obj->size/2)
dist = FrameTime*10;
if ( object_intersects_wall_d(obj,&hseg,&hside,&hface) )
{
vm_vec_scale_add2(&obj->pos,&Segments[hseg].sides[hside].normals[0],FrameTime*10);
vm_vec_scale_add2(&obj->pos,&Segments[hseg].sides[hside].normals[0],dist);
update_object_seg(obj);
}
}
@ -714,7 +719,7 @@ void do_physics_sim(object *obj)
vm_vec_copy_scale(&obj->mtype.phys_info.velocity,&moved_vec,fixdiv(f1_0,FrameTime));
}
fix_illegal_wall_intersection(obj);
fix_illegal_wall_intersection(obj, &start_pos);
//Assert(check_point_in_seg(&obj->pos,obj->segnum,0).centermask==0);