Bit more safeguarding in find_plane_line_intersection() and as a result less agressive but more beautiful back-bumping on illegal wall interesections; Scaling of movement from PhysTime to FrameTime now done with vector math functions
This commit is contained in:
parent
a518930c62
commit
ee9ac80b62
|
@ -3,6 +3,7 @@ D1X-Rebirth Changelog
|
||||||
20110413
|
20110413
|
||||||
--------
|
--------
|
||||||
main/net_udp.c, main/net_udp.h: Improved security for UDP protocol: Add checks for correct packet size and - if possible - valid sender address (valid player) and making sure Clients only accept packets meant for Clients and Hosts only accept packets meant for Hosts
|
main/net_udp.c, main/net_udp.h: Improved security for UDP protocol: Add checks for correct packet size and - if possible - valid sender address (valid player) and making sure Clients only accept packets meant for Clients and Hosts only accept packets meant for Hosts
|
||||||
|
main/fvi.c, main/physics.c: Bit more safeguarding in find_plane_line_intersection() and as a result less agressive but more beautiful back-bumping on illegal wall interesections; Scaling of movement from PhysTime to FrameTime now done with vector math functions
|
||||||
|
|
||||||
20110412
|
20110412
|
||||||
--------
|
--------
|
||||||
|
|
12
main/fvi.c
12
main/fvi.c
|
@ -58,11 +58,13 @@ int find_plane_line_intersection(vms_vector *new_pnt,vms_vector *plane_pnt,vms_v
|
||||||
//check for various bad values
|
//check for various bad values
|
||||||
if (den > 0 && (-num>>15) >= den) //will overflow (large negative)
|
if (den > 0 && (-num>>15) >= den) //will overflow (large negative)
|
||||||
num = (f1_0-f0_5)*den;
|
num = (f1_0-f0_5)*den;
|
||||||
// FIXME: need to handle those or catch somewhere else?
|
// FIXME: Handle those better!
|
||||||
// if (den > 0 && num > den) //frac greater than one
|
if (den > 0 && num > den) //frac greater than one
|
||||||
// return 0;
|
num = den; //return 0;
|
||||||
// if (den < 0 && num < den) //frac greater than one
|
if (den < 0 && num < den) //frac greater than one
|
||||||
// return 0;
|
num = den; //return 0;
|
||||||
|
if (labs (num) / (f1_0 / 2) >= labs (den))
|
||||||
|
return 0;
|
||||||
|
|
||||||
vm_vec_scale2(&d,num,den);
|
vm_vec_scale2(&d,num,den);
|
||||||
vm_vec_add(new_pnt,p0,&d);
|
vm_vec_add(new_pnt,p0,&d);
|
||||||
|
|
|
@ -562,6 +562,17 @@ void do_physics_sim(object *obj)
|
||||||
vms_vector moved_v;
|
vms_vector moved_v;
|
||||||
fix hit_speed=0, wall_part=0;
|
fix hit_speed=0, wall_part=0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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(¢er,&Segments[obj->segnum]);
|
||||||
|
vm_vec_normalized_dir_quick(&bump_vec,¢er,&obj->pos);
|
||||||
|
vm_vec_scale_add2(&obj->pos,&bump_vec,F0_1);
|
||||||
|
}
|
||||||
|
|
||||||
// Find hit speed
|
// Find hit speed
|
||||||
|
|
||||||
vm_vec_sub(&moved_v,&obj->pos,&save_pos);
|
vm_vec_sub(&moved_v,&obj->pos,&save_pos);
|
||||||
|
@ -678,9 +689,10 @@ void do_physics_sim(object *obj)
|
||||||
// As sim_time may not base on FrameTime, scale actual object position to get accurate movement
|
// As sim_time may not base on FrameTime, scale actual object position to get accurate movement
|
||||||
if (PhysTime/FrameTime > 0)
|
if (PhysTime/FrameTime > 0)
|
||||||
{
|
{
|
||||||
obj->pos.x = start_pos.x + ((obj->pos.x - start_pos.x) / ((float)PhysTime/FrameTime));
|
vms_vector md;
|
||||||
obj->pos.y = start_pos.y + ((obj->pos.y - start_pos.y) / ((float)PhysTime/FrameTime));
|
vm_vec_sub(&md, &obj->pos, &start_pos);
|
||||||
obj->pos.z = start_pos.z + ((obj->pos.z - start_pos.z) / ((float)PhysTime/FrameTime));
|
vm_vec_scale(&md, F1_0/((float)PhysTime/FrameTime));
|
||||||
|
vm_vec_add(&obj->pos,&start_pos, &md);
|
||||||
//check for and update correct object segment
|
//check for and update correct object 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)
|
||||||
{
|
{
|
||||||
|
@ -704,26 +716,6 @@ void do_physics_sim(object *obj)
|
||||||
vm_vec_copy_scale(&obj->mtype.phys_info.velocity,&moved_vec,fixdiv(f1_0,FrameTime));
|
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(¢er,&Segments[obj->segnum]);
|
|
||||||
while (object_intersects_wall(obj) && bcount-- > 0)
|
|
||||||
{
|
|
||||||
vm_vec_normalized_dir_quick(&bump_vec,¢er,&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);
|
//Assert(check_point_in_seg(&obj->pos,obj->segnum,0).centermask==0);
|
||||||
|
|
||||||
//if (obj->control_type == CT_FLYING)
|
//if (obj->control_type == CT_FLYING)
|
||||||
|
|
Loading…
Reference in a new issue