text
stringlengths 0
2.2M
|
---|
mesh.verts[i*3+0] = mesh.verts[(i+1)*3+0];
|
mesh.verts[i*3+1] = mesh.verts[(i+1)*3+1];
|
mesh.verts[i*3+2] = mesh.verts[(i+1)*3+2];
|
}
|
mesh.nverts--;
|
// Adjust indices to match the removed vertex layout.
|
for (int i = 0; i < mesh.npolys; ++i)
|
{
|
unsigned short* p = &mesh.polys[i*MAX_VERTS_PER_POLY*2];
|
const int nv = countPolyVerts(p);
|
for (int j = 0; j < nv; ++j)
|
if (p[j] > rem) p[j]--;
|
}
|
for (int i = 0; i < nedges; ++i)
|
{
|
if (edges[i*3+0] > rem) edges[i*3+0]--;
|
if (edges[i*3+1] > rem) edges[i*3+1]--;
|
}
|
if (nedges == 0)
|
return DT_SUCCESS;
|
// Start with one vertex, keep appending connected
|
// segments to the start and end of the hole.
|
pushBack(edges[0], hole, nhole);
|
pushBack(edges[2], harea, nharea);
|
while (nedges)
|
{
|
bool match = false;
|
for (int i = 0; i < nedges; ++i)
|
{
|
const unsigned short ea = edges[i*3+0];
|
const unsigned short eb = edges[i*3+1];
|
const unsigned short a = edges[i*3+2];
|
bool add = false;
|
if (hole[0] == eb)
|
{
|
// The segment matches the beginning of the hole boundary.
|
if (nhole >= MAX_REM_EDGES)
|
return DT_FAILURE | DT_BUFFER_TOO_SMALL;
|
pushFront(ea, hole, nhole);
|
pushFront(a, harea, nharea);
|
add = true;
|
}
|
else if (hole[nhole-1] == ea)
|
{
|
// The segment matches the end of the hole boundary.
|
if (nhole >= MAX_REM_EDGES)
|
return DT_FAILURE | DT_BUFFER_TOO_SMALL;
|
pushBack(eb, hole, nhole);
|
pushBack(a, harea, nharea);
|
add = true;
|
}
|
if (add)
|
{
|
// The edge segment was added, remove it.
|
edges[i*3+0] = edges[(nedges-1)*3+0];
|
edges[i*3+1] = edges[(nedges-1)*3+1];
|
edges[i*3+2] = edges[(nedges-1)*3+2];
|
--nedges;
|
match = true;
|
--i;
|
}
|
}
|
if (!match)
|
break;
|
}
|
unsigned short tris[MAX_REM_EDGES*3];
|
unsigned char tverts[MAX_REM_EDGES*3];
|
unsigned short tpoly[MAX_REM_EDGES*3];
|
// Generate temp vertex array for triangulation.
|
for (int i = 0; i < nhole; ++i)
|
{
|
const unsigned short pi = hole[i];
|
tverts[i*4+0] = (unsigned char)mesh.verts[pi*3+0];
|
tverts[i*4+1] = (unsigned char)mesh.verts[pi*3+1];
|
tverts[i*4+2] = (unsigned char)mesh.verts[pi*3+2];
|
tverts[i*4+3] = 0;
|
tpoly[i] = (unsigned short)i;
|
}
|
// Triangulate the hole.
|
int ntris = triangulate(nhole, tverts, tpoly, tris);
|
if (ntris < 0)
|
{
|
// TODO: issue warning!
|
ntris = -ntris;
|
}
|
if (ntris > MAX_REM_EDGES)
|
return DT_FAILURE | DT_BUFFER_TOO_SMALL;
|
unsigned short polys[MAX_REM_EDGES*MAX_VERTS_PER_POLY];
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.