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

Method M_CheckBottom

game/src/main/java/jake2/game/M.java:84–146  ·  view source on GitHub ↗

Returns false if any part of the bottom of the entity is off an edge that is not a staircase.

(edict_t ent, GameExportsImpl gameExports)

Source from the content-addressed store, hash-verified

82 * is not a staircase.
83 */
84 public static boolean M_CheckBottom(edict_t ent, GameExportsImpl gameExports) {
85 float[] mins = { 0, 0, 0 };
86 float[] maxs = { 0, 0, 0 };
87 float[] start = { 0, 0, 0 };
88 float[] stop = { 0, 0, 0 };
89
90 trace_t trace;
91 int x, y;
92 float mid, bottom;
93
94 Math3D.VectorAdd(ent.s.origin, ent.mins, mins);
95 Math3D.VectorAdd(ent.s.origin, ent.maxs, maxs);
96
97 // if all of the points under the corners are solid world, don't bother
98 // with the tougher checks
99 // the corners must be within 16 of the midpoint
100 start[2] = mins[2] - 1;
101 for (x = 0; x <= 1; x++)
102 for (y = 0; y <= 1; y++) {
103 start[0] = x != 0 ? maxs[0] : mins[0];
104 start[1] = y != 0 ? maxs[1] : mins[1];
105 if (gameExports.gameImports.getPointContents(start) != Defines.CONTENTS_SOLID) {
106 //
107 // check it for real...
108 //
109 start[2] = mins[2];
110
111 // the midpoint must be within 16 of the bottom
112 start[0] = stop[0] = (mins[0] + maxs[0]) * 0.5f;
113 start[1] = stop[1] = (mins[1] + maxs[1]) * 0.5f;
114 stop[2] = start[2] - 2 * GameBase.STEPSIZE;
115 trace = gameExports.gameImports.trace(start, Globals.vec3_origin,
116 Globals.vec3_origin, stop, ent,
117 Defines.MASK_MONSTERSOLID);
118
119 if (trace.fraction == 1.0)
120 return false;
121 mid = bottom = trace.endpos[2];
122
123 // the corners must be within 16 of the midpoint
124 for (x = 0; x <= 1; x++)
125 for (y = 0; y <= 1; y++) {
126 start[0] = stop[0] = x != 0 ? maxs[0] : mins[0];
127 start[1] = stop[1] = y != 0 ? maxs[1] : mins[1];
128
129 trace = gameExports.gameImports.trace(start,
130 Globals.vec3_origin, Globals.vec3_origin,
131 stop, ent, Defines.MASK_MONSTERSOLID);
132
133 if (trace.fraction != 1.0
134 && trace.endpos[2] > bottom)
135 bottom = trace.endpos[2];
136 if (trace.fraction == 1.0
137 || mid - trace.endpos[2] > GameBase.STEPSIZE)
138 return false;
139 }
140
141 return true;

Callers 4

SV_Physics_StepMethod · 0.95
SV_movestepMethod · 0.95
SV_NewChaseDirMethod · 0.95
touchMethod · 0.95

Calls 3

VectorAddMethod · 0.95
getPointContentsMethod · 0.65
traceMethod · 0.65

Tested by

no test coverage detected