Hi,
I was the one to suppress the Vector3 copy constructor (and same for quaternion I think) from Ogre a few years ago.
I did it for performance purpose in debug mode when using for instance some big std::vector<Ogre::Vector3>.
I personnaly would prefer to keep that this way, but I think the performance difference only happens in debug mode.
Anyway, If you found a solution, that is really great jacmoe !
Just my 2 cents,
Pierre
Vector3 copy constructor
- madmarx
- OGRE Expert User
- Posts: 1671
- Joined: Mon Jan 21, 2008 10:26 pm
- x 50
Re: Vector3 copy constructor
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
- jacmoe
- OGRE Retired Moderator
- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
- Contact:
Re: Vector3 copy constructor
Actually, that crap didn't work.
I've been fighting to get Angelscript to work on my 64-bit Debian box for much longer than I'd like to remember..
I never thought I'd live to see the day that I managed to fix it, but - lo and behold! Angelscript now works with Vector3 and Quaternion (and friends) - also when it's passed around by value sans copy constructor.
The most important change is from asOBJ_APP_CLASS_CAK to asOBJ_APP_CLASS_CA | asOBJ_APP_CLASS_ALLFLOATS.
I've been fighting to get Angelscript to work on my 64-bit Debian box for much longer than I'd like to remember..
I never thought I'd live to see the day that I managed to fix it, but - lo and behold! Angelscript now works with Vector3 and Quaternion (and friends) - also when it's passed around by value sans copy constructor.
Code: Select all
- r = engine->RegisterObjectType("Quaternion", sizeof(Ogre::Quaternion), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CAK); assert( r >= 0 );
+ r = engine->RegisterObjectType("Quaternion", sizeof(Ogre::Quaternion), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CA | asOBJ_APP_CLASS_ALLFLOATS); assert( r >= 0 );
As you can see from the date, I've been trying to fix the issues for almost 1.5 years.Andreas Jonsson wrote: Posted 10 October 2011 - 08:02 PM
I've added an additional flag asOBJ_APP_ALLFLOATS that when used with the registration of the Ogre::Vector3 should allow you to use this type in native functions without wrappers. It tells AngelScript that the class consists only of floats, and will thus allow AngelScript to know that the type is returned in the XMM registers instead of the general purpose registers.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
- jacmoe
- OGRE Retired Moderator
- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
- Contact:
Re: Vector3 copy constructor
Just throwing the fix in here so that it might prevent other poor souls from losing their sanity and/or valuable time.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
- madmarx
- OGRE Expert User
- Posts: 1671
- Joined: Mon Jan 21, 2008 10:26 pm
- x 50
Re: Vector3 copy constructor
That's nice to do it even later. It gives a sense of continuity/not forgotten/not done in vain (pick the one you like).
One of my first posts here was solved 3.5 or 4 years later .
One of my first posts here was solved 3.5 or 4 years later .
Tutorials + Ogre searchable API + more for Ogre1.7 : http://sourceforge.net/projects/so3dtools/
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
Corresponding thread : http://www.ogre3d.org/forums/viewtopic. ... 93&start=0
- jacmoe
- OGRE Retired Moderator
- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
- Contact:
Re: Vector3 copy constructor
I feel better already!
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
- saejox
- Goblin
- Posts: 260
- Joined: Tue Oct 25, 2011 1:07 am
- x 36
Re: Vector3 copy constructor
I wish there were c++11 traits like std::is_composed_of_integrals<T> and std::is_composed_of_floats<T>
I looked at all c++14 proposal there isn't one for this. I really wish there was. This blocks my auto generated script bindings generator.
I looked at all c++14 proposal there isn't one for this. I really wish there was. This blocks my auto generated script bindings generator.
- Klaim
- Old One
- Posts: 2565
- Joined: Sun Sep 11, 2005 1:04 am
- Location: Paris, France
- x 56
- Contact:
Re: Vector3 copy constructor
The last proposals are not the only ones, there are proposals for reflection but they focus on compile-time, so that would be a solution.saejox wrote:I wish there were c++11 traits like std::is_composed_of_integrals<T> and std::is_composed_of_floats<T>
I looked at all c++14 proposal there isn't one for this. I really wish there was. This blocks my auto generated script bindings generator.
Unfortunately I don't think we'll get any reflection improvements until c++17 (if it's not late) ;___;
The good news is that it is necessary to get networking in good shape, so big companies push the standard to have these (in particular Google, using Protobuf as example in proposals)
- jacmoe
- OGRE Retired Moderator
- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
- Contact:
Re: Vector3 copy constructor
Just want to add, so that I don't look like a complete idiot, that the fix above was only possible to apply after changing the way we (in Ogitor) register the reference objects:
asOBJ_NOCOUNT!
As in "get the pointer and leave it alone".
That the code became simpler, is a good thing too.
With that fix in place, I could finally apply the fix that were given to me 1.5 years ago (which I forgotten about).
Weird thing is that none of the projects using Angelscript registers objects that way. So I couldn't just browse code and learn.
Code: Select all
- #define REGISTER_REFERENCE_BASEOBJECT( name, classname )\
- {\
- r = engine->RegisterObjectType(name, 0, asOBJ_REF);assert(r >= 0);\
- r = engine->RegisterObjectBehaviour(name, asBEHAVE_ADDREF, "void f()", asMETHOD(classname,_addRef), asCALL_THISCALL); assert( r >= 0 );\
- r = engine->RegisterObjectBehaviour(name, asBEHAVE_RELEASE, "void f()", asMETHOD(classname,_release), asCALL_THISCALL); assert( r >= 0 );\
- r = engine->RegisterObjectBehaviour("BaseEditor", asBEHAVE_REF_CAST, name "@ f()", asFUNCTION((refCast<CBaseEditor,classname>)), asCALL_CDECL_OBJLAST); assert( r >= 0 );\
- r = engine->RegisterObjectBehaviour(name, asBEHAVE_IMPLICIT_REF_CAST, "BaseEditor@ f()", asFUNCTION((refCast<classname,CBaseEditor>)), asCALL_CDECL_OBJLAST); assert( r >= 0 );\
- }\
- //-----------------------------------------------------------------------------------------
+#define REGISTER_REFERENCE_BASEOBJECT( name, classname )\
+{\
+ r = engine->RegisterObjectType(name, sizeof(classname), asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);\
+}\
+//-----------------------------------------------------------------------------------------
As in "get the pointer and leave it alone".
That the code became simpler, is a good thing too.
With that fix in place, I could finally apply the fix that were given to me 1.5 years ago (which I forgotten about).
Weird thing is that none of the projects using Angelscript registers objects that way. So I couldn't just browse code and learn.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.