mirror of
https://github.com/love2d/love.git
synced 2026-08-16 00:02:12 +02:00
Make MouseJoint:getBodies() return only one body (fixes #1179)
Override Joint's Body getters in MouseJoint, to make the second (user-supplied) body the first body returned, and return nil for the second (internal) body
This commit is contained in:
@@ -84,8 +84,8 @@ public:
|
||||
**/
|
||||
Type getType() const;
|
||||
|
||||
Body *getBodyA() const;
|
||||
Body *getBodyB() const;
|
||||
virtual Body *getBodyA() const;
|
||||
virtual Body *getBodyB() const;
|
||||
|
||||
/**
|
||||
* Gets the anchor positions of the Joint in world
|
||||
|
||||
@@ -91,6 +91,16 @@ float MouseJoint::getDampingRatio() const
|
||||
return joint->GetDampingRatio();
|
||||
}
|
||||
|
||||
Body *MouseJoint::getBodyA() const
|
||||
{
|
||||
return Joint::getBodyB();
|
||||
}
|
||||
|
||||
Body *MouseJoint::getBodyB() const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // box2d
|
||||
} // physics
|
||||
} // love
|
||||
|
||||
@@ -95,6 +95,9 @@ public:
|
||||
**/
|
||||
float getDampingRatio() const;
|
||||
|
||||
virtual Body *getBodyA() const;
|
||||
virtual Body *getBodyB() const;
|
||||
|
||||
private:
|
||||
// The Box2D MouseJoint object.
|
||||
b2MouseJoint *joint;
|
||||
|
||||
Reference in New Issue
Block a user