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

Method SV_Physics_Toss

game/src/main/java/jake2/game/SV.java:532–622  ·  view source on GitHub ↗

Toss, bounce, and fly movement. When onground, do nothing.

(SubgameEntity ent, GameExportsImpl gameExports)

Source from the content-addressed store, hash-verified

530 * Toss, bounce, and fly movement. When onground, do nothing.
531 */
532 void SV_Physics_Toss(SubgameEntity ent, GameExportsImpl gameExports) {
533
534 float[] move = { 0, 0, 0 };
535 float[] old_origin = { 0, 0, 0 };
536
537 // regular thinking
538 SV_RunThink(ent, gameExports);
539
540 // if not a team captain, so movement will be handled elsewhere
541 if ((ent.flags & GameDefines.FL_TEAMSLAVE) != 0)
542 return;
543
544 if (ent.velocity[2] > 0)
545 ent.groundentity = null;
546
547 // check for the groundentity going away
548 if (ent.groundentity != null)
549 if (!ent.groundentity.inuse)
550 ent.groundentity = null;
551
552 // if onground, return without moving
553 if (ent.groundentity != null)
554 return;
555
556 Math3D.VectorCopy(ent.s.origin, old_origin);
557
558 SV_CheckVelocity(ent);
559
560 // add gravity
561 if (ent.movetype != GameDefines.MOVETYPE_FLY
562 && ent.movetype != GameDefines.MOVETYPE_FLYMISSILE)
563 SV_AddGravity(ent, gameExports.gameCvars.sv_gravity.value);
564
565 // move angles
566 Math3D.VectorMA(ent.s.angles, Defines.FRAMETIME, ent.avelocity,
567 ent.s.angles);
568
569 // move origin
570 Math3D.VectorScale(ent.velocity, Defines.FRAMETIME, move);
571 trace_t trace = SV_PushEntity(ent, move, gameExports);
572 if (!ent.inuse)
573 return;
574
575 if (trace.fraction < 1) {
576 float backoff;
577 if (ent.movetype == GameDefines.MOVETYPE_BOUNCE)
578 backoff = 1.5f;
579 else
580 backoff = 1;
581
582 GameBase.ClipVelocity(ent.velocity, trace.plane.normal,
583 ent.velocity, backoff);
584
585 // stop if on ground
586 if (trace.plane.normal[2] > 0.7) {
587 if (ent.velocity[2] < 60
588 || ent.movetype != GameDefines.MOVETYPE_BOUNCE) {
589 ent.groundentity = trace.ent;

Callers 1

runEntityMethod · 0.80

Calls 12

SV_RunThinkMethod · 0.95
VectorCopyMethod · 0.95
SV_CheckVelocityMethod · 0.95
SV_AddGravityMethod · 0.95
VectorMAMethod · 0.95
VectorScaleMethod · 0.95
SV_PushEntityMethod · 0.95
ClipVelocityMethod · 0.95
getPointContentsMethod · 0.65
positioned_soundMethod · 0.65
soundindexMethod · 0.65
linkentityMethod · 0.65

Tested by

no test coverage detected