// SPDX-FileCopyrightText: 2021 Jorrit Rouwe // SPDX-License-Identifier: MIT #include #include #include #include #include #include JPH_IMPLEMENT_RTTI_VIRTUAL(OffsetCenterOfMassShapeTest) { JPH_ADD_BASE_CLASS(OffsetCenterOfMassShapeTest, Test) } void OffsetCenterOfMassShapeTest::Initialize() { // Floor Body &floor = CreateFloor(); floor.SetFriction(1.0f); Ref sphere = new SphereShapeSettings(1.0f); Ref left = new OffsetCenterOfMassShapeSettings(Vec3(-1, 0, 0), sphere); Ref right = new OffsetCenterOfMassShapeSettings(Vec3(1, 0, 0), sphere); // Sphere with center of mass moved to the left side Body &body_left = *mBodyInterface->CreateBody(BodyCreationSettings(left, Vec3(-5, 5, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING)); body_left.SetFriction(1.0f); mBodyInterface->AddBody(body_left.GetID(), EActivation::Activate); // Sphere with center of mass centered Body &body_center = *mBodyInterface->CreateBody(BodyCreationSettings(sphere, Vec3(0, 5, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING)); body_center.SetFriction(1.0f); mBodyInterface->AddBody(body_center.GetID(), EActivation::Activate); // Sphere with center of mass moved to the right side Body &body_right = *mBodyInterface->CreateBody(BodyCreationSettings(right, Vec3(5, 5, 0), Quat::sIdentity(), EMotionType::Dynamic, Layers::MOVING)); body_right.SetFriction(1.0f); mBodyInterface->AddBody(body_right.GetID(), EActivation::Activate); }