]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Some minor tweaks to the QC physics logic
authorMario <mario.mario@y7mail.com>
Sun, 27 Nov 2022 02:16:58 +0000 (02:16 +0000)
committerMario <mario.mario@y7mail.com>
Sun, 27 Nov 2022 02:16:58 +0000 (02:16 +0000)
.gitlab-ci.yml
qcsrc/common/physics/movetypes/movetypes.qc
qcsrc/common/physics/movetypes/movetypes.qh
qcsrc/common/physics/movetypes/push.qc
qcsrc/common/physics/movetypes/toss.qc
qcsrc/common/physics/movetypes/walk.qc
qcsrc/common/physics/player.qc

index 6a12c61c1f291c6ae49247e39ee27cbfdadb7be4..fa6d92d5bad3adb508d8cbba35e6919668560ec2 100644 (file)
@@ -55,7 +55,7 @@ test_sv_game:
     - wget -O data/maps/stormkeep.waypoints https://gitlab.com/xonotic/xonotic-maps.pk3dir/raw/master/maps/stormkeep.waypoints\r
     - wget -O data/maps/stormkeep.waypoints.cache https://gitlab.com/xonotic/xonotic-maps.pk3dir/raw/master/maps/stormkeep.waypoints.cache\r
 \r
-    - EXPECT=757e5413dab5085242502ca47740b83c\r
+    - EXPECT=4c834aa9b5950ffe25deec1880f21641\r
     - HASH=$(${ENGINE} +timestamps 1 +exec serverbench.cfg\r
       | tee /dev/stderr\r
       | sed -e 's,^\[[^]]*\] ,,'\r
index 93cf2a4d31cd0f4951d81913191fca1d52d6e6fc..2634b8246bedc6e0eb165b772a11f341d6364924 100644 (file)
@@ -129,14 +129,14 @@ int _Movetype_FlyMove(entity this, float dt, bool applygravity, bool applystepno
                return 0;
 
        int blockedflag = 0;
-       int i, j, numplanes = 0;
+       int numplanes = 0;
        float time_left = dt, grav = 0;
        vector push;
        vector primal_velocity, original_velocity;
        vector restore_velocity = this.velocity;
 
-       for(i = 0; i < MAX_CLIP_PLANES; ++i)
-               planes[i] = '0 0 0';
+       for(int j = 0; j < MAX_CLIP_PLANES; ++j)
+               planes[j] = '0 0 0';
 
        if(applygravity)
        {
@@ -160,7 +160,7 @@ int _Movetype_FlyMove(entity this, float dt, bool applygravity, bool applystepno
                        break;
 
                push = this.velocity * time_left;
-               if(!_Movetype_PushEntity(this, push, true, false))
+               if(!_Movetype_PushEntity(this, push, false))
                {
                        // we got teleported by a touch function
                        // let's abort the move
@@ -205,22 +205,22 @@ int _Movetype_FlyMove(entity this, float dt, bool applygravity, bool applystepno
                {
                        // step - handle it immediately
                        vector org = this.origin;
-                       vector steppush = '0 0 1' * stepheight;
+                       vector steppush = vec3(0, 0, stepheight);
                        push = this.velocity * time_left;
 
-                       if(!_Movetype_PushEntity(this, steppush, true, false))
+                       if(!_Movetype_PushEntity(this, steppush, false))
                        {
                                blockedflag |= 8;
                                break;
                        }
-                       if(!_Movetype_PushEntity(this, push, true, false))
+                       if(!_Movetype_PushEntity(this, push, false))
                        {
                                blockedflag |= 8;
                                break;
                        }
                        float trace2_fraction = trace_fraction;
                        steppush = vec3(0, 0, org.z - this.origin_z);
-                       if(!_Movetype_PushEntity(this, steppush, true, false))
+                       if(!_Movetype_PushEntity(this, steppush, false))
                        {
                                blockedflag |= 8;
                                break;
@@ -268,23 +268,25 @@ int _Movetype_FlyMove(entity this, float dt, bool applygravity, bool applystepno
 
                // modify original_velocity so it parallels all of the clip planes
                vector new_velocity = '0 0 0';
-               for (i = 0;i < numplanes;i++)
+               int plane;
+               for (plane = 0;plane < numplanes;plane++)
                {
-                       new_velocity = _Movetype_ClipVelocity(original_velocity, planes[i], 1);
-                       for (j = 0;j < numplanes;j++)
+                       int newplane;
+                       new_velocity = _Movetype_ClipVelocity(original_velocity, planes[plane], 1);
+                       for (newplane = 0;newplane < numplanes;newplane++)
                        {
-                               if(j != i)
+                               if(newplane != plane)
                                {
                                        // not ok
-                                       if((new_velocity * planes[j]) < 0)
+                                       if((new_velocity * planes[newplane]) < 0)
                                                break;
                                }
                        }
-                       if(j == numplanes)
+                       if(newplane == numplanes)
                                break;
                }
 
-               if(i != numplanes)
+               if(plane != numplanes)
                {
                        // go along this plane
                        this.velocity = new_velocity;
@@ -300,12 +302,7 @@ int _Movetype_FlyMove(entity this, float dt, bool applygravity, bool applystepno
                        }
                        vector dir = cross(planes[0], planes[1]);
                        // LordHavoc: thanks to taniwha of QuakeForge for pointing out this fix for slowed falling in corners
-                       float ilength = sqrt((dir * dir));
-                       if(ilength)
-                               ilength = 1.0 / ilength;
-                       dir.x *= ilength;
-                       dir.y *= ilength;
-                       dir.z *= ilength;
+                       dir = normalize(dir);
                        float d = (dir * this.velocity);
                        this.velocity = dir * d;
                }
@@ -696,12 +693,12 @@ void _Movetype_PushEntityTrace(entity this, vector push)
        tracebox(this.origin, this.mins, this.maxs, end, type, this);
 }
 
-bool _Movetype_PushEntity(entity this, vector push, bool failonstartsolid, bool dolink)  // SV_PushEntity
+bool _Movetype_PushEntity(entity this, vector push, bool dolink)  // SV_PushEntity
 {
        _Movetype_PushEntityTrace(this, push);
 
        // NOTE: this is a workaround for the QC's lack of a worldstartsolid trace parameter
-       if(trace_startsolid && failonstartsolid)
+       if(trace_startsolid)
        {
                int oldtype = this.move_nomonsters;
                this.move_nomonsters = MOVE_WORLDONLY;
index 79b0ea7badd26ad287a1f427d99f2d363029e870..23a3e28e479d263d3e3b410f163f0f8fbe0cebde 100644 (file)
@@ -113,7 +113,7 @@ void _Movetype_LinkEdict_TouchAreaGrid(entity this);
 void _Movetype_LinkEdict(entity this, float touch_triggers);
 vector _Movetype_ClipVelocity(vector vel, vector norm, float f);
 void _Movetype_PushEntityTrace(entity this, vector push);
-bool _Movetype_PushEntity(entity this, vector push, float failonstartsolid, bool dolink);
+bool _Movetype_PushEntity(entity this, vector push, bool dolink);
 
 void Movetype_Physics_NoMatchTicrate(entity this, float movedt, bool isclient);
 void Movetype_Physics_MatchTicrate(entity this, float tr, bool sloppy);
index 1b654b59c7e9329197d1b4cad8650b6eeff641f8..c3c16b904fc278aa8948896d01d4796ae2b7284b 100644 (file)
@@ -131,7 +131,7 @@ void _Movetype_PushMove(entity this, float dt) // SV_PushMove
                // try moving the contacted entity
                int savesolid = this.solid;
                this.solid = SOLID_NOT;
-               if(!_Movetype_PushEntity(check, move, true, true))
+               if(!_Movetype_PushEntity(check, move, true))
                {
                        // entity "check" got teleported
                        check.angles_y += trace_fraction * moveangle.y;
@@ -155,7 +155,7 @@ void _Movetype_PushMove(entity this, float dt) // SV_PushMove
                        if(_Movetype_NudgeOutOfSolid_PivotIsKnownGood(check, pivot))
                        {
                                // hack to invoke all necessary movement triggers
-                               _Movetype_PushEntity(check, '0 0 0', true, true);
+                               _Movetype_PushEntity(check, '0 0 0', true);
                                // we could fix it or entity "check" was telported
                                continue;
                        }
index 67405a636498d0f0aef004f2b5236750e42dda4d..c23ab4384b7651ffb0e284da0ce8b353d1272f85 100644 (file)
@@ -51,7 +51,7 @@ void _Movetype_Physics_Toss(entity this, float dt)  // SV_Physics_Toss
        for (int bump = 0; bump < MAX_CLIP_PLANES && movetime > 0; bump++)
        {
                vector move = this.velocity * movetime;
-               if(!_Movetype_PushEntity(this, move, true, true))
+               if(!_Movetype_PushEntity(this, move, true))
                        return;
                if (wasfreed(this))
                        return;
@@ -67,7 +67,7 @@ void _Movetype_Physics_Toss(entity this, float dt)  // SV_Physics_Toss
                        trace_fraction = oldtrace_fraction;
                        trace_plane_normal = oldtrace_plane_normal;
                        trace_ent = oldtrace_ent;
-                       if(!_Movetype_PushEntity(this, move, true, true))
+                       if(!_Movetype_PushEntity(this, move, true))
                                return;
                        if (wasfreed(this))
                                return;
index babb38ca4f7c02d966f460703af352826ce6c56d..868bf6d35873192a3ffffd39a29aab4dfb80836c 100644 (file)
@@ -37,13 +37,16 @@ void _Movetype_Physics_Walk(entity this, float dt)  // SV_WalkMove
                vector upmove = this.origin + '0 0 1';
                vector downmove = this.origin - '0 0 1';
                int type;
-               if (this.move_movetype == MOVETYPE_FLYMISSILE)
+               if (this.move_nomonsters)
+                       type = max(0, this.move_nomonsters);
+               else if (this.move_movetype == MOVETYPE_FLYMISSILE)
                        type = MOVE_MISSILE;
                else if (this.move_movetype == MOVETYPE_FLY_WORLDONLY)
                        type = MOVE_WORLDONLY;
                else if (this.solid == SOLID_TRIGGER || this.solid == SOLID_NOT)
                        type = MOVE_NOMONSTERS;
-               else type = MOVE_NORMAL;
+               else
+                       type = MOVE_NORMAL;
                tracebox(upmove, this.mins, this.maxs, downmove, type, this);
                if (trace_fraction < 1 && trace_plane_normal.z > 0.7)
                {
@@ -103,7 +106,7 @@ void _Movetype_Physics_Walk(entity this, float dt)  // SV_WalkMove
 
                // move up
                vector upmove = '0 0 1' * PHYS_STEPHEIGHT(this);
-               if(!_Movetype_PushEntity(this, upmove, true, true))
+               if(!_Movetype_PushEntity(this, upmove, true))
                {
                        // we got teleported when upstepping... must abort the move
                        return;
@@ -157,7 +160,7 @@ void _Movetype_Physics_Walk(entity this, float dt)  // SV_WalkMove
        // move down
        vector downmove = '0 0 0';
        downmove.z = -PHYS_STEPHEIGHT(this) + start_velocity.z * dt;
-       if(!_Movetype_PushEntity(this, downmove, true, true))
+       if(!_Movetype_PushEntity(this, downmove, true))
        {
                // we got teleported when downstepping... must abort the move
                return;
index 22a16e7d56558b0904c2fcd646a3ce39220fe66f..8f681ce5f9d12b9b7559fd330d8b1a169485add7 100644 (file)
@@ -166,7 +166,7 @@ void PM_ClientMovement_UpdateStatus(entity this)
                        // setanim(this, this.anim_duck, false, true, true); // this anim is BROKEN anyway
                }
        } else if (IS_DUCKED(this)) {
-               tracebox(this.origin, STAT(PL_MIN, this), STAT(PL_MAX, this), this.origin, false, this);
+               tracebox(this.origin, STAT(PL_MIN, this), STAT(PL_MAX, this), this.origin, MOVE_NORMAL, this);
                if (!trace_startsolid) {
                        UNSET_DUCKED(this);
                        this.view_ofs = STAT(PL_VIEW_OFS, this);