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::WeldJointConf
.
#include "UnitTests.hpp"
#include <PlayRho/Dynamics/Joints/WeldJointConf.hpp>
#include <PlayRho/Dynamics/Joints/Joint.hpp>
#include <PlayRho/Dynamics/BodyConf.hpp>
#include <PlayRho/Dynamics/World.hpp>
#include <PlayRho/Dynamics/WorldFixture.hpp>
#include <PlayRho/Dynamics/WorldMisc.hpp>
#include <PlayRho/Dynamics/WorldBody.hpp>
#include <PlayRho/Dynamics/WorldJoint.hpp>
#include <PlayRho/Dynamics/StepConf.hpp>
#include <PlayRho/Collision/Shapes/DiskShapeConf.hpp>
TEST(WeldJoint, Traits)
{
}
{
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.referenceAngle, 0_deg);
EXPECT_EQ(def.frequency, 0_Hz);
EXPECT_EQ(def.dampingRatio,
Real(0));
}
TEST(WeldJoint, Construction)
{
EXPECT_EQ(
GetType(joint), GetTypeID<WeldJointConf>());
}
{
const auto anchor =
Length2(2_m, 1_m);
ASSERT_EQ(
GetType(joint), GetTypeID<WeldJointConf>());
EXPECT_EQ(cdef.bodyA, bodyA);
EXPECT_EQ(cdef.bodyB, bodyB);
EXPECT_EQ(cdef.collideConnected, false);
EXPECT_EQ(cdef.localAnchorA, anchor);
EXPECT_EQ(cdef.localAnchorB, anchor);
}
TEST(WeldJoint, WithDynamicCircles)
{
const auto p1 =
Length2{-1_m, 0_m};
const auto p2 =
Length2{+1_m, 0_m};
const auto anchor =
Length2(2_m, 1_m);
}
TEST(WeldJoint, WithDynamicCircles2)
{
const auto p1 =
Length2{-1_m, 0_m};
const auto p2 =
Length2{+1_m, 0_m};
const auto anchor =
Length2(2_m, 1_m);
stepConf.doWarmStart = false;
}
TEST(WeldJoint, GetAnchorAandB)
{
const auto loc1 =
Length2{+1_m, -3_m};
const auto anchor =
Length2(2_m, 1_m);
jd.localAnchorA =
Length2(4_m, 5_m);
jd.localAnchorB =
Length2(6_m, 7_m);
EXPECT_EQ(
GetAnchorA(world, joint), loc1 + jd.localAnchorA);
EXPECT_EQ(
GetAnchorB(world, joint), loc2 + jd.localAnchorB);
}
{
const auto amount =
Length2{1_m, 2_m};
const auto copy = def;
EXPECT_EQ(def.
bodyA, copy.bodyA);
EXPECT_EQ(def.
bodyB, copy.bodyB);
EXPECT_EQ(def.
impulse, copy.impulse);
EXPECT_EQ(def.
gamma, copy.gamma);
EXPECT_EQ(def.
bias, copy.bias);
EXPECT_EQ(def.
rA, copy.rA);
EXPECT_EQ(def.
rB, copy.rB);
EXPECT_EQ(def.
mass, copy.mass);
}
{
{
EXPECT_TRUE(conf == conf);
}
{
EXPECT_TRUE(conf == conf);
}
{
EXPECT_TRUE(conf == conf);
}
}
{
{
EXPECT_FALSE(conf != conf);
}
}
{
EXPECT_STREQ(
GetName(GetTypeID<WeldJointConf>()),
"d2::WeldJointConf");
}
{
const auto frequencyA = 67_Hz;
const auto frequencyB = 2_Hz;
}
@ 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
Length2 rA
Relative A.
Definition: WeldJointConf.hpp:107
Name space for 2-dimensionally related PlayRho names.
Definition: AABB.cpp:34
BodyID bodyA
1st attached body.
Definition: JointConf.hpp:36
Weld joint definition.
Definition: WeldJointConf.hpp:51
constexpr auto InvalidJointID
Invalid joint ID value.
Definition: JointID.hpp:33
constexpr void SetFrequency(DistanceJointConf &object, NonNegative< Frequency > value) noexcept
Free function for setting the frequency value of the given configuration.
Definition: DistanceJointConf.hpp:205
const char * GetName(Manifold::Type type) noexcept
Gets a unique name for the given manifold type.
Definition: Manifold.cpp:788
constexpr auto & UseFrequency(NonNegative< Frequency > v) noexcept
Uses the given frequency value.
Definition: WeldJointConf.hpp:70
Length2 localAnchorA
The local anchor point relative to body A's origin.
Definition: WeldJointConf.hpp:84
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
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
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
AngularVelocity bias
Bias.
Definition: WeldJointConf.hpp:106
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
Angle GetReferenceAngle(const Joint &object)
Gets the reference angle of the joint if it has one.
Definition: Joint.cpp:215
constexpr BodyConf & UseLocation(Length2 l) noexcept
Use the given location.
Definition: BodyConf.hpp:172
constexpr auto Meter
Meter unit of Length.
Definition: Units.hpp:337
Angle referenceAngle
The body-B angle minus body-A angle in the reference state (radians).
Definition: WeldJointConf.hpp:90
Vec3 impulse
Impulse.
Definition: WeldJointConf.hpp:102
NonNegative< Frequency > frequency
Mass-spring-damper frequency.
Definition: WeldJointConf.hpp:95
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
Template for determining if the given types are addable.
Definition: Templates.hpp:189
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
Frequency GetFrequency(const Joint &object)
Gets the frequency of the joint if it has this property.
Definition: Joint.cpp:407
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
detail::IndexingNamedType< BodyCounter, struct BodyIdentifier > BodyID
Identifier for bodies.
Definition: BodyID.hpp:30
Length2 rB
Relative B.
Definition: WeldJointConf.hpp:108
InvRotInertia gamma
Gamma.
Definition: WeldJointConf.hpp:105
Real GetDampingRatio(const Joint &object)
Gets the given joint's damping ratio property if it has one.
Definition: Joint.cpp:389
WeldJointConf GetWeldJointConf(const Joint &joint)
Gets the definition data for the given joint.
Definition: WeldJointConf.cpp:101
constexpr auto SquareRadian
Square radian unit type.
Definition: Units.hpp:379
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
typename detail::IsIterableImpl< T > IsIterable
Determines whether the given type is an iterable type.
Definition: Templates.hpp:225
constexpr Momentum2 GetLinearReaction(const DistanceJointConf &object) noexcept
Gets the current linear reaction for the given configuration.
Definition: DistanceJointConf.hpp:163
PLAYRHO_QUANTITY(boost::units::si::moment_of_inertia) RotInertia
Rotational inertia quantity.
Definition: Units.hpp:274
Real dampingRatio
Damping ratio.
Definition: WeldJointConf.hpp:99
A joint-like constraint on one or more bodies.
Definition: Joint.hpp:144
BodyID bodyB
2nd attached body.
Definition: JointConf.hpp:39
Mat33 mass
Mass.
Definition: WeldJointConf.hpp:109
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
bool collideConnected
Collide connected.
Definition: JointConf.hpp:43
Length2 localAnchorB
The local anchor point relative to body B's origin.
Definition: WeldJointConf.hpp:87
Disk shape configuration.
Definition: DiskShapeConf.hpp:42