> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:osg-users
> [EMAIL PROTECTED] On Behalf Of Jean-Sébastien Guay
> Sent: Tuesday, September 11, 2007 12:05 PM
> To: [email protected]
> Cc: [EMAIL PROTECTED]
> Subject: Re: [osg-users] Please test SVN version of OpenSceneGraph
>
> Hello Robert,
>
> Still a few "ambiguous call" errors on Windows/Visual Studio 2005 in  
> the new log2 functions. Here's the fixed include/osg/Math file (note  
> it's just a few casts to make sure the right function is called).
>
> Also, same kinds of fixes to Texture1D.cpp, Texture2D.cpp,  
> Texture2DArray.cpp, Texture3D.cpp and TextureCubeMap.cpp. The problem  
> was that the C function floor (which has versions for float and double  
> only) was being called with an int argument, so it didn't know which  
> to choose (float or double). I've always found that Visual C++ error a  
> bit useless... We don't care which you choose, the result is being put  
> into an int anyways dammit! :-)
>

Can't really slight VS for this one.  Float to int loses precision.  Try 
comparing:
int i = (2<<31)-1;
float f = (float)i;


> Come to think of it, since there's an int version of log2, shouldn't  
> the call to floor just be removed? Since doing floor on an int is a  
> bit nonsensical...
>
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.


> BTW, why are those osg::log2 functions using static_cast<type>?  
> Wouldn't a straight C cast do the same thing? I've only seen  
> static_cast<> and dynamic_cast<> when casting object pointers before,  
> so I'm really just curious, from a language point of view, what's the  
> difference and why is it done this way?
>

For these types the parenthetical casts are equivalent.

Regards,
Chase

> The rest is compiling as I type, going well for now. I'll let you know.
>
> Thanks,
>
> J-S
> -- 
> ______________________________________________________
> Jean-Sebastien Guay     [EMAIL PROTECTED]
>                          http://whitestar02.webhop.org/
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to