MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/PhysX / renderMeshes

Method renderMeshes

physx/samples/sampleframework/renderer/src/Renderer.cpp:519–570  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

517}
518
519void Renderer::renderMeshes(std::vector<RendererMeshContext>& meshes, RendererMaterial::Pass pass)
520{
521 PX_PROFILE_ZONE("Renderer_renderMeshes",0);
522
523 RendererMaterial *lastMaterial = 0;
524 RendererMaterialInstance *lastMaterialInstance = 0;
525 const RendererMesh *lastMesh = 0;
526
527 const PxU32 numMeshes = (PxU32)meshes.size();
528 for(PxU32 i=0; i<numMeshes; i++)
529 {
530 RendererMeshContext& context = meshes[i];
531
532 if(!context.mesh->willRender())
533 {
534 continue;
535 }
536
537 // the mesh context should be bound before the material, this is
538 // necessary because the materials read state from the graphics device
539 // for instance to determine if two-sided lighting should be enabled
540 bindMeshContext(context);
541
542 bool instanced = context.mesh->getInstanceBuffer()?true:false;
543
544 if(context.materialInstance && context.materialInstance != lastMaterialInstance)
545 {
546 if(lastMaterial) lastMaterial->unbind();
547 lastMaterialInstance = context.materialInstance;
548 lastMaterial = &context.materialInstance->getMaterial();
549 lastMaterial->bind(pass, lastMaterialInstance, instanced);
550 }
551 else if(context.material != lastMaterial)
552 {
553 if(lastMaterial) lastMaterial->unbind();
554 lastMaterialInstance = 0;
555 lastMaterial = context.material;
556 lastMaterial->bind(pass, lastMaterialInstance, instanced);
557 }
558
559 if(lastMaterial) lastMaterial->bindMeshState(instanced);
560 if(context.mesh != lastMesh)
561 {
562 if(lastMesh) lastMesh->unbind();
563 lastMesh = context.mesh;
564 if(lastMesh) lastMesh->bind();
565 }
566 if(lastMesh) context.mesh->render(context.material);
567 }
568 if(lastMesh) lastMesh->unbind();
569 if(lastMaterial) lastMaterial->unbind();
570}
571
572struct CompareMeshCameraDist
573{

Callers

nothing calls this directly

Calls 8

getInstanceBufferMethod · 0.80
sizeMethod · 0.45
willRenderMethod · 0.45
unbindMethod · 0.45
getMaterialMethod · 0.45
bindMethod · 0.45
bindMeshStateMethod · 0.45
renderMethod · 0.45

Tested by

no test coverage detected