Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


jacmoe

Member Since 25 Mar 2005
Offline Last Active Dec 11 2014 03:04 AM

Topics I've Started

Ogre Vector3 and amd64

26 July 2011 - 03:18 PM

Due to an obscure issue with Angelscript - because it works in Windows and *nix 32bit - it is nigh impossible to bind an Ogre::Vector3..

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.

test feature fails in amd64

22 July 2011 - 11:15 AM

On amd64 (Debian Sid) test_feature segfaults.

When I debug, I see that it fails on the very first test:
if( TestDefaultArg::Test() 		) goto failed; else printf("-- TestDefaultArg passed\n");

Semi-callstack:
test_defaultarg.cpp:
line 64: r = ExecuteString(engine, "main()", mod);
scripthelper.cpp:
line 154: r = execCtx->Execute();
as_context.cpp:
line 983: ExecuteNext();
line 1956: l_sp += CallSystemFunction(i, this, 0);
as_callfunc.cpp:
line 424: retQW = CallSystemFunctionNative(context, descr, obj, args, sysFunc->hostReturnInMemory ? retPointer : 0, retQW2);
as_callfunc_x64_gcc.cpp:
line 210: int callConv = sysFunc->callConv;

Doesn't look good.

This is latest svn trunk.

Mark topics as read when read

17 June 2011 - 02:05 PM

I don't know if this is just me, but when I read a topic, it's not marked as read..
Until I mark all topics read for the forum.
Which sort of defies the purpose.

It didn't work in the old forum either.

Other IP boards I visit works as intended, so it must be some special GameDev.Net setup?
Or is it a user setting which you turned off by default?

It's really ruining my forum experience.. <_<

Otherwise: site upgrade was/is great.
I am not complaining, but I feel I'm browsing the forum in the dark when I can't determine what topics I've read and what topics I haven't read yet..

<edit>
See this:
Attached File  read-not-read.jpeg   7.4KB   28 downloads
Even though I wrote the topic, it's flagged as unread. :lol:

PARTNERS