#include "UnitTests.hpp"
#include <PlayRho/Dynamics/Joints/FrictionJointConf.hpp>
#include <PlayRho/Dynamics/Joints/Joint.hpp>
#include <PlayRho/Collision/Shapes/DiskShapeConf.hpp>
#include <PlayRho/Dynamics/World.hpp>
#include <PlayRho/Dynamics/WorldBody.hpp>
#include <PlayRho/Dynamics/WorldFixture.hpp>
#include <PlayRho/Dynamics/WorldJoint.hpp>
#include <PlayRho/Dynamics/WorldMisc.hpp>
#include <PlayRho/Dynamics/BodyConf.hpp>
#include <PlayRho/Dynamics/StepConf.hpp>
{
case 4:
break;
case 8:
break;
case 16:
break;
default:
FAIL();
break;
}
}
{
EXPECT_EQ(def.collideConnected, false);
EXPECT_EQ(def.localAnchorA, (
Length2{}));
EXPECT_EQ(def.localAnchorB, (
Length2{}));
EXPECT_EQ(def.maxForce, 0_N);
EXPECT_EQ(def.maxTorque, 0_Nm);
}
{
const auto p1 =
Length2{-1_m, 0_m};
const auto p2 =
Length2{+1_m, 0_m};
const auto anchor =
Length2{0_m, 0_m};
EXPECT_EQ(def.bodyA, b1);
EXPECT_EQ(def.bodyB, b2);
}
TEST(FrictionJoint, Construction)
{
const auto joint =
Joint{def};
EXPECT_EQ(
GetType(joint), GetTypeID<FrictionJointConf>());
}
{
const auto joint =
Joint{def};
ASSERT_EQ(
GetType(joint), GetTypeID<FrictionJointConf>());
EXPECT_EQ(cdef.bodyA, b0);
EXPECT_EQ(cdef.bodyB, b1);
EXPECT_EQ(cdef.collideConnected, false);
EXPECT_EQ(cdef.localAnchorA, (
Length2{}));
EXPECT_EQ(cdef.localAnchorB, (
Length2{}));
EXPECT_EQ(cdef.maxForce, 0_N);
EXPECT_EQ(cdef.maxTorque, 0_Nm);
}
TEST(FrictionJoint, WithDynamicCircles)
{
const auto p1 =
Length2{-1_m, 0_m};
const auto p2 =
Length2{+1_m, 0_m};
jd.bodyB = b2;
stepConf.doWarmStart = false;
}
{
def.localAnchorA =
Length2{-2_m, +3_m};
def.localAnchorB =
Length2{+2_m, -3_m};
def.maxForce = 2_N;
def.maxTorque = 3_Nm;
const auto copy = def;
const auto amount =
Length2{1_m, 2_m};
EXPECT_EQ(def.bodyA, copy.bodyA);
EXPECT_EQ(def.bodyB, copy.bodyB);
EXPECT_EQ(def.collideConnected, copy.collideConnected);
EXPECT_EQ(def.localAnchorA, copy.localAnchorA);
EXPECT_EQ(def.localAnchorB, copy.localAnchorB);
EXPECT_EQ(def.maxForce, copy.maxForce);
EXPECT_EQ(def.maxTorque, copy.maxTorque);
EXPECT_EQ(def.linearImpulse, copy.linearImpulse);
EXPECT_EQ(def.angularImpulse, copy.angularImpulse);
EXPECT_EQ(def.rA, copy.rA);
EXPECT_EQ(def.rB, copy.rB);
EXPECT_EQ(def.linearMass, copy.linearMass);
EXPECT_EQ(def.angularMass, copy.angularMass);
}
{
}
{
EXPECT_THROW(
SetMotorSpeed(joint, 1_rpm), std::invalid_argument);
}
{
EXPECT_EQ(conf.angularMass, rotInertia);
}
{
{
EXPECT_TRUE(conf == conf);
}
{
EXPECT_TRUE(conf == conf);
}
{
EXPECT_TRUE(conf == conf);
}
{
EXPECT_TRUE(conf == conf);
}
}
{
{
EXPECT_FALSE(conf != conf);
}
}
{
EXPECT_STREQ(
GetName(GetTypeID<FrictionJointConf>()),
"d2::FrictionJointConf");
}