Skip to content

Instantly share code, notes, and snippets.

@chapulina
Created December 17, 2020 22:33
Show Gist options
  • Save chapulina/37ffbc3f54139c2ca849094cfb07c3ae to your computer and use it in GitHub Desktop.
Save chapulina/37ffbc3f54139c2ca849094cfb07c3ae to your computer and use it in GitHub Desktop.
Fix Ogre v1.9.0 compilation
diff --git a/OgreMain/include/OgreProgressiveMeshGenerator.h b/OgreMain/include/OgreProgressiveMeshGenerator.h
index b3f1af349..f8107a434 100644
--- a/OgreMain/include/OgreProgressiveMeshGenerator.h
+++ b/OgreMain/include/OgreProgressiveMeshGenerator.h
@@ -34,6 +34,7 @@
#include "OgreSmallVector.h"
#include "OgreMesh.h"
#include "OgreLodConfig.h"
+#include "OgreLogManager.h"
namespace Ogre
{
@@ -43,7 +44,7 @@ class _OgreExport ProgressiveMeshGeneratorBase
public:
/**
* @brief Generates the LOD levels for a mesh.
- *
+ *
* @param lodConfig Specification of the requested LOD levels.
*/
virtual void generateLodLevels(LodConfig& lodConfig) = 0;
@@ -214,8 +215,43 @@ protected:
size_t calcLodVertexCount(const LodLevel& lodConfig);
void tuneContainerSize();
void addVertexData(VertexData* vertexData, bool useSharedVertexLookup);
- template<typename IndexType>
- void addIndexDataImpl(IndexType* iPos, const IndexType* iEnd, VertexLookupList& lookup, unsigned short submeshID);
+template<typename IndexType>
+void addIndexDataImpl(IndexType* iPos, const IndexType* iEnd,
+ VertexLookupList& lookup,
+ unsigned short submeshID)
+{
+
+ // Loop through all triangles and connect them to the vertices.
+ for (; iPos < iEnd; iPos += 3) {
+ // It should never reallocate or every pointer will be invalid.
+ OgreAssert(mTriangleList.capacity() > mTriangleList.size(), "");
+ mTriangleList.push_back(PMTriangle());
+ PMTriangle* tri = &mTriangleList.back();
+ tri->isRemoved = false;
+ tri->submeshID = submeshID;
+ for (int i = 0; i < 3; i++) {
+ // Invalid index: Index is bigger then vertex buffer size.
+ OgreAssert(iPos[i] < lookup.size(), "");
+ tri->vertexID[i] = iPos[i];
+ tri->vertex[i] = lookup[iPos[i]];
+ }
+ if (tri->isMalformed()) {
+#if OGRE_DEBUG_MODE
+ stringstream str;
+ str << "In " << mMeshName << " malformed triangle found with ID: " << getTriangleID(tri) << ". " <<
+ std::endl;
+ printTriangle(tri, str);
+ str << "It will be excluded from LOD level calculations.";
+ LogManager::getSingleton().stream() << str.str();
+#endif
+ tri->isRemoved = true;
+ mIndexBufferInfoList[tri->submeshID].indexCount -= 3;
+ continue;
+ }
+ tri->computeNormal();
+ addTriangleToEdges(tri);
+ }
+}
void addIndexData(IndexData* indexData, bool useSharedVertexLookup, unsigned short submeshID);
void computeCosts();
diff --git a/OgreMain/src/OgreProgressiveMeshGenerator.cpp b/OgreMain/src/OgreProgressiveMeshGenerator.cpp
index b0aa854db..b68f49cf7 100644
--- a/OgreMain/src/OgreProgressiveMeshGenerator.cpp
+++ b/OgreMain/src/OgreProgressiveMeshGenerator.cpp
@@ -72,7 +72,7 @@ void ProgressiveMeshGeneratorBase::getAutoconfig( MeshPtr& inMesh, LodConfig& ou
// if 16 would be smaller, the first LOD would be nearer. if 625 would be bigger, the last LOD would be further away.
// if you increase 16 and decrease 625, first and Last LOD distance would be smaller.
lodLevel.distance = 3388608.f / i4;
-
+
// reductionValue = collapse cost
// Radius: Edges are multiplied by the length, when calculating collapse cost. So as a base value we use radius, which should help in balancing collapse cost to any mesh size.
// The constant and i5 are playing together. 1/(1/100k*i5)
@@ -219,43 +219,6 @@ void ProgressiveMeshGenerator::addVertexData(VertexData* vertexData, bool useSha
}
vbuf->unlock();
}
-template<typename IndexType>
-void ProgressiveMeshGenerator::addIndexDataImpl(IndexType* iPos, const IndexType* iEnd,
- VertexLookupList& lookup,
- unsigned short submeshID)
-{
-
- // Loop through all triangles and connect them to the vertices.
- for (; iPos < iEnd; iPos += 3) {
- // It should never reallocate or every pointer will be invalid.
- OgreAssert(mTriangleList.capacity() > mTriangleList.size(), "");
- mTriangleList.push_back(PMTriangle());
- PMTriangle* tri = &mTriangleList.back();
- tri->isRemoved = false;
- tri->submeshID = submeshID;
- for (int i = 0; i < 3; i++) {
- // Invalid index: Index is bigger then vertex buffer size.
- OgreAssert(iPos[i] < lookup.size(), "");
- tri->vertexID[i] = iPos[i];
- tri->vertex[i] = lookup[iPos[i]];
- }
- if (tri->isMalformed()) {
-#if OGRE_DEBUG_MODE
- stringstream str;
- str << "In " << mMeshName << " malformed triangle found with ID: " << getTriangleID(tri) << ". " <<
- std::endl;
- printTriangle(tri, str);
- str << "It will be excluded from LOD level calculations.";
- LogManager::getSingleton().stream() << str.str();
-#endif
- tri->isRemoved = true;
- mIndexBufferInfoList[tri->submeshID].indexCount -= 3;
- continue;
- }
- tri->computeNormal();
- addTriangleToEdges(tri);
- }
-}
void ProgressiveMeshGenerator::addIndexData(IndexData* indexData, bool useSharedVertexLookup, unsigned short submeshID)
{
@@ -636,7 +599,7 @@ Real ProgressiveMeshGenerator::computeEdgeCollapseCost(PMVertex* src, PMEdge* ds
cost = std::max(cost, (Real)0.005f);
cost *= 8;
#endif
-
+
}
}
@@ -900,7 +863,7 @@ void ProgressiveMeshGenerator::collapse(PMVertex* src)
#endif
}
}
-
+
dst->seam |= src->seam; // Inherit seam property
#ifndef PM_BEST_QUALITY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment