MCPcopy Create free account
hub / github.com/demoth/jake2 / PM_SnapPosition

Method PM_SnapPosition

qcommon/src/main/java/jake2/qcommon/PMove.java:913–948  ·  view source on GitHub ↗

On exit, the origin will have a value that is pre-quantized to the 0.125 precision of the network channel and in a valid position.

()

Source from the content-addressed store, hash-verified

911 */
912
913 public static void PM_SnapPosition() {
914 int sign[] = { 0, 0, 0 };
915 int i, j, bits;
916 short base[] = { 0, 0, 0 };
917
918 // snap velocity to eigths
919 for (i = 0; i < 3; i++)
920 pm.s.velocity[i] = (short) (pml.velocity[i] * 8);
921
922 for (i = 0; i < 3; i++) {
923 if (pml.origin[i] >= 0)
924 sign[i] = 1;
925 else
926 sign[i] = -1;
927 pm.s.origin[i] = (short) (pml.origin[i] * 8);
928 if (pm.s.origin[i] * 0.125 == pml.origin[i])
929 sign[i] = 0;
930 }
931 Math3D.VectorCopy(pm.s.origin, base);
932
933 // try all combinations
934 for (j = 0; j < 8; j++) {
935 bits = jitterbits[j];
936 Math3D.VectorCopy(base, pm.s.origin);
937 for (i = 0; i < 3; i++)
938 if ((bits & (1 << i)) != 0)
939 pm.s.origin[i] += sign[i];
940
941 if (PM_GoodPosition())
942 return;
943 }
944
945 // go back to the last position
946 Math3D.VectorCopy(pml.previous_origin, pm.s.origin);
947 // Com.DPrintf("using previous_origin\n");
948 }
949
950 /**
951 * Snaps the origin of the player move to 0.125 grid.

Callers 1

PmoveMethod · 0.95

Calls 2

VectorCopyMethod · 0.95
PM_GoodPositionMethod · 0.95

Tested by

no test coverage detected