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

Method M_CheckGround

game/src/main/java/jake2/game/M.java:42–78  ·  view source on GitHub ↗
(SubgameEntity ent, GameExportsImpl gameExports)

Source from the content-addressed store, hash-verified

40public final class M {
41
42 public static void M_CheckGround(SubgameEntity ent, GameExportsImpl gameExports) {
43 float[] point = { 0, 0, 0 };
44
45 if ((ent.flags & (GameDefines.FL_SWIM | GameDefines.FL_FLY)) != 0)
46 return;
47
48 if (ent.velocity[2] > 100) {
49 ent.groundentity = null;
50 return;
51 }
52
53 // if the hull point one-quarter unit down is solid the entity is on
54 // ground
55 point[0] = ent.s.origin[0];
56 point[1] = ent.s.origin[1];
57 point[2] = ent.s.origin[2] - 0.25f;
58
59 trace_t trace = gameExports.gameImports.trace(ent.s.origin, ent.mins, ent.maxs, point, ent,
60 Defines.MASK_MONSTERSOLID);
61
62 // check steepness
63 if (trace.plane.normal[2] < 0.7 && !trace.startsolid) {
64 ent.groundentity = null;
65 return;
66 }
67
68 // ent.groundentity = trace.ent;
69 // ent.groundentity_linkcount = trace.ent.linkcount;
70 // if (!trace.startsolid && !trace.allsolid)
71 // VectorCopy (trace.endpos, ent.s.origin);
72 if (!trace.startsolid && !trace.allsolid) {
73 Math3D.VectorCopy(trace.endpos, ent.s.origin);
74 ent.groundentity = trace.ent;
75 ent.groundentity_linkcount = trace.ent.linkcount;
76 ent.velocity[2] = 0;
77 }
78 }
79
80 /**
81 * Returns false if any part of the bottom of the entity is off an edge that

Callers 4

SV_Physics_StepMethod · 0.95
G_RunFrameMethod · 0.95
thinkMethod · 0.95
thinkMethod · 0.95

Calls 2

VectorCopyMethod · 0.95
traceMethod · 0.65

Tested by

no test coverage detected