mirror of
https://github.com/love2d/love.git
synced 2026-08-18 03:34:23 +02:00
Added GearJoint:getJoints (resolves issue #922.)
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
// Module
|
||||
#include "Body.h"
|
||||
#include "World.h"
|
||||
#include "common/Memoizer.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
@@ -60,6 +61,32 @@ float GearJoint::getRatio() const
|
||||
return joint->GetRatio();
|
||||
}
|
||||
|
||||
Joint *GearJoint::getJointA() const
|
||||
{
|
||||
b2Joint *b2joint = joint->GetJoint1();
|
||||
if (b2joint == nullptr)
|
||||
return nullptr;
|
||||
|
||||
Joint *j = (Joint *) Memoizer::find(b2joint);
|
||||
if (j == nullptr)
|
||||
throw love::Exception("A joint has escaped Memoizer!");
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
Joint *GearJoint::getJointB() const
|
||||
{
|
||||
b2Joint *b2joint = joint->GetJoint2();
|
||||
if (b2joint == nullptr)
|
||||
return nullptr;
|
||||
|
||||
Joint *j = (Joint *) Memoizer::find(b2joint);
|
||||
if (j == nullptr)
|
||||
throw love::Exception("A joint has escaped Memoizer!");
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
} // box2d
|
||||
} // physics
|
||||
} // love
|
||||
|
||||
Reference in New Issue
Block a user