Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 95 additions & 5 deletions app/test_scenarios.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@

std::vector<std::string> chapters = {"Kinematics", "Laws of Motion", "Collision", "Rotation", "Fluids", "Thermal Properties"};
std::unordered_map<std::string, std::vector<TestCase>> testmap;
std::vector<std::string> funtests = {"Kinematics", "Laws of Motion", "Collision", "Rotation", "Fluids", "Thermal Properties"};
Comment thread
Just-Here-TO-Code marked this conversation as resolved.

void InitializeTestMap()
{
testmap["Kinematics"] = {TestCase::ProjectMotion, TestCase::RelativeVelocity};
testmap["Laws of Motion"] = {TestCase::NewtonThirdLaw};
testmap["Kinematics"] = {TestCase::ProjectMotion, TestCase::RelativeVelocity, TestCase::InclinedPlane};
testmap["Laws of Motion"] = {TestCase::NewtonThirdLaw, TestCase::MomentumTransfer};
testmap["Collision"] = {TestCase::PerfectElasticCollision, TestCase::PerfectInelasticCollision, TestCase::Collision};
testmap["Rotation"] = {TestCase::BoxToppleOnRamp, TestCase::SphereToppleOnRamp, TestCase::CollisionCauseTopple};
testmap["Rotation"] = {TestCase::CenterOfMassTopple, TestCase::ConstraintPlayground, TestCase::AngularImpulse, TestCase::AngularStack, TestCase::CornerCollision, TestCase::RollingFriction, TestCase::BoxToppleOnRamp, TestCase::SphereToppleOnRamp, TestCase::CollisionCauseTopple, TestCase::CircularMotionRope, TestCase::CircularMotionSpring};
testmap["Fluids"] = {TestCase::BuoyancyTest};
testmap["Thermal Properties"] = {};
testmap["Thermal Properties"] = {TestCase::HeatTransferDemo};
testmap["Stress Tests"] = {TestCase::PyramidStack, TestCase::ManyBoxes, TestCase::ManySpheres, TestCase::RandomScatter};
Comment thread
Just-Here-TO-Code marked this conversation as resolved.
}


Expand Down Expand Up @@ -263,8 +265,14 @@ namespace
float x = (i % 10) - 4.5f;
float y = 3.0f + (i / 10) * 0.9f;
float z = ((i / 5) % 2) * 0.6f;
world.addBody(Rigidbody(Vec3(x, y, z), Vec3(), &g_small_sphere, 0.5f));
if(i>=50)
world.addBody(Rigidbody(Vec3(x, y, z-0.8f), Vec3(), &g_small_sphere, 0.5f));
else {
world.addBody(Rigidbody(Vec3(x, y, z ), Vec3(), &g_small_sphere, 0.5f));
Comment thread
Just-Here-TO-Code marked this conversation as resolved.
}
}
// world.addBody(Rigidbody(Vec3(0, , z), Vec3(), &g_small_sphere, 0.5f));
Comment thread
Just-Here-TO-Code marked this conversation as resolved.

}

void spawn_many_boxes(PhysicsWorld &world)
Expand Down Expand Up @@ -718,6 +726,76 @@ namespace
return Camera().setPosition(glm::vec3(0.0f, 4.8f, 22.0f));
}

Camera spawn_circular_motion_rope(PhysicsWorld &world)
{
Rigidbody fixed_box(Vec3(0.0f, 0.0f, 0.0f), Vec3(), &g_small_box, 0.0f);
fixed_box.friction = 0.5f;
auto box_id = world.addBody(fixed_box);
const float rope_length = 3.0f;
const float orbital_speed = 50.0f;
Rigidbody orbiting_sphere(
Vec3(rope_length, 2.0f, 0.0f),
Vec3(0.0f, 0.0f, orbital_speed),
Comment thread
Just-Here-TO-Code marked this conversation as resolved.
&g_small_sphere,
1.0f
);
orbiting_sphere.friction = 0.1f;
orbiting_sphere.restitution = 0.3f;
auto sphere_id = world.addBody(orbiting_sphere);
world.addDistanceConstraints(box_id, sphere_id, rope_length, DistanceConstraint::ROPE, 0.0f, 0.0f);
return Camera().setPosition(glm::vec3(0.0f, 15.0f, 0.0f))
.setYaw(0.0f)
.setPitch(-90.0f);
}

Camera spawn_circular_motion_spring(PhysicsWorld &world)
{
Rigidbody fixed_box(Vec3(0.0f, 0.0f, 0.0f), Vec3(), &g_small_box, 0.0f);
fixed_box.friction = 0.5f;
auto box_id = world.addBody(fixed_box);
const float spring_length = 3.0f;
const float spring_constant = 2.0f;
const float damping = 0.5f;
const float orbital_speed = 50.0f;
Rigidbody orbiting_sphere(
Vec3(spring_length, 2.0f, 0.0f),
Comment thread
Just-Here-TO-Code marked this conversation as resolved.
Vec3(0.0f, 0.0f, orbital_speed),
&g_small_sphere,
1.0f
);
orbiting_sphere.friction = 0.1f;
orbiting_sphere.restitution = 0.3f;
auto sphere_id = world.addBody(orbiting_sphere);
world.addDistanceConstraints(box_id, sphere_id, spring_length, DistanceConstraint::SPRING, spring_constant, damping);
return Camera().setPosition(glm::vec3(0.0f, 15.0f, 0.0f))
.setYaw(0.0f)
.setPitch(-90.0f);
}

Camera spawn_pyramid_stack_scenario(PhysicsWorld &world)
{
spawn_pyramid_stack(world);
return Camera().setPosition(glm::vec3(0.0f, 5.0f, 25.0f));
}

Camera spawn_many_boxes_scenario(PhysicsWorld &world)
{
spawn_many_boxes(world);
return Camera().setPosition(glm::vec3(0.0f, 5.0f, 25.0f));
}

Camera spawn_many_spheres_scenario(PhysicsWorld &world)
{
spawn_many_spheres(world);
return Camera().setPosition(glm::vec3(0.0f, 5.0f, 25.0f));
}

Camera spawn_random_scatter_scenario(PhysicsWorld &world)
{
spawn_random_scatter(world);
return Camera().setPosition(glm::vec3(0.0f, 5.0f, 30.0f));
}

}

Camera LoadSingleTestScenario(PhysicsWorld &world, TestCase test_case)
Expand Down Expand Up @@ -782,6 +860,18 @@ Camera LoadSingleTestScenario(PhysicsWorld &world, TestCase test_case)
return Camera();
case TestCase::HeatTransferDemo:
return spawn_heat_transfer_demo(world);
case TestCase::CircularMotionRope:
return spawn_circular_motion_rope(world);
case TestCase::CircularMotionSpring:
return spawn_circular_motion_spring(world);
case TestCase::PyramidStack:
return spawn_pyramid_stack_scenario(world);
case TestCase::ManyBoxes:
return spawn_many_boxes_scenario(world);
case TestCase::ManySpheres:
return spawn_many_spheres_scenario(world);
case TestCase::RandomScatter:
return spawn_random_scatter_scenario(world);
default:
return spawn_projectile_demo(world);
break;
Expand Down
8 changes: 7 additions & 1 deletion app/test_scenarios.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ enum class TestCase
NewtonThirdLaw,
BoxToppleOnRamp,
SphereToppleOnRamp,
CollisionCauseTopple
CollisionCauseTopple,
CircularMotionRope,
CircularMotionSpring,
PyramidStack,
ManyBoxes,
ManySpheres,
RandomScatter
};

extern std::vector<std::string> chapters;
Expand Down
25 changes: 21 additions & 4 deletions renderer/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ namespace
TestCase::NewtonThirdLaw,
TestCase::BoxToppleOnRamp,
TestCase::SphereToppleOnRamp,
TestCase::CollisionCauseTopple
TestCase::CollisionCauseTopple,
TestCase::CircularMotionRope,
TestCase::CircularMotionSpring,
TestCase::PyramidStack,
TestCase::ManyBoxes,
TestCase::ManySpheres,
TestCase::RandomScatter
};

constexpr const char *kTestCaseNames[] = {
Expand All @@ -66,7 +72,13 @@ namespace
"Newton's Third Law",
"Box Topple on Ramp",
"Sphere Topple on Ramp",
"Collision Cause Topple"
"Collision Cause Topple",
"Circular Motion with Rope",
"Circular Motion with Spring",
"Pyramid Stack",
"Many Boxes",
"Many Spheres",
"Random Scatter"
};

constexpr const char *kTestCaseDescriptions[] = {
Expand All @@ -87,8 +99,13 @@ namespace
"",
"",
"",
"",
""
"","",
"A fixed box at the origin is connected to a sphere via a rope constraint, demonstrating circular orbital motion with the box as the center axis.",
"A fixed box at the origin is connected to a sphere via a spring constraint, allowing elastic oscillations during circular motion.",
"A large pyramid of boxes falling in layers to demonstrate stacking and gravity effects.",
"Eighty boxes spawned in a scattered pattern for stress testing physics solver performance.",
"Sixty spheres spawned in a scattered pattern to test sphere-sphere collisions and performance.",
"One hundred randomly scattered mixed objects (boxes and spheres) for comprehensive stress testing."
};


Expand Down
Loading