TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
DynamicMapTree Class Reference

#include <DynamicTree.h>

Public Member Functions

 DynamicMapTree ()
 
 ~DynamicMapTree ()
 
bool isInLineOfSight (float x1, float y1, float z1, float x2, float y2, float z2, uint32 phasemask) const
 
bool getIntersectionTime (uint32 phasemask, const G3D::Ray &ray, const G3D::Vector3 &endPos, float &maxDist) const
 
bool getObjectHitPos (uint32 phasemask, const G3D::Vector3 &pPos1, const G3D::Vector3 &pPos2, G3D::Vector3 &pResultHitPos, float pModifyDist) const
 
float getHeight (float x, float y, float z, float maxSearchDist, uint32 phasemask) const
 
void insert (const GameObjectModel &)
 
void remove (const GameObjectModel &)
 
bool contains (const GameObjectModel &) const
 
int size () const
 
void balance ()
 
void update (uint32 diff)
 

Private Attributes

DynTreeImplimpl
 

Constructor & Destructor Documentation

DynamicMapTree::DynamicMapTree ( )
110 : impl(new DynTreeImpl()) { }
DynTreeImpl * impl
Definition: DynamicTree.h:36
Definition: DynamicTree.cpp:63
DynamicMapTree::~DynamicMapTree ( )
113 {
114  delete impl;
115 }
DynTreeImpl * impl
Definition: DynamicTree.h:36

Member Function Documentation

void DynamicMapTree::balance ( )
133 {
134  impl->balance();
135 }
void balance()
Definition: DynamicTree.cpp:86
DynTreeImpl * impl
Definition: DynamicTree.h:36

+ Here is the call graph for this function:

bool DynamicMapTree::contains ( const GameObjectModel mdl) const
128 {
129  return impl->contains(mdl);
130 }
DynTreeImpl * impl
Definition: DynamicTree.h:36
bool contains(const T &value) const
Definition: RegularGrid.h:73

+ Here is the call graph for this function:

float DynamicMapTree::getHeight ( float  x,
float  y,
float  z,
float  maxSearchDist,
uint32  phasemask 
) const
250 {
251  G3D::Vector3 v(x, y, z);
252  G3D::Ray r(v, G3D::Vector3(0, 0, -1));
253  DynamicTreeIntersectionCallback callback(phasemask);
254  impl->intersectZAllignedRay(r, callback, maxSearchDist);
255 
256  if (callback.didHit())
257  return v.z - maxSearchDist;
258  else
259  return -G3D::finf();
260 }
float finf()
Definition: g3dmath.cpp:71
DynTreeImpl * impl
Definition: DynamicTree.h:36
Definition: Vector3.h:58
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Ray.h:24
Definition: DynamicTree.cpp:147
void intersectZAllignedRay(const G3D::Ray &ray, RayCallback &intersectCallback, float &max_dist)
Definition: RegularGrid.h:199
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool DynamicMapTree::getIntersectionTime ( uint32  phasemask,
const G3D::Ray ray,
const G3D::Vector3 endPos,
float &  maxDist 
) const
184 {
185  float distance = maxDist;
186  DynamicTreeIntersectionCallback callback(phasemask);
187  impl->intersectRay(ray, callback, distance, endPos);
188  if (callback.didHit())
189  maxDist = distance;
190  return callback.didHit();
191 }
DynTreeImpl * impl
Definition: DynamicTree.h:36
void intersectRay(const G3D::Ray &ray, RayCallback &intersectCallback, float max_dist)
Definition: RegularGrid.h:106
double distance(double x, double y)
Definition: g3dmath.h:731
Definition: DynamicTree.cpp:147

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool DynamicMapTree::getObjectHitPos ( uint32  phasemask,
const G3D::Vector3 pPos1,
const G3D::Vector3 pPos2,
G3D::Vector3 pResultHitPos,
float  pModifyDist 
) const
196 {
197  bool result = false;
198  float maxDist = (endPos - startPos).magnitude();
199  // valid map coords should *never ever* produce float overflow, but this would produce NaNs too
201  // prevent NaN values which can cause BIH intersection to enter infinite loop
202  if (maxDist < 1e-10f)
203  {
204  resultHit = endPos;
205  return false;
206  }
207  G3D::Vector3 dir = (endPos - startPos)/maxDist; // direction with length of 1
208  G3D::Ray ray(startPos, dir);
209  float dist = maxDist;
210  if (getIntersectionTime(phasemask, ray, endPos, dist))
211  {
212  resultHit = startPos + dir * dist;
213  if (modifyDist < 0)
214  {
215  if ((resultHit - startPos).magnitude() > -modifyDist)
216  resultHit = resultHit + dir*modifyDist;
217  else
218  resultHit = startPos;
219  }
220  else
221  resultHit = resultHit + dir*modifyDist;
222 
223  result = true;
224  }
225  else
226  {
227  resultHit = endPos;
228  result = false;
229  }
230  return result;
231 }
T max(const T &x, const T &y)
Definition: g3dmath.h:320
Definition: Vector3.h:58
Definition: Ray.h:24
#define ASSERT
Definition: Errors.h:55
bool getIntersectionTime(uint32 phasemask, const G3D::Ray &ray, const G3D::Vector3 &endPos, float &maxDist) const
Definition: DynamicTree.cpp:182

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void DynamicMapTree::insert ( const GameObjectModel mdl)
118 {
119  impl->insert(mdl);
120 }
DynTreeImpl * impl
Definition: DynamicTree.h:36
void insert(const Model &mdl)
Definition: DynamicTree.cpp:74

+ Here is the call graph for this function:

bool DynamicMapTree::isInLineOfSight ( float  x1,
float  y1,
float  z1,
float  x2,
float  y2,
float  z2,
uint32  phasemask 
) const
234 {
235  G3D::Vector3 v1(x1, y1, z1), v2(x2, y2, z2);
236 
237  float maxDist = (v2 - v1).magnitude();
238 
239  if (!G3D::fuzzyGt(maxDist, 0) )
240  return true;
241 
242  G3D::Ray r(v1, (v2-v1) / maxDist);
243  DynamicTreeIntersectionCallback callback(phasemask);
244  impl->intersectRay(r, callback, maxDist, v2);
245 
246  return !callback.did_hit;
247 }
DynTreeImpl * impl
Definition: DynamicTree.h:36
void intersectRay(const G3D::Ray &ray, RayCallback &intersectCallback, float max_dist)
Definition: RegularGrid.h:106
Definition: Vector3.h:58
Definition: Ray.h:24
Definition: DynamicTree.cpp:147
bool fuzzyGt(double a, double b)
Definition: g3dmath.h:865

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void DynamicMapTree::remove ( const GameObjectModel mdl)
123 {
124  impl->remove(mdl);
125 }
DynTreeImpl * impl
Definition: DynamicTree.h:36
void remove(const Model &mdl)
Definition: DynamicTree.cpp:80

+ Here is the call graph for this function:

int DynamicMapTree::size ( ) const
138 {
139  return impl->size();
140 }
DynTreeImpl * impl
Definition: DynamicTree.h:36
int size() const
Definition: RegularGrid.h:74

+ Here is the call graph for this function:

void DynamicMapTree::update ( uint32  diff)
143 {
144  impl->update(t_diff);
145 }
DynTreeImpl * impl
Definition: DynamicTree.h:36
void update(uint32 difftime)
Definition: DynamicTree.cpp:92

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

DynTreeImpl* DynamicMapTree::impl
private

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