MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / TestJumpSetup

Function TestJumpSetup

TombEngine/Game/Lara/PlayerContext.cpp:820–862  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

818 }
819
820 static bool TestJumpSetup(const ItemInfo& item, const CollisionInfo& coll, const JumpSetupData& setup)
821 {
822 const auto& player = GetLaraInfo(item);
823
824 bool isWading = setup.TestWadeStatus ? (player.Control.WaterStatus == WaterStatus::Wade) : false;
825 bool isInSwamp = TestEnvironment(ENV_FLAG_SWAMP, &item);
826
827 // 1) Check for swamp or wade status (if applicable).
828 if (isWading || isInSwamp)
829 return false;
830
831 // 2) Check for corner.
832 if (TestLaraFacingCorner(&item, setup.HeadingAngle, setup.Distance))
833 return false;
834
835 // Prepare data for static object LOS.
836 // TODO: Lock-up occurs.
837 /*auto origin = Geometry::TranslatePoint(item.Pose.Position.ToVector3(), item.Pose.Orientation.y, OFFSET_RADIUS(coll.Setup.Radius));
838 auto target = origin + Vector3(0.0f,-STEPUP_HEIGHT, 0.0f);
839 auto dir = target - origin;
840 dir.Normalize();
841
842 // 3) Assess ray-static collision.
843 auto staticLos = GetStaticObjectLos(origin, item.RoomNumber, dir, Vector3::Distance(origin, target), false);
844 if (staticLos.has_value())
845 return false;*/
846
847 // Get point collision.
848 auto pointColl = GetPointCollision(item, setup.HeadingAngle, setup.Distance, -coll.Setup.Height);
849 int relFloorHeight = pointColl.GetFloorHeight() - item.Pose.Position.y;
850 int relCeilHeight = pointColl.GetCeilingHeight() - item.Pose.Position.y;
851
852 // 4) Assess point collision.
853 if (relFloorHeight >= -STEPUP_HEIGHT && // Floor is within highest floor bound.
854 (relCeilHeight < -(coll.Setup.Height + (LARA_HEADROOM * 0.8f)) || // Ceiling is within lowest ceiling bound.
855 (relCeilHeight < -coll.Setup.Height && // OR ceiling is level with Lara's head.
856 relFloorHeight >= CLICK(0.5f)))) // AND there is a drop below.
857 {
858 return true;
859 }
860
861 return false;
862 }
863
864 bool CanJumpUp(const ItemInfo& item, const CollisionInfo& coll)
865 {

Callers 4

CanJumpUpFunction · 0.85
CanRunJumpForwardFunction · 0.85
CanSprintJumpForwardFunction · 0.85

Calls 5

TestEnvironmentFunction · 0.85
TestLaraFacingCornerFunction · 0.85
GetPointCollisionFunction · 0.85
GetFloorHeightMethod · 0.45
GetCeilingHeightMethod · 0.45

Tested by

no test coverage detected