Ogre3D

BUG OF THE MONTH | Incorrect Calculation

V1064 The ‘1’ operand of integer division is less than the ‘100000’ one. The result will always be zero. OgreAutoParamDataSource.cpp 1094

typedef Vector<4, Real> Vector4;

const Vector4& 
  AutoParamDataSource::getShadowSceneDepthRange(size_t index) const
{
  static Vector4 dummy(0, 100000, 100000, 1/100000);
  // ....
}

Here the dummy vector should store floating point numbers. In this case, the constructor receives 4 arguments of the float type. However, there are integer values to the left and right of the division operator. That’s why the result of 1/100000 will be not a fraction but zero.

Let’s fix this:

const Vector4& AutoParamDataSource::getShadowSceneDepthRange(size_t index) const
{
  static Vector4 dummy(0, 100000, 100000, 1.0f/100000);
  // ....
}

Now everything works properly.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.