Hi Jean-Sebastien,<br><br>There is no actuall reason why it is used. I think this is the result of a lot of patching last days/hours. <br><br>It will be enough to write: int numMipmapLevels = 1 + log2(maximum(width, height));<br>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. <br><br>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).<br><br>Art<br><b><i><br>Jean-Sébastien Guay <firstname.lastname@example.org></i></b> schrieb:<blockquote class="replbq" style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"> Hello Chase,<br><br>> floorf accounts for the slight numerical error when the difference <br>> between the value and the next greater integer is less than some <br>> threshold.<br>> Try:<br>> std::cout << floorf(0.6/0.2) <<
std::endl << (int)(0.6/0.2) << std::endl;<br>><br>> Both should be 3, but the cast version prints 2. I'm not sure that <br>> accuracy really matters in the context where this function is used.<br><br>OK, but if the input to floor is an int, and the result is casted back <br>to an int, what's the use?<br><br>The actual code I'm talking about is:<br><br> int width = _textureWidth;<br> int height = _textureHeight;<br> int numMipmapLevels = 1 + <br>(int)floor(float(log2(maximum(width, height))));<br><br>If you break it down:<br>- width and height are ints<br>- they are fed to a template function 'T maximum(T, T)' which will then return<br> an int<br>- this is fed to 'int log2(int)', which returns an int<br>- this is casted to a float, which I added, or else floor would <br>complain (float or double when taking an int?)<br>- the result of floor is casted to an int again.<br><br>Couldn't this just be replaced by<br><br>int
numMipmapLevels = 1 + log2(maximum(width, height));<br><br>since floor(a) if a is an int should just be a?<br><br>> For these types the parenthetical casts are equivalent.<br><br>That's what I thought... But there must be a reason why they're being <br>used here instead?...<br><br>Thanks,<br><br>J-S<br>-- <br>______________________________________________________<br>Jean-Sebastien Guay email@example.com<br> http://whitestar02.webhop.org/<br><br>----------------------------------------------------------------<br>This message was sent using IMP, the Internet Messaging Program.<br><br><br>_______________________________________________<br>osg-users mailing list<br>firstname.lastname@example.org<br>http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org<br></blockquote><br><p>
<hr size=1> Wissenswertes für Bastler und Hobby Handwerker.
<a href="http://de.rd.yahoo.com/evt=48734/*http://de.promotions.yahoo.com/clever/be-a-better/heimwerker.html" target=_new >
<b>BE A BETTER HEIMWERKER!</b></a>