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

Function removeVertex

Source/ThirdParty/recastnavigation/RecastMesh.cpp:663–981  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

rcBuildPolyMeshFunction · 0.70

Calls 10

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

Tested by

no test coverage detected