Patch to compile against Ogre trunk

sinbad

20-02-2009 15:55:19

I happened to grab ETL to try compiling against Ogre trunk today and there were a number of issues, which I fixed. I couldn't find a patch list so I'll post the patch here.

Changes:
- Unqualified STL structures like 'vector' are now ambiguous so I removed all the 'using namespace' entries for that and made them all explicit
- Fixed for changes in LOD API
- Fixed #pragma when not finding Shoggoth
- Fixed warnings about using ~bool instead of !bool


Index: EditableTerrain/include/ETCompatibility.h
===================================================================
--- EditableTerrain/include/ETCompatibility.h (revision 50)
+++ EditableTerrain/include/ETCompatibility.h (working copy)
@@ -53,7 +53,7 @@
typedef FakeRenderableVisitor OgreRenderableVisitor;
#else
#if OGRE_VERSION_MINOR != 6
- #warning Unknown OGRE version. Assuming Shoggoth compatibility.
+ #pragma message("Unknown OGRE version. Assuming Shoggoth compatibility.")
#endif
#define ET_OGRE_ALLOC(type, count) OGRE_ALLOC_T(type, count, MEMCATEGORY_GENERAL)
#define ET_OGRE_FREE(var) OGRE_FREE(var, MEMCATEGORY_GENERAL)
Index: EditableTerrain/include/ETPatch.h
===================================================================
--- EditableTerrain/include/ETPatch.h (revision 50)
+++ EditableTerrain/include/ETPatch.h (working copy)
@@ -130,9 +130,9 @@
IndexHandler* mIndexHandler;
unsigned int mVertexOptions;

- /** Max level of detail */
+ /** std::max level of detail */
unsigned int mMaxLOD;
- /** Max LOD error margin */
+ /** std::max LOD error margin */
Ogre::Real mMaxError;
/** Current level of detail */
unsigned int mCurLOD;
Index: EditableTerrain/src/ETAutoUpdater.cpp
===================================================================
--- EditableTerrain/src/ETAutoUpdater.cpp (revision 50)
+++ EditableTerrain/src/ETAutoUpdater.cpp (working copy)
@@ -66,6 +66,7 @@
(*it)->update();
mTimeSinceLastUpdate -= mUpdateInterval;
}
+ return true;
}
}

Index: EditableTerrain/src/ETBrush.cpp
===================================================================
--- EditableTerrain/src/ETBrush.cpp (revision 50)
+++ EditableTerrain/src/ETBrush.cpp (working copy)
@@ -31,9 +31,9 @@
#include <iostream>

using namespace Ogre;
-using namespace std;


+
namespace ET
{
Brush::Brush(Real width, Real height, Radian rotation)
@@ -76,16 +76,16 @@
Vector2 c2 = transformL2W(Vector2(0,1));
Vector2 c3 = transformL2W(Vector2(1,0));
Vector2 c4 = transformL2W(Vector2(1,1));
- mBoundingRect.left = min(c1.x, min(c2.x, min(c3.x, c4.x)));
- mBoundingRect.right = max(c1.x, max(c2.x, max(c3.x, c4.x)));
- mBoundingRect.bottom = max(c1.y, max(c2.y, max(c3.y, c4.y)));
- mBoundingRect.top = min(c1.y, min(c2.y, min(c3.y, c4.y)));
+ mBoundingRect.left = std::min(c1.x, std::min(c2.x, std::min(c3.x, c4.x)));
+ mBoundingRect.right = std::max(c1.x, std::max(c2.x, std::max(c3.x, c4.x)));
+ mBoundingRect.bottom = std::max(c1.y, std::max(c2.y, std::max(c3.y, c4.y)));
+ mBoundingRect.top = std::min(c1.y, std::min(c2.y, std::min(c3.y, c4.y)));
}


