HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GEO::BVHBase< NAXES, SUBCLASS > Class Template Reference

#include <GEO_BVH.h>

+ Inheritance diagram for GEO::BVHBase< NAXES, SUBCLASS >:

Classes

struct  AllHitsAndNormalsFunctor
 
struct  AllHitsFunctor
 
struct  CommonHitInfo
 
struct  HitInfo
 
struct  HitInfoAndNormal
 
struct  ItemHitInfo
 
struct  MinInfo
 
struct  SingleHitAndNormalFunctor
 
struct  SingleHitFunctor
 

Public Types

using VectorType = typename SYS_SelectType< UT_Vector2, UT_Vector3, NAXES==3 >::type
 
using UintVectorType = typename SYS_SelectType< UT_FixedVector< uint, 2 >, UT_FixedVector< uint, 3 >, NAXES==3 >::type
 
using SingleBoxType = UT::Box< float, NAXES >
 
using BoxType = UT::Box< v4uf, NAXES >
 
using PosAttribType = GA_ROHandleT< VectorType >
 
using RadAttribType = GA_ROHandleF
 

Public Member Functions

 BVHBase () noexcept
 
 ~BVHBase () noexcept
 
SYS_FORCE_INLINE bool isEmpty () const noexcept
 
template<bool farthest = false, bool rm_backface = false, bool reverse = false, typename HitInfoType >
void sendRay (const VectorType &origin, const VectorType &direction, HitInfoType &hit_info, float tmin=0, float tmax=std::numeric_limits< float >::max()) const noexcept
 
template<bool farthest = false, bool rm_backface = false, bool reverse = false, typename HitInfoType >
void sendRayRad (const VectorType &origin, const VectorType &direction, HitInfoType &hit_info, float default_radius, float tmin=0, float tmax=std::numeric_limits< float >::max()) const noexcept
 
template<bool rm_backface = false, bool reverse = false, bool sort = true, typename HitInfoType >
void sendRayAll (const VectorType &origin, const VectorType &direction, UT_Array< HitInfoType > &hit_info, UT_Array< exint > *nesting_temp_array=nullptr, float duplicate_tolerance=0, float tmin=0, float tmax=std::numeric_limits< float >::max()) const noexcept
 
template<bool rm_backface = false, bool reverse = false, bool sort = true, typename HitInfoType >
void sendRayAllRad (const VectorType &origin, const VectorType &direction, UT_Array< HitInfoType > &hit_info, float default_radius, UT_Array< exint > *nesting_temp_array=nullptr, float duplicate_tolerance=0, float tmin=0, float tmax=std::numeric_limits< float >::max()) const noexcept
 
template<bool farthest, bool rm_backface, bool reverse, typename FUNCTOR >
void sendRayGeneric (VectorType origin, VectorType direction, FUNCTOR &hit_info, float tmin=0, float tmax=std::numeric_limits< float >::max()) const noexcept
 
void findClosestToLine (VectorType origin, VectorType direction, const exint max_points, const float max_dist_squared, UT::BVHOrderedStack &output_queue) const noexcept
 Finds the closest points to the infinite line containing origin with direction direction. More...
 
void findClosestToSegment (VectorType p0, VectorType p1, const exint max_points, const float max_dist_squared, UT::BVHOrderedStack &output_queue) const noexcept
 Finds the closest points to the line segment with endpoints p0 and p1. More...
 
void findClosestInCone (VectorType origin, VectorType direction, const float angle, const exint max_points, const float max_dist_squared, UT::BVHOrderedStack &output_queue) const noexcept
 
template<bool farthest>
void findClosest (VectorType origin, MinInfo &min_info, float max_dist_squared=std::numeric_limits< float >::max()) const noexcept
 
void getIntersectingBoxes (const SingleBoxType &query_box, UT_Array< exint > &box_indices) const noexcept
 
SYS_FORCE_INLINE exint numPoints () const noexcept
 
SYS_FORCE_INLINE GA_Offset pointOffset (exint item_index) const noexcept
 
template<bool normalize = true>
VectorType getGeometricNormal (const CommonHitInfo &hit_info) const noexcept
 
void getDerivs (const CommonHitInfo &hit_info, VectorType &dP_du, VectorType &dP_dv) const noexcept
 Fills in the values of dP/du and dP/dv for the hit surface. More...
 
