Another rework for anti-stuck-bumping: Execute after calculation of velocity and add fvi check to make sure we deal with an actual wall collision

This commit is contained in:
zicodxx 2011-03-27 18:01:14 +02:00
parent 8cff6ca835
commit 2bbbabb078
2 changed files with 24 additions and 11 deletions

View file

@ -1,5 +1,9 @@
D1X-Rebirth Changelog
20110327
--------
main/physics.c: Another rework for anti-stuck-bumping: Execute after calculation of velocity and add fvi check to make sure we deal with an actual wall collision
20110314
--------
main/fvi.c, main/physics.c: Again reworked new bump hack to only apply when fate == HIT_WALL (to not break level SKYBOX) and made bumping by distance between object position and wall hit point; Removed/handled some safety checks in find_plane_line_intersection() to make sliding along joining edges smoother again while bad values *should* be handled in pyhsics.c and not make object warp-crashing tru the whole level or stuck in walls (fvi code should still be rewritten tho)

View file

@ -605,17 +605,6 @@ void do_physics_sim(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. (also see FIXME in find_plane_line_intersection)
*/
if (object_intersects_wall(obj) && (obj->type == OBJ_PLAYER || obj->type == OBJ_ROBOT))
{
vms_vector center,bump_vec;
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,vm_vec_dist(&hit_info.hit_pnt, &obj->pos));
}
break;
}
@ -711,6 +700,26 @@ void do_physics_sim(object *obj)
vm_vec_copy_scale(&obj->mtype.phys_info.velocity,&moved_vec,fixdiv(f1_0,FrameTime));
}
/*
* 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. (also see FIXME in find_plane_line_intersection)
* NOTE that we also regulary check if we intersect a wall to make sure we ACTUALLY collide with a wall while bumping out of it - and not having sorta faked wall which is not marked as one...
*/
if (object_intersects_wall(obj) && (obj->type == OBJ_PLAYER || obj->type == OBJ_ROBOT))
{
int success = (fate == HIT_WALL), bcount = obj->size/F0_1;
vms_vector center,bump_vec,safe_pos = obj->pos;
compute_segment_center(&center,&Segments[obj->segnum]);
while (object_intersects_wall(obj) && bcount-- > 0)
{
vm_vec_normalized_dir_quick(&bump_vec,&center,&obj->pos);
vm_vec_scale_add2(&obj->pos,&bump_vec,F0_1);
if (!success)
success = (find_vector_intersection(&fq,&hit_info) == HIT_WALL);
}
if (!success)
obj->pos = safe_pos;
}
//Assert(check_point_in_seg(&obj->pos,obj->segnum,0).centermask==0);
//if (obj->control_type == CT_FLYING)