TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ObjectPosSelector Struct Reference

#include <ObjectPosSelector.h>

Classes

struct  UsedPos
 

Public Types

typedef std::multimap< float,
UsedPos
UsedPosList
 

Public Member Functions

 ObjectPosSelector (float x, float y, float size, float dist)
 
void AddUsedPos (float size, float angle, float dist)
 
void InitializeAngle ()
 
bool FirstAngle (float &angle)
 
bool NextAngle (float &angle)
 
bool NextUsedAngle (float &angle)
 
bool NextPosibleAngle (float &angle)
 
bool CheckAngle (UsedPosList::value_type const &nextUsedPos, float sign, float angle) const
 
bool CheckOriginal () const
 
bool IsNonBalanced () const
 
bool NextAngleFor (UsedPosList::value_type const &usedPos, float sign, UsedPosType uptype, float &angle)
 
bool NextSmallStepAngle (float sign, UsedPosType uptype, float &angle)
 
UsedPosList::value_type constnextUsedPos (UsedPosType uptype)
 
float GetAngle (UsedPos const &usedPos) const
 

Public Attributes

float m_center_x
 
float m_center_y
 
float m_size
 
float m_dist
 
float m_anglestep
 
UsedPosList m_UsedPosLists [2]
 
UsedPosList::const_iterator m_nextUsedPos [2]
 
float m_smallStepAngle [2]
 
bool m_smallStepOk [2]
 
UsedPosList::value_type constm_smallStepNextUsedPos [2]
 

Member Typedef Documentation

typedef std::multimap<float, UsedPos> ObjectPosSelector::UsedPosList

Constructor & Destructor Documentation

ObjectPosSelector::ObjectPosSelector ( float  x,
float  y,
float  size,
float  dist 
)
22 : m_center_x(x), m_center_y(y), m_size(size), m_dist(dist)
23 {
25 
28 
31 
34 
37 }
Definition: ObjectPosSelector.h:26
UsedPosList m_UsedPosLists[2]
Definition: ObjectPosSelector.h:147
arena_t NULL
Definition: jemalloc_internal.h:624
float m_center_x
Definition: ObjectPosSelector.h:141
float m_anglestep
Definition: ObjectPosSelector.h:145
float m_smallStepAngle[2]
Definition: ObjectPosSelector.h:151
float m_dist
Definition: ObjectPosSelector.h:144
G3D::int16 y
Definition: Vector2int16.h:38
Definition: ObjectPosSelector.h:26
UsedPosList::value_type const * m_smallStepNextUsedPos[2]
Definition: ObjectPosSelector.h:153
float acos(float fValue)
Definition: g3dmath.h:633
float m_center_y
Definition: ObjectPosSelector.h:142
G3D::int16 x
Definition: Vector2int16.h:37
bool m_smallStepOk[2]
Definition: ObjectPosSelector.h:152
UsedPosList::const_iterator m_nextUsedPos[2]
Definition: ObjectPosSelector.h:148
float m_size
Definition: ObjectPosSelector.h:143

+ Here is the call graph for this function:

Member Function Documentation

