Skip to content

Commit

Permalink
Fix lighting and other weirdness in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Jondolf committed Feb 20, 2024
1 parent 4db473f commit 860c989
Show file tree
Hide file tree
Showing 18 changed files with 28 additions and 24 deletions.
1 change: 0 additions & 1 deletion crates/bevy_xpbd_2d/examples/distance_joint_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ fn setup(mut commands: Commands) {
.with_rest_length(100.0)
.with_linear_velocity_damping(0.1)
.with_angular_velocity_damping(1.0)
.with_limits(140.0, 150.0)
.with_compliance(0.00000001),
);
}
4 changes: 2 additions & 2 deletions crates/bevy_xpbd_2d/examples/many_shapes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn setup(

let circle = Circle::new(7.5);
let rectangle = Rectangle::new(15.0, 15.0);
let capsule = Capsule2d::new(20.0, 7.5);
let capsule = Capsule2d::new(7.5, 20.0);
let triangle = Triangle2d::new(
Vec2::new(0.0, 10.0),
Vec2::new(-10.0, -10.0),
Expand Down Expand Up @@ -115,7 +115,7 @@ fn setup(
MaterialMesh2dBundle {
mesh,
material,
transform: Transform::from_xyz(x as f32 * 20.0, y as f32 * 20.0, 0.0),
transform: Transform::from_xyz(x as f32 * 25.0, y as f32 * 25.0, 0.0),
..default()
},
collider,
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_xpbd_2d/examples/move_marbles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ fn setup(
let marble_material = materials.add(Color::rgb(0.2, 0.7, 0.9));

// Spawn stacks of marbles
for x in -20..20 {
for y in -20..20 {
for x in -16..16 {
for y in -16..16 {
commands.spawn((
MaterialMesh2dBundle {
mesh: marble_mesh.clone().into(),
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_xpbd_2d/examples/ray_caster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ fn setup(
));
}

// Note: The `PhysicsDebugPlugin` can also render rays, hit points, and normals.
// This system is primarily for demonstration purposes.
fn render_rays(mut rays: Query<(&mut RayCaster, &mut RayHits)>, mut gizmos: Gizmos) {
for (ray, hits) in &mut rays {
// Convert to Vec3 for lines
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_xpbd_2d/examples/sensor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn setup(
MaterialMesh2dBundle {
mesh: meshes.add(Capsule2d::new(12.5, 20.0)).into(),
material: materials.add(Color::rgb(0.2, 0.7, 0.9)),
transform: Transform::from_xyz(0.0, -100.0, 0.0),
transform: Transform::from_xyz(0.0, -100.0, 1.0),
..default()
},
Character,
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_xpbd_3d/examples/async_colliders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn setup(
// The model was made by RayMarch, licenced under CC0-1.0, and can be found here:
// /~https://github.com/RayMarch/ferris3d
scene: assets.load("ferris.glb#Scene0"),
transform: Transform::from_xyz(0.0, 2.0, 0.0).with_scale(Vec3::splat(2.0)),
transform: Transform::from_xyz(0.0, 1.0, 0.0).with_scale(Vec3::splat(2.0)),
..default()
},
// Create colliders using convex decomposition.
Expand All @@ -45,15 +45,15 @@ fn setup(
VHACDParameters::default(),
)))
// Make the arms heavier to make it easier to stand upright
.with_density_for_name("armL_mesh", 5.0)
.with_density_for_name("armR_mesh", 5.0),
.with_density_for_name("armL_mesh", 3.0)
.with_density_for_name("armR_mesh", 3.0),
RigidBody::Dynamic,
));

// Light
commands.spawn(PointLightBundle {
point_light: PointLight {
intensity: 500_000.0,
intensity: 1_000_000.0,
shadows_enabled: true,
..default()
},
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_xpbd_3d/examples/cast_ray_predicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ fn setup(
// Directional light
commands.spawn(DirectionalLightBundle {
directional_light: DirectionalLight {
illuminance: 20_000.0,
illuminance: 5000.0,
shadows_enabled: true,
..default()
},
Expand Down
6 changes: 5 additions & 1 deletion crates/bevy_xpbd_3d/examples/chain_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ fn setup(
let particle_count = 100;
let particle_radius = 0.06;
let particle_mesh = meshes.add(Sphere::new(particle_radius as f32).mesh().ico(5).unwrap());
let particle_material = materials.add(StandardMaterial::from(Color::rgb(0.2, 0.7, 0.9)));
let particle_material = materials.add(StandardMaterial {
base_color: Color::rgb(0.2, 0.7, 0.9),
unlit: true,
..default()
});

// Spawn kinematic particle that can follow the mouse
let mut previous_particle = commands
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_xpbd_3d/examples/cubes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn setup(
// Directional light
commands.spawn(DirectionalLightBundle {
directional_light: DirectionalLight {
illuminance: 1000.0,
illuminance: 5000.0,
shadows_enabled: true,
..default()
},
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_xpbd_3d/examples/custom_broad_phase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn setup(
// Light
commands.spawn(PointLightBundle {
point_light: PointLight {
intensity: 500_000.0,
intensity: 2_000_000.0,
shadows_enabled: true,
..default()
},
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_xpbd_3d/examples/custom_constraint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ fn setup(
// Light
commands.spawn(PointLightBundle {
point_light: PointLight {
intensity: 500_000.0,
intensity: 2_000_000.0,
shadows_enabled: true,
..default()
},
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_xpbd_3d/examples/distance_joint_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn setup(
// Light
commands.spawn(PointLightBundle {
point_light: PointLight {
intensity: 500_000.0,
intensity: 2_000_000.0,
shadows_enabled: true,
..default()
},
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_xpbd_3d/examples/dynamic_character_3d/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn setup(
// Light
commands.spawn(PointLightBundle {
point_light: PointLight {
intensity: 500_000.0,
intensity: 2_000_000.0,
range: 50.0,
shadows_enabled: true,
..default()
Expand Down
3 changes: 1 addition & 2 deletions crates/bevy_xpbd_3d/examples/fixed_joint_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ fn setup(
PbrBundle {
mesh: cube_mesh.clone(),
material: cube_material.clone(),
transform: Transform::from_xyz(3.0, 3.5, 0.0),
..default()
},
RigidBody::Kinematic,
Expand Down Expand Up @@ -54,7 +53,7 @@ fn setup(
// Directional light
commands.spawn(DirectionalLightBundle {
directional_light: DirectionalLight {
illuminance: 1000.0,
illuminance: 2000.0,
shadows_enabled: true,
..default()
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn setup(
// Light
commands.spawn(PointLightBundle {
point_light: PointLight {
intensity: 500_000.0,
intensity: 2_000_000.0,
range: 50.0,
shadows_enabled: true,
..default()
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_xpbd_3d/examples/prismatic_joint_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fn setup(
// Directional light
commands.spawn(DirectionalLightBundle {
directional_light: DirectionalLight {
illuminance: 1000.0,
illuminance: 2000.0,
shadows_enabled: true,
..default()
},
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_xpbd_3d/examples/revolute_joint_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn setup(
// Directional light
commands.spawn(DirectionalLightBundle {
directional_light: DirectionalLight {
illuminance: 1000.0,
illuminance: 2000.0,
shadows_enabled: true,
..default()
},
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_xpbd_3d/examples/trimesh_shapes_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn setup(
mesh: meshes.add(shape),
material: debug_material.clone(),
transform: Transform::from_xyz(
-14.5 / 2.0 + i as f32 / (num_shapes - 1) as f32 * 14.5,
-10.0 / 2.0 + i as f32 / (num_shapes - 1) as f32 * 10.0,
2.0,
0.0,
)
Expand All @@ -79,7 +79,7 @@ fn setup(
// Light
commands.spawn(PointLightBundle {
point_light: PointLight {
intensity: 900_000.0,
intensity: 8_000_000.0,
range: 100.,
shadows_enabled: true,
..default()
Expand Down

0 comments on commit 860c989

Please sign in to comment.