PlayRho
1.1.0
An Interactive Real-Time-Oriented C++ Physics Engine & Library
|
|
This is the googletest
based unit testing file for the interfaces to playrho::d2::RopeJointConf
.
#include "UnitTests.hpp"
#include <PlayRho/Dynamics/Joints/RopeJointConf.hpp>
#include <PlayRho/Dynamics/Joints/Joint.hpp>
#include <PlayRho/Dynamics/BodyConf.hpp>
#include <PlayRho/Dynamics/World.hpp>
#include <PlayRho/Dynamics/WorldJoint.hpp>
#include <PlayRho/Dynamics/WorldBody.hpp>
#include <PlayRho/Dynamics/WorldFixture.hpp>
#include <PlayRho/Dynamics/WorldMisc.hpp>
#include <PlayRho/Dynamics/StepConf.hpp>
#include <PlayRho/Collision/Shapes/DiskShapeConf.hpp>
#include <cstring>
{
case 4:
break;
case 8:
break;
case 16:
break;
default:
FAIL();
break;
}
}
{
EXPECT_EQ(def.collideConnected, false);
EXPECT_EQ(def.localAnchorA,
Length2(-1_m, 0_m));
EXPECT_EQ(def.localAnchorB,
Length2(+1_m, 0_m));
EXPECT_EQ(def.maxLength, 0_m);
}
{
EXPECT_EQ(
GetType(joint), GetTypeID<RopeJointConf>());
const auto conf = TypeCast<RopeJointConf>(
GetJoint(world,
id));
}
{
const auto localAnchorA =
Length2{-2_m, 0_m};
const auto localAnchorB =
Length2{+2_m, 0_m};
def.localAnchorA = localAnchorA;
def.localAnchorB = localAnchorB;
const auto joint =
Joint{def};
ASSERT_EQ(
GetType(joint), GetTypeID<RopeJointConf>());
const auto conf = TypeCast<RopeJointConf>(joint);
EXPECT_EQ(cdef.bodyA, bodyA);
EXPECT_EQ(cdef.bodyB, bodyB);
EXPECT_EQ(cdef.collideConnected, false);
EXPECT_EQ(cdef.localAnchorA, localAnchorA);
EXPECT_EQ(cdef.localAnchorB, localAnchorB);
EXPECT_EQ(cdef.maxLength, 0_m);
}
{
const auto p1 =
Length2{-1_m, 0_m};
const auto p2 =
Length2{+1_m, 0_m};
stepConf.doWarmStart = false;
stepConf.doWarmStart = true;
stepConf.linearSlop = 10_m;
}
{
EXPECT_TRUE(std::memcmp(&jd, ©,
sizeof(
RopeJointConf)) == 0);
}
{
{
EXPECT_TRUE(conf == conf);
}
{
EXPECT_TRUE(conf == conf);
}
{
EXPECT_TRUE(conf == conf);
}
}
{
{
EXPECT_FALSE(conf != conf);
}
}
{
EXPECT_STREQ(
GetName(GetTypeID<RopeJointConf>()),
"d2::RopeJointConf");
}
@ Static
Static body type.
BodyID CreateBody(World &world, const BodyConf &def)
Creates a rigid body with the given configuration.
Definition: WorldBody.cpp:58
constexpr BodyConf & UseType(BodyType t) noexcept
Use the given type.
Definition: BodyConf.hpp:166
Name space for 2-dimensionally related PlayRho names.
Definition: AABB.cpp:34
Length2 localAnchorB
The local anchor point relative to body B's origin.
Definition: RopeJointConf.hpp:82
constexpr auto InvalidJointID
Invalid joint ID value.
Definition: JointID.hpp:33
const char * GetName(Manifold::Type type) noexcept
Gets a unique name for the given manifold type.
Definition: Manifold.cpp:788
constexpr auto & GetX(T &value)
Gets the "X" element of the given value - i.e. the first element.
Definition: Math.hpp:66
Name space for all PlayRho related names.
Definition: AABB.cpp:33
const Joint & GetJoint(const WorldImpl &world, JointID id)
Gets the identified joint's value.
Definition: WorldImplJoint.cpp:57
Length2 GetLocalAnchorA(const Joint &object)
Get the anchor point on body-A in local coordinates.
Definition: Joint.cpp:62
Definition of an independent and simulatable "world".
Definition: World.hpp:129
Mass mass
Mass.
Definition: RopeJointConf.hpp:94
Length2 GetAnchorB(const World &world, JointID id)
Get the anchor point on body-B in world coordinates.
Definition: WorldJoint.cpp:216
constexpr bool ShiftOrigin(DistanceJointConf &, Length2) noexcept
Shifts the origin notion of the given configuration.
Definition: DistanceJointConf.hpp:177
RopeJointConf GetRopeJointConf(const Joint &joint) noexcept
Gets the definition data for the given joint.
Definition: RopeJointConf.cpp:46
BodyID GetBodyB(const Contact &contact) noexcept
Gets the body B ID of the given contact.
Definition: Contact.hpp:588
bool GetCollideConnected(const Joint &object) noexcept
Gets collide connected.
Definition: Joint.hpp:293
BodyID GetBodyA(const Contact &contact) noexcept
Gets the body A ID of the given contact.
Definition: Contact.hpp:581
LimitState GetLimitState(const Joint &object)
Definition: Joint.cpp:631
JointID CreateJoint(WorldImpl &world, const Joint &def)
Creates a new joint.
Definition: WorldImplJoint.cpp:47
Length2 GetLocalAnchorB(const Joint &object)
Get the anchor point on body-B in local coordinates.
Definition: Joint.cpp:96
Angle GetAngle(const UnitVec value)
Gets the angle of the given unit vector.
Definition: Math.hpp:718
bool doWarmStart
Do warm start.
Definition: StepConf.hpp:269
constexpr auto InvalidBodyID
Invalid body ID value.
Definition: BodyID.hpp:33
PLAYRHO_QUANTITY(boost::units::si::angular_momentum) AngularMomentum
Angular momentum quantity.
Definition: Units.hpp:304
Step configuration.
Definition: StepConf.hpp:42
constexpr AngularMomentum GetAngularReaction(const DistanceJointConf &) noexcept
Gets the current angular reaction for the given configuration.
Definition: DistanceJointConf.hpp:170
FixtureID CreateFixture(World &world, FixtureConf def, bool resetMassData)
Creates a fixture within the specified world.
Definition: WorldFixture.cpp:48
float Real
Real-number type.
Definition: Real.hpp:69
constexpr DiskShapeConf & UseRadius(NonNegative< Length > r) noexcept
Uses the given value as the radius.
Definition: DiskShapeConf.hpp:65
Configuration for a body.
Definition: BodyConf.hpp:50
constexpr Length2 GetLocation(const Transformation &value) noexcept
Gets the location information from the given transformation.
Definition: Transformation.hpp:69
Rope joint definition.
Definition: RopeJointConf.hpp:57
detail::IndexingNamedType< BodyCounter, struct BodyIdentifier > BodyID
Identifier for bodies.
Definition: BodyID.hpp:30
Vector.
Definition: Vector.hpp:49
Length2 GetAnchorA(const World &world, JointID id)
Get the anchor point on body-A in world coordinates.
Definition: WorldJoint.cpp:208
TypeID GetType(const Shape &shape) noexcept
Gets the type info of the use of the given shape.
Definition: Shape.hpp:329
constexpr Momentum2 GetLinearReaction(const DistanceJointConf &object) noexcept
Gets the current linear reaction for the given configuration.
Definition: DistanceJointConf.hpp:163
Length2 localAnchorA
The local anchor point relative to body A's origin.
Definition: RopeJointConf.hpp:79
A joint-like constraint on one or more bodies.
Definition: Joint.hpp:144
Length maxLength
The maximum length of the rope.
Definition: RopeJointConf.hpp:85
Shape.
Definition: Shape.hpp:183
constexpr auto & GetY(T &value)
Gets the "Y" element of the given value - i.e. the second element.
Definition: Math.hpp:73
Vector2< Length > Length2
2-element vector of Length quantities.
Definition: Vector2.hpp:43
StepStats Step(WorldImpl &world, const StepConf &conf)
Steps the given world the specified amount.
Definition: WorldImplMisc.cpp:85
constexpr auto GetMaxLength(const RopeJointConf &object) noexcept
Free function for getting the maximum length value of the given configuration.
Definition: RopeJointConf.hpp:165
Disk shape configuration.
Definition: DiskShapeConf.hpp:42