Double Precision Support

Post Reply
Ameise
Posts: 11
Joined: Sun Oct 18, 2009 1:18 am

Double Precision Support

Post by Ameise »

Is there any ETA at all on when double-precision support will be within Bullet3 properly? I've tried using B3_USE_DOUBLE_PRECISION, but there are a ridiculous number of cast warnings between doubles and floats.

I am trying to develop a game that is going to require double precision for the scene to work properly, and I am having a heck of a time finding a physics library that can operate in double precision.
Ameise
Posts: 11
Joined: Sun Oct 18, 2009 1:18 am

Re: Double Precision Support

Post by Ameise »

All right, I think I got the latest version working with double precision... mostly. The previous version supposedly had double precision support, but there were a lot of internal casting errors which truncated the values a lot. After fixing those, I moved onto the latest version. I had to disable the OpenCL support for double precision, as I have no idea how to get that functional.

I will go over it again tomorrow.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Double Precision Support

Post by Erwin Coumans »

Double precision should work just fine in Bullet, despite the warnings.

If you have a clean patch, please consider submitting it to https://github.com/bulletphysics/bullet3/issues or submit a pull request.

Ignore the OpenCL version, it is not actively developed or used at the moment.
Ameise
Posts: 11
Joined: Sun Oct 18, 2009 1:18 am

Re: Double Precision Support

Post by Ameise »

I'd have to put it into a patchable form - it's certainly not current clean.

The current revision that I got from SVN, as it was, did not build. Once I was able to get past the errors, the truncation errors were fairly deep and though I suspect that double-precision would usually work, there were circumstances where it would not. There were also quite a few instances were tests were being done against, say, FLT_EPSILON or FLT_MAX instead of the right ones (should switch between that and DBL_EPSILON and DBL_MAX) along with other areas where single-precision floats were used - a b3Scalar would be copied to a float, work would be done with that float (usually work against b3Scalars) and the result would be passed back to a b3Scalar. I'd expect the precision at that point to not be guaranteed.

My other current worry is the serialized structures. Not sure how to fix them as the comments clearly say not to change the structures, but I don't understand the dependencies they're having on some arbitrary array? They structures generally use float (presumably because a variable-sized type wouldn't be good for serialization) but I'd always prefer using the higher-precision type than the lower-precision one when a serialized structure may be used in either situation.

Glancing through, I've also noticed that there are no SIMD optimizations for double precision (unless I missed them), so I may look into that as well.

As a general thing, I am confused about how the solution is laid out.. is it that bullet2 and bullet3 both exist in this solution, so I'm building both libraries? Is it expected that bullet2 will be removed at some point?
Basroil
Posts: 463
Joined: Fri Nov 30, 2012 4:50 am

Re: Double Precision Support

Post by Basroil »

Ameise wrote: Glancing through, I've also noticed that there are no SIMD optimizations for double precision (unless I missed them), so I may look into that as well.
You would probably have to recode the intrinsics, since most things are written for plain old 32bit SSE2 intrinsics. It shouldn't be a huge amount of work to get btScalar, btVector3, and the matrix/quaternion functions working somewhat on 64bit, but some of the other intrinsics might be a bit harder to do without breaking something by accident. If you manage to get 64bit intrinsics working, I'm sure plenty will want to mooch off that work :wink:
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Double Precision Support

Post by Erwin Coumans »

The current revision that I got from SVN, as it was, did not build.
SVN?

The Bullet repository is at http://github.com/bulletphysics/bullet3 and the unmodified version should build out-of-the-box using the included cmake or premake build systems. Note that warnings are currently not treated as errors in those build systems. If you enable warnings as error, it is a modified version.
Post Reply