MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / removeVertex

Function removeVertex

Engine/lib/recast/Recast/Source/RecastMesh.cpp:666–984  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

664}
665
666static bool removeVertex(rcContext* ctx, rcPolyMesh& mesh, const unsigned short rem, const int maxTris)
667{
668 const int nvp = mesh.nvp;
669
670 // Count number of polygons to remove.
671 int numRemovedVerts = 0;
672 for (int i = 0; i < mesh.npolys; ++i)
673 {
674 unsigned short* p = &mesh.polys[i*nvp*2];
675 const int nv = countPolyVerts(p, nvp);
676 for (int j = 0; j < nv; ++j)
677 {
678 if (p[j] == rem)
679 numRemovedVerts++;
680 }
681 }
682
683 int nedges = 0;
684 rcScopedDelete<int> edges((int*)rcAlloc(sizeof(int)*numRemovedVerts*nvp*4, RC_ALLOC_TEMP));
685 if (!edges)
686 {
687 ctx->log(RC_LOG_WARNING, "removeVertex: Out of memory 'edges' (%d).", numRemovedVerts*nvp*4);
688 return false;
689 }
690
691 int nhole = 0;
692 rcScopedDelete<int> hole((int*)rcAlloc(sizeof(int)*numRemovedVerts*nvp, RC_ALLOC_TEMP));
693 if (!hole)
694 {
695 ctx->log(RC_LOG_WARNING, "removeVertex: Out of memory 'hole' (%d).", numRemovedVerts*nvp);
696 return false;
697 }
698
699 int nhreg = 0;
700 rcScopedDelete<int> hreg((int*)rcAlloc(sizeof(int)*numRemovedVerts*nvp, RC_ALLOC_TEMP));
701 if (!hreg)
702 {
703 ctx->log(RC_LOG_WARNING, "removeVertex: Out of memory 'hreg' (%d).", numRemovedVerts*nvp);
704 return false;
705 }
706
707 int nharea = 0;
708 rcScopedDelete<int> harea((int*)rcAlloc(sizeof(int)*numRemovedVerts*nvp, RC_ALLOC_TEMP));
709 if (!harea)
710 {
711 ctx->log(RC_LOG_WARNING, "removeVertex: Out of memory 'harea' (%d).", numRemovedVerts*nvp);
712 return false;
713 }
714
715 for (int i = 0; i < mesh.npolys; ++i)
716 {
717 unsigned short* p = &mesh.polys[i*nvp*2];
718 const int nv = countPolyVerts(p, nvp);
719 bool hasRem = false;
720 for (int j = 0; j < nv; ++j)
721 if (p[j] == rem) hasRem = true;
722 if (hasRem)
723 {

Callers 2

rcBuildPolyMeshFunction · 0.70
reduceVerticesMethod · 0.50

Calls 10

rcAllocFunction · 0.85
memcpyFunction · 0.85
memsetFunction · 0.85
mergePolyVertsFunction · 0.85
countPolyVertsFunction · 0.70
pushBackFunction · 0.70
pushFrontFunction · 0.70
triangulateFunction · 0.70
getPolyMergeValueFunction · 0.70
logMethod · 0.45

Tested by

no test coverage detected