AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
BIHWrap< T, BoundsFunc > Class Template Reference

#include "BoundingIntervalHierarchyWrapper.h"

Classes

struct  MDLCallback
 

Public Member Functions

 BIHWrap ()
 
void insert (const T &obj)
 
void remove (const T &obj)
 
void balance ()
 
template<typename RayCallback >
void intersectRay (const G3D::Ray &ray, RayCallback &intersectCallback, float &maxDist, bool stopAtFirstHit)
 
template<typename IsectCallback >
void intersectPoint (const G3D::Vector3 &point, IsectCallback &intersectCallback)
 

Private Types

typedef G3D::Array< const T * > ObjArray
 

Private Attributes

BIH m_tree
 
ObjArray m_objects
 
G3D::Table< const T *, uint32m_obj2Idx
 
G3D::Set< const T * > m_objects_to_push
 
int unbalanced_times
 

Detailed Description

template<class T, class BoundsFunc = BoundsTrait<T>>
class BIHWrap< T, BoundsFunc >

Member Typedef Documentation

◆ ObjArray

template<class T , class BoundsFunc = BoundsTrait<T>>
typedef G3D::Array<const T*> BIHWrap< T, BoundsFunc >::ObjArray
private

Constructor & Destructor Documentation

◆ BIHWrap()

template<class T , class BoundsFunc = BoundsTrait<T>>
BIHWrap< T, BoundsFunc >::BIHWrap ( )
inline
75: unbalanced_times(0) { }
int unbalanced_times
Definition: BoundingIntervalHierarchyWrapper.h:72

Member Function Documentation

◆ balance()

template<class T , class BoundsFunc = BoundsTrait<T>>
void BIHWrap< T, BoundsFunc >::balance ( )
inline
99 {
100 if (unbalanced_times == 0)
101 {
102 return;
103 }
104
106 m_objects.fastClear();
107 m_obj2Idx.getKeys(m_objects);
108 m_objects_to_push.getMembers(m_objects);
109 //assert that m_obj2Idx has all the keys
110
111 m_tree.build(m_objects, BoundsFunc::GetBounds2);
112 }
void build(const PrimArray &primitives, BoundsFunc &GetBounds, uint32 leafSize=3, bool printStats=false)
Definition: BoundingIntervalHierarchy.h:80
G3D::Table< const T *, uint32 > m_obj2Idx
Definition: BoundingIntervalHierarchyWrapper.h:70
BIH m_tree
Definition: BoundingIntervalHierarchyWrapper.h:68
ObjArray m_objects
Definition: BoundingIntervalHierarchyWrapper.h:69
G3D::Set< const T * > m_objects_to_push
Definition: BoundingIntervalHierarchyWrapper.h:71

References BIH::build(), BIHWrap< T, BoundsFunc >::m_obj2Idx, BIHWrap< T, BoundsFunc >::m_objects, BIHWrap< T, BoundsFunc >::m_objects_to_push, BIHWrap< T, BoundsFunc >::m_tree, and BIHWrap< T, BoundsFunc >::unbalanced_times.

Referenced by BIHWrap< T, BoundsFunc >::intersectPoint(), and BIHWrap< T, BoundsFunc >::intersectRay().

◆ insert()

template<class T , class BoundsFunc = BoundsTrait<T>>
void BIHWrap< T, BoundsFunc >::insert ( const T &  obj)
inline

◆ intersectPoint()

template<class T , class BoundsFunc = BoundsTrait<T>>
template<typename IsectCallback >
void BIHWrap< T, BoundsFunc >::intersectPoint ( const G3D::Vector3 &  point,
IsectCallback &  intersectCallback 
)
inline
124 {
125 balance();
126 MDLCallback<IsectCallback> callback(intersectCallback, m_objects.getCArray(), m_objects.size());
127 m_tree.intersectPoint(point, callback);
128 }
void intersectPoint(const G3D::Vector3 &p, IsectCallback &intersectCallback) const
Definition: BoundingIntervalHierarchy.h:284
void balance()
Definition: BoundingIntervalHierarchyWrapper.h:98

References BIHWrap< T, BoundsFunc >::balance(), BIH::intersectPoint(), BIHWrap< T, BoundsFunc >::m_objects, and BIHWrap< T, BoundsFunc >::m_tree.

◆ intersectRay()

template<class T , class BoundsFunc = BoundsTrait<T>>
template<typename RayCallback >
void BIHWrap< T, BoundsFunc >::intersectRay ( const G3D::Ray &  ray,
RayCallback &  intersectCallback,
float &  maxDist,
bool  stopAtFirstHit 
)
inline
116 {
117 balance();
118 MDLCallback<RayCallback> temp_cb(intersectCallback, m_objects.getCArray(), m_objects.size());
119 m_tree.intersectRay(ray, temp_cb, maxDist, stopAtFirstHit);
120 }
void intersectRay(const G3D::Ray &r, RayCallback &intersectCallback, float &maxDist, bool stopAtFirstHit) const
Definition: BoundingIntervalHierarchy.h:121

References BIHWrap< T, BoundsFunc >::balance(), BIH::intersectRay(), BIHWrap< T, BoundsFunc >::m_objects, and BIHWrap< T, BoundsFunc >::m_tree.

◆ remove()

template<class T , class BoundsFunc = BoundsTrait<T>>
void BIHWrap< T, BoundsFunc >::remove ( const T &  obj)
inline
84 {
86 uint32 Idx = 0;
87 const T* temp;
88 if (m_obj2Idx.getRemove(&obj, temp, Idx))
89 {
90 m_objects[Idx] = nullptr;
91 }
92 else
93 {
94 m_objects_to_push.remove(&obj);
95 }
96 }
std::uint32_t uint32
Definition: Define.h:107

References BIHWrap< T, BoundsFunc >::m_obj2Idx, BIHWrap< T, BoundsFunc >::m_objects, BIHWrap< T, BoundsFunc >::m_objects_to_push, and BIHWrap< T, BoundsFunc >::unbalanced_times.

Member Data Documentation

◆ m_obj2Idx

template<class T , class BoundsFunc = BoundsTrait<T>>
G3D::Table<const T*, uint32> BIHWrap< T, BoundsFunc >::m_obj2Idx
private

◆ m_objects

template<class T , class BoundsFunc = BoundsTrait<T>>
ObjArray BIHWrap< T, BoundsFunc >::m_objects
private

◆ m_objects_to_push

template<class T , class BoundsFunc = BoundsTrait<T>>
G3D::Set<const T*> BIHWrap< T, BoundsFunc >::m_objects_to_push
private

◆ m_tree

template<class T , class BoundsFunc = BoundsTrait<T>>
BIH BIHWrap< T, BoundsFunc >::m_tree
private

◆ unbalanced_times

template<class T , class BoundsFunc = BoundsTrait<T>>
int BIHWrap< T, BoundsFunc >::unbalanced_times
private