Browse Source

Use std::min and std::max

Michael Hansen 11 years ago
parent
commit
e36220cca5
  1. 3
      Sources/Plasma/CoreLib/HeadSpin.h
  2. 4
      Sources/Plasma/CoreLib/hsBounds.cpp
  3. 4
      Sources/Plasma/CoreLib/hsBounds.h
  4. 14
      Sources/Plasma/CoreLib/hsStream.cpp
  5. 2
      Sources/Plasma/CoreLib/hsTemplates.h
  6. 8
      Sources/Plasma/CoreLib/plViewTransform.cpp
  7. 2
      Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp
  8. 29
      Sources/Plasma/FeatureLib/pfSurface/plLayerAVI.cpp
  9. 2
      Sources/Plasma/NucleusLib/inc/plProfile.h
  10. 2
      Sources/Plasma/NucleusLib/inc/plProfileManager.cpp
  11. 4
      Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp
  12. 2
      Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgr.cpp
  13. 2
      Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgrVS.cpp
  14. 2
      Sources/Plasma/PubUtilLib/plDrawable/plSpaceTreeMaker.cpp
  15. 2
      Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp
  16. 2
      Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp
  17. 4
      Sources/Plasma/PubUtilLib/plGImage/plMipmap.cpp
  18. 2
      Sources/Plasma/PubUtilLib/plGLight/plLightInfo.cpp
  19. 2
      Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.cpp
  20. 2
      Sources/Plasma/PubUtilLib/plInterp/plAnimPath.cpp
  21. 2
      Sources/Plasma/PubUtilLib/plInterp/plController.cpp
  22. 2
      Sources/Plasma/PubUtilLib/plMath/plAvg.cpp
  23. 4
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrShow.cpp
  24. 14
      Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEffect.cpp
  25. 2
      Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEmitter.cpp
  26. 2
      Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp
  27. 2
      Sources/Plasma/PubUtilLib/plPipeline/DX/plDXPipeline.cpp
  28. 3
      Sources/Plasma/PubUtilLib/plPipeline/DX/plDXShader.cpp
  29. 2
      Sources/Plasma/PubUtilLib/plPipeline/plStatusLogDrawer.cpp
  30. 10
      Sources/Plasma/PubUtilLib/plStatGather/plProfileManagerFull.cpp
  31. 8
      Sources/Tools/MaxConvert/plDistributor.cpp
  32. 12
      Sources/Tools/MaxMain/plMaxMeshExtractor.cpp
  33. 26
      Sources/Tools/MaxMain/plMaxNode.cpp
  34. 24
      Sources/Tools/MaxMain/plPhysXCooking.cpp
  35. 2
      Sources/Tools/MaxPlasmaLights/plRealTimeLights.cpp

3
Sources/Plasma/CoreLib/HeadSpin.h

@ -59,6 +59,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <cctype> #include <cctype>
#include <cstdarg> #include <cstdarg>
#include <cstdint> #include <cstdint>
#include <algorithm>
//====================================== //======================================
// Winblows Hacks // Winblows Hacks
@ -132,8 +133,6 @@ typedef uint32_t hsGSeedValue;
#define hsLongAlign(n) (((n) + 3) & ~3L) #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 hsABS(x) ((x) < 0 ? -(x) : (x))
#define hsSGN(x) (((x) < 0) ? -1 : ( ((x) > 0) ? 1 : 0 )) #define hsSGN(x) (((x) < 0) ? -1 : ( ((x) > 0) ? 1 : 0 ))

4
Sources/Plasma/CoreLib/hsBounds.cpp

@ -195,9 +195,9 @@ void hsBounds3::MakeSymmetric(const hsPoint3* p)
float delUp; float delUp;
delUp = fMaxs[i] - (*p)[i]; delUp = fMaxs[i] - (*p)[i];
delMax = hsMaximum(delMax, delUp); delMax = std::max(delMax, delUp);
delUp = (*p)[i] - fMins[i]; delUp = (*p)[i] - fMins[i];
delMax = hsMaximum(delMax, delUp); delMax = std::max(delMax, delUp);
} }
const float sqrtTwo = 1.41421f; const float sqrtTwo = 1.41421f;
delMax *= sqrtTwo; delMax *= sqrtTwo;

4
Sources/Plasma/CoreLib/hsBounds.h

@ -42,7 +42,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifndef hsBounds_inc #ifndef hsBounds_inc
#define hsBounds_inc #define hsBounds_inc
#include "hsGeometry3.h" #include "hsGeometry3.h"
#include "hsPoint2.h" #include "hsPoint2.h"
#include "hsMatrix44.h" #include "hsMatrix44.h"
@ -186,7 +186,7 @@ inline const hsPoint3& hsBounds3::GetCenter() const
inline float hsBounds3::GetMaxDim() const inline float hsBounds3::GetMaxDim() const
{ {
hsAssert(kBoundsNormal == fType, "Invalid type for GetMaxDim"); 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 });
} }
// //

14
Sources/Plasma/CoreLib/hsStream.cpp

@ -1054,7 +1054,7 @@ uint32_t hsQueueStream::Read(uint32_t byteCount, void * buffer)
int32_t limit, length, total; int32_t limit, length, total;
limit = fWriteCursor >= fReadCursor ? fWriteCursor : fSize; limit = fWriteCursor >= fReadCursor ? fWriteCursor : fSize;
length = hsMinimum(limit-fReadCursor,byteCount); length = std::min(limit-fReadCursor, byteCount);
HSMemory::BlockMove(fQueue+fReadCursor,buffer,length); HSMemory::BlockMove(fQueue+fReadCursor,buffer,length);
fReadCursor += length; fReadCursor += length;
fReadCursor %= fSize; fReadCursor %= fSize;
@ -1063,7 +1063,7 @@ uint32_t hsQueueStream::Read(uint32_t byteCount, void * buffer)
if (length < byteCount && limit != fWriteCursor) if (length < byteCount && limit != fWriteCursor)
{ {
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); HSMemory::BlockMove(fQueue,static_cast<char*>(buffer)+total,length);
fReadCursor = length; fReadCursor = length;
total += length; total += length;
@ -1079,7 +1079,7 @@ uint32_t hsQueueStream::Write(uint32_t byteCount, const void* buffer)
int32_t length; int32_t length;
length = hsMinimum(fSize-fWriteCursor,byteCount); length = std::min(fSize-fWriteCursor, byteCount);
HSMemory::BlockMove(buffer,fQueue+fWriteCursor,length); HSMemory::BlockMove(buffer,fQueue+fWriteCursor,length);
if (fReadCursor > fWriteCursor) if (fReadCursor > fWriteCursor)
{ {
@ -1087,7 +1087,7 @@ uint32_t hsQueueStream::Write(uint32_t byteCount, const void* buffer)
if (fReadCursor < fWriteCursor+length+1) if (fReadCursor < fWriteCursor+length+1)
hsStatusMessage("ReadCursor wrapped\n"); hsStatusMessage("ReadCursor wrapped\n");
#endif #endif
fReadCursor = hsMaximum(fReadCursor,fWriteCursor+length+1); fReadCursor = std::min(fReadCursor, fWriteCursor+length+1);
fReadCursor %= fSize; fReadCursor %= fSize;
} }
fWriteCursor += length; fWriteCursor += length;
@ -1106,19 +1106,19 @@ void hsQueueStream::Skip(uint32_t deltaByteCount)
int32_t limit, length; int32_t limit, length;
limit = fWriteCursor >= fReadCursor ? fWriteCursor : fSize; limit = fWriteCursor >= fReadCursor ? fWriteCursor : fSize;
length = hsMinimum(limit-fReadCursor,deltaByteCount); length = std::min(limit-fReadCursor, deltaByteCount);
fReadCursor += length; fReadCursor += length;
if (length < deltaByteCount && limit != fWriteCursor) if (length < deltaByteCount && limit != fWriteCursor)
{ {
limit = fWriteCursor; limit = fWriteCursor;
length = hsMinimum(limit,deltaByteCount-length); length = std::min(limit, static_cast<int32_t>(deltaByteCount)-length);
fReadCursor = length; fReadCursor = length;
} }
else else
{ {
fReadCursor %= fSize; fReadCursor %= fSize;
} }
} }
void hsQueueStream::Rewind() void hsQueueStream::Rewind()

2
Sources/Plasma/CoreLib/hsTemplates.h

