Fix: Prevent division by 0 in CGUIScrollBar::setPos

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@5209 dfc29bdd-3216-0410-991c-e03cc46cb475
master
cutealien 2015-12-09 22:35:03 +00:00
parent 0e48c9399a
commit f6623a32bf
2 changed files with 14 additions and 11 deletions

View File

@ -1,6 +1,7 @@
--------------------------
Changes in 1.9 (not yet released)
- Fix: Prevent division by 0 in CGUIScrollBar::setPos
- Fix: Add missing serialization to CSceneNodeAnimatorCameraFPS and CSceneNodeAnimatorCameraMaya
- Fix: File-open dialog now restores the original locale after modifying it internally
- Fix first calculation of the camerascenenode boundingsphere.

View File

@ -348,20 +348,22 @@ void CGUIScrollBar::setPos(s32 pos)
{
Pos = core::s32_clamp ( pos, Min, Max );
if (Horizontal)
if ( core::isnotzero ( range() ) )
{
f32 f = (RelativeRect.getWidth() - ((f32)RelativeRect.getHeight()*3.0f)) / range();
DrawPos = (s32)( ( ( Pos - Min ) * f) + ((f32)RelativeRect.getHeight() * 0.5f));
DrawHeight = RelativeRect.getHeight();
}
else
{
f32 f = (RelativeRect.getHeight() - ((f32)RelativeRect.getWidth()*3.0f)) / range();
if (Horizontal)
{
f32 f = (RelativeRect.getWidth() - ((f32)RelativeRect.getHeight()*3.0f)) / range();
DrawPos = (s32)( ( ( Pos - Min ) * f) + ((f32)RelativeRect.getHeight() * 0.5f));
DrawHeight = RelativeRect.getHeight();
}
else
{
f32 f = (RelativeRect.getHeight() - ((f32)RelativeRect.getWidth()*3.0f)) / range();
DrawPos = (s32)( ( ( Pos - Min ) * f) + ((f32)RelativeRect.getWidth() * 0.5f));
DrawHeight = RelativeRect.getWidth();
DrawPos = (s32)( ( ( Pos - Min ) * f) + ((f32)RelativeRect.getWidth() * 0.5f));
DrawHeight = RelativeRect.getWidth();
}
}
}