From 78e29455c5cb4acce769498a5a32be6a3c6085b4 Mon Sep 17 00:00:00 2001 From: "FWoltermann@gmail.com" Date: Thu, 8 Dec 2011 16:00:07 +0000 Subject: Fixing up faulty references to class "Point" to "IcePoint" --- Opcode/Ice/IceAABB.h | 56 ++++----- Opcode/Ice/IceBoundingSphere.h | 34 +++--- Opcode/Ice/IceHPoint.h | 12 +- Opcode/Ice/IceIndexedTriangle.h | 34 +++--- Opcode/Ice/IceLSS.h | 8 +- Opcode/Ice/IceMatrix3x3.h | 30 ++--- Opcode/Ice/IceMatrix4x4.h | 26 ++--- Opcode/Ice/IceOBB.h | 24 ++-- Opcode/Ice/IcePlane.cpp | 12 +- Opcode/Ice/IcePlane.h | 26 ++--- Opcode/Ice/IcePoint.cpp | 38 +++--- Opcode/Ice/IcePoint.h | 252 ++++++++++++++++++++-------------------- Opcode/Ice/IceRay.cpp | 6 +- Opcode/Ice/IceRay.h | 22 ++-- Opcode/Ice/IceSegment.cpp | 6 +- Opcode/Ice/IceSegment.h | 26 ++--- Opcode/Ice/IceTriangle.cpp | 66 +++++------ Opcode/Ice/IceTriangle.h | 12 +- Opcode/Ice/IceTrilist.h | 2 +- Opcode/OPC_AABBCollider.cpp | 20 ++-- Opcode/OPC_AABBCollider.h | 10 +- Opcode/OPC_AABBTree.cpp | 12 +- Opcode/OPC_BoxBoxOverlap.h | 6 +- Opcode/OPC_Common.h | 24 ++-- Opcode/OPC_HybridModel.cpp | 10 +- Opcode/OPC_LSSAABBOverlap.h | 32 ++--- Opcode/OPC_LSSCollider.cpp | 20 ++-- Opcode/OPC_LSSCollider.h | 10 +- Opcode/OPC_LSSTriOverlap.h | 32 ++--- Opcode/OPC_MeshInterface.cpp | 10 +- Opcode/OPC_MeshInterface.h | 28 ++--- Opcode/OPC_OBBCollider.cpp | 22 ++-- Opcode/OPC_OBBCollider.h | 16 +-- Opcode/OPC_OptimizedTree.cpp | 16 +-- Opcode/OPC_OptimizedTree.h | 8 +- Opcode/OPC_Picking.cpp | 6 +- Opcode/OPC_Picking.h | 2 +- Opcode/OPC_PlanesAABBOverlap.h | 4 +- Opcode/OPC_PlanesCollider.cpp | 16 +-- Opcode/OPC_PlanesCollider.h | 2 +- Opcode/OPC_RayAABBOverlap.h | 6 +- Opcode/OPC_RayCollider.cpp | 32 ++--- Opcode/OPC_RayCollider.h | 18 +-- Opcode/OPC_RayTriOverlap.h | 20 ++-- Opcode/OPC_SphereAABBOverlap.h | 6 +- Opcode/OPC_SphereCollider.cpp | 22 ++-- Opcode/OPC_SphereCollider.h | 10 +- Opcode/OPC_SphereTriOverlap.h | 12 +- Opcode/OPC_TreeBuilders.cpp | 8 +- Opcode/OPC_TreeBuilders.h | 2 +- Opcode/OPC_TreeCollider.cpp | 50 ++++---- Opcode/OPC_TreeCollider.h | 24 ++-- Opcode/OPC_TriBoxOverlap.h | 42 +++---- Opcode/OPC_TriTriOverlap.h | 14 +-- Opcode/OPC_VolumeCollider.h | 4 +- Opcode/Opcode.vcxproj | 1 + 56 files changed, 635 insertions(+), 634 deletions(-) diff --git a/Opcode/Ice/IceAABB.h b/Opcode/Ice/IceAABB.h index 573629e..2c2ce79 100644 --- a/Opcode/Ice/IceAABB.h +++ b/Opcode/Ice/IceAABB.h @@ -20,15 +20,15 @@ AABB& Add(const AABB& aabb); \ float MakeCube(AABB& cube) const; \ void MakeSphere(Sphere& sphere) const; \ - const sbyte* ComputeOutline(const Point& local_eye, sdword& num) const; \ - float ComputeBoxArea(const Point& eye, const Matrix4x4& mat, float width, float height, sdword& num) const; \ + const sbyte* ComputeOutline(const IcePoint& local_eye, sdword& num) const; \ + float ComputeBoxArea(const IcePoint& eye, const Matrix4x4& mat, float width, float height, sdword& num) const; \ bool IsInside(const AABB& box) const; \ bool ComputePlanes(Plane* planes) const; \ - bool ComputePoints(Point* pts) const; \ - const Point* GetVertexNormals() const; \ + bool ComputePoints(IcePoint* pts) const; \ + const IcePoint* GetVertexNormals() const; \ const udword* GetEdges() const; \ - const Point* GetEdgeNormals() const; \ - inline_ BOOL ContainsPoint(const Point& p) const \ + const IcePoint* GetEdgeNormals() const; \ + inline_ BOOL ContainsPoint(const IcePoint& p) const \ { \ if(p.x > GetMax(0) || p.x < GetMin(0)) return FALSE; \ if(p.y > GetMax(1) || p.y < GetMin(1)) return FALSE; \ @@ -282,7 +282,7 @@ * \param max [in] the max point */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SetMinMax(const Point& min, const Point& max) { mCenter = (max + min)*0.5f; mExtents = (max - min)*0.5f; } + void SetMinMax(const IcePoint& min, const IcePoint& max) { mCenter = (max + min)*0.5f; mExtents = (max - min)*0.5f; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** @@ -291,7 +291,7 @@ * \param e [in] the extents vector */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SetCenterExtents(const Point& c, const Point& e) { mCenter = c; mExtents = e; } + void SetCenterExtents(const IcePoint& c, const IcePoint& e) { mCenter = c; mExtents = e; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** @@ -305,7 +305,7 @@ * Setups a point AABB. */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void SetPoint(const Point& pt) { mCenter = pt; mExtents.Zero(); } + void SetPoint(const IcePoint& pt) { mCenter = pt; mExtents.Zero(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** @@ -321,10 +321,10 @@ * \param p [in] the next point */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void Extend(const Point& p) + void Extend(const IcePoint& p) { - Point Max = mCenter + mExtents; - Point Min = mCenter - mExtents; + IcePoint Max = mCenter + mExtents; + IcePoint Min = mCenter - mExtents; if(p.x > Max.x) Max.x = p.x; if(p.x < Min.x) Min.x = p.x; @@ -340,9 +340,9 @@ // Data access //! Get min point of the box - inline_ void GetMin(Point& min) const { min = mCenter - mExtents; } + inline_ void GetMin(IcePoint& min) const { min = mCenter - mExtents; } //! Get max point of the box - inline_ void GetMax(Point& max) const { max = mCenter + mExtents; } + inline_ void GetMax(IcePoint& max) const { max = mCenter + mExtents; } //! Get component of the box's min point along a given axis inline_ float GetMin(udword axis) const { return mCenter[axis] - mExtents[axis]; } @@ -350,9 +350,9 @@ inline_ float GetMax(udword axis) const { return mCenter[axis] + mExtents[axis]; } //! Get box center - inline_ void GetCenter(Point& center) const { center = mCenter; } + inline_ void GetCenter(IcePoint& center) const { center = mCenter; } //! Get box extents - inline_ void GetExtents(Point& extents) const { extents = mExtents; } + inline_ void GetExtents(IcePoint& extents) const { extents = mExtents; } //! Get component of the box's center along a given axis inline_ float GetCenter(udword axis) const { return mCenter[axis]; } @@ -360,7 +360,7 @@ inline_ float GetExtents(udword axis) const { return mExtents[axis]; } //! Get box diagonal - inline_ void GetDiagonal(Point& diagonal) const { diagonal = mExtents * 2.0f; } + inline_ void GetDiagonal(IcePoint& diagonal) const { diagonal = mExtents * 2.0f; } inline_ float GetWidth() const { return mExtents.x * 2.0f; } inline_ float GetHeight() const { return mExtents.y * 2.0f; } inline_ float GetDepth() const { return mExtents.z * 2.0f; } @@ -392,7 +392,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// inline_ bool GomezIntersect(const AABB& a) { - Point T = mCenter - a.mCenter; // Vector from A to B + IcePoint T = mCenter - a.mCenter; // Vector from A to B return ((fabsf(T.x) <= (a.mExtents.x + mExtents.x)) && (fabsf(T.y) <= (a.mExtents.y + mExtents.y)) && (fabsf(T.z) <= (a.mExtents.z + mExtents.z))); @@ -427,13 +427,13 @@ aabb.mCenter = mCenter * mtx; // Compute new extents. FPU code & CPU code have been interleaved for improved performance. - Point Ex(mtx.m[0][0] * mExtents.x, mtx.m[0][1] * mExtents.x, mtx.m[0][2] * mExtents.x); + IcePoint Ex(mtx.m[0][0] * mExtents.x, mtx.m[0][1] * mExtents.x, mtx.m[0][2] * mExtents.x); IR(Ex.x)&=0x7fffffff; IR(Ex.y)&=0x7fffffff; IR(Ex.z)&=0x7fffffff; - Point Ey(mtx.m[1][0] * mExtents.y, mtx.m[1][1] * mExtents.y, mtx.m[1][2] * mExtents.y); + IcePoint Ey(mtx.m[1][0] * mExtents.y, mtx.m[1][1] * mExtents.y, mtx.m[1][2] * mExtents.y); IR(Ey.x)&=0x7fffffff; IR(Ey.y)&=0x7fffffff; IR(Ey.z)&=0x7fffffff; - Point Ez(mtx.m[2][0] * mExtents.z, mtx.m[2][1] * mExtents.z, mtx.m[2][2] * mExtents.z); + IcePoint Ez(mtx.m[2][0] * mExtents.z, mtx.m[2][1] * mExtents.z, mtx.m[2][2] * mExtents.z); IR(Ez.x)&=0x7fffffff; IR(Ez.y)&=0x7fffffff; IR(Ez.z)&=0x7fffffff; aabb.mExtents.x = Ex.x + Ey.x + Ez.x; @@ -463,19 +463,19 @@ inline_ AABB& operator/=(float s) { mExtents/=s; return *this; } //! Operator for AABB += Point. Translates the box. - inline_ AABB& operator+=(const Point& trans) + inline_ AABB& operator+=(const IcePoint& trans) { mCenter+=trans; return *this; } private: - Point mCenter; //!< AABB Center - Point mExtents; //!< x, y and z extents + IcePoint mCenter; //!< AABB Center + IcePoint mExtents; //!< x, y and z extents }; #endif - inline_ void ComputeMinMax(const Point& p, Point& min, Point& max) + inline_ void ComputeMinMax(const IcePoint& p, IcePoint& min, IcePoint& max) { if(p.x > max.x) max.x = p.x; if(p.x < min.x) min.x = p.x; @@ -487,12 +487,12 @@ if(p.z < min.z) min.z = p.z; } - inline_ void ComputeAABB(AABB& aabb, const Point* list, udword nb_pts) + inline_ void ComputeAABB(AABB& aabb, const IcePoint* list, udword nb_pts) { if(list) { - Point Maxi(MIN_FLOAT, MIN_FLOAT, MIN_FLOAT); - Point Mini(MAX_FLOAT, MAX_FLOAT, MAX_FLOAT); + IcePoint Maxi(MIN_FLOAT, MIN_FLOAT, MIN_FLOAT); + IcePoint Mini(MAX_FLOAT, MAX_FLOAT, MAX_FLOAT); while(nb_pts--) { // _prefetch(list+1); // off by one ? diff --git a/Opcode/Ice/IceBoundingSphere.h b/Opcode/Ice/IceBoundingSphere.h index c66524c..5cbc5a4 100644 --- a/Opcode/Ice/IceBoundingSphere.h +++ b/Opcode/Ice/IceBoundingSphere.h @@ -27,36 +27,36 @@ //! Constructor inline_ Sphere() {} //! Constructor - inline_ Sphere(const Point& center, float radius) : mCenter(center), mRadius(radius) {} + inline_ Sphere(const IcePoint& center, float radius) : mCenter(center), mRadius(radius) {} //! Constructor - Sphere(udword nb_verts, const Point* verts); + Sphere(udword nb_verts, const IcePoint* verts); //! Copy constructor inline_ Sphere(const Sphere& sphere) : mCenter(sphere.mCenter), mRadius(sphere.mRadius) {} //! Destructor inline_ ~Sphere() {} - BSphereMethod Compute(udword nb_verts, const Point* verts); - bool FastCompute(udword nb_verts, const Point* verts); + BSphereMethod Compute(udword nb_verts, const IcePoint* verts); + bool FastCompute(udword nb_verts, const IcePoint* verts); // Access methods - inline_ const Point& GetCenter() const { return mCenter; } + inline_ const IcePoint& GetCenter() const { return mCenter; } inline_ float GetRadius() const { return mRadius; } - inline_ const Point& Center() const { return mCenter; } + inline_ const IcePoint& Center() const { return mCenter; } inline_ float Radius() const { return mRadius; } - inline_ Sphere& Set(const Point& center, float radius) { mCenter = center; mRadius = radius; return *this; } - inline_ Sphere& SetCenter(const Point& center) { mCenter = center; return *this; } + inline_ Sphere& Set(const IcePoint& center, float radius) { mCenter = center; mRadius = radius; return *this; } + inline_ Sphere& SetCenter(const IcePoint& center) { mCenter = center; return *this; } inline_ Sphere& SetRadius(float radius) { mRadius = radius; return *this; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** - * Tests if a point is contained within the sphere. - * \param p [in] the point to test + * Tests if a IcePoint is contained within the sphere. + * \param p [in] the IcePoint to test * \return true if inside the sphere */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - inline_ bool Contains(const Point& p) const + inline_ bool Contains(const IcePoint& p) const { return mCenter.SquareDistance(p) <= mRadius*mRadius; } @@ -90,13 +90,13 @@ // Sounds ok but maybe there's a better way? float R2 = mRadius * mRadius; #ifdef USE_MIN_MAX - const Point& Max = ((ShadowAABB&)&aabb).mMax; - const Point& Min = ((ShadowAABB&)&aabb).mMin; + const IcePoint& Max = ((ShadowAABB&)&aabb).mMax; + const IcePoint& Min = ((ShadowAABB&)&aabb).mMin; #else - Point Max; aabb.GetMax(Max); - Point Min; aabb.GetMin(Min); + IcePoint Max; aabb.GetMax(Max); + IcePoint Min; aabb.GetMin(Min); #endif - Point p; + IcePoint p; p.x=Max.x; p.y=Max.y; p.z=Max.z; if(mCenter.SquareDistance(p)>=R2) return FALSE; p.x=Min.x; if(mCenter.SquareDistance(p)>=R2) return FALSE; p.x=Max.x; p.y=Min.y; if(mCenter.SquareDistance(p)>=R2) return FALSE; @@ -135,7 +135,7 @@ return TRUE; } public: - Point mCenter; //!< Sphere center + IcePoint mCenter; //!< Sphere center float mRadius; //!< Sphere radius }; diff --git a/Opcode/Ice/IceHPoint.h b/Opcode/Ice/IceHPoint.h index 3065d8e..9251691 100644 --- a/Opcode/Ice/IceHPoint.h +++ b/Opcode/Ice/IceHPoint.h @@ -12,18 +12,18 @@ #ifndef __ICEHPOINT_H__ #define __ICEHPOINT_H__ - class ICEMATHS_API HPoint : public Point + class ICEMATHS_API HPoint : public IcePoint { public: //! Empty constructor inline_ HPoint() {} //! Constructor from floats - inline_ HPoint(float _x, float _y, float _z, float _w=0.0f) : Point(_x, _y, _z), w(_w) {} + inline_ HPoint(float _x, float _y, float _z, float _w=0.0f) : IcePoint(_x, _y, _z), w(_w) {} //! Constructor from array - inline_ HPoint(const float f[4]) : Point(f), w(f[3]) {} + inline_ HPoint(const float f[4]) : IcePoint(f), w(f[3]) {} //! Constructor from a Point - inline_ HPoint(const Point& p, float _w=0.0f) : Point(p), w(_w) {} + inline_ HPoint(const IcePoint& p, float _w=0.0f) : IcePoint(p), w(_w) {} //! Destructor inline_ ~HPoint() {} @@ -129,7 +129,7 @@ // Arithmetic operators //! Operator for Point Mul = HPoint * Matrix3x3; - Point operator*(const Matrix3x3& mat) const; + IcePoint operator*(const Matrix3x3& mat) const; //! Operator for HPoint Mul = HPoint * Matrix4x4; HPoint operator*(const Matrix4x4& mat) const; @@ -147,7 +147,7 @@ // Cast operators //! Cast a HPoint to a Point. w is discarded. - inline_ operator Point() const { return Point(x, y, z); } + inline_ operator HPoint() const { return IcePoint(x, y, z); } public: float w; diff --git a/Opcode/Ice/IceIndexedTriangle.h b/Opcode/Ice/IceIndexedTriangle.h index 0c497ee..5dc39ea 100644 --- a/Opcode/Ice/IceIndexedTriangle.h +++ b/Opcode/Ice/IceIndexedTriangle.h @@ -37,17 +37,17 @@ // Methods void Flip(); - float Area(const Point* verts) const; - float Perimeter(const Point* verts) const; - float Compacity(const Point* verts) const; - void Normal(const Point* verts, Point& normal) const; - void DenormalizedNormal(const Point* verts, Point& normal) const; - void Center(const Point* verts, Point& center) const; - void CenteredNormal(const Point* verts, Point& normal) const; - void RandomPoint(const Point* verts, Point& random) const; - bool IsVisible(const Point* verts, const Point& source) const; - bool BackfaceCulling(const Point* verts, const Point& source) const; - float ComputeOcclusionPotential(const Point* verts, const Point& view) const; + float Area(const IcePoint* verts) const; + float Perimeter(const IcePoint* verts) const; + float Compacity(const IcePoint* verts) const; + void Normal(const IcePoint* verts, IcePoint& normal) const; + void DenormalizedNormal(const IcePoint* verts, IcePoint& normal) const; + void Center(const IcePoint* verts, IcePoint& center) const; + void CenteredNormal(const IcePoint* verts, IcePoint& normal) const; + void RandomPoint(const IcePoint* verts, IcePoint& random) const; + bool IsVisible(const IcePoint* verts, const IcePoint& source) const; + bool BackfaceCulling(const IcePoint* verts, const IcePoint& source) const; + float ComputeOcclusionPotential(const IcePoint* verts, const IcePoint& view) const; bool ReplaceVertex(udword oldref, udword newref); bool IsDegenerate() const; bool HasVertex(udword ref) const; @@ -56,13 +56,13 @@ udword OppositeVertex(udword vref0, udword vref1) const; inline_ udword OppositeVertex(ubyte edgenb) const { return mVRef[2-edgenb]; } void GetVRefs(ubyte edgenb, udword& vref0, udword& vref1, udword& vref2) const; - float MinEdgeLength(const Point* verts) const; - float MaxEdgeLength(const Point* verts) const; - void ComputePoint(const Point* verts, float u, float v, Point& pt, udword* nearvtx=null) const; - float Angle(const IndexedTriangle& tri, const Point* verts) const; - inline_ Plane PlaneEquation(const Point* verts) const { return Plane(verts[mVRef[0]], verts[mVRef[1]], verts[mVRef[2]]); } + float MinEdgeLength(const IcePoint* verts) const; + float MaxEdgeLength(const IcePoint* verts) const; + void ComputePoint(const IcePoint* verts, float u, float v, IcePoint& pt, udword* nearvtx=null) const; + float Angle(const IndexedTriangle& tri, const IcePoint* verts) const; + inline_ Plane PlaneEquation(const IcePoint* verts) const { return Plane(verts[mVRef[0]], verts[mVRef[1]], verts[mVRef[2]]); } bool Equal(const IndexedTriangle& tri) const; - CubeIndex ComputeCubeIndex(const Point* verts) const; + CubeIndex ComputeCubeIndex(const IcePoint* verts) const; }; #endif // __ICEINDEXEDTRIANGLE_H__ diff --git a/Opcode/Ice/IceLSS.h b/Opcode/Ice/IceLSS.h index c16c29f..8c2c154 100644 --- a/Opcode/Ice/IceLSS.h +++ b/Opcode/Ice/IceLSS.h @@ -32,13 +32,13 @@ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** - * Tests if a point is contained within the LSS. - * \param pt [in] the point to test + * Tests if a IcePoint is contained within the LSS. + * \param pt [in] the IcePoint to test * \return true if inside the LSS - * \warning point and LSS must be in same space + * \warning IcePoint and LSS must be in same space */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - inline_ bool Contains(const Point& pt) const { return SquareDistance(pt) <= mRadius*mRadius; } + inline_ bool Contains(const IcePoint& pt) const { return SquareDistance(pt) <= mRadius*mRadius; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** diff --git a/Opcode/Ice/IceMatrix3x3.h b/Opcode/Ice/IceMatrix3x3.h index 2266fc5..5b8f141 100644 --- a/Opcode/Ice/IceMatrix3x3.h +++ b/Opcode/Ice/IceMatrix3x3.h @@ -43,13 +43,13 @@ } //! Sets the scale from a Point. The point is put on the diagonal. - inline_ void SetScale(const Point& p) { m[0][0] = p.x; m[1][1] = p.y; m[2][2] = p.z; } + inline_ void SetScale(const IcePoint& p) { m[0][0] = p.x; m[1][1] = p.y; m[2][2] = p.z; } //! Sets the scale from floats. Values are put on the diagonal. inline_ void SetScale(float sx, float sy, float sz) { m[0][0] = sx; m[1][1] = sy; m[2][2] = sz; } //! Scales from a Point. Each row is multiplied by a component. - inline_ void Scale(const Point& p) + inline_ void Scale(const IcePoint& p) { m[0][0] *= p.x; m[0][1] *= p.x; m[0][2] *= p.x; m[1][0] *= p.y; m[1][1] *= p.y; m[1][2] *= p.y; @@ -69,17 +69,17 @@ // Row-column access //! Returns a row. - inline_ void GetRow(const udword r, Point& p) const { p.x = m[r][0]; p.y = m[r][1]; p.z = m[r][2]; } + inline_ void GetRow(const udword r, IcePoint& p) const { p.x = m[r][0]; p.y = m[r][1]; p.z = m[r][2]; } //! Returns a row. - inline_ const Point& GetRow(const udword r) const { return *(const Point*)&m[r][0]; } + inline_ const IcePoint& GetRow(const udword r) const { return *(const IcePoint*)&m[r][0]; } //! Returns a row. - inline_ Point& GetRow(const udword r) { return *(Point*)&m[r][0]; } + inline_ IcePoint& GetRow(const udword r) { return *(IcePoint*)&m[r][0]; } //! Sets a row. - inline_ void SetRow(const udword r, const Point& p) { m[r][0] = p.x; m[r][1] = p.y; m[r][2] = p.z; } + inline_ void SetRow(const udword r, const IcePoint& p) { m[r][0] = p.x; m[r][1] = p.y; m[r][2] = p.z; } //! Returns a column. - inline_ void GetCol(const udword c, Point& p) const { p.x = m[0][c]; p.y = m[1][c]; p.z = m[2][c]; } + inline_ void GetCol(const udword c, IcePoint& p) const { p.x = m[0][c]; p.y = m[1][c]; p.z = m[2][c]; } //! Sets a column. - inline_ void SetCol(const udword c, const Point& p) { m[0][c] = p.x; m[1][c] = p.y; m[2][c] = p.z; } + inline_ void SetCol(const udword c, const IcePoint& p) { m[0][c] = p.x; m[1][c] = p.y; m[2][c] = p.z; } //! Computes the trace. The trace is the sum of the 3 diagonal components. inline_ float Trace() const { return m[0][0] + m[1][1] + m[2][2]; } @@ -124,7 +124,7 @@ //! [ -a.y a.x 0.0 ] //! This is also called a "cross matrix" since for any vectors A and B, //! A^B = Skew(A) * B = - B * Skew(A); - inline_ void SkewSymmetric(const Point& a) + inline_ void SkewSymmetric(const IcePoint& a) { m[0][0] = 0.0f; m[0][1] = -a.z; @@ -258,7 +258,7 @@ } //! Makes a rotation matrix mapping vector "from" to vector "to". - Matrix3x3& FromTo(const Point& from, const Point& to); + Matrix3x3& FromTo(const IcePoint& from, const IcePoint& to); //! Set a rotation matrix around the X axis. //! 1 0 0 @@ -281,7 +281,7 @@ void RotYX(float y, float x); //! Make a rotation matrix about an arbitrary axis - Matrix3x3& Rot(float angle, const Point& axis); + Matrix3x3& Rot(float angle, const IcePoint& axis); //! Transpose the matrix. void Transpose() @@ -380,7 +380,7 @@ void FromQuatL2(const Quat &q, float l2); } //! Operator for Point Mul = Matrix3x3 * Point; - inline_ Point operator*(const Point& v) const { return Point(GetRow(0)|v, GetRow(1)|v, GetRow(2)|v); } + inline_ IcePoint operator*(const IcePoint& v) const { return IcePoint(GetRow(0)|v, GetRow(1)|v, GetRow(2)|v); } //! Operator for Matrix3x3 Mul = Matrix3x3 * float; inline_ Matrix3x3 operator*(float s) const @@ -440,7 +440,7 @@ void FromQuatL2(const Quat &q, float l2); //! Operator for Matrix3x3 *= Matrix3x3 inline_ Matrix3x3& operator*=(const Matrix3x3& mat) { - Point TempRow; + IcePoint TempRow; GetRow(0, TempRow); m[0][0] = TempRow.x*mat.m[0][0] + TempRow.y*mat.m[1][0] + TempRow.z*mat.m[2][0]; @@ -484,8 +484,8 @@ void FromQuatL2(const Quat &q, float l2); //! Cast a Matrix3x3 to a Quat. operator Quat() const; - inline_ const Point& operator[](int row) const { return *(const Point*)&m[row][0]; } - inline_ Point& operator[](int row) { return *(Point*)&m[row][0]; } + inline_ const IcePoint& operator[](int row) const { return *(const IcePoint*)&m[row][0]; } + inline_ IcePoint& operator[](int row) { return *(IcePoint*)&m[row][0]; } public: diff --git a/Opcode/Ice/IceMatrix4x4.h b/Opcode/Ice/IceMatrix4x4.h index d61a461..0b08a4a 100644 --- a/Opcode/Ice/IceMatrix4x4.h +++ b/Opcode/Ice/IceMatrix4x4.h @@ -72,7 +72,7 @@ //! Returns a row. inline_ void GetRow(const udword r, HPoint& p) const { p.x=m[r][0]; p.y=m[r][1]; p.z=m[r][2]; p.w=m[r][3]; } //! Returns a row. - inline_ void GetRow(const udword r, Point& p) const { p.x=m[r][0]; p.y=m[r][1]; p.z=m[r][2]; } + inline_ void GetRow(const udword r, IcePoint& p) const { p.x=m[r][0]; p.y=m[r][1]; p.z=m[r][2]; } //! Returns a row. inline_ const HPoint& GetRow(const udword r) const { return *(const HPoint*)&m[r][0]; } //! Returns a row. @@ -80,23 +80,23 @@ //! Sets a row. inline_ void SetRow(const udword r, const HPoint& p) { m[r][0]=p.x; m[r][1]=p.y; m[r][2]=p.z; m[r][3]=p.w; } //! Sets a row. - inline_ void SetRow(const udword r, const Point& p) { m[r][0]=p.x; m[r][1]=p.y; m[r][2]=p.z; m[r][3]= (r!=3) ? 0.0f : 1.0f; } + inline_ void SetRow(const udword r, const IcePoint& p) { m[r][0]=p.x; m[r][1]=p.y; m[r][2]=p.z; m[r][3]= (r!=3) ? 0.0f : 1.0f; } //! Returns a column. inline_ void GetCol(const udword c, HPoint& p) const { p.x=m[0][c]; p.y=m[1][c]; p.z=m[2][c]; p.w=m[3][c]; } //! Returns a column. - inline_ void GetCol(const udword c, Point& p) const { p.x=m[0][c]; p.y=m[1][c]; p.z=m[2][c]; } + inline_ void GetCol(const udword c, IcePoint& p) const { p.x=m[0][c]; p.y=m[1][c]; p.z=m[2][c]; } //! Sets a column. inline_ void SetCol(const udword c, const HPoint& p) { m[0][c]=p.x; m[1][c]=p.y; m[2][c]=p.z; m[3][c]=p.w; } //! Sets a column. - inline_ void SetCol(const udword c, const Point& p) { m[0][c]=p.x; m[1][c]=p.y; m[2][c]=p.z; m[3][c]= (c!=3) ? 0.0f : 1.0f; } + inline_ void SetCol(const udword c, const IcePoint& p) { m[0][c]=p.x; m[1][c]=p.y; m[2][c]=p.z; m[3][c]= (c!=3) ? 0.0f : 1.0f; } // Translation //! Returns the translation part of the matrix. inline_ const HPoint& GetTrans() const { return GetRow(3); } //! Gets the translation part of the matrix - inline_ void GetTrans(Point& p) const { p.x=m[3][0]; p.y=m[3][1]; p.z=m[3][2]; } + inline_ void GetTrans(IcePoint& p) const { p.x=m[3][0]; p.y=m[3][1]; p.z=m[3][2]; } //! Sets the translation part of the matrix, from a Point. - inline_ void SetTrans(const Point& p) { m[3][0]=p.x; m[3][1]=p.y; m[3][2]=p.z; } + inline_ void SetTrans(const IcePoint& p) { m[3][0]=p.x; m[3][1]=p.y; m[3][2]=p.z; } //! Sets the translation part of the matrix, from a HPoint. inline_ void SetTrans(const HPoint& p) { m[3][0]=p.x; m[3][1]=p.y; m[3][2]=p.z; m[3][3]=p.w; } //! Sets the translation part of the matrix, from floats. @@ -104,11 +104,11 @@ // Scale //! Sets the scale from a Point. The point is put on the diagonal. - inline_ void SetScale(const Point& p) { m[0][0]=p.x; m[1][1]=p.y; m[2][2]=p.z; } + inline_ void SetScale(const IcePoint& p) { m[0][0]=p.x; m[1][1]=p.y; m[2][2]=p.z; } //! Sets the scale from floats. Values are put on the diagonal. inline_ void SetScale(float sx, float sy, float sz) { m[0][0]=sx; m[1][1]=sy; m[2][2]=sz; } //! Scales from a Point. Each row is multiplied by a component. - void Scale(const Point& p) + void Scale(const IcePoint& p) { m[0][0] *= p.x; m[1][0] *= p.y; m[2][0] *= p.z; m[0][1] *= p.x; m[1][1] *= p.y; m[2][1] *= p.z; @@ -218,7 +218,7 @@ void RotZ(float angle) { float Cos = cosf(angle), Sin = sinf(angle); Identity(); m[0][0] = m[1][1] = Cos; m[1][0] = -Sin; m[0][1] = Sin; } //! Makes a rotation matrix about an arbitrary axis - Matrix4x4& Rot(float angle, Point& p1, Point& p2); + Matrix4x4& Rot(float angle, IcePoint& p1, IcePoint& p2); //! Transposes the matrix. void Transpose() @@ -303,9 +303,9 @@ inline_ HPoint operator*(const HPoint& v) const { return HPoint(GetRow(0)|v, GetRow(1)|v, GetRow(2)|v, GetRow(3)|v); } //! Operator for Point Mul = Matrix4x4 * Point; - inline_ Point operator*(const Point& v) const + inline_ IcePoint operator*(const IcePoint& v) const { - return Point( m[0][0]*v.x + m[0][1]*v.y + m[0][2]*v.z + m[0][3], + return IcePoint( m[0][0]*v.x + m[0][1]*v.y + m[0][2]*v.z + m[0][3], m[1][0]*v.x + m[1][1]*v.y + m[1][2]*v.z + m[1][3], m[2][0]*v.x + m[2][1]*v.y + m[2][2]*v.z + m[2][3] ); } @@ -434,7 +434,7 @@ }; //! Quickly rotates & translates a vector, using the 4x3 part of a 4x4 matrix - inline_ void TransformPoint4x3(Point& dest, const Point& source, const Matrix4x4& rot) + inline_ void TransformPoint4x3(IcePoint& dest, const IcePoint& source, const Matrix4x4& rot) { dest.x = rot.m[3][0] + source.x * rot.m[0][0] + source.y * rot.m[1][0] + source.z * rot.m[2][0]; dest.y = rot.m[3][1] + source.x * rot.m[0][1] + source.y * rot.m[1][1] + source.z * rot.m[2][1]; @@ -442,7 +442,7 @@ } //! Quickly rotates a vector, using the 3x3 part of a 4x4 matrix - inline_ void TransformPoint3x3(Point& dest, const Point& source, const Matrix4x4& rot) + inline_ void TransformPoint3x3(IcePoint& dest, const IcePoint& source, const Matrix4x4& rot) { dest.x = source.x * rot.m[0][0] + source.y * rot.m[1][0] + source.z * rot.m[2][0]; dest.y = source.x * rot.m[0][1] + source.y * rot.m[1][1] + source.z * rot.m[2][1]; diff --git a/Opcode/Ice/IceOBB.h b/Opcode/Ice/IceOBB.h index 4747f7f..2badb18 100644 --- a/Opcode/Ice/IceOBB.h +++ b/Opcode/Ice/IceOBB.h @@ -21,7 +21,7 @@ //! Constructor inline_ OBB() {} //! Constructor - inline_ OBB(const Point& center, const Point& extents, const Matrix3x3& rot) : mCenter(center), mExtents(extents), mRot(rot) {} + inline_ OBB(const IcePoint& center, const IcePoint& extents, const Matrix3x3& rot) : mCenter(center), mExtents(extents), mRot(rot) {} //! Destructor inline_ ~OBB() {} @@ -39,12 +39,12 @@ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** - * Tests if a point is contained within the OBB. - * \param p [in] the world point to test + * Tests if a IcePoint is contained within the OBB. + * \param p [in] the world IcePoint to test * \return true if inside the OBB */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool ContainsPoint(const Point& p) const; + bool ContainsPoint(const IcePoint& p) const; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** @@ -103,7 +103,7 @@ * \return true if success */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool ComputePoints(Point* pts) const; + bool ComputePoints(IcePoint* pts) const; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** @@ -112,7 +112,7 @@ * \return true if success */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool ComputeVertexNormals(Point* pts) const; + bool ComputeVertexNormals(IcePoint* pts) const; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** @@ -128,7 +128,7 @@ * \return edge normals in local space */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - const Point* GetLocalEdgeNormals() const; + const IcePoint* GetLocalEdgeNormals() const; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** @@ -137,7 +137,7 @@ * \param world_normal [out] edge normal in world space */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void ComputeWorldEdgeNormal(udword edge_index, Point& world_normal) const; + void ComputeWorldEdgeNormal(udword edge_index, IcePoint& world_normal) const; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** @@ -156,8 +156,8 @@ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// BOOL IsInside(const OBB& box) const; - inline_ const Point& GetCenter() const { return mCenter; } - inline_ const Point& GetExtents() const { return mExtents; } + inline_ const IcePoint& GetCenter() const { return mCenter; } + inline_ const IcePoint& GetExtents() const { return mExtents; } inline_ const Matrix3x3& GetRot() const { return mRot; } inline_ void GetRotatedExtents(Matrix3x3& extents) const @@ -166,8 +166,8 @@ extents.Scale(mExtents); } - Point mCenter; //!< B for Box - Point mExtents; //!< B for Bounding + IcePoint mCenter; //!< B for Box + IcePoint mExtents; //!< B for Bounding Matrix3x3 mRot; //!< O for Oriented // Orientation is stored in row-major format, diff --git a/Opcode/Ice/IcePlane.cpp b/Opcode/Ice/IcePlane.cpp index 36fe473..cd4758c 100644 --- a/Opcode/Ice/IcePlane.cpp +++ b/Opcode/Ice/IcePlane.cpp @@ -25,16 +25,16 @@ using namespace IceMaths; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * Computes the plane equation from 3 points. - * \param p0 [in] first point - * \param p1 [in] second point - * \param p2 [in] third point + * \param p0 [in] first IcePoint + * \param p1 [in] second IcePoint + * \param p2 [in] third IcePoint * \return Self-reference */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -Plane& Plane::Set(const Point& p0, const Point& p1, const Point& p2) +Plane& Plane::Set(const IcePoint& p0, const IcePoint& p1, const IcePoint& p2) { - Point Edge0 = p1 - p0; - Point Edge1 = p2 - p0; + IcePoint Edge0 = p1 - p0; + IcePoint Edge1 = p2 - p0; n = Edge0 ^ Edge1; n.Normalize(); diff --git a/Opcode/Ice/IcePlane.h b/Opcode/Ice/IcePlane.h index 0e0604c..d514e68 100644 --- a/Opcode/Ice/IcePlane.h +++ b/Opcode/Ice/IcePlane.h @@ -22,11 +22,11 @@ //! Constructor from a normal and a distance inline_ Plane(float nx, float ny, float nz, float d) { Set(nx, ny, nz, d); } //! Constructor from a point on the plane and a normal - inline_ Plane(const Point& p, const Point& n) { Set(p, n); } + inline_ Plane(const IcePoint& p, const IcePoint& n) { Set(p, n); } //! Constructor from three points - inline_ Plane(const Point& p0, const Point& p1, const Point& p2) { Set(p0, p1, p2); } + inline_ Plane(const IcePoint& p0, const IcePoint& p1, const IcePoint& p2) { Set(p0, p1, p2); } //! Constructor from a normal and a distance - inline_ Plane(const Point& _n, float _d) { n = _n; d = _d; } + inline_ Plane(const IcePoint& _n, float _d) { n = _n; d = _d; } //! Copy constructor inline_ Plane(const Plane& plane) : n(plane.n), d(plane.d) { } //! Destructor @@ -34,11 +34,11 @@ inline_ Plane& Zero() { n.Zero(); d = 0.0f; return *this; } inline_ Plane& Set(float nx, float ny, float nz, float _d) { n.Set(nx, ny, nz); d = _d; return *this; } - inline_ Plane& Set(const Point& p, const Point& _n) { n = _n; d = - p | _n; return *this; } - Plane& Set(const Point& p0, const Point& p1, const Point& p2); + inline_ Plane& Set(const IcePoint& p, const IcePoint& _n) { n = _n; d = - p | _n; return *this; } + Plane& Set(const IcePoint& p0, const IcePoint& p1, const IcePoint& p2); - inline_ float Distance(const Point& p) const { return (p | n) + d; } - inline_ bool Belongs(const Point& p) const { return fabsf(Distance(p)) < PLANE_EPSILON; } + inline_ float Distance(const IcePoint& p) const { return (p | n) + d; } + inline_ bool Belongs(const IcePoint& p) const { return fabsf(Distance(p)) < PLANE_EPSILON; } inline_ void Normalize() { @@ -50,11 +50,11 @@ } public: // Members - Point n; //!< The normal to the plane + IcePoint n; //!< The normal to the plane float d; //!< The distance from the origin // Cast operators - inline_ operator Point() const { return n; } + inline_ operator IcePoint() const { return n; } inline_ operator HPoint() const { return HPoint(n, d); } // Arithmetic operators @@ -68,8 +68,8 @@ inline_ Plane& operator*=(const Matrix4x4& m) { // Old code from Irion. Kept for reference. - Point n2 = HPoint(n, 0.0f) * m; - d = -((Point) (HPoint( -d*n, 1.0f ) * m) | n2); + IcePoint n2 = HPoint(n, 0.0f) * m; + d = -((IcePoint) (HPoint( -d*n, 1.0f ) * m) | n2); n = n2; return *this; } @@ -90,7 +90,7 @@ transformed.n = plane.n * Matrix3x3(transform); // Compute new d - transformed.d = plane.d - (Point(transform.GetTrans())|transformed.n); + transformed.d = plane.d - (IcePoint(transform.GetTrans())|transformed.n); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -107,7 +107,7 @@ plane.n *= Matrix3x3(transform); // Compute new d - plane.d -= Point(transform.GetTrans())|plane.n; + plane.d -= IcePoint(transform.GetTrans())|plane.n; } #endif // __ICEPLANE_H__ diff --git a/Opcode/Ice/IcePoint.cpp b/Opcode/Ice/IcePoint.cpp index 9fd7570..717fc53 100644 --- a/Opcode/Ice/IcePoint.cpp +++ b/Opcode/Ice/IcePoint.cpp @@ -56,7 +56,7 @@ using namespace IceMaths; * \return Self-reference */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -Point& Point::PositiveUnitRandomVector() +IcePoint& IcePoint::PositiveUnitRandomVector() { x = UnitRandomFloat(); y = UnitRandomFloat(); @@ -71,7 +71,7 @@ Point& Point::PositiveUnitRandomVector() * \return Self-reference */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -Point& Point::UnitRandomVector() +IcePoint& IcePoint::UnitRandomVector() { x = UnitRandomFloat() - 0.5f; y = UnitRandomFloat() - 0.5f; @@ -82,16 +82,16 @@ Point& Point::UnitRandomVector() // Cast operator // WARNING: not inlined -Point::operator HPoint() const { return HPoint(x, y, z, 0.0f); } +IcePoint::operator HPoint() const { return HPoint(x, y, z, 0.0f); } -Point& Point::Refract(const Point& eye, const Point& n, float refractindex, Point& refracted) +IcePoint& IcePoint::Refract(const IcePoint& eye, const IcePoint& n, float refractindex, IcePoint& refracted) { - // Point EyePt = eye position - // Point p = current vertex - // Point n = vertex normal - // Point rv = refracted vector + // IcePoint EyePt = eye position + // IcePoint p = current vertex + // IcePoint n = vertex normal + // IcePoint rv = refracted vector // Eye vector - doesn't need to be normalized - Point Env; + IcePoint Env; Env.x = eye.x - x; Env.y = eye.y - y; Env.z = eye.z - z; @@ -106,13 +106,13 @@ Point& Point::Refract(const Point& eye, const Point& n, float refractindex, Poin return *this; } -Point& Point::ProjectToPlane(const Plane& p) +IcePoint& IcePoint::ProjectToPlane(const Plane& p) { *this-= (p.d + (*this|p.n))*p.n; return *this; } -void Point::ProjectToScreen(float halfrenderwidth, float halfrenderheight, const Matrix4x4& mat, HPoint& projected) const +void IcePoint::ProjectToScreen(float halfrenderwidth, float halfrenderheight, const Matrix4x4& mat, HPoint& projected) const { projected = HPoint(x, y, z, 1.0f) * mat; projected.w = 1.0f / projected.w; @@ -125,7 +125,7 @@ void Point::ProjectToScreen(float halfrenderwidth, float halfrenderheight, const projected.y *= -halfrenderheight; projected.y += halfrenderheight; } -void Point::SetNotUsed() +void IcePoint::SetNotUsed() { // We use a particular integer pattern : 0xffffffff everywhere. This is a NAN. IR(x) = 0xffffffff; @@ -133,7 +133,7 @@ void Point::SetNotUsed() IR(z) = 0xffffffff; } -BOOL Point::IsNotUsed() const +BOOL IcePoint::IsNotUsed() const { if(IR(x)!=0xffffffff) return FALSE; if(IR(y)!=0xffffffff) return FALSE; @@ -141,7 +141,7 @@ BOOL Point::IsNotUsed() const return TRUE; } -Point& Point::Mult(const Matrix3x3& mat, const Point& a) +IcePoint& IcePoint::Mult(const Matrix3x3& mat, const IcePoint& a) { x = a.x * mat.m[0][0] + a.y * mat.m[0][1] + a.z * mat.m[0][2]; y = a.x * mat.m[1][0] + a.y * mat.m[1][1] + a.z * mat.m[1][2]; @@ -149,7 +149,7 @@ Point& Point::Mult(const Matrix3x3& mat, const Point& a) return *this; } -Point& Point::Mult2(const Matrix3x3& mat1, const Point& a1, const Matrix3x3& mat2, const Point& a2) +IcePoint& IcePoint::Mult2(const Matrix3x3& mat1, const IcePoint& a1, const Matrix3x3& mat2, const IcePoint& a2) { x = a1.x * mat1.m[0][0] + a1.y * mat1.m[0][1] + a1.z * mat1.m[0][2] + a2.x * mat2.m[0][0] + a2.y * mat2.m[0][1] + a2.z * mat2.m[0][2]; y = a1.x * mat1.m[1][0] + a1.y * mat1.m[1][1] + a1.z * mat1.m[1][2] + a2.x * mat2.m[1][0] + a2.y * mat2.m[1][1] + a2.z * mat2.m[1][2]; @@ -157,7 +157,7 @@ Point& Point::Mult2(const Matrix3x3& mat1, const Point& a1, const Matrix3x3& mat return *this; } -Point& Point::Mac(const Matrix3x3& mat, const Point& a) +IcePoint& IcePoint::Mac(const Matrix3x3& mat, const IcePoint& a) { x += a.x * mat.m[0][0] + a.y * mat.m[0][1] + a.z * mat.m[0][2]; y += a.x * mat.m[1][0] + a.y * mat.m[1][1] + a.z * mat.m[1][2]; @@ -165,7 +165,7 @@ Point& Point::Mac(const Matrix3x3& mat, const Point& a) return *this; } -Point& Point::TransMult(const Matrix3x3& mat, const Point& a) +IcePoint& IcePoint::TransMult(const Matrix3x3& mat, const IcePoint& a) { x = a.x * mat.m[0][0] + a.y * mat.m[1][0] + a.z * mat.m[2][0]; y = a.x * mat.m[0][1] + a.y * mat.m[1][1] + a.z * mat.m[2][1]; @@ -173,7 +173,7 @@ Point& Point::TransMult(const Matrix3x3& mat, const Point& a) return *this; } -Point& Point::Transform(const Point& r, const Matrix3x3& rotpos, const Point& linpos) +IcePoint& IcePoint::Transform(const IcePoint& r, const Matrix3x3& rotpos, const IcePoint& linpos) { x = r.x * rotpos.m[0][0] + r.y * rotpos.m[0][1] + r.z * rotpos.m[0][2] + linpos.x; y = r.x * rotpos.m[1][0] + r.y * rotpos.m[1][1] + r.z * rotpos.m[1][2] + linpos.y; @@ -181,7 +181,7 @@ Point& Point::Transform(const Point& r, const Matrix3x3& rotpos, const Point& li return *this; } -Point& Point::InvTransform(const Point& r, const Matrix3x3& rotpos, const Point& linpos) +IcePoint& IcePoint::InvTransform(const IcePoint& r, const Matrix3x3& rotpos, const IcePoint& linpos) { float sx = r.x - linpos.x; float sy = r.y - linpos.y; diff --git a/Opcode/Ice/IcePoint.h b/Opcode/Ice/IcePoint.h index 78148d6..7f55a27 100644 --- a/Opcode/Ice/IcePoint.h +++ b/Opcode/Ice/IcePoint.h @@ -22,72 +22,72 @@ const float EPSILON2 = 1.0e-20f; - class ICEMATHS_API Point + class ICEMATHS_API IcePoint { public: //! Empty constructor - inline_ Point() {} + inline_ IcePoint() {} //! Constructor from a single float // inline_ Point(float val) : x(val), y(val), z(val) {} // Removed since it introduced the nasty "Point T = *Matrix4x4.GetTrans();" bug....... //! Constructor from floats - inline_ Point(float _x, float _y, float _z) : x(_x), y(_y), z(_z) {} + inline_ IcePoint(float _x, float _y, float _z) : x(_x), y(_y), z(_z) {} //! Constructor from array - inline_ Point(const float f[3]) : x(f[_X]), y(f[_Y]), z(f[_Z]) {} + inline_ IcePoint(const float f[3]) : x(f[_X]), y(f[_Y]), z(f[_Z]) {} //! Copy constructor - inline_ Point(const Point& p) : x(p.x), y(p.y), z(p.z) {} + inline_ IcePoint(const IcePoint& p) : x(p.x), y(p.y), z(p.z) {} //! Destructor - inline_ ~Point() {} + inline_ ~IcePoint() {} //! Clears the vector - inline_ Point& Zero() { x = y = z = 0.0f; return *this; } + inline_ IcePoint& Zero() { x = y = z = 0.0f; return *this; } //! + infinity - inline_ Point& SetPlusInfinity() { x = y = z = MAX_FLOAT; return *this; } + inline_ IcePoint& SetPlusInfinity() { x = y = z = MAX_FLOAT; return *this; } //! - infinity - inline_ Point& SetMinusInfinity() { x = y = z = MIN_FLOAT; return *this; } + inline_ IcePoint& SetMinusInfinity() { x = y = z = MIN_FLOAT; return *this; } //! Sets positive unit random vector - Point& PositiveUnitRandomVector(); + IcePoint& PositiveUnitRandomVector(); //! Sets unit random vector - Point& UnitRandomVector(); + IcePoint& UnitRandomVector(); //! Assignment from values - inline_ Point& Set(float _x, float _y, float _z) { x = _x; y = _y; z = _z; return *this; } + inline_ IcePoint& Set(float _x, float _y, float _z) { x = _x; y = _y; z = _z; return *this; } //! Assignment from array - inline_ Point& Set(const float f[3]) { x = f[_X]; y = f[_Y]; z = f[_Z]; return *this; } + inline_ IcePoint& Set(const float f[3]) { x = f[_X]; y = f[_Y]; z = f[_Z]; return *this; } //! Assignment from another point - inline_ Point& Set(const Point& src) { x = src.x; y = src.y; z = src.z; return *this; } + inline_ IcePoint& Set(const IcePoint& src) { x = src.x; y = src.y; z = src.z; return *this; } //! Adds a vector - inline_ Point& Add(const Point& p) { x += p.x; y += p.y; z += p.z; return *this; } + inline_ IcePoint& Add(const IcePoint& p) { x += p.x; y += p.y; z += p.z; return *this; } //! Adds a vector - inline_ Point& Add(float _x, float _y, float _z) { x += _x; y += _y; z += _z; return *this; } + inline_ IcePoint& Add(float _x, float _y, float _z) { x += _x; y += _y; z += _z; return *this; } //! Adds a vector - inline_ Point& Add(const float f[3]) { x += f[_X]; y += f[_Y]; z += f[_Z]; return *this; } + inline_ IcePoint& Add(const float f[3]) { x += f[_X]; y += f[_Y]; z += f[_Z]; return *this; } //! Adds vectors - inline_ Point& Add(const Point& p, const Point& q) { x = p.x+q.x; y = p.y+q.y; z = p.z+q.z; return *this; } + inline_ IcePoint& Add(const IcePoint& p, const IcePoint& q) { x = p.x+q.x; y = p.y+q.y; z = p.z+q.z; return *this; } //! Subtracts a vector - inline_ Point& Sub(const Point& p) { x -= p.x; y -= p.y; z -= p.z; return *this; } + inline_ IcePoint& Sub(const IcePoint& p) { x -= p.x; y -= p.y; z -= p.z; return *this; } //! Subtracts a vector - inline_ Point& Sub(float _x, float _y, float _z) { x -= _x; y -= _y; z -= _z; return *this; } + inline_ IcePoint& Sub(float _x, float _y, float _z) { x -= _x; y -= _y; z -= _z; return *this; } //! Subtracts a vector - inline_ Point& Sub(const float f[3]) { x -= f[_X]; y -= f[_Y]; z -= f[_Z]; return *this; } + inline_ IcePoint& Sub(const float f[3]) { x -= f[_X]; y -= f[_Y]; z -= f[_Z]; return *this; } //! Subtracts vectors - inline_ Point& Sub(const Point& p, const Point& q) { x = p.x-q.x; y = p.y-q.y; z = p.z-q.z; return *this; } + inline_ IcePoint& Sub(const IcePoint& p, const IcePoint& q) { x = p.x-q.x; y = p.y-q.y; z = p.z-q.z; return *this; } //! this = -this - inline_ Point& Neg() { x = -x; y = -y; z = -z; return *this; } + inline_ IcePoint& Neg() { x = -x; y = -y; z = -z; return *this; } //! this = -a - inline_ Point& Neg(const Point& a) { x = -a.x; y = -a.y; z = -a.z; return *this; } + inline_ IcePoint& Neg(const IcePoint& a) { x = -a.x; y = -a.y; z = -a.z; return *this; } //! Multiplies by a scalar - inline_ Point& Mult(float s) { x *= s; y *= s; z *= s; return *this; } + inline_ IcePoint& Mult(float s) { x *= s; y *= s; z *= s; return *this; } //! this = a * scalar - inline_ Point& Mult(const Point& a, float scalar) + inline_ IcePoint& Mult(const IcePoint& a, float scalar) { x = a.x * scalar; y = a.y * scalar; @@ -96,7 +96,7 @@ } //! this = a + b * scalar - inline_ Point& Mac(const Point& a, const Point& b, float scalar) + inline_ IcePoint& Mac(const IcePoint& a, const IcePoint& b, float scalar) { x = a.x + b.x * scalar; y = a.y + b.y * scalar; @@ -105,7 +105,7 @@ } //! this = this + a * scalar - inline_ Point& Mac(const Point& a, float scalar) + inline_ IcePoint& Mac(const IcePoint& a, float scalar) { x += a.x * scalar; y += a.y * scalar; @@ -114,7 +114,7 @@ } //! this = a - b * scalar - inline_ Point& Msc(const Point& a, const Point& b, float scalar) + inline_ IcePoint& Msc(const IcePoint& a, const IcePoint& b, float scalar) { x = a.x - b.x * scalar; y = a.y - b.y * scalar; @@ -123,7 +123,7 @@ } //! this = this - a * scalar - inline_ Point& Msc(const Point& a, float scalar) + inline_ IcePoint& Msc(const IcePoint& a, float scalar) { x -= a.x * scalar; y -= a.y * scalar; @@ -132,7 +132,7 @@ } //! this = a + b * scalarb + c * scalarc - inline_ Point& Mac2(const Point& a, const Point& b, float scalarb, const Point& c, float scalarc) + inline_ IcePoint& Mac2(const IcePoint& a, const IcePoint& b, float scalarb, const IcePoint& c, float scalarc) { x = a.x + b.x * scalarb + c.x * scalarc; y = a.y + b.y * scalarb + c.y * scalarc; @@ -141,7 +141,7 @@ } //! this = a - b * scalarb - c * scalarc - inline_ Point& Msc2(const Point& a, const Point& b, float scalarb, const Point& c, float scalarc) + inline_ IcePoint& Msc2(const IcePoint& a, const IcePoint& b, float scalarb, const IcePoint& c, float scalarc) { x = a.x - b.x * scalarb - c.x * scalarc; y = a.y - b.y * scalarb - c.y * scalarc; @@ -150,19 +150,19 @@ } //! this = mat * a - inline_ Point& Mult(const Matrix3x3& mat, const Point& a); + inline_ IcePoint& Mult(const Matrix3x3& mat, const IcePoint& a); //! this = mat1 * a1 + mat2 * a2 - inline_ Point& Mult2(const Matrix3x3& mat1, const Point& a1, const Matrix3x3& mat2, const Point& a2); + inline_ IcePoint& Mult2(const Matrix3x3& mat1, const IcePoint& a1, const Matrix3x3& mat2, const IcePoint& a2); //! this = this + mat * a - inline_ Point& Mac(const Matrix3x3& mat, const Point& a); + inline_ IcePoint& Mac(const Matrix3x3& mat, const IcePoint& a); //! this = transpose(mat) * a - inline_ Point& TransMult(const Matrix3x3& mat, const Point& a); + inline_ IcePoint& TransMult(const Matrix3x3& mat, const IcePoint& a); //! Linear interpolate between two vectors: this = a + t * (b - a) - inline_ Point& Lerp(const Point& a, const Point& b, float t) + inline_ IcePoint& Lerp(const IcePoint& a, const IcePoint& b, float t) { x = a.x + t * (b.x - a.x); y = a.y + t * (b.y - a.y); @@ -175,7 +175,7 @@ //! + p1 * (3t^3 - 5t^2 + 2)/2 //! + p2 * (4t^2 - 3t^3 + t)/2 //! + p3 * (t^3 - t^2)/2 - inline_ Point& Herp(const Point& p0, const Point& p1, const Point& p2, const Point& p3, float t) + inline_ IcePoint& Herp(const IcePoint& p0, const IcePoint& p1, const IcePoint& p2, const IcePoint& p3, float t) { float t2 = t * t; float t3 = t2 * t; @@ -190,22 +190,22 @@ } //! this = rotpos * r + linpos - inline_ Point& Transform(const Point& r, const Matrix3x3& rotpos, const Point& linpos); + inline_ IcePoint& Transform(const IcePoint& r, const Matrix3x3& rotpos, const IcePoint& linpos); //! this = trans(rotpos) * (r - linpos) - inline_ Point& InvTransform(const Point& r, const Matrix3x3& rotpos, const Point& linpos); + inline_ IcePoint& InvTransform(const IcePoint& r, const Matrix3x3& rotpos, const IcePoint& linpos); //! Returns MIN(x, y, z); inline_ float Min() const { return MIN(x, MIN(y, z)); } //! Returns MAX(x, y, z); inline_ float Max() const { return MAX(x, MAX(y, z)); } //! Sets each element to be componentwise minimum - inline_ Point& Min(const Point& p) { x = MIN(x, p.x); y = MIN(y, p.y); z = MIN(z, p.z); return *this; } + inline_ IcePoint& Min(const IcePoint& p) { x = MIN(x, p.x); y = MIN(y, p.y); z = MIN(z, p.z); return *this; } //! Sets each element to be componentwise maximum - inline_ Point& Max(const Point& p) { x = MAX(x, p.x); y = MAX(y, p.y); z = MAX(z, p.z); return *this; } + inline_ IcePoint& Max(const IcePoint& p) { x = MAX(x, p.x); y = MAX(y, p.y); z = MAX(z, p.z); return *this; } //! Clamps each element - inline_ Point& Clamp(float min, float max) + inline_ IcePoint& Clamp(float min, float max) { if(xmax) x=max; if(ymax) y=max; @@ -220,7 +220,7 @@ //! Computes volume inline_ float Volume() const { return x * y * z; } - //! Checks the point is near zero + //! Checks the IcePoint is near zero inline_ bool ApproxZero() const { return SquareMagnitude() < EPSILON2; } //! Tests for exact zero vector @@ -230,7 +230,7 @@ return TRUE; } - //! Checks point validity + //! Checks IcePoint validity inline_ BOOL IsValid() const { if(!IsValidFloat(x)) return FALSE; @@ -239,7 +239,7 @@ return TRUE; } - //! Slighty moves the point + //! Slighty moves the IcePoint void Tweak(udword coord_mask, udword tweak_mask) { if(coord_mask&1) { udword Dummy = IR(x); Dummy^=tweak_mask; x = FR(Dummy); } @@ -249,7 +249,7 @@ #define TWEAKMASK 0x3fffff #define TWEAKNOTMASK ~TWEAKMASK - //! Slighty moves the point out + //! Slighty moves the IcePoint out inline_ void TweakBigger() { udword Dummy = (IR(x)&TWEAKNOTMASK); if(!IS_NEGATIVE_FLOAT(x)) Dummy+=TWEAKMASK+1; x = FR(Dummy); @@ -257,7 +257,7 @@ Dummy = (IR(z)&TWEAKNOTMASK); if(!IS_NEGATIVE_FLOAT(z)) Dummy+=TWEAKMASK+1; z = FR(Dummy); } - //! Slighty moves the point in + //! Slighty moves the IcePoint in inline_ void TweakSmaller() { udword Dummy = (IR(x)&TWEAKNOTMASK); if(IS_NEGATIVE_FLOAT(x)) Dummy+=TWEAKMASK+1; x = FR(Dummy); @@ -266,7 +266,7 @@ } //! Normalizes the vector - inline_ Point& Normalize() + inline_ IcePoint& Normalize() { float M = x*x + y*y + z*z; if(M) @@ -280,7 +280,7 @@ } //! Sets vector length - inline_ Point& SetLength(float length) + inline_ IcePoint& SetLength(float length) { float NewLength = length / Magnitude(); x *= NewLength; @@ -290,7 +290,7 @@ } //! Clamps vector length - inline_ Point& ClampLength(float limit_length) + inline_ IcePoint& ClampLength(float limit_length) { if(limit_length>=0.0f) // Magnitude must be positive { @@ -307,23 +307,23 @@ return *this; } - //! Computes distance to another point - inline_ float Distance(const Point& b) const + //! Computes distance to another IcePoint + inline_ float Distance(const IcePoint& b) const { return sqrtf((x - b.x)*(x - b.x) + (y - b.y)*(y - b.y) + (z - b.z)*(z - b.z)); } - //! Computes square distance to another point - inline_ float SquareDistance(const Point& b) const + //! Computes square distance to another IcePoint + inline_ float SquareDistance(const IcePoint& b) const { return ((x - b.x)*(x - b.x) + (y - b.y)*(y - b.y) + (z - b.z)*(z - b.z)); } //! Dot product dp = this|a - inline_ float Dot(const Point& p) const { return p.x * x + p.y * y + p.z * z; } + inline_ float Dot(const IcePoint& p) const { return p.x * x + p.y * y + p.z * z; } //! Cross product this = a x b - inline_ Point& Cross(const Point& a, const Point& b) + inline_ IcePoint& Cross(const IcePoint& a, const IcePoint& b) { x = a.y * b.z - a.z * b.y; y = a.z * b.x - a.x * b.z; @@ -367,17 +367,17 @@ return m; } - //! Refracts the point - Point& Refract(const Point& eye, const Point& n, float refractindex, Point& refracted); + //! Refracts the IcePoint + IcePoint& Refract(const IcePoint& eye, const IcePoint& n, float refractindex, IcePoint& refracted); - //! Projects the point onto a plane - Point& ProjectToPlane(const Plane& p); + //! Projects the IcePoint onto a plane + IcePoint& ProjectToPlane(const Plane& p); - //! Projects the point onto the screen + //! Projects the IcePoint onto the screen void ProjectToScreen(float halfrenderwidth, float halfrenderheight, const Matrix4x4& mat, HPoint& projected) const; - //! Unfolds the point onto a plane according to edge(a,b) - Point& Unfold(Plane& p, Point& a, Point& b); + //! Unfolds the IcePoint onto a plane according to edge(a,b) + IcePoint& Unfold(Plane& p, IcePoint& a, IcePoint& b); //! Hash function from Ville Miettinen inline_ udword GetHashValue() const @@ -387,101 +387,101 @@ return (f>>22)^(f>>12)^(f); } - //! Stuff magic values in the point, marking it as explicitely not used. + //! Stuff magic values in the IcePoint, marking it as explicitely not used. void SetNotUsed(); - //! Checks the point is marked as not used + //! Checks the IcePoint is marked as not used BOOL IsNotUsed() const; // Arithmetic operators - //! Unary operator for Point Negate = - Point - inline_ Point operator-() const { return Point(-x, -y, -z); } - - //! Operator for Point Plus = Point + Point. - inline_ Point operator+(const Point& p) const { return Point(x + p.x, y + p.y, z + p.z); } - //! Operator for Point Minus = Point - Point. - inline_ Point operator-(const Point& p) const { return Point(x - p.x, y - p.y, z - p.z); } - - //! Operator for Point Mul = Point * Point. - inline_ Point operator*(const Point& p) const { return Point(x * p.x, y * p.y, z * p.z); } - //! Operator for Point Scale = Point * float. - inline_ Point operator*(float s) const { return Point(x * s, y * s, z * s ); } - //! Operator for Point Scale = float * Point. - inline_ friend Point operator*(float s, const Point& p) { return Point(s * p.x, s * p.y, s * p.z); } - - //! Operator for Point Div = Point / Point. - inline_ Point operator/(const Point& p) const { return Point(x / p.x, y / p.y, z / p.z); } - //! Operator for Point Scale = Point / float. - inline_ Point operator/(float s) const { s = 1.0f / s; return Point(x * s, y * s, z * s); } - //! Operator for Point Scale = float / Point. - inline_ friend Point operator/(float s, const Point& p) { return Point(s / p.x, s / p.y, s / p.z); } - - //! Operator for float DotProd = Point | Point. - inline_ float operator|(const Point& p) const { return x*p.x + y*p.y + z*p.z; } - //! Operator for Point VecProd = Point ^ Point. - inline_ Point operator^(const Point& p) const + //! Unary operator for IcePoint Negate = - IcePoint + inline_ IcePoint operator-() const { return IcePoint(-x, -y, -z); } + + //! Operator for IcePoint Plus = IcePoint + IcePoint. + inline_ IcePoint operator+(const IcePoint& p) const { return IcePoint(x + p.x, y + p.y, z + p.z); } + //! Operator for IcePoint Minus = IcePoint - IcePoint. + inline_ IcePoint operator-(const IcePoint& p) const { return IcePoint(x - p.x, y - p.y, z - p.z); } + + //! Operator for IcePoint Mul = IcePoint * IcePoint. + inline_ IcePoint operator*(const IcePoint& p) const { return IcePoint(x * p.x, y * p.y, z * p.z); } + //! Operator for IcePoint Scale = IcePoint * float. + inline_ IcePoint operator*(float s) const { return IcePoint(x * s, y * s, z * s ); } + //! Operator for IcePoint Scale = float * IcePoint. + inline_ friend IcePoint operator*(float s, const IcePoint& p) { return IcePoint(s * p.x, s * p.y, s * p.z); } + + //! Operator for IcePoint Div = IcePoint / IcePoint. + inline_ IcePoint operator/(const IcePoint& p) const { return IcePoint(x / p.x, y / p.y, z / p.z); } + //! Operator for IcePoint Scale = IcePoint / float. + inline_ IcePoint operator/(float s) const { s = 1.0f / s; return IcePoint(x * s, y * s, z * s); } + //! Operator for IcePoint Scale = float / IcePoint. + inline_ friend IcePoint operator/(float s, const IcePoint& p) { return IcePoint(s / p.x, s / p.y, s / p.z); } + + //! Operator for float DotProd = IcePoint | IcePoint. + inline_ float operator|(const IcePoint& p) const { return x*p.x + y*p.y + z*p.z; } + //! Operator for IcePoint VecProd = IcePoint ^ IcePoint. + inline_ IcePoint operator^(const IcePoint& p) const { - return Point( + return IcePoint( y * p.z - z * p.y, z * p.x - x * p.z, x * p.y - y * p.x ); } - //! Operator for Point += Point. - inline_ Point& operator+=(const Point& p) { x += p.x; y += p.y; z += p.z; return *this; } - //! Operator for Point += float. - inline_ Point& operator+=(float s) { x += s; y += s; z += s; return *this; } + //! Operator for IcePoint += IcePoint. + inline_ IcePoint& operator+=(const IcePoint& p) { x += p.x; y += p.y; z += p.z; return *this; } + //! Operator for IcePoint += float. + inline_ IcePoint& operator+=(float s) { x += s; y += s; z += s; return *this; } - //! Operator for Point -= Point. - inline_ Point& operator-=(const Point& p) { x -= p.x; y -= p.y; z -= p.z; return *this; } - //! Operator for Point -= float. - inline_ Point& operator-=(float s) { x -= s; y -= s; z -= s; return *this; } + //! Operator for IcePoint -= IcePoint. + inline_ IcePoint& operator-=(const IcePoint& p) { x -= p.x; y -= p.y; z -= p.z; return *this; } + //! Operator for IcePoint -= float. + inline_ IcePoint& operator-=(float s) { x -= s; y -= s; z -= s; return *this; } - //! Operator for Point *= Point. - inline_ Point& operator*=(const Point& p) { x *= p.x; y *= p.y; z *= p.z; return *this; } - //! Operator for Point *= float. - inline_ Point& operator*=(float s) { x *= s; y *= s; z *= s; return *this; } + //! Operator for IcePoint *= IcePoint. + inline_ IcePoint& operator*=(const IcePoint& p) { x *= p.x; y *= p.y; z *= p.z; return *this; } + //! Operator for IcePoint *= float. + inline_ IcePoint& operator*=(float s) { x *= s; y *= s; z *= s; return *this; } - //! Operator for Point /= Point. - inline_ Point& operator/=(const Point& p) { x /= p.x; y /= p.y; z /= p.z; return *this; } - //! Operator for Point /= float. - inline_ Point& operator/=(float s) { s = 1.0f/s; x *= s; y *= s; z *= s; return *this; } + //! Operator for IcePoint /= IcePoint. + inline_ IcePoint& operator/=(const IcePoint& p) { x /= p.x; y /= p.y; z /= p.z; return *this; } + //! Operator for IcePoint /= float. + inline_ IcePoint& operator/=(float s) { s = 1.0f/s; x *= s; y *= s; z *= s; return *this; } // Logical operators - //! Operator for "if(Point==Point)" - inline_ bool operator==(const Point& p) const { return ( (IR(x)==IR(p.x))&&(IR(y)==IR(p.y))&&(IR(z)==IR(p.z))); } - //! Operator for "if(Point!=Point)" - inline_ bool operator!=(const Point& p) const { return ( (IR(x)!=IR(p.x))||(IR(y)!=IR(p.y))||(IR(z)!=IR(p.z))); } + //! Operator for "if(IcePoint==IcePoint)" + inline_ bool operator==(const IcePoint& p) const { return ( (IR(x)==IR(p.x))&&(IR(y)==IR(p.y))&&(IR(z)==IR(p.z))); } + //! Operator for "if(IcePoint!=IcePoint)" + inline_ bool operator!=(const IcePoint& p) const { return ( (IR(x)!=IR(p.x))||(IR(y)!=IR(p.y))||(IR(z)!=IR(p.z))); } // Arithmetic operators - //! Operator for Point Mul = Point * Matrix3x3. - inline_ Point operator*(const Matrix3x3& mat) const + //! Operator for IcePoint Mul = IcePoint * Matrix3x3. + inline_ IcePoint operator*(const Matrix3x3& mat) const { class ShadowMatrix3x3{ public: float m[3][3]; }; // To allow inlining const ShadowMatrix3x3* Mat = (const ShadowMatrix3x3*)&mat; - return Point( + return IcePoint( x * Mat->m[0][0] + y * Mat->m[1][0] + z * Mat->m[2][0], x * Mat->m[0][1] + y * Mat->m[1][1] + z * Mat->m[2][1], x * Mat->m[0][2] + y * Mat->m[1][2] + z * Mat->m[2][2] ); } - //! Operator for Point Mul = Point * Matrix4x4. - inline_ Point operator*(const Matrix4x4& mat) const + //! Operator for IcePoint Mul = IcePoint * Matrix4x4. + inline_ IcePoint operator*(const Matrix4x4& mat) const { class ShadowMatrix4x4{ public: float m[4][4]; }; // To allow inlining const ShadowMatrix4x4* Mat = (const ShadowMatrix4x4*)&mat; - return Point( + return IcePoint( x * Mat->m[0][0] + y * Mat->m[1][0] + z * Mat->m[2][0] + Mat->m[3][0], x * Mat->m[0][1] + y * Mat->m[1][1] + z * Mat->m[2][1] + Mat->m[3][1], x * Mat->m[0][2] + y * Mat->m[1][2] + z * Mat->m[2][2] + Mat->m[3][2]); } - //! Operator for Point *= Matrix3x3. - inline_ Point& operator*=(const Matrix3x3& mat) + //! Operator for IcePoint *= Matrix3x3. + inline_ IcePoint& operator*=(const Matrix3x3& mat) { class ShadowMatrix3x3{ public: float m[3][3]; }; // To allow inlining const ShadowMatrix3x3* Mat = (const ShadowMatrix3x3*)&mat; @@ -495,8 +495,8 @@ return *this; } - //! Operator for Point *= Matrix4x4. - inline_ Point& operator*=(const Matrix4x4& mat) + //! Operator for IcePoint *= Matrix4x4. + inline_ IcePoint& operator*=(const Matrix4x4& mat) { class ShadowMatrix4x4{ public: float m[4][4]; }; // To allow inlining const ShadowMatrix4x4* Mat = (const ShadowMatrix4x4*)&mat; @@ -512,7 +512,7 @@ // Cast operators - //! Cast a Point to a HPoint. w is set to zero. + //! Cast a IcePoint to a HPoint. w is set to zero. operator HPoint() const; inline_ operator const float*() const { return &x; } @@ -522,7 +522,7 @@ float x, y, z; }; - FUNCTION ICEMATHS_API void Normalize1(Point& a); - FUNCTION ICEMATHS_API void Normalize2(Point& a); + FUNCTION ICEMATHS_API void Normalize1(IcePoint& a); + FUNCTION ICEMATHS_API void Normalize2(IcePoint& a); #endif //__ICEPOINT_H__ diff --git a/Opcode/Ice/IceRay.cpp b/Opcode/Ice/IceRay.cpp index be04043..a3872f6 100644 --- a/Opcode/Ice/IceRay.cpp +++ b/Opcode/Ice/IceRay.cpp @@ -18,7 +18,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /* - O = Origin = impact point + O = Origin = impact IcePoint i = normalized vector along the x axis j = normalized vector along the y axis = actually the normal vector in O D = Direction vector, norm |D| = 1 @@ -63,9 +63,9 @@ using namespace IceMaths; -float Ray::SquareDistance(const Point& point, float* t) const +float Ray::SquareDistance(const IcePoint& Point, float* t) const { - Point Diff = point - mOrig; + IcePoint Diff = Point - mOrig; float fT = Diff | mDir; if(fT<=0.0f) diff --git a/Opcode/Ice/IceRay.h b/Opcode/Ice/IceRay.h index f99a78b..c40552b 100644 --- a/Opcode/Ice/IceRay.h +++ b/Opcode/Ice/IceRay.h @@ -18,31 +18,31 @@ //! Constructor inline_ Ray() {} //! Constructor - inline_ Ray(const Point& orig, const Point& dir) : mOrig(orig), mDir(dir) {} + inline_ Ray(const IcePoint& orig, const IcePoint& dir) : mOrig(orig), mDir(dir) {} //! Copy constructor inline_ Ray(const Ray& ray) : mOrig(ray.mOrig), mDir(ray.mDir) {} //! Destructor inline_ ~Ray() {} - float SquareDistance(const Point& point, float* t=null) const; - inline_ float Distance(const Point& point, float* t=null) const { return sqrtf(SquareDistance(point, t)); } + float SquareDistance(const IcePoint& point, float* t=null) const; + inline_ float Distance(const IcePoint& point, float* t=null) const { return sqrtf(SquareDistance(point, t)); } - Point mOrig; //!< Ray origin - Point mDir; //!< Normalized direction + IcePoint mOrig; //!< Ray origin + IcePoint mDir; //!< Normalized direction }; - inline_ void ComputeReflexionVector(Point& reflected, const Point& incoming_dir, const Point& outward_normal) + inline_ void ComputeReflexionVector(IcePoint& reflected, const IcePoint& incoming_dir, const IcePoint& outward_normal) { reflected = incoming_dir - outward_normal * 2.0f * (incoming_dir|outward_normal); } - inline_ void ComputeReflexionVector(Point& reflected, const Point& source, const Point& impact, const Point& normal) + inline_ void ComputeReflexionVector(IcePoint& reflected, const IcePoint& source, const IcePoint& impact, const IcePoint& normal) { - Point V = impact - source; + IcePoint V = impact - source; reflected = V - normal * 2.0f * (V|normal); } - inline_ void DecomposeVector(Point& normal_compo, Point& tangent_compo, const Point& outward_dir, const Point& outward_normal) + inline_ void DecomposeVector(IcePoint& normal_compo, IcePoint& tangent_compo, const IcePoint& outward_dir, const IcePoint& outward_normal) { normal_compo = outward_normal * (outward_dir|outward_normal); tangent_compo = outward_dir - normal_compo; @@ -56,7 +56,7 @@ * \param world [in] world transform */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - inline_ void ComputeLocalDirection(Point& local_dir, const Point& world_dir, const Matrix4x4& world) + inline_ void ComputeLocalDirection(IcePoint& local_dir, const IcePoint& world_dir, const Matrix4x4& world) { // Get world direction back in local space // Matrix3x3 InvWorld = world; @@ -72,7 +72,7 @@ * \param world [in] world transform */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - inline_ void ComputeLocalPoint(Point& local_pt, const Point& world_pt, const Matrix4x4& world) + inline_ void ComputeLocalPoint(IcePoint& local_pt, const IcePoint& world_pt, const Matrix4x4& world) { // Get world vertex back in local space Matrix4x4 InvWorld = world; diff --git a/Opcode/Ice/IceSegment.cpp b/Opcode/Ice/IceSegment.cpp index 4b51343..f8d1553 100644 --- a/Opcode/Ice/IceSegment.cpp +++ b/Opcode/Ice/IceSegment.cpp @@ -26,10 +26,10 @@ using namespace IceMaths; -float Segment::SquareDistance(const Point& point, float* t) const +float Segment::SquareDistance(const IcePoint& Point, float* t) const { - Point Diff = point - mP0; - Point Dir = mP1 - mP0; + IcePoint Diff = Point - mP0; + IcePoint Dir = mP1 - mP0; float fT = Diff | Dir; if(fT<=0.0f) diff --git a/Opcode/Ice/IceSegment.h b/Opcode/Ice/IceSegment.h index 3dc8314..e3ce8ab 100644 --- a/Opcode/Ice/IceSegment.h +++ b/Opcode/Ice/IceSegment.h @@ -18,19 +18,19 @@ //! Constructor inline_ Segment() {} //! Constructor - inline_ Segment(const Point& p0, const Point& p1) : mP0(p0), mP1(p1) {} + inline_ Segment(const IcePoint& p0, const IcePoint& p1) : mP0(p0), mP1(p1) {} //! Copy constructor inline_ Segment(const Segment& seg) : mP0(seg.mP0), mP1(seg.mP1) {} //! Destructor inline_ ~Segment() {} - inline_ const Point& GetOrigin() const { return mP0; } - inline_ Point ComputeDirection() const { return mP1 - mP0; } - inline_ void ComputeDirection(Point& dir) const { dir = mP1 - mP0; } + inline_ const IcePoint& GetOrigin() const { return mP0; } + inline_ IcePoint ComputeDirection() const { return mP1 - mP0; } + inline_ void ComputeDirection(IcePoint& dir) const { dir = mP1 - mP0; } inline_ float ComputeLength() const { return mP1.Distance(mP0); } inline_ float ComputeSquareLength() const { return mP1.SquareDistance(mP0); } - inline_ void SetOriginDirection(const Point& origin, const Point& direction) + inline_ void SetOriginDirection(const IcePoint& origin, const IcePoint& direction) { mP0 = mP1 = origin; mP1 += direction; @@ -38,18 +38,18 @@ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** - * Computes a point on the segment - * \param pt [out] point on segment - * \param t [in] point's parameter [t=0 => pt = mP0, t=1 => pt = mP1] + * Computes a IcePoint on the segment + * \param pt [out] IcePoint on segment + * \param t [in] IcePoint's parameter [t=0 => pt = mP0, t=1 => pt = mP1] */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - inline_ void ComputePoint(Point& pt, float t) const { pt = mP0 + t * (mP1 - mP0); } + inline_ void ComputePoint(IcePoint& pt, float t) const { pt = mP0 + t * (mP1 - mP0); } - float SquareDistance(const Point& point, float* t=null) const; - inline_ float Distance(const Point& point, float* t=null) const { return sqrtf(SquareDistance(point, t)); } + float SquareDistance(const IcePoint& IcePoint, float* t=null) const; + inline_ float Distance(const IcePoint& IcePoint, float* t=null) const { return sqrtf(SquareDistance(IcePoint, t)); } - Point mP0; //!< Start of segment - Point mP1; //!< End of segment + IcePoint mP0; //!< Start of segment + IcePoint mP1; //!< End of segment }; #endif // __ICESEGMENT_H__ diff --git a/Opcode/Ice/IceTriangle.cpp b/Opcode/Ice/IceTriangle.cpp index ef89109..69a858f 100644 --- a/Opcode/Ice/IceTriangle.cpp +++ b/Opcode/Ice/IceTriangle.cpp @@ -24,7 +24,7 @@ using namespace IceMaths; */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -static sdword VPlaneSideEps(const Point& v, const Plane& plane, float epsilon) +static sdword VPlaneSideEps(const IcePoint& v, const Plane& plane, float epsilon) { // Compute distance from current vertex to the plane float Dist = plane.Distance(v); @@ -42,7 +42,7 @@ static sdword VPlaneSideEps(const Point& v, const Plane& plane, float epsilon) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void Triangle::Flip() { - Point Tmp = mVerts[1]; + IcePoint Tmp = mVerts[1]; mVerts[1] = mVerts[2]; mVerts[2] = Tmp; } @@ -55,9 +55,9 @@ void Triangle::Flip() /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// float Triangle::Area() const { - const Point& p0 = mVerts[0]; - const Point& p1 = mVerts[1]; - const Point& p2 = mVerts[2]; + const IcePoint& p0 = mVerts[0]; + const IcePoint& p1 = mVerts[1]; + const IcePoint& p2 = mVerts[2]; return ((p0 - p1)^(p0 - p2)).Magnitude() * 0.5f; } @@ -69,9 +69,9 @@ float Triangle::Area() const /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// float Triangle::Perimeter() const { - const Point& p0 = mVerts[0]; - const Point& p1 = mVerts[1]; - const Point& p2 = mVerts[2]; + const IcePoint& p0 = mVerts[0]; + const IcePoint& p1 = mVerts[1]; + const IcePoint& p2 = mVerts[2]; return p0.Distance(p1) + p0.Distance(p2) + p1.Distance(p2); @@ -96,11 +96,11 @@ float Triangle::Compacity() const * \param normal [out] the computed normal */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void Triangle::Normal(Point& normal) const +void Triangle::Normal(IcePoint& normal) const { - const Point& p0 = mVerts[0]; - const Point& p1 = mVerts[1]; - const Point& p2 = mVerts[2]; + const IcePoint& p0 = mVerts[0]; + const IcePoint& p1 = mVerts[1]; + const IcePoint& p2 = mVerts[2]; normal = ((p0 - p1)^(p0 - p2)).Normalize(); } @@ -110,11 +110,11 @@ void Triangle::Normal(Point& normal) const * \param normal [out] the computed normal */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void Triangle::DenormalizedNormal(Point& normal) const +void Triangle::DenormalizedNormal(IcePoint& normal) const { - const Point& p0 = mVerts[0]; - const Point& p1 = mVerts[1]; - const Point& p2 = mVerts[2]; + const IcePoint& p0 = mVerts[0]; + const IcePoint& p1 = mVerts[1]; + const IcePoint& p2 = mVerts[2]; normal = ((p0 - p1)^(p0 - p2)); } @@ -124,11 +124,11 @@ void Triangle::DenormalizedNormal(Point& normal) const * \param center [out] the computed center */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void Triangle::Center(Point& center) const +void Triangle::Center(IcePoint& center) const { - const Point& p0 = mVerts[0]; - const Point& p1 = mVerts[1]; - const Point& p2 = mVerts[2]; + const IcePoint& p0 = mVerts[0]; + const IcePoint& p1 = mVerts[1]; + const IcePoint& p2 = mVerts[2]; center = (p0 + p1 + p2)*INV3; } @@ -171,9 +171,9 @@ void Triangle::ComputeMoment(Moment& m) Center(m.mCentroid); // Second-order components. Handle zero-area faces. - Point& p = mVerts[0]; - Point& q = mVerts[1]; - Point& r = mVerts[2]; + IcePoint& p = mVerts[0]; + IcePoint& q = mVerts[1]; + IcePoint& r = mVerts[2]; if(m.mArea==0.0f) { // This triangle has zero area. The second order components would be eliminated with the usual formula, so, for the @@ -242,24 +242,24 @@ float Triangle::MaxEdgeLength() const /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** - * Computes a point on the triangle according to the stabbing information. - * \param u,v [in] point's barycentric coordinates - * \param pt [out] point on triangle + * Computes a IcePoint on the triangle according to the stabbing information. + * \param u,v [in] IcePoint's barycentric coordinates + * \param pt [out] IcePoint on triangle * \param nearvtx [out] index of nearest vertex */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void Triangle::ComputePoint(float u, float v, Point& pt, udword* nearvtx) const +void Triangle::ComputePoint(float u, float v, IcePoint& pt, udword* nearvtx) const { - // Compute point coordinates + // Compute IcePoint coordinates pt = (1.0f - u - v)*mVerts[0] + u*mVerts[1] + v*mVerts[2]; // Compute nearest vertex if needed if(nearvtx) { // Compute distance vector - Point d(mVerts[0].SquareDistance(pt), // Distance^2 from vertex 0 to point on the face - mVerts[1].SquareDistance(pt), // Distance^2 from vertex 1 to point on the face - mVerts[2].SquareDistance(pt)); // Distance^2 from vertex 2 to point on the face + IcePoint d(mVerts[0].SquareDistance(pt), // Distance^2 from vertex 0 to IcePoint on the face + mVerts[1].SquareDistance(pt), // Distance^2 from vertex 1 to IcePoint on the face + mVerts[2].SquareDistance(pt)); // Distance^2 from vertex 2 to IcePoint on the face // Get smallest distance *nearvtx = d.SmallestAxis(); @@ -269,7 +269,7 @@ void Triangle::ComputePoint(float u, float v, Point& pt, udword* nearvtx) const void Triangle::Inflate(float fat_coeff, bool constant_border) { // Compute triangle center - Point TriangleCenter; + IcePoint TriangleCenter; Center(TriangleCenter); // Don't normalize? @@ -277,7 +277,7 @@ void Triangle::Inflate(float fat_coeff, bool constant_border) // Don't => add more to big triangles for(udword i=0;i<3;i++) { - Point v = mVerts[i] - TriangleCenter; + IcePoint v = mVerts[i] - TriangleCenter; if(constant_border) v.Normalize(); diff --git a/Opcode/Ice/IceTriangle.h b/Opcode/Ice/IceTriangle.h index 02e03ce..13eca37 100644 --- a/Opcode/Ice/IceTriangle.h +++ b/Opcode/Ice/IceTriangle.h @@ -33,7 +33,7 @@ //! Constructor inline_ Triangle() {} //! Constructor - inline_ Triangle(const Point& p0, const Point& p1, const Point& p2) { mVerts[0]=p0; mVerts[1]=p1; mVerts[2]=p2; } + inline_ Triangle(const IcePoint& p0, const IcePoint& p1, const IcePoint& p2) { mVerts[0]=p0; mVerts[1]=p1; mVerts[2]=p2; } //! Copy constructor inline_ Triangle(const Triangle& triangle) { @@ -44,16 +44,16 @@ //! Destructor inline_ ~Triangle() {} //! Vertices - Point mVerts[3]; + IcePoint mVerts[3]; // Methods void Flip(); float Area() const; float Perimeter() const; float Compacity() const; - void Normal(Point& normal) const; - void DenormalizedNormal(Point& normal) const; - void Center(Point& center) const; + void Normal(IcePoint& normal) const; + void DenormalizedNormal(IcePoint& normal) const; + void Center(IcePoint& center) const; inline_ Plane PlaneEquation() const { return Plane(mVerts[0], mVerts[1], mVerts[2]); } PartVal TestAgainstPlane(const Plane& plane, float epsilon) const; @@ -61,7 +61,7 @@ void ComputeMoment(Moment& m); float MinEdgeLength() const; float MaxEdgeLength() const; - void ComputePoint(float u, float v, Point& pt, udword* nearvtx=null) const; + void ComputePoint(float u, float v, IcePoint& pt, udword* nearvtx=null) const; void Inflate(float fat_coeff, bool constant_border); }; diff --git a/Opcode/Ice/IceTrilist.h b/Opcode/Ice/IceTrilist.h index 7a8d9de..d5f7c70 100644 --- a/Opcode/Ice/IceTrilist.h +++ b/Opcode/Ice/IceTrilist.h @@ -29,7 +29,7 @@ Add(tri.mVerts[2].x).Add(tri.mVerts[2].y).Add(tri.mVerts[2].z); } - void AddTri(const Point& p0, const Point& p1, const Point& p2) + void AddTri(const IcePoint& p0, const IcePoint& p1, const IcePoint& p2) { Add(p0.x).Add(p0.y).Add(p0.z); Add(p1.x).Add(p1.y).Add(p1.z); diff --git a/Opcode/OPC_AABBCollider.cpp b/Opcode/OPC_AABBCollider.cpp index 7d9346e..fe87d24 100644 --- a/Opcode/OPC_AABBCollider.cpp +++ b/Opcode/OPC_AABBCollider.cpp @@ -285,7 +285,7 @@ bool AABBCollider::Collide(AABBCache& cache, const CollisionAABB& box, const AAB * \return true if the AABB contains the whole box */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -inline_ BOOL AABBCollider::AABBContainsBox(const Point& bc, const Point& be) +inline_ BOOL AABBCollider::AABBContainsBox(const IcePoint& bc, const IcePoint& be) { if(mMin.x > bc.x - be.x) return FALSE; if(mMin.y > bc.y - be.y) return FALSE; @@ -371,8 +371,8 @@ void AABBCollider::_Collide(const AABBQuantizedNode* node) { // Dequantize box const QuantizedAABB& Box = node->mAABB; - const Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); - const Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); + const IcePoint Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); + const IcePoint Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); // Perform AABB-AABB overlap test if(!AABBAABBOverlap(Extents, Center)) return; @@ -403,8 +403,8 @@ void AABBCollider::_CollideNoPrimitiveTest(const AABBQuantizedNode* node) { // Dequantize box const QuantizedAABB& Box = node->mAABB; - const Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); - const Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); + const IcePoint Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); + const IcePoint Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); // Perform AABB-AABB overlap test if(!AABBAABBOverlap(Extents, Center)) return; @@ -479,8 +479,8 @@ void AABBCollider::_Collide(const AABBQuantizedNoLeafNode* node) { // Dequantize box const QuantizedAABB& Box = node->mAABB; - const Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); - const Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); + const IcePoint Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); + const IcePoint Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); // Perform AABB-AABB overlap test if(!AABBAABBOverlap(Extents, Center)) return; @@ -506,8 +506,8 @@ void AABBCollider::_CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node) { // Dequantize box const QuantizedAABB& Box = node->mAABB; - const Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); - const Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); + const IcePoint Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); + const IcePoint Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); // Perform AABB-AABB overlap test if(!AABBAABBOverlap(Extents, Center)) return; @@ -532,7 +532,7 @@ void AABBCollider::_CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node) void AABBCollider::_Collide(const AABBTreeNode* node) { // Perform AABB-AABB overlap test - Point Center, Extents; + IcePoint Center, Extents; node->GetAABB()->GetCenter(Center); node->GetAABB()->GetExtents(Extents); if(!AABBAABBOverlap(Center, Extents)) return; diff --git a/Opcode/OPC_AABBCollider.h b/Opcode/OPC_AABBCollider.h index 8e2b3e4..1d773f1 100644 --- a/Opcode/OPC_AABBCollider.h +++ b/Opcode/OPC_AABBCollider.h @@ -60,10 +60,10 @@ bool Collide(AABBCache& cache, const CollisionAABB& box, const AABBTree* tree); protected: CollisionAABB mBox; //!< Query box in (center, extents) form - Point mMin; //!< Query box min point - Point mMax; //!< Query box max point + IcePoint mMin; //!< Query box min IcePoint + IcePoint mMax; //!< Query box max IcePoint // Leaf description - Point mLeafVerts[3]; //!< Triangle vertices + IcePoint mLeafVerts[3]; //!< Triangle vertices // Internal methods void _Collide(const AABBCollisionNode* node); void _Collide(const AABBNoLeafNode* node); @@ -75,8 +75,8 @@ void _CollideNoPrimitiveTest(const AABBQuantizedNode* node); void _CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node); // Overlap tests - inline_ BOOL AABBContainsBox(const Point& bc, const Point& be); - inline_ BOOL AABBAABBOverlap(const Point& b, const Point& Pb); + inline_ BOOL AABBContainsBox(const IcePoint& bc, const IcePoint& be); + inline_ BOOL AABBAABBOverlap(const IcePoint& b, const IcePoint& Pb); inline_ BOOL TriBoxOverlap(); // Init methods BOOL InitQuery(AABBCache& cache, const CollisionAABB& box); diff --git a/Opcode/OPC_AABBTree.cpp b/Opcode/OPC_AABBTree.cpp index 5738f9b..e7ac631 100644 --- a/Opcode/OPC_AABBTree.cpp +++ b/Opcode/OPC_AABBTree.cpp @@ -164,7 +164,7 @@ bool AABBTreeNode::Subdivide(AABBTreeBuilder* builder) if(builder->mSettings.mRules & SPLIT_LARGEST_AXIS) { // Find the largest axis to split along - Point Extents; mBV.GetExtents(Extents); // Box extents + IcePoint Extents; mBV.GetExtents(Extents); // Box extents udword Axis = Extents.LargestAxis(); // Index of largest axis // Split along the axis @@ -176,7 +176,7 @@ bool AABBTreeNode::Subdivide(AABBTreeBuilder* builder) else if(builder->mSettings.mRules & SPLIT_SPLATTER_POINTS) { // Compute the means - Point Means(0.0f, 0.0f, 0.0f); + IcePoint Means(0.0f, 0.0f, 0.0f); for(udword i=0;iGetNbNodes(); AABBNoLeafNode* Nodes = (AABBNoLeafNode*)((AABBNoLeafTree*)mTree)->GetNodes(); while(Index--) @@ -367,7 +367,7 @@ bool HybridModel::Refit() Min.SetPlusInfinity(); Max.SetMinusInfinity(); - Point TmpMin, TmpMax; + IcePoint TmpMin, TmpMax; // Each leaf box has a set of triangles udword NbTris = CurrentLeaf.GetNbTriangles(); @@ -412,7 +412,7 @@ bool HybridModel::Refit() Min_.SetPlusInfinity(); Max_.SetMinusInfinity(); - Point TmpMin, TmpMax; + IcePoint TmpMin, TmpMax; // Each leaf box has a set of triangles udword NbTris = CurrentLeaf.GetNbTriangles(); diff --git a/Opcode/OPC_LSSAABBOverlap.h b/Opcode/OPC_LSSAABBOverlap.h index c36b250..0b03dbd 100644 --- a/Opcode/OPC_LSSAABBOverlap.h +++ b/Opcode/OPC_LSSAABBOverlap.h @@ -2,10 +2,10 @@ // Following code from Magic-Software (http://www.magic-software.com/) // A bit modified for Opcode -inline_ float OPC_PointAABBSqrDist(const Point& point, const Point& center, const Point& extents) +inline_ float OPC_PointAABBSqrDist(const IcePoint& Point, const IcePoint& center, const IcePoint& extents) { - // Compute coordinates of point in box coordinate system - Point Closest = point - center; + // Compute coordinates of IcePoint in box coordinate system + IcePoint Closest = Point - center; float SqrDistance = 0.0f; @@ -44,9 +44,9 @@ inline_ float OPC_PointAABBSqrDist(const Point& point, const Point& center, cons return SqrDistance; } -static void Face(int i0, int i1, int i2, Point& rkPnt, const Point& rkDir, const Point& extents, const Point& rkPmE, float* pfLParam, float& rfSqrDistance) +static void Face(int i0, int i1, int i2, IcePoint& rkPnt, const IcePoint& rkDir, const IcePoint& extents, const IcePoint& rkPmE, float* pfLParam, float& rfSqrDistance) { - Point kPpE; + IcePoint kPpE; float fLSqr, fInv, fTmp, fParam, fT, fDelta; kPpE[i1] = rkPnt[i1] + extents[i1]; @@ -244,9 +244,9 @@ static void Face(int i0, int i1, int i2, Point& rkPnt, const Point& rkDir, const } } -static void CaseNoZeros(Point& rkPnt, const Point& rkDir, const Point& extents, float* pfLParam, float& rfSqrDistance) +static void CaseNoZeros(IcePoint& rkPnt, const IcePoint& rkDir, const IcePoint& extents, float* pfLParam, float& rfSqrDistance) { - Point kPmE(rkPnt.x - extents.x, rkPnt.y - extents.y, rkPnt.z - extents.z); + IcePoint kPmE(rkPnt.x - extents.x, rkPnt.y - extents.y, rkPnt.z - extents.z); float fProdDxPy, fProdDyPx, fProdDzPx, fProdDxPz, fProdDzPy, fProdDyPz; @@ -284,7 +284,7 @@ static void CaseNoZeros(Point& rkPnt, const Point& rkDir, const Point& extents, } } -static void Case0(int i0, int i1, int i2, Point& rkPnt, const Point& rkDir, const Point& extents, float* pfLParam, float& rfSqrDistance) +static void Case0(int i0, int i1, int i2, IcePoint& rkPnt, const IcePoint& rkDir, const IcePoint& extents, float* pfLParam, float& rfSqrDistance) { float fPmE0 = rkPnt[i0] - extents[i0]; float fPmE1 = rkPnt[i1] - extents[i1]; @@ -361,7 +361,7 @@ static void Case0(int i0, int i1, int i2, Point& rkPnt, const Point& rkDir, cons } } -static void Case00(int i0, int i1, int i2, Point& rkPnt, const Point& rkDir, const Point& extents, float* pfLParam, float& rfSqrDistance) +static void Case00(int i0, int i1, int i2, IcePoint& rkPnt, const IcePoint& rkDir, const IcePoint& extents, float* pfLParam, float& rfSqrDistance) { float fDelta; @@ -397,7 +397,7 @@ static void Case00(int i0, int i1, int i2, Point& rkPnt, const Point& rkDir, con } } -static void Case000(Point& rkPnt, const Point& extents, float& rfSqrDistance) +static void Case000(IcePoint& rkPnt, const IcePoint& extents, float& rfSqrDistance) { float fDelta; @@ -441,12 +441,12 @@ static void Case000(Point& rkPnt, const Point& extents, float& rfSqrDistance) } } -static float SqrDistance(const Ray& rkLine, const Point& center, const Point& extents, float* pfLParam) +static float SqrDistance(const Ray& rkLine, const IcePoint& center, const IcePoint& extents, float* pfLParam) { // compute coordinates of line in box coordinate system - Point kDiff = rkLine.mOrig - center; - Point kPnt = kDiff; - Point kDir = rkLine.mDir; + IcePoint kDiff = rkLine.mOrig - center; + IcePoint kPnt = kDiff; + IcePoint kDir = rkLine.mDir; // Apply reflections so that direction vector has nonnegative components. bool bReflect[3]; @@ -499,7 +499,7 @@ static float SqrDistance(const Ray& rkLine, const Point& center, const Point& ex return fSqrDistance; } -inline_ float OPC_SegmentOBBSqrDist(const Segment& segment, const Point& c0, const Point& e0) +inline_ float OPC_SegmentOBBSqrDist(const Segment& segment, const IcePoint& c0, const IcePoint& e0) { float fLP; float fSqrDistance = SqrDistance(Ray(segment.GetOrigin(), segment.ComputeDirection()), c0, e0, &fLP); @@ -511,7 +511,7 @@ inline_ float OPC_SegmentOBBSqrDist(const Segment& segment, const Point& c0, con else return OPC_PointAABBSqrDist(segment.mP0, c0, e0); } -inline_ BOOL LSSCollider::LSSAABBOverlap(const Point& center, const Point& extents) +inline_ BOOL LSSCollider::LSSAABBOverlap(const IcePoint& center, const IcePoint& extents) { // Stats mNbVolumeBVTests++; diff --git a/Opcode/OPC_LSSCollider.cpp b/Opcode/OPC_LSSCollider.cpp index c1f21a8..059dd52 100644 --- a/Opcode/OPC_LSSCollider.cpp +++ b/Opcode/OPC_LSSCollider.cpp @@ -319,7 +319,7 @@ bool LSSCollider::Collide(LSSCache& cache, const LSS& lss, const AABBTree* tree) * \return true if the LSS contains the whole box */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -inline_ BOOL LSSCollider::LSSContainsBox(const Point& bc, const Point& be) +inline_ BOOL LSSCollider::LSSContainsBox(const IcePoint& bc, const IcePoint& be) { // Not implemented return FALSE; @@ -398,8 +398,8 @@ void LSSCollider::_Collide(const AABBQuantizedNode* node) { // Dequantize box const QuantizedAABB& Box = node->mAABB; - const Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); - const Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); + const IcePoint Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); + const IcePoint Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); // Perform LSS-AABB overlap test if(!LSSAABBOverlap(Center, Extents)) return; @@ -430,8 +430,8 @@ void LSSCollider::_CollideNoPrimitiveTest(const AABBQuantizedNode* node) { // Dequantize box const QuantizedAABB& Box = node->mAABB; - const Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); - const Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); + const IcePoint Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); + const IcePoint Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); // Perform LSS-AABB overlap test if(!LSSAABBOverlap(Center, Extents)) return; @@ -506,8 +506,8 @@ void LSSCollider::_Collide(const AABBQuantizedNoLeafNode* node) { // Dequantize box const QuantizedAABB& Box = node->mAABB; - const Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); - const Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); + const IcePoint Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); + const IcePoint Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); // Perform LSS-AABB overlap test if(!LSSAABBOverlap(Center, Extents)) return; @@ -533,8 +533,8 @@ void LSSCollider::_CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node) { // Dequantize box const QuantizedAABB& Box = node->mAABB; - const Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); - const Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); + const IcePoint Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); + const IcePoint Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); // Perform LSS-AABB overlap test if(!LSSAABBOverlap(Center, Extents)) return; @@ -559,7 +559,7 @@ void LSSCollider::_CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node) void LSSCollider::_Collide(const AABBTreeNode* node) { // Perform LSS-AABB overlap test - Point Center, Extents; + IcePoint Center, Extents; node->GetAABB()->GetCenter(Center); node->GetAABB()->GetExtents(Extents); if(!LSSAABBOverlap(Center, Extents)) return; diff --git a/Opcode/OPC_LSSCollider.h b/Opcode/OPC_LSSCollider.h index 7b69448..b5f07dc 100644 --- a/Opcode/OPC_LSSCollider.h +++ b/Opcode/OPC_LSSCollider.h @@ -24,8 +24,8 @@ { LSSCache() { - Previous.mP0 = Point(0.0f, 0.0f, 0.0f); - Previous.mP1 = Point(0.0f, 0.0f, 0.0f); + Previous.mP0 = IcePoint(0.0f, 0.0f, 0.0f); + Previous.mP1 = IcePoint(0.0f, 0.0f, 0.0f); Previous.mRadius = 0.0f; FatCoeff = 1.1f; } @@ -77,9 +77,9 @@ void _CollideNoPrimitiveTest(const AABBQuantizedNode* node); void _CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node); // Overlap tests - inline_ BOOL LSSContainsBox(const Point& bc, const Point& be); - inline_ BOOL LSSAABBOverlap(const Point& center, const Point& extents); - inline_ BOOL LSSTriOverlap(const Point& vert0, const Point& vert1, const Point& vert2); + inline_ BOOL LSSContainsBox(const IcePoint& bc, const IcePoint& be); + inline_ BOOL LSSAABBOverlap(const IcePoint& center, const IcePoint& extents); + inline_ BOOL LSSTriOverlap(const IcePoint& vert0, const IcePoint& vert1, const IcePoint& vert2); // Init methods BOOL InitQuery(LSSCache& cache, const LSS& lss, const Matrix4x4* worldl=null, const Matrix4x4* worldm=null); }; diff --git a/Opcode/OPC_LSSTriOverlap.h b/Opcode/OPC_LSSTriOverlap.h index 728ef87..b60ab88 100644 --- a/Opcode/OPC_LSSTriOverlap.h +++ b/Opcode/OPC_LSSTriOverlap.h @@ -3,13 +3,13 @@ static const float gs_fTolerance = 1e-05f; -static float OPC_PointTriangleSqrDist(const Point& point, const Point& p0, const Point& p1, const Point& p2) +static float OPC_PointTriangleSqrDist(const IcePoint& Point, const IcePoint& p0, const IcePoint& p1, const IcePoint& p2) { // Hook - Point TriEdge0 = p1 - p0; - Point TriEdge1 = p2 - p0; + IcePoint TriEdge0 = p1 - p0; + IcePoint TriEdge1 = p2 - p0; - Point kDiff = p0 - point; + IcePoint kDiff = p0 - Point; float fA00 = TriEdge0.SquareMagnitude(); float fA01 = TriEdge0 | TriEdge1; float fA11 = TriEdge1.SquareMagnitude(); @@ -54,7 +54,7 @@ static float OPC_PointTriangleSqrDist(const Point& point, const Point& p0, const } else // region 0 { - // minimum at interior point + // minimum at interior IcePoint if(fDet==0.0f) { fSqrDist = MAX_FLOAT; @@ -153,10 +153,10 @@ static float OPC_PointTriangleSqrDist(const Point& point, const Point& p0, const static float OPC_SegmentSegmentSqrDist(const Segment& rkSeg0, const Segment& rkSeg1) { // Hook - Point rkSeg0Direction = rkSeg0.ComputeDirection(); - Point rkSeg1Direction = rkSeg1.ComputeDirection(); + IcePoint rkSeg0Direction = rkSeg0.ComputeDirection(); + IcePoint rkSeg1Direction = rkSeg1.ComputeDirection(); - Point kDiff = rkSeg0.mP0 - rkSeg1.mP0; + IcePoint kDiff = rkSeg0.mP0 - rkSeg1.mP0; float fA00 = rkSeg0Direction.SquareMagnitude(); float fA01 = -rkSeg0Direction.Dot(rkSeg1Direction); float fA11 = rkSeg1Direction.SquareMagnitude(); @@ -352,16 +352,16 @@ inline_ float OPC_SegmentRaySqrDist(const Segment& rkSeg0, const Ray& rkSeg1) return OPC_SegmentSegmentSqrDist(rkSeg0, Segment(rkSeg1.mOrig, rkSeg1.mOrig + rkSeg1.mDir)); } -static float OPC_SegmentTriangleSqrDist(const Segment& segment, const Point& p0, const Point& p1, const Point& p2) +static float OPC_SegmentTriangleSqrDist(const Segment& segment, const IcePoint& p0, const IcePoint& p1, const IcePoint& p2) { // Hook - const Point TriEdge0 = p1 - p0; - const Point TriEdge1 = p2 - p0; + const IcePoint TriEdge0 = p1 - p0; + const IcePoint TriEdge1 = p2 - p0; - const Point& rkSegOrigin = segment.GetOrigin(); - Point rkSegDirection = segment.ComputeDirection(); + const IcePoint& rkSegOrigin = segment.GetOrigin(); + IcePoint rkSegDirection = segment.ComputeDirection(); - Point kDiff = p0 - rkSegOrigin; + IcePoint kDiff = p0 - rkSegOrigin; float fA00 = rkSegDirection.SquareMagnitude(); float fA01 = -rkSegDirection.Dot(TriEdge0); float fA02 = -rkSegDirection.Dot(TriEdge1); @@ -377,7 +377,7 @@ static float OPC_SegmentTriangleSqrDist(const Segment& segment, const Point& p0, float fDet = fA00*fCof00+fA01*fCof01+fA02*fCof02; Ray kTriSeg; - Point kPt; + IcePoint kPt; float fSqrDist, fSqrDist0; if(fabsf(fDet)>=gs_fTolerance) @@ -668,7 +668,7 @@ static float OPC_SegmentTriangleSqrDist(const Segment& segment, const Point& p0, return fabsf(fSqrDist); } -inline_ BOOL LSSCollider::LSSTriOverlap(const Point& vert0, const Point& vert1, const Point& vert2) +inline_ BOOL LSSCollider::LSSTriOverlap(const IcePoint& vert0, const IcePoint& vert1, const IcePoint& vert2) { // Stats mNbVolumePrimTests++; diff --git a/Opcode/OPC_MeshInterface.cpp b/Opcode/OPC_MeshInterface.cpp index 3a1d653..e47451e 100644 --- a/Opcode/OPC_MeshInterface.cpp +++ b/Opcode/OPC_MeshInterface.cpp @@ -81,7 +81,7 @@ * POINTERS: * * If you're internally using the following canonical structures: - * - a vertex made of three 32-bits floating point values + * - a vertex made of three 32-bits floating IcePoint values * - a triangle made of three 32-bits integer vertex references * ...then you may want to use pointers instead of callbacks. This is the same, except OPCODE will directly * use provided pointers to access the topology and geometry, without using a callback. It might be faster, @@ -134,7 +134,7 @@ MeshInterface::MeshInterface() : mVerts (null), #ifdef OPC_USE_STRIDE mTriStride (sizeof(IndexedTriangle)), - mVertexStride (sizeof(Point)), + mVertexStride (sizeof(IcePoint)), #endif #endif mNbTris (0), @@ -225,7 +225,7 @@ bool MeshInterface::SetCallback(RequestCallback callback, void* user_data) * \return true if success */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -bool MeshInterface::SetPointers(const IndexedTriangle* tris, const Point* verts) +bool MeshInterface::SetPointers(const IndexedTriangle* tris, const IcePoint* verts) { if(!tris || !verts) return SetIceError("MeshInterface::SetPointers: pointer is null", null); @@ -238,14 +238,14 @@ bool MeshInterface::SetPointers(const IndexedTriangle* tris, const Point* verts) /** * Strides control * \param tri_stride [in] size of a triangle in bytes. The first sizeof(IndexedTriangle) bytes are used to get vertex indices. - * \param vertex_stride [in] size of a vertex in bytes. The first sizeof(Point) bytes are used to get vertex position. + * \param vertex_stride [in] size of a vertex in bytes. The first sizeof(IcePoint) bytes are used to get vertex position. * \return true if success */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// bool MeshInterface::SetStrides(udword tri_stride, udword vertex_stride) { if(tri_stride= 0.0f; @@ -87,9 +87,9 @@ * \return true if success */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SetPointers(const IndexedTriangle* tris, const Point* verts); + bool SetPointers(const IndexedTriangle* tris, const IcePoint* verts); inline_ const IndexedTriangle* GetTris() const { return mTris; } - inline_ const Point* GetVerts() const { return mVerts; } + inline_ const IcePoint* GetVerts() const { return mVerts; } #ifdef OPC_USE_STRIDE // Strides settings @@ -98,11 +98,11 @@ /** * Strides control * \param tri_stride [in] size of a triangle in bytes. The first sizeof(IndexedTriangle) bytes are used to get vertex indices. - * \param vertex_stride [in] size of a vertex in bytes. The first sizeof(Point) bytes are used to get vertex position. + * \param vertex_stride [in] size of a vertex in bytes. The first sizeof(IcePoint) bytes are used to get vertex position. * \return true if success */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - bool SetStrides(udword tri_stride=sizeof(IndexedTriangle), udword vertex_stride=sizeof(Point)); + bool SetStrides(udword tri_stride=sizeof(IndexedTriangle), udword vertex_stride=sizeof(IcePoint)); inline_ udword GetTriStride() const { return mTriStride; } inline_ udword GetVertexStride() const { return mVertexStride; } #endif @@ -122,9 +122,9 @@ #else #ifdef OPC_USE_STRIDE const IndexedTriangle* T = (const IndexedTriangle*)(((ubyte*)mTris) + index * mTriStride); - vp.Vertex[0] = (const Point*)(((ubyte*)mVerts) + T->mVRef[0] * mVertexStride); - vp.Vertex[1] = (const Point*)(((ubyte*)mVerts) + T->mVRef[1] * mVertexStride); - vp.Vertex[2] = (const Point*)(((ubyte*)mVerts) + T->mVRef[2] * mVertexStride); + vp.Vertex[0] = (const IcePoint*)(((ubyte*)mVerts) + T->mVRef[0] * mVertexStride); + vp.Vertex[1] = (const IcePoint*)(((ubyte*)mVerts) + T->mVRef[1] * mVertexStride); + vp.Vertex[2] = (const IcePoint*)(((ubyte*)mVerts) + T->mVRef[2] * mVertexStride); #else const IndexedTriangle* T = &mTris[index]; vp.Vertex[0] = &mVerts[T->mVRef[0]]; @@ -171,7 +171,7 @@ #else // User pointers const IndexedTriangle* mTris; //!< Array of indexed triangles - const Point* mVerts; //!< Array of vertices + const IcePoint* mVerts; //!< Array of vertices #ifdef OPC_USE_STRIDE udword mTriStride; //!< Possible triangle stride in bytes [Opcode 1.3] udword mVertexStride; //!< Possible vertex stride in bytes [Opcode 1.3] diff --git a/Opcode/OPC_OBBCollider.cpp b/Opcode/OPC_OBBCollider.cpp index a784339..d8cf63f 100644 --- a/Opcode/OPC_OBBCollider.cpp +++ b/Opcode/OPC_OBBCollider.cpp @@ -308,7 +308,7 @@ BOOL OBBCollider::InitQuery(OBBCache& cache, const OBB& box, const Matrix4x4* wo { for(udword j=0;j<3;j++) { - // Epsilon value prevents floating-point inaccuracies (strategy borrowed from RAPID) + // Epsilon value prevents floating-IcePoint inaccuracies (strategy borrowed from RAPID) mAR.m[i][j] = 1e-6f + fabsf(mRBoxToModel.m[i][j]); } } @@ -343,7 +343,7 @@ BOOL OBBCollider::InitQuery(OBBCache& cache, const OBB& box, const Matrix4x4* wo * \return true if the OBB contains the whole box */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -inline_ BOOL OBBCollider::OBBContainsBox(const Point& bc, const Point& be) +inline_ BOOL OBBCollider::OBBContainsBox(const IcePoint& bc, const IcePoint& be) { // I assume if all 8 box vertices are inside the OBB, so does the whole box. // Sounds ok but maybe there's a better way? @@ -354,7 +354,7 @@ inline_ BOOL OBBCollider::OBBContainsBox(const Point& bc, const Point& be) f = p.x * mRModelToBox.m[0][1] + p.y * mRModelToBox.m[1][1] + p.z * mRModelToBox.m[2][1]; if(f>mB0.y || fmB0.z || fmAABB; - const Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); - const Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); + const IcePoint Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); + const IcePoint Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); // Perform OBB-AABB overlap test if(!BoxBoxOverlap(Extents, Center)) return; @@ -498,8 +498,8 @@ void OBBCollider::_CollideNoPrimitiveTest(const AABBQuantizedNode* node) { // Dequantize box const QuantizedAABB& Box = node->mAABB; - const Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); - const Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); + const IcePoint Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); + const IcePoint Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); // Perform OBB-AABB overlap test if(!BoxBoxOverlap(Extents, Center)) return; @@ -574,8 +574,8 @@ void OBBCollider::_Collide(const AABBQuantizedNoLeafNode* node) { // Dequantize box const QuantizedAABB& Box = node->mAABB; - const Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); - const Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); + const IcePoint Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); + const IcePoint Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); // Perform OBB-AABB overlap test if(!BoxBoxOverlap(Extents, Center)) return; @@ -601,8 +601,8 @@ void OBBCollider::_CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node) { // Dequantize box const QuantizedAABB& Box = node->mAABB; - const Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); - const Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); + const IcePoint Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); + const IcePoint Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); // Perform OBB-AABB overlap test if(!BoxBoxOverlap(Extents, Center)) return; diff --git a/Opcode/OPC_OBBCollider.h b/Opcode/OPC_OBBCollider.h index b5c1de2..0601b20 100644 --- a/Opcode/OPC_OBBCollider.h +++ b/Opcode/OPC_OBBCollider.h @@ -85,12 +85,12 @@ Matrix3x3 mAR; //!< Absolute rotation matrix Matrix3x3 mRModelToBox; //!< Rotation from model space to obb space Matrix3x3 mRBoxToModel; //!< Rotation from obb space to model space - Point mTModelToBox; //!< Translation from model space to obb space - Point mTBoxToModel; //!< Translation from obb space to model space + IcePoint mTModelToBox; //!< Translation from model space to obb space + IcePoint mTBoxToModel; //!< Translation from obb space to model space - Point mBoxExtents; - Point mB0; //!< - mTModelToBox + mBoxExtents - Point mB1; //!< - mTModelToBox - mBoxExtents + IcePoint mBoxExtents; + IcePoint mB0; //!< - mTModelToBox + mBoxExtents + IcePoint mB1; //!< - mTModelToBox - mBoxExtents float mBBx1; float mBBy1; @@ -107,7 +107,7 @@ float mBB_9; // Leaf description - Point mLeafVerts[3]; //!< Triangle vertices + IcePoint mLeafVerts[3]; //!< Triangle vertices // Settings bool mFullBoxBoxTest; //!< Perform full BV-BV tests (true) or SAT-lite tests (false) // Internal methods @@ -120,8 +120,8 @@ void _CollideNoPrimitiveTest(const AABBQuantizedNode* node); void _CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node); // Overlap tests - inline_ BOOL OBBContainsBox(const Point& bc, const Point& be); - inline_ BOOL BoxBoxOverlap(const Point& extents, const Point& center); + inline_ BOOL OBBContainsBox(const IcePoint& bc, const IcePoint& be); + inline_ BOOL BoxBoxOverlap(const IcePoint& extents, const IcePoint& center); inline_ BOOL TriBoxOverlap(); // Init methods BOOL InitQuery(OBBCache& cache, const OBB& box, const Matrix4x4* worldb=null, const Matrix4x4* worldm=null); diff --git a/Opcode/OPC_OptimizedTree.cpp b/Opcode/OPC_OptimizedTree.cpp index aed4f64..e2abe60 100644 --- a/Opcode/OPC_OptimizedTree.cpp +++ b/Opcode/OPC_OptimizedTree.cpp @@ -348,7 +348,7 @@ bool AABBNoLeafTree::Build(AABBTree* tree) return true; } -inline_ void ComputeMinMax(Point& min, Point& max, const VertexPointers& vp) +inline_ void ComputeMinMax(IcePoint& min, IcePoint& max, const VertexPointers& vp) { // Compute triangle's AABB = a leaf box #ifdef OPC_USE_FCOMI // a 15% speedup on my machine, not much @@ -384,8 +384,8 @@ bool AABBNoLeafTree::Refit(const MeshInterface* mesh_interface) // Bottom-up update VertexPointers VP; - Point Min,Max; - Point Min_,Max_; + IcePoint Min,Max; + IcePoint Min_,Max_; udword Index = mNbNodes; while(Index--) { @@ -476,8 +476,8 @@ bool AABBNoLeafTree::Walk(GenericWalkingCallback callback, void* user_data) cons // a single extents. While extents would be the biggest, the center wouldn't. #define FIND_MAX_VALUES \ /* Get max values */ \ - Point CMax(MIN_FLOAT, MIN_FLOAT, MIN_FLOAT); \ - Point EMax(MIN_FLOAT, MIN_FLOAT, MIN_FLOAT); \ + IcePoint CMax(MIN_FLOAT, MIN_FLOAT, MIN_FLOAT); \ + IcePoint EMax(MIN_FLOAT, MIN_FLOAT, MIN_FLOAT); \ for(udword i=0;iCMax.x) CMax.x = fabsf(Nodes[i].mAABB.mCenter.x); \ @@ -494,7 +494,7 @@ bool AABBNoLeafTree::Walk(GenericWalkingCallback callback, void* user_data) cons if(!gFixQuantized) nbe++; \ \ /* Compute quantization coeffs */ \ - Point CQuantCoeff, EQuantCoeff; \ + IcePoint CQuantCoeff, EQuantCoeff; \ CQuantCoeff.x = CMax.x!=0.0f ? float((1<=Data->Closest->mDistance) return; - // Discard face if hit point is smaller than min limit. This mainly happens when the face is in front + // Discard face if hit IcePoint is smaller than min limit. This mainly happens when the face is in front // of the near clip plane (or straddles it). If we keep the face nonetheless, the user can select an // object that he may not even be able to see, which is very annoying. if(hit.mDistance<=Data->MinLimit) return; diff --git a/Opcode/OPC_Picking.h b/Opcode/OPC_Picking.h index 74a87b2..fa5dfc0 100644 --- a/Opcode/OPC_Picking.h +++ b/Opcode/OPC_Picking.h @@ -39,7 +39,7 @@ OPCODE_API bool Picking( CollisionFace& picked_face, const Ray& world_ray, const Model& model, const Matrix4x4* world, - float min_dist, float max_dist, const Point& view_point, CullModeCallback callback, void* user_data); + float min_dist, float max_dist, const IcePoint& view_point, CullModeCallback callback, void* user_data); #endif #endif //__OPC_PICKING_H__ \ No newline at end of file diff --git a/Opcode/OPC_PlanesAABBOverlap.h b/Opcode/OPC_PlanesAABBOverlap.h index 010b82f..80b8bce 100644 --- a/Opcode/OPC_PlanesAABBOverlap.h +++ b/Opcode/OPC_PlanesAABBOverlap.h @@ -11,7 +11,7 @@ * \return TRUE if boxes overlap planes */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -inline_ BOOL PlanesCollider::PlanesAABBOverlap(const Point& center, const Point& extents, udword& out_clip_mask, udword in_clip_mask) +inline_ BOOL PlanesCollider::PlanesAABBOverlap(const IcePoint& center, const IcePoint& extents, udword& out_clip_mask, udword in_clip_mask) { // Stats mNbVolumeBVTests++; @@ -21,7 +21,7 @@ inline_ BOOL PlanesCollider::PlanesAABBOverlap(const Point& center, const Point& // Evaluate through all active frustum planes. We determine the relation // between the AABB and a plane by using the concept of "near" and "far" // vertices originally described by Zhang (and later by Möller). Our - // variant here uses 3 fabs ops, 6 muls, 7 adds and two floating point + // variant here uses 3 fabs ops, 6 muls, 7 adds and two floating IcePoint // comparisons per plane. The routine early-exits if the AABB is found // to be outside any of the planes. The loop also constructs a new output // clip mask. Most FPUs have a native single-cycle fabsf() operation. diff --git a/Opcode/OPC_PlanesCollider.cpp b/Opcode/OPC_PlanesCollider.cpp index 89b507c..b8ada6f 100644 --- a/Opcode/OPC_PlanesCollider.cpp +++ b/Opcode/OPC_PlanesCollider.cpp @@ -335,8 +335,8 @@ void PlanesCollider::_Collide(const AABBQuantizedNode* node, udword clip_mask) { // Dequantize box const QuantizedAABB& Box = node->mAABB; - const Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); - const Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); + const IcePoint Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); + const IcePoint Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); // Test the box against the planes. If the box is completely culled, so are its children, hence we exit. udword OutClipMask; @@ -369,8 +369,8 @@ void PlanesCollider::_CollideNoPrimitiveTest(const AABBQuantizedNode* node, udwo { // Dequantize box const QuantizedAABB& Box = node->mAABB; - const Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); - const Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); + const IcePoint Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); + const IcePoint Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); // Test the box against the planes. If the box is completely culled, so are its children, hence we exit. udword OutClipMask; @@ -451,8 +451,8 @@ void PlanesCollider::_Collide(const AABBQuantizedNoLeafNode* node, udword clip_m { // Dequantize box const QuantizedAABB& Box = node->mAABB; - const Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); - const Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); + const IcePoint Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); + const IcePoint Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); // Test the box against the planes. If the box is completely culled, so are its children, hence we exit. udword OutClipMask; @@ -480,8 +480,8 @@ void PlanesCollider::_CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node { // Dequantize box const QuantizedAABB& Box = node->mAABB; - const Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); - const Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); + const IcePoint Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); + const IcePoint Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); // Test the box against the planes. If the box is completely culled, so are its children, hence we exit. udword OutClipMask; diff --git a/Opcode/OPC_PlanesCollider.h b/Opcode/OPC_PlanesCollider.h index 8ac63e8..5fea18d 100644 --- a/Opcode/OPC_PlanesCollider.h +++ b/Opcode/OPC_PlanesCollider.h @@ -100,7 +100,7 @@ void _CollideNoPrimitiveTest(const AABBQuantizedNode* node, udword clip_mask); void _CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node, udword clip_mask); // Overlap tests - inline_ BOOL PlanesAABBOverlap(const Point& center, const Point& extents, udword& out_clip_mask, udword in_clip_mask); + inline_ BOOL PlanesAABBOverlap(const IcePoint& center, const IcePoint& extents, udword& out_clip_mask, udword in_clip_mask); inline_ BOOL PlanesTriOverlap(udword in_clip_mask); // Init methods BOOL InitQuery(PlanesCache& cache, const Plane* planes, udword nb_planes, const Matrix4x4* worldm=null); diff --git a/Opcode/OPC_RayAABBOverlap.h b/Opcode/OPC_RayAABBOverlap.h index 4330652..b64661f 100644 --- a/Opcode/OPC_RayAABBOverlap.h +++ b/Opcode/OPC_RayAABBOverlap.h @@ -1,7 +1,7 @@ // Opcode 1.1: ray-AABB overlap tests based on Woo's code // Opcode 1.2: ray-AABB overlap tests based on the separating axis theorem // -// The point of intersection is not computed anymore. The distance to impact is not needed anymore +// The IcePoint of intersection is not computed anymore. The distance to impact is not needed anymore // since we now have two different queries for segments or rays. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -12,7 +12,7 @@ * \return true on overlap */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -inline_ BOOL RayCollider::SegmentAABBOverlap(const Point& center, const Point& extents) +inline_ BOOL RayCollider::SegmentAABBOverlap(const IcePoint& center, const IcePoint& extents) { // Stats mNbRayBVTests++; @@ -37,7 +37,7 @@ inline_ BOOL RayCollider::SegmentAABBOverlap(const Point& center, const Point& e * \return true on overlap */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -inline_ BOOL RayCollider::RayAABBOverlap(const Point& center, const Point& extents) +inline_ BOOL RayCollider::RayAABBOverlap(const IcePoint& center, const IcePoint& extents) { // Stats mNbRayBVTests++; diff --git a/Opcode/OPC_RayCollider.cpp b/Opcode/OPC_RayCollider.cpp index 92c5a9b..875ae12 100644 --- a/Opcode/OPC_RayCollider.cpp +++ b/Opcode/OPC_RayCollider.cpp @@ -26,7 +26,7 @@ * - d = distance between P0 and P1 * - Origin = P0 * - Direction = (P1 - P0) / d = normalized direction vector - * - A parameter t such as a point P on the line (P0,P1) is P = Origin + t * Direction + * - A parameter t such as a IcePoint P on the line (P0,P1) is P = Origin + t * Direction * - t = 0 --> P = P0 * - t = d --> P = P1 * @@ -34,8 +34,8 @@ * * struct Ray * { - * Point Origin; - * Point Direction; + * IcePoint Origin; + * IcePoint Direction; * }; * * But it actually maps three different things: @@ -178,7 +178,7 @@ using namespace Opcode; /* Perform ray-tri overlap test and return */ \ if(RayTriOverlap(*VP.Vertex[0], *VP.Vertex[1], *VP.Vertex[2])) \ { \ - /* Intersection point is valid if dist < segment's length */ \ + /* Intersection IcePoint is valid if dist < segment's length */ \ /* We know dist>0 so we can use integers */ \ if(IR(mStabbedFace.mDistance)0.0f && mStabbedFace.mDistancemAABB; - const Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); - const Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); + const IcePoint Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); + const IcePoint Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); // Perform Segment-AABB overlap test if(!SegmentAABBOverlap(Center, Extents)) return; @@ -575,8 +575,8 @@ void RayCollider::_SegmentStab(const AABBQuantizedNoLeafNode* node) { // Dequantize box const QuantizedAABB& Box = node->mAABB; - const Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); - const Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); + const IcePoint Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); + const IcePoint Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); // Perform Segment-AABB overlap test if(!SegmentAABBOverlap(Center, Extents)) return; @@ -606,7 +606,7 @@ void RayCollider::_SegmentStab(const AABBQuantizedNoLeafNode* node) void RayCollider::_SegmentStab(const AABBTreeNode* node, Container& box_indices) { // Test the box against the segment - Point Center, Extents; + IcePoint Center, Extents; node->GetAABB()->GetCenter(Center); node->GetAABB()->GetExtents(Extents); if(!SegmentAABBOverlap(Center, Extents)) return; @@ -657,8 +657,8 @@ void RayCollider::_RayStab(const AABBQuantizedNode* node) { // Dequantize box const QuantizedAABB& Box = node->mAABB; - const Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); - const Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); + const IcePoint Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); + const IcePoint Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); // Perform Ray-AABB overlap test if(!RayAABBOverlap(Center, Extents)) return; @@ -713,8 +713,8 @@ void RayCollider::_RayStab(const AABBQuantizedNoLeafNode* node) { // Dequantize box const QuantizedAABB& Box = node->mAABB; - const Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); - const Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); + const IcePoint Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); + const IcePoint Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); // Perform Ray-AABB overlap test if(!RayAABBOverlap(Center, Extents)) return; @@ -744,7 +744,7 @@ void RayCollider::_RayStab(const AABBQuantizedNoLeafNode* node) void RayCollider::_RayStab(const AABBTreeNode* node, Container& box_indices) { // Test the box against the ray - Point Center, Extents; + IcePoint Center, Extents; node->GetAABB()->GetCenter(Center); node->GetAABB()->GetExtents(Extents); if(!RayAABBOverlap(Center, Extents)) return; diff --git a/Opcode/OPC_RayCollider.h b/Opcode/OPC_RayCollider.h index f3b0065..64dc2b4 100644 --- a/Opcode/OPC_RayCollider.h +++ b/Opcode/OPC_RayCollider.h @@ -177,10 +177,10 @@ protected: // Ray in local space - Point mOrigin; //!< Ray origin - Point mDir; //!< Ray direction (normalized) - Point mFDir; //!< fabsf(mDir) - Point mData, mData2; + IcePoint mOrigin; //!< Ray origin + IcePoint mDir; //!< Ray direction (normalized) + IcePoint mFDir; //!< fabsf(mDir) + IcePoint mData, mData2; // Stabbed faces CollisionFace mStabbedFace; //!< Current stabbed face #ifdef OPC_RAYHIT_CALLBACK @@ -195,8 +195,8 @@ // In-out test udword mNbIntersections; //!< Number of valid intersections // Dequantization coeffs - Point mCenterCoeff; - Point mExtentsCoeff; + IcePoint mCenterCoeff; + IcePoint mExtentsCoeff; // Settings float mMaxDist; //!< Valid segment on the ray #ifndef OPC_RAYHIT_CALLBACK @@ -215,9 +215,9 @@ void _RayStab(const AABBQuantizedNoLeafNode* node); void _RayStab(const AABBTreeNode* node, Container& box_indices); // Overlap tests - inline_ BOOL RayAABBOverlap(const Point& center, const Point& extents); - inline_ BOOL SegmentAABBOverlap(const Point& center, const Point& extents); - inline_ BOOL RayTriOverlap(const Point& vert0, const Point& vert1, const Point& vert2); + inline_ BOOL RayAABBOverlap(const IcePoint& center, const IcePoint& extents); + inline_ BOOL SegmentAABBOverlap(const IcePoint& center, const IcePoint& extents); + inline_ BOOL RayTriOverlap(const IcePoint& vert0, const IcePoint& vert1, const IcePoint& vert2); // Init methods BOOL InitQuery(const Ray& world_ray, const Matrix4x4* world=null, udword* face_id=null); }; diff --git a/Opcode/OPC_RayTriOverlap.h b/Opcode/OPC_RayTriOverlap.h index 550effc..6991434 100644 --- a/Opcode/OPC_RayTriOverlap.h +++ b/Opcode/OPC_RayTriOverlap.h @@ -13,17 +13,17 @@ * \return true on overlap. mStabbedFace is filled with relevant info. */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -inline_ BOOL RayCollider::RayTriOverlap(const Point& vert0, const Point& vert1, const Point& vert2) +inline_ BOOL RayCollider::RayTriOverlap(const IcePoint& vert0, const IcePoint& vert1, const IcePoint& vert2) { // Stats mNbRayPrimTests++; // Find vectors for two edges sharing vert0 - Point edge1 = vert1 - vert0; - Point edge2 = vert2 - vert0; + IcePoint edge1 = vert1 - vert0; + IcePoint edge2 = vert2 - vert0; // Begin calculating determinant - also used to calculate U parameter - Point pvec = mDir^edge2; + IcePoint pvec = mDir^edge2; // If determinant is near zero, ray lies in plane of triangle float det = edge1|pvec; @@ -34,7 +34,7 @@ inline_ BOOL RayCollider::RayTriOverlap(const Point& vert0, const Point& vert1, // From here, det is > 0. So we can use integer cmp. // Calculate distance from vert0 to ray origin - Point tvec = mOrigin - vert0; + IcePoint tvec = mOrigin - vert0; // Calculate U parameter and test bounds mStabbedFace.mU = tvec|pvec; @@ -42,7 +42,7 @@ inline_ BOOL RayCollider::RayTriOverlap(const Point& vert0, const Point& vert1, if(IS_NEGATIVE_FLOAT(mStabbedFace.mU) || IR(mStabbedFace.mU)>IR(det)) return FALSE; // Prepare to test V parameter - Point qvec = tvec^edge1; + IcePoint qvec = tvec^edge1; // Calculate V parameter and test bounds mStabbedFace.mV = mDir|qvec; @@ -51,7 +51,7 @@ inline_ BOOL RayCollider::RayTriOverlap(const Point& vert0, const Point& vert1, // Calculate t, scale parameters, ray intersects triangle mStabbedFace.mDistance = edge2|qvec; // Det > 0 so we can early exit here - // Intersection point is valid if distance is positive (else it can just be a face behind the orig point) + // Intersection IcePoint is valid if distance is positive (else it can just be a face behind the orig IcePoint) if(IS_NEGATIVE_FLOAT(mStabbedFace.mDistance)) return FALSE; // Else go on float OneOverDet = 1.0f / det; @@ -66,7 +66,7 @@ inline_ BOOL RayCollider::RayTriOverlap(const Point& vert0, const Point& vert1, float OneOverDet = 1.0f / det; // Calculate distance from vert0 to ray origin - Point tvec = mOrigin - vert0; + IcePoint tvec = mOrigin - vert0; // Calculate U parameter and test bounds mStabbedFace.mU = (tvec|pvec) * OneOverDet; @@ -74,7 +74,7 @@ inline_ BOOL RayCollider::RayTriOverlap(const Point& vert0, const Point& vert1, if(IS_NEGATIVE_FLOAT(mStabbedFace.mU) || IR(mStabbedFace.mU)>IEEE_1_0) return FALSE; // prepare to test V parameter - Point qvec = tvec^edge1; + IcePoint qvec = tvec^edge1; // Calculate V parameter and test bounds mStabbedFace.mV = (mDir|qvec) * OneOverDet; @@ -82,7 +82,7 @@ inline_ BOOL RayCollider::RayTriOverlap(const Point& vert0, const Point& vert1, // Calculate t, ray intersects triangle mStabbedFace.mDistance = (edge2|qvec) * OneOverDet; - // Intersection point is valid if distance is positive (else it can just be a face behind the orig point) + // Intersection IcePoint is valid if distance is positive (else it can just be a face behind the orig IcePoint) if(IS_NEGATIVE_FLOAT(mStabbedFace.mDistance)) return FALSE; } return TRUE; diff --git a/Opcode/OPC_SphereAABBOverlap.h b/Opcode/OPC_SphereAABBOverlap.h index 8a50aa9..a5bd35b 100644 --- a/Opcode/OPC_SphereAABBOverlap.h +++ b/Opcode/OPC_SphereAABBOverlap.h @@ -6,7 +6,7 @@ * \return TRUE on overlap */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -inline_ BOOL SphereCollider::SphereAABBOverlap(const Point& center, const Point& extents) +inline_ BOOL SphereCollider::SphereAABBOverlap(const IcePoint& center, const IcePoint& extents) { // Stats mNbVolumeBVTests++; @@ -93,8 +93,8 @@ inline_ BOOL SphereCollider::SphereAABBOverlap(const Point& center, const Point& //#endif #ifdef OLDIES -// Point Min = center - extents; -// Point Max = center + extents; +// IcePoint Min = center - extents; +// IcePoint Max = center + extents; float d = 0.0f; diff --git a/Opcode/OPC_SphereCollider.cpp b/Opcode/OPC_SphereCollider.cpp index 4f2de83..c584c97 100644 --- a/Opcode/OPC_SphereCollider.cpp +++ b/Opcode/OPC_SphereCollider.cpp @@ -308,11 +308,11 @@ bool SphereCollider::Collide(SphereCache& cache, const Sphere& sphere, const AAB * \return true if the sphere contains the whole box */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -inline_ BOOL SphereCollider::SphereContainsBox(const Point& bc, const Point& be) +inline_ BOOL SphereCollider::SphereContainsBox(const IcePoint& bc, const IcePoint& be) { // I assume if all 8 box vertices are inside the sphere, so does the whole box. // Sounds ok but maybe there's a better way? - Point p; + IcePoint p; p.x=bc.x+be.x; p.y=bc.y+be.y; p.z=bc.z+be.z; if(mCenter.SquareDistance(p)>=mRadius2) return FALSE; p.x=bc.x-be.x; if(mCenter.SquareDistance(p)>=mRadius2) return FALSE; p.x=bc.x+be.x; p.y=bc.y-be.y; if(mCenter.SquareDistance(p)>=mRadius2) return FALSE; @@ -398,8 +398,8 @@ void SphereCollider::_Collide(const AABBQuantizedNode* node) { // Dequantize box const QuantizedAABB& Box = node->mAABB; - const Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); - const Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); + const IcePoint Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); + const IcePoint Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); // Perform Sphere-AABB overlap test if(!SphereAABBOverlap(Center, Extents)) return; @@ -430,8 +430,8 @@ void SphereCollider::_CollideNoPrimitiveTest(const AABBQuantizedNode* node) { // Dequantize box const QuantizedAABB& Box = node->mAABB; - const Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); - const Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); + const IcePoint Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); + const IcePoint Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); // Perform Sphere-AABB overlap test if(!SphereAABBOverlap(Center, Extents)) return; @@ -506,8 +506,8 @@ void SphereCollider::_Collide(const AABBQuantizedNoLeafNode* node) { // Dequantize box const QuantizedAABB& Box = node->mAABB; - const Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); - const Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); + const IcePoint Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); + const IcePoint Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); // Perform Sphere-AABB overlap test if(!SphereAABBOverlap(Center, Extents)) return; @@ -533,8 +533,8 @@ void SphereCollider::_CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node { // Dequantize box const QuantizedAABB& Box = node->mAABB; - const Point Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); - const Point Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); + const IcePoint Center(float(Box.mCenter[0]) * mCenterCoeff.x, float(Box.mCenter[1]) * mCenterCoeff.y, float(Box.mCenter[2]) * mCenterCoeff.z); + const IcePoint Extents(float(Box.mExtents[0]) * mExtentsCoeff.x, float(Box.mExtents[1]) * mExtentsCoeff.y, float(Box.mExtents[2]) * mExtentsCoeff.z); // Perform Sphere-AABB overlap test if(!SphereAABBOverlap(Center, Extents)) return; @@ -559,7 +559,7 @@ void SphereCollider::_CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node void SphereCollider::_Collide(const AABBTreeNode* node) { // Perform Sphere-AABB overlap test - Point Center, Extents; + IcePoint Center, Extents; node->GetAABB()->GetCenter(Center); node->GetAABB()->GetExtents(Extents); if(!SphereAABBOverlap(Center, Extents)) return; diff --git a/Opcode/OPC_SphereCollider.h b/Opcode/OPC_SphereCollider.h index aa53fdf..ee7a278 100644 --- a/Opcode/OPC_SphereCollider.h +++ b/Opcode/OPC_SphereCollider.h @@ -26,7 +26,7 @@ ~SphereCache() {} // Cached faces signature - Point Center; //!< Sphere used when performing the query resulting in cached faces + IcePoint Center; //!< Sphere used when performing the query resulting in cached faces float FatRadius2; //!< Sphere used when performing the query resulting in cached faces // User settings float FatCoeff; //!< mRadius2 multiplier used to create a fat sphere @@ -61,7 +61,7 @@ bool Collide(SphereCache& cache, const Sphere& sphere, const AABBTree* tree); protected: // Sphere in model space - Point mCenter; //!< Sphere center + IcePoint mCenter; //!< Sphere center float mRadius2; //!< Sphere radius squared // Internal methods void _Collide(const AABBCollisionNode* node); @@ -74,9 +74,9 @@ void _CollideNoPrimitiveTest(const AABBQuantizedNode* node); void _CollideNoPrimitiveTest(const AABBQuantizedNoLeafNode* node); // Overlap tests - inline_ BOOL SphereContainsBox(const Point& bc, const Point& be); - inline_ BOOL SphereAABBOverlap(const Point& center, const Point& extents); - BOOL SphereTriOverlap(const Point& vert0, const Point& vert1, const Point& vert2); + inline_ BOOL SphereContainsBox(const IcePoint& bc, const IcePoint& be); + inline_ BOOL SphereAABBOverlap(const IcePoint& center, const IcePoint& extents); + BOOL SphereTriOverlap(const IcePoint& vert0, const IcePoint& vert1, const IcePoint& vert2); // Init methods BOOL InitQuery(SphereCache& cache, const Sphere& sphere, const Matrix4x4* worlds=null, const Matrix4x4* worldm=null); }; diff --git a/Opcode/OPC_SphereTriOverlap.h b/Opcode/OPC_SphereTriOverlap.h index f1452ec..900c2dd 100644 --- a/Opcode/OPC_SphereTriOverlap.h +++ b/Opcode/OPC_SphereTriOverlap.h @@ -6,13 +6,13 @@ // Overall this approach should run faster. // Original code by David Eberly in Magic. -BOOL SphereCollider::SphereTriOverlap(const Point& vert0, const Point& vert1, const Point& vert2) +BOOL SphereCollider::SphereTriOverlap(const IcePoint& vert0, const IcePoint& vert1, const IcePoint& vert2) { // Stats mNbVolumePrimTests++; // Early exit if one of the vertices is inside the sphere - Point kDiff = vert2 - mCenter; + IcePoint kDiff = vert2 - mCenter; float fC = kDiff.SquareMagnitude(); if(fC <= mRadius2) return TRUE; @@ -25,10 +25,10 @@ BOOL SphereCollider::SphereTriOverlap(const Point& vert0, const Point& vert1, co if(fC <= mRadius2) return TRUE; // Else do the full distance test - Point TriEdge0 = vert1 - vert0; - Point TriEdge1 = vert2 - vert0; + IcePoint TriEdge0 = vert1 - vert0; + IcePoint TriEdge1 = vert2 - vert0; -//Point kDiff = vert0 - mCenter; +//IcePoint kDiff = vert0 - mCenter; float fA00 = TriEdge0.SquareMagnitude(); float fA01 = TriEdge0 | TriEdge1; float fA11 = TriEdge1.SquareMagnitude(); @@ -77,7 +77,7 @@ BOOL SphereCollider::SphereTriOverlap(const Point& vert0, const Point& vert1, co } else // region 0 { - // minimum at interior point + // minimum at interior IcePoint if(fDet==0.0f) { // u = 0.0f; diff --git a/Opcode/OPC_TreeBuilders.cpp b/Opcode/OPC_TreeBuilders.cpp index 73e89c7..cd20c80 100644 --- a/Opcode/OPC_TreeBuilders.cpp +++ b/Opcode/OPC_TreeBuilders.cpp @@ -91,7 +91,7 @@ bool AABBTreeOfAABBsBuilder::ComputeGlobalBox(const udword* primitives, udword n float AABBTreeOfAABBsBuilder::GetSplittingValue(udword index, udword axis) const { // For an AABB, the splitting value is the middle of the given axis, - // i.e. the corresponding component of the center point + // i.e. the corresponding component of the center IcePoint return mAABBArray[index].GetCenter(axis); } @@ -110,8 +110,8 @@ bool AABBTreeOfTrianglesBuilder::ComputeGlobalBox(const udword* primitives, udwo if(!primitives || !nb_prims) return false; // Initialize global box - Point Min(MAX_FLOAT, MAX_FLOAT, MAX_FLOAT); - Point Max(MIN_FLOAT, MIN_FLOAT, MIN_FLOAT); + IcePoint Min(MAX_FLOAT, MAX_FLOAT, MAX_FLOAT); + IcePoint Max(MIN_FLOAT, MIN_FLOAT, MIN_FLOAT); // Loop through triangles VertexPointers VP; @@ -138,7 +138,7 @@ bool AABBTreeOfTrianglesBuilder::ComputeGlobalBox(const udword* primitives, udwo float AABBTreeOfTrianglesBuilder::GetSplittingValue(udword index, udword axis) const { /* // Compute center of triangle - Point Center; + IcePoint Center; mTriList[index].Center(mVerts, Center); // Return value return Center[axis];*/ diff --git a/Opcode/OPC_TreeBuilders.h b/Opcode/OPC_TreeBuilders.h index 32486aa..bfff16a 100644 --- a/Opcode/OPC_TreeBuilders.h +++ b/Opcode/OPC_TreeBuilders.h @@ -138,7 +138,7 @@ override(AABBTreeBuilder) float GetSplittingValue(udword index, udword axis) const; override(AABBTreeBuilder) float GetSplittingValue(const udword* primitives, udword nb_prims, const AABB& global_box, udword axis) const; - const Point* mVertexArray; //!< Shortcut to an app-controlled array of vertices. + const IcePoint* mVertexArray; //!< Shortcut to an app-controlled array of vertices. }; class OPCODE_API AABBTreeOfAABBsBuilder : public AABBTreeBuilder diff --git a/Opcode/OPC_TreeCollider.cpp b/Opcode/OPC_TreeCollider.cpp index 00be03c..eb2b4f8 100644 --- a/Opcode/OPC_TreeCollider.cpp +++ b/Opcode/OPC_TreeCollider.cpp @@ -113,11 +113,11 @@ bool AABBTreeCollider::Collide(BVTCache& cache, const Matrix4x4* world0, const M { struct Local { - static Point* SVCallback(const Point& sv, udword& previndex, udword user_data) + static IcePoint* SVCallback(const IcePoint& sv, udword& previndex, udword user_data) { CollisionHull* Hull = (CollisionHull*)user_data; previndex = Hull->ComputeSupportingVertex(sv, previndex); - return (Point*)&Hull->GetVerts()[previndex]; + return (IcePoint*)&Hull->GetVerts()[previndex]; } }; @@ -260,7 +260,7 @@ void AABBTreeCollider::InitQuery(const Matrix4x4* world0, const Matrix4x4* world { for(udword j=0;j<3;j++) { - // Epsilon value prevents floating-point inaccuracies (strategy borrowed from RAPID) + // Epsilon value prevents floating-IcePoint inaccuracies (strategy borrowed from RAPID) mAR.m[i][j] = 1e-6f + fabsf(mR1to0.m[i][j]); } } @@ -379,12 +379,12 @@ bool AABBTreeCollider::Collide(const AABBQuantizedTree* tree0, const AABBQuantiz // Dequantize box A const AABBQuantizedNode* N0 = tree0->GetNodes(); - const Point a(float(N0->mAABB.mExtents[0]) * mExtentsCoeff0.x, float(N0->mAABB.mExtents[1]) * mExtentsCoeff0.y, float(N0->mAABB.mExtents[2]) * mExtentsCoeff0.z); - const Point Pa(float(N0->mAABB.mCenter[0]) * mCenterCoeff0.x, float(N0->mAABB.mCenter[1]) * mCenterCoeff0.y, float(N0->mAABB.mCenter[2]) * mCenterCoeff0.z); + const IcePoint a(float(N0->mAABB.mExtents[0]) * mExtentsCoeff0.x, float(N0->mAABB.mExtents[1]) * mExtentsCoeff0.y, float(N0->mAABB.mExtents[2]) * mExtentsCoeff0.z); + const IcePoint Pa(float(N0->mAABB.mCenter[0]) * mCenterCoeff0.x, float(N0->mAABB.mCenter[1]) * mCenterCoeff0.y, float(N0->mAABB.mCenter[2]) * mCenterCoeff0.z); // Dequantize box B const AABBQuantizedNode* N1 = tree1->GetNodes(); - const Point b(float(N1->mAABB.mExtents[0]) * mExtentsCoeff1.x, float(N1->mAABB.mExtents[1]) * mExtentsCoeff1.y, float(N1->mAABB.mExtents[2]) * mExtentsCoeff1.z); - const Point Pb(float(N1->mAABB.mCenter[0]) * mCenterCoeff1.x, float(N1->mAABB.mCenter[1]) * mCenterCoeff1.y, float(N1->mAABB.mCenter[2]) * mCenterCoeff1.z); + const IcePoint b(float(N1->mAABB.mExtents[0]) * mExtentsCoeff1.x, float(N1->mAABB.mExtents[1]) * mExtentsCoeff1.y, float(N1->mAABB.mExtents[2]) * mExtentsCoeff1.z); + const IcePoint Pb(float(N1->mAABB.mCenter[0]) * mCenterCoeff1.x, float(N1->mAABB.mCenter[1]) * mCenterCoeff1.y, float(N1->mAABB.mCenter[2]) * mCenterCoeff1.z); // Perform collision query _Collide(N0, N1, a, Pa, b, Pb); @@ -534,7 +534,7 @@ void AABBTreeCollider::PrimTest(udword id0, udword id1) mIMesh1->GetTriangle(VP1, id1); // Transform from space 1 to space 0 - Point u0,u1,u2; + IcePoint u0,u1,u2; TransformPoint(u0, *VP1.Vertex[0], mR1to0, mT1to0); TransformPoint(u1, *VP1.Vertex[1], mR1to0, mT1to0); TransformPoint(u2, *VP1.Vertex[2], mR1to0, mT1to0); @@ -749,7 +749,7 @@ void AABBTreeCollider::_Collide(const AABBNoLeafNode* a, const AABBNoLeafNode* b * \param Pb [in] center from box B */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void AABBTreeCollider::_Collide(const AABBQuantizedNode* b0, const AABBQuantizedNode* b1, const Point& a, const Point& Pa, const Point& b, const Point& Pb) +void AABBTreeCollider::_Collide(const AABBQuantizedNode* b0, const AABBQuantizedNode* b1, const IcePoint& a, const IcePoint& Pa, const IcePoint& b, const IcePoint& Pb) { // Perform BV-BV overlap test if(!BoxBoxOverlap(a, Pa, b, Pb)) return; @@ -760,32 +760,32 @@ void AABBTreeCollider::_Collide(const AABBQuantizedNode* b0, const AABBQuantized { // Dequantize box const QuantizedAABB* Box = &b0->GetNeg()->mAABB; - const Point negPa(float(Box->mCenter[0]) * mCenterCoeff0.x, float(Box->mCenter[1]) * mCenterCoeff0.y, float(Box->mCenter[2]) * mCenterCoeff0.z); - const Point nega(float(Box->mExtents[0]) * mExtentsCoeff0.x, float(Box->mExtents[1]) * mExtentsCoeff0.y, float(Box->mExtents[2]) * mExtentsCoeff0.z); + const IcePoint negPa(float(Box->mCenter[0]) * mCenterCoeff0.x, float(Box->mCenter[1]) * mCenterCoeff0.y, float(Box->mCenter[2]) * mCenterCoeff0.z); + const IcePoint nega(float(Box->mExtents[0]) * mExtentsCoeff0.x, float(Box->mExtents[1]) * mExtentsCoeff0.y, float(Box->mExtents[2]) * mExtentsCoeff0.z); _Collide(b0->GetNeg(), b1, nega, negPa, b, Pb); if(ContactFound()) return; // Dequantize box Box = &b0->GetPos()->mAABB; - const Point posPa(float(Box->mCenter[0]) * mCenterCoeff0.x, float(Box->mCenter[1]) * mCenterCoeff0.y, float(Box->mCenter[2]) * mCenterCoeff0.z); - const Point posa(float(Box->mExtents[0]) * mExtentsCoeff0.x, float(Box->mExtents[1]) * mExtentsCoeff0.y, float(Box->mExtents[2]) * mExtentsCoeff0.z); + const IcePoint posPa(float(Box->mCenter[0]) * mCenterCoeff0.x, float(Box->mCenter[1]) * mCenterCoeff0.y, float(Box->mCenter[2]) * mCenterCoeff0.z); + const IcePoint posa(float(Box->mExtents[0]) * mExtentsCoeff0.x, float(Box->mExtents[1]) * mExtentsCoeff0.y, float(Box->mExtents[2]) * mExtentsCoeff0.z); _Collide(b0->GetPos(), b1, posa, posPa, b, Pb); } else { // Dequantize box const QuantizedAABB* Box = &b1->GetNeg()->mAABB; - const Point negPb(float(Box->mCenter[0]) * mCenterCoeff1.x, float(Box->mCenter[1]) * mCenterCoeff1.y, float(Box->mCenter[2]) * mCenterCoeff1.z); - const Point negb(float(Box->mExtents[0]) * mExtentsCoeff1.x, float(Box->mExtents[1]) * mExtentsCoeff1.y, float(Box->mExtents[2]) * mExtentsCoeff1.z); + const IcePoint negPb(float(Box->mCenter[0]) * mCenterCoeff1.x, float(Box->mCenter[1]) * mCenterCoeff1.y, float(Box->mCenter[2]) * mCenterCoeff1.z); + const IcePoint negb(float(Box->mExtents[0]) * mExtentsCoeff1.x, float(Box->mExtents[1]) * mExtentsCoeff1.y, float(Box->mExtents[2]) * mExtentsCoeff1.z); _Collide(b0, b1->GetNeg(), a, Pa, negb, negPb); if(ContactFound()) return; // Dequantize box Box = &b1->GetPos()->mAABB; - const Point posPb(float(Box->mCenter[0]) * mCenterCoeff1.x, float(Box->mCenter[1]) * mCenterCoeff1.y, float(Box->mCenter[2]) * mCenterCoeff1.z); - const Point posb(float(Box->mExtents[0]) * mExtentsCoeff1.x, float(Box->mExtents[1]) * mExtentsCoeff1.y, float(Box->mExtents[2]) * mExtentsCoeff1.z); + const IcePoint posPb(float(Box->mCenter[0]) * mCenterCoeff1.x, float(Box->mCenter[1]) * mCenterCoeff1.y, float(Box->mCenter[2]) * mCenterCoeff1.z); + const IcePoint posb(float(Box->mExtents[0]) * mExtentsCoeff1.x, float(Box->mExtents[1]) * mExtentsCoeff1.y, float(Box->mExtents[2]) * mExtentsCoeff1.z); _Collide(b0, b1->GetPos(), a, Pa, posb, posPb); } } @@ -805,8 +805,8 @@ void AABBTreeCollider::_CollideTriBox(const AABBQuantizedNoLeafNode* b) { // Dequantize box const QuantizedAABB* bb = &b->mAABB; - const Point Pb(float(bb->mCenter[0]) * mCenterCoeff1.x, float(bb->mCenter[1]) * mCenterCoeff1.y, float(bb->mCenter[2]) * mCenterCoeff1.z); - const Point eb(float(bb->mExtents[0]) * mExtentsCoeff1.x, float(bb->mExtents[1]) * mExtentsCoeff1.y, float(bb->mExtents[2]) * mExtentsCoeff1.z); + const IcePoint Pb(float(bb->mCenter[0]) * mCenterCoeff1.x, float(bb->mCenter[1]) * mCenterCoeff1.y, float(bb->mCenter[2]) * mCenterCoeff1.z); + const IcePoint eb(float(bb->mExtents[0]) * mExtentsCoeff1.x, float(bb->mExtents[1]) * mExtentsCoeff1.y, float(bb->mExtents[2]) * mExtentsCoeff1.z); // Perform triangle-box overlap test if(!TriBoxOverlap(Pb, eb)) return; @@ -831,8 +831,8 @@ void AABBTreeCollider::_CollideBoxTri(const AABBQuantizedNoLeafNode* b) { // Dequantize box const QuantizedAABB* bb = &b->mAABB; - const Point Pa(float(bb->mCenter[0]) * mCenterCoeff0.x, float(bb->mCenter[1]) * mCenterCoeff0.y, float(bb->mCenter[2]) * mCenterCoeff0.z); - const Point ea(float(bb->mExtents[0]) * mExtentsCoeff0.x, float(bb->mExtents[1]) * mExtentsCoeff0.y, float(bb->mExtents[2]) * mExtentsCoeff0.z); + const IcePoint Pa(float(bb->mCenter[0]) * mCenterCoeff0.x, float(bb->mCenter[1]) * mCenterCoeff0.y, float(bb->mCenter[2]) * mCenterCoeff0.z); + const IcePoint ea(float(bb->mExtents[0]) * mExtentsCoeff0.x, float(bb->mExtents[1]) * mExtentsCoeff0.y, float(bb->mExtents[2]) * mExtentsCoeff0.z); // Perform triangle-box overlap test if(!TriBoxOverlap(Pa, ea)) return; @@ -857,12 +857,12 @@ void AABBTreeCollider::_Collide(const AABBQuantizedNoLeafNode* a, const AABBQuan { // Dequantize box A const QuantizedAABB* ab = &a->mAABB; - const Point Pa(float(ab->mCenter[0]) * mCenterCoeff0.x, float(ab->mCenter[1]) * mCenterCoeff0.y, float(ab->mCenter[2]) * mCenterCoeff0.z); - const Point ea(float(ab->mExtents[0]) * mExtentsCoeff0.x, float(ab->mExtents[1]) * mExtentsCoeff0.y, float(ab->mExtents[2]) * mExtentsCoeff0.z); + const IcePoint Pa(float(ab->mCenter[0]) * mCenterCoeff0.x, float(ab->mCenter[1]) * mCenterCoeff0.y, float(ab->mCenter[2]) * mCenterCoeff0.z); + const IcePoint ea(float(ab->mExtents[0]) * mExtentsCoeff0.x, float(ab->mExtents[1]) * mExtentsCoeff0.y, float(ab->mExtents[2]) * mExtentsCoeff0.z); // Dequantize box B const QuantizedAABB* bb = &b->mAABB; - const Point Pb(float(bb->mCenter[0]) * mCenterCoeff1.x, float(bb->mCenter[1]) * mCenterCoeff1.y, float(bb->mCenter[2]) * mCenterCoeff1.z); - const Point eb(float(bb->mExtents[0]) * mExtentsCoeff1.x, float(bb->mExtents[1]) * mExtentsCoeff1.y, float(bb->mExtents[2]) * mExtentsCoeff1.z); + const IcePoint Pb(float(bb->mCenter[0]) * mCenterCoeff1.x, float(bb->mCenter[1]) * mCenterCoeff1.y, float(bb->mCenter[2]) * mCenterCoeff1.z); + const IcePoint eb(float(bb->mExtents[0]) * mExtentsCoeff1.x, float(bb->mExtents[1]) * mExtentsCoeff1.y, float(bb->mExtents[2]) * mExtentsCoeff1.z); // Perform BV-BV overlap test if(!BoxBoxOverlap(ea, Pa, eb, Pb)) return; diff --git a/Opcode/OPC_TreeCollider.h b/Opcode/OPC_TreeCollider.h index bb8d1b6..ce58ff8 100644 --- a/Opcode/OPC_TreeCollider.h +++ b/Opcode/OPC_TreeCollider.h @@ -45,7 +45,7 @@ HullTest = true; SepVector.pid = 0; SepVector.qid = 0; - SepVector.SV = Point(1.0f, 0.0f, 0.0f); + SepVector.SV = IcePoint(1.0f, 0.0f, 0.0f); #endif // __MESHMERIZER_H__ } @@ -191,15 +191,15 @@ Matrix3x3 mAR; //!< Absolute rotation matrix Matrix3x3 mR0to1; //!< Rotation from object0 to object1 Matrix3x3 mR1to0; //!< Rotation from object1 to object0 - Point mT0to1; //!< Translation from object0 to object1 - Point mT1to0; //!< Translation from object1 to object0 + IcePoint mT0to1; //!< Translation from object0 to object1 + IcePoint mT1to0; //!< Translation from object1 to object0 // Dequantization coeffs - Point mCenterCoeff0; - Point mExtentsCoeff0; - Point mCenterCoeff1; - Point mExtentsCoeff1; + IcePoint mCenterCoeff0; + IcePoint mExtentsCoeff0; + IcePoint mCenterCoeff1; + IcePoint mExtentsCoeff1; // Leaf description - Point mLeafVerts[3]; //!< Triangle vertices + IcePoint mLeafVerts[3]; //!< Triangle vertices udword mLeafIndex; //!< Triangle index // Settings bool mFullBoxBoxTest; //!< Perform full BV-BV tests (true) or SAT-lite tests (false) @@ -209,7 +209,7 @@ // Standard AABB trees void _Collide(const AABBCollisionNode* b0, const AABBCollisionNode* b1); // Quantized AABB trees - void _Collide(const AABBQuantizedNode* b0, const AABBQuantizedNode* b1, const Point& a, const Point& Pa, const Point& b, const Point& Pb); + void _Collide(const AABBQuantizedNode* b0, const AABBQuantizedNode* b1, const IcePoint& a, const IcePoint& Pa, const IcePoint& b, const IcePoint& Pb); // No-leaf AABB trees void _CollideTriBox(const AABBNoLeafNode* b); void _CollideBoxTri(const AABBNoLeafNode* b); @@ -223,9 +223,9 @@ inline_ void PrimTestTriIndex(udword id1); inline_ void PrimTestIndexTri(udword id0); - inline_ BOOL BoxBoxOverlap(const Point& ea, const Point& ca, const Point& eb, const Point& cb); - inline_ BOOL TriBoxOverlap(const Point& center, const Point& extents); - inline_ BOOL TriTriOverlap(const Point& V0, const Point& V1, const Point& V2, const Point& U0, const Point& U1, const Point& U2); + inline_ BOOL BoxBoxOverlap(const IcePoint& ea, const IcePoint& ca, const IcePoint& eb, const IcePoint& cb); + inline_ BOOL TriBoxOverlap(const IcePoint& center, const IcePoint& extents); + inline_ BOOL TriTriOverlap(const IcePoint& V0, const IcePoint& V1, const IcePoint& V2, const IcePoint& U0, const IcePoint& U1, const IcePoint& U2); // Init methods void InitQuery(const Matrix4x4* world0=null, const Matrix4x4* world1=null); bool CheckTemporalCoherence(Pair* cache); diff --git a/Opcode/OPC_TriBoxOverlap.h b/Opcode/OPC_TriBoxOverlap.h index 923e324..662a127 100644 --- a/Opcode/OPC_TriBoxOverlap.h +++ b/Opcode/OPC_TriBoxOverlap.h @@ -8,9 +8,9 @@ if(x2>max) max=x2; //! TO BE DOCUMENTED -inline_ BOOL planeBoxOverlap(const Point& normal, const float d, const Point& maxbox) +inline_ BOOL planeBoxOverlap(const IcePoint& normal, const float d, const IcePoint& maxbox) { - Point vmin, vmax; + IcePoint vmin, vmax; for(udword q=0;q<=2;q++) { if(normal[q]>0.0f) { vmin[q]=-maxbox[q]; vmax[q]=maxbox[q]; } @@ -93,7 +93,7 @@ inline_ BOOL planeBoxOverlap(const Point& normal, const float d, const Point& ma AXISTEST_Y02(e1.z, e1.x, fez1, fex1); \ AXISTEST_Z0(e1.y, e1.x, fey1, fex1); \ \ - const Point e2 = mLeafVerts[0] - mLeafVerts[2]; \ + const IcePoint e2 = mLeafVerts[0] - mLeafVerts[2]; \ const float fey2 = fabsf(e2.y); \ const float fez2 = fabsf(e2.z); \ AXISTEST_X2(e2.z, e2.y, fez2, fey2); \ @@ -115,7 +115,7 @@ inline_ BOOL planeBoxOverlap(const Point& normal, const float d, const Point& ma * \return true if triangle & box overlap */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -inline_ BOOL AABBTreeCollider::TriBoxOverlap(const Point& center, const Point& extents) +inline_ BOOL AABBTreeCollider::TriBoxOverlap(const IcePoint& center, const IcePoint& extents) { // Stats mNbBVPrimTests++; @@ -129,7 +129,7 @@ inline_ BOOL AABBTreeCollider::TriBoxOverlap(const Point& center, const Point& e // this gives 3x3=9 more tests // move everything so that the boxcenter is in (0,0,0) - Point v0, v1, v2; + IcePoint v0, v1, v2; v0.x = mLeafVerts[0].x - center.x; v1.x = mLeafVerts[1].x - center.x; v2.x = mLeafVerts[2].x - center.x; @@ -180,9 +180,9 @@ inline_ BOOL AABBTreeCollider::TriBoxOverlap(const Point& center, const Point& e // 2) Test if the box intersects the plane of the triangle // compute plane equation of triangle: normal*x+d=0 // ### could be precomputed since we use the same leaf triangle several times - const Point e0 = v1 - v0; - const Point e1 = v2 - v1; - const Point normal = e0 ^ e1; + const IcePoint e0 = v1 - v0; + const IcePoint e1 = v2 - v1; + const IcePoint normal = e0 ^ e1; const float d = -normal|v0; if(!planeBoxOverlap(normal, d, extents)) return FALSE; @@ -201,10 +201,10 @@ inline_ BOOL OBBCollider::TriBoxOverlap() mNbVolumePrimTests++; // Hook - const Point& extents = mBoxExtents; - const Point& v0 = mLeafVerts[0]; - const Point& v1 = mLeafVerts[1]; - const Point& v2 = mLeafVerts[2]; + const IcePoint& extents = mBoxExtents; + const IcePoint& v0 = mLeafVerts[0]; + const IcePoint& v1 = mLeafVerts[1]; + const IcePoint& v2 = mLeafVerts[2]; // use separating axis theorem to test overlap between triangle and box // need to test for overlap in these directions: @@ -242,9 +242,9 @@ inline_ BOOL OBBCollider::TriBoxOverlap() // 2) Test if the box intersects the plane of the triangle // compute plane equation of triangle: normal*x+d=0 // ### could be precomputed since we use the same leaf triangle several times - const Point e0 = v1 - v0; - const Point e1 = v2 - v1; - const Point normal = e0 ^ e1; + const IcePoint e0 = v1 - v0; + const IcePoint e1 = v2 - v1; + const IcePoint normal = e0 ^ e1; const float d = -normal|v0; if(!planeBoxOverlap(normal, d, mBoxExtents)) return FALSE; @@ -262,8 +262,8 @@ inline_ BOOL AABBCollider::TriBoxOverlap() mNbVolumePrimTests++; // Hook - const Point& center = mBox.mCenter; - const Point& extents = mBox.mExtents; + const IcePoint& center = mBox.mCenter; + const IcePoint& extents = mBox.mExtents; // use separating axis theorem to test overlap between triangle and box // need to test for overlap in these directions: @@ -274,7 +274,7 @@ inline_ BOOL AABBCollider::TriBoxOverlap() // this gives 3x3=9 more tests // move everything so that the boxcenter is in (0,0,0) - Point v0, v1, v2; + IcePoint v0, v1, v2; v0.x = mLeafVerts[0].x - center.x; v1.x = mLeafVerts[1].x - center.x; v2.x = mLeafVerts[2].x - center.x; @@ -325,9 +325,9 @@ inline_ BOOL AABBCollider::TriBoxOverlap() // 2) Test if the box intersects the plane of the triangle // compute plane equation of triangle: normal*x+d=0 // ### could be precomputed since we use the same leaf triangle several times - const Point e0 = v1 - v0; - const Point e1 = v2 - v1; - const Point normal = e0 ^ e1; + const IcePoint e0 = v1 - v0; + const IcePoint e1 = v2 - v1; + const IcePoint normal = e0 ^ e1; const float d = -normal|v0; if(!planeBoxOverlap(normal, d, extents)) return FALSE; diff --git a/Opcode/OPC_TriTriOverlap.h b/Opcode/OPC_TriTriOverlap.h index 45de8ba..ccc8161 100644 --- a/Opcode/OPC_TriTriOverlap.h +++ b/Opcode/OPC_TriTriOverlap.h @@ -72,7 +72,7 @@ } //! TO BE DOCUMENTED -BOOL CoplanarTriTri(const Point& n, const Point& v0, const Point& v1, const Point& v2, const Point& u0, const Point& u1, const Point& u2) +BOOL CoplanarTriTri(const IcePoint& n, const IcePoint& v0, const IcePoint& v1, const IcePoint& v2, const IcePoint& u0, const IcePoint& u1, const IcePoint& u2) { float A[3]; short i0,i1; @@ -176,15 +176,15 @@ BOOL CoplanarTriTri(const Point& n, const Point& v0, const Point& v1, const Poin * \return true if triangles overlap */ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -inline_ BOOL AABBTreeCollider::TriTriOverlap(const Point& V0, const Point& V1, const Point& V2, const Point& U0, const Point& U1, const Point& U2) +inline_ BOOL AABBTreeCollider::TriTriOverlap(const IcePoint& V0, const IcePoint& V1, const IcePoint& V2, const IcePoint& U0, const IcePoint& U1, const IcePoint& U2) { // Stats mNbPrimPrimTests++; // Compute plane equation of triangle(V0,V1,V2) - Point E1 = V1 - V0; - Point E2 = V2 - V0; - const Point N1 = E1 ^ E2; + IcePoint E1 = V1 - V0; + IcePoint E2 = V2 - V0; + const IcePoint N1 = E1 ^ E2; const float d1 =-N1 | V0; // Plane equation 1: N1.X+d1=0 @@ -208,7 +208,7 @@ inline_ BOOL AABBTreeCollider::TriTriOverlap(const Point& V0, const Point& V1, c // Compute plane of triangle (U0,U1,U2) E1 = U1 - U0; E2 = U2 - U0; - const Point N2 = E1 ^ E2; + const IcePoint N2 = E1 ^ E2; const float d2=-N2 | U0; // plane equation 2: N2.X+d2=0 @@ -230,7 +230,7 @@ inline_ BOOL AABBTreeCollider::TriTriOverlap(const Point& V0, const Point& V1, c return FALSE; // no intersection occurs // Compute direction of intersection line - const Point D = N1^N2; + const IcePoint D = N1^N2; // Compute and index to the largest component of D float max=fabsf(D[0]); diff --git a/Opcode/OPC_VolumeCollider.h b/Opcode/OPC_VolumeCollider.h index 05ea693..5c39ea3 100644 --- a/Opcode/OPC_VolumeCollider.h +++ b/Opcode/OPC_VolumeCollider.h @@ -93,8 +93,8 @@ Container* mTouchedPrimitives; //!< List of touched primitives // Dequantization coeffs - Point mCenterCoeff; - Point mExtentsCoeff; + IcePoint mCenterCoeff; + IcePoint mExtentsCoeff; // Stats udword mNbVolumeBVTests; //!< Number of Volume-BV tests udword mNbVolumePrimTests; //!< Number of Volume-Primitive tests diff --git a/Opcode/Opcode.vcxproj b/Opcode/Opcode.vcxproj index 86aebed..dbee6ac 100644 --- a/Opcode/Opcode.vcxproj +++ b/Opcode/Opcode.vcxproj @@ -51,6 +51,7 @@ .\Debug\ .\Debug\ false + ..\Opcode;$(IncludePath) .\Release\ -- cgit v1.1