]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move PM_fly to ecs
authorTimePath <andrew.hardaker1995@gmail.com>
Thu, 23 Jun 2016 22:55:40 +0000 (08:55 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Thu, 23 Jun 2016 22:55:40 +0000 (08:55 +1000)
qcsrc/common/physics/player.qc
qcsrc/ecs/components/physics.qh
qcsrc/ecs/systems/physics.qc
qcsrc/uncrustify.cfg

index 5925ada7bfc86c6dfe0ea85737e30d5add58a21e..38c6fed9e0e079b68641b5178ffa12ee1329a762 100644 (file)
@@ -816,27 +816,6 @@ void PM_check_blocked(entity this)
 #endif
 }
 
-void PM_fly(entity this, float maxspd_mod)
-{
-       // noclipping or flying
-       UNSET_ONGROUND(this);
-
-       this.velocity = this.velocity * (1 - PHYS_INPUT_TIMELENGTH * PHYS_FRICTION(this));
-       makevectors(this.v_angle);
-       //wishvel = v_forward * this.movement.x + v_right * this.movement.y + v_up * this.movement.z;
-       vector wishvel = v_forward * this.movement.x
-                                       + v_right * this.movement.y
-                                       + '0 0 1' * this.movement.z;
-       // acceleration
-       vector wishdir = normalize(wishvel);
-       float wishspeed = min(vlen(wishvel), PHYS_MAXSPEED(this) * maxspd_mod);
-#ifdef SVQC
-       if(time >= PHYS_TELEPORT_TIME(this))
-#endif
-               PM_Accelerate(this, wishdir, wishspeed, wishspeed, PHYS_ACCELERATE(this) * maxspd_mod, 1, 0, 0, 0);
-       PM_ClientMovement_Move(this);
-}
-
 void PM_swim(entity this, float maxspd_mod)
 {
        // swimming
index 502657e4bcbeb52db0fa319c1c41161a21f13480..7457cb29c73bfbe296d2b7a51c42c2e0162a7102 100644 (file)
@@ -4,4 +4,7 @@ COMPONENT(phys);
 .vector com_phys_pos, com_phys_pos_prev;
 .vector com_phys_ang, com_phys_ang_prev;
 .vector com_phys_vel;
+.float com_phys_vel_max;
 .vector com_phys_acc;
+.float com_phys_acc_rate;
+.float com_phys_friction;
index 3457198c5e093d0af6d5888aaa2b11901f776ab7..27b3689c90f6355ce5b6a9dfe8d75120fbf7c965 100644 (file)
@@ -3,13 +3,14 @@
 
 .int disableclientprediction;
 
+void sys_phys_simulate(entity this, float dt);
+
 void sys_phys_update(entity this, float dt)
 {
        sys_in_update(this, dt);
 
        sys_phys_fix(this, dt);
-       if (sys_phys_override(this)) return;
-       sys_phys_monitor(this);
+       if (sys_phys_override(this)) { return; } sys_phys_monitor(this);
 
        int buttons_prev = this.buttons_old;
        this.buttons_old = PHYS_INPUT_BUTTON_MASK(this);
@@ -21,8 +22,7 @@ void sys_phys_update(entity this, float dt)
        sys_phys_pregame_hold(this);
 
        if (IS_SVQC) {
-               if (PHYS_MOVETYPE(this) == MOVETYPE_NONE) return;
-
+               if (PHYS_MOVETYPE(this) == MOVETYPE_NONE) { return; }
                // when we get here, disableclientprediction cannot be 2
                this.disableclientprediction = 0;
        }
@@ -33,11 +33,10 @@ void sys_phys_update(entity this, float dt)
 
        PM_check_blocked(this);
 
-       float maxspeed_mod = (!this.in_swamp) ? 1 : this.swamp_slowdown; // cvar("g_balance_swamp_moverate");
+       float maxspeed_mod = (!this.in_swamp) ? 1 : this.swamp_slowdown;  // cvar("g_balance_swamp_moverate");
 
 // conveyors: first fix velocity
-       if (this.conveyor.state) this.velocity -= this.conveyor.movedir;
-
+       if (this.conveyor.state) { this.velocity -= this.conveyor.movedir; }
        MUTATOR_CALLHOOK(PlayerPhysics, this);
 
        if (!IS_PLAYER(this)) {
@@ -59,8 +58,7 @@ void sys_phys_update(entity this, float dt)
                goto end;
        }
 
-       if (IS_SVQC && !PHYS_FIXANGLE(this)) this.angles = '0 1 0' * this.v_angle.y;
-
+       if (IS_SVQC && !PHYS_FIXANGLE(this)) { this.angles = '0 1 0' * this.v_angle.y; }
        if (IS_PLAYER(this)) {
                if (IS_ONGROUND(this)) {
                        PM_check_hitground(this);
@@ -88,7 +86,10 @@ void sys_phys_update(entity this, float dt)
            || PHYS_MOVETYPE(this) == MOVETYPE_FLY
            || PHYS_MOVETYPE(this) == MOVETYPE_FLY_WORLDONLY
            || MUTATOR_CALLHOOK(IsFlying, this)) {
-               PM_fly(this, maxspeed_mod);
+               this.com_phys_friction = PHYS_FRICTION(this);
+               this.com_phys_vel_max = PHYS_MAXSPEED(this) * maxspeed_mod;
+               this.com_phys_acc_rate = PHYS_ACCELERATE(this) * maxspeed_mod;
+               sys_phys_simulate(this, dt);
        } else if (this.waterlevel >= WATERLEVEL_SWIMMING) {
                PM_swim(this, maxspeed_mod);
        } else if (time < this.ladder_time) {
@@ -102,12 +103,30 @@ void sys_phys_update(entity this, float dt)
        }
 
        LABEL(end)
-       if (IS_ONGROUND(this)) this.lastground = time;
-
+       if (IS_ONGROUND(this)) { this.lastground = time; }
 // conveyors: then break velocity again
-       if (this.conveyor.state) this.velocity += this.conveyor.movedir;
-
+       if (this.conveyor.state) { this.velocity += this.conveyor.movedir; }
        this.lastflags = this.flags;
 
        this.lastclassname = this.classname;
 }
+
+void sys_phys_simulate(entity this, float dt)
+{
+       // noclipping or flying
+       UNSET_ONGROUND(this);
+
+       this.velocity = this.velocity * (1 - dt * this.com_phys_friction);
+       makevectors(this.v_angle);
+       // wishvel = v_forward * this.movement.x + v_right * this.movement.y + v_up * this.movement.z;
+       vector wishvel = v_forward * this.movement.x
+           + v_right * this.movement.y
+           + '0 0 1' * this.movement.z;
+       // acceleration
+       vector wishdir = normalize(wishvel);
+       float wishspeed = min(vlen(wishvel), this.com_phys_vel_max);
+       if (IS_CSQC || time >= PHYS_TELEPORT_TIME(this)) {
+               PM_Accelerate(this, wishdir, wishspeed, wishspeed, this.com_phys_acc_rate, 1, 0, 0, 0);
+       }
+       PM_ClientMovement_Move(this);
+}
index 692cb06eef295d5f2c7f2e20c73182b735722743..b598727223ee7321209bbc9360e9d32cd833a565 100644 (file)
@@ -1570,27 +1570,27 @@ nl_between_annotation                    = ignore   # ignore/add/remove/force
 #
 
 # Add or remove braces on single-line 'do' statement
-mod_full_brace_do                        = add      # ignore/add/remove/force
+mod_full_brace_do                        = force    # ignore/add/remove/force
 
 # Add or remove braces on single-line 'for' statement
 # NOTE: is 3 worse than ignore
-mod_full_brace_for                       = remove   # ignore/add/remove/force
+mod_full_brace_for                       = force    # ignore/add/remove/force
 
 # Add or remove braces on single-line function definitions. (Pawn)
 mod_full_brace_function                  = ignore   # ignore/add/remove/force #ignore
 
 # Add or remove braces on single-line 'if' statement. Will not remove the braces if they contain an 'else'.
-mod_full_brace_if                        = add      # ignore/add/remove/force
+mod_full_brace_if                        = force    # ignore/add/remove/force
 
 # Make all if/elseif/else statements in a chain be braced or not. Overrides mod_full_brace_if.
 # If any must be braced, they are all braced.  If all can be unbraced, then the braces are removed.
-mod_full_brace_if_chain                  = true     # false/true #force
+mod_full_brace_if_chain                  = false    # false/true #force
 
 # Don't remove braces around statements that span N newlines
 mod_full_brace_nl                        = 2        # number #force
 
 # Add or remove braces on single-line 'while' statement
-mod_full_brace_while                     = remove   # ignore/add/remove/force
+mod_full_brace_while                     = force    # ignore/add/remove/force
 
 # Add or remove braces on single-line 'using ()' statement
 # WARNING: Code doesn't seem to use this feature - delete from the config?