Callback function

OvermindDL1

03-03-2006 10:20:26

You know the function where you give a body a static callback function, would it be possible for you to add a simple overload function so we can bind data to the function, as in:

mBody->setCustomForceAndTorqueCallback(function<void(const NewtonBody*)>(bind(MyGameUnitClass::forceCallback, this, _1)));

The overload would have to come before the original, and it would be something like:

//! set a custom force callback for this body to use.
template<class F>
void setCustomForceAndTorqueCallback( F callback );


Looking through your setup of that function, such an override would be simple enough, might have to change your m_forcecallback to be an actual functor, which would be fully compatable with what you are doing with that variable currently, or mabye add a new variable for the function and just have a different internal callback call it. If I get time this weekend I could make the change and give you the code to review if you wish.

Reasoning is, I really don't like wierd workarounds of getting the user data and casting it back to the type and all such, would prefer to just reference it as the actual class method (in the above example, the function 'callback' is a method, not a static function). More C++ in style (considering how heavy C++ Ogre is). The style currently used brings me back to old C days...

EDIT: Actually if you converted the object to a functor itself, it would still be backwards compatable, and would not need the template. The declaration would be something like:
void setCustomForceAndTorqueCallback( function<void(const NewtonBody*)> callback );

Not to mention, you suddenly gain type checking and the ability to bind (so you can use a method instead of a static function). Using this style the above top example would be converted to:

mBody->setCustomForceAndTorqueCallback(bind(MyGameUnitClass::forceCallback, this, _1));

Or you could still do the original:

mBody->setCustomForceAndTorqueCallback(MyGameUnitClass::originalStaticCallbackFunction);

walaber

03-03-2006 17:27:11

i would be interested in seeing a working solution for this... I think many people would probably prefer a solution like that... I know CEGUI uses something similar which works very well.

OvermindDL1

03-03-2006 18:13:32

Boost is the most well-known, well-researched, and my personal favorate implementation. Plus you can take the code from boost and copy it into your project for free, as long as you don't misrepresent the source or remove the copyright from the source file, other then that you don't even need to say you use it, one of the most free licenses of all. The function and binding classes are also completely in headers, no library needed, so you could use both, even put them in the ogrenewt namespace (you can edit the files, just have to say that you edited the file at the top of the file I believe, or just copy the boost code to elsewhere, with proper notice at top of that file). Boost's libraries have a high tendency to be added to the standard C++ set at each new revision (function is on the list of possibles to be added, as is bind, to replace std::'s usual bind_1st and bind_2nd). I can whip up a demo this weekend. I'll update from cvs (sourceforge had better be working...) and make the change, whip up a demo source file to use it in a couple different ways, and post up the changes I made and the example source. It's a very simple change, shouldn't take but five minutes to make it and the example.

If you are overly concerned, function objects like that have on average 10% processing overhead over a normal function pointer, which is pretty negligable in any case. It can be as high as 20ms for debug mode, to being the same as (actually generating the same instructions as) a normal function pointer with a good compiler.

You could wrap up that bind nonsense into a macro too, to make it easier to use to people who are unfamilier with the syntax. Or you could make a wrapper function which accepts a function object (just the pointer to the method member) and a void* and it can do the binding then pass it to the main callback registration. I havn't actually written up the latter yet, so I am unsure how easy that would be to setup (aka, if an unbound member function pointer can easily be given to a function, pretty certain it can, but not positive).

Tora-Bora

05-03-2006 09:22:52

May be make sence replace callback function to signals? From boost library? http://www.boost.org/doc/html/signals.html

OvermindDL1

06-03-2006 04:46:24

