Of course, the Vector3 addon works a treat, both passed by value and by reference.

Ogre::Vector3 only works when passed by reference..

When passing it by value, it is lost..

I have this code to bind Ogre::Vector3:

static void Vector3DefaultConstructor(Ogre::Vector3 *self) { new(self) Ogre::Vector3(0,0,0); } static void Vector3InitConstructor(float x, float y, float z, Ogre::Vector3 *self) { new(self) Ogre::Vector3(Ogre::Real(x), Ogre::Real(y), Ogre::Real(z)); } static void CopyConstructVector3(const Ogre::Vector3 &other, Ogre::Vector3 *thisPointer) { new(thisPointer) Ogre::Vector3(other); } static void DestructVector3(Ogre::Vector3 *thisPointer) { thisPointer->~Vector3(); } static Ogre::Vector3 &Vector3Assignment(Ogre::Vector3 *other, Ogre::Vector3 *self) { return *self = *other; } void RegisterScriptOgreVector3(asIScriptEngine *engine) { int r; r = engine->RegisterObjectType("vector3", sizeof(Ogre::Vector3), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CAK); assert( r >= 0 ); r = engine->RegisterObjectProperty("vector3", "float x", offsetof(Ogre::Vector3, x)); assert( r >= 0 ); r = engine->RegisterObjectProperty("vector3", "float y", offsetof(Ogre::Vector3, y)); assert( r >= 0 ); r = engine->RegisterObjectProperty("vector3", "float z", offsetof(Ogre::Vector3, z)); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("vector3", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(Vector3DefaultConstructor), asCALL_CDECL_OBJLAST); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("vector3", asBEHAVE_CONSTRUCT, "void f(const vector3 &in)", asFUNCTION(CopyConstructVector3), asCALL_CDECL_OBJLAST); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("vector3", asBEHAVE_CONSTRUCT, "void f(float, float, float)", asFUNCTION(Vector3InitConstructor), asCALL_CDECL_OBJLAST); assert(r >= 0); r = engine->RegisterObjectMethod("vector3", "vector3 &opAssign(vector3&in)", asFUNCTION(Vector3Assignment), asCALL_CDECL_OBJLAST); assert( r >= 0 ); r = engine->RegisterObjectMethod("vector3", "vector3 crossProduct(const vector3 &in) const", asMETHOD(Ogre::Vector3, crossProduct), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("vector3", "vector3 opAdd(const vector3 &in) const", asMETHODPR(Ogre::Vector3, operator+, (const Ogre::Vector3&) const, Ogre::Vector3), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("vector3", "vector3 opSub(const vector3 &in) const", asMETHODPR(Ogre::Vector3, operator-, (const Ogre::Vector3&) const, Ogre::Vector3), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("vector3", "vector3 opMul(float) const", asMETHODPR(Ogre::Vector3, operator*, (float) const, Ogre::Vector3), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("vector3", "vector3 opNeg() const", asMETHODPR(Ogre::Vector3, operator-, () const, Ogre::Vector3), asCALL_THISCALL); assert(r >= 0); }That code is known to work in Windows.

This is the code I use to test it:

RegisterScriptOgreVector3(mEngine); int r; r = mEngine->RegisterObjectType("AngelscriptTest", 0, asOBJ_REF | asOBJ_NOHANDLE); assert( r >= 0); r = mEngine->RegisterObjectMethod("AngelscriptTest", "void quit()", asMETHOD(AngelscriptTest, quit), asCALL_THISCALL); assert( r >= 0); r = mEngine->RegisterObjectMethod("AngelscriptTest", "void test()", asMETHOD(AngelscriptTest, test), asCALL_THISCALL); assert( r >= 0); r = mEngine->RegisterObjectMethod("AngelscriptTest", "void setcp(vector3)", asMETHOD(AngelscriptTest, setCameraPosition), asCALL_THISCALL); assert( r >= 0); r = mEngine->RegisterObjectMethod("AngelscriptTest", "void pv(vector3)", asMETHOD(AngelscriptTest, printVector3), asCALL_THISCALL); assert( r >= 0); r = mEngine->RegisterObjectMethod("AngelscriptTest", "vector3 getcp()", asMETHOD(AngelscriptTest, getCameraPosition), asCALL_THISCALL); assert( r >= 0); r = mEngine->RegisterObjectMethod("AngelscriptTest", "vector3 bv()", asMETHOD(AngelscriptTest, byValue), asCALL_THISCALL); assert( r >= 0); // Register the singleton's address that the script will use to access it r = mEngine->RegisterGlobalProperty("AngelscriptTest app", this); assert( r >= 0);

And it does not work on amd64.

'getcp' returns garbage.

'setcp(vector3(100,100,100))' does not set the camera position to vector3(100,100,100) but to vector3(0,0,0).

What am I missing?

It works when using references.

But that's not solving anything as I can't return/pass by reference in all places.