Skip to content

Commit

Permalink
1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Darius committed Mar 15, 2018
1 parent f2878e7 commit 9fb54cf
Show file tree
Hide file tree
Showing 124 changed files with 14,492 additions and 7,495 deletions.
405 changes: 405 additions & 0 deletions Ice/IceAABB.cpp

Large diffs are not rendered by default.

310 changes: 165 additions & 145 deletions OpcodeDistrib/OPC_AABB.h → Ice/IceAABB.h

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions Ice/IceAxes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Contains axes definition.
* \file IceAxes.h
* \author Pierre Terdiman
* \date January, 29, 2000
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Include Guard
#ifndef __ICEAXES_H__
#define __ICEAXES_H__

enum PointComponent
{
_X = 0,
_Y = 1,
_Z = 2,
_W = 3,

_FORCE_DWORD = 0x7fffffff
};

enum AxisOrder
{
AXES_XYZ = (_X)|(_Y<<2)|(_Z<<4),
AXES_XZY = (_X)|(_Z<<2)|(_Y<<4),
AXES_YXZ = (_Y)|(_X<<2)|(_Z<<4),
AXES_YZX = (_Y)|(_Z<<2)|(_X<<4),
AXES_ZXY = (_Z)|(_X<<2)|(_Y<<4),
AXES_ZYX = (_Z)|(_Y<<2)|(_X<<4),

AXES_FORCE_DWORD = 0x7fffffff
};

class ICEMATHS_API Axes
{
public:

inline_ Axes(AxisOrder order)
{
mAxis0 = (order ) & 3;
mAxis1 = (order>>2) & 3;
mAxis2 = (order>>4) & 3;
}
inline_ ~Axes() {}

udword mAxis0;
udword mAxis1;
udword mAxis2;
};

#endif // __ICEAXES_H__
79 changes: 53 additions & 26 deletions OpcodeDistrib/OPC_BoundingSphere.h → Ice/IceBoundingSphere.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,38 @@
#ifndef __ICEBOUNDINGSPHERE_H__
#define __ICEBOUNDINGSPHERE_H__

class MESHMERIZER_API Sphere
enum BSphereMethod
{
BS_NONE,
BS_GEMS,
BS_MINIBALL,

BS_FORCE_DWORD = 0x7fffffff
};

