VDrift / vdrift

VDrift source code
http://vdrift.net/
GNU General Public License v3.0
349 stars 93 forks source link

Fix build with bullet double precision library #192

Closed rapsys closed 1 year ago

rapsys commented 1 year ago

This pull request should fix issue #191

logzero commented 1 year ago

I think it should be enough if you just cast the constants btScalar(0), btScalar(1) etc, would be less noisy that way.

logzero commented 1 year ago

Although I'd be also fine with explicit instantiation Min<btScalar>(...) etc.

rapsys commented 1 year ago

Although I'd be also fine with explicit instantiation Min<btScalar>(...) etc.

Sorry, I am not a c++ expert, I don't see what you mean.

An example of code would be welcome.

logzero commented 1 year ago

Min/Max/Clamp are so called function templates expecting the same argument type. The compiler will complain if they get mixed type arguments (like float and double for example), thus the casting business.

Alternatively you can explicitly tell the compiler which type of function should be used (instantiated) by writing Min<float> or Min<double> etc and the compiler will cast the arguments accordingly if possible.

So instead of

Min(btScalar(a), btScalar(b));

you can write

Min<btScalar>(a, b);

logzero commented 1 year ago

I've pushed a slightly cleaner variant of the fix.

Thanks for looking into it.

rapsys commented 1 year ago

Thanks for the upstream integration.