From: TimePath Date: Sun, 22 Nov 2015 03:38:46 +0000 (+1100) Subject: Physics: unroll unstick_offsets X-Git-Tag: xonotic-v0.8.2~1644 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2ae1423181548ca07cb54944b348024af978f812;p=xonotic%2Fxonotic-data.pk3dir.git Physics: unroll unstick_offsets --- diff --git a/qcsrc/common/physics.qc b/qcsrc/common/physics.qc index ad5f13808..3417b5ab8 100644 --- a/qcsrc/common/physics.qc +++ b/qcsrc/common/physics.qc @@ -192,49 +192,48 @@ float GeomLerp(float a, float lerp, float b) noref float pmove_waterjumptime; -const float unstick_count = 27; -vector unstick_offsets[unstick_count] = +#define unstick_offsets(X) \ +/* 1 no nudge (just return the original if this test passes) */ \ + X(' 0.000 0.000 0.000') \ +/* 6 simple nudges */ \ + X(' 0.000 0.000 0.125') X('0.000 0.000 -0.125') \ + X('-0.125 0.000 0.000') X('0.125 0.000 0.000') \ + X(' 0.000 -0.125 0.000') X('0.000 0.125 0.000') \ +/* 4 diagonal flat nudges */ \ + X('-0.125 -0.125 0.000') X('0.125 -0.125 0.000') \ + X('-0.125 0.125 0.000') X('0.125 0.125 0.000') \ +/* 8 diagonal upward nudges */ \ + X('-0.125 0.000 0.125') X('0.125 0.000 0.125') \ + X(' 0.000 -0.125 0.125') X('0.000 0.125 0.125') \ + X('-0.125 -0.125 0.125') X('0.125 -0.125 0.125') \ + X('-0.125 0.125 0.125') X('0.125 0.125 0.125') \ +/* 8 diagonal downward nudges */ \ + X('-0.125 0.000 -0.125') X('0.125 0.000 -0.125') \ + X(' 0.000 -0.125 -0.125') X('0.000 0.125 -0.125') \ + X('-0.125 -0.125 -0.125') X('0.125 -0.125 -0.125') \ + X('-0.125 0.125 -0.125') X('0.125 0.125 -0.125') \ +/**/ + +void PM_ClientMovement_Unstick(entity this) { -// 1 no nudge (just return the original if this test passes) - '0.000 0.000 0.000', -// 6 simple nudges - ' 0.000 0.000 0.125', '0.000 0.000 -0.125', - '-0.125 0.000 0.000', '0.125 0.000 0.000', - ' 0.000 -0.125 0.000', '0.000 0.125 0.000', -// 4 diagonal flat nudges - '-0.125 -0.125 0.000', '0.125 -0.125 0.000', - '-0.125 0.125 0.000', '0.125 0.125 0.000', -// 8 diagonal upward nudges - '-0.125 0.000 0.125', '0.125 0.000 0.125', - ' 0.000 -0.125 0.125', '0.000 0.125 0.125', - '-0.125 -0.125 0.125', '0.125 -0.125 0.125', - '-0.125 0.125 0.125', '0.125 0.125 0.125', -// 8 diagonal downward nudges - '-0.125 0.000 -0.125', '0.125 0.000 -0.125', - ' 0.000 -0.125 -0.125', '0.000 0.125 -0.125', - '-0.125 -0.125 -0.125', '0.125 -0.125 -0.125', - '-0.125 0.125 -0.125', '0.125 0.125 -0.125', -}; - -void PM_ClientMovement_Unstick() -{SELFPARAM(); - float i; - for (i = 0; i < unstick_count; i++) - { - vector neworigin = unstick_offsets[i] + self.origin; - tracebox(neworigin, PL_CROUCH_MIN, PL_CROUCH_MAX, neworigin, MOVE_NORMAL, self); - if (!trace_startsolid) - { - setorigin(self, neworigin); - return;// true; - } + #define X(unstick_offset) \ + { \ + vector neworigin = unstick_offset + this.origin; \ + tracebox(neworigin, PL_CROUCH_MIN, PL_CROUCH_MAX, neworigin, MOVE_NORMAL, this); \ + if (!trace_startsolid) \ + { \ + setorigin(this, neworigin); \ + return; \ + } \ } + unstick_offsets(X); + #undef X } void PM_ClientMovement_UpdateStatus(bool ground) {SELFPARAM(); // make sure player is not stuck - PM_ClientMovement_Unstick(); + PM_ClientMovement_Unstick(this); // set crouched if (PHYS_INPUT_BUTTON_CROUCH(self))