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

Method renderDebugNormals

Engine/source/ts/tsShapeInstance.cpp:331–393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

329//-------------------------------------------------------------------------------------
330
331void TSShapeInstance::renderDebugNormals( F32 normalScalar, S32 dl )
332{
333 if ( dl < 0 )
334 return;
335
336 AssertFatal( dl >= 0 && dl < mShape->details.size(),
337 "TSShapeInstance::renderDebugNormals() - Bad detail level!" );
338
339 static GFXStateBlockRef sb;
340 if ( sb.isNull() )
341 {
342 GFXStateBlockDesc desc;
343 desc.setCullMode( GFXCullNone );
344 desc.setZReadWrite( true );
345 desc.zWriteEnable = false;
346 desc.vertexColorEnable = true;
347
348 sb = GFX->createStateBlock( desc );
349 }
350 GFX->setStateBlock( sb );
351
352 const TSDetail *detail = &mShape->details[dl];
353 const S32 ss = detail->subShapeNum;
354 if ( ss < 0 )
355 return;
356
357 const S32 start = mShape->subShapeFirstObject[ss];
358 const S32 end = start + mShape->subShapeNumObjects[ss];
359
360 for ( S32 i = start; i < end; i++ )
361 {
362 MeshObjectInstance *meshObj = &mMeshObjects[i];
363 if ( !meshObj )
364 continue;
365
366 const MatrixF &meshMat = meshObj->getTransform();
367
368 // Then go through each TSMesh...
369 U32 m = 0;
370 for( TSMesh *mesh = meshObj->getMesh(m); mesh != NULL; mesh = meshObj->getMesh(m++) )
371 {
372 // and pull out the list of normals.
373 const U32 numNrms = mesh->mNumVerts;
374 PrimBuild::begin( GFXLineList, 2 * numNrms );
375 for ( U32 n = 0; n < numNrms; n++ )
376 {
377 const TSMesh::__TSMeshVertexBase &v = mesh->mVertexData.getBase(n);
378 Point3F norm = v.normal();
379 Point3F vert = v.vert();
380
381 meshMat.mulP( vert );
382 meshMat.mulV( norm );
383
384 // Then render them.
385 PrimBuild::color4f( mFabs( norm.x ), mFabs( norm.y ), mFabs( norm.z ), 1.0f );
386 PrimBuild::vertex3fv( vert );
387 PrimBuild::vertex3fv( vert + (norm * normalScalar) );
388 }

Callers 1

_renderNormalsMethod · 0.80

Calls 15

beginFunction · 0.85
color4fFunction · 0.85
mFabsFunction · 0.85
endFunction · 0.85
setCullModeMethod · 0.80
setZReadWriteMethod · 0.80
createStateBlockMethod · 0.80
normalMethod · 0.80
vertMethod · 0.80
mulPMethod · 0.80
mulVMethod · 0.80
vertex3fvFunction · 0.50

Tested by

no test coverage detected