-
-
Notifications
You must be signed in to change notification settings - Fork 208
Closed
Labels
A-DynamicsRelates to rigid body dynamics: motion, mass, constraint solving, joints, CCD, and so onRelates to rigid body dynamics: motion, mass, constraint solving, joints, CCD, and so onC-BugSomething isn't workingSomething isn't working
Description
This is somewhat related to #200 , but that was specific to XPBD.
I've tried to make the same thing happen in Avian2d, but am failing to get an infinite bounce no matter what. The balls bounce decays rather quickly.
I did try without parallel and without simd and got the same results. I was unable to try with f64 due to build errors that I haven't had time to look into.
It also happens in release mode and debug mode.
My Cargo.toml:
[package]
name = "game"
version = "0.1.0"
edition = "2021"
[dependencies]
bevy = { version = "0.15.0", features = ["dynamic_linking"] }
leafwing-input-manager = "0.15.1"
leafwing_abilities = "0.9.0"
avian2d = { git = "https://github.com/Jondolf/avian", branch = "main", features = ["2d", "parallel", "simd"]}
bevy_prototype_lyon = "0.13.0"
# Enable a small amount of optimization in the dev profile.
[profile.dev]
opt-level = 1
# Enable a large amount of optimization in the dev profile for dependencies.
[profile.dev.package."*"]
opt-level = 3
My code:
use bevy::{color::palettes::css::*, prelude::*};
use bevy_prototype_lyon::prelude::*;
use avian2d::prelude::*;
fn main() {
App::new()
.insert_resource(ClearColor(Color::srgb(0., 0., 0.)))
.insert_resource(Gravity(Vec2::NEG_Y * 98.1))
.insert_resource(Time::<Fixed>::from_hz(120.0))
.add_plugins((DefaultPlugins, ShapePlugin, PhysicsPlugins::default()))
.add_systems(Startup, spawn)
.run();
}
fn spawn(mut commands: Commands) {
//camera
commands.spawn((Camera2d, Msaa::Sample4));
//shapes
let circle = shapes::Circle {
radius: 10.0,
..Default::default()
};
let rect = shapes::Rectangle {
extents: [50.0, 5.0].into(),
origin: RectangleOrigin::Center,
..Default::default()
};
//ball
commands.spawn((
Collider::circle(10.0),
Friction::ZERO.with_combine_rule(CoefficientCombine::Min),
Mass(1.0),
AngularVelocity(0.0),
LinearVelocity([0.0, 0.0].into()),
ColliderDensity(0.0),
AngularDamping(0.0),
LinearDamping(0.0),
SweptCcd::default(),
RigidBody::Dynamic,
Restitution::PERFECTLY_ELASTIC.with_combine_rule(CoefficientCombine::Max),
ShapeBundle {
path: GeometryBuilder::build_as(&circle),
..default()
},
Fill::color(GREEN),
));
//start indicator
commands.spawn((
ShapeBundle {
path: GeometryBuilder::build_as(&rect),
transform: Transform::from_xyz(0.0, 15.0, 0.0),
..default()
},
Fill::color(RED),
));
//floor
commands.spawn((
RigidBody::Static,
Collider::rectangle(50.0, 5.0),
ShapeBundle {
path: GeometryBuilder::build_as(&rect),
transform: Transform::from_xyz(0.0, -100.0, 0.0),
..default()
},
Fill::color(BLUE),
Friction::ZERO.with_combine_rule(CoefficientCombine::Min),
Restitution::PERFECTLY_ELASTIC.with_combine_rule(CoefficientCombine::Max),
));
}Metadata
Metadata
Assignees
Labels
A-DynamicsRelates to rigid body dynamics: motion, mass, constraint solving, joints, CCD, and so onRelates to rigid body dynamics: motion, mass, constraint solving, joints, CCD, and so onC-BugSomething isn't workingSomething isn't working