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

Method GetSurfaceTriangleID

TombEngine/Game/collision/floordata.cpp:39–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37int BridgeCacheSlotID = 0;
38
39int FloorInfo::GetSurfaceTriangleID(int x, int z, bool isFloor) const
40{
41 constexpr auto TRI_ID_0 = 0;
42 constexpr auto TRI_ID_1 = 1;
43
44 static const auto ROT_MATRIX_0 = Matrix::CreateRotationZ(TO_RAD(SectorSurfaceData::SPLIT_ANGLE_0));
45 static const auto ROT_MATRIX_1 = Matrix::CreateRotationZ(TO_RAD(SectorSurfaceData::SPLIT_ANGLE_1));
46
47 // Get matrix.
48 const auto& rotMatrix = isFloor ?
49 ((FloorSurface.SplitAngle == SectorSurfaceData::SPLIT_ANGLE_0) ? ROT_MATRIX_0 : ROT_MATRIX_1) :
50 ((CeilingSurface.SplitAngle == SectorSurfaceData::SPLIT_ANGLE_0) ? ROT_MATRIX_0 : ROT_MATRIX_1);
51
52 // Calculate bias.
53 auto sectorPoint = GetSectorPoint(x, z).ToVector2();
54 float bias = Vector2::Transform(sectorPoint, rotMatrix).x;
55
56 // Return triangle ID according to bias.
57 return ((bias < 0.0f) ? TRI_ID_0 : TRI_ID_1);
58}
59
60const SectorSurfaceTriangleData& FloorInfo::GetSurfaceTriangle(int x, int z, bool isFloor) const
61{

Callers 1

GetNearestLedgeAngleFunction · 0.80

Calls 3

TO_RADFunction · 0.85
GetSectorPointFunction · 0.85
ToVector2Method · 0.45

Tested by

no test coverage detected