From 40734883d8daa6b053cb1bf1f37e3ad22070ee39 Mon Sep 17 00:00:00 2001 From: Martin Felis Date: Fri, 9 Jul 2021 20:26:59 +0200 Subject: [PATCH] Adjusted simulation scene generation (boxes and spheres) --- src/simulator.cc | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/simulator.cc b/src/simulator.cc index a9a30e4..1c6e1e2 100644 --- a/src/simulator.cc +++ b/src/simulator.cc @@ -43,17 +43,31 @@ void simulator_init() { sWorld.mStaticShapes.push_back(sGroundShape); - double restitution = 0.8; + double restitution = 0.5; - int num_spheres = 7; - for (int i = 0; i < num_spheres; i++) { - SimBody sphere_body = CreateSphereBody( - 1., - 1., - restitution, - Vector3d::Random() * 5., - Vector3d::Zero()); - sWorld.mBodies.push_back(sphere_body); + int num_bodies = 10; + for (int i = 0; i < num_bodies; i++) { + SimBody body; + + bool create_sphere = i %2; + + if (!create_sphere) { + body = CreateBoxBody( + 1., + Vector3d(2., 1., 1.), + restitution, + Vector3d::Random() * 5., + Vector3d::Zero()); + } else { + body = CreateSphereBody( + 1., + 1., + restitution, + Vector3d::Random() * 5., + Vector3d::Zero()); + } + + sWorld.mBodies.push_back(body); } for (int i = 0; i < sWorld.mBodies.size(); i++) {