@ -238,7 +238,7 @@ void hsDynamicArray<T>::SetCount(int32_t count)
{ T* newArray = new T[count]; { T* newArray = new T[count];
if (fArray) if (fArray)
{ int copyCount = hsMinimum(count, fCount); { int copyCount = std::min(count, fCount);
for (int i = 0; i < copyCount; i++) for (int i = 0; i < copyCount; i++)
newArray[i] = fArray[i]; newArray[i] = fArray[i];

8
Sources/Plasma/CoreLib/plViewTransform.cpp

@ -270,9 +270,9 @@ bool plViewTransform::Intersect(const plViewTransform& view)
int i; int i;
for( i = 0; i < 3; 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] ) if( mins[i] >= maxs[i] )
{ {
@ -292,9 +292,9 @@ bool plViewTransform::Union(const plViewTransform& view)
int i; int i;
for( i = 0; i < 3; 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); SetView(mins, maxs);

2
Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp

@ -133,7 +133,7 @@ void plDispatchLog::DumpMsg(plMessage* msg, int numReceivers, int sendTimeMs, in
float sendTime = hsTimer::GetMilliSeconds<float>(hsTimer::GetTicks() - fStartTicks); float sendTime = hsTimer::GetMilliSeconds<float>(hsTimer::GetTicks() - fStartTicks);
char indentStr[50]; char indentStr[50];
indent = hsMinimum(indent, sizeof(indentStr)-1); indent = std::min(indent, static_cast<int32_t>(sizeof(indentStr)-1));
memset(indentStr, ' ', indent); memset(indentStr, ' ', indent);
indentStr[indent] = '\0'; indentStr[indent] = '\0';

29
Sources/Plasma/FeatureLib/pfSurface/plLayerAVI.cpp

@ -162,21 +162,20 @@ static bool ICopySourceToTexture16(BITMAPINFO* bmi, plMipmap* b)
uint32_t* pix = (uint32_t*)b->GetImage(); uint32_t* pix = (uint32_t*)b->GetImage();
pix += b->GetWidth() * b->GetHeight(); pix += b->GetWidth() * b->GetHeight();
int width = bmi->bmiHeader.biWidth; uint32_t width = bmi->bmiHeader.biWidth;
int height = bmi->bmiHeader.biHeight; uint32_t height = bmi->bmiHeader.biHeight;
int useHeight = hsMinimum(height, b->GetHeight()); uint32_t useHeight = std::min(height, b->GetHeight());
int useWidth = hsMinimum(width, b->GetWidth()); uint32_t useWidth = std::min(width, b->GetWidth());
int i;
for( i = 0; i < useHeight; i++ ) for (uint32_t i = 0; i < useHeight; i++)
{ {
uint16_t* src = pSrc; uint16_t* src = pSrc;
pSrc += width; pSrc += width;
pix -= b->GetWidth(); pix -= b->GetWidth();
uint32_t* tPix = pix; uint32_t* tPix = pix;
int j; for (uint32_t j = 0; j < useWidth; j++)
for( j = 0; j < useWidth; j++ )
{ {
*tPix = ((*src & 0x001f) << 3) // up 3 *tPix = ((*src & 0x001f) << 3) // up 3
| ((*src & 0x03e0) << 6) // down 5 up 3 up 8 | ((*src & 0x03e0) << 6) // down 5 up 3 up 8
@ -199,22 +198,20 @@ static bool ICopySourceToTexture24(BITMAPINFO* bmi, plMipmap* b)
hsRGBAColor32* pix = (hsRGBAColor32*)b->GetImage(); hsRGBAColor32* pix = (hsRGBAColor32*)b->GetImage();
pix += b->GetWidth() * b->GetHeight(); pix += b->GetWidth() * b->GetHeight();
int width = bmi->bmiHeader.biWidth; uint32_t width = bmi->bmiHeader.biWidth;
int height = bmi->bmiHeader.biHeight; uint32_t height = bmi->bmiHeader.biHeight;
int useHeight = hsMinimum(height, b->GetHeight()); uint32_t useHeight = std::min(height, b->GetHeight());
int useWidth = hsMinimum(width, b->GetWidth()); uint32_t useWidth = std::min(width, b->GetWidth());
int i;
for( i = 0; i < useHeight; i++ ) for (uint32_t i = 0; i < useHeight; i++)
{ {
unsigned char* src = pSrc; unsigned char* src = pSrc;
pSrc += width * 3; pSrc += width * 3;
pix -= b->GetWidth(); pix -= b->GetWidth();
hsRGBAColor32* tPix = pix; hsRGBAColor32* tPix = pix;
int j; for (uint32_t j = 0; j < useWidth; j++)
for( j = 0; j < useWidth; j++ )
{ {
tPix->b = *src++; tPix->b = *src++;
tPix->g = *src++; tPix->g = *src++;

2
Sources/Plasma/NucleusLib/inc/plProfile.h

@ -158,7 +158,7 @@ protected:
uint32_t fAvgCount; uint32_t fAvgCount;
uint64_t fAvgTotal; uint64_t fAvgTotal;
uint32_t fLastAvg; uint32_t fLastAvg;
uint32_t fMax; uint64_t fMax;
bool fActive; bool fActive;
bool fRunning; bool fRunning;
uint8_t fDisplayFlags; uint8_t fDisplayFlags;

2
Sources/Plasma/NucleusLib/inc/plProfileManager.cpp

@ -161,7 +161,7 @@ void plProfileBase::EndFrame()
{ {
fAvgCount++; fAvgCount++;
fAvgTotal += fValue; fAvgTotal += fValue;
fMax = hsMaximum(fMax, fValue); fMax = std::max(fMax, fValue);
} }
void plProfileBase::UpdateAvg() void plProfileBase::UpdateAvg()

4
Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp

@ -402,7 +402,7 @@ void plWalkingStrategy::Apply(float delSecs)
// the largest, so we won't launch into the air if we're running uphill. // the largest, so we won't launch into the air if we're running uphill.
float prevZVel = achievedVelocity.fZ; float prevZVel = achievedVelocity.fZ;
if (IsOnGround()) if (IsOnGround())
prevZVel = hsMinimum(prevZVel, 0.0f); prevZVel = std::min(prevZVel, 0.0f);
velocity.fZ = prevZVel + (kGravity * delSecs); velocity.fZ = prevZVel + (kGravity * delSecs);
} }
@ -716,7 +716,7 @@ void plDynamicWalkingStrategy::Apply(float delSecs)
// the largest, so we won't launch into the air if we're running uphill. // the largest, so we won't launch into the air if we're running uphill.
float prevZVel = achievedVelocity.fZ; float prevZVel = achievedVelocity.fZ;
if (IsOnGround()) if (IsOnGround())
prevZVel = hsMinimum(prevZVel, 0.f); prevZVel = std::min(prevZVel, 0.f);
velocity.fZ = prevZVel + (kGravity * delSecs); velocity.fZ = prevZVel + (kGravity * delSecs);
} }

2
Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgr.cpp

@ -219,7 +219,7 @@ bool plDynaRippleMgr::IRippleFromShape(const plPrintShape* shape, bool force)
plConst(float) kHeightScale = 1.f; plConst(float) kHeightScale = 1.f;
pos.fZ += (shape->GetHeight() * fScale.fZ * kHeightScale) * 0.25f; pos.fZ += (shape->GetHeight() * fScale.fZ * kHeightScale) * 0.25f;
float wid = hsMaximum(shape->GetWidth(), shape->GetLength()); float wid = std::max(shape->GetWidth(), shape->GetLength());
hsVector3 size(wid * fScale.fX, wid * fScale.fY, shape->GetHeight() * fScale.fZ * kHeightScale); hsVector3 size(wid * fScale.fX, wid * fScale.fY, shape->GetHeight() * fScale.fZ * kHeightScale);
fCutter->SetLength(size); fCutter->SetLength(size);
fCutter->Set(pos, dir, up); fCutter->Set(pos, dir, up);

2
Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgrVS.cpp

@ -212,7 +212,7 @@ bool plDynaRippleVSMgr::IRippleFromShape(const plPrintShape* shape, bool force)
hsVector3 dir(fWaveSetBase->GetWindDir()); hsVector3 dir(fWaveSetBase->GetWindDir());
hsVector3 up(0.f, 0.f, 1.f); hsVector3 up(0.f, 0.f, 1.f);
float wid = hsMaximum(shape->GetWidth(), shape->GetLength()); float wid = std::max(shape->GetWidth(), shape->GetLength());
plConst(float) kMaxWaterDepth(1000.f); plConst(float) kMaxWaterDepth(1000.f);

2
Sources/Plasma/PubUtilLib/plDrawable/plSpaceTreeMaker.cpp

@ -591,7 +591,7 @@ int plSpaceTreeMaker::ITreeDepth(plSpacePrepNode* subRoot)
int dep0 = ITreeDepth(subRoot->fChildren[0]); int dep0 = ITreeDepth(subRoot->fChildren[0]);
int dep1 = ITreeDepth(subRoot->fChildren[1]); int dep1 = ITreeDepth(subRoot->fChildren[1]);
int dep = hsMaximum(dep0, dep1); int dep = std::max(dep0, dep1);
return dep+1; return dep+1;
} }

2
Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp

@ -301,7 +301,7 @@ uint32_t plEncryptedStream::Read(uint32_t bytes, void* buffer)
// Offset into the first buffer (0 if we are aligned on a chunk, which means no extra block read) // Offset into the first buffer (0 if we are aligned on a chunk, which means no extra block read)
uint32_t startChunkPos = startPos % kEncryptChunkSize; uint32_t startChunkPos = startPos % kEncryptChunkSize;
// Amount of data in the partial first chunk (0 if we're aligned) // Amount of data in the partial first chunk (0 if we're aligned)
uint32_t startAmt = (startChunkPos != 0) ? hsMinimum(kEncryptChunkSize - startChunkPos, bytes) : 0; uint32_t startAmt = (startChunkPos != 0) ? std::min(kEncryptChunkSize - startChunkPos, bytes) : 0;
uint32_t totalNumRead = IRead(bytes, buffer); uint32_t totalNumRead = IRead(bytes, buffer);

2
Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp

@ -434,7 +434,7 @@ uint32_t plSecureStream::Read(uint32_t bytes, void* buffer)
// Offset into the first buffer (0 if we are aligned on a chunk, which means no extra block read) // Offset into the first buffer (0 if we are aligned on a chunk, which means no extra block read)
uint32_t startChunkPos = startPos % kEncryptChunkSize; uint32_t startChunkPos = startPos % kEncryptChunkSize;
// Amount of data in the partial first chunk (0 if we're aligned) // Amount of data in the partial first chunk (0 if we're aligned)
uint32_t startAmt = (startChunkPos != 0) ? hsMinimum(kEncryptChunkSize - startChunkPos, bytes) : 0; uint32_t startAmt = (startChunkPos != 0) ? std::min(kEncryptChunkSize - startChunkPos, bytes) : 0;
uint32_t totalNumRead = IRead(bytes, buffer); uint32_t totalNumRead = IRead(bytes, buffer);

4
Sources/Plasma/PubUtilLib/plGImage/plMipmap.cpp

@ -994,9 +994,9 @@ float plMipmap::IGetDetailLevelAlpha( uint8_t level, float dropStart, float drop
detailAlpha = ( level - dropStart ) * ( min - max ) / ( dropStop - dropStart ) + max; detailAlpha = ( level - dropStart ) * ( min - max ) / ( dropStop - dropStart ) + max;
if( min < max ) if( min < max )
detailAlpha = hsMinimum( max, hsMaximum( min, detailAlpha ) ); detailAlpha = std::min(max, std::max(min, detailAlpha));
else else
detailAlpha = hsMinimum( min, hsMaximum( max, detailAlpha ) ); detailAlpha = std::min(min, std::max(max, detailAlpha));
return detailAlpha; return detailAlpha;
} }

2
Sources/Plasma/PubUtilLib/plGLight/plLightInfo.cpp

@ -951,7 +951,7 @@ void plSpotLightInfo::IRefresh()
float yon = GetRadius(); float yon = GetRadius();
if( yon < kMinHither ) if( yon < kMinHither )
yon = kMaxYon; yon = kMaxYon;
float hither = hsMinimum(kMinHither, yon * 0.5f); float hither = std::min(kMinHither, yon * 0.5f);
float sinFOV, cosFOV; float sinFOV, cosFOV;
hsFastMath::SinCos(effFOV, sinFOV, cosFOV); hsFastMath::SinCos(effFOV, sinFOV, cosFOV);

2
Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.cpp

@ -373,7 +373,7 @@ plShadowSlave* plShadowMaster::ILastChanceToBail(plShadowCastMsg* castMsg, plSha
float maxDist = fMaxDist > 0 float maxDist = fMaxDist > 0
? (fGlobalMaxDist > 0 ? (fGlobalMaxDist > 0
? hsMinimum(fMaxDist, fGlobalMaxDist) ? std::min(fMaxDist, fGlobalMaxDist)
: fMaxDist) : fMaxDist)
: fGlobalMaxDist; : fGlobalMaxDist;

2
Sources/Plasma/PubUtilLib/plInterp/plAnimPath.cpp

@ -271,7 +271,7 @@ float plAnimPath::GetExtremePoint(hsPoint3 &worldPt) const
{ {
float fore = keyTimes[i + 1] - t; float fore = keyTimes[i + 1] - t;
float back = t - keyTimes[i - 1]; float back = t - keyTimes[i - 1];
delTime = hsMaximum(fore, back); delTime = std::max(fore, back);
} }
} }
} }

2
Sources/Plasma/PubUtilLib/plInterp/plController.cpp

@ -816,7 +816,7 @@ float plCompoundController::GetLength() const
for(i=0; i<3; i++) for(i=0; i<3; i++)
{ {
if (GetController(i)) if (GetController(i))
len = hsMaximum(len, GetController(i)->GetLength()); len = std::max(len, GetController(i)->GetLength());
} }
return len; return len;
} }

2
Sources/Plasma/PubUtilLib/plMath/plAvg.cpp

@ -153,7 +153,7 @@ void TimeBasedAvgRing<T>::AddItem(T value, double time)
} }
// update the max avg // update the max avg
fMaxAvg = hsMaximum( fMaxAvg, fAvg ); fMaxAvg = std::max(fMaxAvg, fAvg);
} }

