SO3Engine
OgreNewt_Prerequisites.h
Go to the documentation of this file.
1/*
2 OgreNewt Library
3
4 Ogre implementation of Newton Game Dynamics SDK
5
6 OgreNewt basically has no license, you may use any or all of the library however you desire... I hope it can help you in any way.
7
8 by Walaber
9 some changes by melven
10
11*/
12
13
14#ifndef __INCLUDE_OGRENEWT_PREREQ__
15#define __INCLUDE_OGRENEWT_PREREQ__
16
17
18#include <Ogre.h>
19#include <OgreQuaternion.h>
20#include <OgreMovableObject.h>
21#include <OgreRenderable.h>
22#include <OgreNode.h>
23#include <OgreFrameListener.h>
24#include <OgreSceneNode.h>
25#include <OgreSceneManager.h>
26#include <OgreManualObject.h>
27#include <OgreOverlay.h>
28#include <OgreFontManager.h>
29#include <OgreFont.h>
30//#include <OgreTerrain.h>
31# ifndef OGRENEWT_NO_OGRE_ANY
32# include <OgreAny.h>
33# endif
34
35#include <Newton.h>
36#include <dVector.h>
37#include <boost/function.hpp>
38#include <boost/bind/bind.hpp>
39#ifndef OGRENEWT_NO_COLLISION_SHAREDPTR
40# include <boost/shared_ptr.hpp>
41#endif
42
43#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
44# if defined( _OGRENEWT_EXPORTS ) && defined( _OGRENEWT_DYNAMIC )
45# define _CDECL _cdecl
46# define _OgreNewtExport __declspec( dllexport )
47# elif defined( _OGRENEWT_DYNAMIC )
48# define _CDECL _cdecl
49# define _OgreNewtExport __declspec( dllimport )
50# else
51# define _CDECL
52# define _OgreNewtExport
53# endif
54#else // Linux / Mac OSX etc
55# define _OgreNewtExport
56# define _CDECL
57#endif
58
59
60
61
62
63#ifdef OGRENEWT_NO_COLLISION_SHAREDPTR
64#warning "the option OGRENEWT_NO_COLLISION_SHAREDPTR is set"
65#endif
66
67#ifdef OGRENEWT_NO_OGRE_ANY
68#warning "the option OGRENEWT_NO_OGRE_ANY is set"
69#endif
70
71namespace OgreNewt
72{
73 class World;
74 class MaterialID;
75 class Joint;
76 class OgCustomJoint;
77 class Contact;
78 class MaterialPair;
79 class Body;
80 class Collision;
81 class CollisionSerializer;
82 class ConvexCollision;
83 class Debugger;
84
85
87
92 template<class DerivedClass>
94 {
95 public:
97
101 typedef std::function<void(DerivedClass*)> DestructorCallbackFunction;
102
104 _DestructorCallback() : m_callback(NULL) {}
105
108 {
109 if( m_callback )
110 m_callback((DerivedClass*)(this));
111 }
112
114 void removeDestructorCallback() {m_callback = NULL;}
115
117
133 void setDestructorCallback( DestructorCallbackFunction fun ) { m_callback = fun; }
134 template<class c> void setDestructorCallback( std::function<void(c*, DerivedClass*)> callback, c *instancedClassPointer )
135 {
136 setDestructorCallback( std::bind(callback, instancedClassPointer, std::placeholders::_1) );
137 }
138 private:
140
141 };
142}
143
144#endif
145
helper class: OgreNewt-classes can derive from this class to implement a destructor-callback
void setDestructorCallback(DestructorCallbackFunction fun)
set the destructor callback
std::function< void(DerivedClass *)> DestructorCallbackFunction
destructor callback
void setDestructorCallback(std::function< void(c *, DerivedClass *)> callback, c *instancedClassPointer)
void removeDestructorCallback()
remove any destructor callback