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