diff --git a/sceneObjects/DMeshSO.cs b/sceneObjects/DMeshSO.cs index 8ad35f6..c862f83 100644 --- a/sceneObjects/DMeshSO.cs +++ b/sceneObjects/DMeshSO.cs @@ -472,10 +472,7 @@ override public bool FindRayIntersection(Ray3f rayW, out SORayHit hit) if (enable_spatial == false) return false; - if (spatial == null) { - spatial = new DMeshAABBTree3(mesh); - spatial.Build(); - } + validate_spatial(); // convert ray to local FScene scene = this.GetScene(); @@ -517,10 +514,7 @@ public virtual bool FindNearest(Vector3d point, double maxDist, out SORayHit nea if (enable_spatial == false) return false; - if (spatial == null) { - spatial = new DMeshAABBTree3(mesh); - spatial.Build(); - } + validate_spatial(); // convert to local Vector3f local_pt = SceneTransforms.TransformTo((Vector3f)point, this, eInCoords, CoordSpace.ObjectCoords);