Skip to content

Conversation

@BSali
Copy link

@BSali BSali commented Feb 1, 2026

This Pull request:

Introduce navigation functionality for TGeoTessellated using triangle-ray-intersection tests.

This is the navigation functionality as it is implemented for the historically grown, non-ROOT-implementation TGeoArbN.
To improve usability in VMC based simulations of meshes with high triangle count (>500), partitioning structures in the form of an Octree, as well as a BVH (using the bvh library included in root), are added. We found so far that the choice of partitioning structures seems to be mesh dependent (often BVH is best, however, for some particularly large meshes (~250k triangles) the Octree seems better). However, our BVH usage may be suboptimal.

As Dr. Sandro Wenzel opened a pull-request for his navigation implementation Add BVH-based navigation functions to TGeoTessellated #21045, we wanted to "offer" our implementation in parallel. Maybe something can be learned from it.

Tested using TGeoChecker CheckShape functionality (on a box mesh, the teddy.obj in tutorials/visualisation/geom/ contains triangle-intersections and hence is faulty), as well as by computing navigation information for 100 million random points for a box mesh and comparing results with TGeoBBox as quick test that no errors were introduced while translating our TGeoArbN to ROOT's TGeoTessellated.

Dr. Sandro Wenzel's 'rayTriangle' implementation was used to improve own implementation of Triangle ray intersection in TGeoTriangle.

Still required changes:

// #if __has_include(<span>)
// #include <span>
// #else
// Falling back to ROOT span
#include "ROOT/span.hxx"
// #endif

to compile for me, otherwise issues with std.span and modules

  • I had to reintroduce 'Physics' to geom's dependencies to be able to use TVector3.h again. Change to Math::ROOT::XYZVector may be required.
  • Squash commits

Ben Salisbury added 6 commits February 1, 2026 19:08
Implementation of TGeoTessellated navigation functionality
using triangle-ray-intersection similar to GEANT4 G4TessellatedSolid.

Due to low simulation speeds for meshes of high triangle count, additional
partitioning structures such as an Octree and the BVH (using the bvh library
included in ROOT) can be used to reduce required simulation time.
Here, the most benefitial partitioning structure seems to be mesh
dependent. However, the usage of the BVH functionality is potentially
not optimal and may require more intense testing.

First comparisons from the CBM collaboration indicate that this
implementation approach (including the Octree) is more time
consuming than the VecGeom implementation for tessellated
shapes (DOI: 10.1051/epjconf/202533701268).

All usage modes (without partitioning structure and with) have been
regularly tested against TGeoBBox navigation results by simulations
of boxes with geant3/4_vmc TVirtualMCApplications and it is being
actively used in simulations.

Add TGeoVector3 include to TGeoTypedefs.h

Add Tessellated helper classes

REQUIRES REVERT: changed top_down_sah_builder.h to only include ROOT/span.hxx

Changed TGeoTessellated to TGeoArbN code

Adjusted ROOT classes to Tessellated changes

Add DOI to TGeoTessellated.cxx

Fix up constness of TGeoTessellated::ComputeNormal

Remove TGeoFacet from LinkDef1.h

Removes "Warning: Unused class rule: TGeoFacet"

Remove overriding TPartitioningI::Print

fix compile time warnings concerning TGDMLWrite size_t/int cast

Add Reference for AABB-triangle overlap test

Fix TGeoTessellated in tutorial scripts

Fix: After resizing recompute triangle center

Fixup spacing in TGeoTessellated::InspectShape

TGeoTessellated add default implementations for minor TGeoShape functions

Add DistancetoPrimitive,  SavePrimitive and Sizeof3D default implementations.

Adjust Octree tolerance to determine  directions parallel to axis

The Revelles Octree Traversal approach requires a tolerance value to determine if a direction is parallel to Octree axis. If a direction component is smaller than this value, this will be interpreted to be 0. If a particle is tracked close to a octant boundary, this can be problematic, as the wrong octant can be chosen to be traversed next. This is a minute effect, never encountered before, but seen by tessellatedNav.C
@dpiparo
Copy link
Member

dpiparo commented Feb 2, 2026

Thanks for the proposal @BSali ! Even if this is a draft, let me comment that TVector3 is a legacy class (see the doc) and, as such, should not be used and has to be replaced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants