Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'steadyum'",
"cargo": {
"args": [
"build",
"--bin=steadyum",
"--package=steadyum",
"--features=dim3",
],
"filter": {
"name": "steadyum",
"kind": "bin"
}
},
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in executable 'steadyum'",
"cargo": {
"args": [
"test",
"--no-run",
"--bin=steadyum",
"--package=steadyum"
],
"filter": {
"name": "steadyum",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
}
]
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rust-analyzer.cargo.features": [
"dim3"
]
}
47 changes: 28 additions & 19 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,40 @@ parallel = ["bevy_rapier2d?/parallel", "bevy_rapier3d?/parallel"]
simd-stable = ["bevy_rapier2d?/simd-stable", "bevy_rapier3d?/simd-stable"]
wasm-bindgen = ["bevy_rapier2d?/wasm-bindgen", "bevy_rapier3d?/wasm-bindgen"]
simd-nightly = ["bevy_rapier2d?/simd-nightly", "bevy_rapier3d?/simd-nightly"]
serde-serialize = ["bevy_rapier2d?/serde-serialize", "bevy_rapier3d?/serde-serialize"]
enhanced-determinism = ["bevy_rapier2d?/enhanced-determinism", "bevy_rapier3d?/enhanced-determinism"]
serde-serialize = [
"bevy_rapier2d?/serde-serialize",
"bevy_rapier3d?/serde-serialize",
]
enhanced-determinism = [
"bevy_rapier2d?/enhanced-determinism",
"bevy_rapier3d?/enhanced-determinism",
]
voxels = ["dot_vox"]

[dependencies]
nalgebra = { version = "0.32", features = ["convert-glam020"] }
nalgebra = { version = "0.33", features = ["convert-glam027"] }
# Don't enable the default features because we don't need the ColliderSet/RigidBodySet
rapier3d = { version = "0.19", optional = true, features = ["profiler"] }
bevy_rapier3d = { version = "0.26", optional = true, features = ["serde-serialize"] }
rapier2d = { version = "0.19", optional = true, features = ["profiler"] }
bevy_rapier2d = { version = "0.26", optional = true, features = ["serde-serialize"] }
rapier3d = { version = "0.21", optional = true, features = ["profiler"] }
bevy_rapier3d = { version = "0.27", optional = true, features = [
"serde-serialize",
] }
rapier2d = { version = "0.21", optional = true, features = ["profiler"] }
bevy_rapier2d = { version = "0.27", optional = true, features = [
"serde-serialize",
] }

bitflags = "1"
strum = "0.24"
strum_macros = "0.24"
strum = "0.26"
strum_macros = "0.26"
image = "0.24"
winit = "0.28"
winit = "0.30"
log = "0.4"
oorandom = "11"
bytemuck = "1"
serde = "1"
bincode = "1"
serde_json = "1"
noise = "0.8"
noise = "0.9"
sled = "0.34"
clap = { version = "4", features = ["derive"] }
anyhow = "1"
Expand All @@ -55,17 +65,17 @@ uuid = "1"
dot_vox = { version = "5", optional = true }
instant = "0.1"

bevy = { version = "0.13", features = ["serialize"] }
bevy_egui = "0.27"
bevy = { version = "0.14", features = ["serialize"] }
bevy_egui = "0.28"
#bevy_stl = "0.7"
bevy_obj = "0.13"
bevy_polyline = { git = "https://github.com/nsabovic/bevy_polyline", branch = "bevy-13" }
bevy_prototype_lyon = "0.11"
bevy_infinite_grid = "0.12"
bevy_obj = "0.14"
bevy_polyline = "0.10"
bevy_prototype_lyon = "0.12"
bevy_infinite_grid = "0.13"

# Not compatible with WASM
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
native-dialog = "0.6" # For opening mesh files.
native-dialog = "0.7" # For opening mesh files.

[profile.release]
debug = true
Expand All @@ -83,4 +93,3 @@ debug = true
#bevy_rapier3d = { path = "../bevy_rapier/bevy_rapier3d" }
#bevy_rapier2d = { git = "https://github.com/dimforge/bevy_rapier", branch = "gosim" }
#bevy_rapier3d = { git = "https://github.com/dimforge/bevy_rapier", branch = "gosim" }

18 changes: 10 additions & 8 deletions src/floor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ impl Plugin for FloorPlugin {
}

fn setup_floor(mut commands: Commands, _meshes: ResMut<Assets<Mesh>>) {
commands.spawn(InfiniteGridBundle {
settings: InfiniteGridSettings {
// shadow_color: None,
fadeout_distance: 500.0,
dot_fadeout_strength: 0.1,
commands
.spawn(InfiniteGridBundle {
settings: InfiniteGridSettings {
// shadow_color: None,
fadeout_distance: 500.0,
dot_fadeout_strength: 0.1,
..Default::default()
},
..Default::default()
},
..Default::default()
});
})
.insert(Name::new("Infinite Grid"));
}
3 changes: 2 additions & 1 deletion src/insertion/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ fn spawn_preview_entity(mut commands: Commands) {
commands
.spawn(preview_shape_bundle(Vect::ONE, Color::WHITE))
.insert(InsertionPreview)
.insert(Visibility::Hidden);
.insert(Visibility::Hidden)
.insert(Name::new("Preview"));
}

#[cfg(feature = "dim2")]
Expand Down
2 changes: 1 addition & 1 deletion src/layers.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub const GIZMO_LAYER: u8 = 1;
pub const GIZMO_LAYER: usize = 1;
30 changes: 17 additions & 13 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn main() {
title,
..Default::default()
})*/
.insert_resource(ClearColor(Color::rgb(0.55, 0.55, 0.55)))
.insert_resource(ClearColor(Color::srgb(0.55, 0.55, 0.55)))
.insert_resource(args)
.insert_resource(PhysicsProgress::default())
.add_plugins(DefaultPlugins)
Expand Down Expand Up @@ -191,19 +191,21 @@ fn setup_graphics(mut commands: Commands) {

#[cfg(feature = "dim3")]
fn setup_graphics(mut commands: Commands) {
commands.spawn(DirectionalLightBundle {
directional_light: DirectionalLight {
illuminance: 10_000.0,
shadows_enabled: true,
..Default::default()
},
transform: Transform {
translation: Vec3::new(10.0, 2.0, 10.0),
rotation: Quat::from_rotation_x(-std::f32::consts::FRAC_PI_4),
commands
.spawn(DirectionalLightBundle {
directional_light: DirectionalLight {
illuminance: 10_000.0,
shadows_enabled: true,
..Default::default()
},
transform: Transform {
translation: Vec3::new(10.0, 2.0, 10.0),
rotation: Quat::from_rotation_x(-std::f32::consts::FRAC_PI_4),
..Default::default()
},
..Default::default()
},
..Default::default()
});
})
.insert(Name::new("Light"));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

names are useful to understand the layout when injecting bevy-inspector-egui


let mut orbit = OrbitCamera {
pan_sensitivity: 4.0,
Expand All @@ -227,6 +229,7 @@ fn setup_graphics(mut commands: Commands) {
}),
..Default::default()
})
.insert(Name::new("3D Camera"))
// .insert(UnrealCameraBundle::new(
// UnrealCameraController { ..default() },
// Vec3::new(-2.0, 25.0, 5.0),
Expand All @@ -251,6 +254,7 @@ fn setup_graphics(mut commands: Commands) {
},
..default()
})
.insert(Name::new("Gizmos Camera"))
.insert(GizmoCamera)
.insert(RenderLayers::layer(GIZMO_LAYER));
}
Expand Down
1 change: 1 addition & 0 deletions src/operation/add_collision_shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub fn add_collision_shape(
commands
.spawn(collider.clone())
.insert(rigid_body.clone())
.insert(Name::new("Collision Shape"))
.insert(TransformBundle::from_transform(*transform))
.insert(ColliderRenderBundle::new(&mut colors));
}
Expand Down
5 changes: 4 additions & 1 deletion src/render/collision_shape_outline_render3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ pub fn create_collider_outline_renders_system(
}
} else {
let target = commands.entity(entity).with_children(|cmd| {
let target = cmd.spawn(bundle).id();
let target = cmd
.spawn(bundle)
.insert(Name::new("Collider Outlines"))
.id();
render_target.outline_target = Some(target);
});
}
Expand Down
12 changes: 6 additions & 6 deletions src/render/components.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use bevy::prelude::Color;
use bevy::prelude::*;

pub const DEFAULT_COLOR: Color = Color::BEIGE;
pub const DEFAULT_COLOR: Color = Color::Srgba(bevy::color::palettes::css::BEIGE);
pub const DEFAULT_PALETTE: [Color; 3] = [
Color::rgb(
Color::srgb(
0x98 as f32 / 255.0,
0xC1 as f32 / 255.0,
0xD9 as f32 / 255.0,
),
Color::rgb(
Color::srgb(
0x05 as f32 / 255.0,
0x3C as f32 / 255.0,
0x5E as f32 / 255.0,
),
Color::rgb(
Color::srgb(
0x1F as f32 / 255.0,
0x7A as f32 / 255.0,
0x8C as f32 / 255.0,
Expand Down Expand Up @@ -91,8 +91,8 @@ impl ColliderOutlineRender {
/*
* Joint rendering.
*/
pub const DEFAULT_JOINT_ANCHOR_COLOR: Color = Color::rgb(0.0, 0.0, 1.0);
pub const DEFAULT_JOINT_SEPARATION_COLOR: Color = Color::rgb(1.0, 0.0, 1.0);
pub const DEFAULT_JOINT_ANCHOR_COLOR: Color = Color::srgb(0.0, 0.0, 1.0);
pub const DEFAULT_JOINT_SEPARATION_COLOR: Color = Color::srgb(1.0, 0.0, 1.0);

#[derive(Copy, Clone, Component)]
pub struct JointRender {
Expand Down
7 changes: 6 additions & 1 deletion src/selection/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use bevy::app::PluginGroupBuilder;
use bevy::prelude::*;
use bevy::render::view::{check_visibility, VisibilitySystems};
use bevy_rapier::prelude::*;

pub use self::selection_shape::SelectionShape;
Expand Down Expand Up @@ -50,7 +51,11 @@ impl Plugin for SelectionPlugin {
fn build(&self, app: &mut App) {
app.insert_resource(SelectionState::default())
.insert_resource(SceneMouse::default())
.add_systems(Update, add_missing_selection_components);
.add_systems(Update, add_missing_selection_components)
.add_systems(
PostUpdate,
check_visibility::<With<Selection>>.in_set(VisibilitySystems::CheckVisibility),
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/selection/mouse/track.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub fn track_mouse_state(
- Vec2::ONE)
* Vec2::new(1.0, -1.0);
let ndc_to_world =
camera_transform.compute_matrix() * camera.projection_matrix().inverse();
camera_transform.compute_matrix() * camera.clip_from_view().inverse();
let ray_pt1 =
ndc_to_world.project_point3(Vec3::new(ndc_cursor.x, ndc_cursor.y, -1.0));

Expand Down
4 changes: 2 additions & 2 deletions src/selection/transform_gizmo/assets/gizmo_material.wgsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import bevy_pbr::mesh_functions::{get_model_matrix, mesh_position_local_to_clip}
#import bevy_pbr::mesh_functions::{get_world_from_local, mesh_position_local_to_clip}

struct GizmoMaterial {
color: vec4<f32>,
Expand All @@ -20,7 +20,7 @@ struct VertexOutput {
fn vertex(vertex: Vertex) -> VertexOutput {
var out: VertexOutput;
out.clip_position = mesh_position_local_to_clip(
get_model_matrix(vertex.instance_index),
get_world_from_local(vertex.instance_index),
vec4<f32>(vertex.position, 1.0),
);
return out;
Expand Down
10 changes: 6 additions & 4 deletions src/selection/transform_gizmo/gizmo_material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use bevy::{
prelude::*,
reflect::TypePath,
render::{
mesh::MeshVertexBufferLayout,
mesh::{MeshVertexBufferLayout, MeshVertexBufferLayoutRef},
render_resource::{
AsBindGroup, RenderPipelineDescriptor, ShaderRef, SpecializedMeshPipelineError,
},
Expand All @@ -15,12 +15,14 @@ pub const GIZMO_SHADER_HANDLE: Handle<Shader> = Handle::weak_from_u128(139538002
#[derive(Asset, TypePath, AsBindGroup, Debug, Clone)]
pub struct GizmoMaterial {
#[uniform(0)]
pub color: Color,
pub color: LinearRgba,
}

impl From<Color> for GizmoMaterial {
fn from(color: Color) -> Self {
GizmoMaterial { color }
GizmoMaterial {
color: color.into(),
}
}
}

Expand All @@ -40,7 +42,7 @@ impl Material for GizmoMaterial {
fn specialize(
_pipeline: &MaterialPipeline<Self>,
descriptor: &mut RenderPipelineDescriptor,
_layout: &MeshVertexBufferLayout,
_layout: &MeshVertexBufferLayoutRef,
_key: MaterialPipelineKey<Self>,
) -> Result<(), SpecializedMeshPipelineError> {
descriptor.primitive.cull_mode = None;
Expand Down
Loading