MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / _preprocess

Method _preprocess

Engine/source/math/mIntersector.h:158–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156
157template< typename Polyhedron >
158void PolyhedronBoxIntersector< Polyhedron >::_preprocess( const MatrixF& objToWorld, const Point3F& scale )
159{
160 PROFILE_SCOPE( PolyhedronBoxIntersector_preprocess );
161
162 // Transform the planes.
163
164 const U32 numPlanes = this->mTester.getNumPlanes();
165 const typename Polyhedron::PlaneType* planes = this->mTester.getPlanes();
166
167 PlaneTransformer transformer;
168 transformer.set( objToWorld, scale );
169
170 mPlanes.setSize( numPlanes );
171 for( U32 i = 0; i < numPlanes; ++ i )
172 transformer.transform( planes[ i ], mPlanes[ i ] );
173
174 // Extract the silhouettes for each of the three
175 // orthographic projections.
176
177 const U32 numEdges = this->mTester.getNumEdges();
178 const typename Polyhedron::EdgeType* edges = this->mTester.getEdges();
179 const typename Polyhedron::PointType* points = this->mTester.getPoints();
180
181 for( U32 i = 0; i < 3; ++ i )
182 {
183 U32 numEdgesThisProj = 0;
184
185 // Gather edge-lines for this projection.
186
187 for( U32 n = 0; n < numEdges; ++ n )
188 {
189 const typename Polyhedron::EdgeType& edge = edges[ n ];
190
191 // Compute dot product with face normals. With our projection
192 // pointing straight down the current axis, this is reduced to
193 // '1*normal[i]'.
194
195 F32 dotFace[ 2 ];
196
197 dotFace[ 0 ] = mPlanes[ edge.face[ 0 ] ][ i ];
198 dotFace[ 1 ] = mPlanes[ edge.face[ 1 ] ][ i ];
199
200 // Skip edge if not a silhouette edge in this view.
201
202 if( mSign( dotFace[ 0 ] ) == mSign( dotFace[ 1 ] ) )
203 continue;
204
205 // Find out which face is the front facing one. Since we expect normals
206 // to be pointing inwards, this means a reversal of the normal back facing
207 // test and we're looking for a normal facing the *same* way as our projection.
208
209 const U32 frontFace = dotFace[ 0 ] > 0.f ? 0 : 1;
210 if( dotFace[ frontFace ] <= 0.f )
211 continue; // This face or other face is perpendicular to us.
212
213 // Now we want to find the line equation for the edge. For that, we first need
214 // the normal. The direction of the normal is important so that we identify
215 // the half-spaces correctly. We want it to be pointing to the inside of the

Callers

nothing calls this directly

Calls 15

mSignFunction · 0.85
mulPMethod · 0.80
swapFunction · 0.70
mDotFunction · 0.70
Point3FClass · 0.70
getNumPlanesMethod · 0.45
getPlanesMethod · 0.45
setMethod · 0.45
setSizeMethod · 0.45
transformMethod · 0.45
getNumEdgesMethod · 0.45
getEdgesMethod · 0.45

Tested by

no test coverage detected