void ObjectPosSelector::AddUsedPos ( float  size,
float  angle,
float  dist 
)
57 {
58  if (angle >= 0)
59  m_UsedPosLists[USED_POS_PLUS].insert(UsedPosList::value_type(angle, UsedPos(1.0f, size, dist)));
60  else
61  m_UsedPosLists[USED_POS_MINUS].insert(UsedPosList::value_type(-angle, UsedPos(-1.0f, size, dist)));
62 }
Definition: ObjectPosSelector.h:26
UsedPosList m_UsedPosLists[2]
Definition: ObjectPosSelector.h:147
Definition: ObjectPosSelector.h:26
bool ObjectPosSelector::CheckAngle ( UsedPosList::value_type const nextUsedPos,
float  sign,
float  angle 
) const
inline
59  {
60  float angle_step2 = GetAngle(nextUsedPos.second);
61 
62  float next_angle = nextUsedPos.first;
63  if (nextUsedPos.second.sign * sign < 0) // last node from diff. list (-pi+alpha)
64  next_angle = 2 * float(M_PI) - next_angle; // move to positive
65 
66  return std::fabs(angle) + angle_step2 <= next_angle;
67  }
#define M_PI
Definition: Common.h:163
UsedPosList::value_type const * nextUsedPos(UsedPosType uptype)
Definition: ObjectPosSelector.cpp:39
float GetAngle(UsedPos const &usedPos) const
Definition: ObjectPosSelector.h:139
double sign(double fValue)
Definition: g3dmath.h:669
bool ObjectPosSelector::CheckOriginal ( ) const
inline
70  {
71  return (m_UsedPosLists[USED_POS_PLUS].empty() || CheckAngle(*m_UsedPosLists[USED_POS_PLUS].begin(), 1.0f, 0)) &&
72  (m_UsedPosLists[USED_POS_MINUS].empty() || CheckAngle(*m_UsedPosLists[USED_POS_MINUS].begin(), -1.0f, 0));
73  }
Definition: ObjectPosSelector.h:26
UsedPosList m_UsedPosLists[2]
Definition: ObjectPosSelector.h:147
bool CheckAngle(UsedPosList::value_type const &nextUsedPos, float sign, float angle) const
Definition: ObjectPosSelector.h:58
Definition: ObjectPosSelector.h:26
bool ObjectPosSelector::FirstAngle ( float &  angle)
77 {
79  return NextAngleFor(*m_UsedPosLists[USED_POS_MINUS].begin(), 1.0f, USED_POS_PLUS, angle);
80  else if (m_UsedPosLists[USED_POS_MINUS].empty() && !m_UsedPosLists[USED_POS_PLUS].empty())
81  return NextAngleFor(*m_UsedPosLists[USED_POS_PLUS].begin(), -1.0f, USED_POS_MINUS, angle);
82 
83  return false;
84 }
Definition: ObjectPosSelector.h:26
UsedPosList m_UsedPosLists[2]
Definition: ObjectPosSelector.h:147
bool NextAngleFor(UsedPosList::value_type const &usedPos, float sign, UsedPosType uptype, float &angle)
Definition: ObjectPosSelector.h:77
Definition: ObjectPosSelector.h:26

+ Here is the call graph for this function:

float ObjectPosSelector::GetAngle ( UsedPos const usedPos) const
inline
139 { return std::acos(m_dist/(usedPos.dist+usedPos.size+m_size)); }
float m_dist
Definition: ObjectPosSelector.h:144
float acos(float fValue)
Definition: g3dmath.h:633
float m_size
Definition: ObjectPosSelector.h:143

+ Here is the call graph for this function:

void ObjectPosSelector::InitializeAngle ( )
65 {
68 
71 
74 }
Definition: ObjectPosSelector.h:26
UsedPosList m_UsedPosLists[2]
Definition: ObjectPosSelector.h:147
float m_smallStepAngle[2]
Definition: ObjectPosSelector.h:151
Definition: ObjectPosSelector.h:26
bool m_smallStepOk[2]
Definition: ObjectPosSelector.h:152
UsedPosList::const_iterator m_nextUsedPos[2]
Definition: ObjectPosSelector.h:148
bool ObjectPosSelector::IsNonBalanced ( ) const
inline
75 { return m_UsedPosLists[USED_POS_PLUS].empty() != m_UsedPosLists[USED_POS_MINUS].empty(); }
Definition: ObjectPosSelector.h:26
UsedPosList m_UsedPosLists[2]
Definition: ObjectPosSelector.h:147
Definition: ObjectPosSelector.h:26
bool ObjectPosSelector::NextAngle ( float &  angle)
87 {
91  {
92  // calculate next possible angle
93  if (NextPosibleAngle(angle))
94  return true;
95  }
96 
97  return false;
98 }
Definition: ObjectPosSelector.h:26
UsedPosList m_UsedPosLists[2]
Definition: ObjectPosSelector.h:147
bool NextPosibleAngle(float &angle)
Definition: ObjectPosSelector.cpp:113
Definition: ObjectPosSelector.h:26
bool m_smallStepOk[2]
Definition: ObjectPosSelector.h:152
UsedPosList::const_iterator m_nextUsedPos[2]
Definition: ObjectPosSelector.h:148

