Properly deal with duplicate verts in portal geometry

This commit is contained in:
lawnjelly 2020-01-07 18:16:54 +00:00 committed by GitHub
parent fd88f6fc0a
commit 969abe8092
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 4 deletions

3
SCsub
View File

@ -15,7 +15,8 @@ sources = [
]
module_env = env.Clone()
module_env.Append(CXXFLAGS=['-O2', '-std=c++11', '-Wno-sign-compare', '-Wno-strict-aliasing'])
#module_env.Append(CXXFLAGS=['-O2', '-std=c++11', '-Wno-sign-compare', '-Wno-strict-aliasing'])
module_env.Append(CXXFLAGS=['-std=c++11', '-Wno-sign-compare', '-Wno-strict-aliasing'])
if ARGUMENTS.get('lportal_shared', 'no') == 'yes':
# Shared lib compilation

View File

@ -24,6 +24,7 @@
// you won't be able to get frame debugging of the visibility tree though.
#ifdef DEBUG_ENABLED
#pragma message ("LPortal DEBUG_ENABLED")
#define LPRINT_RUN(a, b) {String sz;\
for (int n=0; n<Lawn::LDebug::m_iTabDepth; n++)\
sz += "\t";\

View File

@ -234,15 +234,32 @@ void LPortal::CreateGeometry(PoolVector<Vector3> p_vertices, const Transform &tr
int nPoints = p_vertices.size();
ERR_FAIL_COND(nPoints < 3);
m_ptsWorld.resize(nPoints);
m_ptsWorld.clear();
//print("\t\t\tLPortal::CreateGeometry nPoints : " + itos(nPoints));
for (int n=0; n<nPoints; n++)
{
Vector3 ptWorld = trans.xform(p_vertices[n]);
m_ptsWorld.set(n, ptWorld);
m_ptCentre += ptWorld;
// new!! test for duplicates. Some geometry may contain duplicate verts in portals which will muck up
// the winding etc...
bool bDuplicate = false;
for (int m=0; m<m_ptsWorld.size(); m++)
{
Vector3 ptDiff = ptWorld - m_ptsWorld[m];
if (ptDiff.length() < 0.001f)
{
bDuplicate = true;
break;
}
}
if (!bDuplicate)
{
m_ptsWorld.push_back(ptWorld);
m_ptCentre += ptWorld;
}
//print("\t\t\t\t" + itos(n) + "\tLocal : " + Variant(p_vertices[n]) + "\tWorld : " + ptWorld);
}