Free Electron
FlatTree.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __surface_FlatTree_h__
8 #define __surface_FlatTree_h__
9 
10 namespace fe
11 {
12 namespace ext
13 {
14 
15 /**************************************************************************//**
16  @brief Triangular storage using a simple array
17 
18  @ingroup surface
19 *//***************************************************************************/
20 class FE_DL_EXPORT FlatTree: public SpatialTreeBase
21 {
22  public:
23 
24  FlatTree(void);
25 virtual ~FlatTree(void);
26 
27 virtual void setRefinement(U32 a_refinement) {}
28 
29 virtual void populate(
30  const Vector3i* a_pElementArray,
31  const SpatialVector* a_pVertexArray,
32  const SpatialVector* a_pNormalArray,
33  const Vector2* a_pUVArray,
34  const Color* a_pColorArray,
35  const I32* a_pTriangleIndexArray,
36  const I32* a_pPointIndexArray,
37  const I32* a_pPrimitiveIndexArray,
38  const I32* a_pPartitionIndexArray,
39  U32 a_primitives,U32 a_vertices,
40  const SpatialVector& a_center,F32 a_radius);
41 virtual Real nearestPoint(const SpatialVector& a_origin,
42  Real a_maxDistance,BWORD a_anyHit,U32 a_hitLimit,
43  const sp<PartitionI>& a_rspPartition,
44  Array< sp<SpatialTreeI::Hit> >& a_rHitArray)
45  const;
46 virtual Real rayImpact(const SpatialVector& a_origin,
47  const SpatialVector& a_direction,
48  Real a_maxDistance,BWORD a_anyHit,U32 a_hitLimit,
49  const sp<PartitionI>& a_rspPartition,
50  Array< sp<SpatialTreeI::Hit> >& a_rHitArray)
51  const;
52 
53  protected:
54 
55  class Ball
56  {
57  public:
58  Vector4 m_sphere;
59  I32 m_faceIndex;
60  I32 m_triangleIndex;
61  I32 m_primitiveIndex;
62  I32 m_partitionIndex;
63  };
64 
65  void nearestAccumulate(I32 a_face,I32 a_triangleIndex,
66  I32 a_primitiveIndex,I32 a_partitionIndex,
67  const SpatialVector& a_origin,U32 a_hitLimit,
68  Array< sp<SpatialTreeI::Hit> >& a_rHitArray,
69  const SpatialVector& a_rCenter,Real a_radius,
70  const I32* a_pPointIndex,
71  const SpatialVector* a_pVertex,
72  const SpatialVector* a_pNormal) const;
73 
74 static void addHit(U32 a_hitLimit,
75  Array< sp<SpatialTreeI::Hit> >& a_rHitArray,
76  CountedPool<Hit>& a_rHitPool,Real a_distance,
77  const SpatialVector& a_rDirection,
78  const SpatialVector& a_rIntersection,
79  I32 a_face,I32 a_triangleIndex,
80  I32 a_primitiveIndex,I32 a_partitionIndex,
81  const SpatialBary& a_rBarycenter,
82  const Vector2& a_rUV,
83  const SpatialVector& a_rDu,
84  const SpatialVector& a_rDv,
85  const Color& a_rColor,
86  const I32 a_subCount,
87  const I32* a_pPointIndex,
88  const SpatialVector* a_pVertex,
89  const SpatialVector* a_pNormal);
90 
91  struct Sort
92  {
93  bool operator()(const sp<SpatialTreeI::Hit>& rspHit1,
94  const sp<SpatialTreeI::Hit>& rspHit2)
95  {
96  return (rspHit1->distance() < rspHit2->distance());
97  }
98  };
99 
100  void cacheSpheres(void);
101 
102 const Vector3i* m_pElementArray;
103 const SpatialVector* m_pVertexArray;
104 const SpatialVector* m_pNormalArray;
105 const Vector2* m_pUVArray;
106 const Color* m_pColorArray;
107 const I32* m_pTriangleIndexArray;
108 const I32* m_pPointIndexArray;
109 const I32* m_pPrimitiveIndexArray;
110 const I32* m_pPartitionIndexArray;
111  U32 m_primitives;
112  U32 m_vertices;
113 
114  Ball* m_pBallArray;
115  U32 m_ballCount; // != primitive count if clipped
116 
117 mutable CountedPool<Hit> m_hitPool;
118 };
119 
120 } /* namespace ext */
121 } /* namespace fe */
122 
123 #endif /* __surface_FlatTree_h__ */
kernel
Definition: namespace.dox:3
Special vector for color (RGBA)
Definition: Color.h:21
Triangular storage using a simple array.
Definition: SpatialTreeBase.h:20
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