mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 19:29:09 +00:00
Convert custom HeadSpin integer types to standard types from stdint.h
This commit is contained in:
@ -52,7 +52,7 @@ hsNoiseFunc::~hsNoiseFunc()
|
||||
{
|
||||
}
|
||||
|
||||
void hsNoiseFunc::Seed(UInt32 s)
|
||||
void hsNoiseFunc::Seed(uint32_t s)
|
||||
{
|
||||
srand(s);
|
||||
}
|
||||
@ -101,7 +101,7 @@ hsScalar hsTableNoise::Noise(hsScalar lo, hsScalar hi, hsScalar t)
|
||||
t = hsScalar1;
|
||||
|
||||
hsScalar tIdx = t * fTableLen;
|
||||
UInt32 idx = UInt32(tIdx);
|
||||
uint32_t idx = uint32_t(tIdx);
|
||||
hsScalar frac = tIdx - hsScalar(idx);
|
||||
hsAssert((idx >= 0)&&(idx <= fTableLen), "Noise parm t out of range [0..1]");
|
||||
|
||||
@ -116,21 +116,21 @@ hsScalar hsTableNoise::NoisePoint(const hsPoint3& p, hsScalar lo, hsScalar hi, h
|
||||
{
|
||||
hsAssert(fTableLen, "Badly initialized table noise function");
|
||||
|
||||
UInt32 sX = *((UInt32*)&p.fX);
|
||||
UInt32 sY = *((UInt32*)&p.fY);
|
||||
UInt32 sZ = *((UInt32*)&p.fZ);
|
||||
uint32_t sX = *((uint32_t*)&p.fX);
|
||||
uint32_t sY = *((uint32_t*)&p.fY);
|
||||
uint32_t sZ = *((uint32_t*)&p.fZ);
|
||||
|
||||
UInt32 sAll = ((((sX & 0x07800000) >> 16) | ((sX & 0x007fffff) >> 17)) << 20)
|
||||
uint32_t sAll = ((((sX & 0x07800000) >> 16) | ((sX & 0x007fffff) >> 17)) << 20)
|
||||
| ((((sY & 0x07800000) >> 16) | ((sY & 0x007fffff) >> 17)) << 10)
|
||||
| ((((sZ & 0x07800000) >> 16) | ((sZ & 0x007fffff) >> 17)) );
|
||||
|
||||
const UInt32 kExp = 0x3f800000;
|
||||
const UInt32 kMsk = 0x007fffff;
|
||||
const uint32_t kExp = 0x3f800000;
|
||||
const uint32_t kMsk = 0x007fffff;
|
||||
|
||||
const UInt32 kA = 1665636L;
|
||||
const UInt32 kC = 1013904223L;
|
||||
const uint32_t kA = 1665636L;
|
||||
const uint32_t kC = 1013904223L;
|
||||
|
||||
UInt32 iR = kA * sAll + kC;
|
||||
uint32_t iR = kA * sAll + kC;
|
||||
iR &= kMsk;
|
||||
iR |= kExp;
|
||||
|
||||
@ -144,7 +144,7 @@ hsScalar hsTableNoise::NoisePoint(const hsPoint3& p, hsScalar lo, hsScalar hi, h
|
||||
t = hsScalar1;
|
||||
|
||||
hsScalar tIdx = t * fTableLen;
|
||||
UInt32 idx = UInt32(tIdx);
|
||||
uint32_t idx = uint32_t(tIdx);
|
||||
hsScalar frac = tIdx - hsScalar(idx);
|
||||
hsAssert((idx >= 0)&&(idx <= fTableLen), "Noise parm t out of range [0..1]");
|
||||
|
||||
|
@ -54,7 +54,7 @@ public:
|
||||
hsNoiseFunc();
|
||||
virtual ~hsNoiseFunc();
|
||||
|
||||
virtual void Seed(UInt32 s);
|
||||
virtual void Seed(uint32_t s);
|
||||
virtual hsScalar Noise(hsScalar lo=0, hsScalar hi=hsScalar1, hsScalar t=0) = 0; // t = [0..1] - returns random num [lo..hi] scaled by fTable[t]
|
||||
|
||||
virtual hsScalar NoisePoint(const hsPoint3& p, hsScalar lo=0, hsScalar hi=hsScalar1, hsScalar t=0) = 0; // t = [0..1] - returns random num [lo..hi] scaled by fTable[t]
|
||||
@ -64,7 +64,7 @@ class hsTableNoise : public hsNoiseFunc // should inherit from keyed object
|
||||
{
|
||||
protected:
|
||||
hsScalar* fTable;
|
||||
UInt32 fTableLen;
|
||||
uint32_t fTableLen;
|
||||
|
||||
|
||||
public:
|
||||
|
@ -135,7 +135,7 @@ void hsRadixSort::IReverse()
|
||||
}
|
||||
}
|
||||
|
||||
hsRadixSort::Elem* hsRadixSort::Sort(Elem* inList, UInt32 flags)
|
||||
hsRadixSort::Elem* hsRadixSort::Sort(Elem* inList, uint32_t flags)
|
||||
{
|
||||
if( !(inList && inList->fNext) )
|
||||
return inList;
|
||||
|
@ -84,7 +84,7 @@ public:
|
||||
|
||||
hsRadixSort();
|
||||
|
||||
Elem* Sort(Elem* inList, UInt32 flags = 0);
|
||||
Elem* Sort(Elem* inList, uint32_t flags = 0);
|
||||
|
||||
};
|
||||
|
||||
|
@ -59,15 +59,15 @@ set from 0 to max forever index.
|
||||
template <class T> class hsVersionNode {
|
||||
protected:
|
||||
T fData;
|
||||
Int32 fIndex;
|
||||
int32_t fIndex;
|
||||
hsVersionNode<T>* fNext;
|
||||
public:
|
||||
hsVersionNode(const UInt32 idx, const T &data) : fIndex(idx), fNext(nil) { fData = data; }
|
||||
hsVersionNode(const uint32_t idx, const T &data) : fIndex(idx), fNext(nil) { fData = data; }
|
||||
~hsVersionNode() { delete fNext; }
|
||||
|
||||
hsVersionNode<T>* Next() const { return fNext; }
|
||||
|
||||
Int32 Index() const { return fIndex; }
|
||||
int32_t Index() const { return fIndex; }
|
||||
|
||||
inline void Append(hsVersionNode<T>* next);
|
||||
inline int operator==(const T& o) const;
|
||||
@ -92,33 +92,33 @@ template <class T> void hsVersionNode<T>::Append(hsVersionNode<T>* next)
|
||||
|
||||
template <class T> class hsSearchVersion {
|
||||
protected:
|
||||
UInt32 fLength;
|
||||
uint32_t fLength;
|
||||
hsVersionNode<T>** fArray;
|
||||
UInt32 fNextIndex;
|
||||
UInt32 fNumIndex;
|
||||
UInt32 fIncIndex;
|
||||
uint32_t fNextIndex;
|
||||
uint32_t fNumIndex;
|
||||
uint32_t fIncIndex;
|
||||
T** fBackArray;
|
||||
|
||||
void ICheckBackArray();
|
||||
public:
|
||||
hsSearchVersion(UInt32 len, UInt32 inc = 0);
|
||||
hsSearchVersion(uint32_t len, uint32_t inc = 0);
|
||||
~hsSearchVersion();
|
||||
|
||||
T& operator[]( Int32 index );
|
||||
T& operator[]( int32_t index );
|
||||
|
||||
Int32 Find(int where, const T& what, hsBool forceUnique=false);
|
||||
int32_t Find(int where, const T& what, hsBool forceUnique=false);
|
||||
|
||||
UInt32 GetCount() const { return fNextIndex; }
|
||||
uint32_t GetCount() const { return fNextIndex; }
|
||||
};
|
||||
|
||||
template <class T> T& hsSearchVersion<T>::operator[]( Int32 index )
|
||||
template <class T> T& hsSearchVersion<T>::operator[]( int32_t index )
|
||||
{
|
||||
hsDebugCode(hsThrowIfBadParam((UInt32)index >= (UInt32)fNextIndex);)
|
||||
hsDebugCode(hsThrowIfBadParam((uint32_t)index >= (uint32_t)fNextIndex);)
|
||||
|
||||
return *fBackArray[index];
|
||||
}
|
||||
|
||||
template <class T> hsSearchVersion<T>::hsSearchVersion(UInt32 len, UInt32 inc)
|
||||
template <class T> hsSearchVersion<T>::hsSearchVersion(uint32_t len, uint32_t inc)
|
||||
: fNextIndex(0)
|
||||
{
|
||||
fIncIndex = inc ? inc : len;
|
||||
@ -149,7 +149,7 @@ template <class T> void hsSearchVersion<T>::ICheckBackArray()
|
||||
}
|
||||
}
|
||||
|
||||
template <class T> Int32 hsSearchVersion<T>::Find(int where, const T&what, hsBool forceUnique)
|
||||
template <class T> int32_t hsSearchVersion<T>::Find(int where, const T&what, hsBool forceUnique)
|
||||
{
|
||||
hsVersionNode<T>* curr = fArray[where];
|
||||
|
||||
|
@ -56,7 +56,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
class plRandom
|
||||
{
|
||||
protected:
|
||||
mutable UInt32 fSeed;
|
||||
mutable uint32_t fSeed;
|
||||
public:
|
||||
inline float RandNorm() const;
|
||||
inline int Rand() const;
|
||||
@ -65,7 +65,7 @@ public:
|
||||
inline float RandMinusOneToOne() const;
|
||||
inline float RandZeroToOne() const;
|
||||
|
||||
UInt32 GetSeed() const { return fSeed; }
|
||||
uint32_t GetSeed() const { return fSeed; }
|
||||
void SetSeed(int seed) { fSeed = seed; }
|
||||
|
||||
plRandom(int seed = 1) : fSeed(seed) {}
|
||||
@ -92,18 +92,18 @@ inline int plRandom::Rand() const
|
||||
#endif // FAST_Q
|
||||
}
|
||||
|
||||
// RandZeroToOne - take our usual random UInt32.
|
||||
// RandZeroToOne - take our usual random uint32_t.
|
||||
// We're going to mask in an exponent to make it
|
||||
// a float in range [1..2). Then subtract 1.f to
|
||||
// make it [0..1). We shift our random UInt32 down
|
||||
// make it [0..1). We shift our random uint32_t down
|
||||
// by 9 because the upper bits are the most random.
|
||||
inline float plRandom::RandZeroToOne() const
|
||||
{
|
||||
#ifndef FAST_Q
|
||||
return Rand() * RandNorm();
|
||||
#else // FAST_Q
|
||||
const UInt32 kOneExp = 0x3f800000;
|
||||
register UInt32 temp = kOneExp | (UInt32(Rand()) >> 9);
|
||||
const uint32_t kOneExp = 0x3f800000;
|
||||
register uint32_t temp = kOneExp | (uint32_t(Rand()) >> 9);
|
||||
return (*(float*)&temp) - 1.f;
|
||||
#endif // FAST_Q
|
||||
}
|
||||
@ -116,8 +116,8 @@ inline float plRandom::RandMinusOneToOne() const
|
||||
#ifndef FAST_Q
|
||||
return RandZeroToOne() * 2.f - 1.f;
|
||||
#else // FAST_Q
|
||||
const UInt32 kTwoExp = 0x40000000;
|
||||
register UInt32 temp = kTwoExp | (UInt32(Rand()) >> 9);
|
||||
const uint32_t kTwoExp = 0x40000000;
|
||||
register uint32_t temp = kTwoExp | (uint32_t(Rand()) >> 9);
|
||||
return (*(float*)&temp) - 3.f;
|
||||
#endif // FAST_Q
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ plTriUtils::Bary plTriUtils::ComputeBarycentric(const hsPoint3& p0, const hsPoin
|
||||
|
||||
plTriUtils::Bary plTriUtils::IComputeBarycentric(const hsVector3& v12, hsScalar invLenSq12, const hsVector3& v0, const hsVector3& v1, hsPoint3& out)
|
||||
{
|
||||
UInt32 state = 0;
|
||||
uint32_t state = 0;
|
||||
|
||||
hsScalar lenSq0 = v0.MagnitudeSquared();
|
||||
if( lenSq0 < kAlmostZeroSquared )
|
||||
|
Reference in New Issue
Block a user