template<GA_AttributeOwner owner, typename T , typename DEST_T >
bool getAttribute (const CommonHitInfo &hit_info, const GA_ROHandleT< T > &attrib, const GEO_Detail &detail, DEST_T &value) const noexcept
 
SingleBoxType getBBox () const noexcept
 
template<bool normalize>
BVHBase< NAXES, SUBCLASS >
::VectorType 
getGeometricNormal (const CommonHitInfo &hit_info) const noexcept
 

Static Public Member Functions

static void pointUVWToPolar (VectorType &uvw) noexcept
 

Protected Types

using NodeData = BoxType
 

Protected Member Functions

void clear () noexcept
 
SYS_FORCE_INLINE SUBCLASS * subclass () noexcept
 
SYS_FORCE_INLINE const SUBCLASS * subclass () const noexcept
 
template<bool farthest, typename QUERY_POINT >
void findMaximalPointsCommon (const QUERY_POINT &query_point, UT::BVHOrderedStack &stack, UT::BVHOrderedStack &output_queue, exint max_points, float max_dist_squared) const noexcept
 

Protected Attributes

UT_BVH< BVH_NmyTree
 
UT_UniquePtr< BoxType[]> myNodeBoxes
 
UT_UniquePtr< UT_FixedVector
< int32, BVH_N >[]> 
myNodeNItems
 
UT_Array< VectorTypemyPositions
 Positions for points. More...
 
UT_Array< float > myRadii
 Radii for disconnected points. More...
 
PosAttribType myPosAttrib
 
RadAttribType myRadAttrib
 
GA_OffsetList myPoints
 Disconnected points. More...
 
bool myHasCurvesOrPoints
 
GA_DataId myPositionsDataId
 
GA_DataId myRadiiDataId
 

Static Protected Attributes

static constexpr uint BVH_N = 4
 

Detailed Description

template<uint NAXES, typename SUBCLASS>
class GEO::BVHBase< NAXES, SUBCLASS >

Definition at line 31 of file GEO_BVH.h.

Member Typedef Documentation

template<uint NAXES, typename SUBCLASS>
using GEO::BVHBase< NAXES, SUBCLASS >::BoxType = UT::Box<v4uf,NAXES>

Definition at line 45 of file GEO_BVH.h.

template<uint NAXES, typename SUBCLASS>
using GEO::BVHBase< NAXES, SUBCLASS >::NodeData = BoxType
protected

Definition at line 265 of file GEO_BVH.h.

template<uint NAXES, typename SUBCLASS>
using GEO::BVHBase< NAXES, SUBCLASS >::PosAttribType = GA_ROHandleT<VectorType>

Definition at line 249 of file GEO_BVH.h.

template<uint NAXES, typename SUBCLASS>
using GEO::BVHBase< NAXES, SUBCLASS >::RadAttribType = GA_ROHandleF

Definition at line 250 of file GEO_BVH.h.

template<uint NAXES, typename SUBCLASS>
using GEO::BVHBase< NAXES, SUBCLASS >::SingleBoxType = UT::Box<float,NAXES>

Definition at line 41 of file GEO_BVH.h.

template<uint NAXES, typename SUBCLASS>
using GEO::BVHBase< NAXES, SUBCLASS >::UintVectorType = typename SYS_SelectType<UT_FixedVector<uint,2>,UT_FixedVector<uint,3>,NAXES==3>::type

Definition at line 40 of file GEO_BVH.h.

template<uint NAXES, typename SUBCLASS>
using GEO::BVHBase< NAXES, SUBCLASS >::VectorType = typename SYS_SelectType<UT_Vector2,UT_Vector3,NAXES==3>::type

Definition at line 39 of file GEO_BVH.h.

Constructor & Destructor Documentation

template<uint NAXES, typename SUBCLASS>
GEO::BVHBase< NAXES, SUBCLASS >::BVHBase ( )
inlinenoexcept

Definition at line 34 of file GEO_BVH.h.

template<uint NAXES, typename SUBCLASS>
GEO::BVHBase< NAXES, SUBCLASS >::~BVHBase ( )
inlinenoexcept

Definition at line 37 of file GEO_BVH.h.

Member Function Documentation

template<uint NAXES, typename SUBCLASS >
void GEO::BVHBase< NAXES, SUBCLASS >::clear ( )
protectednoexcept

Definition at line 34 of file GEO_BVHImpl.h.

