Commit 57485235 authored by hybrid's avatar hybrid

Added some vector operations which take just one scalar as argument.

Optimized isBetweenPoints for vector2d
Added some virtual qualifiers for better readability
Added some terrain interface methods which are not properly working, yet


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1513 dfc29bdd-3216-0410-991c-e03cc46cb475
parent a7d24e4b
...@@ -26,7 +26,7 @@ namespace scene ...@@ -26,7 +26,7 @@ namespace scene
} }
//! destructor //! destructor
~CDynamicMeshBuffer() virtual ~CDynamicMeshBuffer()
{ {
if (VertexBuffer) if (VertexBuffer)
VertexBuffer->drop(); VertexBuffer->drop();
......
...@@ -91,7 +91,7 @@ namespace scene ...@@ -91,7 +91,7 @@ namespace scene
setType(IndexType); setType(IndexType);
} }
~CIndexBuffer() virtual ~CIndexBuffer()
{ {
delete Indices; delete Indices;
} }
......
...@@ -18,7 +18,7 @@ namespace scene ...@@ -18,7 +18,7 @@ namespace scene
{ {
public: public:
//! Default constructor for empty meshbuffer //! Default constructor for empty meshbuffer
CMeshBuffer():ChangedID_Vertex(1),ChangedID_Index(1),MappingHint(EHM_NEVER) // everything's default constructed CMeshBuffer() : ChangedID_Vertex(1), ChangedID_Index(1), MappingHint(EHM_NEVER)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("SMeshBuffer"); setDebugName("SMeshBuffer");
......
...@@ -14,7 +14,6 @@ namespace scene ...@@ -14,7 +14,6 @@ namespace scene
class CVertexBuffer : public IVertexBuffer class CVertexBuffer : public IVertexBuffer
{ {
class IVertexList class IVertexList
{ {
public: public:
...@@ -75,7 +74,7 @@ namespace scene ...@@ -75,7 +74,7 @@ namespace scene
setType(vertexType); setType(vertexType);
} }
~CVertexBuffer() virtual ~CVertexBuffer()
{ {
delete Vertices; delete Vertices;
} }
......
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
namespace irr namespace irr
{ {
namespace io
{
class IReadFile;
} // end namespace io
namespace scene namespace scene
{ {
class IMesh; class IMesh;
...@@ -146,6 +150,15 @@ namespace scene ...@@ -146,6 +150,15 @@ namespace scene
first set. If this is another value than zero, it will scale first set. If this is another value than zero, it will scale
the second texture coordinate set by this value. */ the second texture coordinate set by this value. */
virtual void scaleTexture(f32 scale = 1.0f, f32 scale2 = 0.0f) = 0; virtual void scaleTexture(f32 scale = 1.0f, f32 scale2 = 0.0f) = 0;
//! Initializes the terrain data. Loads the vertices from the heightMapFile.
virtual bool loadHeightMap(io::IReadFile* file,
video::SColor vertexColor = video::SColor ( 255, 255, 255, 255 ), s32 smoothFactor = 0 ) =0;
//! Initializes the terrain data. Loads the vertices from the heightMapFile.
virtual bool loadHeightMapRAW(io::IReadFile* file, s32 bitsPerPixel = 16,
video::SColor vertexColor = video::SColor ( 255, 255, 255, 255 ), s32 smoothFactor = 0 ) =0;
}; };
} // end namespace scene } // end namespace scene
......
...@@ -18,9 +18,13 @@ template <class T> ...@@ -18,9 +18,13 @@ template <class T>
class vector2d class vector2d
{ {
public: public:
//! Default constructor (null vector)
vector2d() : X(0), Y(0) {} vector2d() : X(0), Y(0) {}
//! Constructor with two different values
vector2d(T nx, T ny) : X(nx), Y(ny) {} vector2d(T nx, T ny) : X(nx), Y(ny) {}
//! Constructor with the same value for both members
explicit vector2d(T n) : X(n), Y(n) {}
//! Copy constructor
vector2d(const vector2d<T>& other) : X(other.X), Y(other.Y) {} vector2d(const vector2d<T>& other) : X(other.X), Y(other.Y) {}
// operators // operators
...@@ -217,9 +221,16 @@ public: ...@@ -217,9 +221,16 @@ public:
\return True if this vector is between begin and end, false if not. */ \return True if this vector is between begin and end, false if not. */
bool isBetweenPoints(const vector2d<T>& begin, const vector2d<T>& end) const bool isBetweenPoints(const vector2d<T>& begin, const vector2d<T>& end) const
{ {
const T f = (end - begin).getLengthSQ(); if (begin.X != end.X)
return getDistanceFromSQ(begin) <= f && {
getDistanceFromSQ(end) <= f; return ((begin.X <= X && X <= end.X) ||
(begin.X >= X && X >= end.X));
}
else
{
return ((begin.Y <= Y && Y <= end.Y) ||
(begin.Y >= Y && Y >= end.Y));
}
} }
//! Get the interpolated vector //! Get the interpolated vector
......
...@@ -19,7 +19,11 @@ namespace core ...@@ -19,7 +19,11 @@ namespace core
public: public:
//! Default constructor (null vector). //! Default constructor (null vector).
vector3d() : X(0), Y(0), Z(0) {} vector3d() : X(0), Y(0), Z(0) {}
//! Constructor with three different values
vector3d(T nx, T ny, T nz) : X(nx), Y(ny), Z(nz) {} vector3d(T nx, T ny, T nz) : X(nx), Y(ny), Z(nz) {}
//! Constructor with the same value for all elements
explicit vector3d(T n) : X(n), Y(n), Z(n) {}
//! Copy constructor
vector3d(const vector3d<T>& other) : X(other.X), Y(other.Y), Z(other.Z) {} vector3d(const vector3d<T>& other) : X(other.X), Y(other.Y), Z(other.Z) {}
// operators // operators
...@@ -30,9 +34,13 @@ namespace core ...@@ -30,9 +34,13 @@ namespace core
vector3d<T> operator+(const vector3d<T>& other) const { return vector3d<T>(X + other.X, Y + other.Y, Z + other.Z); } vector3d<T> operator+(const vector3d<T>& other) const { return vector3d<T>(X + other.X, Y + other.Y, Z + other.Z); }
vector3d<T>& operator+=(const vector3d<T>& other) { X+=other.X; Y+=other.Y; Z+=other.Z; return *this; } vector3d<T>& operator+=(const vector3d<T>& other) { X+=other.X; Y+=other.Y; Z+=other.Z; return *this; }
vector3d<T> operator+(const T val) const { return vector3d<T>(X + val, Y + val, Z + val); }
vector3d<T>& operator+=(const T val) { X+=val; Y+=val; Z+=val; return *this; }
vector3d<T> operator-(const vector3d<T>& other) const { return vector3d<T>(X - other.X, Y - other.Y, Z - other.Z); } vector3d<T> operator-(const vector3d<T>& other) const { return vector3d<T>(X - other.X, Y - other.Y, Z - other.Z); }
vector3d<T>& operator-=(const vector3d<T>& other) { X-=other.X; Y-=other.Y; Z-=other.Z; return *this; } vector3d<T>& operator-=(const vector3d<T>& other) { X-=other.X; Y-=other.Y; Z-=other.Z; return *this; }
vector3d<T> operator-(const T val) const { return vector3d<T>(X - val, Y - val, Z - val); }
vector3d<T>& operator-=(const T val) { X-=val; Y-=val; Z-=val; return *this; }
vector3d<T> operator*(const vector3d<T>& other) const { return vector3d<T>(X * other.X, Y * other.Y, Z * other.Z); } vector3d<T> operator*(const vector3d<T>& other) const { return vector3d<T>(X * other.X, Y * other.Y, Z * other.Z); }
vector3d<T>& operator*=(const vector3d<T>& other) { X*=other.X; Y*=other.Y; Z*=other.Z; return *this; } vector3d<T>& operator*=(const vector3d<T>& other) { X*=other.X; Y*=other.Y; Z*=other.Z; return *this; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment