[osg-users] Please test SVN version of OpenSceneGraph
CHASE.BRADFORD at saic.com
Tue Sep 11 12:55:20 PDT 2007
> -----Original Message-----
> From: osg-users-bounces at lists.openscenegraph.org [mailto:osg-users
> bounces at lists.openscenegraph.org] On Behalf Of Jean-Sébastien Guay
> Sent: Tuesday, September 11, 2007 12:05 PM
> To: osg-users at lists.openscenegraph.org
> Cc: osg-submissions at lists.openscenegraph.org
> 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.
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.
> The rest is compiling as I type, going well for now. I'll let you know.
> Jean-Sebastien Guay jean-sebastien.guay at polymtl.ca
> This message was sent using IMP, the Internet Messaging Program.
More information about the osg-users