True, I love signals, use them for quite a bit, my entire action/event system uses them, all tied together, makes an input action-mapper idiotically easy. This is from a post I made elsewhere a few weeks back:
Also, I think I finished the first usable part of my action mapper. It currently has an input manager embedded into it (I want a central access to this, and I completely hide the input manager actually, if anything even wants to access the keyboard for typing they register to listen to whatever actions, which are of course rebindable, can make it so if you hit 'z' on the keyboard, it sends 'p'). Multiple actions can listen to one action, an action can listen to multiple actions. By default there are actions for each key on the keyboard, and you can build more actions from those just by binding more. They are referenced by name, which may seem slow, but you only use such access when you are initially making or destroy bindings; gives the advantage of being able to make an arbitrary amount of actions. The way this is setup, you can also make actions not bound to keys or other actions, and these can be triggered by whatever else code you have elsewhere so it would make a good system for triggers and such as well. Here is some example code for how to bind a method to recieve input to a custom action:

// say that actionManager is a pointer to the action manager class
class someClass
{
scopedActionConnection connFire;
public:
someClass()
{
actionManager->addAction("Fire"); // if Fire already exists, does nothing
actionManager->addLink("mouseButton0", "Fire"); // mouseButton0 is actually another action, just by default bound to mouseButton0
connFire = actionManager->addLink("Fire", bind(&someClass::doWhateverHere, this, _1)); // that convoluted bind stuff will disappear later
}

void doWhateverHere(float power)
{
// When the left mouse button is pressed (or any other actions bound to Fire are activated),
// this is called upon every change, for a button, like the left mouse button, it is simple:
// power==0.0f when it is let up, power==1.0f when it is pressed. Do note, it doesn't have
// to be a button, if I bound it to a joystick axis or a mouse axis, then it would vary between
// 0.0f and 1.0f depending on how far, so you could say, have a variable rate machine gun
// that varies depending on how far the joystick is pressed up or something. each direction of
// an axis is its own action for note, so pressing up could do one thing, and down could do
// another. Could always make an action that listens to both and has 0.5f be in the center.
// More advanced topic though.
fireGun(power);
}
}


Planned changes:
Remove that bind convulation (easily done, just was easy to stick in for now).
Considering letting there be scopes, so there could be different actions depending on a setting, say, gui, tank, spacecraft. Wouldn't be hard to do.
Finish the serializing. Partially done, just need to finish. Serializing, as in save to disk or read from disk. Right now it reads in from any location designated in the resource system, just doesn't do anything with it yet. Writing out has a stuf function so far, need to finish it.

Creating events is expensive, hash lookup.
Creating links is also expensive, two lookups if it is between actions, one lookup if it is between a method and an action.
The return from addLink in the example above is stuffed into a scoped container, you can also subclass from actionTrackable to do this same thing without requiring another var, which will auto remove the link when the class is destroyed, you can also destroy it manually by calling disconnect() on the container. Overall this is not expensive.
The actuall callbacks are as fast as a normal function wrapper callback, so, quite fast even not considering how often inputs will be hit per frame. :P

This is partially tied into my object system right now. I have classes that you subclass from to handle a multitude of things, this also use actions heavily and they are in a stack form, so the higher ones in the stack get primary input, the lower ones (below the upper-most) can either share input with the top (with top getting calls first), or will be completely blocked, depending on how the top is pushed onto the stack. This class setup is the reason why I'm even thinking of why bother with the scopes embedded into the action system at all, but if someone wanted to use it externally of my object system, it would be useful.


Yes, signals are nice, never used them up until a month ago, wish I'd figured them out earlier.

EDIT: Here, change the file to be like this:
First, I'm using boost, you can strip out the needed files and include them with your project directly if you want, so I add an include for boost/function.hpp and boost/bind.hpp (only need function, but for anything that wants to bind in the above example, so they wont' have to include it themselves, and to remind to make a copy of it in your project too).

First I replaced:

typedef void(*ForceCallback)( Body* me );
typedef void(*TransformCallback)( Body* me, const Ogre::Quaternion& orient, const Ogre::Vector3& pos );
typedef bool(*buoyancyPlaneCallback)( int collisionID, Body* me, const Ogre::Quaternion& orient, const Ogre::Vector3& pos, Ogre::Plane& retPlane );

with:
typedef boost::function<void(Body*)> ForceCallback;
typedef boost::function<void(Body*,const Ogre::Quaternion&,const Ogre::Vector3&)> TransformCallback;
typedef boost::function<bool(int,Body*,const Ogre::Quaternion&,const Ogre::Vector3&,Ogre::Plane&)> buoyancyPlaneCallback;


