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

Method initVertexBuffers

Engine/source/ts/tsShape.cpp:613–726  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

611}
612
613void TSShape::initVertexBuffers()
614{
615 // Assumes mVertexData is valid
616 if (!mShapeVertexData.vertexDataReady)
617 {
618 AssertFatal(false, "WTF");
619 }
620
621 U32 destIndices = 0;
622 U32 destPrims = 0;
623
624 for (Vector<TSMesh*>::iterator iter = meshes.begin(); iter != meshes.end(); iter++)
625 {
626 TSMesh *mesh = *iter;
627 if (!mesh ||
628 (mesh->getMeshType() != TSMesh::StandardMeshType &&
629 mesh->getMeshType() != TSMesh::SkinMeshType))
630 continue;
631
632 destIndices += mesh->mIndices.size();
633 destPrims += mesh->mPrimitives.size();
634 }
635
636 // For HW skinning we can just use the static buffer
637 if (TSShape::smUseHardwareSkinning)
638 {
639 getVertexBuffer(mShapeVertexBuffer, GFXBufferTypeStatic);
640 }
641
642 // Also the IBO
643 mShapeVertexIndices.set(GFX, destIndices, destPrims, GFXBufferTypeStatic);
644 U16 *indicesStart = NULL;
645 mShapeVertexIndices.lock(&indicesStart, NULL);
646 U16 *ibIndices = indicesStart;
647 GFXPrimitive *piInput = mShapeVertexIndices->mPrimitiveArray;
648 U32 vertStart = 0;
649 U32 primStart = 0;
650 U32 indStart = 0;
651
652 // Create VBO
653 for (Vector<TSMesh*>::iterator iter = meshes.begin(); iter != meshes.end(); iter++)
654 {
655 TSMesh *mesh = *iter;
656 if (!mesh ||
657 (mesh->getMeshType() != TSMesh::StandardMeshType &&
658 mesh->getMeshType() != TSMesh::SkinMeshType))
659 continue;
660
661 // Make the offset vbo
662 mesh->mPrimBufferOffset = primStart;
663
664 // Dump primitives to locked buffer
665 mesh->dumpPrimitives(vertStart, indStart, piInput, ibIndices);
666
667 AssertFatal(mesh->mVertOffset / mVertexSize == vertStart, "offset mismatch");
668
669 vertStart += mesh->mNumVerts;
670 primStart += mesh->mPrimitives.size();

Callers

nothing calls this directly

Calls 9

getMeshTypeMethod · 0.80
dumpPrimitivesMethod · 0.80
printVertsMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
setMethod · 0.45
lockMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected