diff --git a/include/SurfaceVertex.h b/include/SurfaceVertex.h index e386b5ad..1fe4f4ef 100644 --- a/include/SurfaceVertex.h +++ b/include/SurfaceVertex.h @@ -32,7 +32,7 @@ namespace Ogre { public: SurfaceVertex(); - SurfaceVertex(UIntVector3 positionToSet); + SurfaceVertex(UIntVector3 positionToSet, float alphaToSet); SurfaceVertex(UIntVector3 positionToSet, Vector3 normalToSet); friend bool operator==(const SurfaceVertex& lhs, const SurfaceVertex& rhs); @@ -50,9 +50,11 @@ namespace Ogre std::string toString(void) const; private: - UIntVector3 position; - Vector3 normal; float alpha; + Vector3 normal; + UIntVector3 position; + + SurfaceEdgeIterator edge; diff --git a/source/PolyVoxSceneManager.cpp b/source/PolyVoxSceneManager.cpp index a577970a..ef5fe703 100644 --- a/source/PolyVoxSceneManager.cpp +++ b/source/PolyVoxSceneManager.cpp @@ -626,16 +626,80 @@ namespace Ogre if((material0 == material1) && (material1 == material2)) { - SurfaceVertex surfaceVertex0(vertex0); - surfaceVertex0.setAlpha(1.0); - SurfaceVertex surfaceVertex1(vertex1); - surfaceVertex1.setAlpha(1.0); - SurfaceVertex surfaceVertex2(vertex2); - surfaceVertex2.setAlpha(1.0); + SurfaceVertex surfaceVertex0(vertex0,1.0); + SurfaceVertex surfaceVertex1(vertex1,1.0); + SurfaceVertex surfaceVertex2(vertex2,1.0); result[material0].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2); } + else if(material0 == material1) + { + { + SurfaceVertex surfaceVertex0(vertex0,1.0); + SurfaceVertex surfaceVertex1(vertex1,1.0); + SurfaceVertex surfaceVertex2(vertex2,0.0); + result[material0].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2); + } + { + SurfaceVertex surfaceVertex0(vertex0,0.0); + SurfaceVertex surfaceVertex1(vertex1,0.0); + SurfaceVertex surfaceVertex2(vertex2,1.0); + result[material2].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2); + } + } + else if(material1 == material2) + { + { + SurfaceVertex surfaceVertex0(vertex0,0.0); + SurfaceVertex surfaceVertex1(vertex1,1.0); + SurfaceVertex surfaceVertex2(vertex2,1.0); + result[material1].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2); + } + { + SurfaceVertex surfaceVertex0(vertex0,1.0); + SurfaceVertex surfaceVertex1(vertex1,0.0); + SurfaceVertex surfaceVertex2(vertex2,0.0); + result[material0].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2); + } + } + else if(material2 == material0) + { + { + SurfaceVertex surfaceVertex0(vertex0,1.0); + SurfaceVertex surfaceVertex1(vertex1,0.0); + SurfaceVertex surfaceVertex2(vertex2,1.0); + result[material0].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2); + } + { + SurfaceVertex surfaceVertex0(vertex0,0.0); + SurfaceVertex surfaceVertex1(vertex1,1.0); + SurfaceVertex surfaceVertex2(vertex2,0.0); + surfaceVertex2.setAlpha(0.0); + result[material1].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2); + } + } else + { + { + SurfaceVertex surfaceVertex0(vertex0,1.0); + SurfaceVertex surfaceVertex1(vertex1,0.0); + SurfaceVertex surfaceVertex2(vertex2,0.0); + result[material0].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2); + } + { + SurfaceVertex surfaceVertex0(vertex0,0.0); + SurfaceVertex surfaceVertex1(vertex1,1.0); + SurfaceVertex surfaceVertex2(vertex2,0.0); + result[material1].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2); + } + { + SurfaceVertex surfaceVertex0(vertex0,0.0); + SurfaceVertex surfaceVertex1(vertex1,0.0); + SurfaceVertex surfaceVertex2(vertex2,1.0); + result[material2].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2); + } + } + /*else { std::set materials; //FIXME - set::set is pretty slow for this as it only holds up to 3 vertices. materials.insert(material0); @@ -666,7 +730,7 @@ namespace Ogre result[material].addTriangle(surfaceVertex0, surfaceVertex1, surfaceVertex2); } - } + }*/ } } diff --git a/source/SurfaceVertex.cpp b/source/SurfaceVertex.cpp index 6d8b4f53..87ca5789 100644 --- a/source/SurfaceVertex.cpp +++ b/source/SurfaceVertex.cpp @@ -11,10 +11,12 @@ namespace Ogre { } - SurfaceVertex::SurfaceVertex(UIntVector3 positionToSet) - :position(positionToSet) + SurfaceVertex::SurfaceVertex(UIntVector3 positionToSet, float alphaToSet) + :alpha(alphaToSet) + ,position(positionToSet) + ,m_uHash((position.x*(OGRE_REGION_SIDE_LENGTH*2+1)*(OGRE_REGION_SIDE_LENGTH*2+1)) + (position.y*(OGRE_REGION_SIDE_LENGTH*2+1)) + (position.z)) { - m_uHash = (position.x*(OGRE_REGION_SIDE_LENGTH*2+1)*(OGRE_REGION_SIDE_LENGTH*2+1)) + (position.y*(OGRE_REGION_SIDE_LENGTH*2+1)) + (position.z); + } SurfaceVertex::SurfaceVertex(UIntVector3 positionToSet, Vector3 normalToSet)