]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Support noclip + fly
authorTimePath <andrew.hardaker1995@gmail.com>
Mon, 18 Apr 2016 11:45:33 +0000 (21:45 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Mon, 18 Apr 2016 11:45:33 +0000 (21:45 +1000)
qcsrc/ecs/cl_main.qc
qcsrc/ecs/components/physics.qh
qcsrc/ecs/systems/physics.qc

index b7e638f49b9aefd4a15bcc45664e3eebd956233d..c1d87524bc4c07631bea99663f720585408a84a8 100644 (file)
                it.com_phys_stepheight = 31;
                it.com_phys_jumpvel = 260;
                it.com_phys_friction = 6;
-               it.com_phys_gravity = 800;
+               // it.com_phys_gravity = 800;
+               it.com_phys_noclip = true;
+
+               it.com_phys_pos = '0 0 200';
        }
 
        void CSQC_Ent_Update(bool isnew)
@@ -64,7 +67,7 @@
                vector dir = normalize(it.com_in_move);
                vector upvec = '0 0 1';
                vector vel = (v_forward * dir.x + v_right * dir.y + upvec * dir.z);
-               vel = vec_reflect(vel, upvec, 0);
+               if (!it.com_phys_noclip) vel = vec_reflect(vel, upvec, 0);
                vel = normalize(vel);
                vel *= 360 * frametime * 8;
                it.com_phys_vel += vel;
index fe22496b59a6bc55ebbaa85738fa38dfe120e7f3..09685a7d190b81c46629e8162da85f042101c3af 100644 (file)
@@ -7,6 +7,7 @@ COMPONENT(phys);
 .vector com_phys_vel;
 .vector com_phys_acc;
 
+.bool   com_phys_noclip;
 .bool   com_phys_grounded;
 .bool   com_phys_nogravityonground;
 .float  com_phys_stepheight;
index f4cefc221cbc61153ec0f0534cca6f95c99aeab7..1eb12fbfda900302e3d66fa6a90023133ebd267e 100644 (file)
@@ -29,6 +29,11 @@ void sys_phys_update(entity this, float dt)
        float bounce = this.com_phys_bounce;
        float friction = this.com_phys_friction;
        float gravity = this.com_phys_gravity;
+       bool noclip = this.com_phys_noclip;
+       if (noclip) {
+           jump = false;
+           nogravityonground = false;
+       }
 
        vector g = upvec * -gravity;
 
@@ -36,7 +41,7 @@ void sys_phys_update(entity this, float dt)
        // alternatives: rk4, verlet, euler
        vel += (acc + g) * dt / 2;
        {
-               if (onground)
+               if (onground || noclip)
                {
                        if (nogravityonground)
                        {
@@ -50,7 +55,7 @@ void sys_phys_update(entity this, float dt)
                        else  // the first landing frame is free
                        {
                                // friction
-                               vector slide = vec_reflect(vel, upvec, 0);
+                               vector slide = noclip ? vel : vec_reflect(vel, upvec, 0);
                                vector push = vel - slide;
                                // TODO: slick
                                slide *= 1 - friction * dt;
@@ -62,6 +67,7 @@ void sys_phys_update(entity this, float dt)
                bool foundground = false;                  // assume until proven otherwise
                if (nogravityonground) foundground = true; // override
                bool steplimit = 1;
+               if (noclip) pass = true; else
                for (int i = 0; i < PHYSICS_TRACE_PLANE_MAX; ++i)
                {
                        vector p0 = pos;