chore: rework vertical stacks demo

This commit is contained in:
Sébastien Crozet
2024-04-14 18:59:08 +02:00
committed by Sébastien Crozet
parent 2f1ce1887f
commit de5e871cd1
3 changed files with 28 additions and 17 deletions

View File

@@ -58,7 +58,7 @@ pub fn main() {
("Convex polygons", convex_polygons2::init_world),
("Heightfield", heightfield2::init_world),
("Pyramid", pyramid2::init_world),
("Verticals tacks", vertical_stacks2::init_world),
("Verticals stacks", vertical_stacks2::init_world),
("(Stress test) joint ball", joint_ball2::init_world),
("(Stress test) joint fixed", joint_fixed2::init_world),
(

View File

@@ -10,10 +10,14 @@ pub fn init_world(testbed: &mut Testbed) {
let impulse_joints = ImpulseJointSet::new();
let multibody_joints = MultibodyJointSet::new();
let num = 40;
let rad = 50.0 / 2.0; // 0.5;
/*
* Ground
*/
let ground_size = 100.0;
let ground_size = num as f32 * rad * 10.0;
let ground_thickness = 1.0;
let rigid_body = RigidBodyBuilder::fixed();
@@ -24,18 +28,22 @@ pub fn init_world(testbed: &mut Testbed) {
/*
* Create the cubes
*/
let num = 30;
let rad = 0.5;
let shift = rad * 2.0;
let centery = shift / 2.0 + ground_thickness;
let shiftx_centerx = [
(rad * 2.0, -(num as f32) * rad * 2.0 * 1.5),
(rad * 2.0 + rad, num as f32 * rad * 2.0 * 1.5),
];
for (shiftx, centerx) in shiftx_centerx {
let shifty = rad * 2.0;
let centery = shifty / 2.0 + ground_thickness;
for i in 0..num {
for j in 0usize..1 + i * 2 {
let fj = j as f32;
let fi = i as f32;
let x = (fj - fi) * shift; // (shift + rad / 2.0);
let y = (num as f32 - fi - 1.0) * shift + centery;
let x = (fj - fi) * shiftx + centerx;
let y = (num as f32 - fi - 1.0) * shifty + centery;
// Build the rigid body.
let rigid_body = RigidBodyBuilder::dynamic().translation(vector![x, y]);
@@ -44,6 +52,7 @@ pub fn init_world(testbed: &mut Testbed) {
colliders.insert_with_parent(collider, handle, &mut bodies);
}
}
}
/*
* Set up the testbed.

View File

@@ -1,6 +1,8 @@
use crate::math::Real;
use std::num::NonZeroUsize;
// TODO: enabling the block solver in 3d introduces a lot of jitters in
// the 3D domino demo. So for now we dont enable it in 3D.
pub(crate) static BLOCK_SOLVER_ENABLED: bool = cfg!(feature = "dim2");
pub(crate) static DISABLE_FRICTION_LIMIT_REAPPLY: bool = false;