mirror of
https://github.com/edubart/otclient.git
synced 2025-10-19 05:53:26 +02:00
Use of clamp
This commit is contained in:
@@ -50,7 +50,7 @@ TexturePtr LightView::generateLightBubble(float centerFactor)
|
||||
for(int x = 0; x < bubbleDiameter; x++) {
|
||||
for(int y = 0; y < bubbleDiameter; y++) {
|
||||
float radius = std::sqrt((bubbleRadius - x)*(bubbleRadius - x) + (bubbleRadius - y)*(bubbleRadius - y));
|
||||
float intensity = std::max<float>(std::min<float>((bubbleRadius-radius)/(float)(bubbleRadius-centerRadius), 1.0f), 0.0f);
|
||||
float intensity = stdext::clamp<float>((bubbleRadius - radius) / (float)(bubbleRadius - centerRadius), 0.0f, 1.0f);
|
||||
|
||||
// light intensity varies inversely with the square of the distance
|
||||
intensity = intensity * intensity;
|
||||
|
@@ -644,7 +644,7 @@ int MapView::calcFirstVisibleFloor()
|
||||
}
|
||||
|
||||
// just ensure the that the floor is in the valid range
|
||||
z = std::min<int>(std::max<int>(z, 0), (int)Otc::MAX_Z);
|
||||
z = stdext::clamp<int>(z, 0, (int)Otc::MAX_Z);
|
||||
return z;
|
||||
}
|
||||
|
||||
@@ -669,7 +669,7 @@ int MapView::calcLastVisibleFloor()
|
||||
z = std::max<int>(m_lockedFirstVisibleFloor, z);
|
||||
|
||||
// just ensure the that the floor is in the valid range
|
||||
z = std::min<int>(std::max<int>(z, 0), (int)Otc::MAX_Z);
|
||||
z = stdext::clamp<int>(z, 0, (int)Otc::MAX_Z);
|
||||
return z;
|
||||
}
|
||||
|
||||
|
@@ -77,7 +77,7 @@ void UIMap::movePixels(int x, int y)
|
||||
|
||||
bool UIMap::setZoom(int zoom)
|
||||
{
|
||||
m_zoom = std::min<int>(std::max<int>(zoom, m_maxZoomIn), m_maxZoomOut);
|
||||
m_zoom = stdext::clamp<int>(zoom, m_maxZoomOut, m_maxZoomIn);
|
||||
updateVisibleDimension();
|
||||
return false;
|
||||
}
|
||||
|
@@ -84,7 +84,7 @@ void UIProgressRect::drawSelf(Fw::DrawPane drawPane)
|
||||
|
||||
void UIProgressRect::setPercent(float percent)
|
||||
{
|
||||
m_percent = std::max<float>(std::min<float>((double)percent, 100.0), 0.0);
|
||||
m_percent = stdext::clamp<float>((double)percent, 0.0, 100.0);
|
||||
}
|
||||
|
||||
void UIProgressRect::onStyleApply(const std::string& styleName, const OTMLNodePtr& styleNode)
|
||||
|
Reference in New Issue
Block a user