MCPcopy Create free account
hub / github.com/TheRealMJP/SHforHLSL / updateEdgeAdjacency

Function updateEdgeAdjacency

SHTest/Externals/meshoptimizer/simplifier.cpp:51–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51static void updateEdgeAdjacency(EdgeAdjacency& adjacency, const unsigned int* indices, size_t index_count, size_t vertex_count, const unsigned int* remap)
52{
53 size_t face_count = index_count / 3;
54 unsigned int* offsets = adjacency.offsets + 1;
55 EdgeAdjacency::Edge* data = adjacency.data;
56
57 // fill edge counts
58 memset(offsets, 0, vertex_count * sizeof(unsigned int));
59
60 for (size_t i = 0; i < index_count; ++i)
61 {
62 unsigned int v = remap ? remap[indices[i]] : indices[i];
63 assert(v < vertex_count);
64
65 offsets[v]++;
66 }
67
68 // fill offset table
69 unsigned int offset = 0;
70
71 for (size_t i = 0; i < vertex_count; ++i)
72 {
73 unsigned int count = offsets[i];
74 offsets[i] = offset;
75 offset += count;
76 }
77
78 assert(offset == index_count);
79
80 // fill edge data
81 for (size_t i = 0; i < face_count; ++i)
82 {
83 unsigned int a = indices[i * 3 + 0], b = indices[i * 3 + 1], c = indices[i * 3 + 2];
84
85 if (remap)
86 {
87 a = remap[a];
88 b = remap[b];
89 c = remap[c];
90 }
91
92 data[offsets[a]].next = b;
93 data[offsets[a]].prev = c;
94 offsets[a]++;
95
96 data[offsets[b]].next = c;
97 data[offsets[b]].prev = a;
98 offsets[b]++;
99
100 data[offsets[c]].next = a;
101 data[offsets[c]].prev = b;
102 offsets[c]++;
103 }
104
105 // finalize offsets
106 adjacency.offsets[0] = 0;
107 assert(adjacency.offsets[vertex_count] == index_count);
108}

Callers 1

meshopt_simplifyEdgeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected