MCPcopy Create free account
hub / github.com/davideberly/GeometricTools / GetTriangle

Method GetTriangle

GTE/Graphics/IndexBuffer.cpp:276–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274}
275
276bool IndexBuffer::GetTriangle(uint32_t i, uint32_t& v0, uint32_t& v1, uint32_t& v2) const
277{
278 if (ValidPrimitiveType(IP_HAS_TRIANGLES))
279 {
280 if (mData && i < mNumPrimitives)
281 {
282 if (mElementSize == sizeof(uint32_t))
283 {
284 if (mPrimitiveType == IP_TRIMESH)
285 {
286 uint32_t const* index = 3 * static_cast<size_t>(i) + Get<uint32_t>();
287 v0 = *index++;
288 v1 = *index++;
289 v2 = *index;
290 }
291 else if (mPrimitiveType == IP_TRISTRIP)
292 {
293 uint32_t const* index = static_cast<size_t>(i) + Get<uint32_t>();
294 uint32_t offset = (i & 1);
295 v0 = index[0];
296 v1 = index[1 + offset];
297 v2 = index[2 - offset];
298 }
299 else if (mPrimitiveType == IP_TRIMESH_ADJ)
300 {
301 uint32_t const* index = 6 * static_cast<size_t>(i) + Get<uint32_t>();
302 v0 = index[0];
303 v1 = index[2];
304 v2 = index[4];
305 }
306 else if (mPrimitiveType == IP_TRISTRIP_ADJ)
307 {
308 LogError("IP_TRISTRIP_ADJ not yet supported.");
309 }
310 }
311 else
312 {
313 if (mPrimitiveType == IP_TRIMESH)
314 {
315 uint16_t const* index = 3 * static_cast<size_t>(i) + Get<uint16_t>();
316 v0 = static_cast<uint32_t>(*index++);
317 v1 = static_cast<uint32_t>(*index++);
318 v2 = static_cast<uint32_t>(*index);
319 }
320 else if (mPrimitiveType == IP_TRISTRIP)
321 {
322 uint16_t const* index = static_cast<size_t>(i) + Get<uint16_t>();
323 int32_t offset = (i & 1);
324 v0 = static_cast<uint32_t>(index[0]);
325 v1 = static_cast<uint32_t>(index[1 + offset]);
326 v2 = static_cast<uint32_t>(index[2 - offset]);
327 }
328 else if (mPrimitiveType == IP_TRIMESH_ADJ)
329 {
330 uint16_t const* index = 6 * static_cast<size_t>(i) + Get<uint16_t>();
331 v0 = index[0];
332 v1 = index[2];
333 v2 = index[4];

Callers 7

TestIntersectionMethod · 0.45
FindIntersectionMethod · 0.45
UpdateModelNormalsMethod · 0.45
GetModelSpacePlanesMethod · 0.45
ReverseTriangleOrderMethod · 0.45
PickTrianglesMethod · 0.45

Calls

no outgoing calls

Tested by 1

TestIntersectionMethod · 0.36