+ Here is the call graph for this function:

bool ObjectPosSelector::NextAngleFor ( UsedPosList::value_type const usedPos,
float  sign,
UsedPosType  uptype,
float &  angle 
)
inline
78  {
79  float angle_step = GetAngle(usedPos.second);
80 
81  // next possible angle
82  angle = usedPos.first * usedPos.second.sign + angle_step * sign;
83 
84  UsedPosList::value_type const* nextNode = nextUsedPos(uptype);
85  if (nextNode)
86  {
87  // if next node permit use selected angle, then do it
88  if (!CheckAngle(*nextNode, sign, angle))
89  {
90  m_smallStepOk[uptype] = false;
91  return false;
92  }
93  }
94 
95  // possible more points
96  m_smallStepOk[uptype] = true;
97  m_smallStepAngle[uptype] = angle;
98  m_smallStepNextUsedPos[uptype] = nextNode;
99 
100  return true;
101  }
bool CheckAngle(UsedPosList::value_type const &nextUsedPos, float sign, float angle) const
Definition: ObjectPosSelector.h:58
float m_smallStepAngle[2]
Definition: ObjectPosSelector.h:151
UsedPosList::value_type const * nextUsedPos(UsedPosType uptype)
Definition: ObjectPosSelector.cpp:39
float GetAngle(UsedPos const &usedPos) const
Definition: ObjectPosSelector.h:139
UsedPosList::value_type const * m_smallStepNextUsedPos[2]
Definition: ObjectPosSelector.h:153
double sign(double fValue)
Definition: g3dmath.h:669
bool m_smallStepOk[2]
Definition: ObjectPosSelector.h:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ObjectPosSelector::NextPosibleAngle ( float &  angle)
114 {
115  // ++ direction less updated
118  {
119  bool ok;
121  ok = NextSmallStepAngle(1.0f, USED_POS_PLUS, angle);
122  else
123  ok = NextAngleFor(*m_nextUsedPos[USED_POS_PLUS], 1.0f, USED_POS_PLUS, angle);
124 
125  if (!ok)
126  ++m_nextUsedPos[USED_POS_PLUS]; // increase. only at fail (original or checked)
127  return ok;
128  }
129  // -- direction less updated
131  {
132  bool ok;
134  ok = NextSmallStepAngle(-1.0f, USED_POS_MINUS, angle);
135  else
136  ok = NextAngleFor(*m_nextUsedPos[USED_POS_MINUS], -1.0f, USED_POS_MINUS, angle);
137 
138  if (!ok)
140  return ok;
141  }
142  else // both list empty
143  {
144  if (m_smallStepOk[USED_POS_PLUS] && (!m_smallStepOk[USED_POS_MINUS] || m_smallStepAngle[USED_POS_PLUS] <= m_smallStepAngle[USED_POS_MINUS]))
145  return NextSmallStepAngle(1.0f, USED_POS_PLUS, angle);
146  // -- direction less updated
147  else if (m_smallStepOk[USED_POS_MINUS])
148  return NextSmallStepAngle(-1.0f, USED_POS_MINUS, angle);
149  }
150 
151  // no angles
152  return false;
153 }
Definition: ObjectPosSelector.h:26
UsedPosList m_UsedPosLists[2]
Definition: ObjectPosSelector.h:147
bool NextSmallStepAngle(float sign, UsedPosType uptype, float &angle)
Definition: ObjectPosSelector.h:103
bool NextAngleFor(UsedPosList::value_type const &usedPos, float sign, UsedPosType uptype, float &angle)
Definition: ObjectPosSelector.h:77
float m_smallStepAngle[2]
Definition: ObjectPosSelector.h:151
Definition: ObjectPosSelector.h:26
bool m_smallStepOk[2]
Definition: ObjectPosSelector.h:152
UsedPosList::const_iterator m_nextUsedPos[2]
Definition: ObjectPosSelector.h:148

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ObjectPosSelector::NextSmallStepAngle ( float  sign,
UsedPosType  uptype,
float &  angle 
)
inline
104  {
105  // next possible angle
106  angle = m_smallStepAngle[uptype] + m_anglestep * sign;
107 
108  if (std::fabs(angle) > float(M_PI))
109  {
110  m_smallStepOk[uptype] = false;
111  return false;
112  }
113 
114  if (m_smallStepNextUsedPos[uptype])
115  {
116  if (std::fabs(angle) >= m_smallStepNextUsedPos[uptype]->first)
117  {
118  m_smallStepOk[uptype] = false;
119  return false;
120  }
121 
122  // if next node permit use selected angle, then do it
123  if (!CheckAngle(*m_smallStepNextUsedPos[uptype], sign, angle))
124  {
125  m_smallStepOk[uptype] = false;
126  return false;
127  }
128  }
129 
130  // possible more points
131  m_smallStepAngle[uptype] = angle;
132  return true;
133  }
#define M_PI
Definition: Common.h:163
bool CheckAngle(UsedPosList::value_type const &nextUsedPos, float sign, float angle) const
Definition: ObjectPosSelector.h:58
float m_anglestep
Definition: ObjectPosSelector.h:145
float m_smallStepAngle[2]
Definition: ObjectPosSelector.h:151
UsedPosList::value_type const * m_smallStepNextUsedPos[2]
Definition: ObjectPosSelector.h:153
double sign(double fValue)
Definition: g3dmath.h:669
bool m_smallStepOk[2]
Definition: ObjectPosSelector.h:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ObjectPosSelector::NextUsedAngle ( float &  angle)
101 {
104  {
105  // calculate next possible angle
106  if (!NextPosibleAngle(angle))
107  return true;
108  }
109 
110  return false;
111 }
Definition: ObjectPosSelector.h:26
UsedPosList m_UsedPosLists[2]
Definition: ObjectPosSelector.h:147
bool NextPosibleAngle(float &angle)
Definition: ObjectPosSelector.cpp:113
Definition: ObjectPosSelector.h:26
UsedPosList::const_iterator m_nextUsedPos[2]
Definition: ObjectPosSelector.h:148

