Ogre Vector3 and amd64
Maybe this could be added to the documentation somewhere?
That a POD needs to have an explicit copy constructor on 64bit *nix?
Too many projects; too much time
Passing this flag to GCC will turn off the value to reference optimization trick I think:
-fno-ipa-sra
-fipa-sra
Perform interprocedural scalar replacement of aggregates, removal of unused parameters and replacement of parameters passed by reference by parameters passed by value.
Enabled at levels -O2, -O3 and -Os. [/quote]
Don't know if it works, though.
I think I'll just use some ugly casts between Angelic proxy classes and Ogre's POD classes instead.
Do I have to teach Angelscript how to handle that?
Too many projects; too much time
If you cannot use your own custom version of Ogre::Vector3, or change the methods that take the Vector3 type by value to take them by reference (note, it should still be possible to return the type by value), then the only other solution is to use function wrappers. For this, I believe you can use the auto wrappers, that you'll find in the add-ons.
[source]
// Example
#include "add_on/autowrapper/aswrappedcall.h"
// Implemente a method wrapper for the class method that takes the Ogre::Vector3 type by value in parameter
asDECLARE_METHOD_WRAPPER(AngelScriptTest_setCameraPosition_Wrapper, AngelScriptTest, setCameraPosition);
...
// Register the wrapper, instead of the real method
r = mEngine->RegisterObjectMethod("AngelscriptTest", "void setcp(vector3)", asFUNCTION(AngelscriptTest_setCameraPosition_Wrapper), asCALL_GENERIC); assert( r >= 0);
[/source]
This only needs to be done for the functions and class methods that take the Vector3 by value. Other functions and methods can be registered normally without any wrappers.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
http://www.ogre3d.org/forums/viewtopic.php?f=22&t=65876
A shame. ;)
I will try your suggestion.
Thanks a lot for your patience.
Too many projects; too much time
If possible I'll add support for these kind of types in AngelScript. After all, it is quite common structure (i.e. all members are float).
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
It was deemed not kosher by a team member:
http://www.ogre3d.or...hp?f=22&t=65876
A shame. ;)
I will try your suggestion.
Thanks a lot for your patience.
Wow. Their acerbic response is a little bit distasteful for a fix that is so simple, but provides so much to some of their user-base. Not to mention, it wouldn't be the first time they disregarded standards-compliant behavior for a non-standard compiler implementation. Has anyone in that topic seen OgreSingleton.h?
Singleton( void )
{
assert( !ms_Singleton );
#if defined( _MSC_VER ) && _MSC_VER < 1200
int offset = (int)(T*)1 - (int)(Singleton <T>*)(T*)1;
ms_Singleton = (T*)((int)this + offset);
#else
ms_Singleton = static_cast< T* >( this );
#endif
}
In fact, it's a simple as implementing the following code in any offending classes:
//
// Provide an explict copy-constructor for GCC 4.6.1 on 64-bit Linux architectures
// (in-depth explanation here)
//
#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX && \
OGRE_ARCH_TYPE == OGRE_ARCHITECTURE_64 && \
OGRE_COMPILTER == OGRE_COMPILER_GCC && \
OGRE_COMP_VER > 461 // (assume version greater than 4.6.1 exhibit the same behavior
inline Vector3(const Vector3& other)
: x(other.x), y(other.y), z(other.z)
{
}
#endif
There they go. A standards-compliant version of the class for standard-compliant compilers, and a non-standard-compliant version for non-standard versions. It's really quite simple. This small fix wouldn't decrease maintainability in the least, and the increase in line count is hardly noticeable.That entire thread put a bad taste in my mouth. But hey, I guess I'm not on the Ogre development team for a reason.
"When men are most sure and arrogant they are commonly most mistaken, giving views to passion without that proper deliberation which alone can secure them from the grossest absurdities." - David Hume
My thoughts exactly.
Too many projects; too much time
I read the thread over at Ogre. While I feel it is a pity they didn't want add the copy constructor, I can't really say I blame them. After all, they are not doing anything wrong by leaving it as an implicit copy constructor. And who knows, it may even cause a minor performance impact if the copy constructor is added, as it would prevent the GCC compiler from passing the type in the CPU registers.
*Them* is one team member. Don't expect a reply from anyone else.
And, yes: it is a pity.
I am aware of the possible performance impact, of course..
If possible I'll add support for these kind of types in AngelScript. After all, it is quite common structure (i.e. all members are float).
That would be lovely.
Too many projects; too much time
I'll let you know when I'm done modifying the real code, but it does work a treat in my test project.
Thank you Andreas - you're the best.
<edit>
asDECLARE_METHOD_WRAPPER(AngelscriptTest_getCameraPosition_Wrapper, AngelscriptTest, getCameraPosition);
and
// Register the wrapper, instead of the real method
r = mEngine->RegisterObjectMethod("AngelscriptTest", "vector3 getcp()",
asFUNCTION(AngelscriptTest_getCameraPosition_Wrapper),
asCALL_GENERIC); assert( r >= 0);
Too many projects; too much time
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game