Advertisement

Linux x64 + asOBJ_VALUE problem.

Started by March 09, 2014 08:17 PM
6 comments, last by carew 10 years, 8 months ago

Hi,

I'm trying to register btQuaternion and btVector3 (classes from Bullet Physics) classes in AngelScript as value objects. On Windows x86 and Linux x86 all works fine, but on Linux x64 I see problems with these classes. I use "asOBJ_VALUE|asOBJ_APP_CLASS_CDAK" for those classes. In script I see following results:


btRigidBodyObject.setGravity(btVector3(5.f, 6.f, 7.f));
btVector3 a(1.f, 2.f, 3.f);
float b = 1.f;
btQuaternion sample(a, b);
sample.getAxis().x(); // when I print this value I see data which I set in setGravity method, so 5.f, getAxis method return btVector3

Do you know where issue may exist? Why getAxis method return data from gravity? I tried asOBJ_APP_CLASS_ALLFLOATS for both btVector3 and btQuaternion, but it didn't help.

BTW. I disabled sse and allign to 16 bytes for bullet classes.

UPDATE:

I forgot to mention that on OSX x64 the same issue appear. I use the latest rev from trunk.

Cheers,

Both of these classes should be registered with asOBJ_APP_CLASS_C, not asOBJ_APP_CLASS_CDAK. The classes have no destructor, operator=, or copy constructor to warrant the other flags.

If you're unsure of how to choose the right flags, you can use the template function GetTypeTraits<T>() in the scripthelper add-on.

I'm not sure if asOBJ_APP_CLASS_ALLFLOATS should be used in this case, because the data members are stored as a union, which may be handled differently by the C++ compiler. Try it both with and without the flag to see which works.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement

Thanks for replay. When I used GetTypeTraits<T>() I get this error when I try to register methods which return btVector3 or btQuaternion:

ERR : Don't support returning type 'btVector3' by value from application in native calling convention on this platform

What's the value the that it returns? asOBJ_APP_CLASS_C right?

On Linux 64bit (and MacOSX 64bit) simple types are passed to and from function in the CPU registers. In order for AngelScript to know which CPU registers to use you must also inform either asOBJ_APP_CLASS_ALLFLOATS or asOBJ_APP_CLASS_ALLINTS.

Like I said in the last post, because of the union inside the classes I'm not too sure which of the two are the correct to use.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Sorry for double post. I pressed 'post' by mistake. Upper error is cause of missing copy constructor. In my app I use static functions for copy constructor:


template<class T> static void CONST_COPY(T* th, const T& ot)
{
     new(th) T(ot);
}

Anyway when I use upper function as copy constructor and register classes as asOBJ_APP_CLASS_CK I see issues from my first post.

What's the value the that it returns?

It returns 768 for these classes.

Advertisement

Sorry for double post. I pressed 'post' by mistake. Upper error is cause of missing copy constructor. In my app I use static functions for copy constructor:


template<class T> static void CONST_COPY(T* th, const T& ot)
{
     new(th) T(ot);
}

Anyway when I use upper function as copy constructor and register classes as asOBJ_APP_CLASS_CK I see issues from my first post.

asOBJ_APP_CLASS_xxx isn't related to what behaviours you register. The flags are use to tell AngelScript how C++ sees the class, so that AngelScript can know how to pass the object to or from registered functions correctly.

768 = asOBJ_APP_CLASS_C smile.png

See my previous post how to handle the 'Don't support ...' message.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Thanks a lot for your help! It works great! :)

This topic is closed to new replies.

Advertisement