MCPcopy Create free account
hub / github.com/MyGUI/mygui / GetMeshInformation

Method GetMeshInformation

UnitTests/UnitTest_Layers/SceneObject.cpp:34–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32 }
33
34 void SceneObject::GetMeshInformation(
35 const Ogre::MeshPtr mesh,
36 size_t& vertex_count,
37 Ogre::Vector3*& vertices,
38 size_t& index_count,
39 unsigned long*& indices,
40 Ogre::Vector2*& coords,
41 const Ogre::Vector3& position,
42 const Ogre::Quaternion& orient,
43 const Ogre::Vector3& scale,
44 std::string_view _material)
45 {
46 bool added_shared = false;
47 size_t current_offset = 0;
48 //size_t shared_offset = 0;
49 size_t next_offset = 0;
50 size_t index_offset = 0;
51
52 vertex_count = index_count = 0;
53
54 // Calculate how many vertices and indices we're going to need
55 for (unsigned short i = 0; i < mesh->getNumSubMeshes(); ++i)
56 {
57 Ogre::SubMesh* submesh = mesh->getSubMesh(i);
58 if (submesh->getMaterialName() != _material)
59 continue;
60
61 // We only need to add the shared vertices once
62 if (submesh->useSharedVertices)
63 {
64 if (!added_shared)
65 {
66 vertex_count += mesh->sharedVertexData->vertexCount;
67 added_shared = true;
68 }
69 }
70 else
71 {
72 vertex_count += submesh->vertexData->vertexCount;
73 }
74
75 // Add the indices
76 index_count += submesh->indexData->indexCount;
77 }
78
79
80 // Allocate space for the vertices and indices
81 vertices = new Ogre::Vector3[vertex_count];
82 indices = new unsigned long[index_count];
83 coords = new Ogre::Vector2[vertex_count];
84
85 added_shared = false;
86
87 // Run through the submeshes again, adding the data into the arrays
88 for (unsigned short i = 0; i < mesh->getNumSubMeshes(); ++i)
89 {
90 Ogre::SubMesh* submesh = mesh->getSubMesh(i);
91 if (submesh->getMaterialName() != _material)

Callers

nothing calls this directly

Calls 4

getOffsetMethod · 0.80
lockMethod · 0.45
unlockMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected