Added some new conditions to the bumping code: Only bump objects which can slide (alive robots and players) and added a count making sure this function can never get stuck in an infinite loop
This commit is contained in:
parent
4f160df96e
commit
3a91bdb89d
|
@ -3,6 +3,7 @@ D2X-Rebirth Changelog
|
||||||
20110124
|
20110124
|
||||||
--------
|
--------
|
||||||
main/physics.c: Revamped what previously was the BUMP_HACK by checking if an object is actually intersecting a segment and move it out towards segment center just after the initial object movement composed by fvi and before velocity is made - should make inaccurate wall collisions a bit smoother and prevent objects from goind inside or through walls, too
|
main/physics.c: Revamped what previously was the BUMP_HACK by checking if an object is actually intersecting a segment and move it out towards segment center just after the initial object movement composed by fvi and before velocity is made - should make inaccurate wall collisions a bit smoother and prevent objects from goind inside or through walls, too
|
||||||
|
main/physics.c: Added some new conditions to the bumping code: Only bump objects which can slide (alive robots and players) and added a count making sure this function can never get stuck in an infinite loop
|
||||||
|
|
||||||
20110123
|
20110123
|
||||||
--------
|
--------
|
||||||
|
|
|
@ -310,7 +310,7 @@ void do_physics_sim(object *obj)
|
||||||
int fate=0;
|
int fate=0;
|
||||||
vms_vector frame_vec; //movement in this frame
|
vms_vector frame_vec; //movement in this frame
|
||||||
vms_vector new_pos,ipos; //position after this frame
|
vms_vector new_pos,ipos; //position after this frame
|
||||||
int count=0;
|
int count=0,bumpcount=0;
|
||||||
int objnum;
|
int objnum;
|
||||||
int WallHitSeg, WallHitSide;
|
int WallHitSeg, WallHitSide;
|
||||||
fvi_info hit_info;
|
fvi_info hit_info;
|
||||||
|
@ -514,14 +514,15 @@ void do_physics_sim(object *obj)
|
||||||
* 1) object_intersects_wall() does not say how far we went inside the wall which is why we use while to move out until we do not intersect anymore. This should be improved so we only move one time.
|
* 1) object_intersects_wall() does not say how far we went inside the wall which is why we use while to move out until we do not intersect anymore. This should be improved so we only move one time.
|
||||||
* 2) we move the object towards segment center. Depending on the level architecture this is safe. However this will heavily influence velocity and reduce sliding speed near joining edges. Also depending on velocity it's still possible we might not pass an endge leading into another segment since we are pulled back to the old one.
|
* 2) we move the object towards segment center. Depending on the level architecture this is safe. However this will heavily influence velocity and reduce sliding speed near joining edges. Also depending on velocity it's still possible we might not pass an endge leading into another segment since we are pulled back to the old one.
|
||||||
*/
|
*/
|
||||||
while (object_intersects_wall(obj))
|
if ((obj->type == OBJ_PLAYER || obj->type == OBJ_ROBOT) && !(obj->flags&OF_SHOULD_BE_DEAD))
|
||||||
{
|
while (object_intersects_wall(obj) && bumpcount++ < 64)
|
||||||
vms_vector center,bump_vec;
|
{
|
||||||
//bump player a little towards center of segment to unstick
|
vms_vector center,bump_vec;
|
||||||
compute_segment_center(¢er,&Segments[iseg]);
|
//bump player a little towards center of segment to unstick
|
||||||
vm_vec_normalized_dir_quick(&bump_vec,¢er,&obj->pos);
|
compute_segment_center(¢er,&Segments[iseg]);
|
||||||
vm_vec_scale_add2(&obj->pos,&bump_vec,F0_1);
|
vm_vec_normalized_dir_quick(&bump_vec,¢er,&obj->pos);
|
||||||
}
|
vm_vec_scale_add2(&obj->pos,&bump_vec,F0_1);
|
||||||
|
}
|
||||||
|
|
||||||
//if start point not in segment, move object to center of segment
|
//if start point not in segment, move object to center of segment
|
||||||
if (get_seg_masks(&obj->pos, obj->segnum, 0, __FILE__, __LINE__).centermask !=0 )
|
if (get_seg_masks(&obj->pos, obj->segnum, 0, __FILE__, __LINE__).centermask !=0 )
|
||||||
|
|
Loading…
Reference in a new issue