Now, you can still set it to 0, can still do a boolean test if it has a function set to it, etc... the main parts that need changing are dereferences, such as at:
// OgreNewt_Body.cpp

// line 80:
(*me->m_forcecallback)( me );
// changed to:
me->m_forcecallback(me);

// line 71:
(*me->m_transformcallback)( me, orient, pos );
// changed to:
me->m_transformcallback(me, orient, pos);

// line 121:
if ((*me->m_buoyancycallback)(collisionID, me, orient, pos, theplane ))
// changed to:
if(me->m_buoyancycallback(collisionID, me, orient, pos, theplane))


And compares (as they are done with function_equal(someFunction, anotherFunction) instead), so (I just commented them out rather then change it to function_equal, you can do it that way instead, but I figure they shouldn't be changing these callbacks too much anyway...):
// line 187:
if (m_forcecallback != callback)
// commented out

// line 203:
if (m_transformcallback != callback)
// commented out


All the demo's ran just fine (although only Demo's 4 and 6 used those callbacks anyway) without alteration. As a demo, I edited the code in demo 6 (buoyancy) to make all three callbacks non-static (I don't need to show code changes for that do I? :P ) in the framelistener. And made these changes as well:
// OgreNewtonApplication.cpp

// line 99
child->setCustomForceAndTorqueCallback( OgreNewtonFrameListener::standardForceCallback );
// changed to:
child->setCustomForceAndTorqueCallback( boost::bind(OgreNewtonFrameListener::standardForceCallback, (OgreNewtonFrameListener*)mFrameListener, _1) );

// line 132:
bod->setCustomForceAndTorqueCallback( OgreNewtonFrameListener::standardForceCallback );
// changed to:
bod->setCustomForceAndTorqueCallback( boost::bind(OgreNewtonFrameListener::standardForceCallback, (OgreNewtonFrameListener*)mFrameListener, _1) );

// OgreNewtonFrameListener.cpp

// lines 215 AND lines 231:
me->addBouyancyForce( 0.7, 0.5, 0.5, Ogre::Vector3(0.0f,-9.8f,0.0f), OgreNewtonFrameListener::buoyancyCallback );
// changed to:
me->addBouyancyForce( 0.7, 0.5, 0.5, Ogre::Vector3(0.0f,-9.8f,0.0f), boost::bind(OgreNewtonFrameListener::buoyancyCallback, this, _1, _2, _3, _4, _5) );

// line 139:
dragBody->setCustomForceAndTorqueCallback( OgreNewtonFrameListener::standardForceCallback );
// changed to:
dragBody->setCustomForceAndTorqueCallback( boost::bind(OgreNewtonFrameListener::standardForceCallback, this, _1) );

// line 115:
info.mBody->setCustomForceAndTorqueCallback( OgreNewtonFrameListener::dragCallback );
// changed to:
info.mBody->setCustomForceAndTorqueCallback( boost::bind(OgreNewtonFrameListener::dragCallback, this, _1) );


Pretty useless to bind and not just keep static the callbacks standardForceCallback and buoyancyCallback, but dragCallback it is useful on, so I remove that casting and useinfo stuff and changed the entire function to this:
void OgreNewtonFrameListener::dragCallback( OgreNewt::Body* me )
{
// this body is being dragged by the mouse, so apply a spring force.
// first find the global point the mouse is at...
CEGUI::Point mouse = CEGUI::MouseCursor::getSingleton().getPosition();
CEGUI::Renderer* rend = CEGUI::System::getSingleton().getRenderer();

Ogre::Real mx,my;
mx = mouse.d_x / rend->getWidth();
my = mouse.d_y / rend->getHeight();
Ogre::Ray camray = mCamera->getCameraToViewportRay( mx, my );

Ogre::Vector3 campt = camray.getPoint( dragDist );

// now find the global point on the body:
Ogre::Quaternion bodorient;
Ogre::Vector3 bodpos;

me->getPositionOrientation( bodpos, bodorient );

Ogre::Vector3 bodpt = (bodorient * dragPoint) + bodpos;

// apply the spring force!
Ogre::Vector3 inertia;
Ogre::Real mass;

me->getMassMatrix( mass, inertia );

Ogre::Vector3 dragForce = ((campt - bodpt) * mass * 8.0) - me->getVelocity();

// draw a 3D line between these points for visual effect :)
if (mDragLine)
{
// line exists, remove it.
remove3DLine();
}
mDragLine = new Line3D();
mDragLine->addPoint( campt );
mDragLine->addPoint( bodpt );
mDragLine->drawLines();
mDragLineNode->attachObject( mDragLine );


// Add the force!
me->addGlobalForce( dragForce, bodpt );



Ogre::Vector3 gravity = Ogre::Vector3(0,-9.8,0) * mass;
me->addForce( gravity );

// also don't forget buoyancy force.
// me->addBouyancyForce( 0.7, 0.5, 0.5, Ogre::Vector3(0.0f,-9.8f,0.0f), OgreNewtonFrameListener::buoyancyCallback );
me->addBouyancyForce( 0.7, 0.5, 0.5, Ogre::Vector3(0.0f,-9.8f,0.0f), boost::bind(OgreNewtonFrameListener::buoyancyCallback, this, _1, _2, _3, _4, _5) );

}


This program worked and compiled as was before, and it works and compiles now, not to mention is also allows you to access protected/private members/functions in the callback functions now, proper OO. :)


