Added GearJoint:getJoints (resolves issue #922.)

This commit is contained in:
Alex Szpakowski
2014-11-14 22:06:37 -04:00
parent 78d5db6981
commit 68936e6d2f
4 changed files with 82 additions and 0 deletions
+27
View File
@@ -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