7 #ifndef __surface_QuadTree_h__ 8 #define __surface_QuadTree_h__ 29 virtual void setRefinement(U32 a_refinement) { m_subdivMax=a_refinement; }
31 virtual void populate(
36 const Color* a_pColorArray,
37 const I32* a_pTriangleIndexArray,
38 const I32* a_pPointIndexArray,
39 const I32* a_pPrimitiveIndexArray,
40 const I32* a_pPartitionIndexArray,
41 U32 a_primitives,U32 a_vertices,
44 Real a_maxDistance,BWORD a_anyHit,U32 a_hitLimit,
50 Real a_maxDistance,BWORD a_anyHit,U32 a_hitLimit,
61 Real nearestTo(BWORD a_mutable,BWORD a_directional,
64 Real a_maxDistance,BWORD a_anyHit,U32 a_hitLimit,
67 U32 a_subdivMax)
const;
77 static int compare(
const void* a_pVoid1,
const void* a_pVoid2);
80 class FE_DL_EXPORT BaseNode:
97 setName(
"QuadTree::BaseNode");
100 virtual ~BaseNode(
void) {}
108 U32 a_keyIndex,U32 a_keyCount,
109 U32 a_level,U32 a_maxLevel,
112 virtual void subdivideOne(
118 U32 a_level,U32 a_maxLevel,
120 virtual void subdivideAll(
125 U32 a_level,U32 a_maxLevel,
132 const Color* a_pColor,
134 static void calcFrames(
143 void nearestTo(BWORD a_mutable,BWORD a_directional,
146 Real a_maxDistance,BWORD a_anyHit,
153 SurfaceI::Accuracy a_accuracy,
155 const I32* a_pPointIndexArray,
159 const Color* a_pColorArray,
160 const Ball* a_pBallArray,
161 U32 a_timeStamp)
const;
163 virtual I32 face(U32 a_keyIndex,
164 const Ball* a_pBallArray)
const =0;
165 virtual U32 faceCount(
void)
const =0;
167 const I32* facePointIndex(
168 const Ball* a_pBallArray,
170 const I32* a_pPointIndexArray,
171 U32 a_keyIndex)
const =0;
174 const Ball* a_pBallArray,
177 U32 a_keyIndex)
const =0;
180 const Ball* a_pBallArray,
183 U32 a_keyIndex)
const =0;
186 const Ball* a_pBallArray,
189 U32 a_keyIndex)
const =0;
191 const Color* faceColor(
192 const Ball* a_pBallArray,
194 const Color* a_pColorArray,
195 U32 a_keyIndex)
const =0;
197 virtual I32 ballIndex(U32 a_keyIndex)
const {
return -1; }
199 const Vector4 sphereData(U32 a_keyIndex,
200 const Ball* a_pBallArray)
const 201 {
return Vector4(0.0f,0.0f,0.0f,0.0f); }
203 void prune(U32 a_timeStamp);
206 class FE_DL_EXPORT Node:
221 setName(
"QuadTree::Node");
224 virtual ~Node(
void) {}
232 const Ball* a_pBallArray,
234 void split(U32 a_axis,Key*& a_rpKeys,U32& a_rKeyCount,
236 Key** a_rppKeys,U32* a_rpKeyCount);
237 static U32 quickSelect(Key*& a_rpKeys,U32& a_keyCount,
238 U32 a_selectIndex,U32 a_axis);
239 static U32 select(Key*& a_rpKeys,U32 a_count,
240 U32 a_left,U32 a_right,
241 U32 a_selectIndex,U32 a_axis);
242 static U32 partition(Key*& a_rpKeys,U32 a_count,
243 U32 a_left,U32 a_right,
244 U32 a_pivotIndex,U32 a_axis);
248 const U32 a_vertexCount);
253 const Ball* a_pBallArray);
255 virtual void subdivideOne(
261 U32 a_level,U32 a_maxLevel,U32 a_timeStamp);
262 virtual void subdivideAll(
267 U32 a_level,U32 a_maxLevel,
270 virtual I32 face(U32 a_keyIndex,
const Ball* a_pBallArray)
const 271 { FEASSERT(a_keyIndex<m_keyCount);
272 return a_pBallArray[ballIndex(a_keyIndex)]
275 virtual U32 faceCount(
void)
const 276 {
return m_keyCount; }
278 const I32* facePointIndex(
279 const Ball* a_pBallArray,
281 const I32* a_pPointIndexArray,
282 U32 a_keyIndex)
const 285 face(a_keyIndex,a_pBallArray);
286 const U32 startIndex=
287 a_pElementArray[faceIndex][0];
288 return &a_pPointIndexArray[startIndex];
292 const Ball* a_pBallArray,
295 U32 a_keyIndex)
const 298 face(a_keyIndex,a_pBallArray);
299 const U32 startIndex=
300 a_pElementArray[faceIndex][0];
301 return &a_pVertexArray[startIndex];
305 const Ball* a_pBallArray,
308 U32 a_keyIndex)
const 311 face(a_keyIndex,a_pBallArray);
312 const U32 startIndex=
313 a_pElementArray[faceIndex][0];
314 return &a_pNormalArray[startIndex];
318 const Ball* a_pBallArray,
321 U32 a_keyIndex)
const 324 face(a_keyIndex,a_pBallArray);
325 const U32 startIndex=
326 a_pElementArray[faceIndex][0];
327 return a_pUVArray? &a_pUVArray[startIndex]:
331 const Color* faceColor(
332 const Ball* a_pBallArray,
334 const Color* a_pColorArray,
335 U32 a_keyIndex)
const 338 face(a_keyIndex,a_pBallArray);
339 const U32 startIndex=
340 a_pElementArray[faceIndex][0];
341 return a_pColorArray?
342 &a_pColorArray[startIndex]: NULL;
345 virtual I32 ballIndex(U32 a_keyIndex)
const 346 { FEASSERT(a_keyIndex<m_keyCount);
347 return m_pKeyArray[a_keyIndex].m_ballIndex; }
349 const Vector4 sphereData(U32 a_keyIndex,
350 const Ball* a_pBallArray)
const 351 { FEASSERT(a_keyIndex<m_keyCount);
352 return a_pBallArray[m_pKeyArray[a_keyIndex]
353 .m_ballIndex].m_sphere; }
356 class FE_DL_EXPORT SubNode:
371 m_pSubdivPrimitiveArray(NULL),
372 m_pSubdivVertexArray(NULL),
373 m_pSubdivNormalArray(NULL),
374 m_pSubdivUVArray(NULL),
380 setName(
"QuadTree::SubNode");
383 virtual ~SubNode(
void)
385 delete[] m_pSubdivUVArray;
386 delete[] m_pSubdivNormalArray;
387 delete[] m_pSubdivVertexArray;
388 delete[] m_pSubdivPrimitiveArray;
391 virtual void subdivideOne(
397 U32 a_level,U32 a_maxLevel,U32 a_timeStamp);
398 virtual void subdivideAll(
403 U32 a_level,U32 a_maxLevel,
407 virtual I32 face(U32 a_keyIndex,
const Ball* a_pBallArray)
const 408 {
return a_keyIndex; }
410 virtual U32 faceCount(
void)
const 411 {
return m_subdivCount/3; }
413 const I32* facePointIndex(
414 const Ball* a_pBallArray,
416 const I32* a_pPointIndexArray,
417 U32 a_keyIndex)
const 422 const Ball* a_pBallArray,
425 U32 a_keyIndex)
const 429 const U32 startIndex=
430 a_pElementArray[a_keyIndex][0];
431 return &m_pSubdivVertexArray[startIndex];
436 const Ball* a_pBallArray,
439 U32 a_keyIndex)
const 443 const U32 startIndex=
444 a_pElementArray[a_keyIndex][0];
445 return &m_pSubdivNormalArray[startIndex];
450 const Ball* a_pBallArray,
453 U32 a_keyIndex)
const 459 const U32 startIndex=
460 a_pElementArray[a_keyIndex][0];
461 return m_pSubdivUVArray?
462 &m_pSubdivUVArray[startIndex]:
467 const Color* faceColor(
468 const Ball* a_pBallArray,
470 const Color* a_pColorArray,
471 U32 a_keyIndex)
const 481 Child(
void): m_spNode(NULL),m_distance(0.0) {}
485 static int compare(
const void* a_pVoid1,
const void* a_pVoid2);
488 class Worker:
public Thread::Functor
493 m_spJobQueue(a_spJobQueue),
499 { m_spQuadTree=a_spQuadTree; }
518 void buildGraph(
void);
522 const Job lookupJob(I32 a_index);
530 void unlockSafe(
void);
kernel
Definition: namespace.dox:3
Node in a Directed Acyclic Graph.
Definition: DAGNode.h:18
Special vector for color (RGBA)
Definition: Color.h:21
Safe handle for shared pointer.
Definition: Handled.h:61
Automatically reference-counted string container.
Definition: String.h:128
Wrapper for std::vector.
Definition: Array.h:21
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
Triangular storage using a simple array.
Definition: FlatTree.h:20
Triangular storage using divisions by quarters.
Definition: QuadTree.h:20
Per-class participation non-RTTI fallback dynamic casting mechanism.
Definition: Castable.h:192
Object level locking for thread safety.
Definition: SafeShared.h:220