MCPcopy Create free account
hub / github.com/beefytech/Beef / Compact

Method Compact

BeefySysLib/gfx/ModelDef.cpp:167–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167void ModelDef::Compact()
168{
169 for (auto& mesh : mMeshes)
170 {
171 for (auto& prims : mesh.mPrimitives)
172 {
173 Array<int> vtxMap;
174 vtxMap.Insert(0, -1, prims.mVertices.mSize);
175 int newVtxIdx = 0;
176
177 for (uint16 vtxIdx : prims.mIndices)
178 {
179 if (vtxMap[vtxIdx] == -1)
180 vtxMap[vtxIdx] = newVtxIdx++;
181 }
182
183 if (newVtxIdx >= prims.mVertices.mSize)
184 continue;
185
186 for (uint16& vtxIdx : prims.mIndices)
187 vtxIdx = vtxMap[vtxIdx];
188
189 Array<ModelVertex> oldVertices = prims.mVertices;
190 prims.mVertices.Resize(newVtxIdx);
191 for (int oldVtxIdx = 0; oldVtxIdx < oldVertices.mSize; oldVtxIdx++)
192 {
193 int newVtxIdx = vtxMap[oldVtxIdx];
194 if (newVtxIdx != -1)
195 prims.mVertices[newVtxIdx] = oldVertices[oldVtxIdx];
196 }
197 }
198 }
199}
200
201void ModelDef::CalcBounds()
202{

Callers 1

ModelDef_CompactFunction · 0.80

Calls 2

InsertMethod · 0.45
ResizeMethod · 0.45

Tested by

no test coverage detected