diff -r 58d50844286b docs/manual/illustrations/src/Illustrations.cpp
--- a/docs/manual/illustrations/src/Illustrations.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/docs/manual/illustrations/src/Illustrations.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -303,7 +303,7 @@
putMesh(mp,1);
next("shape_ellipse", 3);
- s = TriangleShape().setLengthA(3).setLengthB(3).setLengthC(3).realizeShape();
+ s = TriangleShape().setLength(3).realizeShape();
mp = s.realizeMesh();
putMesh(mp,1);
next("shape_triangle", 3);
diff -r 58d50844286b library/include/ProceduralBoxGenerator.h
--- a/library/include/ProceduralBoxGenerator.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralBoxGenerator.h Tue Nov 13 14:27:32 2012 +0100
@@ -48,23 +48,38 @@
BoxGenerator(Ogre::Real sizeX=1.f, Ogre::Real sizeY=1.f, Ogre::Real sizeZ=1.f, unsigned int numSegX=1, unsigned int numSegY=1, unsigned int numSegZ=1) :
mSizeX(sizeX), mSizeY(sizeY), mSizeZ(sizeZ), mNumSegX(numSegX), mNumSegY(numSegY), mNumSegZ(numSegZ) {}
- /** Sets size along X axis (default=1) */
+ /**
+ Sets size along X axis (default=1)
+ \exception Ogre::InvalidParametersException X size must be larger than 0!
+ */
BoxGenerator& setSizeX(Ogre::Real sizeX)
{
+ if(sizeX <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "X size must be larger than 0!", "Procedural::BoxGenerator::setSizeX(Ogre::Real)");
mSizeX = sizeX;
return *this;
}
- /** Sets size along Y axis (default=1) */
+ /**
+ Sets size along Y axis (default=1)
+ \exception Ogre::InvalidParametersException Y size must be larger than 0!
+ */
BoxGenerator& setSizeY(Ogre::Real sizeY)
{
+ if(sizeY <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Y size must be larger than 0!", "Procedural::BoxGenerator::setSizeY(Ogre::Real)");
mSizeY = sizeY;
return *this;
}
- /** Sets size along Z axis (default=1) */
+ /**
+ Sets size along Z axis (default=1)
+ \exception Ogre::InvalidParametersException Z size must be larger than 0!
+ */
BoxGenerator& setSizeZ(Ogre::Real sizeZ)
{
+ if(sizeZ <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Z size must be larger than 0!", "Procedural::BoxGenerator::setSizeZ(Ogre::Real)");
mSizeZ = sizeZ;
return *this;
}
@@ -72,29 +87,44 @@
/** Sets the size (default=1,1,1) */
BoxGenerator& setSize(Ogre::Vector3 size)
{
- mSizeX = size.x;
- mSizeY = size.y;
- mSizeZ = size.z;
+ setSizeX(size.x);
+ setSizeY(size.y);
+ setSizeZ(size.z);
return *this;
}
- /** Sets the number of segments along X axis (default=1) */
+ /**
+ Sets the number of segments along X axis (default=1)
+ \exception Ogre::InvalidParametersException Minimum of numSegX is 1
+ */
BoxGenerator& setNumSegX(unsigned int numSegX)
{
+ if(numSegX == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::BoxGenerator::setNumSegX(unsigned int)");
mNumSegX = numSegX;
return *this;
}
- /** Sets the number of segments along Y axis (default=1) */
+ /**
+ Sets the number of segments along Y axis (default=1)
+ \exception Ogre::InvalidParametersException Minimum of numSegY is 1
+ */
BoxGenerator& setNumSegY(unsigned int numSegY)
{
+ if(numSegY == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::BoxGenerator::setNumSegY(unsigned int)");
mNumSegY = numSegY;
return *this;
}
- /** Sets the number of segments along Z axis (default=1) */
+ /**
+ Sets the number of segments along Z axis (default=1)
+ \exception Ogre::InvalidParametersException Minimum of numSegZ is 1
+ */
BoxGenerator& setNumSegZ(unsigned int numSegZ)
{
+ if(numSegZ == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::BoxGenerator::setNumSegZ(unsigned int)");
mNumSegZ = numSegZ;
return *this;
}
diff -r 58d50844286b library/include/ProceduralCapsuleGenerator.h
--- a/library/include/ProceduralCapsuleGenerator.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralCapsuleGenerator.h Tue Nov 13 14:27:32 2012 +0100
@@ -66,37 +66,62 @@
*/
void addToTriangleBuffer(TriangleBuffer& buffer) const;
- /** Sets the radius of the cylinder part (default=1)*/
+ /**
+ Sets the radius of the cylinder part (default=1)
+ \exception Ogre::InvalidParametersException Radius must be larger than 0!
+ */
inline CapsuleGenerator & setRadius(Ogre::Real radius)
{
+ if(radius <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Radius must be larger than 0!", "Procedural::CapsuleGenerator::setRadius(Ogre::Real)");
mRadius = radius;
return *this;
}
- /** Sets the number of segments of the sphere part (default=8)*/
+ /**
+ Sets the number of segments of the sphere part (default=8)
+ \exception Ogre::InvalidParametersException Minimum of numRings is 1
+ */
inline CapsuleGenerator & setNumRings(unsigned int numRings)
{
+ if(numRings == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 rings", "Procedural::CapsuleGenerator::setNumRings(unsigned int)");
mNumRings = numRings;
return *this;
}
- /** Sets the number of segments when rotating around the cylinder (default=16)*/
+ /**
+ Sets the number of segments when rotating around the cylinder (default=16)
+ \exception Ogre::InvalidParametersException Minimum of numSegments is 1
+ */
inline CapsuleGenerator & setNumSegments(unsigned int numSegments)
{
+ if(numSegments == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::CapsuleGenerator::setNumSegments(unsigned int)");
mNumSegments = numSegments;
return *this;
}
- /** Sets the number of segments along the axis of the cylinder (default=1)*/
+ /**
+ Sets the number of segments along the axis of the cylinder (default=1)
+ \exception Ogre::InvalidParametersException Minimum of numSeg is 1
+ */
inline CapsuleGenerator & setNumSegHeight(unsigned int numSegHeight)
{
+ if(numSegHeight == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::CapsuleGenerator::setNumSegHeight(unsigned int)");
mNumSegHeight = numSegHeight;
return *this;
}
- /** Sets the height of the cylinder part of the capsule (default=1)*/
+ /**
+ Sets the height of the cylinder part of the capsule (default=1)
+ \exception Ogre::InvalidParametersException Height must be larger than 0!
+ */
inline CapsuleGenerator & setHeight(Ogre::Real height)
{
+ if(height <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Height must be larger than 0!", "Procedural::CapsuleGenerator::setHeight(Ogre::Real)");
mHeight = height;
return *this;
}
diff -r 58d50844286b library/include/ProceduralConeGenerator.h
--- a/library/include/ProceduralConeGenerator.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralConeGenerator.h Tue Nov 13 14:27:32 2012 +0100
@@ -59,30 +59,50 @@
*/
void addToTriangleBuffer(TriangleBuffer& buffer) const;
- /** Sets the number of segments on the side of the base (default=16)*/
+ /**
+ Sets the number of segments on the side of the base (default=16)
+ \exception Ogre::InvalidParametersException Minimum of numSegBase is 1
+ */
inline ConeGenerator & setNumSegBase(unsigned int numSegBase)
{
+ if(numSegBase == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::ConeGenerator::setNumSegBase(unsigned int)");
mNumSegBase = numSegBase;
return *this;
}
- /** Sets the number of segments on the height (default=1) */
+ /**
+ Sets the number of segments on the height (default=1)
+ \exception Ogre::InvalidParametersException Minimum of numSegHeight is 1
+ */
inline ConeGenerator & setNumSegHeight(unsigned int numSegHeight)
{
+ if(numSegHeight == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::ConeGenerator::setNumSegHeight(unsigned int)");
mNumSegHeight = numSegHeight;
return *this;
}
- /** Sets the base radius (default=1)*/
+ /**
+ Sets the base radius (default=1)
+ \exception Ogre::InvalidParametersException Radius must be larger than 0!
+ */
inline ConeGenerator & setRadius(Ogre::Real radius)
{
+ if(radius <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Radius must be larger than 0!", "Procedural::ConeGenerator::setRadius(Ogre::Real)");
mRadius = radius;
return *this;
}
- /** Sets the height of the cone (default=1)*/
+ /**
+ Sets the height of the cone (default=1)
+ \exception Ogre::InvalidParametersException Height must be larger than 0!
+ */
inline ConeGenerator & setHeight(Ogre::Real height)
{
+ if(height <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Height must be larger than 0!", "Procedural::ConeGenerator::setHeight(Ogre::Real)");
mHeight = height;
return *this;
}
diff -r 58d50844286b library/include/ProceduralCylinderGenerator.h
--- a/library/include/ProceduralCylinderGenerator.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralCylinderGenerator.h Tue Nov 13 14:27:32 2012 +0100
@@ -62,16 +62,26 @@
*/
void addToTriangleBuffer(TriangleBuffer& buffer) const;
- /** Sets the number of segments when rotating around the cylinder's axis (default=16) */
+ /**
+ Sets the number of segments when rotating around the cylinder's axis (default=16)
+ \exception Ogre::InvalidParametersException Minimum of numSegBase is 1
+ */
inline CylinderGenerator & setNumSegBase(unsigned int numSegBase)
{
+ if(numSegBase == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::CylinderGenerator::setNumSegBase(unsigned int)");
mNumSegBase = numSegBase;
return *this;
}
- /** Sets the number of segments along the height of the cylinder (default=1) */
+ /**
+ Sets the number of segments along the height of the cylinder (default=1)
+ \exception Ogre::InvalidParametersException Minimum of numSegHeight is 1
+ */
inline CylinderGenerator & setNumSegHeight(unsigned int numSegHeight)
{
+ if(numSegHeight == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::CylinderGenerator::setNumSegHeight(unsigned int)");
mNumSegHeight = numSegHeight;
return *this;
}
@@ -83,16 +93,26 @@
return *this;
}
- /** Sets the radius of the cylinder (default=1) */
+ /**
+ Sets the radius of the cylinder (default=1)
+ \exception Ogre::InvalidParametersException Radius must be larger than 0!
+ */
inline CylinderGenerator & setRadius(Ogre::Real radius)
{
+ if(radius <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Radius must be larger than 0!", "Procedural::CylinderGenerator::setRadius(Ogre::Real)");
mRadius = radius;
return *this;
}
- /** Sets the height of the cylinder (default=1) */
+ /**
+ Sets the height of the cylinder (default=1)
+ \exception Ogre::InvalidParametersException Height must be larger than 0!
+ */
inline CylinderGenerator & setHeight(Ogre::Real height)
{
+ if(height <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Height must be larger than 0!", "Procedural::CylinderGenerator::setHeight(Ogre::Real)");
mHeight = height;
return *this;
}
diff -r 58d50844286b library/include/ProceduralDebugRendering.h
--- a/library/include/ProceduralDebugRendering.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralDebugRendering.h Tue Nov 13 14:27:32 2012 +0100
@@ -76,6 +76,8 @@
/// Builds the normals representation as a manual object
+ /// \exception Ogre::InvalidStateException The input triangle buffer must not be null
+ /// \exception Ogre::InvalidStateException Scene Manager is not set in OGRE root object
Ogre::ManualObject* buildManualObject() const;
/// Builds the normals representation as a mesh
diff -r 58d50844286b library/include/ProceduralExtruder.h
--- a/library/include/ProceduralExtruder.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralExtruder.h Tue Nov 13 14:27:32 2012 +0100
@@ -70,6 +70,8 @@
/**
* Builds the mesh into the given TriangleBuffer
* @param buffer The TriangleBuffer on where to append the mesh.
+ * @exception Ogre::InvalidStateException Either shape or multishape must be defined!
+ * @exception Ogre::InvalidStateException Required parameter is zero!
*/
void addToTriangleBuffer(TriangleBuffer& buffer) const;
diff -r 58d50844286b library/include/ProceduralIcoSphereGenerator.h
--- a/library/include/ProceduralIcoSphereGenerator.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralIcoSphereGenerator.h Tue Nov 13 14:27:32 2012 +0100
@@ -56,9 +56,14 @@
*/
void addToTriangleBuffer(TriangleBuffer& buffer) const;
- /** Sets the radius of the sphere (default=1) */
+ /**
+ Sets the radius of the sphere (default=1)
+ \exception Ogre::InvalidParametersException Radius must be larger than 0!
+ */
inline IcoSphereGenerator & setRadius(Ogre::Real radius)
{
+ if(radius <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Radius must be larger than 0!", "Procedural::IcoSphereGenerator::setRadius(Ogre::Real)");
mRadius = radius;
return *this;
}
@@ -67,9 +72,12 @@
First iteration corresponds to a 20 face sphere.
Each iteration has 3 more faces than the previous.
(default=2)
+ \exception Ogre::InvalidParametersException Minimum of numIterations is 1
*/
inline IcoSphereGenerator & setNumIterations(unsigned int numIterations)
{
+ if(numIterations == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 iterations", "Procedural::IcoSphereGenerator::setNumRings(unsigned int)");
mNumIterations = numIterations;
return *this;
}
diff -r 58d50844286b library/include/ProceduralLathe.h
--- a/library/include/ProceduralLathe.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralLathe.h Tue Nov 13 14:27:32 2012 +0100
@@ -58,9 +58,14 @@
mNumSeg(numSeg), mAngleBegin(0), mAngleEnd((Ogre::Radian)Ogre::Math::TWO_PI), mClosed(true), mCapped(true)
{}
- /** Sets the number of segments when rotating around the axis (default=16)*/
+ /**
+ Sets the number of segments when rotating around the axis (default=16)
+ \exception Ogre::InvalidParametersException Minimum of numSeg is 1
+ */
inline Lathe& setNumSeg(unsigned int numSeg)
{
+ if(numSeg == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::Lathe::setNumSeg(unsigned int)");
mNumSeg = numSeg;
return *this;
}
@@ -123,6 +128,8 @@
/**
* Builds the mesh into the given TriangleBuffer
* @param buffer The TriangleBuffer on where to append the mesh.
+ * @exception Ogre::InvalidStateException Either shape or multishape must be defined!
+ * @exception Ogre::InvalidStateException Required parameter is zero!
*/
void addToTriangleBuffer(TriangleBuffer& buffer) const;
};
diff -r 58d50844286b library/include/ProceduralMeshGenerator.h
--- a/library/include/ProceduralMeshGenerator.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralMeshGenerator.h Tue Nov 13 14:27:32 2012 +0100
@@ -95,6 +95,7 @@
public:
/// Default constructor
+ /// \exception Ogre::InvalidStateException Scene Manager is not set in OGRE root object
MeshGenerator() : mUTile(1.f),
mVTile(1.f),
mEnableNormals(true),
@@ -109,7 +110,8 @@
mEnableDumpToFile(false)
{
mSceneMgr = Ogre::Root::getSingleton().getSceneManagerIterator().begin()->second;
- assert(mSceneMgr && "Scene Manager must be set in Root");
+ if(mSceneMgr == NULL)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "Scene Manager must be set in Root", "Procedural::MeshGenerator::MeshGenerator()");
}
/**
diff -r 58d50844286b library/include/ProceduralMeshModifiers.h
--- a/library/include/ProceduralMeshModifiers.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralMeshModifiers.h Tue Nov 13 14:27:32 2012 +0100
@@ -42,12 +42,16 @@
SpherifyModifier() : mInputTriangleBuffer(0) {}
+ /// \exception Ogre::InvalidParametersException Input triangle buffer must not be null
SpherifyModifier& setInputTriangleBuffer(TriangleBuffer* inputTriangleBuffer)
{
+ if(inputTriangleBuffer == NULL)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Input triangle buffer must not be null", "Procedural::SpherifyModifier::setInputTriangleBuffer(Procedural::TriangleBuffer*)");
mInputTriangleBuffer = inputTriangleBuffer;
return *this;
}
+ /// \exception Ogre::InvalidStateException Input triangle buffer must be set
void modify();
};
diff -r 58d50844286b library/include/ProceduralPath.h
--- a/library/include/ProceduralPath.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralPath.h Tue Nov 13 14:27:32 2012 +0100
@@ -122,10 +122,14 @@
return *this;
}
- /** Define the path as being closed. Almost the same as adding a last point on the first point position */
+ /**
+ Define the path as being closed. Almost the same as adding a last point on the first point position
+ \exception Ogre::InvalidStateException Cannot close an empty path
+ */
Path& close()
{
- assert(mPoints.size()>0 && "Cannot close an empty path");
+ if(mPoints.empty())
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "Cannot close an empty path", "Procedural::Path::close()");
mClosed = true;
return *this;
}
@@ -209,10 +213,14 @@
/// Gets a position on the shape with index of the point and a percentage of position on the segment
/// @param i index of the segment
/// @param coord a number between 0 and 1 meaning the percentage of position on the segment
+ /// @exception Ogre::InvalidParametersException i is out of bounds
+ /// @exception Ogre::InvalidParametersException coord must be comprised between 0 and 1
inline Ogre::Vector3 getPosition(unsigned int i, Ogre::Real coord) const
{
- assert(mClosed || (i < mPoints.size() - 1 && "Out of Bounds"));
- assert(coord>=0. && coord<=1. && "Coord must be comprised between 0 and 1");
+ if(i >= mPoints.size())
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Out of Bounds", "Procedural::Path::getPosition(unsigned int, Ogre::Real)");
+ if(coord < 0.0f || coord > 1.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Coord must be comprised between 0 and 1", "Procedural::Path::getPosition(unsigned int, Ogre::Real)");
Ogre::Vector3 A = getPoint(i);
Ogre::Vector3 B = getPoint(i+1);
return A + coord*(B-A);
@@ -220,6 +228,7 @@
/// Gets a position on the shape from lineic coordinate
/// @param coord lineic coordinate
+ /// @exception Ogre::InvalidStateException The path must at least contain 2 points
Ogre::Vector3 getPosition(Ogre::Real coord) const;
/**
diff -r 58d50844286b library/include/ProceduralPathGenerators.h
--- a/library/include/ProceduralPathGenerators.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralPathGenerators.h Tue Nov 13 14:27:32 2012 +0100
@@ -179,8 +179,11 @@
}
/// Sets the number of segments for this line
+ /// \exception Ogre::InvalidParametersException Minimum of numSeg is 1
inline LinePath& setNumSeg(unsigned int numSeg)
{
+ if(numSeg == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::LinePath::setNumSeg(unsigned int)");
mNumSeg = numSeg;
return *this;
}
@@ -196,7 +199,6 @@
/// Outputs a path
Path realizePath()
{
- assert(mNumSeg > 0);
Path p;
for (unsigned int i = 0; i <= mNumSeg; ++i)
{
@@ -251,6 +253,7 @@
/**
* Builds a shape from control points
+ * \exception Ogre::InvalidStateException The path contains no points
*/
Path realizePath();
};
@@ -269,8 +272,11 @@
BezierCurve3() : mNumSeg(8) {}
/// Sets number of segments per two control points
+ /// \exception Ogre::InvalidParametersException Minimum of numSeg is 1
inline BezierCurve3& setNumSeg(unsigned int numSeg)
{
+ if(numSeg == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::BezierCurve3::setNumSeg(unsigned int)");
mNumSeg = numSeg;
return *this;
}
@@ -299,6 +305,7 @@
/**
* Build a path from bezier control points
+ * @exception Ogre::InvalidStateException The curve must at least contain 2 points
*/
Path realizePath();
};
diff -r 58d50844286b library/include/ProceduralPathGeneratorsBase.h
--- a/library/include/ProceduralPathGeneratorsBase.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralPathGeneratorsBase.h Tue Nov 13 14:27:32 2012 +0100
@@ -50,9 +50,11 @@
BaseSpline3() : mNumSeg(4), mClosed(false) {}
/// Sets the number of segments between 2 control points
- inline T& setNumSeg(int numSeg)
+ /// \exception Ogre::InvalidParametersException Minimum of numSeg is 1
+ inline T& setNumSeg(unsigned int numSeg)
{
- assert(numSeg>=1);
+ if(numSeg == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::BaseSpline3::setNumSeg(unsigned int)");
mNumSeg = numSeg;
return (T&)*this;
}
diff -r 58d50844286b library/include/ProceduralPlaneGenerator.h
--- a/library/include/ProceduralPlaneGenerator.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralPlaneGenerator.h Tue Nov 13 14:27:32 2012 +0100
@@ -60,40 +60,73 @@
*/
void addToTriangleBuffer(TriangleBuffer& buffer) const;
- /** Sets the number of segements along local X axis */
+ /**
+ Sets the number of segements along local X axis
+ \exception Ogre::InvalidParametersException Minimum of numSegX is 1
+ */
inline PlaneGenerator & setNumSegX(unsigned int numSegX)
{
+ if(numSegX == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::PlaneGenerator::setNumSegX(unsigned int)");
mNumSegX = numSegX;
return *this;
}
- /** Sets the number of segments along local Y axis */
+ /**
+ Sets the number of segments along local Y axis
+ \exception Ogre::InvalidParametersException Minimum of numSegY is 1
+ */
inline PlaneGenerator & setNumSegY(unsigned int numSegY)
{
+ if(numSegY == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::PlaneGenerator::setNumSegY(unsigned int)");
mNumSegY = numSegY;
return *this;
}
- /** Sets the normal of the plane */
+ /**
+ Sets the normal of the plane
+ \exception Ogre::InvalidParametersException Normal must not be null
+ */
inline PlaneGenerator & setNormal(Ogre::Vector3 normal)
{
+ if(mNormal.isZeroLength())
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Normal must not be null", "Procedural::PlaneGenerator::setNormal(unsigned int)");
mNormal = normal;
return *this;
}
- /** Sets the size of the plane along local X axis */
+ /**
+ Sets the size of the plane along local X axis
+ \exception Ogre::InvalidParametersException X size must be larger than 0!
+ */
inline PlaneGenerator & setSizeX(Ogre::Real sizeX)
{
+ if(sizeX <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "X size must be larger than 0!", "Procedural::BoxGenerator::setSizeX(Ogre::Real)");
mSizeX = sizeX;
return *this;
}
- /** Sets the size of the plane along local Y axis */
+ /**
+ Sets the size of the plane along local Y axis
+ \exception Ogre::InvalidParametersException Y size must be larger than 0!
+ */
inline PlaneGenerator & setSizeY(Ogre::Real sizeY)
{
+ if(sizeY <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Y size must be larger than 0!", "Procedural::BoxGenerator::setSizeY(Ogre::Real)");
mSizeY = sizeY;
return *this;
}
+
+ /** Sets the size (default=1,1) */
+ inline PlaneGenerator & setSize(Ogre::Vector2 size)
+ {
+ setSizeX(size.x);
+ setSizeY(size.y);
+ return *this;
+ }
};
}
#endif
diff -r 58d50844286b library/include/ProceduralRoundedBoxGenerator.h
--- a/library/include/ProceduralRoundedBoxGenerator.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralRoundedBoxGenerator.h Tue Nov 13 14:27:32 2012 +0100
@@ -50,51 +50,95 @@
RoundedBoxGenerator() : mSizeX(1.f), mSizeY(1.f), mSizeZ(1.f),
mNumSegX(1), mNumSegY(1), mNumSegZ(1), mChamferSize(.1f), mChamferNumSeg(8) {}
- /** Sets the size of the box along X axis */
+ /**
+ Sets the size of the box along X axis
+ \exception Ogre::InvalidParametersException X size must be larger than 0!
+ */
RoundedBoxGenerator& setSizeX(Ogre::Real sizeX)
{
+ if(sizeX <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "X size must be larger than 0!", "Procedural::RoundedBoxGenerator::setSizeX(Ogre::Real)");
mSizeX = sizeX;
return *this;
}
- /** Sets the size of the box along Y axis */
+ /**
+ Sets the size of the box along Y axis
+ \exception Ogre::InvalidParametersException Y size must be larger than 0!
+ */
RoundedBoxGenerator& setSizeY(Ogre::Real sizeY)
{
+ if(sizeY <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "X size must be larger than 0!", "Procedural::RoundedBoxGenerator::setSizeY(Ogre::Real)");
mSizeY = sizeY;
return *this;
}
- /** Sets the size of the box along Z axis */
+ /**
+ Sets the size of the box along Z axis
+ \exception Ogre::InvalidParametersException Z size must be larger than 0!
+ */
RoundedBoxGenerator& setSizeZ(Ogre::Real sizeZ)
{
+ if(sizeZ <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Z size must be larger than 0!", "Procedural::RoundedBoxGenerator::setSizeZ(Ogre::Real)");
mSizeZ = sizeZ;
return *this;
}
- /** Sets the number of segments along X axis */
+ /** Sets the size (default=1,1,1) */
+ RoundedBoxGenerator& setSize(Ogre::Vector3 size)
+ {
+ setSizeX(size.x);
+ setSizeY(size.y);
+ setSizeZ(size.z);
+ return *this;
+ }
+
+ /**
+ Sets the number of segments along X axis (default=1)
+ \exception Ogre::InvalidParametersException Minimum of numSegX is 1
+ */
RoundedBoxGenerator& setNumSegX(unsigned short numSegX)
{
+ if(numSegX == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::RoundedBoxGenerator::setNumSegX(unsigned int)");
mNumSegX = numSegX;
return *this;
}
- /** Sets the number of segments along Y axis */
+ /**
+ Sets the number of segments along Y axis (default=1)
+ \exception Ogre::InvalidParametersException Minimum of numSegY is 1
+ */
RoundedBoxGenerator& setNumSegY(unsigned short numSegY)
{
+ if(numSegY == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::RoundedBoxGenerator::setNumSegY(unsigned int)");
mNumSegY = numSegY;
return *this;
}
- /** Sets the number of segments along Z axis */
+ /**
+ Sets the number of segments along Z axis (default=1)
+ \exception Ogre::InvalidParametersException Minimum of numSegZ is 1
+ */
RoundedBoxGenerator& setNumSegZ(unsigned short numSegZ)
{
+ if(numSegZ == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::RoundedBoxGenerator::setNumSegZ(unsigned int)");
mNumSegZ = numSegZ;
return *this;
}
- /** Sets the size of the chamfer, ie the radius of the rounded part */
+ /**
+ Sets the size of the chamfer, ie the radius of the rounded part
+ \exception Ogre::InvalidParametersException chamferSize must be larger than 0!
+ */
RoundedBoxGenerator& setChamferSize(Ogre::Real chamferSize)
{
+ if(chamferSize <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Chamfer size must be larger than 0!", "Procedural::RoundedBoxGenerator::setChamferSize(Ogre::Real)");
mChamferSize = chamferSize;
return *this;
}
diff -r 58d50844286b library/include/ProceduralSVG.h
--- a/library/include/ProceduralSVG.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralSVG.h Tue Nov 13 14:27:32 2012 +0100
@@ -119,9 +119,9 @@
double tb = atan2(vy, vx);
if (tb >= ta)
- return tb - ta;
+ return (Ogre::Real)(tb - ta);
- return Ogre::Math::TWO_PI - (ta - tb);
+ return Ogre::Math::TWO_PI - (Ogre::Real)(ta - tb);
}
void parseArcTo(bool rel, bool next);
diff -r 58d50844286b library/include/ProceduralShape.h
--- a/library/include/ProceduralShape.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralShape.h Tue Nov 13 14:27:32 2012 +0100
@@ -335,6 +335,8 @@
*
| \image html shape_booleansetup.png "Start shapes" | \image html shape_booleanintersection.png "Intersection of the two shapes" |
* @param other The shape against which the intersection is computed
* @return The intersection of two shapes, as a new shape
+ * @exception Ogre::InvalidStateException Current shapes must be closed and has to contain at least 2 points!
+ * @exception Ogre::InvalidParametersException Other shapes must be closed and has to contain at least 2 points!
*/
MultiShape booleanIntersect(const Shape& other) const;
@@ -344,6 +346,8 @@
* | \image html shape_booleansetup.png "Start shapes" | \image html shape_booleanunion.png "Union of the two shapes" |
* @param other The shape against which the union is computed
* @return The union of two shapes, as a new shape
+ * @exception Ogre::InvalidStateException Current shapes must be closed and has to contain at least 2 points!
+ * @exception Ogre::InvalidParametersException Other shapes must be closed and has to contain at least 2 points!
*/
MultiShape booleanUnion(const Shape& other) const;
@@ -353,6 +357,8 @@
* | \image html shape_booleansetup.png "Start shapes" | \image html shape_booleandifference.png "Difference of the two shapes" |
* @param other The shape against which the diffenrence is computed
* @return The difference of two shapes, as a new shape
+ * @exception Ogre::InvalidStateException Current shapes must be closed and has to contain at least 2 points!
+ * @exception Ogre::InvalidParametersException Other shapes must be closed and has to contain at least 2 points!
*/
MultiShape booleanDifference(const Shape& other) const;
@@ -547,10 +553,14 @@
/// Gets a position on the shape with index of the point and a percentage of position on the segment
/// @param i index of the segment
/// @param coord a number between 0 and 1 meaning the percentage of position on the segment
+ /// @exception Ogre::InvalidParametersException i is out of bounds
+ /// @exception Ogre::InvalidParametersException coord must be comprised between 0 and 1
inline Ogre::Vector2 getPosition(unsigned int i, Ogre::Real coord) const
{
- assert(mClosed || (i < mPoints.size() - 1 && "Out of Bounds"));
- assert(coord>=0. && coord<=1. && "Coord must be comprised between 0 and 1");
+ if(!mClosed || i >= mPoints.size())
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Out of Bounds", "Procedural::Path::getPosition(unsigned int, Ogre::Real)");
+ if(coord < 0.0f || coord > 1.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Coord must be comprised between 0 and 1", "Procedural::Path::getPosition(unsigned int, Ogre::Real)");
Ogre::Vector2 A = getPoint(i);
Ogre::Vector2 B = getPoint(i+1);
return A + coord*(B-A);
@@ -558,9 +568,11 @@
/// Gets a position on the shape from lineic coordinate
/// @param coord lineic coordinate
+ /// @exception Ogre::InvalidStateException The shape must at least contain 2 points
inline Ogre::Vector2 getPosition(Ogre::Real coord) const
{
- assert(mPoints.size()>=2 && "The shape must at least contain 2 points");
+ if(mPoints.size() < 2)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "The shape must at least contain 2 points", "Procedural::Shape::getPosition(Ogre::Real)");
unsigned int i=0;
while(true)
{
diff -r 58d50844286b library/include/ProceduralShapeGenerators.h
--- a/library/include/ProceduralShapeGenerators.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralShapeGenerators.h Tue Nov 13 14:27:32 2012 +0100
@@ -199,22 +199,28 @@
*/
class _ProceduralExport RectangleShape
{
- Ogre::Real mWidth,mHeight;
+ Ogre::Real mWidth, mHeight;
public:
/// Default constructor
RectangleShape() : mWidth(1.0), mHeight(1.0) {}
/// Sets width
+ /// \exception Ogre::InvalidParametersException Width must be larger than 0!
inline RectangleShape& setWidth(Ogre::Real width)
{
+ if(width <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Width must be larger than 0!", "Procedural::RectangleShape::setWidth(Ogre::Real)");
mWidth = width;
return *this;
}
/// Sets height
+ /// \exception Ogre::InvalidParametersException Height must be larger than 0!
inline RectangleShape& setHeight(Ogre::Real height)
{
+ if(height <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Height must be larger than 0!", "Procedural::RectangleShape::setHeight(Ogre::Real)");
mHeight = height;
return *this;
}
@@ -247,15 +253,21 @@
CircleShape() : mRadius(1.0), mNumSeg(8) {}
/// Sets radius
+ /// \exception Ogre::InvalidParametersException Radius must be larger than 0!
inline CircleShape& setRadius(Ogre::Real radius)
{
+ if(radius <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Radius must be larger than 0!", "Procedural::CircleShape::setRadius(Ogre::Real)");
mRadius = radius;
return *this;
}
/// Sets number of segments
+ /// \exception Ogre::InvalidParametersException Minimum of numSeg is 1
inline CircleShape& setNumSeg(unsigned int numSeg)
{
+ if(numSeg == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::CircleShape::setNumSeg(unsigned int)");
mNumSeg = numSeg;
return *this;
}
@@ -289,22 +301,31 @@
EllipseShape() : mRadiusX(1.0), mRadiusY(1.0), mNumSeg(8) {}
/// Sets radius in x direction
+ /// \exception Ogre::InvalidParametersException Radius must be larger than 0!
inline EllipseShape& setRadiusX(Ogre::Real radius)
{
+ if(radius <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Radius must be larger than 0!", "Procedural::EllipseShape::setRadiusX(Ogre::Real)");
mRadiusX = radius;
return *this;
}
/// Sets radius in y direction
+ /// \exception Ogre::InvalidParametersException Radius must be larger than 0!
inline EllipseShape& setRadiusY(Ogre::Real radius)
{
+ if(radius <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Radius must be larger than 0!", "Procedural::EllipseShape::setRadiusY(Ogre::Real)");
mRadiusY = radius;
return *this;
}
/// Sets number of segments
+ /// \exception Ogre::InvalidParametersException Minimum of numSeg is 1
inline EllipseShape& setNumSeg(unsigned int numSeg)
{
+ if(numSeg == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::EllipseShape::setNumSeg(unsigned int)");
mNumSeg = numSeg;
return *this;
}
@@ -332,27 +353,57 @@
{
Ogre::Real mLengthA, mLengthB, mLengthC;
- public:
+public:
/// Default constructor
TriangleShape() : mLengthA(1.0), mLengthB(1.0), mLengthC(1.0) {}
+ /// Creates an equilateral triangle
+ /// \exception Ogre::InvalidStateException Length of triangle edges must be longer than 0!
+ inline TriangleShape& setLength(Ogre::Real length)
+ {
+ if(length <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "Length of triangle edge must be longer than 0!", "Procedural::TriangleShape::setLengthA(Ogre::Real)");
+ mLengthA = length;
+ mLengthB = length;
+ mLengthC = length;
+ return *this;
+ }
+
/// Sets length of edge A
+ /// \exception Ogre::InvalidStateException Length of triangle edge must be longer than 0!
+ /// \exception Ogre::InvalidStateException Length of triangle edge A must be shorter or equal than B+C!
inline TriangleShape& setLengthA(Ogre::Real length)
{
+ if(length <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "Length of triangle edge must be longer than 0!", "Procedural::TriangleShape::setLengthA(Ogre::Real)");
+ if(length > (mLengthB + mLengthC))
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "Length of triangle edge A must be shorter or equal than B+C!", "Procedural::TriangleShape::setLengthA(Ogre::Real)");
mLengthA = length;
return *this;
}
/// Sets length of edge B
+ /// \exception Ogre::InvalidStateException Length of triangle edge must be longer than 0!
+ /// \exception Ogre::InvalidStateException Length of triangle edge A must be shorter or equal than B+C!
inline TriangleShape& setLengthB(Ogre::Real length)
{
+ if(length <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "Length of triangle edge must be longer than 0!", "Procedural::TriangleShape::setLengthB(Ogre::Real)");
+ if(mLengthA > (length + mLengthC))
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "Length of triangle edge A must be shorter or equal than B+C!", "Procedural::TriangleShape::setLengthB(Ogre::Real)");
mLengthB = length;
return *this;
}
/// Sets length of edge C
+ /// \exception Ogre::InvalidStateException Length of triangle edge must be longer than 0!
+ /// \exception Ogre::InvalidStateException Length of triangle edge A must be shorter or equal than B+C!
inline TriangleShape& setLengthC(Ogre::Real length)
{
+ if(length <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "Length of triangle edge must be longer than 0!", "Procedural::TriangleShape::setLengthC(Ogre::Real)");
+ if(mLengthA > (mLengthB + length))
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "Length of triangle edge A must be shorter or equal than B+C!", "Procedural::TriangleShape::setLengthC(Ogre::Real)");
mLengthC = length;
return *this;
}
@@ -360,8 +411,6 @@
/// Builds the shape
inline Shape realizeShape()
{
- assert(mLengthA>0 && mLengthB>0 && mLengthC>0 && "Length of triangle edge must be longer than 0!");
- assert(mLengthA< (mLengthB+mLengthC) && "Length of triangle edge A must be shorter or equal than B+C!");
Ogre::Radian alpha = Ogre::Math::ACos((mLengthB * mLengthB + mLengthC * mLengthC - mLengthA * mLengthA) / (2 * mLengthB * mLengthC));
Shape s;
@@ -420,6 +469,7 @@
/**
* Builds a shape from control points
+ * \exception Ogre::InvalidStateException The path contains no points
*/
Shape realizeShape();
};
@@ -439,8 +489,11 @@
BezierCurve2() : mNumSeg(8) {}
/// Sets number of segments per two control points
+ /// \exception Ogre::InvalidParametersException Minimum of numSeg is 1
inline BezierCurve2& setNumSeg(unsigned int numSeg)
{
+ if(numSeg == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::BezierCurve2::setNumSeg(unsigned int)");
mNumSeg = numSeg;
return *this;
}
@@ -469,6 +522,7 @@
/**
* Build a shape from bezier control points
+ * @exception Ogre::InvalidStateException The curve must at least contain 2 points
*/
Shape realizeShape();
};
diff -r 58d50844286b library/include/ProceduralShapeGeneratorsBase.h
--- a/library/include/ProceduralShapeGeneratorsBase.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralShapeGeneratorsBase.h Tue Nov 13 14:27:32 2012 +0100
@@ -66,9 +66,11 @@
}
/// Sets the number of segments between 2 control points
+ /// \exception Ogre::InvalidParametersException Minimum of numSeg is 1
inline T& setNumSeg(unsigned int numSeg)
{
- assert(numSeg>=1);
+ if(numSeg == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::BaseSpline2::setNumSeg(unsigned int)");
mNumSeg = numSeg;
return (T&)*this;
}
diff -r 58d50844286b library/include/ProceduralSphereGenerator.h
--- a/library/include/ProceduralSphereGenerator.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralSphereGenerator.h Tue Nov 13 14:27:32 2012 +0100
@@ -51,23 +51,38 @@
{}
- /** Sets the radius of the sphere (default=1) */
+ /**
+ Sets the radius of the sphere (default=1)
+ \exception Ogre::InvalidParametersException Radius must be larger than 0!
+ */
inline SphereGenerator & setRadius(Ogre::Real radius)
{
+ if(radius <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Radius must be larger than 0!", "Procedural::SphereGenerator::setRadius(Ogre::Real)");
mRadius = radius;
return *this;
}
- /** Sets the number of rings (default=16) */
+ /**
+ Sets the number of rings (default=16)
+ \exception Ogre::InvalidParametersException Minimum of numRings is 1
+ */
inline SphereGenerator & setNumRings(unsigned int numRings)
{
+ if(numRings == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 rings", "Procedural::SphereGenerator::setNumRings(unsigned int)");
mNumRings = numRings;
return *this;
}
- /** Sets the number of segments (default=16) */
+ /**
+ Sets the number of segments (default=16)
+ \exception Ogre::InvalidParametersException Minimum of numSegments is 1
+ */
inline SphereGenerator & setNumSegments(unsigned int numSegments)
{
+ if(numSegments == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::SphereGenerator::setNumSegments(unsigned int)");
mNumSegments = numSegments;
return *this;
}
diff -r 58d50844286b library/include/ProceduralSpringGenerator.h
--- a/library/include/ProceduralSpringGenerator.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralSpringGenerator.h Tue Nov 13 14:27:32 2012 +0100
@@ -52,29 +52,41 @@
HelixPath() : mHeight(1.0f), mRadius(1.0f), mNumRound(5.0), mNumSegPath(8) {}
/// Sets the height of the helix (default=1.0)
+ /// \exception Ogre::InvalidParametersException Height must be larger than 0!
inline HelixPath& setHeight(Ogre::Real height)
{
+ if(height <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Height must be larger than 0!", "Procedural::HelixPath::setHeight(Ogre::Real)");
mHeight = height;
return *this;
}
/// Sets the radius of the helix (default = 1.0)
+ /// \exception Ogre::InvalidParametersException Radius must be larger than 0!
inline HelixPath& setRadius(Ogre::Real radius)
{
+ if(radius <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Radius must be larger than 0!", "Procedural::HelixPath::setRadius(Ogre::Real)");
mRadius = radius;
return *this;
}
/// Sets the number of rounds (default = 5.0)
+ /// \exception Ogre::InvalidParametersException You have to rotate more then 0 times!
inline HelixPath& setNumRound(Ogre::Real numRound)
{
+ if(numRound <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "You have to rotate more then 0 times!", "Procedural::HelixPath::setNumRound(Ogre::Real)");
mNumRound = numRound;
return *this;
}
/// Sets number of segments along the path per turn
+ /// \exception Ogre::InvalidParametersException Minimum of numSeg is 1
inline HelixPath& setNumSegPath(unsigned int numSeg)
{
+ if(numSeg == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::HelixPath::setNumSegPath(unsigned int)");
mNumSegPath = numSeg;
return *this;
}
@@ -103,43 +115,61 @@
mHeight(height), mRadiusHelix(radiusHelix), mRadiusCircle(radiusCircle), mNumRound(numRound), mNumSegPath(numSegPath), mNumSegCircle(numSegCircle) {}
/// Sets the height of the spring (default=1)
+ /// \exception Ogre::InvalidParametersException Height must be larger than 0!
inline SpringGenerator& setHeight(Ogre::Real height)
{
+ if(height <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Height must be larger than 0!", "Procedural::SpringGenerator::setHeight(Ogre::Real)");
mHeight = height;
return *this;
}
/// Sets helix radius (default=1)
+ /// \exception Ogre::InvalidParametersException Radius must be larger than 0!
inline SpringGenerator& setRadiusHelix(Ogre::Real radiusHelix)
{
+ if(radiusHelix <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Radius must be larger than 0!", "Procedural::SpringGenerator::setRadiusHelix(Ogre::Real)");
mRadiusHelix = radiusHelix;
return *this;
}
/// Sets radius for extruding circle (default=0.1)
+ /// \exception Ogre::InvalidParametersException Radius must be larger than 0!
inline SpringGenerator& setRadiusCircle(Ogre::Real radiusCircle)
{
+ if(radiusCircle <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Radius must be larger than 0!", "Procedural::SpringGenerator::setRadiusCircle(Ogre::Real)");
mRadiusCircle = radiusCircle;
return *this;
}
/// Sets the number of segments along the height of the spring (default=1)
+ /// \exception Ogre::InvalidParametersException You have to rotate more then 0 times!
inline SpringGenerator& setNumRound (Ogre::Real numRound)
{
+ if(numRound <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "You have to rotate more then 0 times!", "Procedural::SpringGenerator::setNumRound(Ogre::Real)");
mNumRound = numRound;
return *this;
}
/// Sets the number of segments along helix path (default=10)
+ /// \exception Ogre::InvalidParametersException Minimum of numSegPath is 1
inline SpringGenerator& setNumSegPath(int numSegPath)
{
+ if(numSegPath == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::SpringGenerator::setNumSegPath(unsigned int)");
mNumSegPath = numSegPath;
return *this;
}
/// Sets the number of segments for extruding circle (default=8)
+ /// \exception Ogre::InvalidParametersException Minimum of numSegCircle is 1
inline SpringGenerator& setNumSegCircle(int numSegCircle)
{
+ if(numSegCircle == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::SpringGenerator::setNumSegCircle(unsigned int)");
mNumSegCircle = numSegCircle;
return *this;
}
diff -r 58d50844286b library/include/ProceduralTextureGenerator.h
--- a/library/include/ProceduralTextureGenerator.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralTextureGenerator.h Tue Nov 13 14:27:32 2012 +0100
@@ -57,51 +57,241 @@
Ogre::uint mHeight;
public:
+ /**
+ \brief Set colour of a specified pixel
+ \param x X position of pixel to paint on (0 <= x < width)
+ \param y Y position of pixel to paint on (0 <= y < height)
+ \param colour New colour of pixel
+ \exception Ogre::InvalidParametersException Pixel location is out of bounds!
+ */
void setPixel(size_t x, size_t y, Ogre::ColourValue colour);
+
+ /**
+ \brief Set colour of a specified pixel
+ \param x X position of pixel to paint on (0 <= x < width)
+ \param y Y position of pixel to paint on (0 <= y < height)
+ \param red New red value of pixel colour [0, 255]
+ \param green New green value of pixel colour [0, 255]
+ \param blue New blue value of pixel colour [0, 255]
+ \param alpha New alpha value of pixel colour [0, 255]
+ \exception Ogre::InvalidParametersException Pixel location is out of bounds!
+ */
void setPixel(size_t x, size_t y, Ogre::uchar red, Ogre::uchar green, Ogre::uchar blue, Ogre::uchar alpha = 255);
+
+ /**
+ \brief Set colour of a specified pixel
+ \param x X position of pixel to paint on (0 <= x < width)
+ \param y Y position of pixel to paint on (0 <= y < height)
+ \param red New red value of pixel colour
+ \param green New green value of pixel colour [0.0, 1.0]
+ \param blue New blue value of pixel colour [0.0, 1.0]
+ \param alpha New alpha value of pixel colour [0.0, 1.0]
+ \exception Ogre::InvalidParametersException Pixel location is out of bounds!
+ \exception Ogre::InvalidParametersException Colour value must be between 0 and 1!
+ */
void setPixel(size_t x, size_t y, Ogre::Real red, Ogre::Real green, Ogre::Real blue, Ogre::Real alpha = 1.0f);
+
+ /**
+ \brief Set red colour value of a specified pixel
+ \param x X position of pixel to paint on (0 <= x < width)
+ \param y Y position of pixel to paint on (0 <= y < height)
+ \param red New red value of pixel colour [0, 255]
+ \exception Ogre::InvalidParametersException Pixel location is out of bounds!
+ */
void setRed(size_t x, size_t y, Ogre::uchar red);
+
+ /**
+ \brief Set green colour value of a specified pixel
+ \param x X position of pixel to paint on (0 <= x < width)
+ \param y Y position of pixel to paint on (0 <= y < height)
+ \param green New green value of pixel colour [0, 255]
+ \exception Ogre::InvalidParametersException Pixel location is out of bounds!
+ */
void setGreen(size_t x, size_t y, Ogre::uchar green);
+
+ /**
+ \brief Set blue colour value of a specified pixel
+ \param x X position of pixel to paint on (0 <= x < width)
+ \param y Y position of pixel to paint on (0 <= y < height)
+ \param blue New blue value of pixel colour [0, 255]
+ \exception Ogre::InvalidParametersException Pixel location is out of bounds!
+ */
void setBlue(size_t x, size_t y, Ogre::uchar blue);
+
+ /**
+ \brief Set alpha colour value of a specified pixel
+ \param x X position of pixel to paint on (0 <= x < width)
+ \param y Y position of pixel to paint on (0 <= y < height)
+ \param alpha New alpha value of pixel colour [0, 255]
+ \exception Ogre::InvalidParametersException Pixel location is out of bounds!
+ */
void setAlpha(size_t x, size_t y, Ogre::uchar alpha);
+
+ /**
+ \brief Set red colour value of a specified pixel
+ \param x X position of pixel to paint on (0 <= x < width)
+ \param y Y position of pixel to paint on (0 <= y < height)
+ \param red New red value of pixel colour [0.0, 1.0]
+ \exception Ogre::InvalidParametersException Pixel location is out of bounds!
+ \exception Ogre::InvalidParametersException Colour value must be between 0 and 1!
+ */
void setRed(size_t x, size_t y, Ogre::Real red);
+
+ /**
+ \brief Set green colour value of a specified pixel
+ \param x X position of pixel to paint on (0 <= x < width)
+ \param y Y position of pixel to paint on (0 <= y < height)
+ \param green New green value of pixel colour [0.0, 1.0]
+ \exception Ogre::InvalidParametersException Pixel location is out of bounds!
+ */
void setGreen(size_t x, size_t y, Ogre::Real green);
+
+ /**
+ \brief Set blue colour value of a specified pixel
+ \param x X position of pixel to paint on (0 <= x < width)
+ \param y Y position of pixel to paint on (0 <= y < height)
+ \param blue New blue value of pixel colour [0.0, 1.0]
+ \exception Ogre::InvalidParametersException Pixel location is out of bounds!
+ */
void setBlue(size_t x, size_t y, Ogre::Real blue);
+
+ /**
+ \brief Set alpha colour value of a specified pixel
+ \param x X position of pixel to paint on (0 <= x < width)
+ \param y Y position of pixel to paint on (0 <= y < height)
+ \param alpha New alpha value of pixel colour [0.0, 1.0]
+ \exception Ogre::InvalidParametersException Pixel location is out of bounds!
+ */
void setAlpha(size_t x, size_t y, Ogre::Real alpha);
+
+ /**
+ \brief Copy image data (RGBA) from a buffer to this object
+ \param width Width of the image in buffer
+ \param height Height of the image in buffer
+ \param data Image buffer as source for copy
+ */
void setData(size_t width, size_t height, Ogre::uchar* data);
+
+ /**
+ \brief Copy image data (RGBA) from an other TextureBuffer object
+ \param buffer Image buffer as source for copy
+ */
void setData(TextureBufferPtr buffer);
+
+ /**
+ \brief Get colour value of a specified pixel
+ \param x X position of pixel to paint on (0 <= x < width)
+ \param y Y position of pixel to paint on (0 <= y < height)
+ \return Return colour value as an Ogre::ColourValue object.
+ \exception Ogre::InvalidParametersException Pixel location is out of bounds!
+ */
Ogre::ColourValue getPixel(size_t x, size_t y);
+
+ /**
+ \brief Get red colour value of a specified pixel
+ \param x X position of pixel to paint on (0 <= x < width)
+ \param y Y position of pixel to paint on (0 <= y < height)
+ \return Return red colour value as a byte [0, 255].
+ \exception Ogre::InvalidParametersException Pixel location is out of bounds!
+ */
Ogre::uchar getPixelRedByte(size_t x, size_t y);
+
+ /**
+ \brief Get green colour value of a specified pixel
+ \param x X position of pixel to paint on (0 <= x < width)
+ \param y Y position of pixel to paint on (0 <= y < height)
+ \return Return green colour value as a byte [0, 255].
+ \exception Ogre::InvalidParametersException Pixel location is out of bounds!
+ */
Ogre::uchar getPixelGreenByte(size_t x, size_t y);
+
+ /**
+ \brief Get blue colour value of a specified pixel
+ \param x X position of pixel to paint on (0 <= x < width)
+ \param y Y position of pixel to paint on (0 <= y < height)
+ \return Return blue colour value as a byte [0, 255].
+ \exception Ogre::InvalidParametersException Pixel location is out of bounds!
+ */
Ogre::uchar getPixelBlueByte(size_t x, size_t y);
+
+ /**
+ \brief Get alpha colour value of a specified pixel
+ \param x X position of pixel to paint on (0 <= x < width)
+ \param y Y position of pixel to paint on (0 <= y < height)
+ \return Return alpha colour value as a byte [0, 255].
+ \exception Ogre::InvalidParametersException Pixel location is out of bounds!
+ */
Ogre::uchar getPixelAlphaByte(size_t x, size_t y);
+
+ /**
+ \brief Get red colour value of a specified pixel
+ \param x X position of pixel to paint on (0 <= x < width)
+ \param y Y position of pixel to paint on (0 <= y < height)
+ \return Return red colour value as a Ogre::Real [0.0, 1.0].
+ \exception Ogre::InvalidParametersException Pixel location is out of bounds!
+ */
Ogre::Real getPixelRedReal(size_t x, size_t y);
+
+ /**
+ \brief Get green colour value of a specified pixel
+ \param x X position of pixel to paint on (0 <= x < width)
+ \param y Y position of pixel to paint on (0 <= y < height)
+ \return Return green colour value as a Ogre::Real [0.0, 1.0].
+ \exception Ogre::InvalidParametersException Pixel location is out of bounds!
+ */
Ogre::Real getPixelGreenReal(size_t x, size_t y);
+
+ /**
+ \brief Get blue colour value of a specified pixel
+ \param x X position of pixel to paint on (0 <= x < width)
+ \param y Y position of pixel to paint on (0 <= y < height)
+ \return Return blue colour value as a Ogre::Real [0.0, 1.0].
+ \exception Ogre::InvalidParametersException Pixel location is out of bounds!
+ */
Ogre::Real getPixelBlueReal(size_t x, size_t y);
+
+ /**
+ \brief Get alpha colour value of a specified pixel
+ \param x X position of pixel to paint on (0 <= x < width)
+ \param y Y position of pixel to paint on (0 <= y < height)
+ \return Return alpha colour value as a Ogre::Real [0.0, 1.0].
+ \exception Ogre::InvalidParametersException Pixel location is out of bounds!
+ */
Ogre::Real getPixelAlphaReal(size_t x, size_t y);
+ /**
+ \brief Get the texture image width.
+ */
inline Ogre::uint getWidth() const
{
return mWidth;
}
+ /**
+ \brief Get the texture image height.
+ */
inline Ogre::uint getHeight() const
{
return mHeight;
}
+ /**
+ \brief Create a copy of the current texture image buffer
+ \note You have to delete cloned object by yourself!
+ */
TextureBufferPtr clone();
-public:
/**
\brief Standard constructor which copy a given image
\param tocopy Image which to copy
+ \exception Ogre::InvalidParametersException Pointer to source image must not be NULL!
*/
TextureBuffer(TextureBufferPtr tocopy);
/**
\brief Standard constructor which creates a quadratic image buffer with the given size
\param width_height Edge length in px
+ \exception Ogre::InvalidParametersException Minimum edge size is 8!
*/
TextureBuffer(Ogre::uint width_height);
@@ -146,6 +336,7 @@
Default constructor.
\param pBuffer Image buffer where to store the generated image.
\param name Filter name
+ \exception Ogre::InvalidParametersException Texture buffer is not set!
*/
TextureProcessing(TextureBufferPtr pBuffer, Ogre::String name);
diff -r 58d50844286b library/include/ProceduralTorusGenerator.h
--- a/library/include/ProceduralTorusGenerator.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralTorusGenerator.h Tue Nov 13 14:27:32 2012 +0100
@@ -58,30 +58,50 @@
*/
void addToTriangleBuffer(TriangleBuffer& buffer) const;
- /** Sets the number of segments on the section circle */
+ /**
+ Sets the number of segments on the section circle
+ \exception Ogre::InvalidParametersException Minimum of numSegSection is 1
+ */
inline TorusGenerator & setNumSegSection(unsigned int numSegSection)
{
+ if(mNumSegSection == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::TorusGenerator::setNumSegSection(unsigned int)");
mNumSegSection = numSegSection;
return *this;
}
- /** Sets the number of segments along the guiding circle */
+ /**
+ Sets the number of segments along the guiding circle
+ \exception Ogre::InvalidParametersException Minimum of numSegCircle is 1
+ */
inline TorusGenerator & setNumSegCircle(unsigned int numSegCircle)
{
+ if(numSegCircle == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::TorusGenerator::setNumSegCircle(unsigned int)");
mNumSegCircle = numSegCircle;
return *this;
}
- /** Sets the radius of the guiding circle */
+ /**
+ Sets the radius of the guiding circle
+ \exception Ogre::InvalidParametersException Radius must be larger than 0!
+ */
inline TorusGenerator & setRadius(Ogre::Real radius)
{
+ if(radius <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Radius must be larger than 0!", "Procedural::TorusGenerator::setRadius(Ogre::Real)");
mRadius = radius;
return *this;
}
- /** Sets the radius of the section circle */
+ /**
+ Sets the radius of the section circle
+ \exception Ogre::InvalidParametersException Radius must be larger than 0!
+ */
inline TorusGenerator & setSectionRadius(Ogre::Real sectionRadius)
{
+ if(sectionRadius <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Radius must be larger than 0!", "Procedural::TorusGenerator::setSectionRadius(Ogre::Real)");
mSectionRadius = sectionRadius;
return *this;
}
diff -r 58d50844286b library/include/ProceduralTorusKnotGenerator.h
--- a/library/include/ProceduralTorusKnotGenerator.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralTorusKnotGenerator.h Tue Nov 13 14:27:32 2012 +0100
@@ -62,44 +62,74 @@
*/
void addToTriangleBuffer(TriangleBuffer& buffer) const;
- /** Sets the number of segments along the section (default=8) */
+ /**
+ Sets the number of segments along the section (default=8)
+ \exception Ogre::InvalidParametersException Minimum of numSegCircle is 1
+ */
inline TorusKnotGenerator & setNumSegSection(unsigned int numSegSection)
{
+ if(numSegSection == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::TorusKnotGenerator::setNumSegSection(unsigned int)");
mNumSegSection = numSegSection;
return *this;
}
- /** Sets the number of segments along the circle (default=16) */
+ /**
+ Sets the number of segments along the circle (default=16)
+ \exception Ogre::InvalidParametersException Minimum of numSegCircle is 1
+ */
inline TorusKnotGenerator & setNumSegCircle(unsigned int numSegCircle)
{
+ if(numSegCircle == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::TorusKnotGenerator::setNumSegCircle(unsigned int)");
mNumSegCircle = numSegCircle;
return *this;
}
- /** Sets the main radius of the knot (default=1) */
+ /**
+ Sets the main radius of the knot (default=1)
+ \exception Ogre::InvalidParametersException Radius must be larger than 0!
+ */
inline TorusKnotGenerator & setRadius(Ogre::Real radius)
{
+ if(radius <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Radius must be larger than 0!", "Procedural::TorusKnotGenerator::setRadius(Ogre::Real)");
mRadius = radius;
return *this;
}
- /** Sets the section radius (default=0.2) */
+ /**
+ Sets the section radius (default=0.2)
+ \exception Ogre::InvalidParametersException Radius must be larger than 0!
+ */
inline TorusKnotGenerator & setSectionRadius(Ogre::Real sectionRadius)
{
+ if(sectionRadius <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Radius must be larger than 0!", "Procedural::TorusKnotGenerator::setSectionRadius(Ogre::Real)");
mSectionRadius = sectionRadius;
return *this;
}
- /** Sets the p parameter of the knot (default=2) */
+ /**
+ Sets the p parameter of the knot (default=2)
+ \exception Ogre::InvalidParametersException Parameter p must be larger than 0!
+ */
inline TorusKnotGenerator & setP(int p)
{
+ if(p <= 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Parameter p must be larger than 0!", "Procedural::TorusKnotGenerator::setP(int)");
mP = p;
return *this;
}
- /** Sets the q parameter of the knot (default=3) */
+ /**
+ Sets the q parameter of the knot (default=3)
+ \exception Ogre::InvalidParametersException Parameter q must be larger than 0!
+ */
inline TorusKnotGenerator & setQ(int q)
{
+ if(q <= 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Parameter q must be larger than 0!", "Procedural::TorusKnotGenerator::setQ(int)");
mQ = q;
return *this;
}
diff -r 58d50844286b library/include/ProceduralTriangulator.h
--- a/library/include/ProceduralTriangulator.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralTriangulator.h Tue Nov 13 14:27:32 2012 +0100
@@ -53,101 +53,101 @@
struct DelaunaySegment;
typedef std::list DelaunayTriangleBuffer;
-//-----------------------------------------------------------------------
-struct DelaunaySegment
-{
- int i1, i2;
- DelaunaySegment(int _i1, int _i2) : i1(_i1), i2(_i2) {}
- bool operator<(const DelaunaySegment& other) const
+ //-----------------------------------------------------------------------
+ struct DelaunaySegment
{
- if (i1!=other.i1)
- return i1pl = pl;
+ }
+ inline Ogre::Vector2 p(int k) const
+ {
+ return (*pl)[i[k]];
+ }
+
+ bool operator==(const Triangle& other) const
+ {
+ return i[0]==other.i[0] && i[1]==other.i[1] && i[2]==other.i[2];
+ }
+
+ inline Ogre::Vector2 getMidPoint() const
+ {
+ return 1.f/3.f * (p(0)+p(1)+p(2));
+ }
+
+ void setVertices(int i0, int i1, int i2);
+
+ int findSegNumber(int i0, int i1) const;
+
+ bool isPointInside(const Ogre::Vector2& point);
+
+ bool containsSegment(int i0, int i1) const
+ {
+ return ((i0==i[0] || i0==i[1] || i0==i[2])&&(i1==i[0] || i1==i[1] || i1==i[2]));
+ }
+
+ enum InsideType
+ {
+ IT_INSIDE, IT_OUTSIDE, IT_BORDERLINEOUTSIDE
+ };
+
+ InsideType isPointInsideCircumcircle(const Ogre::Vector2& point);
+
+ inline void makeDirectIfNeeded()
+ {
+ if ((p(1)-p(0)).crossProduct(p(2)-p(0))<0)
+ {
+ std::swap(i[0], i[1]);
+ }
+ }
+
+ inline bool isDegenerate()
+ {
+ if ( Ogre::Math::Abs((p(1)-p(0)).crossProduct(p(2)-p(0)))<1e-4)
+ return true;
+ return false;
+ }
+
+ std::string debugDescription()
+ {
+ return "("+Ogre::StringConverter::toString(i[0])+","
+ +Ogre::StringConverter::toString(i[1])+","+Ogre::StringConverter::toString(i[2])+") <"
+ "("+Ogre::StringConverter::toString(p(0))+","
+ +Ogre::StringConverter::toString(p(1))+","+Ogre::StringConverter::toString(p(2))+">";
+ }
+ };
//-----------------------------------------------------------------------
-struct Triangle
-{
- const PointList* pl;
- int i[3];
- Triangle(const PointList* pl)
- { this->pl = pl;
- }
-
- inline Ogre::Vector2 p(int k) const
+ struct TouchSuperTriangle
{
- return (*pl)[i[k]];
- }
-
- bool operator==(const Triangle& other) const
- {
- return i[0]==other.i[0] && i[1]==other.i[1] && i[2]==other.i[2];
- }
-
- inline Ogre::Vector2 getMidPoint() const
- {
- return 1.f/3.f * (p(0)+p(1)+p(2));
- }
-
- void setVertices(int i0, int i1, int i2);
-
- int findSegNumber(int i0, int i1) const;
-
- bool isPointInside(const Ogre::Vector2& point);
-
- bool containsSegment(int i0, int i1) const
- {
- return ((i0==i[0] || i0==i[1] || i0==i[2])&&(i1==i[0] || i1==i[1] || i1==i[2]));
- }
-
- enum InsideType
- {
- IT_INSIDE, IT_OUTSIDE, IT_BORDERLINEOUTSIDE
+ int i0,i1,i2;
+ TouchSuperTriangle(int i, int j, int k) : i0(i), i1(j), i2(k) {}
+ bool operator()(const Triangulator::Triangle& tri)
+ {
+ for (int k=0;k<3;k++) if (tri.i[k]==i0 || tri.i[k]==i1 ||tri.i[k]==i2) return true;
+ return false;
+ }
};
- InsideType isPointInsideCircumcircle(const Ogre::Vector2& point);
-
- inline void makeDirectIfNeeded()
- {
- if ((p(1)-p(0)).crossProduct(p(2)-p(0))<0)
- {
- std::swap(i[0], i[1]);
- }
- }
-
- inline bool isDegenerate()
- {
- if ( Ogre::Math::Abs((p(1)-p(0)).crossProduct(p(2)-p(0)))<1e-4)
- return true;
- return false;
- }
-
- std::string debugDescription()
- {
- return "("+Ogre::StringConverter::toString(i[0])+","
- +Ogre::StringConverter::toString(i[1])+","+Ogre::StringConverter::toString(i[2])+") <"
- "("+Ogre::StringConverter::toString(p(0))+","
- +Ogre::StringConverter::toString(p(1))+","+Ogre::StringConverter::toString(p(2))+">";
- }
-};
-//-----------------------------------------------------------------------
-struct TouchSuperTriangle
-{
- int i0,i1,i2;
- TouchSuperTriangle(int i, int j, int k) : i0(i), i1(j), i2(k) {}
- bool operator()(const Triangulator::Triangle& tri)
- {
- for (int k=0;k<3;k++) if (tri.i[k]==i0 || tri.i[k]==i1 ||tri.i[k]==i2) return true;
- return false;
- }
-};
-
Shape* mShapeToTriangulate;
MultiShape* mMultiShapeToTriangulate;
Triangle2D* mManualSuperTriangle;
@@ -202,6 +202,7 @@
/**
* Executes the Constrained Delaunay Triangulation algorithm
* @param ouput A vector of index where is outputed the resulting triangle indexes
+ * @exception Ogre::InvalidStateException Either shape or multishape or segment list must be defined
*/
void triangulate(std::vector& output, PointList& outputVertices) const;
diff -r 58d50844286b library/include/ProceduralTubeGenerator.h
--- a/library/include/ProceduralTubeGenerator.h Fri Nov 09 23:09:04 2012 +0100
+++ b/library/include/ProceduralTubeGenerator.h Tue Nov 13 14:27:32 2012 +0100
@@ -61,37 +61,68 @@
*/
void addToTriangleBuffer(TriangleBuffer& buffer) const;
- /** Sets the number of segments when rotating around the tube's axis (default=16) */
+ /**
+ Sets the number of segments when rotating around the tube's axis (default=16)
+ \exception Ogre::InvalidParametersException Minimum of numSegBase is 1
+ */
inline TubeGenerator & setNumSegBase(unsigned int numSegBase)
{
+ if(numSegBase == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::TubeGenerator::setNumSegBase(unsigned int)");
mNumSegBase = numSegBase;
return *this;
}
- /** Sets the number of segments along the height of the cylinder (default=1) */
+ /**
+ Sets the number of segments along the height of the cylinder (default=1)
+ \exception Ogre::InvalidParametersException Minimum of numSegHeight is 1
+ */
inline TubeGenerator & setNumSegHeight(unsigned int numSegHeight)
{
+ if(numSegHeight == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "There must be more than 0 segments", "Procedural::TubeGenerator::setNumSegHeight(unsigned int)");
mNumSegHeight = numSegHeight;
return *this;
}
- /** Sets the outer radius of the tube (default=2)*/
+ /**
+ Sets the outer radius of the tube (default=2)
+ \exception Ogre::InvalidParametersException Radius must be larger than 0!
+ \exception Ogre::InvalidParametersException Outer radius must be bigger than inner radius
+ */
inline TubeGenerator & setOuterRadius(Ogre::Real outerRadius)
{
+ if(outerRadius <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Radius must be larger than 0!", "Procedural::TubeGenerator::setOuterRadius(Ogre::Real)");
+ if(outerRadius < mInnerRadius)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Outer radius must be bigger than inner radius!", "Procedural::TubeGenerator::setOuterRadius(Ogre::Real)");
mOuterRadius = outerRadius;
return *this;
}
- /** Sets the inner radius of the tube (default=1)*/
+ /**
+ Sets the inner radius of the tube (default=1)
+ \exception Ogre::InvalidParametersException Radius must be larger than 0!
+ \exception Ogre::InvalidParametersException Outer radius must be bigger than inner radius
+ */
inline TubeGenerator & setInnerRadius(Ogre::Real innerRadius)
{
+ if(innerRadius <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Radius must be larger than 0!", "Procedural::TubeGenerator::setInnerRadius(Ogre::Real)");
+ if(mOuterRadius < innerRadius)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Outer radius must be bigger than inner radius!", "Procedural::TubeGenerator::setInnerRadius(Ogre::Real)");
mInnerRadius = innerRadius;
return *this;
}
- /** Sets the height of the tube (default=1) */
+ /**
+ Sets the height of the tube (default=1)
+ \exception Ogre::InvalidParametersException Height must be larger than 0!
+ */
inline TubeGenerator & setHeight(Ogre::Real height)
{
+ if(height <= 0.0f)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Height must be larger than 0!", "Procedural::TubeGenerator::setHeight(Ogre::Real)");
mHeight = height;
return *this;
}
diff -r 58d50844286b library/src/ProceduralBoxGenerator.cpp
--- a/library/src/ProceduralBoxGenerator.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/library/src/ProceduralBoxGenerator.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -36,9 +36,6 @@
{
void BoxGenerator::addToTriangleBuffer(TriangleBuffer& buffer) const
{
- assert(mNumSegX>0 && mNumSegY>0 && mNumSegZ>0 && "Num seg must be positive integers");
- assert(mSizeX>0. && mSizeY>0. && mSizeZ>0. && "Sizes must be positive");
-
PlaneGenerator pg;
pg.setUTile(mUTile).setVTile(mVTile);
if (mTransform)
diff -r 58d50844286b library/src/ProceduralCapsuleGenerator.cpp
--- a/library/src/ProceduralCapsuleGenerator.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/library/src/ProceduralCapsuleGenerator.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -35,9 +35,6 @@
{
void CapsuleGenerator::addToTriangleBuffer(TriangleBuffer& buffer) const
{
- assert(mNumRings>0 && mNumSegments>0 && mNumSegHeight>0 && "Num seg must be positive integers");
- assert(mHeight>0. && mRadius>0. && "mHeight and radius must be positive");
-
buffer.rebaseOffset();
buffer.estimateVertexCount((2*mNumRings+2)*(mNumSegments+1) + (mNumSegHeight-1)*(mNumSegments+1));
buffer.estimateIndexCount((2*mNumRings+1)*(mNumSegments+1)*6 + (mNumSegHeight-1)*(mNumSegments+1)*6);
diff -r 58d50844286b library/src/ProceduralConeGenerator.cpp
--- a/library/src/ProceduralConeGenerator.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/library/src/ProceduralConeGenerator.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -35,9 +35,6 @@
{
void ConeGenerator::addToTriangleBuffer(TriangleBuffer& buffer) const
{
- assert(mHeight>0. && mRadius>0. && "Height and radius must be positive");
- assert(mNumSegBase>0 && mNumSegHeight>0 && "Num seg must be positive integers");
-
buffer.rebaseOffset();
buffer.estimateVertexCount((mNumSegHeight+1)*(mNumSegBase+1)+mNumSegBase+2);
buffer.estimateIndexCount(mNumSegHeight*mNumSegBase*6+3*mNumSegBase);
diff -r 58d50844286b library/src/ProceduralCylinderGenerator.cpp
--- a/library/src/ProceduralCylinderGenerator.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/library/src/ProceduralCylinderGenerator.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -36,9 +36,6 @@
void CylinderGenerator::addToTriangleBuffer(TriangleBuffer& buffer) const
{
- assert(mHeight>0. && mRadius>0. && "height and radius must be positive");
- assert(mNumSegBase>0 && mNumSegHeight>0 && "Num seg must be positive integers");
-
buffer.rebaseOffset();
if (mCapped)
{
diff -r 58d50844286b library/src/ProceduralDebugRendering.cpp
--- a/library/src/ProceduralDebugRendering.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/library/src/ProceduralDebugRendering.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -34,8 +34,11 @@
{
ManualObject* ShowNormalsGenerator::buildManualObject() const
{
- assert(mTriangleBuffer && "The input triangle buffer must not be null");
+ if(mTriangleBuffer == NULL)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "The input triangle buffer must not be null", "Procedural::ShowNormalsGenerator::buildManualObject()");
SceneManager* sceneMgr = Ogre::Root::getSingleton().getSceneManagerIterator().begin()->second;
+ if(sceneMgr == NULL)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "Scene Manager must be set in Root", "Procedural::ShowNormalsGenerator::buildManualObject()");
ManualObject * manual = sceneMgr->createManualObject();
manual->begin("BaseWhiteNoLighting", RenderOperation::OT_LINE_LIST);
const std::vector& vertices = mTriangleBuffer->getVertices();
diff -r 58d50844286b library/src/ProceduralExtruder.cpp
--- a/library/src/ProceduralExtruder.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/library/src/ProceduralExtruder.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -37,10 +37,14 @@
//-----------------------------------------------------------------------
void Extruder::_extrudeBodyImpl(TriangleBuffer& buffer, const Shape* shapeToExtrude) const
{
- assert(mExtrusionPath && shapeToExtrude && "Shape and Path must not be null!");
+ if(mExtrusionPath == NULL || shapeToExtrude == NULL)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "Shape and Path must not be null!", "Procedural::Extruder::_extrudeBodyImpl(Procedural::TriangleBuffer&, const Procedural::Shape*)");
+
unsigned int numSegPath = mExtrusionPath->getSegCount();
unsigned int numSegShape = shapeToExtrude->getSegCount();
- assert(numSegPath>0 && numSegShape>0 && "Shape and path must contain at least two points");
+
+ if(numSegPath == 0 || numSegShape == 0)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "Shape and path must contain at least two points", "Procedural::Extruder::_extrudeBodyImpl(Procedural::TriangleBuffer&, const Procedural::Shape*)");
Real totalPathLength = mExtrusionPath->getTotalLength();
Real totalShapeLength = shapeToExtrude->getTotalLength();
@@ -224,7 +228,8 @@
//-----------------------------------------------------------------------
void Extruder::addToTriangleBuffer(TriangleBuffer& buffer) const
{
- assert((mShapeToExtrude || mMultiShapeToExtrude) && "Either shape or multishape must be defined!");
+ if(mShapeToExtrude == NULL && mMultiShapeToExtrude == NULL)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "Either shape or multishape must be defined!", "Procedural::Extruder::addToTriangleBuffer(Procedural::TriangleBuffer)");
// Triangulate the begin and end caps
bool isShapeClosed = (mShapeToExtrude && mShapeToExtrude->isClosed()) || (mMultiShapeToExtrude && mMultiShapeToExtrude->isClosed());
diff -r 58d50844286b library/src/ProceduralIcoSphereGenerator.cpp
--- a/library/src/ProceduralIcoSphereGenerator.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/library/src/ProceduralIcoSphereGenerator.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -35,9 +35,6 @@
{
void IcoSphereGenerator::addToTriangleBuffer(TriangleBuffer& buffer) const
{
- assert(mRadius>0. && "Radius must me positive");
- assert(mNumIterations>0 && "numIterations must be positive");
-
std::vector vertices;
int offset = 0;
diff -r 58d50844286b library/src/ProceduralLathe.cpp
--- a/library/src/ProceduralLathe.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/library/src/ProceduralLathe.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -36,8 +36,11 @@
//-----------------------------------------------------------------------
void Lathe::_latheBodyImpl(TriangleBuffer& buffer, const Shape* shapeToExtrude) const
{
+ if(shapeToExtrude == NULL)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "Shape must not be null!", "Procedural::Lathe::_latheBodyImpl(Procedural::TriangleBuffer&, const Procedural::Shape*)");
int numSegShape = shapeToExtrude->getSegCount();
- assert(numSegShape>1 && "Shape must contain at least two points");
+ if(numSegShape < 2)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "Shape must contain at least two points", "Procedural::Lathe::_latheBodyImpl(Procedural::TriangleBuffer&, const Procedural::Shape*)");
int offset =0;
//int numSeg = mClosed?mNumSeg+1:mNumSeg;
@@ -165,7 +168,8 @@
//-----------------------------------------------------------------------
void Lathe::addToTriangleBuffer(TriangleBuffer& buffer) const
{
- assert((mShapeToExtrude || mMultiShapeToExtrude) && "Either shape or multishape must be defined!");
+ if(mShapeToExtrude == NULL && mMultiShapeToExtrude == NULL)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "Either shape or multishape must be defined!", "Procedural::Lathe::addToTriangleBuffer(Procedural::TriangleBuffer)");
// Triangulate the begin and end caps
if (!mClosed && mCapped)
diff -r 58d50844286b library/src/ProceduralMeshModifiers.cpp
--- a/library/src/ProceduralMeshModifiers.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/library/src/ProceduralMeshModifiers.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -32,7 +32,8 @@
{
void SpherifyModifier::modify()
{
- assert(mInputTriangleBuffer && "Input triangle buffer must not be null");
+ if(mInputTriangleBuffer == NULL)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "Input triangle buffer must be set", "Procedural::SpherifyModifier::modify()");
for (std::vector::iterator it = mInputTriangleBuffer->getVertices().begin(); it!=mInputTriangleBuffer->getVertices().end(); ++it)
{
diff -r 58d50844286b library/src/ProceduralPath.cpp
--- a/library/src/ProceduralPath.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/library/src/ProceduralPath.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -95,7 +95,8 @@
Ogre::Vector3 Path::getPosition(Ogre::Real coord) const
{
- assert(mPoints.size() >= 2 && "The path must at least contain 2 points");
+ if(mPoints.size() < 2)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "The path must at least contain 2 points", "Procedural::Path::getPosition(Ogre::Real)");
unsigned int i = 0;
while (true)
{
diff -r 58d50844286b library/src/ProceduralPathGenerators.cpp
--- a/library/src/ProceduralPathGenerators.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/library/src/ProceduralPathGenerators.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -87,7 +87,8 @@
//-----------------------------------------------------------------------
Path RoundedCornerSpline3::realizePath()
{
- assert(!mPoints.empty());
+ if(mPoints.empty())
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "The path contains no points", "Procedural::RoundedCornerSpline3::realizePath()");
Path path;
unsigned int numPoints = mClosed ? mPoints.size() : (mPoints.size() - 2);
@@ -143,7 +144,8 @@
//-----------------------------------------------------------------------
Path BezierCurve3::realizePath()
{
- assert(mPoints.size() > 1);
+ if(mPoints.size() < 2)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "The curve must at least contain 2 points", "Procedural::BezierCurve3::realizePath()");
unsigned int* coef = new unsigned int[mPoints.size()];
if(mPoints.size() == 2)
diff -r 58d50844286b library/src/ProceduralPlaneGenerator.cpp
--- a/library/src/ProceduralPlaneGenerator.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/library/src/ProceduralPlaneGenerator.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -35,10 +35,6 @@
{
void PlaneGenerator::addToTriangleBuffer(TriangleBuffer& buffer) const
{
- assert(mNumSegX>0 && mNumSegY>0 && "Num seg must be positive");
- assert(!mNormal.isZeroLength() && "Normal must not be null");
- assert(mSizeX>0. && mSizeY>0. && "Size must be positive");
-
buffer.rebaseOffset();
buffer.estimateVertexCount((mNumSegX+1)*(mNumSegY+1));
buffer.estimateIndexCount(mNumSegX*mNumSegY*6);
diff -r 58d50844286b library/src/ProceduralRoundedBoxGenerator.cpp
--- a/library/src/ProceduralRoundedBoxGenerator.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/library/src/ProceduralRoundedBoxGenerator.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -37,8 +37,6 @@
void RoundedBoxGenerator::_addCorner(TriangleBuffer& buffer, bool isXPositive, bool isYPositive, bool isZPositive) const
{
- assert(mNumSegX>0 && mNumSegY>0 && mNumSegZ>0 && mChamferNumSeg>0 && "Num seg must be positive integers");
- assert(mSizeX>0. && mSizeY>0. && mSizeZ>0. && mChamferSize>0. && "Sizes must be positive");
buffer.rebaseOffset();
buffer.estimateVertexCount((mChamferNumSeg+1)*(mChamferNumSeg+1));
buffer.estimateIndexCount(mChamferNumSeg*mChamferNumSeg*6);
diff -r 58d50844286b library/src/ProceduralSVG.cpp
--- a/library/src/ProceduralSVG.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/library/src/ProceduralSVG.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -291,7 +291,7 @@
for(size_t i = 0; i < len; i++)
{
bool valid = false;
- for(int j = 0; j < strlen(achar); j++)
+ for(Ogre::uint j = 0; j < strlen(achar); j++)
{
valid = (tmp[i] == achar[j]);
if(valid) break;
@@ -507,8 +507,8 @@
Real sinPhi = sin(x_axis_rotation * RadiansPerDegree);
Real cosPhi = cos(x_axis_rotation * RadiansPerDegree);
- Real x1dash = cosPhi * (point.x - epx) / 2.0 + sinPhi * (point.y - epy) / 2.0;
- Real y1dash = -sinPhi * (point.x - epx) / 2.0 + cosPhi * (point.y - epy) / 2.0;
+ Real x1dash = cosPhi * (point.x - epx) / 2.0f + sinPhi * (point.y - epy) / 2.0f;
+ Real y1dash = -sinPhi * (point.x - epx) / 2.0f + cosPhi * (point.y - epy) / 2.0f;
Real root;
Real numerator = rx * rx * ry * ry - rx * rx * y1dash * y1dash - ry * ry * x1dash * x1dash;
@@ -523,26 +523,26 @@
}
else
{
- root = ((largeArc && clockwise) || (!largeArc && !clockwise) ? -1.0 : 1.0) * sqrt(numerator / (rx * rx * y1dash * y1dash + ry * ry * x1dash * x1dash));
+ root = ((largeArc && clockwise) || (!largeArc && !clockwise) ? -1.0f : 1.0f) * sqrt(numerator / (rx * rx * y1dash * y1dash + ry * ry * x1dash * x1dash));
}
Real cxdash = root * rx * y1dash / ry;
Real cydash = -root * ry * x1dash / rx;
- Real cx = cosPhi * cxdash - sinPhi * cydash + (point.x + epx) / 2.0;
- Real cy = sinPhi * cxdash + cosPhi * cydash + (point.y + epy) / 2.0;
+ Real cx = cosPhi * cxdash - sinPhi * cydash + (point.x + epx) / 2.0f;
+ Real cy = sinPhi * cxdash + cosPhi * cydash + (point.y + epy) / 2.0f;
Real theta1 = CalculateVectorAngle(1.0, 0.0, (x1dash - cxdash) / rx, (y1dash - cydash) / ry);
Real dtheta = CalculateVectorAngle((x1dash - cxdash) / rx, (y1dash - cydash) / ry, (-x1dash - cxdash) / rx, (-y1dash - cydash) / ry);
if (!clockwise && dtheta > 0)
- dtheta -= 2.0 * Math::PI;
+ dtheta -= 2.0f * Math::PI;
else if (clockwise && dtheta < 0)
- dtheta += 2.0 * Math::PI;
+ dtheta += 2.0f * Math::PI;
- int segments = (int)ceil((double)abs(dtheta / (Math::PI / 2.0)));
+ int segments = (int)ceil((double)abs(dtheta / (Math::PI / 2.0f)));
Real delta = dtheta / segments;
- Real t = 8.0 / 3.0 * sin(delta / 4.0) * sin(delta / 4.0) / sin(delta / 2.0);
+ Real t = 8.0f / 3.0f * sin(delta / 4.0f) * sin(delta / 4.0f) / sin(delta / 2.0f);
Real startX = point.x;
Real startY = point.y;
diff -r 58d50844286b library/src/ProceduralShape.cpp
--- a/library/src/ProceduralShape.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/library/src/ProceduralShape.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -230,8 +230,10 @@
//-----------------------------------------------------------------------
MultiShape Shape::_booleanOperation(const Shape& other, BooleanOperationType opType) const
{
- assert(mClosed && other.mClosed);
- assert(mPoints.size()>1 && other.mPoints.size()>1);
+ if(!mClosed || mPoints.size() < 2)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "Current shapes must be closed and has to contain at least 2 points!", "Procedural::Shape::_booleanOperation(const Procedural::Shape&, Procedural::BooleanOperationType)");
+ if(!other.mClosed || other.mPoints.size() < 2)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Other shapes must be closed and has to contain at least 2 points!", "Procedural::Shape::_booleanOperation(const Procedural::Shape&, Procedural::BooleanOperationType)");
// Compute the intersection between the 2 shapes
std::vector intersections;
@@ -362,7 +364,7 @@
bool result = _findWhereToGo(inputShapes, opType, currentIntersection, shapeSelector, isIncreasing, currentSegment);
if (!result)
{
- assert(false && "we should not be here!");
+ OGRE_EXCEPT(Ogre::Exception::ERR_INTERNAL_ERROR, "We should not be here!", "Procedural::Shape::_booleanOperation(const Procedural::Shape&, Procedural::BooleanOperationType)");
}
}
else
diff -r 58d50844286b library/src/ProceduralShapeGenerators.cpp
--- a/library/src/ProceduralShapeGenerators.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/library/src/ProceduralShapeGenerators.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -116,7 +116,8 @@
//-----------------------------------------------------------------------
Shape RoundedCornerSpline2::realizeShape()
{
- assert(!mPoints.empty());
+ if(mPoints.empty())
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "The shape contains no points", "Procedural::RoundedCornerSpline2::realizePath()");
Shape shape;
unsigned int numPoints = mClosed ? mPoints.size() : (mPoints.size() - 2);
@@ -170,7 +171,8 @@
//-----------------------------------------------------------------------
Shape BezierCurve2::realizeShape()
{
- assert(mPoints.size() > 1);
+ if(mPoints.size() < 2)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "The curve must at least contain 2 points", "Procedural::BezierCurve2::realizePath()");
unsigned int* coef = new unsigned int[mPoints.size()];
if(mPoints.size() == 2)
diff -r 58d50844286b library/src/ProceduralSphereGenerator.cpp
--- a/library/src/ProceduralSphereGenerator.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/library/src/ProceduralSphereGenerator.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -35,9 +35,6 @@
{
void SphereGenerator::addToTriangleBuffer(TriangleBuffer& buffer) const
{
- assert(mNumRings>0 && mNumSegments>0 && "Num seg must be positive");
- assert(mRadius>0 && "Radius must be positive");
-
buffer.rebaseOffset();
buffer.estimateVertexCount((mNumRings+1)*(mNumSegments+1));
buffer.estimateIndexCount(mNumRings*(mNumSegments+1)*6);
diff -r 58d50844286b library/src/ProceduralSpringGenerator.cpp
--- a/library/src/ProceduralSpringGenerator.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/library/src/ProceduralSpringGenerator.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -40,17 +40,12 @@
//-----------------------------------------------------------------------
Path HelixPath::realizePath()
{
- assert(mNumSegPath>0 && "Num seg must be positive integers");
- assert(mHeight>0. && "Sizes must be positive");
- assert(mNumRound>0. && "number of rounds must be positive");
- assert(mRadius>0. && "Radius must be positive");
-
Path helix;
Real angleStep = Math::TWO_PI / static_cast(mNumSegPath);
Real heightStep = mHeight / static_cast(mNumSegPath);
+
for (size_t i=0;i0 && mNumSegCircle>0 && "Num seg must be positive integers");
- assert(mHeight>0. && "Sizes must be positive");
- assert(mNumRound>0. && "number of rounds must be positive");
- assert(mRadiusHelix>0. && mRadiusCircle>0. && "Radians must be positive");
-
Path p = HelixPath().setHeight(mHeight).setNumRound(mNumRound).setNumSegPath(mNumSegPath).setRadius(mRadiusHelix).realizePath();
Shape s = CircleShape().setRadius(mRadiusCircle).setNumSeg(mNumSegCircle).realizeShape();
diff -r 58d50844286b library/src/ProceduralTextureGenerator.cpp
--- a/library/src/ProceduralTextureGenerator.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/library/src/ProceduralTextureGenerator.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -49,7 +49,8 @@
TextureBuffer::TextureBuffer(TextureBufferPtr tocopy)
{
- assert(tocopy != NULL);
+ if(tocopy == NULL)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Pointer to source image must not be NULL!", "Procedural::TextureBuffer::TextureBuffer(Procedural::TextureBufferPtr)");
mWidth = tocopy->getWidth();
mHeight = tocopy->getHeight();
@@ -60,7 +61,8 @@
TextureBuffer::TextureBuffer(Ogre::uint width_height)
: mWidth(width_height), mHeight(width_height)
{
- assert(width_height > 7);
+ if(width_height < 8)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Minimum edge size is 8!", "Procedural::TextureBuffer::TextureBuffer(Procedural::TextureBufferPtr)");
mPixels = new Ogre::uchar[mWidth * mHeight * 4];
memset(mPixels, 0, mWidth * mHeight * 4 * sizeof(Ogre::uchar));
for (size_t y = 0; y < mHeight; y++)
@@ -104,41 +106,65 @@
void TextureBuffer::setRed(size_t x, size_t y, Ogre::uchar red)
{
+ if(x >= mWidth || y >= mHeight)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Pixel location is out of bounds!", "Procedural::TextureBuffer::setRed(size_t, size_t, Ogre::uchar)");
+
mPixels[y * mWidth * 4 + x * 4 + PROCEDURAL_RED] = red;
}
void TextureBuffer::setGreen(size_t x, size_t y, Ogre::uchar green)
{
+ if(x >= mWidth || y >= mHeight)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Pixel location is out of bounds!", "Procedural::TextureBuffer::setGreen(size_t, size_t, Ogre::uchar)");
+
mPixels[y * mWidth * 4 + x * 4 + PROCEDURAL_GREEN] = green;
}
void TextureBuffer::setBlue(size_t x, size_t y, Ogre::uchar blue)
{
+ if(x >= mWidth || y >= mHeight)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Pixel location is out of bounds!", "Procedural::TextureBuffer::setBlue(size_t, size_t, Ogre::uchar)");
+
mPixels[y * mWidth * 4 + x * 4 + PROCEDURAL_BLUE] = blue;
}
void TextureBuffer::setAlpha(size_t x, size_t y, Ogre::uchar alpha)
{
+ if(x >= mWidth || y >= mHeight)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Pixel location is out of bounds!", "Procedural::TextureBuffer::setAlpha(size_t, size_t, Ogre::uchar)");
+
mPixels[y * mWidth * 4 + x * 4 + PROCEDURAL_ALPHA] = alpha;
}
void TextureBuffer::setRed(size_t x, size_t y, Ogre::Real red)
{
+ if(x >= mWidth || y >= mHeight)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Pixel location is out of bounds!", "Procedural::TextureBuffer::setRed(size_t, size_t, Ogre::Real)");
+
mPixels[y * mWidth * 4 + x * 4 + PROCEDURAL_RED] = (Ogre::uchar)(std::min(std::max(red * 255.0f, 0.0f), 255.0f));
}
void TextureBuffer::setGreen(size_t x, size_t y, Ogre::Real green)
{
+ if(x >= mWidth || y >= mHeight)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Pixel location is out of bounds!", "Procedural::TextureBuffer::setGreen(size_t, size_t, Ogre::Real)");
+
mPixels[y * mWidth * 4 + x * 4 + PROCEDURAL_GREEN] = (Ogre::uchar)(std::min(std::max(green * 255.0f, 0.0f), 255.0f));
}
void TextureBuffer::setBlue(size_t x, size_t y, Ogre::Real blue)
{
+ if(x >= mWidth || y >= mHeight)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Pixel location is out of bounds!", "Procedural::TextureBuffer::setBlue(size_t, size_t, Ogre::Real)");
+
mPixels[y * mWidth * 4 + x * 4 + PROCEDURAL_BLUE] = (Ogre::uchar)(std::min(std::max(blue * 255.0f, 0.0f), 255.0f));
}
void TextureBuffer::setAlpha(size_t x, size_t y, Ogre::Real alpha)
{
+ if(x >= mWidth || y >= mHeight)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Pixel location is out of bounds!", "Procedural::TextureBuffer::setAlpha(size_t, size_t, Ogre::Real)");
+
mPixels[y * mWidth * 4 + x * 4 + PROCEDURAL_ALPHA] = (Ogre::uchar)(std::min(std::max(alpha * 255.0f, 0.0f), 255.0f));
}
@@ -158,46 +184,73 @@
Ogre::ColourValue TextureBuffer::getPixel(size_t x, size_t y)
{
+ if(x >= mWidth || y >= mHeight)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Pixel location is out of bounds!", "Procedural::TextureBuffer::getPixel(size_t, size_t)");
+
return Ogre::ColourValue(getPixelRedReal(x, y), getPixelGreenReal(x, y), getPixelBlueReal(x, y), getPixelAlphaReal(x, y));
}
Ogre::uchar TextureBuffer::getPixelRedByte(size_t x, size_t y)
{
+ if(x >= mWidth || y >= mHeight)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Pixel location is out of bounds!", "Procedural::TextureBuffer::getPixelRedByte(size_t, size_t)");
+
return mPixels[y * mWidth * 4 + x * 4 + PROCEDURAL_RED];
}
Ogre::uchar TextureBuffer::getPixelGreenByte(size_t x, size_t y)
{
+ if(x >= mWidth || y >= mHeight)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Pixel location is out of bounds!", "Procedural::TextureBuffer::getPixelGreenByte(size_t, size_t)");
+
return mPixels[y * mWidth * 4 + x * 4 + PROCEDURAL_GREEN];
}
Ogre::uchar TextureBuffer::getPixelBlueByte(size_t x, size_t y)
{
+ if(x >= mWidth || y >= mHeight)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Pixel location is out of bounds!", "Procedural::TextureBuffer::getPixelBlueByte(size_t, size_t)");
+
return mPixels[y * mWidth * 4 + x * 4 + PROCEDURAL_BLUE];
}
Ogre::uchar TextureBuffer::getPixelAlphaByte(size_t x, size_t y)
{
+ if(x >= mWidth || y >= mHeight)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Pixel location is out of bounds!", "Procedural::TextureBuffer::getPixelAlphaByte(size_t, size_t)");
+
return mPixels[y * mWidth * 4 + x * 4 + PROCEDURAL_ALPHA];
}
Ogre::Real TextureBuffer::getPixelRedReal(size_t x, size_t y)
{
+ if(x >= mWidth || y >= mHeight)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Pixel location is out of bounds!", "Procedural::TextureBuffer::getPixelRedReal(size_t, size_t)");
+
return ((Ogre::Real)mPixels[y * mWidth * 4 + x * 4 + PROCEDURAL_RED]) / 255.0f;
}
Ogre::Real TextureBuffer::getPixelGreenReal(size_t x, size_t y)
{
+ if(x >= mWidth || y >= mHeight)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Pixel location is out of bounds!", "Procedural::TextureBuffer::getPixelGreenReal(size_t, size_t)");
+
return ((Ogre::Real)mPixels[y * mWidth * 4 + x * 4 + PROCEDURAL_GREEN]) / 255.0f;
}
Ogre::Real TextureBuffer::getPixelBlueReal(size_t x, size_t y)
{
+ if(x >= mWidth || y >= mHeight)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Pixel location is out of bounds!", "Procedural::TextureBuffer::getPixelBlueReal(size_t, size_t)");
+
return ((Ogre::Real)mPixels[y * mWidth * 4 + x * 4 + PROCEDURAL_BLUE]) / 255.0f;
}
Ogre::Real TextureBuffer::getPixelAlphaReal(size_t x, size_t y)
{
+ if(x >= mWidth || y >= mHeight)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Pixel location is out of bounds!", "Procedural::TextureBuffer::getPixelAlphaReal(size_t, size_t)");
+
return ((Ogre::Real)mPixels[y * mWidth * 4 + x * 4 + PROCEDURAL_ALPHA]) / 255.0f;
}
@@ -245,7 +298,8 @@
TextureProcessing::TextureProcessing(TextureBufferPtr pBuffer, Ogre::String name)
{
- assert(pBuffer != NULL);
+ if(pBuffer == NULL)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Texture buffer is not set!", "Procedural::TextureProcessing::TextureProcessing(TextureBufferPtr, Ogre::String)");
mBuffer = pBuffer;
mName = name;
#if OGRE_DEBUG_MODE
diff -r 58d50844286b library/src/ProceduralTorusGenerator.cpp
--- a/library/src/ProceduralTorusGenerator.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/library/src/ProceduralTorusGenerator.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -35,9 +35,6 @@
{
void TorusGenerator::addToTriangleBuffer(TriangleBuffer& buffer) const
{
- assert(mNumSegSection>0 && mNumSegCircle>0 && "Num seg must be positive");
- assert(mRadius>0. && mSectionRadius>0. && "Radius must be positive");
-
buffer.rebaseOffset();
buffer.estimateVertexCount((mNumSegCircle+1)*(mNumSegSection+1));
buffer.estimateIndexCount((mNumSegCircle)*(mNumSegSection+1)*6);
diff -r 58d50844286b library/src/ProceduralTorusKnotGenerator.cpp
--- a/library/src/ProceduralTorusKnotGenerator.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/library/src/ProceduralTorusKnotGenerator.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -35,10 +35,6 @@
{
void TorusKnotGenerator::addToTriangleBuffer(TriangleBuffer& buffer) const
{
- assert(mNumSegSection>0 && mNumSegCircle>0 && "Num seg and circle must be positive");
- assert(mRadius>0. && mSectionRadius>0. && "Radius and section radius must be positive");
- assert(mP>0 && mQ>0 && "p and q must be positive");
-
buffer.rebaseOffset();
buffer.estimateVertexCount((mNumSegCircle*mP+1)*(mNumSegSection+1));
buffer.estimateIndexCount((mNumSegCircle*mP)*(mNumSegSection+1)*6);
diff -r 58d50844286b library/src/ProceduralTriangulator.cpp
--- a/library/src/ProceduralTriangulator.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/library/src/ProceduralTriangulator.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -429,8 +429,8 @@
//-----------------------------------------------------------------------
void Triangulator::triangulate(std::vector& output, PointList& outputVertices) const
{
- assert((mShapeToTriangulate || mMultiShapeToTriangulate || mSegmentListToTriangulate) && "Either shape or multishape or segment list must be defined");
- //assert((((mShapeToTriangulate && mShapeToTriangulate->isClosed()) || (mMultiShapeToTriangulate&&mMultiShapeToTriangulate->isClosed()))||(!mRemoveOutside)) && "Input shape must be closed");
+ if(mShapeToTriangulate == NULL && mMultiShapeToTriangulate == NULL && mSegmentListToTriangulate == NULL)
+ OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "Either shape or multishape or segment list must be defined!", "Procedural::Triangulator::triangulate(std::vector&, PointList&)");
Ogre::Timer mTimer;
mTimer.reset();
diff -r 58d50844286b library/src/ProceduralTubeGenerator.cpp
--- a/library/src/ProceduralTubeGenerator.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/library/src/ProceduralTubeGenerator.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -34,10 +34,6 @@
namespace Procedural {
void TubeGenerator::addToTriangleBuffer(TriangleBuffer& buffer) const
{
- assert(mHeight>0. && mOuterRadius>0. && mInnerRadius>0. && "Height and radius must be positive");
- assert(mInnerRadius<=mOuterRadius && "Outer radius must be bigger than inner radius");
- assert(mNumSegBase>0 && mNumSegHeight>0 && "Num seg must be positive integers");
-
buffer.rebaseOffset();
buffer.estimateVertexCount((mNumSegHeight+1)*(mNumSegBase+1)*2+(mNumSegBase+1)*4);
buffer.estimateIndexCount(6*(mNumSegBase+1)*mNumSegHeight*2+6*mNumSegBase*2);
diff -r 58d50844286b samples/material/src/Material.cpp
--- a/samples/material/src/Material.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/samples/material/src/Material.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -46,11 +46,11 @@
Procedural::TextureBuffer distort(brickLines * pxPerBrick);
Procedural::Solid(&distort).setColour((Ogre::uchar)125, (Ogre::uchar)133, (Ogre::uchar)0, (Ogre::uchar)255).process();
Procedural::Rectangle rectDraw(&distort);
- for(size_t i = 1; i < brickLines; i++)
+ for(int i = 1; i < brickLines; i++)
{
Ogre::ColourValue rc = Ogre::ColourValue((i % 2 == 0) ? Ogre::Math::RangeRandom(0.4f, 0.6f) : Ogre::Math::RangeRandom(0.0f, 0.2f), 0.52f, 1.0f);
rc.a = 1.0f;
- rectDraw.setRectangle(0, i * pxPerBrick, brickLines * pxPerBrick, i * pxPerBrick + pxPerBrick).setColour(rc).process();
+ rectDraw.setRectangle((size_t)0, (size_t)(i * pxPerBrick), (size_t)(brickLines * pxPerBrick), (size_t)(i * pxPerBrick + pxPerBrick)).setColour(rc).process();
}
Procedural::Distort(&bricks).setParameterImage(&distort).setPower(50).process();
Procedural::Cloud(&distort).process();
diff -r 58d50844286b samples/svg/src/Svg.cpp
--- a/samples/svg/src/Svg.cpp Fri Nov 09 23:09:04 2012 +0100
+++ b/samples/svg/src/Svg.cpp Tue Nov 13 14:27:32 2012 +0100
@@ -41,7 +41,7 @@
Procedural::MultiShape out;
Procedural::SvgLoader svg;
svg.parseSvgFile(out, "test.svg", "Essential", 16);
- Procedural::Extruder().setMultiShapeToExtrude(&out).setExtrusionPath(&p).setScale(.05).realizeMesh("svg");
+ Procedural::Extruder().setMultiShapeToExtrude(&out).setExtrusionPath(&p).setScale(.05f).realizeMesh("svg");
putMesh2("svg");
}
//-------------------------------------------------------------------------------------