Although, signals would be better overall, as you can see in the example syntax above...

Tora-Bora

06-03-2006 18:21:53

It's mutch more usability then native callbacks. You can commit it in CVS? Or only walaber can decide to do it?

walaber

06-03-2006 18:31:30

i agree this is better than the current system, which emulates Newton itself, and is not very OOP. however I'm not a big fan of requiring any external libraries other than Ogre and Newton to compile OgreNewt...

Tora-Bora

06-03-2006 18:38:31

I understand... but you can cut out signal code from boost and use it as part of OgreNewt?

OvermindDL1

06-03-2006 21:52:07

Boost is made to be sliced up and included/used in your projects. My previous post is just using functions and binding, using signals I agree would be better; if I get a chance soon, I'll make up an example that uses signals instead.

Almost all of boost is completely header files, so not even any libs to include, the exceptions are things like wave and the python wrapper, so including it in your own projects is as simple as copying the, for example, function.hpp, bind.hpp, and the function and bind directories, into your own project. Just include the function/bind.hpp's when you want to use them. Some libraries, like signals, use others so you have to include the others as well, the others (in signals) being function and bind. Signals is basically just a wrapper for those that makes things even idiotically easier. :)

walaber

06-03-2006 22:08:09

okay, as long as everything is OK with licensing issues, I wouldn't mind adding a OgreNewt\OgreNewt_Main\dependencies\ directory, and putting the relevant boost stuff in there.

if someone would like to submit this as a very clean patch to OgreNewt_Main, I will have a look and (most likely) commit it to CVS.

OvermindDL1

06-03-2006 22:52:32

The license for Boost is very simple, it can be summed up from this copied paragraph (taken from the "How is it (un)like the GPL" section):
The Boost license permits the creation of derivative works for commercial or non-commercial use with no legal requirement to release your source code. Other differences include Boost not requiring reproduction of copyright messages for object code redistribution, and the fact that the Boost license is not "viral": if you distribute your own code along with some Boost code, the Boost license applies only to the Boost code (and modified versions thereof); you are free to license your own code under any terms you like.

So basically, you can include it all you want, don't have to say you are using it in any credits or licenses or anything, can still license your product however you want. Just need to keep the copyrights at the top of each boost file you use, unmodified, unless you modify the file, then you can say you modified it, but still can't erase anything that is there. About the most unrestrictive license you could hope for.

If you just want to use functions and binds, I already have the conversion done and I can make some documentation for it and make a patch.

If you want to use signals, just wait till I get some free time to whip it up (weekend at the latest).

