From 270a86da565b1d45a8792294baaab187408fd9bb Mon Sep 17 00:00:00 2001 From: zicodxx Date: Thu, 19 May 2011 11:49:49 +0200 Subject: [PATCH] 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 --- CHANGELOG.txt | 1 + main/physics.c | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 48260a74b..54eb7022e 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,6 +4,7 @@ D2X-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 -------- diff --git a/main/physics.c b/main/physics.c index 90f505232..2007e9b62 100644 --- a/main/physics.c +++ b/main/physics.c @@ -298,16 +298,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); } } @@ -758,7 +763,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);