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

Function IsNextSectorValid

TombEngine/Game/misc.cpp:21–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19}
20
21bool IsNextSectorValid(const ItemInfo& item, const Vector3& dir, float dist, bool canFloat)
22{
23 auto projectedPos = Geometry::TranslatePoint(item.Pose.Position, dir, dist);
24 auto pointColl = GetPointCollision(item.Pose.Position, item.RoomNumber, dir, dist);
25 int height = GameBoundingBox(&item).GetHeight();
26
27 // TODO: Use floor normal directly.
28 auto floorTilt = GetSurfaceTilt(pointColl.GetFloorNormal(), true);
29
30 // Test for wall.
31 if (pointColl.GetSector().IsWall(projectedPos.x, projectedPos.z))
32 return false;
33
34 // Test for slippery slope.
35 if (pointColl.IsSteepFloor())
36 return false;
37
38 // Flat floor.
39 if ((abs(floorTilt.x) == 0 && abs(floorTilt.y) == 0))
40 {
41 // Test for step.
42 int relFloorHeight = abs(pointColl.GetFloorHeight() - item.Pose.Position.y);
43 if (relFloorHeight >= CLICK(1) && item.Pose.Position.y >= pointColl.GetFloorHeight() && canFloat)
44 {
45 return false;
46 }
47 else if (relFloorHeight >= CLICK(1) && !canFloat)
48 {
49 return false;
50 }
51 }
52 // Sloped floor.
53 else
54 {
55 // Half block.
56 int relFloorHeight = abs(pointColl.GetFloorHeight() - item.Pose.Position.y);
57 if (relFloorHeight > CLICK(1) && canFloat)
58 {
59 return false;
60 }
61 else if (relFloorHeight > CLICK(2) && !canFloat)
62 {
63 return false;
64 }
65
66 short slopeAngle = ANGLE(0.0f);
67 if (floorTilt.x > 0)
68 {
69 slopeAngle = ANGLE(-90.0f);
70 }
71 else if (floorTilt.x < 0)
72 {
73 slopeAngle = ANGLE(90.0f);
74 }
75
76 if (floorTilt.y > 0 && floorTilt.y > abs(floorTilt.x))
77 {
78 slopeAngle = ANGLE(180.0f);

Callers 2

ControlSquishyBlockFunction · 0.85

Calls 14

TranslatePointFunction · 0.85
GetPointCollisionFunction · 0.85
GetSurfaceTiltFunction · 0.85
ANGLEFunction · 0.85
phd_atanFunction · 0.85
GetShortestAngleFunction · 0.85
GetHeightMethod · 0.80
IsDiagonalFloorStepMethod · 0.80
GameBoundingBoxClass · 0.70
GetFloorNormalMethod · 0.45
IsWallMethod · 0.45
IsSteepFloorMethod · 0.45

Tested by

no test coverage detected