From e36220cca5eaf57c30fc2aeca5a7cdcc565f10c0 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Tue, 22 Jul 2014 21:12:09 -0700 Subject: [PATCH] Use std::min and std::max --- Sources/Plasma/CoreLib/HeadSpin.h | 3 +- Sources/Plasma/CoreLib/hsBounds.cpp | 4 +-- Sources/Plasma/CoreLib/hsBounds.h | 4 +-- Sources/Plasma/CoreLib/hsStream.cpp | 14 ++++----- Sources/Plasma/CoreLib/hsTemplates.h | 2 +- Sources/Plasma/CoreLib/plViewTransform.cpp | 8 ++--- .../FeatureLib/pfConsole/pfDispatchLog.cpp | 2 +- .../FeatureLib/pfSurface/plLayerAVI.cpp | 29 +++++++++---------- Sources/Plasma/NucleusLib/inc/plProfile.h | 2 +- .../NucleusLib/inc/plProfileManager.cpp | 2 +- .../plAvatar/plPhysicalControllerCore.cpp | 4 +-- .../PubUtilLib/plDrawable/plDynaRippleMgr.cpp | 2 +- .../plDrawable/plDynaRippleMgrVS.cpp | 2 +- .../plDrawable/plSpaceTreeMaker.cpp | 2 +- .../PubUtilLib/plFile/plEncryptedStream.cpp | 2 +- .../PubUtilLib/plFile/plSecureStream.cpp | 2 +- .../Plasma/PubUtilLib/plGImage/plMipmap.cpp | 4 +-- .../PubUtilLib/plGLight/plLightInfo.cpp | 2 +- .../PubUtilLib/plGLight/plShadowMaster.cpp | 2 +- .../Plasma/PubUtilLib/plInterp/plAnimPath.cpp | 2 +- .../PubUtilLib/plInterp/plController.cpp | 2 +- Sources/Plasma/PubUtilLib/plMath/plAvg.cpp | 2 +- .../plNetClient/plNetClientMgrShow.cpp | 4 +-- .../plParticleSystem/plParticleEffect.cpp | 14 ++++----- .../plParticleSystem/plParticleEmitter.cpp | 2 +- .../PubUtilLib/plPhysX/plSimulationMgr.cpp | 2 +- .../PubUtilLib/plPipeline/DX/plDXPipeline.cpp | 2 +- .../PubUtilLib/plPipeline/DX/plDXShader.cpp | 3 +- .../plPipeline/plStatusLogDrawer.cpp | 2 +- .../plStatGather/plProfileManagerFull.cpp | 10 +++---- Sources/Tools/MaxConvert/plDistributor.cpp | 8 ++--- Sources/Tools/MaxMain/plMaxMeshExtractor.cpp | 12 ++++---- Sources/Tools/MaxMain/plMaxNode.cpp | 26 ++++++++--------- Sources/Tools/MaxMain/plPhysXCooking.cpp | 24 +++++++-------- .../MaxPlasmaLights/plRealTimeLights.cpp | 2 +- 35 files changed, 101 insertions(+), 108 deletions(-) diff --git a/Sources/Plasma/CoreLib/HeadSpin.h b/Sources/Plasma/CoreLib/HeadSpin.h index f14cabc6..471d9efc 100644 --- a/Sources/Plasma/CoreLib/HeadSpin.h +++ b/Sources/Plasma/CoreLib/HeadSpin.h @@ -59,6 +59,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include #include #include +#include //====================================== // Winblows Hacks @@ -132,8 +133,6 @@ typedef uint32_t hsGSeedValue; #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 )) diff --git a/Sources/Plasma/CoreLib/hsBounds.cpp b/Sources/Plasma/CoreLib/hsBounds.cpp index dabd8b12..95d28211 100644 --- a/Sources/Plasma/CoreLib/hsBounds.cpp +++ b/Sources/Plasma/CoreLib/hsBounds.cpp @@ -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; diff --git a/Sources/Plasma/CoreLib/hsBounds.h b/Sources/Plasma/CoreLib/hsBounds.h index 82e91efd..3fc56837 100644 --- a/Sources/Plasma/CoreLib/hsBounds.h +++ b/Sources/Plasma/CoreLib/hsBounds.h @@ -42,7 +42,7 @@ 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" @@ -186,7 +186,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 }); } // diff --git a/Sources/Plasma/CoreLib/hsStream.cpp b/Sources/Plasma/CoreLib/hsStream.cpp index f93d04dc..72f4f65f 100644 --- a/Sources/Plasma/CoreLib/hsStream.cpp +++ b/Sources/Plasma/CoreLib/hsStream.cpp @@ -1054,7 +1054,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 +1063,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(byteCount)-length); HSMemory::BlockMove(fQueue,static_cast(buffer)+total,length); fReadCursor = length; total += length; @@ -1079,7 +1079,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 +1087,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 +1106,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(deltaByteCount)-length); fReadCursor = length; } else { fReadCursor %= fSize; -} + } } void hsQueueStream::Rewind() diff --git a/Sources/Plasma/CoreLib/hsTemplates.h b/Sources/Plasma/CoreLib/hsTemplates.h index f25d4261..f5f0ffe4 100644 --- a/Sources/Plasma/CoreLib/hsTemplates.h +++ b/Sources/Plasma/CoreLib/hsTemplates.h @@ -238,7 +238,7 @@ void hsDynamicArray::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]; diff --git a/Sources/Plasma/CoreLib/plViewTransform.cpp b/Sources/Plasma/CoreLib/plViewTransform.cpp index 78579da7..d76f6907 100644 --- a/Sources/Plasma/CoreLib/plViewTransform.cpp +++ b/Sources/Plasma/CoreLib/plViewTransform.cpp @@ -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); diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp index 96c0bb9e..1f76944a 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfDispatchLog.cpp @@ -133,7 +133,7 @@ void plDispatchLog::DumpMsg(plMessage* msg, int numReceivers, int sendTimeMs, in float sendTime = hsTimer::GetMilliSeconds(hsTimer::GetTicks() - fStartTicks); char indentStr[50]; - indent = hsMinimum(indent, sizeof(indentStr)-1); + indent = std::min(indent, static_cast(sizeof(indentStr)-1)); memset(indentStr, ' ', indent); indentStr[indent] = '\0'; diff --git a/Sources/Plasma/FeatureLib/pfSurface/plLayerAVI.cpp b/Sources/Plasma/FeatureLib/pfSurface/plLayerAVI.cpp index 99e9b1d2..416fd68e 100644 --- a/Sources/Plasma/FeatureLib/pfSurface/plLayerAVI.cpp +++ b/Sources/Plasma/FeatureLib/pfSurface/plLayerAVI.cpp @@ -162,21 +162,20 @@ static bool ICopySourceToTexture16(BITMAPINFO* bmi, plMipmap* b) uint32_t* pix = (uint32_t*)b->GetImage(); pix += b->GetWidth() * b->GetHeight(); - int width = bmi->bmiHeader.biWidth; - int height = bmi->bmiHeader.biHeight; + uint32_t width = bmi->bmiHeader.biWidth; + uint32_t height = bmi->bmiHeader.biHeight; - int useHeight = hsMinimum(height, b->GetHeight()); - int useWidth = hsMinimum(width, b->GetWidth()); - int i; - for( i = 0; i < useHeight; i++ ) + uint32_t useHeight = std::min(height, b->GetHeight()); + uint32_t useWidth = std::min(width, b->GetWidth()); + + for (uint32_t i = 0; i < useHeight; i++) { uint16_t* src = pSrc; pSrc += width; pix -= b->GetWidth(); uint32_t* tPix = pix; - int j; - for( j = 0; j < useWidth; j++ ) + for (uint32_t j = 0; j < useWidth; j++) { *tPix = ((*src & 0x001f) << 3) // up 3 | ((*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(); pix += b->GetWidth() * b->GetHeight(); - int width = bmi->bmiHeader.biWidth; - int height = bmi->bmiHeader.biHeight; + uint32_t width = bmi->bmiHeader.biWidth; + uint32_t height = bmi->bmiHeader.biHeight; - int useHeight = hsMinimum(height, b->GetHeight()); - int useWidth = hsMinimum(width, b->GetWidth()); - int i; + uint32_t useHeight = std::min(height, b->GetHeight()); + uint32_t useWidth = std::min(width, b->GetWidth()); - for( i = 0; i < useHeight; i++ ) + for (uint32_t i = 0; i < useHeight; i++) { unsigned char* src = pSrc; pSrc += width * 3; pix -= b->GetWidth(); hsRGBAColor32* tPix = pix; - int j; - for( j = 0; j < useWidth; j++ ) + for (uint32_t j = 0; j < useWidth; j++) { tPix->b = *src++; tPix->g = *src++; diff --git a/Sources/Plasma/NucleusLib/inc/plProfile.h b/Sources/Plasma/NucleusLib/inc/plProfile.h index 9dc7cbd0..6ccba04c 100644 --- a/Sources/Plasma/NucleusLib/inc/plProfile.h +++ b/Sources/Plasma/NucleusLib/inc/plProfile.h @@ -158,7 +158,7 @@ protected: uint32_t fAvgCount; uint64_t fAvgTotal; uint32_t fLastAvg; - uint32_t fMax; + uint64_t fMax; bool fActive; bool fRunning; uint8_t fDisplayFlags; diff --git a/Sources/Plasma/NucleusLib/inc/plProfileManager.cpp b/Sources/Plasma/NucleusLib/inc/plProfileManager.cpp index 1c6f2eea..d8a380bd 100644 --- a/Sources/Plasma/NucleusLib/inc/plProfileManager.cpp +++ b/Sources/Plasma/NucleusLib/inc/plProfileManager.cpp @@ -161,7 +161,7 @@ void plProfileBase::EndFrame() { fAvgCount++; fAvgTotal += fValue; - fMax = hsMaximum(fMax, fValue); + fMax = std::max(fMax, fValue); } void plProfileBase::UpdateAvg() diff --git a/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp b/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp index ea9dc96f..c515e7f1 100644 --- a/Sources/Plasma/PubUtilLib/plAvatar/plPhysicalControllerCore.cpp +++ b/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. float prevZVel = achievedVelocity.fZ; if (IsOnGround()) - prevZVel = hsMinimum(prevZVel, 0.0f); + prevZVel = std::min(prevZVel, 0.0f); 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. float prevZVel = achievedVelocity.fZ; if (IsOnGround()) - prevZVel = hsMinimum(prevZVel, 0.f); + prevZVel = std::min(prevZVel, 0.f); velocity.fZ = prevZVel + (kGravity * delSecs); } diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgr.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgr.cpp index e6fbd8e5..9e246c68 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgr.cpp @@ -219,7 +219,7 @@ bool plDynaRippleMgr::IRippleFromShape(const plPrintShape* shape, bool force) plConst(float) kHeightScale = 1.f; 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); fCutter->SetLength(size); fCutter->Set(pos, dir, up); diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgrVS.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgrVS.cpp index a6cd0ce9..96b2547b 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgrVS.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgrVS.cpp @@ -212,7 +212,7 @@ bool plDynaRippleVSMgr::IRippleFromShape(const plPrintShape* shape, bool force) hsVector3 dir(fWaveSetBase->GetWindDir()); 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); diff --git a/Sources/Plasma/PubUtilLib/plDrawable/plSpaceTreeMaker.cpp b/Sources/Plasma/PubUtilLib/plDrawable/plSpaceTreeMaker.cpp index d93cd59b..c8c2da1d 100644 --- a/Sources/Plasma/PubUtilLib/plDrawable/plSpaceTreeMaker.cpp +++ b/Sources/Plasma/PubUtilLib/plDrawable/plSpaceTreeMaker.cpp @@ -591,7 +591,7 @@ int plSpaceTreeMaker::ITreeDepth(plSpacePrepNode* subRoot) int dep0 = ITreeDepth(subRoot->fChildren[0]); int dep1 = ITreeDepth(subRoot->fChildren[1]); - int dep = hsMaximum(dep0, dep1); + int dep = std::max(dep0, dep1); return dep+1; } diff --git a/Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp b/Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp index 217aafab..e6b96279 100644 --- a/Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp +++ b/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) uint32_t startChunkPos = startPos % kEncryptChunkSize; // 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); diff --git a/Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp b/Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp index 391bb807..c99c4b19 100644 --- a/Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp +++ b/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) uint32_t startChunkPos = startPos % kEncryptChunkSize; // 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); diff --git a/Sources/Plasma/PubUtilLib/plGImage/plMipmap.cpp b/Sources/Plasma/PubUtilLib/plGImage/plMipmap.cpp index 9ec4a70a..5cdf684c 100644 --- a/Sources/Plasma/PubUtilLib/plGImage/plMipmap.cpp +++ b/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; if( min < max ) - detailAlpha = hsMinimum( max, hsMaximum( min, detailAlpha ) ); + detailAlpha = std::min(max, std::max(min, detailAlpha)); else - detailAlpha = hsMinimum( min, hsMaximum( max, detailAlpha ) ); + detailAlpha = std::min(min, std::max(max, detailAlpha)); return detailAlpha; } diff --git a/Sources/Plasma/PubUtilLib/plGLight/plLightInfo.cpp b/Sources/Plasma/PubUtilLib/plGLight/plLightInfo.cpp index a284092c..b22eb1ec 100644 --- a/Sources/Plasma/PubUtilLib/plGLight/plLightInfo.cpp +++ b/Sources/Plasma/PubUtilLib/plGLight/plLightInfo.cpp @@ -951,7 +951,7 @@ void plSpotLightInfo::IRefresh() float yon = GetRadius(); if( yon < kMinHither ) yon = kMaxYon; - float hither = hsMinimum(kMinHither, yon * 0.5f); + float hither = std::min(kMinHither, yon * 0.5f); float sinFOV, cosFOV; hsFastMath::SinCos(effFOV, sinFOV, cosFOV); diff --git a/Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.cpp b/Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.cpp index 49464f7b..40d99dcd 100644 --- a/Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.cpp +++ b/Sources/Plasma/PubUtilLib/plGLight/plShadowMaster.cpp @@ -373,7 +373,7 @@ plShadowSlave* plShadowMaster::ILastChanceToBail(plShadowCastMsg* castMsg, plSha float maxDist = fMaxDist > 0 ? (fGlobalMaxDist > 0 - ? hsMinimum(fMaxDist, fGlobalMaxDist) + ? std::min(fMaxDist, fGlobalMaxDist) : fMaxDist) : fGlobalMaxDist; diff --git a/Sources/Plasma/PubUtilLib/plInterp/plAnimPath.cpp b/Sources/Plasma/PubUtilLib/plInterp/plAnimPath.cpp index d921772e..e25ba89c 100644 --- a/Sources/Plasma/PubUtilLib/plInterp/plAnimPath.cpp +++ b/Sources/Plasma/PubUtilLib/plInterp/plAnimPath.cpp @@ -271,7 +271,7 @@ float plAnimPath::GetExtremePoint(hsPoint3 &worldPt) const { float fore = keyTimes[i + 1] - t; float back = t - keyTimes[i - 1]; - delTime = hsMaximum(fore, back); + delTime = std::max(fore, back); } } } diff --git a/Sources/Plasma/PubUtilLib/plInterp/plController.cpp b/Sources/Plasma/PubUtilLib/plInterp/plController.cpp index 3a29b82c..79baf8a9 100644 --- a/Sources/Plasma/PubUtilLib/plInterp/plController.cpp +++ b/Sources/Plasma/PubUtilLib/plInterp/plController.cpp @@ -816,7 +816,7 @@ float plCompoundController::GetLength() const for(i=0; i<3; i++) { if (GetController(i)) - len = hsMaximum(len, GetController(i)->GetLength()); + len = std::max(len, GetController(i)->GetLength()); } return len; } diff --git a/Sources/Plasma/PubUtilLib/plMath/plAvg.cpp b/Sources/Plasma/PubUtilLib/plMath/plAvg.cpp index cefae7fd..9e7be7cf 100644 --- a/Sources/Plasma/PubUtilLib/plMath/plAvg.cpp +++ b/Sources/Plasma/PubUtilLib/plMath/plAvg.cpp @@ -153,7 +153,7 @@ void TimeBasedAvgRing::AddItem(T value, double time) } // update the max avg - fMaxAvg = hsMaximum( fMaxAvg, fAvg ); + fMaxAvg = std::max(fMaxAvg, fAvg); } diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrShow.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrShow.cpp index 42279dfa..5c370143 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrShow.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgrShow.cpp @@ -234,7 +234,7 @@ void plNetClientMgr::IShowRelevanceRegions() uint32_t maxPlayerName = 0; 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; int i; @@ -247,7 +247,7 @@ void plNetClientMgr::IShowRelevanceRegions() const plString& name = mbr->GetPlayerName(); 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; } diff --git a/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEffect.cpp b/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEffect.cpp index d2db210a..78a662ab 100644 --- a/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEffect.cpp +++ b/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEffect.cpp @@ -681,12 +681,11 @@ plParticleFlockEffect::~plParticleFlockEffect() void plParticleFlockEffect::IUpdateDistances(const plEffectTargetInfo& target) { - int i, j; - int numParticles = hsMinimum(fMaxParticles, target.fNumValidParticles); + uint32_t numParticles = std::min(static_cast(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)); 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) { - int i, j; - int numParticles = hsMinimum(fMaxParticles, target.fNumValidParticles); + uint32_t numParticles = std::min(static_cast(fMaxParticles), target.fNumValidParticles); - for (i = 0; i < numParticles; i++) + for (uint32_t i = 0; i < numParticles; i++) { int numAvg = 0; int numRep = 0; fInfluences[i].fAvgVel.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) continue; diff --git a/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEmitter.cpp b/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEmitter.cpp index aeeb15ac..ec5c51dd 100644 --- a/Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEmitter.cpp +++ b/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 spaceAvail = (uint16_t)(fMaxParticles - fNumValidParticles); - uint16_t numToCopy = (uint16_t)(hsMinimum(num, (victim ? victim->fNumValidParticles : 0))); + uint16_t numToCopy = std::min(num, static_cast(victim ? victim->fNumValidParticles : 0)); if (spaceAvail < numToCopy) numToCopy = spaceAvail; diff --git a/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp b/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp index 468c5a8d..23531fb0 100644 --- a/Sources/Plasma/PubUtilLib/plPhysX/plSimulationMgr.cpp +++ b/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 // time, so no interpenetration issues pop up on other clients 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 double syncTime = 0.0; diff --git a/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXPipeline.cpp b/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXPipeline.cpp index 733297a1..23de0275 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXPipeline.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXPipeline.cpp @@ -6421,7 +6421,7 @@ plLayerInterface* plDXPipeline::IPopOverAllLayer(plLayerInterface* li) // Calculate the number of active piggy backs. int plDXPipeline::ISetNumActivePiggyBacks() { - return fActivePiggyBacks = hsMinimum(fSettings.fMaxPiggyBacks, fPiggyBackStack.GetCount()); + return fActivePiggyBacks = std::min(static_cast(fSettings.fMaxPiggyBacks), fPiggyBackStack.GetCount()); } // IPushProjPiggyBack ////////////////////////////////////////////////// diff --git a/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXShader.cpp b/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXShader.cpp index ef5f9b1b..2f9def01 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXShader.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/DX/plDXShader.cpp @@ -41,11 +41,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com *==LICENSE==*/ #include "HeadSpin.h" +#define NOMINMAX #include #include -#include "HeadSpin.h" - #include "plDXShader.h" #include "plSurface/plShader.h" diff --git a/Sources/Plasma/PubUtilLib/plPipeline/plStatusLogDrawer.cpp b/Sources/Plasma/PubUtilLib/plPipeline/plStatusLogDrawer.cpp index 8a996b79..72ab227c 100644 --- a/Sources/Plasma/PubUtilLib/plPipeline/plStatusLogDrawer.cpp +++ b/Sources/Plasma/PubUtilLib/plPipeline/plStatusLogDrawer.cpp @@ -62,7 +62,7 @@ void plStatusLogDrawer::IDrawLogNames(plStatusLog* curLog, plStatusLog* firstLog plStatusLog* iLog = firstLog; 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; numLogs++; } diff --git a/Sources/Plasma/PubUtilLib/plStatGather/plProfileManagerFull.cpp b/Sources/Plasma/PubUtilLib/plStatGather/plProfileManagerFull.cpp index 004c7807..0e3b0644 100644 --- a/Sources/Plasma/PubUtilLib/plStatGather/plProfileManagerFull.cpp +++ b/Sources/Plasma/PubUtilLib/plStatGather/plProfileManagerFull.cpp @@ -189,7 +189,7 @@ static void PrintColumn(ProfileGroup& group, const char* groupName, int column, height = 0; width = 0; - width = hsMaximum(width, txt.CalcStringWidth(groupName) + 1); + width = std::max(width, static_cast(txt.CalcStringWidth(groupName) + 1)); txt.DrawString(x, y+height, groupName, 255, 255, 255, 255, plDebugText::kStyleBold); 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 // width based on the stat name plus the width of the widest sample we should // get - width = hsMaximum(width, txt.CalcStringWidth(str) + samplesWidth + 1); + width = std::max(width, static_cast(txt.CalcStringWidth(str) + samplesWidth + 1)); // Now add on the samples text, if we have any if (group[i]->GetTimerSamples()) @@ -235,12 +235,12 @@ static void PrintColumn(ProfileGroup& group, const char* groupName, int column, txt.DrawString(x, y+height, str); if (column != kColName) - width = hsMaximum(width, txt.CalcStringWidth(str) + 1); + width = std::max(width, static_cast(txt.CalcStringWidth(str) + 1)); height += yInc; } // 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(txt.CalcStringWidth("000.0 ms") + 1)); } static void PrintGroup(ProfileGroup& group, const char* groupName, int& x, int& y) @@ -315,7 +315,7 @@ void plProfileManagerFull::Update() int x = 10; PrintGroup(group, groupName.c_str(), x, y); - maxX = hsMaximum(maxX, x); + maxX = std::max(maxX, x); y += 10; } diff --git a/Sources/Tools/MaxConvert/plDistributor.cpp b/Sources/Tools/MaxConvert/plDistributor.cpp index 517eeb3b..9cbdfbce 100644 --- a/Sources/Tools/MaxConvert/plDistributor.cpp +++ b/Sources/Tools/MaxConvert/plDistributor.cpp @@ -501,16 +501,16 @@ bool plDistributor::IFailsProbBitmap(int iFace, const Point3& bary) const break; case kMax: case kMaxColor: - frac = hsMaximum(evCol.r, hsMaximum(evCol.g, evCol.b)); + frac = std::max({ evCol.r, evCol.g, evCol.b }); break; 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; case kMaxRedGreen: - frac = hsMaximum(evCol.r, evCol.g); + frac = std::max(evCol.r, evCol.g); break; case kMaxRedGreenTimesAlpha: - frac = hsMaximum(evCol.r, evCol.g) * evCol.a; + frac = std::max(evCol.r, evCol.g) * evCol.a; break; } diff --git a/Sources/Tools/MaxMain/plMaxMeshExtractor.cpp b/Sources/Tools/MaxMain/plMaxMeshExtractor.cpp index 0c70956f..703747ac 100644 --- a/Sources/Tools/MaxMain/plMaxMeshExtractor.cpp +++ b/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++) { hsPoint3* vert = &pVerts[i]; - min.fX = hsMinimum(vert->fX, min.fX); - min.fY = hsMinimum(vert->fY, min.fY); - min.fZ = hsMinimum(vert->fZ, min.fZ); - max.fX = hsMaximum(vert->fX, max.fX); - max.fY = hsMaximum(vert->fY, max.fY); - max.fZ = hsMaximum(vert->fZ, max.fZ); + min.fX = std::min(vert->fX, min.fX); + min.fY = std::min(vert->fY, min.fY); + min.fZ = std::min(vert->fZ, min.fZ); + max.fX = std::max(vert->fX, max.fX); + max.fY = std::max(vert->fY, max.fY); + max.fZ = std::max(vert->fZ, max.fZ); } } diff --git a/Sources/Tools/MaxMain/plMaxNode.cpp b/Sources/Tools/MaxMain/plMaxNode.cpp index fc576665..97b6d400 100644 --- a/Sources/Tools/MaxMain/plMaxNode.cpp +++ b/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); for (int i = 0; i < mesh.fNumVerts; i++) { - minV.fX = hsMinimum(mesh.fVerts[i].fX, minV.fX); - minV.fY = hsMinimum(mesh.fVerts[i].fY, minV.fY); - minV.fZ = hsMinimum(mesh.fVerts[i].fZ, minV.fZ); - maxV.fX = hsMaximum(mesh.fVerts[i].fX, maxV.fX); - maxV.fY = hsMaximum(mesh.fVerts[i].fY, maxV.fY); - maxV.fZ = hsMaximum(mesh.fVerts[i].fZ, maxV.fZ); + minV.fX = std::min(mesh.fVerts[i].fX, minV.fX); + minV.fY = std::min(mesh.fVerts[i].fY, minV.fY); + minV.fZ = std::min(mesh.fVerts[i].fZ, minV.fZ); + maxV.fX = std::max(mesh.fVerts[i].fX, maxV.fX); + maxV.fY = std::max(mesh.fVerts[i].fY, maxV.fY); + maxV.fZ = std::max(mesh.fVerts[i].fZ, maxV.fZ); } hsPoint3 width = maxV - minV; 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); for (int i = 0; i < mesh.fNumVerts; i++) { - minV.fX = hsMinimum(mesh.fVerts[i].fX, minV.fX); - minV.fY = hsMinimum(mesh.fVerts[i].fY, minV.fY); - minV.fZ = hsMinimum(mesh.fVerts[i].fZ, minV.fZ); - maxV.fX = hsMaximum(mesh.fVerts[i].fX, maxV.fX); - maxV.fY = hsMaximum(mesh.fVerts[i].fY, maxV.fY); - maxV.fZ = hsMaximum(mesh.fVerts[i].fZ, maxV.fZ); + minV.fX = std::min(mesh.fVerts[i].fX, minV.fX); + minV.fY = std::min(mesh.fVerts[i].fY, minV.fY); + minV.fZ = std::min(mesh.fVerts[i].fZ, minV.fZ); + maxV.fX = std::max(mesh.fVerts[i].fX, maxV.fX); + maxV.fY = std::max(mesh.fVerts[i].fY, maxV.fY); + maxV.fZ = std::max(mesh.fVerts[i].fZ, maxV.fZ); } 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.offset = minV + (width / 2.f); } diff --git a/Sources/Tools/MaxMain/plPhysXCooking.cpp b/Sources/Tools/MaxMain/plPhysXCooking.cpp index 874fbfbd..62990dc8 100644 --- a/Sources/Tools/MaxMain/plPhysXCooking.cpp +++ b/Sources/Tools/MaxMain/plPhysXCooking.cpp @@ -304,12 +304,12 @@ void ReadBoxFromHull(hsStream* stream, NxBoxShapeDesc& box) for (int i = 0; i < nVertices; i++) { hsPoint3& vec = pVertices[i]; - minX = hsMinimum(minX, vec.fX); - minY = hsMinimum(minY, vec.fY); - minZ = hsMinimum(minZ, vec.fZ); - maxX = hsMaximum(maxX, vec.fX); - maxY = hsMaximum(maxY, vec.fY); - maxZ = hsMaximum(maxZ, vec.fZ); + minX = std::min(minX, vec.fX); + minY = std::min(minY, vec.fY); + minZ = std::min(minZ, vec.fZ); + maxX = std::max(maxX, vec.fX); + maxY = std::max(maxY, vec.fY); + maxZ = std::max(maxZ, vec.fZ); } delete[] pVertices; @@ -453,12 +453,12 @@ hsVectorStream* plPhysXCooking::IMakePolytope(const plMaxMeshExtractor::NeutralM } for(int i=0;iGetDecayRadius(t); projector = gl->GetProjector(); - fov = hsMaximum(fs,hs); + fov = std::max(fs, hs); float aspect = 1.0f;