MCPcopy Create free account
hub / github.com/davideberly/GeometricTools / SetTargetRecord

Method SetTargetRecord

GTE/Graphics/CLODMesh.cpp:20–81  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20bool CLODMesh::SetTargetRecord(int32_t targetRecord)
21{
22 if (0 <= targetRecord &&
23 targetRecord < GetNumRecords() &&
24 targetRecord != mTargetRecord)
25 {
26 auto* indices = mIBuffer->Get<int32_t>();
27
28 // Collapse the mesh, if necessary.
29 while (mTargetRecord < targetRecord)
30 {
31 ++mTargetRecord;
32
33 // Replace indices in the connectivity array.
34 auto const& record = mRecords[mTargetRecord];
35 for (size_t i = 0; i < record.indices.size(); ++i)
36 {
37 int32_t c = record.indices[i];
38 LogAssert(
39 indices[c] == record.vThrow,
40 "Inconsistent record in SetTargetRecord.");
41
42 indices[c] = record.vKeep;
43 }
44
45 // Reduce the vertex count; the vertices are properly ordered.
46 mVBuffer->SetNumActiveElements(record.numVertices);
47
48 // Reduce the triangle count; the triangles are properly ordered.
49 mIBuffer->SetNumActiveElements(3 * record.numTriangles);
50 }
51
52 // Expand the mesh, if necessary.
53 while (mTargetRecord > targetRecord)
54 {
55 // Restore indices in the connectivity array.
56 auto const& record = mRecords[mTargetRecord];
57 for (size_t i = 0; i < record.indices.size(); ++i)
58 {
59 int32_t c = record.indices[i];
60 LogAssert(
61 indices[c] == record.vKeep,
62 "Inconsistent record in SetTargetRecord.");
63
64 indices[c] = record.vThrow;
65 }
66
67 --mTargetRecord;
68 auto const& prevRecord = mRecords[mTargetRecord];
69
70 // Increase the vertex count; the vertices are properly ordered.
71 mVBuffer->SetNumActiveElements(prevRecord.numVertices);
72
73 // Increase the triangle count; the triangles are properly ordered.
74 mIBuffer->SetNumActiveElements(3 * prevRecord.numTriangles);
75 }
76
77 return true;

Callers 1

UpdateCLODMeshMethod · 0.80

Calls 1

SetNumActiveElementsMethod · 0.45

Tested by

no test coverage detected