45 Joint* Joint::Create(
const JointConf& def)
50 return Create<DistanceJoint>(
static_cast<const DistanceJointConf&
>(def));
52 return Create<TargetJoint>(
static_cast<const TargetJointConf&
>(def));
54 return Create<PrismaticJoint>(
static_cast<const PrismaticJointConf&
>(def));
56 return Create<RevoluteJoint>(
static_cast<const RevoluteJointConf&
>(def));
58 return Create<PulleyJoint>(
static_cast<const PulleyJointConf&
>(def));
60 return Create<GearJoint>(
static_cast<const GearJointConf&
>(def));
62 return Create<WheelJoint>(
static_cast<const WheelJointConf&
>(def));
64 return Create<WeldJoint>(
static_cast<const WeldJointConf&
>(def));
66 return Create<FrictionJoint>(
static_cast<const FrictionJointConf&
>(def));
68 return Create<RopeJoint>(
static_cast<const RopeJointConf&
>(def));
70 return Create<MotorJoint>(
static_cast<const MotorJointConf&
>(def));
74 throw InvalidArgument(
"Joint::Create: Unknown joint type");
77 Joint::FlagsType Joint::GetFlags(
const JointConf& def) noexcept
79 auto flags = Joint::FlagsType{0};
80 if (def.collideConnected)
82 flags |= e_collideConnectedFlag;
88 m_bodyA{def.
bodyA}, m_bodyB{def.bodyB}, m_userData{def.userData}, m_flags{GetFlags(def)}
93 void Joint::Destroy(
const Joint* joint) noexcept
100 return def.bodyA != def.bodyB;
107 const auto bA = j.GetBodyA();
108 const auto bB = j.GetBodyB();
109 return (!bA || bA->IsEnabled()) && (!bB || bB->IsEnabled());
114 const auto bA = j.GetBodyA();
115 const auto bB = j.GetBodyB();
132 const auto world = bA? bA->
GetWorld():
133 bB? bB->GetWorld():
static_cast<const World*
>(
nullptr);
138 const auto it = std::find_if(cbegin(joints), cend(joints), [&](
const Joint *j) {
139 return (j == joint) || ((
void) ++i,
false);
141 if (it != end(joints))
150 #ifdef PLAYRHO_PROVIDE_VECTOR_AT
153 auto last = end(container);
154 auto first = begin(container);
155 first = std::lower_bound(first, last, key, [](
const BodyConstraintPair &a,
const Body* b){
156 return std::get<const Body*>(a) < b;
158 if ((first == last) || (key != std::get<const Body*>(*first)))
160 throw std::out_of_range{
"invalid key"};
162 return std::get<BodyConstraintPtr>(*first);
169 return container.at(key);