[osg-users] Please test SVN version of OpenSceneGraph

Art Tevs stud_info2 at yahoo.de
Tue Sep 11 13:29:09 PDT 2007

Hi Jean-Sebastien,

There is no actuall reason why it is used. I think this is the result of a lot of patching last days/hours. 

It will be enough to write: int numMipmapLevels = 1 + log2(maximum(width, height));
you are right. But since we are currently deciding to remove the int version of the log2 from the osg, it will be patched again. 

Just wait couple of days or make your proposition of how to fix the problem (see osg-submission and osg-users list for more details about log2 issue).


Jean-Sébastien Guay <jean-sebastien.guay at polymtl.ca> schrieb: Hello Chase,

> floorf accounts for the slight numerical error when the difference   
> between the value and the next greater integer is less than some   
> threshold.
> Try:
> std::cout << floorf(0.6/0.2) << std::endl << (int)(0.6/0.2) << std::endl;
> Both should be 3, but the cast version prints 2.  I'm not sure that   
> accuracy really matters in the context where this function is used.

OK, but if the input to floor is an int, and the result is casted back  
to an int, what's the use?

The actual code I'm talking about is:

         int width = _textureWidth;
         int height = _textureHeight;
         int numMipmapLevels = 1 +  
(int)floor(float(log2(maximum(width, height))));

If you break it down:
- width and height are ints
- they are fed to a template function 'T maximum(T, T)' which will then return
   an int
- this is fed to 'int log2(int)', which returns an int
- this is casted to a float, which I added, or else floor would  
complain (float or double when taking an int?)
- the result of floor is casted to an int again.

Couldn't this just be replaced by

int numMipmapLevels = 1 + log2(maximum(width, height));

since floor(a) if a is an int should just be a?

> For these types the parenthetical casts are equivalent.

That's what I thought... But there must be a reason why they're being  
used here instead?...


Jean-Sebastien Guay     jean-sebastien.guay at polymtl.ca

This message was sent using IMP, the Internet Messaging Program.

osg-users mailing list
osg-users at lists.openscenegraph.org

 Wissenswertes für Bastler und Hobby Handwerker.BE A BETTER HEIMWERKER!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20070911/a533796d/attachment-0003.htm>

More information about the osg-users mailing list