Skip to content

AcresCoreTerrain.h#

Core/Source/AcresCoreTerrain.h Generated

The ACRE survey terrain as the game's wheels see it: the corner heights of heights.f32 (1001 x 1001 float32 on the 1.524 m survey grid of site.json), each cell split into two triangles along its anti-diagonal, exactly as the triangulated collision mesh the wheel traces hit (AAcresVehiclePawn::AcreHeight, checked against the mesh to 1 cm by VerifyAcreTerrain). Heights, face normals and ray casts are exact on that mesh.

Frames: the Core's ENU metres (x east, y north). The grid is indexed as in the game, cell u east and v south from the tile's north-west corner: u = (x - x0) / step, v = (-y - y0) / step with site.json grid_x0_m, grid_y0_m (Unreal X east, Y south). Read-only after Load, so any number of threads may query it.

FRayHit#

struct FRayHit

Ray hit on a surface.

Name Type Unit Default Description
T double 0 Distance along the ray (in units of the direction's length), m for a unit direction.
Point, Normal FVec3 Hit point and the face's unit normal (pointing against the ray's side of the surface for the terrain: up).

FAcresTerrain#

class FAcresTerrain

Triangulated height field of the ACRE tile.

Name Type Unit Default Description
X0, Y0, Step double Grid geometry: Unreal grid_x0_m / grid_y0_m (north-west corner, X east, Y south), cell size (m), cells per side.
Heights std::vector<float> Corner heights, (Width + 1) x (Height + 1), row v, column u.

FAcresTerrain::Load#

Reads site.json (grid geometry) and heights.f32 from a Content/Simulation/ACRE folder.

Argument Description
AcreDirectory The folder holding site.json and heights.f32.
Error Why it failed (may be null).

Returns: True on success.

bool Load(const std::string& AcreDirectory, std::string* Error = nullptr);

FAcresTerrain::MakeFlat#

A flat plane at height Z over a square of HalfSizeM around the origin (tests, the log replays on flat ground).

void MakeFlat(double Z = 0, double HalfSizeM = 2000, double StepM = 10);

FAcresTerrain::HeightAt#

Height of the surface at a point, m (the game's AcreHeight; points outside the grid take the edge cell's triangles, clamped as the game does).

double HeightAt(double X, double Y) const;

FAcresTerrain::NormalAt#

Unit up-facing normal of the triangle under a point.

FVec3 NormalAt(double X, double Y) const;

FAcresTerrain::RayCast#

First intersection of a ray with the triangulated surface, from either side.

Argument Description
Origin Ray start, world m.
Direction Ray direction (any length; T is in its units).
MaxT Farthest T to search.
Hit Receives the hit.

Returns: True when the ray hits the surface inside the grid within MaxT.

bool RayCast(const FVec3& Origin, const FVec3& Direction, double MaxT, FRayHit& Hit) const;

FAcresTerrain::Inside#

True when a point lies over the grid, with a margin in m (positive: inside by at least that much).

bool Inside(double X, double Y, double MarginM = 0) const;

FAcresTerrain::ToGrid#

Grid coordinates (u east, v south, cells) of a world point, and back.

void ToGrid(double X, double Y, double& U, double& V) const ;