MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / addVertex

Function addVertex

Source/ThirdParty/recastnavigation/RecastMesh.cpp:136–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136static unsigned short addVertex(unsigned short x, unsigned short y, unsigned short z,
137 unsigned short* verts, int* firstVert, int* nextVert, int& nv)
138{
139 int bucket = computeVertexHash(x, 0, z);
140 int i = firstVert[bucket];
141
142 while (i != -1)
143 {
144 const unsigned short* v = &verts[i*3];
145 if (v[0] == x && (rcAbs(v[1] - y) <= 2) && v[2] == z)
146 return (unsigned short)i;
147 i = nextVert[i]; // next
148 }
149
150 // Could not find, create new.
151 i = nv; nv++;
152 unsigned short* v = &verts[i*3];
153 v[0] = x;
154 v[1] = y;
155 v[2] = z;
156 nextVert[i] = firstVert[bucket];
157 firstVert[bucket] = i;
158
159 return (unsigned short)i;
160}
161
162// Last time I checked the if version got compiled using cmov, which was a lot faster than module (with idiv).
163inline int prev(int i, int n) { return i-1 >= 0 ? i-1 : n-1; }

Callers 2

rcBuildPolyMeshFunction · 0.70
rcMergePolyMeshesFunction · 0.70

Calls 2

computeVertexHashFunction · 0.85
rcAbsFunction · 0.85

Tested by

no test coverage detected