template<uint NAXES, typename SUBCLASS >
template<bool farthest>
void GEO::BVHBase< NAXES, SUBCLASS >::findClosest ( VectorType  origin,
MinInfo min_info,
float  max_dist_squared = std::numeric_limits<float>::max() 
) const
noexcept

Finds the closest (or farthest) position to origin on any surface, as long as it's within max_dist_squared. NOTE: If farthest is true, max_dist_squared is actually the minimum distance squared from the origin, so you will need to specify a value.

Definition at line 1193 of file GEO_BVHImpl.h.

template<uint NAXES, typename SUBCLASS >
void GEO::BVHBase< NAXES, SUBCLASS >::findClosestInCone ( VectorType  origin,
VectorType  direction,
const float  angle,
const exint  max_points,
const float  max_dist_squared,
UT::BVHOrderedStack output_queue 
) const
noexcept

Finds the closest points from the origin to any surface within max_dist_squared, within the cone containing all points at most angle away from direction.

Definition at line 1101 of file GEO_BVHImpl.h.

template<uint NAXES, typename SUBCLASS >
void GEO::BVHBase< NAXES, SUBCLASS >::findClosestToLine ( VectorType  origin,
VectorType  direction,
const exint  max_points,
const float  max_dist_squared,
UT::BVHOrderedStack output_queue 
) const
noexcept

Finds the closest points to the infinite line containing origin with direction direction.

Definition at line 1063 of file GEO_BVHImpl.h.

template<uint NAXES, typename SUBCLASS >
void GEO::BVHBase< NAXES, SUBCLASS >::findClosestToSegment ( VectorType  p0,
VectorType  p1,
const exint  max_points,
const float  max_dist_squared,
UT::BVHOrderedStack output_queue 
) const
noexcept

Finds the closest points to the line segment with endpoints p0 and p1.

Definition at line 1082 of file GEO_BVHImpl.h.

template<uint NAXES, typename SUBCLASS >
template<bool farthest, typename QUERY_POINT >
void GEO::BVHBase< NAXES, SUBCLASS >::findMaximalPointsCommon ( const QUERY_POINT &  query_point,
UT::BVHOrderedStack stack,
UT::BVHOrderedStack output_queue,
exint  max_points,
float  max_dist_squared 
) const
protectednoexcept

Definition at line 990 of file GEO_BVHImpl.h.

template<uint NAXES, typename SUBCLASS >
template<GA_AttributeOwner owner, typename T , typename DEST_T >
bool GEO::BVHBase< NAXES, SUBCLASS >::getAttribute ( const CommonHitInfo hit_info,
const GA_ROHandleT< T > &  attrib,
const GEO_Detail detail,
DEST_T &  value 
) const
noexcept

Returns true on success, false on failure. The function can fail if the hit is on a point and the attribute is a vertex or primitive attribute.

Definition at line 1722 of file GEO_BVHImpl.h.

template<uint NAXES, typename SUBCLASS>
SingleBoxType GEO::BVHBase< NAXES, SUBCLASS >::getBBox ( ) const
inlinenoexcept

Definition at line 201 of file GEO_BVH.h.

template<uint NAXES, typename SUBCLASS >
void GEO::BVHBase< NAXES, SUBCLASS >::getDerivs ( const CommonHitInfo hit_info,
VectorType dP_du,
VectorType dP_dv 
) const
noexcept

Fills in the values of dP/du and dP/dv for the hit surface.

Definition at line 1660 of file GEO_BVHImpl.h.

template<uint NAXES, typename SUBCLASS>
template<bool normalize = true>
VectorType GEO::BVHBase< NAXES, SUBCLASS >::getGeometricNormal ( const CommonHitInfo hit_info) const
noexcept

Returns the geometric normal (not based on the N attribute) for the hit surface, optionally normalized, since apparently Mantra doesn't need it normalized.

template<uint NAXES, typename SUBCLASS>
template<bool normalize>
BVHBase<NAXES,SUBCLASS>::VectorType GEO::BVHBase< NAXES, SUBCLASS >::getGeometricNormal ( const CommonHitInfo hit_info) const
noexcept

Definition at line 1648 of file GEO_BVHImpl.h.

template<uint NAXES, typename SUBCLASS >
void GEO::BVHBase< NAXES, SUBCLASS >::getIntersectingBoxes ( const SingleBoxType query_box,
UT_Array< exint > &  box_indices 
) const
noexcept