walaber

06-03-2006 23:41:28

well I already get a lot of emails and trouble with people not understanding the callback system, so whichever system is the easiest for the end-user to implement I would like to go with. from that I understand boost::signal seems to sound the easiest.

please package it up in an easy-to understand way, and I will review it, add it, and commit to CVS!

OvermindDL1

07-03-2006 00:13:23

Actually, signals would be easier to impliment from your side (which if your not doing, doesn't matter aynways. I have normal functions/bind done :P ), they would be setup the same from the other side.

There is one thing, if you bind a class method to an instanced class, they need to make sure that it never goes out of scope when you might use it, which is not a problem with static functions. Signal has things to handle that, but it adds some more dealings to the user side, either by setting up a scoped container (see my input manager example above), or subclassing from boost::signal::trackable. As long as they remember to remove the callback before the class goes out of scope (obviously not a problem if the class destroys the body before it goes out of scope :P ), it is fine. Which is a normal problem with normal callbacks anyway, so meh..

If I get a moment soon, I'll package up the changes I made, along with stripping boost of the things you want, and converting the changes to use it.

EDIT: Question, when I package up the changes, do you want me to include the changes I made to demo 6, and do you want me to make the same changes to demo 4, as those are the only two demo's that use those callbacks.

EDIT2: Compiling up changes now. How do you make a patch for only specific files using cvs, I know how using svn. If I manage to finish all this first, I'll just package it all up in a self-extracting zip.

EDIT3: Think I figured out how to make a patch in cvs, lot of good it does, sourceforge is inaccessable again, went ahead and made a self-extracting compressed file with the proper directory tree, just extract directly to OgreNewt to make the changes, would of course be best to extract elsewhere and run windiff or something to see what changed. Added a dependency tree. Link is at bottom of this edit, I'll leave it up a while. And of course, if you are allergic to exe's, or you are on linux, use any standard 7zip extractor to extract it, like 7zip, or winrar, or whatever. Now just need to wait for what I forgot with it (I *always* forget something in a zip when I make a zip... >.<)
Link to my forum post with patch: http://www.overminddl1.com/forum/index. ... 2.new.html
Link to patch itself: http://www.overminddl1.com/forum/index. ... attach=195

walaber

07-03-2006 02:09:17

i will check this when I get home... and integrate it into my local copy of ogrenewt assuming all is OK. then I will commit it to CVS myself.

thanks for your help so far!!

OvermindDL1

07-03-2006 02:40:25

Do note, that is built using OgreNewt CVS from about three days ago, so if you changed any of these files at all, make sure to diff em first.

EDIT: Do note, I made a modification to what I showed above. I added three functions, just overrides to the set a callback functions, the new ones take the same as the old, plus a pointer to an instanced class at the end, if they use that one, they just need to pass a class method and the pointer to the instanced class, it got rid of that bind stuff for the users.

walaber

07-03-2006 05:23:38

it seems to be missing a few files that boost wants.

ogreaddons\ogrenewt\ogrenewt_main\dependencies\bind.hpp(24) : fatal error C1083: Cannot open include file: 'boost/config.hpp': No such file or directory

in that file there are lots of "boost/blah.hpp" type includes that don't seem like they are going to work since obviously none of those files are there.

OvermindDL1

07-03-2006 10:37:37

Err, I know why. Will fix it after I sleep some. Didn't I say that I always forget something. :roll:

Sinjaph

07-03-2006 16:40:33

AFAIK boost has many other capabilities. if we only need binding capabilities why dont we use fastdelegate instead? only a single header is enough

http://www.codeproject.com/cpp/FastDelegate.asp

PS. I've already integrated fastdelegate, seems working

OvermindDL1

07-03-2006 17:35:04

It looks nice, but I am unsure how optimized it can get compared to boost though. The most popular parts of boost do have a tendency to get moved to std upon each new C++ revision after all, must say something. The fastdelegate code I've seen in the past, but its interface is odd (maybe I'm just used to boost's format) and requires more typing. The boost function and bind is already accepted into the next std for C++ so if you intend to use the standard set in the next revision, may as well use this now. Not to mention that the underlying code is generally optimized out by any half decent compiler to be as fast as a function call.

Besides, I know what I forgot anyway. >.>

Should have a chance to fix in 7 hours from now.

walaber

07-03-2006 17:36:00

FastDelegate seems pretty nice! I will investigate this a bit farther... it sounds simple, fast, and cleaner in the sense that onle 1 .h is needed!
:D

[edit] I've added FastDelegate to my local copy, and so far compiling great. this will result in non-braking changes for all existing code, but you can now bind member functions to specific instances of the class as well if you want. I'll do a few more checks and if all is OK I will commit the changes. [/edit]

walaber

07-03-2006 19:13:17

okay guys fastdelegate is in! with a single .h addition, you can now use standard member functions as callbacks!

the best part is there are no breaking changes, all existing code still compiles and works as-is.

I have updated the demos (demo04 and 06) to show how you can now bind to standard member functions... it's very very easy.

I will wait for reports from users as to any potential problems before updating the zip download on my website.

OvermindDL1 thanks for your help. I understand why you are more interested in using boost. I will consider reverting to the boost style once it has been accepted into the C++ std .

OvermindDL1

07-03-2006 21:34:43

Cool, will check out tonight (hopeing anon cvs is updated...). At work right now. Out of curiosity, what is a quick example line of code for binding a static function with it, and for binding a member function to an instanced class? Is it like the code in that zip above, or simpler?

walaber

07-03-2006 22:44:55

for a simple static function:
body->setCustomForceAndTorqueCallback( &SomeClass::SomeSimpleStaticFunnction );

for a member function:
from within the class
mBody->setCustomForceAndTorqueCallback( fastdelegate::MakeDelegate( this, &Myclass::forceCallback ) );

outside the class
body->setCustomForceAndTorqueCallback( fastdelegate::MakeDelegate( (MyClass*)classInstance, &Myclass::forceCallback ) );

so it's really, really easy. you just use the MakeDelegate function, and pass a pointer to the class, and a pointer to the function. it works the same for the ForceAndTorque callback, the Transform callback, and the AddBuoyancyPlane callback.

OvermindDL1

08-03-2006 00:02:33

For note, but for function pointers, using & is generally unneeded unless you are using VC6 or less...

And that fastdelegate::MakeDelegate stuff reminds me of the boost::bind stuff that I wanted to get rid of. And I did, I'd recommend just changing the code in my zip above for the wrapper functions I created to do the same thing, ergo if you interface ever changes (you use another delegate type or whatnot), no changes will be needed. :)

Just got home, going to hope sf is up and anon cvs is updated with these changes.

walaber

08-03-2006 00:39:33

For note, but for function pointers, using & is generally unneeded unless you are using VC6 or less...


from that I understand it is the opposite. the standard requires the & sign, and MS compilers did not require it until the release of 8.0 (2005), which does give an error if the "&" is missing (at least for standard function pointers).

when I upgraded to 2005 I had to change a lot of my source code to compile by adding & in front of function pointers.

OvermindDL1

08-03-2006 01:00:34

Hmm, odd, I could of sworn that it wasn't required... now where did I read that...


Found it:
Note that the & isn't really necessary unless you happen to be using Microsoft Visual C++ version 6.
It is refering to function pointers, that is actually in the boost documentation: http://www.boost.org/doc/html/function/ ... #id2688524
So it might only be with boost...

EDIT: In another program I have that uses boost::function, this is what the compiled code turns into when calling the function:
00401124 mov edi,dword ptr [callbackEvent]
00401127 test edi,edi
00401129 jne $L82157 (40113Dh)
0040112B lea eax,[ebp-34h]
0040112E push eax
0040112F call boost::bad_function_call::bad_function_call (401000h)
00401134 mov byte ptr [ebp-4],1
00401138 call boost::throw_exception<boost::bad_function_call> (403320h)
$L82157:
0040113D mov esi,dword ptr [ebp+0Ch]
00401140 push 0Dh
00401142 push esi
00401143 call dword ptr [ebp+10h]
, in which most of it is just if it fails, no function assigned to it. So assuming that the function has something in it, this is its code path:
00401124 mov edi,dword ptr [tes]
00401127 test edi,edi
00401129 jne $L82157 (40113Dh)
0040113D mov esi,dword ptr [ebp+0Ch]
00401140 push 0Dh
00401142 push esi
00401143 call dword ptr [ebp+10h]


Going to test the fast delegate thing when I get a chance, then post up its generated assembly. Let's see how it compares. Don't forget that the fastdelegate function is years old, boost:function gets an update every revision (few times a year), so it would make sense it would be as perfect as can be, especially since it is already accepted into std (to be released upon next C++ version, 2007 is expected :) ).

