Jump to content
  • Advertisement
Sign in to follow this  
carew

Linux x64 + asOBJ_VALUE problem.

This topic is 2049 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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,

Edited by carew

Share this post


Link to post
Share on other sites
Advertisement

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.

Share this post


Link to post
Share on other sites

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

 

Share this post


Link to post
Share on other sites

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.

Edited by Andreas Jonsson

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!