PM_FlyMove.
(boolean doclip)
| 748 | * PM_FlyMove. |
| 749 | */ |
| 750 | public static void PM_FlyMove(boolean doclip) { |
| 751 | float speed, drop, friction, control, newspeed; |
| 752 | float currentspeed, addspeed, accelspeed; |
| 753 | int i; |
| 754 | float[] wishvel = { 0, 0, 0 }; |
| 755 | float fmove, smove; |
| 756 | float[] wishdir = { 0, 0, 0 }; |
| 757 | float wishspeed; |
| 758 | float[] end = { 0, 0, 0 }; |
| 759 | trace_t trace; |
| 760 | |
| 761 | pm.viewheight = 22; |
| 762 | |
| 763 | // friction |
| 764 | |
| 765 | speed = Math3D.VectorLength(pml.velocity); |
| 766 | if (speed < 1) { |
| 767 | Math3D.VectorCopy(Globals.vec3_origin, pml.velocity); |
| 768 | } else { |
| 769 | drop = 0; |
| 770 | |
| 771 | friction = pm_friction * 1.5f; // extra friction |
| 772 | control = speed < pm_stopspeed ? pm_stopspeed : speed; |
| 773 | drop += control * friction * pml.frametime; |
| 774 | |
| 775 | // scale the velocity |
| 776 | newspeed = speed - drop; |
| 777 | if (newspeed < 0) |
| 778 | newspeed = 0; |
| 779 | newspeed /= speed; |
| 780 | |
| 781 | Math3D.VectorScale(pml.velocity, newspeed, pml.velocity); |
| 782 | } |
| 783 | |
| 784 | // accelerate |
| 785 | fmove = pm.cmd.forwardmove; |
| 786 | smove = pm.cmd.sidemove; |
| 787 | |
| 788 | Math3D.VectorNormalize(pml.forward); |
| 789 | Math3D.VectorNormalize(pml.right); |
| 790 | |
| 791 | for (i = 0; i < 3; i++) |
| 792 | wishvel[i] = pml.forward[i] * fmove + pml.right[i] |
| 793 | * smove; |
| 794 | wishvel[2] += pm.cmd.upmove; |
| 795 | |
| 796 | Math3D.VectorCopy(wishvel, wishdir); |
| 797 | wishspeed = Math3D.VectorNormalize(wishdir); |
| 798 | |
| 799 | // clamp to server defined max speed |
| 800 | if (wishspeed > pm_maxspeed) { |
| 801 | Math3D.VectorScale(wishvel, pm_maxspeed / wishspeed, wishvel); |
| 802 | wishspeed = pm_maxspeed; |
| 803 | } |
| 804 | |
| 805 | currentspeed = Math3D.DotProduct(pml.velocity, wishdir); |
| 806 | addspeed = wishspeed - currentspeed; |
| 807 | if (addspeed <= 0) |
no test coverage detected