Spinning Topp Logo BlackTopp Studios
inc
ghostproxy.h
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4 The Mezzanine Engine is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8 
9 The Mezzanine Engine is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18 'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21 Build professional software and charge for their product.
22 
23 However there are some practical restrictions, so if your project involves
24 any of the following you should contact us and we will try to work something
25 out:
26 - DRM or Copy Protection of any kind(except Copyrights)
27 - Software Patents You Do Not Wish to Freely License
28 - Any Kind of Linking to Non-GPL licensed Works
29 - Are Currently In Violation of Another Copyright Holder's GPL License
30 - If You want to change our code and not add a few hundred MB of stuff to
31 your distribution
32 
33 These and other limitations could cause serious legal problems if you ignore
34 them, so it is best to simply contact us or the Free Software Foundation, if
35 you have any questions.
36 
37 Joseph Toppi - toppij@gmail.com
38 John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _ghostproxy_h
41 #define _ghostproxy_h
42 
43 #include "Physics/collidableproxy.h"
44 
45 class btPairCachingGhostObject;
46 
47 namespace Mezzanine
48 {
49  namespace Physics
50  {
51  ///////////////////////////////////////////////////////////////////////////////
52  /// @brief This is the proxy object for ghost objects with no contact response.
53  /// @details
54  ///////////////////////////////////////
56  {
57  protected:
58  /// @internal
59  /// @brief GhostBody proxy used by the internal physics.
60  btPairCachingGhostObject* PhysicsGhostBody;
61 
62  /// @internal
63  /// @brief Used to create the physics representation of the ghost body.
64  /// @param Mass The mass of the ghost body to be created.
65  virtual void CreateGhostObject();
66  public:
67  /// @brief Class constructor.
68  /// @param ID The unique ID assigned to this proxy.
69  /// @param Creator A pointer to the manager that created this proxy.
70  GhostProxy(const UInt32 ID, PhysicsManager* Creator);
71  /// @brief Shape constructor.
72  /// @param ID The unique ID assigned to this proxy.
73  /// @param Shape A pointer to the collision shape that will be applied to this proxy.
74  /// @param Creator A pointer to the manager that created this proxy.
75  GhostProxy(const UInt32 ID, CollisionShape* Shape, PhysicsManager* Creator);
76  /// @brief XML constructor.
77  /// @param SelfRoot An XML::Node containing the data to populate this class with.
78  /// @param Creator A pointer to the manager that created this proxy.
79  GhostProxy(const XML::Node& SelfRoot, PhysicsManager* Creator);
80  /// @brief Class destructor.
81  virtual ~GhostProxy();
82 
83  ///////////////////////////////////////////////////////////////////////////////
84  // Utility
85 
86  /// @copydoc WorldProxy::GetProxyType() const
87  virtual Mezzanine::ProxyType GetProxyType() const;
88 
89  /// @copydoc WorldProxy::AddToWorld()
90  virtual void AddToWorld();
91  /// @copydoc WorldProxy::RemoveFromWorld()
92  virtual void RemoveFromWorld();
93 
94  ///////////////////////////////////////////////////////////////////////////////
95  // Overlapping Proxy Access
96 
97  /// @brief Gets a proxy overlapping with the AABB of this ghost.
98  /// @note This method is faster than getting an overlap by collision shape, but it is also much less accurate.
99  /// @param Index The index of the proxy to retrieve.
100  /// @return Returns a pointer to the overlapping proxy at the specified index.
101  virtual CollidableProxy* GetAABBOverlappingProxy(const UInt32 Index);
102  /// @brief Gets the number of proxies overlapping with the AABB of this ghost.
103  /// @return Returns the number of proxies overlapping with the AABB of this ghost.
104  virtual UInt32 GetNumAABBOverlappingProxies() const;
105 
106  /// @brief Gets a proxy overlapping with the collision shape of this ghost.
107  /// @note The underlying physics implementation tries to predict contacts in order to accelerate physics steps. Because of this in some situations an invalid
108  /// contact/collision may be generated between collision shapes. This method detects that and will return NULL if that is the case. @n @n
109  /// Also note that getting overlaps by shape is slower than getting them by AABB. Only use this if you need the extra accuracy.
110  /// @param Index The index of the proxy to retrieve.
111  /// @return Returns a pointer to the overlapping proxy at the specified index, or NULL if it is invalid.
112  virtual CollidableProxy* GetShapeOverlappingProxy(const UInt32 Index);
113  /// @brief Gets the number of proxies overlapping with the actual collision shape of this ghost.
114  /// @return Returns the number of proxies overlapping with the actual shape of this ghost.
115  virtual UInt32 GetNumShapeOverlappingProxies() const;
116 
117  ///////////////////////////////////////////////////////////////////////////////
118  // Serialization
119 
120  /// @copydoc WorldProxy::ProtoSerializeProperties(XML::Node&) const
121  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
122  /// @copydoc WorldProxy::ProtoDeSerializeProperties(const XML::Node&)
123  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
124 
125  /// @copydoc WorldProxy::GetDerivedSerializableName() const
126  virtual String GetDerivedSerializableName() const;
127  /// @copydoc WorldProxy::GetSerializableName()
128  static String GetSerializableName();
129 
130  ///////////////////////////////////////////////////////////////////////////////
131  // Internal Methods
132 
133  /// @internal
134  /// @brief Accessor for the internal ghost body physics proxy.
135  /// @return Returns a pointer to the internal proxy this proxy is based on.
136  virtual btPairCachingGhostObject* _GetPhysicsObject() const;
137  /// @copydoc CollidableProxy::_GetBasePhysicsObject()
138  virtual btCollisionObject* _GetBasePhysicsObject() const;
139 
140  };//GhostProxy
141  }//Physics
142 }//Mezzanine
143 
144 #endif
This is the base class for all collision shapes.
This is the proxy object for ghost objects with no contact response.
Definition: ghostproxy.h:55
btPairCachingGhostObject * PhysicsGhostBody
GhostBody proxy used by the internal physics.
Definition: ghostproxy.h:60
A light-weight handle for manipulating nodes in DOM tree.
Definition: node.h:89
ProxyType
Used by all World proxies to describe what their derived types are.
Definition: enumerations.h:91
uint32_t UInt32
An 32-bit unsigned integer.
Definition: datatypes.h:126
This is a proxy from which physics objects that can collide with each other are handled.
This is simply a place for storing all the Physics Related functions.
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159