From: TimePath Date: Mon, 18 Apr 2016 11:45:33 +0000 (+1000) Subject: Support noclip + fly X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f704ff33f8754a2ea125a128e5cd6d76efe076ae;p=xonotic%2Fxonotic-data.pk3dir.git Support noclip + fly --- diff --git a/qcsrc/ecs/cl_main.qc b/qcsrc/ecs/cl_main.qc index b7e638f49..c1d87524b 100644 --- a/qcsrc/ecs/cl_main.qc +++ b/qcsrc/ecs/cl_main.qc @@ -18,7 +18,10 @@ 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; diff --git a/qcsrc/ecs/components/physics.qh b/qcsrc/ecs/components/physics.qh index fe22496b5..09685a7d1 100644 --- a/qcsrc/ecs/components/physics.qh +++ b/qcsrc/ecs/components/physics.qh @@ -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; diff --git a/qcsrc/ecs/systems/physics.qc b/qcsrc/ecs/systems/physics.qc index f4cefc221..1eb12fbfd 100644 --- a/qcsrc/ecs/systems/physics.qc +++ b/qcsrc/ecs/systems/physics.qc @@ -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;