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

Method end

Engine/source/collision/clippedPolyList.cpp:176–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174//----------------------------------------------------------------------------
175
176void ClippedPolyList::end()
177{
178 PROFILE_SCOPE( ClippedPolyList_Clip );
179
180 Poly& poly = mPolyList.last();
181
182 // Reject polygons facing away from our normal.
183 if ( mDot( poly.plane, mNormal ) < mNormalTolCosineRadians )
184 {
185 mIndexList.setSize(poly.vertexStart);
186 mPolyList.decrement();
187 return;
188 }
189
190 // Build initial inside/outside plane masks
191 U32 indexStart = poly.vertexStart;
192 U32 vertexCount = mIndexList.size() - indexStart;
193
194 U32 frontMask = 0,backMask = 0;
195 U32 i;
196 for (i = indexStart; i < mIndexList.size(); i++)
197 {
198 U32 mask = mVertexList[mIndexList[i]].mask;
199 frontMask |= mask;
200 backMask |= ~mask;
201 }
202
203 // Trivial accept if all the vertices are on the backsides of
204 // all the planes.
205 if (!frontMask)
206 {
207 poly.vertexCount = vertexCount;
208 return;
209 }
210
211 // Trivial reject if any plane not crossed has all it's points
212 // on the front.
213 U32 crossMask = frontMask & backMask;
214 if (~crossMask & frontMask)
215 {
216 mIndexList.setSize(poly.vertexStart);
217 mPolyList.decrement();
218 return;
219 }
220
221 // Potentially, this will add up to mPlaneList.size() * (indexStart - indexEnd)
222 // elements to mIndexList, so ensure that it has enough space to store that
223 // so we can use push_back_noresize. If you find this code block getting hit
224 // frequently, changing the value of 'IndexListReserveSize' or doing some selective
225 // allocation is suggested
226 //
227 // TODO: Re-visit this, since it obviously does not work correctly, and than
228 // re-enable the push_back_noresize
229 //while(mIndexList.size() + mPlaneList.size() * (mIndexList.size() - indexStart) > mIndexList.capacity() )
230 // mIndexList.reserve(mIndexList.capacity() * 2);
231
232 // Need to do some clipping
233 for (U32 p = 0; p < mPlaneList.size(); p++)

Callers 3

cullUnusedVertsMethod · 0.45
triangulateMethod · 0.45
generateNormalsMethod · 0.45

Calls 11

mLerpFunction · 0.85
memcpyFunction · 0.85
decrementMethod · 0.80
incrementMethod · 0.80
distToPlaneMethod · 0.80
mDotFunction · 0.50
lastMethod · 0.45
setSizeMethod · 0.45
sizeMethod · 0.45
normalizeSafeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected