Path Tracer
SGSpatialSort.h
1 /*
2 Open Asset Import Library (assimp)
3 ----------------------------------------------------------------------
4 
5 Copyright (c) 2006-2020, assimp team
6 
7 
8 All rights reserved.
9 
10 Redistribution and use of this software in source and binary forms,
11 with or without modification, are permitted provided that the
12 following conditions are met:
13 
14 * Redistributions of source code must retain the above
15  copyright notice, this list of conditions and the
16  following disclaimer.
17 
18 * Redistributions in binary form must reproduce the above
19  copyright notice, this list of conditions and the
20  following disclaimer in the documentation and/or other
21  materials provided with the distribution.
22 
23 * Neither the name of the assimp team, nor the names of its
24  contributors may be used to endorse or promote products
25  derived from this software without specific prior
26  written permission of the assimp team.
27 
28 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 
40 ----------------------------------------------------------------------
41 */
42 
45 #pragma once
46 #ifndef AI_D3DSSPATIALSORT_H_INC
47 #define AI_D3DSSPATIALSORT_H_INC
48 
49 #ifdef __GNUC__
50 # pragma GCC system_header
51 #endif
52 
53 #include <assimp/types.h>
54 #include <vector>
55 #include <stdint.h>
56 
57 namespace Assimp {
58 
59 // ----------------------------------------------------------------------------------
65 // ----------------------------------------------------------------------------------
66 class ASSIMP_API SGSpatialSort
67 {
68 public:
69 
70  SGSpatialSort();
71 
72  // -------------------------------------------------------------------
76  explicit SGSpatialSort(const std::vector<aiVector3D>& vPositions);
77 
78  // -------------------------------------------------------------------
84  void Add(const aiVector3D& vPosition, unsigned int index,
85  unsigned int smoothingGroup);
86 
87  // -------------------------------------------------------------------
90  void Prepare();
91 
94 
95  // -------------------------------------------------------------------
108  // -------------------------------------------------------------------
109  void FindPositions( const aiVector3D& pPosition, uint32_t pSG,
110  float pRadius, std::vector<unsigned int>& poResults,
111  bool exactMatch = false) const;
112 
113 protected:
116 
117  // -------------------------------------------------------------------
121  // -------------------------------------------------------------------
122  struct Entry {
123  unsigned int mIndex;
125  uint32_t mSmoothGroups;
126  float mDistance;
127 
128  Entry() AI_NO_EXCEPT
129  : mIndex(0)
130  , mPosition()
131  , mSmoothGroups(0)
132  , mDistance(0.0f) {
133  // empty
134  }
135 
136  Entry( unsigned int pIndex, const aiVector3D& pPosition, float pDistance,uint32_t pSG)
137  : mIndex( pIndex)
138  , mPosition( pPosition)
139  , mSmoothGroups(pSG)
140  , mDistance( pDistance) {
141  // empty
142  }
143 
144  bool operator < (const Entry& e) const {
145  return mDistance < e.mDistance;
146  }
147  };
148 
149  // all positions, sorted by distance to the sorting plane
150  std::vector<Entry> mPositions;
151 };
152 
153 } // end of namespace Assimp
154 
155 #endif // AI_SPATIALSORT_H_INC
Assimp::SGSpatialSort::Prepare
void Prepare()
aiVector3D
Definition: vector3.h:136
types.h
Assimp::SGSpatialSort::Add
void Add(const aiVector3D &vPosition, unsigned int index, unsigned int smoothingGroup)
Assimp::SGSpatialSort::mPlaneNormal
aiVector3D mPlaneNormal
Definition: SGSpatialSort.h:115
Assimp::SGSpatialSort::SGSpatialSort
SGSpatialSort(const std::vector< aiVector3D > &vPositions)
Assimp::SGSpatialSort::~SGSpatialSort
~SGSpatialSort()
Assimp::SGSpatialSort::FindPositions
void FindPositions(const aiVector3D &pPosition, uint32_t pSG, float pRadius, std::vector< unsigned int > &poResults, bool exactMatch=false) const
Assimp::SGSpatialSort::Entry
Definition: SGSpatialSort.h:122
Assimp::SGSpatialSort::Entry::mIndex
unsigned int mIndex
The vertex referred by this entry.
Definition: SGSpatialSort.h:123
Assimp
Definition: ai_assert.h:50
Assimp::SGSpatialSort::Entry::mDistance
float mDistance
Distance of this vertex to the sorting plane.
Definition: SGSpatialSort.h:126
Assimp::SGSpatialSort::Entry::mPosition
aiVector3D mPosition
Position.
Definition: SGSpatialSort.h:124
Assimp::SGSpatialSort
Definition: SGSpatialSort.h:67