EDIT2: Gull bloody frick I can't get this fast delegate to compile. Trying to convert what I showed above from using boost to fastdelegate Quick help you who use it?
Using boost I was doing:
template<class cla>
void saveMethodPointer(boost::function<void(cla*,int)> tes, cla *instancedClassPointer){
methodPtr = boost::bind(tes, instancedClassPointer, _1);
}


I can't seem to figure out a way to get this to compile with fastdelegate, this is where I am at now:
template<class cla>
void saveMethodPointer(fastdelegate::FastDelegate2<cla*,int> tes, cla *instancedClassPointer){
methodPtr = fastdelegate::MakeDelegate(instancedClassPointer, tes);
}

Also tried:
template<class cla>
void saveMethodPointer(fastdelegate::FastDelegate2<cla*,int> tes, cla *instancedClassPointer){
methodPtr.bind(instancedClassPointer, tes);
}


Nothing will compile like this using fastdelegate, and I have a good couple dozen things written using this way.

0040F3A0 mov ecx,dword ptr [methodPtr]
0040F3A3 push 10h
0040F3A5 call dword ptr [ebp-8]

EDIT3: Okay, not using a passing thing like above, actually putting a makedelegate thing inside a source file that calls that function (ew) and it works, here is the same code at the same location:

0040F3B0 mov ecx,dword ptr [tes]
0040F3B3 push 10h
0040F3B5 lea edx,[callbackEvent]
0040F3B8 push edx
0040F3B9 call dword ptr [ebp-8]

