Compile problems with btVector3

basiror
Posts: 4
Joined: Thu Aug 07, 2008 8:30 am

Compile problems with btVector3

Post by basiror »

Hello,
I have a little problem with this section of my code, I cant seem to figure out what goes wrong during compilation
vector3 is my custom vector implementation

Code: Select all

146         const vector3& org = desc.GetOrigin();
147         const vector3& angles = desc.GetAngles();
148
149         btVector3 origin(btScalar(org[0]),btScalar(org[1]),btScalar(org[2]));
150         btQuaternion rotation(btScalar(angles[0]),btScalar(angles[1]),btScalar(angles[2]));
151
152         btTransform transform;
153         transform.setIdentity();
154         transform.setOrigin(origin);
I get the following error message from Gcc for the code above:
src/physics/physicsengine.cpp:154: error: no matching function for call to 'btTransform::setOrigin(btVector3 (&)(btScalar*, btScalar*, btScalar*))'
/usr/local/include/bullet/LinearMath/btTransform.h:112: note: candidates are: void btTransform::setOrigin(const btVector3&)
If I change the line 149 & 150 to this everything works ok, although the constructor
SIMD_FORCE_INLINE btVector3 (const btScalar &x, const btScalar &y, const btScalar &z) is declared.

Code: Select all

149         const btVector3 origin = btVector3(btScalar(org[0]),btScalar(org[1]),btScalar(org[2]));
150         const btQuaternion rotation = btQuaternion(btScalar(angles[0]),btScalar(angles[1]),btScalar(angles[2]));
I am working on Suse10.0.
gcc -v:
Using built-in specs.
Target: x86_64-suse-linux
Configured with: ../configure --enable-threads=posix --prefix=/usr --with-local-prefix=/usr/local --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,objc,f95,java,ada --disable-checking --with-gxx-include-dir=/usr/include/c++/4.0.2 --enable-java-awt=gtk --disable-libjava-multilib --with-slibdir=/lib64 --with-system-zlib --enable-shared --enable-__cxa_atexit --without-system-libunwind --host=x86_64-suse-linux
Thread model: posix
gcc version 4.0.2 20050901 (prerelease) (SUSE Linux)
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Compile problems with btVector3

Post by Erwin Coumans »

This looks like an issue with your version of the gcc compiler, have you tried reporting it to the compiler developers?

Hope this helps,
Erwin
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York

Re: Compile problems with btVector3

Post by sparkprime »

This is erroneous c++. The origin and rotation definitions are being parsed as function declarations. You can do a few things to prevent this. You can do (btScalar)org[0], or (btScalar(org[0])) or basically anything that makes the syntax unambiguous. There is no bug in gcc.
basiror
Posts: 4
Joined: Thu Aug 07, 2008 8:30 am

Re: Compile problems with btVector3

Post by basiror »

Hi,
thanks for the help, your suggestion did indeed solve the problem, but that looks really strange now if you ask me

Code: Select all

150         const btVector3 origin((btScalar(org[0])),(btScalar(org[1])),(btScalar(org[2])));
151         const btQuaternion rotation((btScalar(angles[0])),(btScalar(angles[1])),(btScalar(angles[2])));