MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ghostproxy.h
1 // © Copyright 2010 - 2012 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 Creator A pointer to the manager that created this proxy.
69  GhostProxy(PhysicsManager* Creator);
70  /// @brief XML constructor.
71  /// @param SelfRoot An XML::Node containing the data to populate this class with.
72  /// @param Creator A pointer to the manager that created this proxy.
73  GhostProxy(const XML::Node& SelfRoot, PhysicsManager* Creator);
74  /// @brief Class destructor.
75  virtual ~GhostProxy();
76 
77  ///////////////////////////////////////////////////////////////////////////////
78  // Utility
79 
80  /// @copydoc WorldProxy::GetProxyType() const
81  virtual Mezzanine::ProxyType GetProxyType() const;
82 
83  /// @copydoc WorldProxy::AddToWorld()
84  virtual void AddToWorld();
85  /// @copydoc WorldProxy::RemoveFromWorld()
86  virtual void RemoveFromWorld();
87 
88  ///////////////////////////////////////////////////////////////////////////////
89  // Overlapping Proxy Access
90 
91  /// @brief Gets a proxy overlapping with the AABB of this ghost.
92  /// @note This method is faster than getting an overlap by collision shape, but it is also much less accurate.
93  /// @param Index The index of the proxy to retrieve.
94  /// @return Returns a pointer to the overlapping proxy at the specified index.
95  virtual CollidableProxy* GetAABBOverlappingProxy(const UInt32 Index);
96  /// @brief Gets the number of proxies overlapping with the AABB of this ghost.
97  /// @return Returns the number of proxies overlapping with the AABB of this ghost.
98  virtual UInt32 GetNumAABBOverlappingProxies() const;
99 
100  /// @brief Gets a proxy overlapping with the collision shape of this ghost.
101  /// @note The underlying physics implementation tries to predict contacts in order to accelerate physics steps. Because of this in some situations an invalid
102  /// contact/collision may be generated between collision shapes. This method detects that and will return NULL if that is the case. @n @n
103  /// Also note that getting overlaps by shape is slower than getting them by AABB. Only use this if you need the extra accuracy.
104  /// @param Index The index of the proxy to retrieve.
105  /// @return Returns a pointer to the overlapping proxy at the specified index, or NULL if it is invalid.
106  virtual CollidableProxy* GetShapeOverlappingProxy(const UInt32 Index);
107  /// @brief Gets the number of proxies overlapping with the actual collision shape of this ghost.
108  /// @return Returns the number of proxies overlapping with the actual shape of this ghost.
109  virtual UInt32 GetNumShapeOverlappingProxies() const;
110 
111  ///////////////////////////////////////////////////////////////////////////////
112  // Serialization
113 
114  /// @copydoc WorldProxy::ProtoSerializeProperties(XML::Node&) const
115  virtual void ProtoSerializeProperties(XML::Node& SelfRoot) const;
116  /// @copydoc WorldProxy::ProtoDeSerializeProperties(const XML::Node&)
117  virtual void ProtoDeSerializeProperties(const XML::Node& SelfRoot);
118 
119  /// @copydoc WorldProxy::GetDerivedSerializableName() const
120  virtual String GetDerivedSerializableName() const;
121  /// @copydoc WorldProxy::GetSerializableName()
122  static String GetSerializableName();
123 
124  ///////////////////////////////////////////////////////////////////////////////
125  // Internal Methods
126 
127  /// @internal
128  /// @brief Accessor for the internal ghost body physics proxy.
129  /// @return Returns a pointer to the internal proxy this proxy is based on.
130  virtual btPairCachingGhostObject* _GetPhysicsObject() const;
131  /// @copydoc CollidableProxy::_GetBasePhysicsObject()
132  virtual btCollisionObject* _GetBasePhysicsObject() const;
133  };//GhostProxy
134  }//Physics
135 }//Mezzanine
136 
137 #endif