diff --git a/app/test_scenarios.cpp b/app/test_scenarios.cpp index 2329db8..9226fb3 100644 --- a/app/test_scenarios.cpp +++ b/app/test_scenarios.cpp @@ -13,15 +13,17 @@ std::vector chapters = {"Kinematics", "Laws of Motion", "Collision", "Rotation", "Fluids", "Thermal Properties"}; std::unordered_map> testmap; +std::vector funtests = {"Kinematics", "Laws of Motion", "Collision", "Rotation", "Fluids", "Thermal Properties"}; 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}; } @@ -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)); + } } + // world.addBody(Rigidbody(Vec3(0, , z), Vec3(), &g_small_sphere, 0.5f)); + } void spawn_many_boxes(PhysicsWorld &world) @@ -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), + &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), + 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) @@ -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; diff --git a/app/test_scenarios.hpp b/app/test_scenarios.hpp index c736e61..f4fb609 100644 --- a/app/test_scenarios.hpp +++ b/app/test_scenarios.hpp @@ -25,7 +25,13 @@ enum class TestCase NewtonThirdLaw, BoxToppleOnRamp, SphereToppleOnRamp, - CollisionCauseTopple + CollisionCauseTopple, + CircularMotionRope, + CircularMotionSpring, + PyramidStack, + ManyBoxes, + ManySpheres, + RandomScatter }; extern std::vector chapters; diff --git a/renderer/window.cpp b/renderer/window.cpp index 324202a..2817f2f 100644 --- a/renderer/window.cpp +++ b/renderer/window.cpp @@ -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[] = { @@ -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[] = { @@ -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." };