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

Function ConvertFakePlaneToPlane

TombEngine/Specific/level.cpp:837–849  ·  view source on GitHub ↗

The way floordata "planes" were previously stored was non-standard. Instead of a Plane object with a normal + distance, they used a Vector3 object with data laid out as follows: x: X tilt grade (0.25f = 1/4 block). y: Z tilt grade (0.25f = 1/4 block). z: Plane's absolute height at the sector's center (i.e. distance in regular plane terms).

Source from the content-addressed store, hash-verified

835// y: Z tilt grade (0.25f = 1/4 block).
836// z: Plane's absolute height at the sector's center (i.e. distance in regular plane terms).
837static Plane ConvertFakePlaneToPlane(const Vector3& fakePlane, bool isFloor)
838{
839 // Calculate normal from tilt grades.
840 int sign = isFloor ? -1 : 1;
841 auto normal = Vector3(-fakePlane.x, 1.0f, -fakePlane.y) * sign;
842 normal.Normalize();
843
844 // Determine distance.
845 float dist = fakePlane.z;
846
847 // Return plane.
848 return Plane(normal, dist);
849}
850
851void LoadDynamicRoomData()
852{

Callers 1

LoadStaticRoomDataFunction · 0.85

Calls 2

Vector3Function · 0.50
NormalizeMethod · 0.45

Tested by

no test coverage detected