X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fphysics%2Fmovetypes%2Ftoss.qc;h=caf1fda477b8521b155194e507a3c6f56e5c1f4d;hb=f963d587753ce1f8e48c8bf87b0bf860732986be;hp=772eb1b070c59a2be0df4aa72df5bc904e115838;hpb=e928607ec4292b2b548afad0304d5830792bc485;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/physics/movetypes/toss.qc b/qcsrc/common/physics/movetypes/toss.qc index 772eb1b07..caf1fda47 100644 --- a/qcsrc/common/physics/movetypes/toss.qc +++ b/qcsrc/common/physics/movetypes/toss.qc @@ -48,21 +48,39 @@ void _Movetype_Physics_Toss(entity this, float dt) // SV_Physics_Toss this.angles = this.angles + this.avelocity * dt; float movetime = dt; - for (int bump = 0; bump < MAX_CLIP_PLANES && movetime > 0; bump++) + for (int bump = 0; bump < MAX_CLIP_PLANES && movetime > 0; ++bump) { + if(this.velocity == '0 0 0') + break; + vector move = this.velocity * movetime; - if(!_Movetype_PushEntity(this, move, true, true)) - return; + if(!_Movetype_PushEntity(this, move, true)) + return; // teleported if (wasfreed(this)) return; - if (trace_startsolid) + // NOTE: this is bmodelstartsolid in the engine + if (trace_allsolid && trace_fraction == 0 && trace_ent.solid == SOLID_BSP) { + // QC lacks pointers so we must save the old trace values + float oldtrace_fraction = trace_fraction; + vector oldtrace_plane_normal = trace_plane_normal; + entity oldtrace_ent = trace_ent; _Movetype_UnstickEntity(this); - if(!_Movetype_PushEntity(this, move, true, true)) - return; + trace_fraction = oldtrace_fraction; + trace_plane_normal = oldtrace_plane_normal; + trace_ent = oldtrace_ent; + if(!_Movetype_PushEntity(this, move, true)) + return; // teleported if (wasfreed(this)) return; + if (trace_allsolid && trace_fraction == 0) + { + // immovably stuck, don't waste CPU trying to move again + this.velocity = '0 0 0'; + SET_ONGROUND(this); + return; + } } if (trace_fraction == 1)