VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Joint.h
1 /*
2  * Copyright (C) 2014 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef JOINT_H
18 #define JOINT_H
19 
20 #include <QObject>
21 
22 class Body;
23 class b2Joint;
28 class Joint : public QObject {
29  Q_OBJECT
30 public:
35  explicit Joint(QObject* parent = 0);
36  virtual ~Joint();
37 
43  void setTargets(Body* bodyA, Body* bodyB);
47  Body* getBodyATarget() const { return mBodyA; }
51  Body* getBodyBTarget() const { return mBodyB; }
52 
59  virtual void createJoint();
60 
64  virtual void destroyJoint();
65 
69  virtual void notifyJointDestroyed(b2Joint* joint);
70 
71 protected:
75  b2Joint* mJoint = nullptr;
76 
77 private:
78  Body* mBodyA = nullptr;
79  Body* mBodyB = nullptr;
80 };
81 Q_DECLARE_METATYPE(Joint*)
82 
83 #endif // JOINT_H
Joint(QObject *parent=0)
Construct a Joint.
virtual void createJoint()
Creates the Box2D joint.
A QObject container for a Box2D b2Body.
Definition: Body.h:57
virtual void destroyJoint()
Destroys the b2Joint, if it has been created.
Body * getBodyBTarget() const
Returns Body B.
Definition: Joint.h:51
virtual void notifyJointDestroyed(b2Joint *joint)
Called when a b2Joint associated with this object has been deleted by Box2D.
void setTargets(Body *bodyA, Body *bodyB)
Sets the two Bodys constrained by this Joint.
A constraint between two Bodys.
Definition: Joint.h:28
b2Joint * mJoint
Reference to the Box2D b2Joint.
Definition: Joint.h:75
QObject * parent() const
Body * getBodyATarget() const
Returns Body A.
Definition: Joint.h:47