Removed log2 and replaced the places where is was used with a new Image::computeNumberOfMipmapLevels method.
This commit is contained in:
@@ -429,6 +429,13 @@ int Image::computeNearestPowerOfTwo(int s,float bias)
|
||||
return s;
|
||||
}
|
||||
|
||||
int Image::computeNumberOfMipmapLevels(int s,int t, int r)
|
||||
{
|
||||
int w = maximum(s, t);
|
||||
w = maximum(w, r);
|
||||
return 1 + static_cast<int>(floor(logf(w)/logf(2.0f)));
|
||||
}
|
||||
|
||||
unsigned int Image::getTotalSizeInBytesIncludingMipmaps() const
|
||||
{
|
||||
if (_mipmapData.empty())
|
||||
|
||||
@@ -414,7 +414,7 @@ void Texture1D::allocateMipmap(State& state) const
|
||||
|
||||
// compute number of mipmap levels
|
||||
int width = _textureWidth;
|
||||
int numMipmapLevels = 1 + (int)floor(log2(width));
|
||||
int numMipmapLevels = Image::computeNumberOfMipmapLevels(width);
|
||||
|
||||
// we do not reallocate the level 0, since it was already allocated
|
||||
width >>= 1;
|
||||
|
||||
@@ -408,7 +408,7 @@ void Texture2D::allocateMipmap(State& state) const
|
||||
// compute number of mipmap levels
|
||||
int width = _textureWidth;
|
||||
int height = _textureHeight;
|
||||
int numMipmapLevels = 1 + (int)floor(log2(maximum(width, height)));
|
||||
int numMipmapLevels = Image::computeNumberOfMipmapLevels(width, height);
|
||||
|
||||
// we do not reallocate the level 0, since it was already allocated
|
||||
width >>= 1;
|
||||
|
||||
@@ -464,7 +464,7 @@ void Texture2DArray::allocateMipmap(State& state) const
|
||||
// compute number of mipmap levels
|
||||
int width = _textureWidth;
|
||||
int height = _textureHeight;
|
||||
int numMipmapLevels = 1 + (int)floor(log2(maximum(width, height)));
|
||||
int numMipmapLevels = Image::computeNumberOfMipmapLevels(width, height);
|
||||
|
||||
// we do not reallocate the level 0, since it was already allocated
|
||||
width >>= 1;
|
||||
|
||||
@@ -456,7 +456,7 @@ void Texture3D::allocateMipmap(State& state) const
|
||||
int width = _textureWidth;
|
||||
int height = _textureHeight;
|
||||
int depth = _textureDepth;
|
||||
int numMipmapLevels = 1 + (int)floor(log2(maximum(width, maximum(depth, height))));
|
||||
int numMipmapLevels = Image::computeNumberOfMipmapLevels(width, height, depth);
|
||||
|
||||
// we do not reallocate the level 0, since it was already allocated
|
||||
width >>= 1;
|
||||
|
||||
@@ -384,7 +384,7 @@ void TextureCubeMap::allocateMipmap(State& state) const
|
||||
// compute number of mipmap levels
|
||||
int width = _textureWidth;
|
||||
int height = _textureHeight;
|
||||
int numMipmapLevels = 1 + (int)floor(log2(maximum(width, height)));
|
||||
int numMipmapLevels = Image::computeNumberOfMipmapLevels(width, height);
|
||||
|
||||
// we do not reallocate the level 0, since it was already allocated
|
||||
width >>= 1;
|
||||
|
||||
@@ -357,6 +357,10 @@ BEGIN_OBJECT_REFLECTOR(osg::Image)
|
||||
__int__computeNearestPowerOfTwo__int__float_S,
|
||||
"",
|
||||
"");
|
||||
I_StaticMethodWithDefaults3(int, computeNumberOfMipmapLevels, IN, int, s, , IN, int, t, 1, IN, int, r, 1,
|
||||
__int__computeNumberOfMipmapLevels__int__int__int_S,
|
||||
"",
|
||||
"");
|
||||
I_ProtectedMethod0(void, deallocateData,
|
||||
Properties::NON_VIRTUAL,
|
||||
Properties::NON_CONST,
|
||||
|
||||
Reference in New Issue
Block a user