Fills box_indices array with the indices of all boxes intersecting query_box. NOTE: This does not clear out previous contents of indices, so that you can easily query intersection with multiple boxes. WARNING: DO NOT depend on the order of box_indices. If you need a consistent order, sort it.

Definition at line 1640 of file GEO_BVHImpl.h.

template<uint NAXES, typename SUBCLASS>
SYS_FORCE_INLINE bool GEO::BVHBase< NAXES, SUBCLASS >::isEmpty ( ) const
inlinenoexcept

Definition at line 52 of file GEO_BVH.h.

template<uint NAXES, typename SUBCLASS>
SYS_FORCE_INLINE exint GEO::BVHBase< NAXES, SUBCLASS >::numPoints ( ) const
inlinenoexcept

Definition at line 174 of file GEO_BVH.h.

template<uint NAXES, typename SUBCLASS>
SYS_FORCE_INLINE GA_Offset GEO::BVHBase< NAXES, SUBCLASS >::pointOffset ( exint  item_index) const
inlinenoexcept

Definition at line 178 of file GEO_BVH.h.

template<uint NAXES, typename SUBCLASS >
void GEO::BVHBase< NAXES, SUBCLASS >::pointUVWToPolar ( VectorType uvw)
staticnoexcept

For points, this converts the uvw from ItemHitInfo to polar form. The original is effectively a normal.

Definition at line 1700 of file GEO_BVHImpl.h.

template<uint NAXES, typename SUBCLASS >
template<bool farthest, bool rm_backface, bool reverse, typename HitInfoType >
void GEO::BVHBase< NAXES, SUBCLASS >::sendRay ( const VectorType origin,
const VectorType direction,
HitInfoType &  hit_info,
float  tmin = 0,
float  tmax = std::numeric_limits<float>::max() 
) const
noexcept

Sends a ray from the specified origin in the specified direction and finds the closest (or farthest) intersection. Potential hits less than tmin or greater than tmax from the origin are treated as not having been hit, regardless of whether farthest is true. If rm_backface is true, backface hits will be treated as no hit, and if reverse is also true, frontface hits will be treated as no hit. NOTE: If the hit_info.myNestedItemIndices is non-null, it will be filled with the hit path, ignoring the outermost index, which is in hit_info.myItemIndex.

Definition at line 346 of file GEO_BVHImpl.h.

template<uint NAXES, typename SUBCLASS >
template<bool rm_backface, bool reverse, bool sort, typename HitInfoType >
void GEO::BVHBase< NAXES, SUBCLASS >::sendRayAll ( const VectorType origin,
const VectorType direction,
UT_Array< HitInfoType > &  hit_info,
UT_Array< exint > *  nesting_temp_array = nullptr,
float  duplicate_tolerance = 0,
float  tmin = 0,
float  tmax = std::numeric_limits<float>::max() 
) const
noexcept

Sends a ray from the specified origin in the specified direction and finds all intersections, removing all but one that are within duplicate_tolerance of another hit. Potential hits less than tmin or greater than tmax from the origin are treated as not having been hit, regardless of whether farthest is true. If rm_backface is true, backface hits will be treated as no hit, and if reverse is also true, frontface hits will be treated as no hit. NOTE: If nesting_temp_array is non-null, this function will allocate nesting arrays for any applicable entries in hit_info, so the caller is responsible for deleting myNestedItemIndices arrays in hit_info. nesting_temp_array itself is just used for temporary storage to reduce the number of allocations.

Definition at line 380 of file GEO_BVHImpl.h.

template<uint NAXES, typename SUBCLASS >
template<bool rm_backface, bool reverse, bool sort, typename HitInfoType >
void GEO::BVHBase< NAXES, SUBCLASS >::sendRayAllRad ( const VectorType origin,
const VectorType direction,
UT_Array< HitInfoType > &  hit_info,
float  default_radius,
UT_Array< exint > *  nesting_temp_array = nullptr,
float  duplicate_tolerance = 0,
float  tmin = 0,
float  tmax = std::numeric_limits<float>::max() 
) const
noexcept

Like sendRayAll, except with a radius (tolerance) for curve and point hits, in case myRadii is empty.

Definition at line 426 of file GEO_BVHImpl.h.

