Cleaning up some code.

This commit is contained in:
David Williams 2008-02-05 21:33:09 +00:00
parent 1e3904098a
commit 91c2c7241c
5 changed files with 61 additions and 74 deletions

56
include/Block.h Normal file
View File

@ -0,0 +1,56 @@
/******************************************************************************
This file is part of a voxel plugin for OGRE
Copyright (C) 2006 David Williams
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
******************************************************************************/
#ifndef __Block_H__
#define __Block_H__
#include "OgrePrerequisites.h"
#include "Constants.h"
#include "TypeDef.h"
namespace Ogre
{
class VOXEL_SCENE_MANAGER_API Block
{
//Make VolumeIterator a friend
friend class VolumeIterator;
//Block interface
public:
Block();
Block(const Block& rhs);
~Block();
Block& operator=(const Block& rhs);
bool isHomogeneous(void);
uchar getVoxelAt(const uint xPosition, const uint yPosition, const uint zPosition) const;
void setVoxelAt(const uint xPosition, const uint yPosition, const uint zPosition, const uchar value);
void fillWithValue(const uchar value);
private:
uchar mData[OGRE_NO_OF_VOXELS_IN_BLOCK];
};
}
#endif

View File

@ -69,8 +69,6 @@ namespace Ogre
void generateMeshDataForRegion(uint regionX, uint regionY, uint regionZ, IndexedSurfacePatch* singleMaterialPatch, IndexedSurfacePatch* multiMaterialPatch) const;
void doRegionGrowing(uint xStart, uint yStart, uint zStart, uchar value);
bool containsPoint(Vector3 pos, float boundary);
bool containsPoint(IntVector3 pos, uint boundary);

View File

@ -27,15 +27,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "TypeDef.h"
#include "IntegralVector3.h"
#include <OgreResourceManager.h>
namespace Ogre
{
class VOXEL_SCENE_MANAGER_API Volume
{
//Make VolumeIterator a friend
friend class VolumeIterator;
friend class VolumeResource;
//Volume interface
public:
@ -45,8 +42,7 @@ namespace Ogre
Volume& operator=(const Volume& rhs);
//uchar getVoxelAt(const uint xPosition, const uint yPosition, const uint zPosition) const;
//void setVoxelAt(const uint xPosition, const uint yPosition, const uint zPosition, const uchar value);
SharedPtr<Block> getBlock(uint index);
bool containsPoint(Vector3 pos, float boundary);
bool containsPoint(IntVector3 pos, uint boundary);
@ -61,8 +57,6 @@ namespace Ogre
static SharedPtr<Block> mHomogeneousBlocks[256];
SharedPtr<Block> mBlocks[OGRE_NO_OF_BLOCKS_IN_VOLUME];
};
VOXEL_SCENE_MANAGER_API Volume createDilatedCopy(Volume& volInput, uchar value);
}
#endif

View File

@ -688,13 +688,6 @@ namespace Ogre
}
}
void PolyVoxSceneManager::doRegionGrowing(uint xStart, uint yStart, uint zStart, uchar value)
{
volumeData->regionGrow(xStart,yStart,zStart,value);
//FIXME - keep track of what has changed...
markRegionChanged(0,0,0,OGRE_VOLUME_SIDE_LENGTH-1,OGRE_VOLUME_SIDE_LENGTH-1,OGRE_VOLUME_SIDE_LENGTH-1);
}
uint PolyVoxSceneManager::getSideLength(void)
{
return OGRE_VOLUME_SIDE_LENGTH;

View File

@ -129,7 +129,10 @@ namespace Ogre
block->setVoxelAt(xOffset,yOffset,zOffset, value);
}*/
SharedPtr<Block> Volume::getBlock(uint index)
{
return mBlocks[index];
}
bool Volume::containsPoint(Vector3 pos, float boundary)
{
@ -332,61 +335,4 @@ namespace Ogre
}
}
}
Volume createDilatedCopy(Volume& volInput, uchar value)
{
Volume volResult = volInput;
VolumeIterator iterResult(volResult);
VolumeIterator iterInput(volInput);
//FIXME - use looping over region thing...
for(uint z = 1; z < OGRE_VOLUME_SIDE_LENGTH-1; z++)
{
//std::cout << "z = " << z << std::endl;
for(uint y = 1; y < OGRE_VOLUME_SIDE_LENGTH-1; y++)
{
for(uint x = 1; x < OGRE_VOLUME_SIDE_LENGTH-1; x++)
{
iterInput.setPosition(x,y,z);
if
(
(iterInput.peekVoxel1nx1ny1nz() == value) ||
(iterInput.peekVoxel1nx1ny0pz() == value) ||
(iterInput.peekVoxel1nx1ny1pz() == value) ||
(iterInput.peekVoxel1nx0py1nz() == value) ||
(iterInput.peekVoxel1nx0py0pz() == value) ||
(iterInput.peekVoxel1nx0py1pz() == value) ||
(iterInput.peekVoxel1nx1py1nz() == value) ||
(iterInput.peekVoxel1nx1py0pz() == value) ||
(iterInput.peekVoxel1nx1py1pz() == value) ||
(iterInput.peekVoxel0px1ny1nz() == value) ||
(iterInput.peekVoxel0px1ny0pz() == value) ||
(iterInput.peekVoxel0px1ny1pz() == value) ||
(iterInput.peekVoxel0px0py1nz() == value) ||
//(iterInput.peekVoxel0px0py0pz() == value) ||
(iterInput.peekVoxel0px0py1pz() == value) ||
(iterInput.peekVoxel0px1py1nz() == value) ||
(iterInput.peekVoxel0px1py0pz() == value) ||
(iterInput.peekVoxel0px1py1pz() == value) ||
(iterInput.peekVoxel1px1ny1nz() == value) ||
(iterInput.peekVoxel1px1ny0pz() == value) ||
(iterInput.peekVoxel1px1ny1pz() == value) ||
(iterInput.peekVoxel1px0py1nz() == value) ||
(iterInput.peekVoxel1px0py0pz() == value) ||
(iterInput.peekVoxel1px0py1pz() == value) ||
(iterInput.peekVoxel1px1py1nz() == value) ||
(iterInput.peekVoxel1px1py0pz() == value) ||
(iterInput.peekVoxel1px1py1pz() == value)
)
{
iterResult.setVoxelAt(x,y,z,value);
}
}
}
}
return volResult;
}
}