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

Method PM_StepSlideMove

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

Each intersection will try to step over the obstruction instead of sliding along it. Returns a new origin, velocity, and contact entity. Does not modify any world state?

()

Source from the content-addressed store, hash-verified

225 * Does not modify any world state?
226 */
227 public static void PM_StepSlideMove() {
228 float[] start_o = { 0, 0, 0 }, start_v = { 0, 0, 0 };
229 float[] down_o = { 0, 0, 0 }, down_v = { 0, 0, 0 };
230 trace_t trace;
231 float down_dist, up_dist;
232 // float [] delta;
233 float[] up = { 0, 0, 0 }, down = { 0, 0, 0 };
234
235 Math3D.VectorCopy(pml.origin, start_o);
236 Math3D.VectorCopy(pml.velocity, start_v);
237
238 PM_StepSlideMove_();
239
240 Math3D.VectorCopy(pml.origin, down_o);
241 Math3D.VectorCopy(pml.velocity, down_v);
242
243 Math3D.VectorCopy(start_o, up);
244 up[2] += Defines.STEPSIZE;
245
246 trace = pm.trace.trace(up, pm.mins, pm.maxs, up);
247 if (trace.allsolid)
248 return; // can't step up
249
250 // try sliding above
251 Math3D.VectorCopy(up, pml.origin);
252 Math3D.VectorCopy(start_v, pml.velocity);
253
254 PM_StepSlideMove_();
255
256 // push down the final amount
257 Math3D.VectorCopy(pml.origin, down);
258 down[2] -= Defines.STEPSIZE;
259 trace = pm.trace.trace(pml.origin, pm.mins,
260 pm.maxs, down);
261 if (!trace.allsolid) {
262 Math3D.VectorCopy(trace.endpos, pml.origin);
263 }
264
265 Math3D.VectorCopy(pml.origin, up);
266
267 // decide which one went farther
268 down_dist = (down_o[0] - start_o[0]) * (down_o[0] - start_o[0])
269 + (down_o[1] - start_o[1]) * (down_o[1] - start_o[1]);
270 up_dist = (up[0] - start_o[0]) * (up[0] - start_o[0])
271 + (up[1] - start_o[1]) * (up[1] - start_o[1]);
272
273 if (down_dist > up_dist || trace.plane.normal[2] < Defines.MIN_STEP_NORMAL) {
274 Math3D.VectorCopy(down_o, pml.origin);
275 Math3D.VectorCopy(down_v, pml.velocity);
276 return;
277 }
278 //!! Special case
279 // if we were walking along a plane, then we need to copy the Z over
280 pml.velocity[2] = down_v[2];
281 }
282
283 /**
284 * Handles both ground friction and water friction.

Callers 3

PM_WaterMoveMethod · 0.95
PM_AirMoveMethod · 0.95
PmoveMethod · 0.95

Calls 3

VectorCopyMethod · 0.95
PM_StepSlideMove_Method · 0.95
traceMethod · 0.65

Tested by

no test coverage detected