template<uint NAXES, typename SUBCLASS >
template<bool farthest, bool rm_backface, bool reverse, typename FUNCTOR >
void GEO::BVHBase< NAXES, SUBCLASS >::sendRayGeneric ( VectorType  origin,
VectorType  direction,
FUNCTOR &  hit_info,
float  tmin = 0,
float  tmax = std::numeric_limits<float>::max() 
) const
noexcept

Definition at line 481 of file GEO_BVHImpl.h.

template<uint NAXES, typename SUBCLASS >
template<bool farthest, bool rm_backface, bool reverse, typename HitInfoType >
void GEO::BVHBase< NAXES, SUBCLASS >::sendRayRad ( const VectorType origin,
const VectorType direction,
HitInfoType &  hit_info,
float  default_radius,
float  tmin = 0,
float  tmax = std::numeric_limits<float>::max() 
) const
noexcept

Like sendRay, except with a radius (tolerance) for curve and point hits, in case myRadii is empty.

Definition at line 359 of file GEO_BVHImpl.h.

template<uint NAXES, typename SUBCLASS>
SYS_FORCE_INLINE SUBCLASS* GEO::BVHBase< NAXES, SUBCLASS >::subclass ( )
inlineprotectednoexcept

Definition at line 254 of file GEO_BVH.h.

template<uint NAXES, typename SUBCLASS>
SYS_FORCE_INLINE const SUBCLASS* GEO::BVHBase< NAXES, SUBCLASS >::subclass ( ) const
inlineprotectednoexcept

Definition at line 255 of file GEO_BVH.h.

Member Data Documentation

template<uint NAXES, typename SUBCLASS>
constexpr uint GEO::BVHBase< NAXES, SUBCLASS >::BVH_N = 4
staticprotected

Definition at line 270 of file GEO_BVH.h.

template<uint NAXES, typename SUBCLASS>
bool GEO::BVHBase< NAXES, SUBCLASS >::myHasCurvesOrPoints
protected

Definition at line 300 of file GEO_BVH.h.

template<uint NAXES, typename SUBCLASS>
UT_UniquePtr<BoxType[]> GEO::BVHBase< NAXES, SUBCLASS >::myNodeBoxes
protected

Definition at line 273 of file GEO_BVH.h.

template<uint NAXES, typename SUBCLASS>
UT_UniquePtr<UT_FixedVector<int32,BVH_N>[]> GEO::BVHBase< NAXES, SUBCLASS >::myNodeNItems
protected

Definition at line 275 of file GEO_BVH.h.

template<uint NAXES, typename SUBCLASS>
GA_OffsetList GEO::BVHBase< NAXES, SUBCLASS >::myPoints
protected

Disconnected points.

Definition at line 292 of file GEO_BVH.h.

template<uint NAXES, typename SUBCLASS>
PosAttribType GEO::BVHBase< NAXES, SUBCLASS >::myPosAttrib
protected

Attribute for positions, to avoid having to copy all positions into myPositions if only a small subset of points are needed.

Definition at line 285 of file GEO_BVH.h.

template<uint NAXES, typename SUBCLASS>
UT_Array<VectorType> GEO::BVHBase< NAXES, SUBCLASS >::myPositions
protected

Positions for points.

Definition at line 278 of file GEO_BVH.h.

template<uint NAXES, typename SUBCLASS>
GA_DataId GEO::BVHBase< NAXES, SUBCLASS >::myPositionsDataId
protected

Data IDs for myPositions and myRadii

Definition at line 296 of file GEO_BVH.h.

template<uint NAXES, typename SUBCLASS>
RadAttribType GEO::BVHBase< NAXES, SUBCLASS >::myRadAttrib
protected

Attribute for radii, to avoid having to copy all radii into myRadii if only a small subset of points are needed.

Definition at line 289 of file GEO_BVH.h.

template<uint NAXES, typename SUBCLASS>
UT_Array<float> GEO::BVHBase< NAXES, SUBCLASS >::myRadii
protected

Radii for disconnected points.

Definition at line 281 of file GEO_BVH.h.

template<uint NAXES, typename SUBCLASS>
GA_DataId GEO::BVHBase< NAXES, SUBCLASS >::myRadiiDataId
protected

Data IDs for myPositions and myRadii

Definition at line 297 of file GEO_BVH.h.

template<uint NAXES, typename SUBCLASS>
UT_BVH<BVH_N> GEO::BVHBase< NAXES, SUBCLASS >::myTree
protected

Definition at line 272 of file GEO_BVH.h.


The documentation for this class was generated from the following files: