#include "gtest/gtest.h"
TEST(Body, DefaultConstruction)
{
}
TEST(Body, StaticTypeConstruction)
{
EXPECT_FALSE(body.IsDestroyed());
EXPECT_TRUE(body.IsImpenetrable());
EXPECT_FALSE(body.IsSpeedable());
EXPECT_FALSE(body.IsAccelerable());
EXPECT_TRUE(body.IsSleepingAllowed());
EXPECT_FALSE(body.IsAwake());
EXPECT_FALSE(body.IsFixedRotation());
EXPECT_FALSE(body.IsMassDataDirty());
EXPECT_TRUE(body.IsEnabled());
}
TEST(Body, KinematicTypeConstruction)
{
EXPECT_FALSE(body.IsDestroyed());
EXPECT_TRUE(body.IsImpenetrable());
EXPECT_TRUE(body.IsSpeedable());
EXPECT_FALSE(body.IsAccelerable());
EXPECT_TRUE(body.IsSleepingAllowed());
EXPECT_TRUE(body.IsAwake());
EXPECT_FALSE(body.IsFixedRotation());
EXPECT_FALSE(body.IsMassDataDirty());
EXPECT_TRUE(body.IsEnabled());
}
TEST(Body, DynamicTypeConstruction)
{
EXPECT_FALSE(body.IsDestroyed());
EXPECT_FALSE(body.IsImpenetrable());
EXPECT_TRUE(body.IsSpeedable());
EXPECT_TRUE(body.IsAccelerable());
EXPECT_TRUE(body.IsSleepingAllowed());
EXPECT_TRUE(body.IsAwake());
EXPECT_FALSE(body.IsFixedRotation());
EXPECT_FALSE(body.IsMassDataDirty());
EXPECT_TRUE(body.IsEnabled());
}
TEST(Body, UseFixedRotationConstruction)
{
}
TEST(Body, UseAwakeConstruction)
{
}
TEST(Body, UseAllowSleepConstruction)
{
}
TEST(Body, ShapeOnConstruction)
{
EXPECT_EQ(Body(BodyConf{}.Use(shapeId)).
GetShapes()[0], shapeId);
}
TEST(Body, LinearDampingOnConstruction)
{
}
TEST(Body, AngularDampingOnConstruction)
{
}
TEST(Body, InvMassOnConstruction)
{
}
TEST(Body, TransformationOnConstruction)
{
{
const auto conf = BodyConf{}.UseLocation(
Length2{10_m, 12_m}).UseAngle(90_deg);
}
{
const auto conf = BodyConf{}.UseLocation(
Length2{4_m, -3_m}).UseAngle(-32_deg);
}
}
TEST(Body, VelocityOnConstruction)
{
auto body = Body{};
EXPECT_EQ(
EXPECT_EQ(
}
TEST(Body, AccelerationOnConstruction)
{
auto body = Body{};
EXPECT_EQ(Body(BodyConf{}
body.GetLinearAcceleration());
EXPECT_EQ(Body(BodyConf{}
body.GetAngularAcceleration());
}
TEST(Body, SetUnsetDestroyed)
{
auto body = Body();
ASSERT_FALSE(body.IsDestroyed());
body.SetDestroyed();
EXPECT_TRUE(body.IsDestroyed());
body.UnsetDestroyed();
EXPECT_FALSE(body.IsDestroyed());
}
TEST(Body, SetUnsetDestroyedFreeFuncs)
{
auto body = Body();
}
TEST(Body, EqualsOperator)
{
EXPECT_TRUE(Body() == Body());
{
auto body = Body{};
EXPECT_TRUE(body == Body());
}
{
auto bodyA = Body();
auto bodyB = Body();
bodyB.SetDestroyed();
EXPECT_FALSE(bodyA == bodyB);
bodyA.SetDestroyed();
EXPECT_TRUE(bodyA == bodyB);
bodyB.UnsetDestroyed();
EXPECT_FALSE(bodyA == bodyB);
bodyA.UnsetDestroyed();
EXPECT_TRUE(bodyA == bodyB);
}
{
auto body1 = Body{};
auto body2 = Body{};
EXPECT_TRUE(body1 == body2);
}
{
auto body = Body{};
EXPECT_FALSE(body == Body());
}
{
auto body = Body{};
body.SetSweep(Sweep{Position{
Length2{}, 2_deg}});
EXPECT_FALSE(body == Body());
}
{
auto body = Body{};
EXPECT_FALSE(body == Body());
}
{
auto body = Body{};
EXPECT_FALSE(body == Body());
}
{
auto body1 = Body{};
auto body2 = Body{};
EXPECT_FALSE(body1 == body2);
}
{
auto body = Body{};
EXPECT_FALSE(body == Body());
}
{
auto body = Body{};
body.SetInvMassData(body.GetInvMass(), (
Real(2) *
SquareRadian) / (2_m2 * 1.2_kg));
EXPECT_FALSE(body == Body());
}
{
auto body = Body{};
EXPECT_FALSE(body == Body());
}
{
auto body = Body{};
EXPECT_FALSE(body == Body());
}
{
auto body1 = Body{};
body1.SetUnderActiveTime(2_s);
auto body2 = Body{};
EXPECT_FALSE(body1 == body2);
}
{
auto bodyA = Body{};
auto bodyB = Body{};
EXPECT_FALSE(bodyA == bodyB);
EXPECT_TRUE(bodyA == bodyB);
}
{
auto bodyA = Body{};
auto bodyB = Body{};
bodyA.SetSleepingAllowed(false);
EXPECT_FALSE(bodyA == bodyB);
}
}
TEST(Body, NotEqualsOperator)
{
EXPECT_FALSE(Body() != Body());
{
auto body = Body{};
EXPECT_FALSE(body != Body());
}
{
auto body1 = Body{};
auto body2 = Body{};
EXPECT_FALSE(body1 != body2);
}
{
auto body = Body{};
EXPECT_TRUE(body != Body());
}
{
auto body = Body{};
body.SetSweep(Sweep{Position{
Length2{}, 2_deg}});
EXPECT_TRUE(body != Body());
}
{
auto body = Body{};
EXPECT_TRUE(body != Body());
}
{
auto body = Body{};
EXPECT_TRUE(body != Body());
}
{
auto body1 = Body{};
auto body2 = Body{};
EXPECT_TRUE(body1 != body2);
}
{
auto body = Body{};
EXPECT_TRUE(body != Body());
}
{
auto body = Body{};
body.SetInvMassData(body.GetInvMass(), (
Real(2) *
SquareRadian) / (2_m2 * 1.2_kg));
EXPECT_TRUE(body != Body());
}
{
auto body = Body{};
EXPECT_TRUE(body != Body());
}
{
auto body = Body{};
EXPECT_TRUE(body != Body());
}
{
auto body1 = Body{};
body1.SetUnderActiveTime(2_s);
auto body2 = Body{};
EXPECT_TRUE(body1 != body2);
}
}
Declarations of the Body class, and functions associated with it.
static constexpr auto DefaultLinearDamping
Default linear damping.
Definition: Body.hpp:84
static constexpr auto DefaultAngularDamping
Default angular damping.
Definition: Body.hpp:87
constexpr auto RadianPerSquareSecond
Radian per square second unit of angular acceleration.
Definition: Units.hpp:478
constexpr auto SquareRadian
Square radian unit type.
Definition: Units.hpp:463
constexpr void SetDestroyed(Body &body) noexcept
Sets the destroyed property of the given body.
Definition: Body.hpp:770
std::size_t size(const DynamicTree &tree) noexcept
Gets the "size" of the given tree.
Definition: DynamicTree.hpp:715
bool IsAwake(const Body &body) noexcept
Gets the awake/asleep state of this body.
Definition: Body.hpp:884
Velocity GetVelocity(const Body &body) noexcept
Gets the velocity.
Definition: Body.hpp:1292
NonNegative< Frequency > GetLinearDamping(const Body &body) noexcept
Gets the linear damping of the body.
Definition: Body.hpp:1122
bool IsSleepingAllowed(const Body &body) noexcept
Gets whether or not this body allowed to sleep.
Definition: Body.hpp:833
Transformation GetTransform1(const Sweep &sweep) noexcept
Gets the transform at "time" one.
Definition: Math.hpp:271
void SetAngularDamping(Body &body, NonNegative< Frequency > value) noexcept
Sets the angular damping of the body.
Definition: Body.hpp:1146
BodyType GetType(const Body &body) noexcept
Gets the type of this body.
Definition: Body.hpp:748
NonNegative< Frequency > GetAngularDamping(const Body &body) noexcept
Gets the angular damping of the body.
Definition: Body.hpp:1138
const Transformation & GetTransformation(const Body &body) noexcept
Gets the body's transformation.
Definition: Body.hpp:1014
NonNegativeFF< InvMass > GetInvMass(const Body &body) noexcept
Gets the inverse total mass of the body.
Definition: Body.hpp:1102
bool IsSpeedable(const Body &body) noexcept
Is "speedable".
Definition: Body.hpp:786
bool IsFixedRotation(const Body &body) noexcept
Does this body have fixed rotation?
Definition: Body.hpp:1073
AngularAcceleration GetAngularAcceleration(const Body &body) noexcept
Gets this body's angular acceleration.
Definition: Body.hpp:1183
void SetLinearDamping(Body &body, NonNegative< Frequency > value) noexcept
Sets the linear damping of the body.
Definition: Body.hpp:1130
bool IsEnabled(const Body &body) noexcept
Gets the enabled/disabled state of the body.
Definition: Body.hpp:850
auto IsDestroyed(const AabbTreeWorld &world, BodyID id) -> bool
Gets whether the given identifier is to a body that's been destroyed.
Definition: AabbTreeWorld.hpp:341
constexpr void UnsetDestroyed(Body &body) noexcept
Unsets the destroyed property of the given body.
Definition: Body.hpp:777
LinearAcceleration2 GetLinearAcceleration(const Body &body) noexcept
Gets this body's linear acceleration.
Definition: Body.hpp:1175
void SetMass(Body &body, Mass mass)
Sets the mass of the given body.
Definition: Body.hpp:1225
void SetTransformation(Body &body, const Transformation &value) noexcept
Sets the body's transformation.
Definition: Body.cpp:270
const std::vector< ShapeID > & GetShapes(const AabbTreeWorld &world, BodyID id)
Disassociates all of the associated shape from the validly identified body.
Definition: AabbTreeWorld.cpp:2913
Definition: ArrayList.hpp:43
float Real
Real-number type.
Definition: Real.hpp:69
Vector2< LinearVelocity > LinearVelocity2
2-element vector of linear velocity (LinearVelocity) quantities.
Definition: Vector2.hpp:58
Vector2< LinearAcceleration > LinearAcceleration2
2-element vector of linear acceleration (LinearAcceleration) quantities.
Definition: Vector2.hpp:62
detail::IndexingNamedType< ShapeCounter, struct ShapeIdentifier > ShapeID
Shape identifier.
Definition: ShapeID.hpp:44
Vector2< Length > Length2
2-element vector of Length quantities.
Definition: Vector2.hpp:51
constexpr bool empty(IndexPair3 pairs) noexcept
Checks whether the given collection of index pairs is empty.
Definition: IndexPair.hpp:75
AngularVelocity angular
Angular velocity.
Definition: Velocity.hpp:47
LinearVelocity2 linear
Linear velocity.
Definition: Velocity.hpp:46