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

Method drawPolyhedronDebugInfo

Engine/source/gfx/sim/debugDraw.cpp:484–549  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

482}
483
484void DebugDrawer::drawPolyhedronDebugInfo( const AnyPolyhedron& polyhedron, const MatrixF& transform, const Point3F& scale )
485{
486 Point3F center = polyhedron.getCenterPoint();
487 center.convolve( scale );
488 transform.mulP( center );
489
490 // Render plane indices and normals.
491
492 const U32 numPlanes = polyhedron.getNumPlanes();
493 for( U32 i = 0; i < numPlanes; ++ i )
494 {
495 const AnyPolyhedron::PlaneType& plane = polyhedron.getPlanes()[ i ];
496
497 Point3F planePos = plane.getPosition();
498 planePos.convolve( scale );
499 transform.mulP( planePos );
500
501 Point3F normal = plane.getNormal();
502 transform.mulV( normal );
503
504 drawText( planePos, String::ToString( i ), ColorI::BLACK );
505 drawLine( planePos, planePos + normal, ColorI::GREEN );
506 }
507
508 // Render edge indices and direction indicators.
509
510 const U32 numEdges = polyhedron.getNumEdges();
511 for( U32 i = 0; i < numEdges; ++ i )
512 {
513 const AnyPolyhedron::EdgeType& edge = polyhedron.getEdges()[ i ];
514
515 Point3F v1 = polyhedron.getPoints()[ edge.vertex[ 0 ] ];
516 Point3F v2 = polyhedron.getPoints()[ edge.vertex[ 1 ] ];
517
518 v1.convolve( scale );
519 v2.convolve( scale );
520 transform.mulP( v1 );
521 transform.mulP( v2 );
522
523 const Point3F midPoint = v1 + ( v2 - v1 ) / 2.f;
524
525 drawText( midPoint, String::ToString( "%i (%i, %i)", i, edge.face[ 0 ], edge.face[ 1 ] ), ColorI::WHITE );
526
527 // Push out the midpoint away from the center to place the direction indicator.
528
529 Point3F pushDir = midPoint - center;
530 pushDir.normalize();
531 const Point3F dirPoint = midPoint + pushDir;
532 const Point3F lineDir = ( v2 - v1 ) / 2.f;
533
534 drawLine( dirPoint, dirPoint + lineDir, ColorI::RED );
535 }
536
537 // Render point indices and coordinates.
538
539 const U32 numPoints = polyhedron.getNumPoints();
540 for( U32 i = 0; i < numPoints; ++ i )
541 {

Callers 3

_renderObjectMethod · 0.80
_renderObjectMethod · 0.80
_renderObjectMethod · 0.80

Calls 14

mulPMethod · 0.80
mulVMethod · 0.80
drawLineFunction · 0.50
getCenterPointMethod · 0.45
convolveMethod · 0.45
getNumPlanesMethod · 0.45
getPlanesMethod · 0.45
getPositionMethod · 0.45
getNormalMethod · 0.45
getNumEdgesMethod · 0.45
getEdgesMethod · 0.45
getPointsMethod · 0.45

Tested by

no test coverage detected