mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 11:19:10 +00:00
@ -94,12 +94,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
//======================================
|
||||
// Basic macros
|
||||
//======================================
|
||||
#ifdef __cplusplus
|
||||
#define hsCTypeDefStruct(foo)
|
||||
#else
|
||||
#define hsCTypeDefStruct(foo) typedef struct foo foo;
|
||||
#endif
|
||||
|
||||
#ifdef HS_BUILD_FOR_WIN32
|
||||
# ifndef CDECL
|
||||
# define CDECL __cdecl
|
||||
@ -108,9 +102,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
# define CDECL
|
||||
#endif
|
||||
|
||||
#define kPosInfinity16 (32767)
|
||||
#define kNegInfinity16 (-32768)
|
||||
|
||||
#define kPosInfinity32 (0x7fffffff)
|
||||
#define kNegInfinity32 (0x80000000)
|
||||
|
||||
@ -123,24 +114,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#endif
|
||||
|
||||
typedef int32_t hsError;
|
||||
typedef uint32_t hsGSeedValue;
|
||||
|
||||
#define hsOK 0
|
||||
#define hsFail -1
|
||||
#define hsFailed(r) ((hsError)(r)<hsOK)
|
||||
#define hsSucceeded(r) ((hsError)(r)>=hsOK)
|
||||
|
||||
#define hsLongAlign(n) (((n) + 3) & ~3L)
|
||||
|
||||
#define hsMaximum(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define hsMinimum(a, b) ((a) < (b) ? (a) : (b))
|
||||
#define hsABS(x) ((x) < 0 ? -(x) : (x))
|
||||
#define hsSGN(x) (((x) < 0) ? -1 : ( ((x) > 0) ? 1 : 0 ))
|
||||
|
||||
#define hsBitTst2Bool(value, mask) (((value) & (mask)) != 0)
|
||||
|
||||
#define hsFourByteTag(a, b, c, d) (((uint32_t)(a) << 24) | ((uint32_t)(b) << 16) | ((uint32_t)(c) << 8) | (d))
|
||||
|
||||
#if defined(HAVE_CXX14_DEPRECATED_ATTR)
|
||||
# define hsDeprecated(message) [[deprecated(message)]]
|
||||
#elif defined(HAVE_GCC_DEPRECATED_ATTR)
|
||||
@ -178,15 +157,25 @@ inline uint64_t hsSwapEndian64(uint64_t value)
|
||||
}
|
||||
inline float hsSwapEndianFloat(float fvalue)
|
||||
{
|
||||
uint32_t value = *(uint32_t*)&fvalue;
|
||||
value = hsSwapEndian32(value);
|
||||
return *(float*)&value;
|
||||
union {
|
||||
uint32_t i;
|
||||
float f;
|
||||
} value;
|
||||
|
||||
value.f = fvalue;
|
||||
value.i = hsSwapEndian32(value.i);
|
||||
return value.f;
|
||||
}
|
||||
inline double hsSwapEndianDouble(double dvalue)
|
||||
{
|
||||
uint64_t value = *(uint64_t*)&dvalue;
|
||||
value = hsSwapEndian64(value);
|
||||
return *(double*)&value;
|
||||
union {
|
||||
uint64_t i;
|
||||
double f;
|
||||
} value;
|
||||
|
||||
value.f = dvalue;
|
||||
value.i = hsSwapEndian64(value.i);
|
||||
return value.f;
|
||||
}
|
||||
|
||||
#if LITTLE_ENDIAN
|
||||
@ -213,27 +202,6 @@ inline double hsSwapEndianDouble(double dvalue)
|
||||
#define hsToLEDouble(n) hsSwapEndianDouble(n)
|
||||
#endif
|
||||
|
||||
inline void hsSwap(int32_t& a, int32_t& b)
|
||||
{
|
||||
int32_t c = a;
|
||||
a = b;
|
||||
b = c;
|
||||
}
|
||||
|
||||
inline void hsSwap(uint32_t& a, uint32_t& b)
|
||||
{
|
||||
uint32_t c = a;
|
||||
a = b;
|
||||
b = c;
|
||||
}
|
||||
|
||||
inline void hsSwap(float& a, float& b)
|
||||
{
|
||||
float c = a;
|
||||
a = b;
|
||||
b = c;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// Define a NOOP (null) statement
|
||||
//===========================================================================
|
||||
@ -243,66 +211,6 @@ inline void hsSwap(float& a, float& b)
|
||||
# define NULL_STMT ((void)0)
|
||||
#endif
|
||||
|
||||
//===========================================================================
|
||||
template<class T>
|
||||
inline T max (const T & a, const T & b) {
|
||||
return (a > b) ? a : b;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
inline unsigned max (int a, unsigned b) {
|
||||
return ((unsigned)a > b) ? a : b;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
inline unsigned max (unsigned a, int b) {
|
||||
return (a > (unsigned)b) ? a : b;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
template<class T>
|
||||
inline T min (const T & a, const T & b) {
|
||||
return (a < b) ? a : b;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
inline unsigned min (int a, unsigned b) {
|
||||
return ((unsigned)a < b) ? a : b;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
inline unsigned min (unsigned a, int b) {
|
||||
return (a < (unsigned)b) ? a : b;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* MAX/MIN macros
|
||||
* These are less safe than the inline function versions, since they
|
||||
* evaluate parameters twice. However, they can be used to produce
|
||||
* compile-time constants.
|
||||
*
|
||||
***/
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* SWAP
|
||||
* Swaps the values of two variables
|
||||
*
|
||||
***/
|
||||
|
||||
//===========================================================================
|
||||
template<class T>
|
||||
void SWAP (T & a, T & b) {
|
||||
T temp = a;
|
||||
a = b;
|
||||
b = temp;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
@ -448,8 +356,6 @@ inline float hsRadiansToDegrees(float rad) { return float(rad * (180 / M_PI)); }
|
||||
# define ALIGN(n) __atribute__(aligned(n))
|
||||
#endif
|
||||
|
||||
#define hsFopen(name, mode) fopen(name, mode)
|
||||
|
||||
/************************ Debug/Error Macros **************************/
|
||||
|
||||
typedef void (*hsDebugMessageProc)(const char message[]);
|
||||
|
@ -195,9 +195,9 @@ void hsBounds3::MakeSymmetric(const hsPoint3* p)
|
||||
float delUp;
|
||||
|
||||
delUp = fMaxs[i] - (*p)[i];
|
||||
delMax = hsMaximum(delMax, delUp);
|
||||
delMax = std::max(delMax, delUp);
|
||||
delUp = (*p)[i] - fMins[i];
|
||||
delMax = hsMaximum(delMax, delUp);
|
||||
delMax = std::max(delMax, delUp);
|
||||
}
|
||||
const float sqrtTwo = 1.41421f;
|
||||
delMax *= sqrtTwo;
|
||||
|
@ -42,10 +42,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
#ifndef hsBounds_inc
|
||||
#define hsBounds_inc
|
||||
|
||||
|
||||
#include "hsGeometry3.h"
|
||||
#include "hsPoint2.h"
|
||||
#include "hsMatrix44.h"
|
||||
#include <algorithm>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// BOUNDS
|
||||
@ -186,7 +187,7 @@ inline const hsPoint3& hsBounds3::GetCenter() const
|
||||
inline float hsBounds3::GetMaxDim() const
|
||||
{
|
||||
hsAssert(kBoundsNormal == fType, "Invalid type for GetMaxDim");
|
||||
return hsMaximum(hsMaximum(fMaxs.fX-fMins.fX, fMaxs.fY-fMins.fY), fMaxs.fZ-fMins.fZ);
|
||||
return std::max({ fMaxs.fX - fMins.fX, fMaxs.fY - fMins.fY, fMaxs.fZ - fMins.fZ });
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -75,7 +75,6 @@ struct hsColor32 {
|
||||
}
|
||||
int operator!=(const hsColor32& aa) { return !(aa == *this); }
|
||||
};
|
||||
hsCTypeDefStruct(hsColor32)
|
||||
typedef hsColor32 hsRGBAColor32;
|
||||
|
||||
struct hsColorRGBA {
|
||||
|
@ -81,7 +81,7 @@ hsPoint3 hsQuat::Rotate(const hsScalarTriple* v) const
|
||||
hsQuat qVec(v->fX, v->fY, v->fZ, 0);
|
||||
hsQuat t = qInv * qVec;
|
||||
hsQuat res = (t * (*this));
|
||||
//hsAssert(hsABS(res.fW)<1e-5, "Error rotating vector");
|
||||
//hsAssert(fabs(res.fW)<1e-5, "Error rotating vector");
|
||||
return hsPoint3(res.fX, res.fY, res.fZ);
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#if HS_BUILD_FOR_WIN32
|
||||
# include <io.h>
|
||||
#endif
|
||||
#include <algorithm>
|
||||
#pragma hdrstop
|
||||
|
||||
#include "hsStream.h"
|
||||
@ -1054,7 +1055,7 @@ uint32_t hsQueueStream::Read(uint32_t byteCount, void * buffer)
|
||||
int32_t limit, length, total;
|
||||
|
||||
limit = fWriteCursor >= fReadCursor ? fWriteCursor : fSize;
|
||||
length = hsMinimum(limit-fReadCursor,byteCount);
|
||||
length = std::min(limit-fReadCursor, byteCount);
|
||||
HSMemory::BlockMove(fQueue+fReadCursor,buffer,length);
|
||||
fReadCursor += length;
|
||||
fReadCursor %= fSize;
|
||||
@ -1063,7 +1064,7 @@ uint32_t hsQueueStream::Read(uint32_t byteCount, void * buffer)
|
||||
if (length < byteCount && limit != fWriteCursor)
|
||||
{
|
||||
limit = fWriteCursor;
|
||||
length = hsMinimum(limit,byteCount-length);
|
||||
length = std::min(limit, static_cast<int32_t>(byteCount)-length);
|
||||
HSMemory::BlockMove(fQueue,static_cast<char*>(buffer)+total,length);
|
||||
fReadCursor = length;
|
||||
total += length;
|
||||
@ -1079,7 +1080,7 @@ uint32_t hsQueueStream::Write(uint32_t byteCount, const void* buffer)
|
||||
|
||||
int32_t length;
|
||||
|
||||
length = hsMinimum(fSize-fWriteCursor,byteCount);
|
||||
length = std::min(fSize-fWriteCursor, byteCount);
|
||||
HSMemory::BlockMove(buffer,fQueue+fWriteCursor,length);
|
||||
if (fReadCursor > fWriteCursor)
|
||||
{
|
||||
@ -1087,7 +1088,7 @@ uint32_t hsQueueStream::Write(uint32_t byteCount, const void* buffer)
|
||||
if (fReadCursor < fWriteCursor+length+1)
|
||||
hsStatusMessage("ReadCursor wrapped\n");
|
||||
#endif
|
||||
fReadCursor = hsMaximum(fReadCursor,fWriteCursor+length+1);
|
||||
fReadCursor = std::min(fReadCursor, fWriteCursor+length+1);
|
||||
fReadCursor %= fSize;
|
||||
}
|
||||
fWriteCursor += length;
|
||||
@ -1106,19 +1107,19 @@ void hsQueueStream::Skip(uint32_t deltaByteCount)
|
||||
int32_t limit, length;
|
||||
|
||||
limit = fWriteCursor >= fReadCursor ? fWriteCursor : fSize;
|
||||
length = hsMinimum(limit-fReadCursor,deltaByteCount);
|
||||
length = std::min(limit-fReadCursor, deltaByteCount);
|
||||
fReadCursor += length;
|
||||
|
||||
if (length < deltaByteCount && limit != fWriteCursor)
|
||||
{
|
||||
limit = fWriteCursor;
|
||||
length = hsMinimum(limit,deltaByteCount-length);
|
||||
length = std::min(limit, static_cast<int32_t>(deltaByteCount)-length);
|
||||
fReadCursor = length;
|
||||
}
|
||||
else
|
||||
{
|
||||
fReadCursor %= fSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hsQueueStream::Rewind()
|
||||
|
@ -47,6 +47,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
#include "hsRefCnt.h"
|
||||
|
||||
#include <cstdarg>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
#ifdef HS_DEBUGGING
|
||||
@ -238,7 +239,7 @@ void hsDynamicArray<T>::SetCount(int32_t count)
|
||||
{ T* newArray = new T[count];
|
||||
|
||||
if (fArray)
|
||||
{ int copyCount = hsMinimum(count, fCount);
|
||||
{ int copyCount = std::min(count, fCount);
|
||||
|
||||
for (int i = 0; i < copyCount; i++)
|
||||
newArray[i] = fArray[i];
|
||||
|
@ -61,8 +61,16 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
# define _WIN32_IE 0x400
|
||||
# endif
|
||||
|
||||
// HACK: Max headers depend on the min() and max() macros normally pulled
|
||||
// in by windows.h... However, we usually disable those, since they break
|
||||
// std::min and std::max. Therefore, we bring the std:: versions down to
|
||||
// the global namespace so we can still compile max code without breaking
|
||||
// everything else :/
|
||||
# ifndef NOMINMAX
|
||||
# define NOMINMAX
|
||||
# include <algorithm>
|
||||
using std::min;
|
||||
using std::max;
|
||||
# endif
|
||||
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
|
@ -270,9 +270,9 @@ bool plViewTransform::Intersect(const plViewTransform& view)
|
||||
int i;
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
mins[i] = hsMaximum(fMin[i], view.fMin[i]);
|
||||
mins[i] = std::max(fMin[i], view.fMin[i]);
|
||||
|
||||
maxs[i] = hsMinimum(fMax[i], view.fMax[i]);
|
||||
maxs[i] = std::min(fMax[i], view.fMax[i]);
|
||||
|
||||
if( mins[i] >= maxs[i] )
|
||||
{
|
||||
@ -292,9 +292,9 @@ bool plViewTransform::Union(const plViewTransform& view)
|
||||
int i;
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
mins[i] = hsMinimum(fMin[i], view.fMin[i]);
|
||||
mins[i] = std::min(fMin[i], view.fMin[i]);
|
||||
|
||||
maxs[i] = hsMaximum(fMax[i], view.fMax[i]);
|
||||
maxs[i] = std::max(fMax[i], view.fMax[i]);
|
||||
|
||||
}
|
||||
SetView(mins, maxs);
|
||||
|
Reference in New Issue
Block a user