Compare commits

...

4 Commits

Author SHA1 Message Date
Martin Felis 0081cff8bc Added slides of Gregorius' talk "Robust Contact Creation for Physics Simulation" 2021-05-16 15:37:13 +02:00
Martin Felis 6193af5387 Merge branch 'master' of ssh://i13s.de/martin/rbdlsim 2021-02-07 14:45:34 +01:00
Martin Felis 5f4675d9ef Fixed build for runsim 2020-11-25 17:05:29 +01:00
Martin Felis 10b59578e1 Properly separate sliders for each body 2020-11-25 17:05:13 +01:00
3 changed files with 14 additions and 26 deletions

View File

@ -41,7 +41,7 @@ target_include_directories(
target_link_libraries(runsim ${PROJECT_NAME})
target_sources(runsim PRIVATE src/main.cc)
target_sources(runsim PRIVATE src/main.cc src/utils.cc)
# Visualization
add_executable(vissim)

Binary file not shown.

View File

@ -43,31 +43,17 @@ void simulator_init() {
sWorld.mStaticShapes.push_back(sGroundShape);
double restitution = 0.3;
double restitution = 0.8;
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);
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);
}
for (int i = 0; i < sWorld.mBodies.size(); i++) {
@ -164,6 +150,7 @@ void simulator_update(double dt) {
ImGui::Text("Bodies");
for (int i = 0; i < sWorld.mBodies.size(); i++) {
ImGui::PushID(i);
SimBody& body = sWorld.mBodies[i];
Vector3f body_pos = body.q.block(0, 0, 3, 1);
ImGui::DragFloat3("Pos", body_pos.data(), 0.01f, -5.0f, 5.0f);
@ -176,6 +163,7 @@ void simulator_update(double dt) {
Vector4f body_rot = body.mModel.GetQuaternion(2, body.q);
ImGui::DragFloat4("Rot", body_rot.data(), 0.01f, -20.0f, 20.0f);
ImGui::PopID();
body.updateCollisionShapes();
}
@ -272,4 +260,4 @@ void simulator_draw(srcmdbuf* cmdbuf) {
srcmdbuf_add(cmdbuf, &rcmd);
}
}
}
}