reckfellENGINE

TriangleMesh

CPU triangle BVH for local ray/segment queries.

On this page
class TriangleMeshReckfellSharpInherits RefCounted

TriangleMesh is an owned RefCounted intersection structure rather than a drawable ArrayMesh or physics body. CreateFromFaces takes a flat Vector3 array in triples rather than an index buffer. It builds a BVH snapshot: editing the source mesh/array does not update it automatically. Dispose an owned instance after use.

Build positions are snapped with snappedf(0.0001) and welded by snapped coordinates. GetFaces need not preserve input floats bit-for-bit. Account for units/scale: this is not exact arbitrary-scale microgeometry intersection.

IntersectRay takes origin plus a nonzero direction; IntersectSegment takes origin plus endpoint. Use BVH coordinates for all inputs: MeshInstance3D transforms are not applied automatically. Both return an owned Dictionary. Empty means miss or an unbuilt BVH. Hits contain position (Vector3), normal (Vector3), and face_index (int). The normal is oriented against the query rather than necessarily matching source winding. Read keys after checking Count and dispose the dictionary.

Returns the nearest accepted intersection rather than every hit, collider, UV or scene-surface list. face_index identifies a triple in the current faces input rather than an Entity/material ID. Equal-distance ties, degenerate triangles and extreme-scale accuracy were not accepted by this review.

The combined 34 headless checks covered a new empty object, building, nearest ray/segment hits, opposed normals, GetFaces copies, span rebuild and snapping. This is CPU evidence; graphics and physics-world execution were not tested.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

TriangleMeshConstructor
# TriangleMesh
C#
public TriangleMesh();

Creates an owned RefCounted without a valid BVH. GetFaces/queries return empty before building.

Methods5

CreateFromFaces2 overloads
# CreateFromFaces · 1/2
C#
public bool CreateFromFaces(Vector3[] faces);

Replaces BVH from nonempty flat Vector3 triples. Positions snap to a 0.0001 grid and equal snapped coordinates are welded. Invalid lengths are diagnosed after valid is reset; do not assume the old valid BVH survives. Array/span overloads share semantics.

Parameters
NameTypeDefault
facesVector3[]—
faces

Nonempty finite Vector3 array with length divisible by 3; every triple is a triangle, not an index list.

Returns bool

true for a valid built BVH; false does not guarantee preservation of the previous structure.

# CreateFromFaces · 2/2
C#
public bool CreateFromFaces(ReadOnlySpan<Vector3> faces);

Replaces BVH from nonempty flat Vector3 triples. Positions snap to a 0.0001 grid and equal snapped coordinates are welded. Invalid lengths are diagnosed after valid is reset; do not assume the old valid BVH survives. Array/span overloads share semantics.

Parameters
NameTypeDefault
facesReadOnlySpan<Vector3>—
faces

Nonempty finite Vector3 array with length divisible by 3; every triple is a triangle, not an index list.

Returns bool

true for a valid built BVH; false does not guarantee preservation of the previous structure.

GetFacesVector3[]
# GetFaces
C#
public Vector3[] GetFaces();

Returns a managed copy of current BVH triangle corners in triples. Coordinates are already snapped; editing the result does not mutate BVH. Empty without a valid structure.

Returns Vector3[]

New Vector3[] of corner triples, or empty.

IntersectRayReckfell.Collections.Dictionary
# IntersectRay
C#
public Reckfell.Collections.Dictionary IntersectRay(Vector3 begin, Vector3 dir);

Finds the nearest accepted forward hit from begin along nonzero dir. An infinite ray rather than segment begin→dir. Hit normal opposes the query. Uses local snapshot coordinates without physics layers or automatic Transform3D.

Parameters
NameTypeDefault
beginVector3—
dirVector3—
begin

Query origin in BVH coordinates.

dir

Nonzero ray direction, normally normalized, rather than an endpoint.

Returns Reckfell.Collections.Dictionary

Owned Dictionary: position, normal, face_index on hit, otherwise empty. Dispose after use.

IntersectSegmentReckfell.Collections.Dictionary
# IntersectSegment
C#
public Reckfell.Collections.Dictionary IntersectSegment(Vector3 begin, Vector3 end);

Finds the nearest accepted hit on finite begin→end. Returns one hit with its normal facing against travel. Not a full-body containment/overlap query.

Parameters
NameTypeDefault
beginVector3—
endVector3—
begin

Query origin in BVH coordinates.

end

Segment endpoint in BVH coordinates rather than a direction.

Returns Reckfell.Collections.Dictionary

Owned Dictionary: position, normal, face_index on hit, otherwise empty. Dispose after use.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.