class ICEMATHS_API Sphere
{
public:
//! Constructor
inline_ Sphere() {}
//! Constructor
inline_ Sphere(const Point& center, float radius) : mCenter(center), mRadius(radius) {}
//! Constructor
Sphere(const udword n, Point* p);
Sphere(udword nb_verts, const Point* verts);
//! Copy constructor
inline_ Sphere(const Sphere& sphere) : mCenter(sphere.mCenter), mRadius(sphere.mRadius) {}
//! Destructor
inline_ ~Sphere() {}

bool Compute(udword nbverts, Point* verts);
bool FastCompute(udword nbverts, Point* verts);
BSphereMethod Compute(udword nb_verts, const Point* verts);
bool FastCompute(udword nb_verts, const Point* verts);

// Access methods
inline_ const Point& GetCenter() const { return mCenter; }
inline_ float GetRadius() const { return mRadius; }
inline_ const Point& GetCenter() const { return mCenter; }
inline_ float GetRadius() const { return mRadius; }

inline_ const Point& Center() const { return mCenter; }
inline_ float Radius() const { return mRadius; }
inline_ const Point& 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; }
Expand All @@ -47,9 +56,9 @@
* \return true if inside the sphere
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
inline_ bool Contains(const Point& p) const
inline_ bool Contains(const Point& p) const
{
return mCenter.SquareDistance(p) < mRadius*mRadius;
return mCenter.SquareDistance(p) <= mRadius*mRadius;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -61,8 +70,11 @@
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
inline_ bool Contains(const Sphere& sphere) const
{
// If our radius is the smallest, we can't possibly contain the other sphere
if(mRadius < sphere.mRadius) return false;
// So r is always positive or null now
float r = mRadius - sphere.mRadius;
return mCenter.SquareDistance(sphere.mCenter) < r*r;
return mCenter.SquareDistance(sphere.mCenter) <= r*r;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -77,9 +89,13 @@
// 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?
float R2 = mRadius * mRadius;
#ifdef USE_MIN_MAX
const Point& Max = ((ShadowAABB&)&aabb).mMax;
const Point& Min = ((ShadowAABB&)&aabb).mMin;
#else
Point Max; aabb.GetMax(Max);
Point Min; aabb.GetMin(Min);

#endif
Point 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;
Expand All @@ -93,23 +109,34 @@
return TRUE;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Tests if the sphere intersects another sphere
* \param sphere [in] the other sphere
* \return true if spheres overlap
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
inline_ bool Intersect(const Sphere& sphere) const
{
float r = mRadius + sphere.mRadius;
return mCenter.SquareDistance(sphere.mCenter) <= r*r;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Checks the sphere is valid.
* \return true if the box is valid
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
inline_ BOOL IsValid() const
{
// Consistency condition for spheres: Radius >= 0.0f
if(mRadius < 0.0f) return FALSE;
return TRUE;
}
public:
Point mCenter; //!< Sphere center
float mRadius; //!< Sphere radius
#ifdef OLD
private:
Sphere PlanarCircumscribe3 (const Point& p0, const Point& p1, const Point& p2);
Sphere Circumscribe4 (const Point& p0, const Point& p1, const Point& p2, const Point& p3);
Sphere MinFix3 (int n, Point** perm, Point* fixed0, Point* fixed1, Point* fixed2);
Sphere MinFix2 (int n, Point** perm, Point* fixed0, Point* fixed1);
Sphere MinFix1 (int n, Point** perm, Point* fixed0);

int PointInsideSphere (const Point& p, const Sphere& s);
Sphere MinimalSphere1 (const Point& p);
Sphere MinimalSphere2 (const Point& p0, const Point& p1);
Sphere MinimalSphere3 (const Point& p0, const Point& p1, const Point& p2);
Sphere MinimalSphere4 (const Point& p0, const Point& p1, const Point& p2, const Point& p3);
#endif
};

#endif // __ICEBOUNDINGSPHERE_H__
50 changes: 44 additions & 6 deletions OpcodeDistrib/OPC_Container.cpp → Ice/IceContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,20 @@ Container::Container(udword size, float growth_factor) : mMaxNbEntries(0), mCurN
SetSize(size);
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Copy constructor.
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Container::Container(const Container& object) : mMaxNbEntries(0), mCurNbEntries(0), mEntries(null), mGrowthFactor(2.0f)
{
#ifdef CONTAINER_STATS
mNbContainers++;
mUsedRam+=sizeof(Container);
#endif
*this = object;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Destructor. Frees everything and leaves.
Expand All @@ -73,6 +87,23 @@ Container::~Container()
#endif
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Clears the container. All stored values are deleted, and it frees used ram.
* \see Reset()
* \return Self-Reference
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Container& Container::Empty()
{
#ifdef CONTAINER_STATS
mUsedRam-=mMaxNbEntries*sizeof(udword);
#endif
DELETEARRAY(mEntries);
mCurNbEntries = mMaxNbEntries = 0;
return *this;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Resizes the container.
Expand Down Expand Up @@ -259,17 +290,17 @@ bool Container::DeleteKeepingOrder(udword entry)
/**
* Gets the next entry, starting from input one.
* \param entry [in/out] On input, the entry to look for. On output, the next entry
* \param wrap [in] true to wrap at the end of the array
* \param find_mode [in] wrap/clamp
* \return Self-Reference
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Container& Container::FindNext(udword& entry, bool wrap)
Container& Container::FindNext(udword& entry, FindMode find_mode)
{
udword Location;
if(Contains(entry, &Location))
{
Location++;
if(Location==mCurNbEntries) Location = wrap ? 0 : mCurNbEntries-1;
if(Location==mCurNbEntries) Location = find_mode==FIND_WRAP ? 0 : mCurNbEntries-1;
entry = mEntries[Location];
}
return *this;
Expand All @@ -279,17 +310,17 @@ Container& Container::FindNext(udword& entry, bool wrap)
/**
* Gets the previous entry, starting from input one.
* \param entry [in/out] On input, the entry to look for. On output, the previous entry
* \param wrap [in] true to wrap at the end of the array
* \param find_mode [in] wrap/clamp
* \return Self-Reference
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Container& Container::FindPrev(udword& entry, bool wrap)
Container& Container::FindPrev(udword& entry, FindMode find_mode)
{
udword Location;
if(Contains(entry, &Location))
{
Location--;
if(Location==0xffffffff) Location = wrap ? mCurNbEntries-1 : 0;
if(Location==0xffffffff) Location = find_mode==FIND_WRAP ? mCurNbEntries-1 : 0;
entry = mEntries[Location];
}
return *this;
Expand All @@ -305,3 +336,10 @@ udword Container::GetUsedRam() const
{
return sizeof(Container) + mMaxNbEntries * sizeof(udword);
}

void Container::operator=(const Container& object)
{
SetSize(object.GetNbEntries());
CopyMemory(mEntries, object.GetEntries(), mMaxNbEntries*sizeof(udword));
mCurNbEntries = mMaxNbEntries;
}
Loading

0 comments on commit 9fb54cf

Please sign in to comment.