And here is the boost one again:
00401124 mov edi,dword ptr [tes]
00401127 test edi,edi
00401129 jne $L82157 (40113Dh)
0040113D mov esi,dword ptr [ebp+0Ch]
00401140 push 0Dh
00401142 push esi
00401143 call dword ptr [ebp+10h]

The boost one has a check to make sure it is valid, other then that they are... identical. I have a place where functors are used, going to test it there...

EDIT4: Okay, here is the assembly using a functor and boost::function:
0040F477 mov eax,offset boost::detail::function::functor_manager<callBackFunctor,std::allocator<void> >::manage (403820h)
0040F47C test eax,eax
0040F47E mov dword ptr [ebp-4],0
0040F485 jne main+99h (40F499h)
0040F487 lea ecx,[ebp-50h]
0040F48A push ecx
0040F48B call boost::bad_function_call::bad_function_call (401000h)
0040F490 mov byte ptr [ebp-4],1
0040F494 jmp boost::throw_exception<boost::bad_function_call> (403350h)
0040F499 push 11h
0040F49B push esi
0040F49C call boost::detail::function::void_function_obj_invoker1<callBackFunctor,void,int>::invoke (4037F0h)

Again, a ton of failure condition code, the actual code is quite small, but since it is a functor it has another jump to do before the function is called, that call leads to another section of code that apparently inlined my entire functor into, the code that isn't my functor is two assembly lines total.

Now, as for using fastdelegate, still trying to get it to compile it, getting rather irritating.
boost::function<void(int)> m_ActionCallback = theFunctor; is basically what I'm doing with the boost code (although it is a member variable and theFunctor is a function variable passed in).
FastDelegate1<int> m_ActionCallback = theFunctor;
This just does not want to compile, and I can't figure out a way. I've tried the makedelegate, bind, all sorts of things...