4
Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrShow.cpp

@ -234,7 +234,7 @@ void plNetClientMgr::IShowRelevanceRegions()
uint32_t maxPlayerName = 0; uint32_t maxPlayerName = 0;
txt.DrawString(x, y, GetPlayerName().c_str()); txt.DrawString(x, y, GetPlayerName().c_str());
maxPlayerName = hsMaximum(maxPlayerName, txt.CalcStringWidth(GetPlayerName().c_str())); maxPlayerName = std::max(maxPlayerName, txt.CalcStringWidth(GetPlayerName().c_str()));
y += yOff; y += yOff;
int i; int i;
@ -247,7 +247,7 @@ void plNetClientMgr::IShowRelevanceRegions()
const plString& name = mbr->GetPlayerName(); const plString& name = mbr->GetPlayerName();
txt.DrawString(x, y, name.c_str()); txt.DrawString(x, y, name.c_str());
maxPlayerName = hsMaximum(maxPlayerName, txt.CalcStringWidth(name.c_str())); maxPlayerName = std::max(maxPlayerName, txt.CalcStringWidth(name.c_str()));
y += yOff; y += yOff;
} }

14
Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEffect.cpp

@ -681,12 +681,11 @@ plParticleFlockEffect::~plParticleFlockEffect()
void plParticleFlockEffect::IUpdateDistances(const plEffectTargetInfo& target) void plParticleFlockEffect::IUpdateDistances(const plEffectTargetInfo& target)
{ {
int i, j; uint32_t numParticles = std::min(static_cast<uint32_t>(fMaxParticles), target.fNumValidParticles);
int numParticles = hsMinimum(fMaxParticles, target.fNumValidParticles);
for (i = 0; i < numParticles; i++) for (uint32_t i = 0; i < numParticles; i++)
{ {
for (j = i + 1; j < numParticles; j++) for (uint32_t j = i + 1; j < numParticles; j++)
{ {
hsVector3 diff((hsPoint3*)(target.fPos + i * target.fPosStride), (hsPoint3*)(target.fPos + j * target.fPosStride)); hsVector3 diff((hsPoint3*)(target.fPos + i * target.fPosStride), (hsPoint3*)(target.fPos + j * target.fPosStride));
fDistSq[i * fMaxParticles + j] = fDistSq[j * fMaxParticles + i] = diff.MagnitudeSquared(); fDistSq[i * fMaxParticles + j] = fDistSq[j * fMaxParticles + i] = diff.MagnitudeSquared();
@ -696,17 +695,16 @@ void plParticleFlockEffect::IUpdateDistances(const plEffectTargetInfo& target)
void plParticleFlockEffect::IUpdateInfluences(const plEffectTargetInfo &target) void plParticleFlockEffect::IUpdateInfluences(const plEffectTargetInfo &target)
{ {
int i, j; uint32_t numParticles = std::min(static_cast<uint32_t>(fMaxParticles), target.fNumValidParticles);
int numParticles = hsMinimum(fMaxParticles, target.fNumValidParticles);
for (i = 0; i < numParticles; i++) for (uint32_t i = 0; i < numParticles; i++)
{ {
int numAvg = 0; int numAvg = 0;
int numRep = 0; int numRep = 0;
fInfluences[i].fAvgVel.Set(0.f, 0.f, 0.f); fInfluences[i].fAvgVel.Set(0.f, 0.f, 0.f);
fInfluences[i].fRepDir.Set(0.f, 0.f, 0.f); fInfluences[i].fRepDir.Set(0.f, 0.f, 0.f);
for (j = 0; j < numParticles; j++) for (uint32_t j = 0; j < numParticles; j++)
{ {
if (i == j) if (i == j)
continue; continue;

2
Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEmitter.cpp

@ -261,7 +261,7 @@ void plParticleEmitter::UpdateGenerator(uint32_t paramID, float paramValue)
uint16_t plParticleEmitter::StealParticlesFrom(plParticleEmitter *victim, uint16_t num) uint16_t plParticleEmitter::StealParticlesFrom(plParticleEmitter *victim, uint16_t num)
{ {
uint16_t spaceAvail = (uint16_t)(fMaxParticles - fNumValidParticles); uint16_t spaceAvail = (uint16_t)(fMaxParticles - fNumValidParticles);
uint16_t numToCopy = (uint16_t)(hsMinimum(num, (victim ? victim->fNumValidParticles : 0))); uint16_t numToCopy = std::min(num, static_cast<uint16_t>(victim ? victim->fNumValidParticles : 0));
if (spaceAvail < numToCopy) if (spaceAvail < numToCopy)
numToCopy = spaceAvail; numToCopy = spaceAvail;

2
Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp

@ -701,7 +701,7 @@ void plSimulationMgr::ConsiderSynch(plPXPhysical* physical, plPXPhysical* other)
// If both objects are capable of syncing, we want to do it at the same // If both objects are capable of syncing, we want to do it at the same
// time, so no interpenetration issues pop up on other clients // time, so no interpenetration issues pop up on other clients
if (syncOther) if (syncOther)
timeElapsed = hsMaximum(timeElapsed, timeNow - other->GetLastSyncTime()); timeElapsed = std::max(timeElapsed, timeNow - other->GetLastSyncTime());
// Set the sync time to 1 second from the last sync // Set the sync time to 1 second from the last sync
double syncTime = 0.0; double syncTime = 0.0;

2
Sources/Plasma/PubUtilLib/plPipeline/DX/plDXPipeline.cpp

@ -6421,7 +6421,7 @@ plLayerInterface* plDXPipeline::IPopOverAllLayer(plLayerInterface* li)
// Calculate the number of active piggy backs. // Calculate the number of active piggy backs.
int plDXPipeline::ISetNumActivePiggyBacks() int plDXPipeline::ISetNumActivePiggyBacks()
{ {
return fActivePiggyBacks = hsMinimum(fSettings.fMaxPiggyBacks, fPiggyBackStack.GetCount()); return fActivePiggyBacks = std::min(static_cast<int>(fSettings.fMaxPiggyBacks), fPiggyBackStack.GetCount());
} }
// IPushProjPiggyBack ////////////////////////////////////////////////// // IPushProjPiggyBack //////////////////////////////////////////////////

3
Sources/Plasma/PubUtilLib/plPipeline/DX/plDXShader.cpp

@ -41,11 +41,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include "HeadSpin.h" #include "HeadSpin.h"
#define NOMINMAX
#include <d3d9.h> #include <d3d9.h>
#include <d3dx9core.h> #include <d3dx9core.h>
#include "HeadSpin.h"
#include "plDXShader.h" #include "plDXShader.h"
#include "plSurface/plShader.h" #include "plSurface/plShader.h"

2
Sources/Plasma/PubUtilLib/plPipeline/plStatusLogDrawer.cpp

@ -62,7 +62,7 @@ void plStatusLogDrawer::IDrawLogNames(plStatusLog* curLog, plStatusLog* firstLog
plStatusLog* iLog = firstLog; plStatusLog* iLog = firstLog;
while (iLog) while (iLog)
{ {
width = hsMaximum(drawText.CalcStringWidth_TEMP(iLog->GetFileName().AsString()) + 4, width); width = std::max(drawText.CalcStringWidth_TEMP(iLog->GetFileName().AsString()) + 4, width);
iLog = iLog->fNext; iLog = iLog->fNext;
numLogs++; numLogs++;
} }

10
Sources/Plasma/PubUtilLib/plStatGather/plProfileManagerFull.cpp

@ -189,7 +189,7 @@ static void PrintColumn(ProfileGroup& group, const char* groupName, int column,
height = 0; height = 0;
width = 0; width = 0;
width = hsMaximum(width, txt.CalcStringWidth(groupName) + 1); width = std::max(width, static_cast<int>(txt.CalcStringWidth(groupName) + 1));
txt.DrawString(x, y+height, groupName, 255, 255, 255, 255, plDebugText::kStyleBold); txt.DrawString(x, y+height, groupName, 255, 255, 255, 255, plDebugText::kStyleBold);
height += yInc; height += yInc;
@ -209,7 +209,7 @@ static void PrintColumn(ProfileGroup& group, const char* groupName, int column,
// 1 sample the width of the column will jump around. So we calculate the // 1 sample the width of the column will jump around. So we calculate the
// width based on the stat name plus the width of the widest sample we should // width based on the stat name plus the width of the widest sample we should
// get // get
width = hsMaximum(width, txt.CalcStringWidth(str) + samplesWidth + 1); width = std::max(width, static_cast<int>(txt.CalcStringWidth(str) + samplesWidth + 1));
// Now add on the samples text, if we have any // Now add on the samples text, if we have any
if (group[i]->GetTimerSamples()) if (group[i]->GetTimerSamples())
@ -235,12 +235,12 @@ static void PrintColumn(ProfileGroup& group, const char* groupName, int column,
txt.DrawString(x, y+height, str); txt.DrawString(x, y+height, str);
if (column != kColName) if (column != kColName)
width = hsMaximum(width, txt.CalcStringWidth(str) + 1); width = std::max(width, static_cast<int>(txt.CalcStringWidth(str) + 1));
height += yInc; height += yInc;
} }
// So the columns don't jump around as much as values change, pad them out to a certain width // So the columns don't jump around as much as values change, pad them out to a certain width
width = hsMaximum(width, txt.CalcStringWidth("000.0 ms") + 1); width = std::max(width, static_cast<int>(txt.CalcStringWidth("000.0 ms") + 1));
} }
static void PrintGroup(ProfileGroup& group, const char* groupName, int& x, int& y) static void PrintGroup(ProfileGroup& group, const char* groupName, int& x, int& y)
@ -315,7 +315,7 @@ void plProfileManagerFull::Update()
int x = 10; int x = 10;
PrintGroup(group, groupName.c_str(), x, y); PrintGroup(group, groupName.c_str(), x, y);
maxX = hsMaximum(maxX, x); maxX = std::max(maxX, x);
y += 10; y += 10;
} }

8
Sources/Tools/MaxConvert/plDistributor.cpp

@ -501,16 +501,16 @@ bool plDistributor::IFailsProbBitmap(int iFace, const Point3& bary) const
break; break;
case kMax: case kMax:
case kMaxColor: case kMaxColor:
frac = hsMaximum(evCol.r, hsMaximum(evCol.g, evCol.b)); frac = std::max({ evCol.r, evCol.g, evCol.b });
break; break;
case kMaxColorTimesAlpha: case kMaxColorTimesAlpha:
frac = hsMaximum(evCol.r, hsMaximum(evCol.g, evCol.b)) * evCol.a; frac = std::max({ evCol.r, evCol.g, evCol.b }) * evCol.a;
break; break;
case kMaxRedGreen: case kMaxRedGreen:
frac = hsMaximum(evCol.r, evCol.g); frac = std::max(evCol.r, evCol.g);
break; break;
case kMaxRedGreenTimesAlpha: case kMaxRedGreenTimesAlpha:
frac = hsMaximum(evCol.r, evCol.g) * evCol.a; frac = std::max(evCol.r, evCol.g) * evCol.a;
break; break;
} }

12
Sources/Tools/MaxMain/plMaxMeshExtractor.cpp

@ -83,12 +83,12 @@ static void MeshMinMax(hsPoint3& min, hsPoint3& max, int numVerts, hsPoint3* pVe
for (int i = 0; i < numVerts; i++) for (int i = 0; i < numVerts; i++)
{ {
hsPoint3* vert = &pVerts[i]; hsPoint3* vert = &pVerts[i];
min.fX = hsMinimum(vert->fX, min.fX); min.fX = std::min(vert->fX, min.fX);
min.fY = hsMinimum(vert->fY, min.fY); min.fY = std::min(vert->fY, min.fY);
min.fZ = hsMinimum(vert->fZ, min.fZ); min.fZ = std::min(vert->fZ, min.fZ);
max.fX = hsMaximum(vert->fX, max.fX); max.fX = std::max(vert->fX, max.fX);
max.fY = hsMaximum(vert->fY, max.fY); max.fY = std::max(vert->fY, max.fY);
max.fZ = hsMaximum(vert->fZ, max.fZ); max.fZ = std::max(vert->fZ, max.fZ);
} }
} }

26
Sources/Tools/MaxMain/plMaxNode.cpp

@ -699,12 +699,12 @@ bool plMaxNode::MakePhysical(plErrorMsg *pErrMsg, plConvertSettings *settings)
hsPoint3 minV(FLT_MAX, FLT_MAX, FLT_MAX), maxV(-FLT_MAX, -FLT_MAX, -FLT_MAX); hsPoint3 minV(FLT_MAX, FLT_MAX, FLT_MAX), maxV(-FLT_MAX, -FLT_MAX, -FLT_MAX);
for (int i = 0; i < mesh.fNumVerts; i++) for (int i = 0; i < mesh.fNumVerts; i++)
{ {
minV.fX = hsMinimum(mesh.fVerts[i].fX, minV.fX); minV.fX = std::min(mesh.fVerts[i].fX, minV.fX);
minV.fY = hsMinimum(mesh.fVerts[i].fY, minV.fY); minV.fY = std::min(mesh.fVerts[i].fY, minV.fY);
minV.fZ = hsMinimum(mesh.fVerts[i].fZ, minV.fZ); minV.fZ = std::min(mesh.fVerts[i].fZ, minV.fZ);
maxV.fX = hsMaximum(mesh.fVerts[i].fX, maxV.fX); maxV.fX = std::max(mesh.fVerts[i].fX, maxV.fX);
maxV.fY = hsMaximum(mesh.fVerts[i].fY, maxV.fY); maxV.fY = std::max(mesh.fVerts[i].fY, maxV.fY);
maxV.fZ = hsMaximum(mesh.fVerts[i].fZ, maxV.fZ); maxV.fZ = std::max(mesh.fVerts[i].fZ, maxV.fZ);
} }
hsPoint3 width = maxV - minV; hsPoint3 width = maxV - minV;
recipe.bDimensions = width / 2; recipe.bDimensions = width / 2;
@ -770,15 +770,15 @@ bool plMaxNode::MakePhysical(plErrorMsg *pErrMsg, plConvertSettings *settings)
hsPoint3 minV(FLT_MAX, FLT_MAX, FLT_MAX), maxV(-FLT_MAX, -FLT_MAX, -FLT_MAX); hsPoint3 minV(FLT_MAX, FLT_MAX, FLT_MAX), maxV(-FLT_MAX, -FLT_MAX, -FLT_MAX);
for (int i = 0; i < mesh.fNumVerts; i++) for (int i = 0; i < mesh.fNumVerts; i++)
{ {
minV.fX = hsMinimum(mesh.fVerts[i].fX, minV.fX); minV.fX = std::min(mesh.fVerts[i].fX, minV.fX);
minV.fY = hsMinimum(mesh.fVerts[i].fY, minV.fY); minV.fY = std::min(mesh.fVerts[i].fY, minV.fY);
minV.fZ = hsMinimum(mesh.fVerts[i].fZ, minV.fZ); minV.fZ = std::min(mesh.fVerts[i].fZ, minV.fZ);
maxV.fX = hsMaximum(mesh.fVerts[i].fX, maxV.fX); maxV.fX = std::max(mesh.fVerts[i].fX, maxV.fX);
maxV.fY = hsMaximum(mesh.fVerts[i].fY, maxV.fY); maxV.fY = std::max(mesh.fVerts[i].fY, maxV.fY);
maxV.fZ = hsMaximum(mesh.fVerts[i].fZ, maxV.fZ); maxV.fZ = std::max(mesh.fVerts[i].fZ, maxV.fZ);
} }
hsPoint3 width = maxV - minV; hsPoint3 width = maxV - minV;
recipe.radius = hsMaximum(width.fX, hsMaximum(width.fY, width.fZ)); recipe.radius = std::max({ width.fX, width.fY, width.fZ });
recipe.radius /= 2.f; recipe.radius /= 2.f;
recipe.offset = minV + (width / 2.f); recipe.offset = minV + (width / 2.f);
} }

24
Sources/Tools/MaxMain/plPhysXCooking.cpp

@ -304,12 +304,12 @@ void ReadBoxFromHull(hsStream* stream, NxBoxShapeDesc& box)
for (int i = 0; i < nVertices; i++) for (int i = 0; i < nVertices; i++)
{ {
hsPoint3& vec = pVertices[i]; hsPoint3& vec = pVertices[i];
minX = hsMinimum(minX, vec.fX); minX = std::min(minX, vec.fX);
minY = hsMinimum(minY, vec.fY); minY = std::min(minY, vec.fY);
minZ = hsMinimum(minZ, vec.fZ); minZ = std::min(minZ, vec.fZ);
maxX = hsMaximum(maxX, vec.fX); maxX = std::max(maxX, vec.fX);
maxY = hsMaximum(maxY, vec.fY); maxY = std::max(maxY, vec.fY);
maxZ = hsMaximum(maxZ, vec.fZ); maxZ = std::max(maxZ, vec.fZ);
} }
delete[] pVertices; delete[] pVertices;
@ -453,12 +453,12 @@ hsVectorStream* plPhysXCooking::IMakePolytope(const plMaxMeshExtractor::NeutralM
} }
for(int i=0;i<inMesh.fNumVerts;i++) for(int i=0;i<inMesh.fNumVerts;i++)
{ {
AABBMin.fX = hsMinimum(nxLocs2[i].x, AABBMin.fX); AABBMin.fX = std::min(nxLocs2[i].x, AABBMin.fX);
AABBMin.fY = hsMinimum(nxLocs2[i].y, AABBMin.fY); AABBMin.fY = std::min(nxLocs2[i].y, AABBMin.fY);
AABBMin.fZ = hsMinimum(nxLocs2[i].z, AABBMin.fZ); AABBMin.fZ = std::min(nxLocs2[i].z, AABBMin.fZ);
AABBMax.fX = hsMaximum(nxLocs2[i].x, AABBMax.fX); AABBMax.fX = std::max(nxLocs2[i].x, AABBMax.fX);
AABBMax.fY = hsMaximum(nxLocs2[i].y, AABBMax.fY); AABBMax.fY = std::max(nxLocs2[i].y, AABBMax.fY);
AABBMax.fZ = hsMaximum(nxLocs2[i].z, AABBMax.fZ); AABBMax.fZ = std::max(nxLocs2[i].z, AABBMax.fZ);
} }
int resultingPoints=0; int resultingPoints=0;

2
Sources/Tools/MaxPlasmaLights/plRealTimeLights.cpp

@ -315,7 +315,7 @@ int SpotLight::Update(TimeValue t, const RendContext &rc, RenderGlobalContext *r
decayRadius = gl->GetDecayRadius(t); decayRadius = gl->GetDecayRadius(t);
projector = gl->GetProjector(); projector = gl->GetProjector();
fov = hsMaximum(fs,hs); fov = std::max(fs, hs);
float aspect = 1.0f; float aspect = 1.0f;

Loading…
Cancel
Save