+ Here is the call graph for this function:

ObjectPosSelector::UsedPosList::value_type const * ObjectPosSelector::nextUsedPos ( UsedPosType  uptype)
40 {
41  UsedPosList::const_iterator itr = m_nextUsedPos[uptype];
42  if (itr!=m_UsedPosLists[uptype].end())
43  ++itr;
44 
45  if (itr==m_UsedPosLists[uptype].end())
46  {
47  if (!m_UsedPosLists[~uptype].empty())
48  return &*m_UsedPosLists[~uptype].rbegin();
49  else
50  return NULL;
51  }
52  else
53  return &*itr;
54 }
UsedPosList m_UsedPosLists[2]
Definition: ObjectPosSelector.h:147
arena_t NULL
Definition: jemalloc_internal.h:624
UsedPosList::const_iterator m_nextUsedPos[2]
Definition: ObjectPosSelector.h:148

Member Data Documentation

float ObjectPosSelector::m_anglestep
float ObjectPosSelector::m_center_x
float ObjectPosSelector::m_center_y
float ObjectPosSelector::m_dist
UsedPosList::const_iterator ObjectPosSelector::m_nextUsedPos[2]
float ObjectPosSelector::m_size
float ObjectPosSelector::m_smallStepAngle[2]
UsedPosList::value_type const* ObjectPosSelector::m_smallStepNextUsedPos[2]
bool ObjectPosSelector::m_smallStepOk[2]
UsedPosList ObjectPosSelector::m_UsedPosLists[2]

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