- pair<bool, Vector2> Brush::getBrushPosition(const Vector2& center, const Vector2& pos) const
+ std::pair<bool, Vector2> Brush::getBrushPosition(const Vector2& center, const Vector2& pos) const
{
- pair<bool, Vector2> res;
+ std::pair<bool, Vector2> res;
res.second = transformW2L(pos - center);
res.first = (res.second.x >= 0 && res.second.y >= 0 && res.second.x <= 1 && res.second.y <= 1);
return res;
Index: EditableTerrain/src/ETDynamicTexture.cpp
===================================================================
--- EditableTerrain/src/ETDynamicTexture.cpp (revision 50)
+++ EditableTerrain/src/ETDynamicTexture.cpp (working copy)
@@ -31,9 +31,9 @@
#include <OgreRoot.h>

using namespace Ogre;
-using namespace std;


+
namespace ET
{
DynamicTexture::DynamicTexture(const String& name, const String& group,
@@ -125,10 +125,10 @@
{
mData.at(x,z) = colour;
// update dirty rect
- mDirtyX1 = min(mDirtyX1, x);
- mDirtyZ1 = min(mDirtyZ1, z);
- mDirtyX2 = max(mDirtyX2, x);
- mDirtyZ2 = max(mDirtyZ2, z);
+ mDirtyX1 = std::min(mDirtyX1, x);
+ mDirtyZ1 = std::min(mDirtyZ1, z);
+ mDirtyX2 = std::max(mDirtyX2, x);
+ mDirtyZ2 = std::max(mDirtyZ2, z);
}


@@ -155,7 +155,7 @@
{
// get position of the pixel
Vector2 pos (mGridScale.x * ix, mGridScale.y * iz);
- pair<bool, Vector2> brushQry = brush->getBrushPosition(Vector2(x,z), pos);
+ std::pair<bool, Vector2> brushQry = brush->getBrushPosition(Vector2(x,z), pos);
if (!brushQry.first)
continue;
Real pct = intensity * brush->getIntensityAt(brushQry.second);
@@ -165,10 +165,10 @@
}

// update dirty rect
- mDirtyX1 = min(mDirtyX1, editRect.x1);
- mDirtyX2 = max(mDirtyX2, editRect.x2);
- mDirtyZ1 = min(mDirtyZ1, editRect.y1);
- mDirtyZ2 = max(mDirtyZ2, editRect.y2);
+ mDirtyX1 = std::min(mDirtyX1, editRect.x1);
+ mDirtyX2 = std::max(mDirtyX2, editRect.x2);
+ mDirtyZ1 = std::min(mDirtyZ1, editRect.y1);
+ mDirtyZ2 = std::max(mDirtyZ2, editRect.y2);
}


Index: EditableTerrain/src/ETEditable.cpp
===================================================================
--- EditableTerrain/src/ETEditable.cpp (revision 50)
+++ EditableTerrain/src/ETEditable.cpp (working copy)
@@ -29,9 +29,9 @@
#include <OgreRectangle.h>

using namespace Ogre;
-using namespace std;


+
namespace ET
{
EditableListener::~EditableListener()
@@ -67,10 +67,10 @@
bounds.bottom = floor(bounds.bottom / mGridScale.y);
// get the according integer coordinates
Rect editRect;
- editRect.x1 = (unsigned int) max<Real>(0, bounds.left);
- editRect.y1 = (unsigned int) max<Real>(0, bounds.top);
- editRect.x2 = (unsigned int) min<Real>(mGridWidth-1, bounds.right);
- editRect.y2 = (unsigned int) min<Real>(mGridHeight-1, bounds.bottom);
+ editRect.x1 = (unsigned int) std::max<Real>(0, bounds.left);
+ editRect.y1 = (unsigned int) std::max<Real>(0, bounds.top);
+ editRect.x2 = (unsigned int) std::min<Real>(mGridWidth-1, bounds.right);
+ editRect.y2 = (unsigned int) std::min<Real>(mGridHeight-1, bounds.bottom);
mLastEditedRect = editRect;
return editRect;
}
Index: EditableTerrain/src/ETFlatTerrain.cpp
===================================================================
--- EditableTerrain/src/ETFlatTerrain.cpp (revision 50)
+++ EditableTerrain/src/ETFlatTerrain.cpp (working copy)
@@ -33,9 +33,9 @@
#include <iostream>

using namespace Ogre;
-using namespace std;


+
namespace ET
{
FlatTerrain::FlatTerrain(const RealArray2D& heights, const Vector2& gridScale, Ogre::Real maxHeight)
@@ -259,7 +259,7 @@



- pair<bool, Vector3> FlatTerrain::rayIntersects(const Ray& ray)
+ std::pair<bool, Vector3> FlatTerrain::rayIntersects(const Ray& ray)
{
// first step: convert the ray to vertex space
Vector3 rayOrigin = transformPositionW2L(ray.getOrigin());
@@ -271,16 +271,16 @@
Ray localRay (rayOrigin, rayDirection);
// test if the ray actually hits the terrain's bounds
AxisAlignedBox aabb (Vector3(0, 0, 0), Vector3(mSizeX, 1, mSizeZ));
- pair<bool, Real> aabbTest = localRay.intersects(aabb);
- pair<bool, Vector3> result (false, Vector3());
+ std::pair<bool, Real> aabbTest = localRay.intersects(aabb);
+ std::pair<bool, Vector3> result (false, Vector3());
if (!aabbTest.first)
return result;
// get intersection point and move inside
Vector3 cur = localRay.getPoint(aabbTest.second);

// now check every quad the ray touches
- int quadX = min(max(static_cast<int>(cur.x), 0), (int)mSizeX-2);
- int quadZ = min(max(static_cast<int>(cur.z), 0), (int)mSizeZ-2);
+ int quadX = std::min(std::max(static_cast<int>(cur.x), 0), (int)mSizeX-2);
+ int quadZ = std::min(std::max(static_cast<int>(cur.z), 0), (int)mSizeZ-2);
int flipX = (rayDirection.x < 0 ? 0 : 1);
int flipZ = (rayDirection.z < 0 ? 0 : 1);
int xDir = (rayDirection.x < 0 ? -1 : 1);
@@ -315,7 +315,7 @@
}


- pair<bool, Vector3> FlatTerrain::checkQuadIntersection(int x, int z, const Ray& ray)
+ std::pair<bool, Vector3> FlatTerrain::checkQuadIntersection(int x, int z, const Ray& ray)
{
// build the two planes belonging to the quad
Vector3 v1 (x, mHeights.at(x,z), z);
@@ -327,13 +327,13 @@

// test for intersection with the two planes. Ensure that the intersection points are actually
// still inside the triangle (with a small error margin)
- pair<bool, Real> planeInt = ray.intersects(p1);
+ std::pair<bool, Real> planeInt = ray.intersects(p1);
if (planeInt.first)
{
Vector3 where = ray.getPoint(planeInt.second);
Vector3 rel = where - v1;
if (rel.x >= -0.01 && rel.x <= 1.01 && rel.z >= -0.01 && rel.z <= 1.01 && rel.x+rel.z <= 1.01)
- return pair<bool, Vector3>(true, where);
+ return std::pair<bool, Vector3>(true, where);
}
planeInt = ray.intersects(p2);
if (planeInt.first)
@@ -341,10 +341,10 @@
Vector3 where = ray.getPoint(planeInt.second);
Vector3 rel = where - v1;
if (rel.x >= -0.01 && rel.x <= 1.01 && rel.z >= -0.01 && rel.z <= 1.01 && rel.x+rel.z >= 0.99)
- return pair<bool, Vector3>(true, where);
+ return std::pair<bool, Vector3>(true, where);
}

- return pair<bool, Vector3>(false, Vector3());
+ return std::pair<bool, Vector3>(false, Vector3());
}


@@ -358,11 +358,11 @@
{
// get position of the vertex
Vector2 pos (mVertexScale.x * ix, mVertexScale.z * iz);
- pair<bool, Vector2> brushQry = brush->getBrushPosition(Vector2(x,z), pos);
+ std::pair<bool, Vector2> brushQry = brush->getBrushPosition(Vector2(x,z), pos);
if (!brushQry.first)
continue; // not inside brush rectangle
Real newHeight = getHeightValue(ix, iz) + intensity * brush->getIntensityAt(brushQry.second);
- newHeight = min(Real(1), max(Real(0), newHeight));
+ newHeight = std::min(Real(1), std::max(Real(0), newHeight));
setHeightValue(ix, iz, newHeight);
}
}
Index: EditableTerrain/src/ETIndexHandler.cpp
===================================================================
--- EditableTerrain/src/ETIndexHandler.cpp (revision 50)
+++ EditableTerrain/src/ETIndexHandler.cpp (working copy)
@@ -31,9 +31,9 @@
#include <cassert>

using namespace Ogre;
-using namespace std;


+
namespace ET
{
IndexHandler::IndexHandler(unsigned int sizeX, unsigned int sizeZ)
@@ -58,7 +58,7 @@

void IndexHandler::findMaxLOD()
{
- // determine max LOD in X dimension
+ // determine std::max LOD in X dimension
unsigned int maxLODX = (mSizeX != 1 ? 32 : 0);
for (unsigned int n = 1; n < 32; ++n)
{
@@ -70,7 +70,7 @@
}
}

- // determine max LOD in Z dimension
+ // determine std::max LOD in Z dimension
unsigned int maxLODZ = (mSizeZ != 1 ? 32 : 0);
for (unsigned int n = 1; n < 32; ++n)
{
@@ -85,7 +85,7 @@
if (maxLODX == 32 || maxLODZ == 32)
OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Dimensions must satisfy (2^n)+1", "ET::IndexHandler::findMaxLOD");

- mMaxLOD = min(maxLODX, maxLODZ);
+ mMaxLOD = std::min(maxLODX, maxLODZ);
mIndexBuffers = LODArray(mMaxLOD);
}

Index: EditableTerrain/src/ETMapGeneration.cpp
===================================================================
--- EditableTerrain/src/ETMapGeneration.cpp (revision 50)
+++ EditableTerrain/src/ETMapGeneration.cpp (working copy)
@@ -28,8 +28,8 @@
#include "ETUtility.h"

using namespace Ogre;
-using namespace std;

+
namespace ET
{
void generateNormalMap(ColourArray2D& array, FlatTerrain* terrain)
@@ -73,7 +73,7 @@
{
// interpolate normal at current position and determine dot product with light direction
Vector3 interpNormal = terrain->interpolateNormalAt(posX, posZ);
- Real amount = max(Real(0), interpNormal.dotProduct(lightDirection));
+ Real amount = std::max(Real(0), interpNormal.dotProduct(lightDirection));
array[x][z] = ambient + amount*lightColour;
posX += stepSizeX;
}
Index: EditableTerrain/src/ETPage.cpp
===================================================================
--- EditableTerrain/src/ETPage.cpp (revision 50)
+++ EditableTerrain/src/ETPage.cpp (working copy)
@@ -34,9 +34,9 @@
#include <OgreEntity.h>

using namespace Ogre;
-using namespace std;


+
namespace ET
{
Page::Page(const String& name, TerrainDescription* description, unsigned int patchSizeX,
Index: EditableTerrain/src/ETPatch.cpp
===================================================================
--- EditableTerrain/src/ETPatch.cpp (revision 50)
+++ EditableTerrain/src/ETPatch.cpp (working copy)
@@ -36,9 +36,9 @@
#include <iostream>

using namespace Ogre;
-using namespace std;


+
namespace ET
{
const unsigned short MAIN_BINDING = 0;
@@ -69,14 +69,14 @@

memset(mNeighbours, 0, sizeof(mNeighbours));

- mMaxLOD = min(mMaxLOD, mIndexHandler->getMaxLOD());
- // disable LOD morphing if max LOD is 1
+ mMaxLOD = std::min(mMaxLOD, mIndexHandler->getMaxLOD());
+ // disable LOD morphing if std::max LOD is 1
if (mMaxLOD <= 1)
{
mMaxLOD = 1;
mVertexOptions &= (~VO_LODMORPH);
}
- mLODChangeMinDistSqr = vector<Real>(mMaxLOD);
+ mLODChangeMinDistSqr = std::vector<Real>(mMaxLOD);

mLastNextLOD = mMaxLOD+1;

@@ -310,18 +310,18 @@
unsigned int patchSizeZ = mDescription->getNumVerticesZ();

// lock delta buffers, if vertex morphing is enabled
- vector<float*> pDeltas (mMaxLOD-1);
+ std::vector<float*> pDeltas (mMaxLOD-1);
if (mVertexOptions & VO_LODMORPH)
{
for (unsigned int l = 0; l < mMaxLOD-1; ++l)
pDeltas[l] = static_cast<float*>( mDeltaBuffers[l]->lock(HardwareBuffer::HBL_NORMAL) );
}

- // we are caching values in chunks of the size of the max LOD step
+ // we are caching values in chunks of the size of the std::max LOD step
unsigned int cacheStep = 1 << (mMaxLOD-1);
unsigned int cacheSizeX = patchSizeX / cacheStep;
unsigned int cacheSizeZ = patchSizeZ / cacheStep;
- vector<RealArray2D> cache (mMaxLOD-1, RealArray2D(cacheStep+1, cacheStep+1, 0));
+ std::vector<RealArray2D> cache (mMaxLOD-1, RealArray2D(cacheStep+1, cacheStep+1, 0));
// update all LOD frames which need updating, each frame is cacheStep x cacheStep
for (VertexList::const_iterator it = dirtyLODFrames.begin(); it != dirtyLODFrames.end(); ++it)
{
@@ -409,7 +409,7 @@
mDeltaBuffers[l]->unlock();
}

- // C is a factor for the calculation of the min distance.
+ // C is a factor for the calculation of the std::min distance.
Real C = 0.5 / mMaxError;
// calculate new switch distances
mLODChangeMinDistSqr[0] = 0;
@@ -417,7 +417,7 @@
{
Real maxError = *max_element(mLODCache[l].begin(), mLODCache[l].end());
Real switchDist = maxError*maxError*C*C;
- mLODChangeMinDistSqr[l+1] = max(mLODChangeMinDistSqr[l], switchDist);
+ mLODChangeMinDistSqr[l+1] = std::max(mLODChangeMinDistSqr[l], switchDist);
}
}

@@ -639,7 +639,7 @@
// scale so that morphFactor == 0 for percent == mLODMorphDistStart and morphFactor == 1
// for percent == 1, clamp to 0 below
Real scale = 1.0 / (1.0 - mLODMorphDistStart);
- mLODMorphFactor = max((percent - mLODMorphDistStart) * scale, Real(0));
+ mLODMorphFactor = std::max((percent - mLODMorphDistStart) * scale, Real(0));
}

// bind the correct delta buffer if changed
@@ -663,7 +663,12 @@
Technique* Patch::getTechnique() const
{
// based on the current distance to the camera, select the appropriate LOD technique from the material
+#if OGRE_VERSION_MINOR <= 6
unsigned short lodIndex = mMaterial->getLodIndexSquaredDepth(mCurCameraDistanceSqr);
+#else
+ // TODO - not strictly correct, use strategy
+ unsigned short lodIndex = mMaterial->getLodIndex(mCurCameraDistanceSqr);
+#endif
return mMaterial->getBestTechnique(lodIndex);
}
}
Index: EditableTerrain/src/ETShaderGenerator.cpp
===================================================================
--- EditableTerrain/src/ETShaderGenerator.cpp (revision 50)
+++ EditableTerrain/src/ETShaderGenerator.cpp (working copy)
@@ -28,9 +28,9 @@
#include <sstream>

using namespace Ogre;
-using namespace std;


+
namespace ET
{
namespace
@@ -86,7 +86,7 @@
virtual const Ogre::String& createVertexShader(int numSplatMaps, int numTextures,
bool patchLocalCoords, bool vertexMorphing, ShaderModel sm)
{
- ostringstream s;
+ std::ostringstream s;
s << NAME_PREFIX << VS_PREFIX << MODEL_PREFIX[sm] << "S" << numSplatMaps;
s << "T" << numTextures;
if (patchLocalCoords)
@@ -112,8 +112,8 @@
vertexHeaderOutput(s, sm, numSplatMaps+numTextures, vertexMorphing);
vertexBody(s, sm, numSplatMaps, numTextures, patchLocalCoords, vertexMorphing);
program->setSource(s.str());
- cout << "Generated vertex shader " << shaderName << ":\n";
- cout << s.str() << "\n";
+ std::cout << "Generated vertex shader " << shaderName << ":\n";
+ std::cout << s.str() << "\n";
program->load();
GpuProgramParametersSharedPtr params = program->getDefaultParameters();
params->setIgnoreMissingParams(true);
@@ -128,7 +128,7 @@
virtual const Ogre::String& createFragmentShader(Ogre::PixelFormat format,
int numSplatMaps, int numTextures, int startChannel, ShaderModel sm)
{
- ostringstream s;
+ std::ostringstream s;
s << NAME_PREFIX << PS_PREFIX << MODEL_PREFIX[sm];
s << PixelUtil::getFormatName(format) << "_";
s << "S" << numSplatMaps;
@@ -152,8 +152,8 @@
fragmentHeader(s, sm, numSplatMaps, numTextures);
fragmentBody(s, sm, format, numSplatMaps, numTextures, startChannel);
program->setSource(s.str());
- cout << "Generated fragment shader " << shaderName << ":\n";
- cout << s.str() << "\n";
+ std::cout << "Generated fragment shader " << shaderName << ":\n";
+ std::cout << s.str() << "\n";
program->load();
}

@@ -163,7 +163,7 @@

private:

- void vertexHeaderInput(ostringstream& s, bool patchLocalCoords, bool vertexMorphing)
+ void vertexHeaderInput(std::ostringstream& s, bool patchLocalCoords, bool vertexMorphing)
{
s << "void main( \n";
s << " float4 iPos: POSITION, \n";
@@ -174,7 +174,7 @@
s << " float delta: BLENDWEIGHT,\n";
}

- void vertexHeaderOutput(ostringstream& s, ShaderModel sm, int numTextures, bool vertexMorphing)
+ void vertexHeaderOutput(std::ostringstream& s, ShaderModel sm, int numTextures, bool vertexMorphing)
{
s << " out float4 oPos: POSITION, \n";
s << " out float2 oUV0: TEXCOORD0, \n";
@@ -192,7 +192,7 @@
s << ")\n";
}

- void vertexBody(ostringstream& s, ShaderModel sm, int numSplatMaps,
+ void vertexBody(std::ostringstream& s, ShaderModel sm, int numSplatMaps,
int numTextures, bool patchLocalCoords, bool vertexMorphing)
{
s << "{\n";
@@ -213,7 +213,7 @@
}


- void fragmentHeader(ostringstream& s, ShaderModel sm, int numSplatMaps,
+ void fragmentHeader(std::ostringstream& s, ShaderModel sm, int numSplatMaps,
int numTextures)
{
s << "void main(\n";
@@ -232,7 +232,7 @@
s << ")\n";
}

- void fragmentBody(ostringstream& s, ShaderModel sm, PixelFormat format,
+ void fragmentBody(std::ostringstream& s, ShaderModel sm, PixelFormat format,
int numSplatMaps, int numTextures, int startChannel)
{
s << "{\n";
@@ -256,7 +256,7 @@
s << " ;\n}\n";
}

- void readSplatMap(ostringstream& s, ShaderModel sm, const MapFormatDesc& desc, int i)
+ void readSplatMap(std::ostringstream& s, ShaderModel sm, const MapFormatDesc& desc, int i)
{
s << " " << desc.type << " cov" << i << " = tex2D(map" << i << ", ";
if (sm < SM_20)
@@ -266,7 +266,7 @@
s << ")." << desc.channels << ";\n";
}

- void readTexture(ostringstream& s, ShaderModel sm, int curMap, int curTex,
+ void readTexture(std::ostringstream& s, ShaderModel sm, int curMap, int curTex,
int curChan, int curUV)
{
static const char CHAN_MAP[4] = {'x','y','z','w'};
Index: EditableTerrain/src/ETSplattingManager.cpp
===================================================================
--- EditableTerrain/src/ETSplattingManager.cpp (revision 50)
+++ EditableTerrain/src/ETSplattingManager.cpp (working copy)
@@ -3,7 +3,7 @@
#include <functional>
#include <iostream>

-using namespace std;
+
using namespace Ogre;


@@ -48,8 +48,8 @@
// we check the rect in circles so that we can potentially
// make it smaller for later queries.
bool chanUsed = false;
- cout << "Checking channel " << i << " with dirty rect: ";
- cout << r.x1 << "," << r.y1 << "," << r.x2 << "," << r.y2 << endl;
+ std::cout << "Checking channel " << i << " with dirty rect: ";
+ std::cout << r.x1 << "," << r.y1 << "," << r.x2 << "," << r.y2 << std::endl;
while (r.y1 <= r.y2 && r.x1 <= r.x2)
{
for (int x = r.x1; x <= r.x2; ++x)
@@ -58,8 +58,8 @@
Real contents2 = mSplattingLayout->getChannelContent(x, r.y2, i);
if (contents1 > THRESHOLD || contents2 > THRESHOLD)
{
- cout << "Channel used at x = " << x << ", y = (" << r.y1 <<","<<r.y2<<"): ";
- cout << contents1 << ", " << contents2 << "\n";
+ std::cout << "Channel used at x = " << x << ", y = (" << r.y1 <<","<<r.y2<<"): ";
+ std::cout << contents1 << ", " << contents2 << "\n";
chanUsed = true;
break;
}
@@ -72,8 +72,8 @@
Real contents2 = mSplattingLayout->getChannelContent(r.x2, y, i);
if (contents1 > THRESHOLD || contents2 > THRESHOLD)
{
- cout << "Channel used at x = (" << r.x1<<","<<r.x2 << ", y = " << y<<"): ";
- cout << contents1 << ", " << contents2 << "\n";
+ std::cout << "Channel used at x = (" << r.x1<<","<<r.x2 << ", y = " << y<<"): ";
+ std::cout << contents1 << ", " << contents2 << "\n";
chanUsed = true;
break;
}
@@ -88,14 +88,14 @@

if (!chanUsed)
{
- cout << "Channel is not in use." << endl;
+ std::cout << "Channel is not in use." << std::endl;
// channel is not used, so mark it as free
mTexChanMap.erase(mTextures[i]);
mTextures[i].clear();
mDirtyRects[i] = Rect(mGridWidth, mGridHeight, 0, 0);
if (i == mNumUsedChannels-1)
{
- cout << "Channel is last in list, delete it." << endl;
+ std::cout << "Channel is last in list, delete it." << std::endl;
// last channel, simply delete it
mTextures.erase(mTextures.end()-1);
mDirtyRects.erase(mDirtyRects.end()-1);
@@ -121,7 +121,7 @@
{
mTextures[i] = texture;
mTexChanMap[texture] = i;
- cout << "Reusing channel " << i << "\n";
+ std::cout << "Reusing channel " << i << "\n";
inserted = true;
}
}
@@ -134,12 +134,12 @@
mTexChanMap[texture] = mNumUsedChannels;
++mNumUsedChannels;
mSplattingLayout->setNumChannels(mNumUsedChannels);
- cout << "Added texture in channel " << mNumUsedChannels-1 << "\n";
+ std::cout << "Added texture in channel " << mNumUsedChannels-1 << "\n";
}
updateMaps = numMaps != mSplattingLayout->getNumSplattingMaps();

// inform listeners about texture list change
- for (vector<SplattingListener*>::iterator l = mListeners.begin(); l != mListeners.end(); ++l)
+ for (std::vector<SplattingListener*>::iterator l = mListeners.begin(); l != mListeners.end(); ++l)
{
(*l)->notifySplattingTextures(mTextures);
if (updateMaps)
@@ -158,10 +158,10 @@
// update potential area rect for the used texture
Rect ur = mSplattingLayout->getLastEditedRect();
Rect& dr = mDirtyRects[chan];
- dr.x1 = min(dr.x1, ur.x1);
- dr.y1 = min(dr.y1, ur.y1);
- dr.x2 = max(dr.x2, ur.x2);
- dr.y2 = max(dr.y2, ur.y2);
+ dr.x1 = std::min(dr.x1, ur.x1);
+ dr.y1 = std::min(dr.y1, ur.y1);
+ dr.x2 = std::max(dr.x2, ur.x2);
+ dr.y2 = std::max(dr.y2, ur.y2);
}

void SplattingManager::splat(const Vector3& pos, const Brush* brush, const String& texture,
@@ -181,7 +181,7 @@

void SplattingManager::removeListener(SplattingListener* listener)
{
- vector<SplattingListener*>::iterator it = find(mListeners.begin(), mListeners.end(), listener);
+ std::vector<SplattingListener*>::iterator it = find(mListeners.begin(), mListeners.end(), listener);
if (it != mListeners.end())
mListeners.erase(it);
}
Index: EditableTerrain/src/ETSplattingMaterial.cpp
===================================================================
--- EditableTerrain/src/ETSplattingMaterial.cpp (revision 50)
+++ EditableTerrain/src/ETSplattingMaterial.cpp (working copy)
@@ -32,9 +32,9 @@
#include <OgrePass.h>

using namespace Ogre;
-using namespace std;


+
namespace ET
{
namespace
@@ -109,19 +109,19 @@

void SplattingMaterial::createMaterial()
{
- cout << "Creating material with maps:\n";
+ std::cout << "Creating material with maps:\n";
for (size_t i = 0; i < mMaps.size(); ++i)
- cout << " " << mMaps[i] << "\n";
- cout << "and splatting textures:\n";
+ std::cout << " " << mMaps[i] << "\n";
+ std::cout << "and splatting textures:\n";
for (size_t i = 0; i < mTextures.size(); ++i)
- cout << " " << mTextures[i] << "\n";
+ std::cout << " " << mTextures[i] << "\n";
// prepare material from empty or base material
mMaterial->removeAllTechniques();
if (!mBaseMaterial.isNull())
mBaseMaterial->copyDetailsTo(mMaterial);
mMaterial->load();

- cout << flush;
+ std::cout << std::flush;

if (mTextures.empty() || mMaps.empty())
return;
@@ -131,17 +131,17 @@
if (!t)
t = mMaterial->createTechnique();

- cout << "Checking whether to split passes..." << endl;
+ std::cout << "Checking whether to split passes..." << std::endl;
bool splitMapsAcrossPasses = checkMapSplitSaves();
// create passes
int curTex = 0;
int curMap = 0;
int curChan = 0;
int curPass = 0;
- cout << "Creating passes..." << endl;
+ std::cout << "Creating passes..." << std::endl;
while (curTex < mTextures.size() && curMap < mMaps.size())
{
- cout << "New pass at curTex = " << curTex << " and curMap = " << curMap << endl;
+ std::cout << "New pass at curTex = " << curTex << " and curMap = " << curMap << std::endl;
if (!splitMapsAcrossPasses)
createPassNoSplit(t, curPass, curTex, curMap);
else
@@ -160,13 +160,13 @@
if (curPass != 0)
p->setSceneBlending(SBT_ADD);
p->setLightingEnabled(false);
- int numMaps = min(numPerPass / (numChannels+1), mMaps.size()-curMap);
- int numTex = min(numMaps * numChannels, mTextures.size()-curTex);
+ int numMaps = std::min(numPerPass / (numChannels+1), mMaps.size()-curMap);
+ int numTex = std::min(numMaps * numChannels, mTextures.size()-curTex);
p->setVertexProgram(mShaderGenerator->createVertexShader(numMaps, numTex,
mPatchLocalCoords, mVertexMorphing, mShaderModel));
p->setFragmentProgram(mShaderGenerator->createFragmentShader(mFormat, numMaps,
numTex, 0, mShaderModel));
- cout << flush;
+ std::cout << std::flush;
for (int i = curMap; i < curMap+numMaps; ++i)
p->createTextureUnitState(mMaps[i]);
for (int i = curTex; i < curTex+numTex; ++i)
@@ -207,7 +207,7 @@
--numUnitsLeft;
++curChan;
}
- numMaps = min(numMaps, (int)mMaps.size() - curMap);
+ numMaps = std::min(numMaps, (int)mMaps.size() - curMap);
p->setVertexProgram(mShaderGenerator->createVertexShader(numMaps, numTex,
mPatchLocalCoords, mVertexMorphing, mShaderModel));
p->setFragmentProgram(mShaderGenerator->createFragmentShader(mFormat, numMaps,
@@ -265,20 +265,20 @@

void SplattingMaterial::notifySplattingTextures(const TextureList& textures)
{
- cout << "New splatting textures:\n";
+ std::cout << "New splatting textures:\n";
for (size_t i = 0; i < textures.size(); ++i)
- cout << textures[i] << "\n";
- cout << flush;
+ std::cout << textures[i] << "\n";
+ std::cout << std::flush;
setSplattingTextures(textures);
createMaterial();
}

void SplattingMaterial::notifySplattingMaps(const TextureList& maps)
{
- cout << "New splatting maps:\n";
+ std::cout << "New splatting maps:\n";
for (size_t i = 0; i < maps.size(); ++i)
- cout << maps[i] << "\n";
- cout << flush;
+ std::cout << maps[i] << "\n";
+ std::cout << std::flush;
setSplattingMaps(maps);
createMaterial();
}
Index: EditableTerrain/src/ETSubDescription.cpp
===================================================================
--- EditableTerrain/src/ETSubDescription.cpp (revision 50)
+++ EditableTerrain/src/ETSubDescription.cpp (working copy)
@@ -29,9 +29,9 @@
#include <OgreVector2.h>

using namespace Ogre;
-using namespace std;


+
namespace ET
{
SubDescription::SubDescription(TerrainDescription* description, unsigned int startX,
@@ -57,7 +57,7 @@
{
// the parent is still active, so unregister as listener and inform own listeners of destruction
mDescription->removeListener(this);
- for (vector<TerrainListener*>::iterator it = mListeners.begin(); it != mListeners.end(); ++it)
+ for (std::vector<TerrainListener*>::iterator it = mListeners.begin(); it != mListeners.end(); ++it)
(*it)->notifyDestroyed();
}
}
@@ -156,7 +156,7 @@
if (subList.empty())
return;
// notify listeners
- for (vector<TerrainListener*>::iterator it = mListeners.begin(); it != mListeners.end(); ++it)
+ for (std::vector<TerrainListener*>::iterator it = mListeners.begin(); it != mListeners.end(); ++it)
(*it)->notifyUpdated(subList);
}

@@ -164,7 +164,7 @@
void SubDescription::notifyDestroyed()
{
// notify listeners
- for (vector<TerrainListener*>::iterator it = mListeners.begin(); it != mListeners.end(); ++it)
+ for (std::vector<TerrainListener*>::iterator it = mListeners.begin(); it != mListeners.end(); ++it)
(*it)->notifyDestroyed();

// reset the parent description
Index: EditableTerrain/src/ETUtility.cpp
===================================================================
--- EditableTerrain/src/ETUtility.cpp (revision 50)
+++ EditableTerrain/src/ETUtility.cpp (working copy)
@@ -33,9 +33,9 @@
#include <iostream>

using namespace Ogre;
-using namespace std;


+
namespace ET
{
using Ogre::uint8;
@@ -124,7 +124,7 @@
}


- RealArray2D loadRealArrayFromRawData(const string& rawData, size_t width, size_t height, bool endianess)
+ RealArray2D loadRealArrayFromRawData(const std::string& rawData, size_t width, size_t height, bool endianess)
{
size_t size = width*height;
// determine bytes per value
@@ -171,7 +171,7 @@
// determine bytes per value
size_t bpv = PixelUtil::getNumElemBytes(image.getFormat());
// determine endianess
- bool endianess = (PixelUtil::isNativeEndian(image.getFormat()) ? ENDIAN_NATIVE : ~ENDIAN_NATIVE);
+ bool endianess = (PixelUtil::isNativeEndian(image.getFormat()) ? ENDIAN_NATIVE : !ENDIAN_NATIVE);

// call appropriate function based on bytes per value
switch (bpv)
@@ -196,7 +196,7 @@
/** Helper function to store a single Real value in a byte stream */
void storeVal(Real val, uchar* buf, size_t bytesPerVal, bool endianess)
{
- uint32 maxVal = numeric_limits<uint32>::max() >> 8*(4-bytesPerVal);
+ uint32 maxVal = std::numeric_limits<uint32>::max() >> 8*(4-bytesPerVal);
uint32 write = uint32(maxVal * val);
// adjust endianess if necessary
if (endianess != ENDIAN_NATIVE)
@@ -228,18 +228,18 @@
}


- string saveRealArrayToRawString(const RealArray2D& array, size_t bytesPerVal, bool endianess)
+ std::string saveRealArrayToRawString(const RealArray2D& array, size_t bytesPerVal, bool endianess)
{
if (bytesPerVal < 1 || bytesPerVal > 4)
OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "bytesPerVal must be between 1 and 4", __FUNCTION__);

uchar* buf = saveRealArrayToBuffer(array, bytesPerVal, endianess);
- string str ((char*)buf, array.size() * bytesPerVal);
+ std::string str ((char*)buf, array.size() * bytesPerVal);
ET_OGRE_FREE(buf);
return str;
}

- void saveRealArrayToRawStream(const RealArray2D& array, ostream& stream, size_t bytesPerVal, bool endianess)
+ void saveRealArrayToRawStream(const RealArray2D& array, std::ostream& stream, size_t bytesPerVal, bool endianess)
{
stream << saveRealArrayToRawString(array, bytesPerVal, endianess);
}
@@ -248,7 +248,7 @@
Image saveRealArrayToImage(const RealArray2D& array, PixelFormat format)
{
size_t bytesPerVal = PixelUtil::getNumElemBytes(format);
- bool endianess = (PixelUtil::isNativeEndian(format) ? ENDIAN_NATIVE : ~ENDIAN_NATIVE);
+ bool endianess = (PixelUtil::isNativeEndian(format) ? ENDIAN_NATIVE : !ENDIAN_NATIVE);
uchar* buf = saveRealArrayToBuffer(array, bytesPerVal, endianess);
Image image;
image.loadDynamicImage(buf, array.sizeX(), array.sizeY(), 1, format, true);

CABAListic

20-02-2009 21:20:21

Thanks, I'll incorporate it next week. Once I hit the first official beta release, I'll establish some standard procedure to submit bugs and patches :)