Working on excessive batch count bug.
This commit is contained in:
parent
bb67aaceb1
commit
a0bcd6b214
@ -1,8 +1,8 @@
|
||||
#ifndef __IndexedSurfacePatch_H__
|
||||
#define __IndexedSurfacePatch_H__
|
||||
|
||||
#include <set>
|
||||
#include <list>
|
||||
//#include <set>
|
||||
//#include <list>
|
||||
|
||||
#include "Constants.h"
|
||||
#include "IntegralVector3.h"
|
||||
@ -28,6 +28,10 @@ namespace Ogre
|
||||
|
||||
long int vertexIndices[OGRE_REGION_SIDE_LENGTH*2+1][OGRE_REGION_SIDE_LENGTH*2+1][OGRE_REGION_SIDE_LENGTH*2+1];
|
||||
|
||||
static long int noOfVerticesSubmitted;
|
||||
static long int noOfVerticesAccepted;
|
||||
static long int noOfTrianglesSubmitted;
|
||||
|
||||
private:
|
||||
bool m_AllowDuplicateVertices;
|
||||
};
|
||||
|
@ -2,6 +2,10 @@
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
long int IndexedSurfacePatch::noOfVerticesSubmitted = 0;
|
||||
long int IndexedSurfacePatch::noOfVerticesAccepted = 0;
|
||||
long int IndexedSurfacePatch::noOfTrianglesSubmitted = 0;
|
||||
|
||||
IndexedSurfacePatch::IndexedSurfacePatch(bool allowDuplicateVertices)
|
||||
:m_AllowDuplicateVertices(allowDuplicateVertices)
|
||||
{
|
||||
@ -14,6 +18,8 @@ namespace Ogre
|
||||
|
||||
void IndexedSurfacePatch::addTriangle(const SurfaceVertex& v0,const SurfaceVertex& v1,const SurfaceVertex& v2)
|
||||
{
|
||||
noOfTrianglesSubmitted++;
|
||||
noOfVerticesSubmitted += 3;
|
||||
if(!m_AllowDuplicateVertices)
|
||||
{
|
||||
long int index = vertexIndices[long int(v0.getPosition().x +0.5)][long int(v0.getPosition().y +0.5)][long int(v0.getPosition().z +0.5)];
|
||||
@ -21,6 +27,9 @@ namespace Ogre
|
||||
{
|
||||
m_vecVertices.push_back(v0);
|
||||
m_vecTriangleIndices.push_back(m_vecVertices.size()-1);
|
||||
vertexIndices[long int(v0.getPosition().x +0.5)][long int(v0.getPosition().y +0.5)][long int(v0.getPosition().z +0.5)] = m_vecVertices.size()-1;
|
||||
|
||||
noOfVerticesAccepted++;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -32,6 +41,9 @@ namespace Ogre
|
||||
{
|
||||
m_vecVertices.push_back(v1);
|
||||
m_vecTriangleIndices.push_back(m_vecVertices.size()-1);
|
||||
vertexIndices[long int(v1.getPosition().x +0.5)][long int(v1.getPosition().y +0.5)][long int(v1.getPosition().z +0.5)] = m_vecVertices.size()-1;
|
||||
|
||||
noOfVerticesAccepted++;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -43,6 +55,9 @@ namespace Ogre
|
||||
{
|
||||
m_vecVertices.push_back(v2);
|
||||
m_vecTriangleIndices.push_back(m_vecVertices.size()-1);
|
||||
vertexIndices[long int(v2.getPosition().x +0.5)][long int(v2.getPosition().y +0.5)][long int(v2.getPosition().z +0.5)] = m_vecVertices.size()-1;
|
||||
|
||||
noOfVerticesAccepted++;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -57,6 +72,8 @@ namespace Ogre
|
||||
m_vecTriangleIndices.push_back(m_vecVertices.size()-1);
|
||||
m_vecVertices.push_back(v2);
|
||||
m_vecTriangleIndices.push_back(m_vecVertices.size()-1);
|
||||
|
||||
noOfVerticesAccepted += 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,13 +144,21 @@ namespace Ogre
|
||||
if(surfaceUpToDate[regionX][regionY][regionZ] == false)
|
||||
{
|
||||
//Generate the surface
|
||||
//std::vector< std::vector<SurfaceVertex> > vertexData;
|
||||
//std::vector< std::vector<SurfaceTriangle> > indexData;
|
||||
IndexedSurfacePatch* singleMaterialPatch = new IndexedSurfacePatch(false);
|
||||
IndexedSurfacePatch* multiMaterialPatch = new IndexedSurfacePatch(true);
|
||||
|
||||
generateMeshDataForRegion(regionX,regionY,regionZ, singleMaterialPatch, multiMaterialPatch);
|
||||
|
||||
/*if((singleMaterialPatch->m_vecVertices.size == 0) && (singleMaterialPatch->m_vecTriangleIndices.size == 0))
|
||||
{
|
||||
//No geometry exists. We can delete the scene node if it exists (it might, if the region has only just become empty)
|
||||
std::map<UIntVector3, SceneNode*>::iterator iterSceneNode = sceneNodes.find(UIntVector3(regionX,regionY,regionZ));
|
||||
if(iterSceneNode != sceneNodes.end())
|
||||
{
|
||||
getRootSceneNode()->removeChild
|
||||
}
|
||||
}*/
|
||||
|
||||
//If a SceneNode doesn't exist in this position then create one.
|
||||
std::map<UIntVector3, SceneNode*>::iterator iterSceneNode = sceneNodes.find(UIntVector3(regionX,regionY,regionZ));
|
||||
SceneNode* sceneNode;
|
||||
@ -175,21 +183,21 @@ namespace Ogre
|
||||
triangleCounter += iterSurfacePatch->second.getNoOfTriangles();*/
|
||||
|
||||
SurfacePatchRenderable* singleMaterialSurfacePatchRenderable = m_singleMaterialSurfaces[regionX][regionY][regionZ];
|
||||
SurfacePatchRenderable* multiMaterialSurfacePatchRenderable = m_multiMaterialSurfaces[regionX][regionY][regionZ];
|
||||
//SurfacePatchRenderable* multiMaterialSurfacePatchRenderable = m_multiMaterialSurfaces[regionX][regionY][regionZ];
|
||||
if(singleMaterialSurfacePatchRenderable == 0) //if single is null then multi should also be null
|
||||
{
|
||||
//We have to create the surfaces
|
||||
singleMaterialSurfacePatchRenderable = new SurfacePatchRenderable(singleMaterialPatch,materialMap->getMaterialAtIndex(1));
|
||||
multiMaterialSurfacePatchRenderable = new SurfacePatchRenderable(multiMaterialPatch,materialMap->getMaterialAtIndex(2));
|
||||
//multiMaterialSurfacePatchRenderable = new SurfacePatchRenderable(multiMaterialPatch,materialMap->getMaterialAtIndex(2));
|
||||
|
||||
multiMaterialSurfacePatchRenderable->setRenderQueueGroup(RENDER_QUEUE_3);
|
||||
//multiMaterialSurfacePatchRenderable->setRenderQueueGroup(RENDER_QUEUE_3);
|
||||
singleMaterialSurfacePatchRenderable->setRenderQueueGroup(RENDER_QUEUE_4);
|
||||
|
||||
m_singleMaterialSurfaces[regionX][regionY][regionZ] = singleMaterialSurfacePatchRenderable;
|
||||
sceneNode->attachObject(singleMaterialSurfacePatchRenderable);
|
||||
|
||||
m_multiMaterialSurfaces[regionX][regionY][regionZ] = multiMaterialSurfacePatchRenderable;
|
||||
sceneNode->attachObject(multiMaterialSurfacePatchRenderable);
|
||||
//m_multiMaterialSurfaces[regionX][regionY][regionZ] = multiMaterialSurfacePatchRenderable;
|
||||
//sceneNode->attachObject(multiMaterialSurfacePatchRenderable);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -197,8 +205,8 @@ namespace Ogre
|
||||
singleMaterialSurfacePatchRenderable->updateWithNewSurfacePatch(singleMaterialPatch);
|
||||
sceneNode->attachObject(singleMaterialSurfacePatchRenderable);
|
||||
|
||||
multiMaterialSurfacePatchRenderable->updateWithNewSurfacePatch(multiMaterialPatch);
|
||||
sceneNode->attachObject(multiMaterialSurfacePatchRenderable);
|
||||
//multiMaterialSurfacePatchRenderable->updateWithNewSurfacePatch(multiMaterialPatch);
|
||||
//sceneNode->attachObject(multiMaterialSurfacePatchRenderable);
|
||||
}
|
||||
}
|
||||
//sceneNode->showBoundingBox(true);
|
||||
@ -213,6 +221,10 @@ namespace Ogre
|
||||
|
||||
//Now call the base class to do the actual visibility determination...
|
||||
SceneManager::_findVisibleObjects(cam, visibleBounds, onlyShadowCasters);
|
||||
|
||||
LogManager::getSingleton().logMessage("\nNo of triangles = " + StringConverter::toString(IndexedSurfacePatch::noOfTrianglesSubmitted));
|
||||
LogManager::getSingleton().logMessage("No of vertices submitted = " + StringConverter::toString(IndexedSurfacePatch::noOfVerticesSubmitted));
|
||||
LogManager::getSingleton().logMessage("No of vertices accepted = " + StringConverter::toString(IndexedSurfacePatch::noOfVerticesAccepted));
|
||||
}
|
||||
|
||||
void PolyVoxSceneManager::setAllUpToDateFalse(void)
|
||||
|
Loading…
x
Reference in New Issue
Block a user