FScanBvh
The deterministic scan hierarchy (§29 A2). Shots replicate, not points, so every client re-traces every shot — and the cloud a player sees is only shared if every client's trace returns the same hits bit for bit. Jolt and Embree cannot promise that: they are float hierarchies built in an order that follows the ECS iteration and the thread schedule, and the two of them do not even generate the same rays.
- Module
- Game
- Header
#include "PointCloud/ScanBvh.h"- Namespace
Mowo
This one is canonical by construction: - vertices are snapped to a 1/1024 m grid as they are added, so every coordinate is exactly representable and the build never sees two machines' transform round-off; - triangles are sorted by a content key (Morton code of the snapped centroid, then the snapped vertices, then the tag), so the hierarchy is the same whatever order the level's meshes were added in; - traversal reports the nearest hit with ties broken by that canonical triangle index, so neither child order nor thread count changes a result; - a shot's rays are cast in parallel but written per ray index.
Static geometry is built once; moving bodies go into a second hierarchy rebuilt each Sync from their current transforms, deterministic as long as the transforms themselves are the replicated state.
Properties
| Type | Name | Description |
|---|---|---|
static constexpr float | kGridPerMetre | Default 1024.0f. |
static constexpr uint32_t | kLeafSize | Default 4. |
Public functions
| Returns | Name | Description |
|---|---|---|
void | Clear | |
void | AddMesh | Appends a mesh's triangles, transformed to world space and snapped. |
void | Build | |
bool | IsBuilt | |
uint32_t | TriangleCount | |
uint32_t | NodeCount | |
uint64_t | ContentHash | FNV-1a over the canonical triangle list: two machines whose hashes match trace the same geometry. |
bool | Intersect | Nearest hit with t in (tMin, tMax). |
float | SnapCoordinate |
Function details
Clear
void Clear()AddMesh
void AddMesh(const std::vector<Vec3>& positions, const std::vector<uint32_t>& indices, const Mat4& toWorld, FScanTag tag, uint32_t instanceId, bool dynamic, bool character = false)Appends a mesh's triangles, transformed to world space and snapped. Degenerate triangles (zero area after snapping) are dropped.
Build
void Build()IsBuilt
bool IsBuilt() constTriangleCount
uint32_t TriangleCount() constNodeCount
uint32_t NodeCount() constContentHash
uint64_t ContentHash() constFNV-1a over the canonical triangle list: two machines whose hashes match trace the same geometry. Valid after Build.
Intersect
bool Intersect(const Vec3& origin, const Vec3& direction, float tMin, float tMax, FScanBvhHit& out) constNearest hit with t in (tMin, tMax).
SnapCoordinate
static float SnapCoordinate(float metres)