Table of Contents

Class NwcSpatialIndex

Namespace
NwcIO.Model.Spatial
Assembly
NwcIO.dll

A fast 3D Bounding Volume Hierarchy (BVH) spatial index over polygon meshes, enabling sub-millisecond bounding box queries, raycasting, and element selection.

public sealed class NwcSpatialIndex

Inheritance

Inherited Members

Constructors

NwcSpatialIndex(IReadOnlyList<NwcMesh>)

public NwcSpatialIndex(IReadOnlyList<NwcMesh> meshes)

Parameters

meshes IReadOnlyList<NwcMesh>

Properties

Bounds

public BoundingBox3d Bounds { get; }

Property Value

BoundingBox3d

LeafCount

public int LeafCount { get; }

Property Value

int

MaxDepth

public int MaxDepth { get; }

Property Value

int

MeshCount

public int MeshCount { get; }

Property Value

int

NodeCount

public int NodeCount { get; }

Property Value

int

Methods

IntersectTriangle(Vector3d, Vector3d, Vector3d, Vector3d, Vector3d, out double, out Vector3d)

Möller–Trumbore ray-triangle intersection algorithm.

public static bool IntersectTriangle(Vector3d origin, Vector3d dir, Vector3d v0, Vector3d v1, Vector3d v2, out double t, out Vector3d normal)

Parameters

origin Vector3d
dir Vector3d
v0 Vector3d
v1 Vector3d
v2 Vector3d
t double
normal Vector3d

Returns

bool

QueryBox(BoundingBox3d)

Finds all meshes whose world bounding box intersects box.

public IReadOnlyList<NwcMesh> QueryBox(BoundingBox3d box)

Parameters

box BoundingBox3d

Returns

IReadOnlyList<NwcMesh>

Raycast(Vector3d, Vector3d, out RaycastHit, double)

Performs a 3D raycast and returns the closest geometric intersection hit, if any.

public bool Raycast(Vector3d origin, Vector3d direction, out RaycastHit hit, double maxDistance = Infinity)

Parameters

origin Vector3d
direction Vector3d
hit RaycastHit
maxDistance double

Returns

bool

RaycastAll(Vector3d, Vector3d, double)

Performs a 3D raycast and returns all geometric intersections sorted by distance.

public IReadOnlyList<RaycastHit> RaycastAll(Vector3d origin, Vector3d direction, double maxDistance = Infinity)

Parameters

origin Vector3d
direction Vector3d
maxDistance double

Returns

IReadOnlyList<RaycastHit>