mirror of
https://github.com/Relintai/godot-lportal.git
synced 2024-11-11 10:52:09 +01:00
Properly deal with duplicate verts in portal geometry
This commit is contained in:
parent
fd88f6fc0a
commit
969abe8092
3
SCsub
3
SCsub
@ -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
|
||||
|
1
ldebug.h
1
ldebug.h
@ -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";\
|
||||
|
23
lportal.cpp
23
lportal.cpp
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user