This commit is contained in:
1 parent
cc6acb188d
commit
9f95ba3082
24 files changed
+891
-78
No files matched your search
@@ -86,6 +86,7 @@ pub fn draw_actor_inspector(world: &mut World, ui: &mut egui::Ui, entity: Entity
|
||||
|
||||
match kind {
|
||||
ActorKind::StaticMesh
|
||||
| ActorKind::Brush
|
||||
| ActorKind::ImportedModel
|
||||
| ActorKind::Light
|
||||
| ActorKind::Empty
|
||||
@@ -110,7 +111,7 @@ pub fn draw_actor_inspector(world: &mut World, ui: &mut egui::Ui, entity: Entity
|
||||
|
||||
fn actor_icon(kind: ActorKind) -> egui_phosphor_icons::Icon {
|
||||
match kind {
|
||||
ActorKind::StaticMesh | ActorKind::ImportedModel => icons::CUBE,
|
||||
ActorKind::StaticMesh | ActorKind::Brush | ActorKind::ImportedModel => icons::CUBE,
|
||||
ActorKind::Light => icons::LIGHTBULB,
|
||||
ActorKind::PrefabAnchor => icons::PACKAGE,
|
||||
ActorKind::PlayerSpawn => icons::PERSON_SIMPLE_RUN,
|
||||
|
||||
@@ -51,10 +51,31 @@ impl Default for EditorComponentRegistry {
|
||||
description: "Renders one or more normalized imported mesh slots.",
|
||||
search_terms: &["mesh", "renderer", "rendering", "model", "static"],
|
||||
recommended: &[],
|
||||
conflicts_with: &["shared::components::Primitive"],
|
||||
conflicts_with: &[
|
||||
"shared::components::Primitive",
|
||||
"shared::components::BrushDesc",
|
||||
],
|
||||
hydration_effect:
|
||||
"Hydrates into generated mesh children and material bindings.",
|
||||
},
|
||||
EditorComponentDescriptor {
|
||||
type_name: "shared::components::BrushDesc",
|
||||
display_name: "Brush",
|
||||
category: EditorComponentCategory::Authoring,
|
||||
addable: true,
|
||||
removable: true,
|
||||
reorderable: true,
|
||||
hidden: false,
|
||||
icon: icons::CUBE.as_str(),
|
||||
description: "Creates authored convex brush geometry for blockout.",
|
||||
search_terms: &["brush", "blockout", "convex", "csg", "geometry"],
|
||||
recommended: &["shared::components::MaterialDesc"],
|
||||
conflicts_with: &[
|
||||
"shared::components::Primitive",
|
||||
"shared::components::StaticMeshRenderer",
|
||||
],
|
||||
hydration_effect: "Hydrates into generated brush mesh children.",
|
||||
},
|
||||
EditorComponentDescriptor {
|
||||
type_name: "shared::components::MaterialDesc",
|
||||
display_name: "Authoring Material",
|
||||
@@ -127,7 +148,10 @@ impl Default for EditorComponentRegistry {
|
||||
description: "Creates an authored built-in primitive shape.",
|
||||
search_terms: &["box", "sphere", "ramp", "primitive"],
|
||||
recommended: &[],
|
||||
conflicts_with: &["shared::components::StaticMeshRenderer"],
|
||||
conflicts_with: &[
|
||||
"shared::components::StaticMeshRenderer",
|
||||
"shared::components::BrushDesc",
|
||||
],
|
||||
hydration_effect:
|
||||
"Hydrates into generated primitive render and collision data.",
|
||||
},
|
||||
|
||||
@@ -89,6 +89,7 @@ pub fn light_snapshot(name: &str, translation: Vec3) -> EditorEntitySnapshot {
|
||||
name: Some(name.to_string()),
|
||||
transform: Transform::from_translation(translation),
|
||||
primitive: None,
|
||||
brush: None,
|
||||
static_mesh_renderer: None,
|
||||
material: None,
|
||||
material_override: None,
|
||||
@@ -136,6 +137,7 @@ pub fn ensure_player_spawn_for_edit(world: &mut World) -> Entity {
|
||||
name: Some("Player Start".to_string()),
|
||||
transform,
|
||||
primitive: None,
|
||||
brush: None,
|
||||
static_mesh_renderer: None,
|
||||
material: None,
|
||||
material_override: None,
|
||||
@@ -223,6 +225,7 @@ pub fn create_scene_sun_override_from_project_settings(world: &mut World) -> Ent
|
||||
name: Some("Scene Sun".to_string()),
|
||||
transform,
|
||||
primitive: None,
|
||||
brush: None,
|
||||
static_mesh_renderer: None,
|
||||
material: None,
|
||||
material_override: None,
|
||||
|
||||
@@ -106,7 +106,7 @@ fn actor_kind_sort_key(world: &World, entity: Entity) -> u8 {
|
||||
.copied()
|
||||
.map(|kind| match kind {
|
||||
ActorKind::Empty => 0,
|
||||
ActorKind::StaticMesh | ActorKind::ImportedModel => 1,
|
||||
ActorKind::Brush | ActorKind::StaticMesh | ActorKind::ImportedModel => 1,
|
||||
ActorKind::Light => 2,
|
||||
ActorKind::PrefabAnchor => 3,
|
||||
ActorKind::PlayerSpawn => 4,
|
||||
@@ -336,6 +336,7 @@ pub fn actor_kind_icon(kind: ActorKind) -> &'static str {
|
||||
use egui_phosphor_icons::icons;
|
||||
match kind {
|
||||
ActorKind::Empty => icons::FOLDER.as_str(),
|
||||
ActorKind::Brush => icons::CUBE.as_str(),
|
||||
ActorKind::StaticMesh => icons::CUBE.as_str(),
|
||||
ActorKind::ImportedModel => icons::CUBE_TRANSPARENT.as_str(),
|
||||
ActorKind::Light => icons::LIGHTBULB.as_str(),
|
||||
|
||||
@@ -7,25 +7,25 @@ use bevy::prelude::*;
|
||||
use bevy_egui::egui;
|
||||
use egui_phosphor_icons::{icons, Icon};
|
||||
use shared::{
|
||||
inspector_component_active, AuthoringLightKind, AuthoringRigidBody, ColliderDesc,
|
||||
ColliderShapeDesc, ColorDesc, ComponentInstanceId, EditorAssetRef, InspectorOrder, LevelObject,
|
||||
LightDesc, MaterialDesc, MaterialParameter, MaterialParameterValue, MaterialShaderKind,
|
||||
ObjectiveMarker, PhysicsBody, PlayerSpawn, PostProcessVolumeDesc, PrefabInstance, Primitive,
|
||||
PrimitiveShape, ProjectSun, RigidBodyDesc, StaticMeshRenderer, StaticMeshRendererEntry,
|
||||
TeamSpawn, TriggerVolume, WeaponSpawn, AUTHORING_DIRECTIONAL_LUX_MAX,
|
||||
AUTHORING_POINT_SPOT_LUMENS_MAX, COMPONENT_COLLIDER_DESC, COMPONENT_LIGHT_DESC,
|
||||
COMPONENT_MATERIAL_DESC, COMPONENT_OBJECTIVE_MARKER, COMPONENT_PHYSICS_BODY,
|
||||
COMPONENT_PLAYER_SPAWN, COMPONENT_POST_PROCESS_VOLUME, COMPONENT_PREFAB_INSTANCE,
|
||||
COMPONENT_PRIMITIVE, COMPONENT_PROJECT_SUN, COMPONENT_RIGID_BODY_DESC,
|
||||
COMPONENT_STATIC_MESH_RENDERER, COMPONENT_TEAM_SPAWN, COMPONENT_TRIGGER_VOLUME,
|
||||
COMPONENT_WEAPON_SPAWN,
|
||||
inspector_component_active, AuthoringLightKind, AuthoringRigidBody, BrushDesc, BrushKind,
|
||||
ColliderDesc, ColliderShapeDesc, ColorDesc, ComponentInstanceId, EditorAssetRef,
|
||||
InspectorOrder, LevelObject, LightDesc, MaterialDesc, MaterialParameter,
|
||||
MaterialParameterValue, MaterialShaderKind, ObjectiveMarker, PhysicsBody, PlayerSpawn,
|
||||
PostProcessVolumeDesc, PrefabInstance, Primitive, PrimitiveShape, ProjectSun, RigidBodyDesc,
|
||||
StaticMeshRenderer, StaticMeshRendererEntry, TeamSpawn, TriggerVolume, WeaponSpawn,
|
||||
AUTHORING_DIRECTIONAL_LUX_MAX, AUTHORING_POINT_SPOT_LUMENS_MAX, COMPONENT_BRUSH_DESC,
|
||||
COMPONENT_COLLIDER_DESC, COMPONENT_LIGHT_DESC, COMPONENT_MATERIAL_DESC,
|
||||
COMPONENT_OBJECTIVE_MARKER, COMPONENT_PHYSICS_BODY, COMPONENT_PLAYER_SPAWN,
|
||||
COMPONENT_POST_PROCESS_VOLUME, COMPONENT_PREFAB_INSTANCE, COMPONENT_PRIMITIVE,
|
||||
COMPONENT_PROJECT_SUN, COMPONENT_RIGID_BODY_DESC, COMPONENT_STATIC_MESH_RENDERER,
|
||||
COMPONENT_TEAM_SPAWN, COMPONENT_TRIGGER_VOLUME, COMPONENT_WEAPON_SPAWN,
|
||||
};
|
||||
|
||||
use crate::history::{
|
||||
material_eq, set_collider_with_history, set_inspector_order_with_history,
|
||||
set_light_with_history, set_material_with_history, set_physics_with_history,
|
||||
set_post_process_volume_with_history, set_primitive_with_history, set_rigid_body_with_history,
|
||||
set_static_mesh_renderer_with_history, EditorEntitySnapshot,
|
||||
material_eq, set_brush_with_history, set_collider_with_history,
|
||||
set_inspector_order_with_history, set_light_with_history, set_material_with_history,
|
||||
set_physics_with_history, set_post_process_volume_with_history, set_primitive_with_history,
|
||||
set_rigid_body_with_history, set_static_mesh_renderer_with_history, EditorEntitySnapshot,
|
||||
};
|
||||
use crate::selection::SelectedEntity;
|
||||
use crate::ui::theme::{
|
||||
@@ -131,6 +131,7 @@ enum AddComponentShelfDirection {
|
||||
#[derive(Debug, Clone)]
|
||||
enum CopiedComponent {
|
||||
Primitive(Primitive),
|
||||
BrushDesc(BrushDesc),
|
||||
StaticMeshRenderer(StaticMeshRenderer),
|
||||
MaterialDesc(MaterialDesc),
|
||||
LightDesc(LightDesc),
|
||||
@@ -149,6 +150,7 @@ impl CopiedComponent {
|
||||
fn type_name(&self) -> &'static str {
|
||||
match self {
|
||||
Self::Primitive(_) => COMPONENT_PRIMITIVE,
|
||||
Self::BrushDesc(_) => COMPONENT_BRUSH_DESC,
|
||||
Self::StaticMeshRenderer(_) => COMPONENT_STATIC_MESH_RENDERER,
|
||||
Self::MaterialDesc(_) => COMPONENT_MATERIAL_DESC,
|
||||
Self::LightDesc(_) => COMPONENT_LIGHT_DESC,
|
||||
@@ -357,6 +359,9 @@ fn present_component_type_names(world: &World, entity: Entity) -> Vec<&'static s
|
||||
if world.get::<Primitive>(entity).is_some() {
|
||||
present.push(COMPONENT_PRIMITIVE);
|
||||
}
|
||||
if world.get::<BrushDesc>(entity).is_some() {
|
||||
present.push(COMPONENT_BRUSH_DESC);
|
||||
}
|
||||
if world.get::<MaterialDesc>(entity).is_some() || world.get::<Primitive>(entity).is_some() {
|
||||
present.push(COMPONENT_MATERIAL_DESC);
|
||||
}
|
||||
@@ -405,6 +410,10 @@ fn copy_component(world: &mut World, entity: Entity, type_name: &str) {
|
||||
.get::<Primitive>(entity)
|
||||
.cloned()
|
||||
.map(CopiedComponent::Primitive),
|
||||
COMPONENT_BRUSH_DESC => world
|
||||
.get::<BrushDesc>(entity)
|
||||
.cloned()
|
||||
.map(CopiedComponent::BrushDesc),
|
||||
COMPONENT_STATIC_MESH_RENDERER => world
|
||||
.get::<StaticMeshRenderer>(entity)
|
||||
.cloned()
|
||||
@@ -468,6 +477,9 @@ fn paste_component(world: &mut World, entity: Entity, type_name: &str) {
|
||||
Some(CopiedComponent::Primitive(value)) if type_name == COMPONENT_PRIMITIVE => {
|
||||
set_primitive_with_history(world, entity, value);
|
||||
}
|
||||
Some(CopiedComponent::BrushDesc(value)) if type_name == COMPONENT_BRUSH_DESC => {
|
||||
set_brush_with_history(world, entity, value);
|
||||
}
|
||||
Some(CopiedComponent::StaticMeshRenderer(value))
|
||||
if type_name == COMPONENT_STATIC_MESH_RENDERER =>
|
||||
{
|
||||
@@ -517,6 +529,7 @@ fn paste_component(world: &mut World, entity: Entity, type_name: &str) {
|
||||
fn reset_component(world: &mut World, entity: Entity, type_name: &str) {
|
||||
match type_name {
|
||||
COMPONENT_PRIMITIVE => set_primitive_with_history(world, entity, Primitive::default()),
|
||||
COMPONENT_BRUSH_DESC => set_brush_with_history(world, entity, BrushDesc::default()),
|
||||
COMPONENT_STATIC_MESH_RENDERER => {
|
||||
set_static_mesh_renderer_with_history(world, entity, StaticMeshRenderer::default());
|
||||
}
|
||||
@@ -575,6 +588,10 @@ fn remove_registered_component(world: &mut World, entity: Entity, type_name: &st
|
||||
entity_mut.remove::<Primitive>();
|
||||
true
|
||||
}
|
||||
COMPONENT_BRUSH_DESC if before.brush.is_some() => {
|
||||
entity_mut.remove::<BrushDesc>();
|
||||
true
|
||||
}
|
||||
COMPONENT_STATIC_MESH_RENDERER if before.static_mesh_renderer.is_some() => {
|
||||
entity_mut.remove::<StaticMeshRenderer>();
|
||||
true
|
||||
@@ -670,6 +687,7 @@ fn draw_authoring_component_by_type(
|
||||
) {
|
||||
match type_name {
|
||||
COMPONENT_STATIC_MESH_RENDERER => static_mesh_renderer_ui(world, ui, entity),
|
||||
COMPONENT_BRUSH_DESC => brush_editor_ui(world, ui, entity),
|
||||
COMPONENT_PRIMITIVE => primitive_editor_ui(world, ui, entity),
|
||||
COMPONENT_MATERIAL_DESC => material_editor_ui(world, ui, entity),
|
||||
COMPONENT_LIGHT_DESC => light_editor_ui(world, ui, entity),
|
||||
@@ -1090,6 +1108,7 @@ fn component_display_name(
|
||||
fn component_present(world: &World, entity: Entity, type_name: &str) -> bool {
|
||||
match type_name {
|
||||
"shared::components::Primitive" => world.get::<Primitive>(entity).is_some(),
|
||||
"shared::components::BrushDesc" => world.get::<BrushDesc>(entity).is_some(),
|
||||
"shared::components::StaticMeshRenderer" => {
|
||||
world.get::<StaticMeshRenderer>(entity).is_some()
|
||||
}
|
||||
@@ -1112,10 +1131,19 @@ fn component_present(world: &World, entity: Entity, type_name: &str) -> bool {
|
||||
fn insert_registered_component(world: &mut World, entity: Entity, type_name: &str) {
|
||||
match type_name {
|
||||
"shared::components::Primitive" => insert_component(world, entity, |world, e| {
|
||||
world.entity_mut(e).insert(Primitive::cuboid(Vec3::ONE));
|
||||
world
|
||||
.entity_mut(e)
|
||||
.insert((shared::ActorKind::StaticMesh, Primitive::cuboid(Vec3::ONE)));
|
||||
}),
|
||||
"shared::components::BrushDesc" => insert_component(world, entity, |world, e| {
|
||||
world
|
||||
.entity_mut(e)
|
||||
.insert((shared::ActorKind::Brush, BrushDesc::default()));
|
||||
}),
|
||||
"shared::components::StaticMeshRenderer" => insert_component(world, entity, |world, e| {
|
||||
world.entity_mut(e).insert(StaticMeshRenderer::default());
|
||||
world
|
||||
.entity_mut(e)
|
||||
.insert((shared::ActorKind::StaticMesh, StaticMeshRenderer::default()));
|
||||
}),
|
||||
"shared::components::MaterialDesc" => insert_component(world, entity, |world, e| {
|
||||
world.entity_mut(e).insert(MaterialDesc::default());
|
||||
@@ -1189,6 +1217,7 @@ fn diff_added(before: &EditorEntitySnapshot, after: &EditorEntitySnapshot) -> Ed
|
||||
.primitive
|
||||
.clone()
|
||||
.filter(|_| before.primitive.is_none()),
|
||||
brush: after.brush.clone().filter(|_| before.brush.is_none()),
|
||||
static_mesh_renderer: after
|
||||
.static_mesh_renderer
|
||||
.clone()
|
||||
@@ -2370,6 +2399,62 @@ pub fn material_editor_ui(world: &mut World, ui: &mut egui::Ui, entity: Entity)
|
||||
}
|
||||
}
|
||||
|
||||
fn brush_editor_ui(world: &mut World, ui: &mut egui::Ui, entity: Entity) {
|
||||
let Some(mut brush) = world.get::<BrushDesc>(entity).cloned() else {
|
||||
return;
|
||||
};
|
||||
let original = brush.clone();
|
||||
let mut changed = false;
|
||||
let mut reset_cube = false;
|
||||
let card = component_card_context(
|
||||
world,
|
||||
entity,
|
||||
ComponentCardOptions::removable(COMPONENT_BRUSH_DESC, "Brush", icons::CUBE),
|
||||
);
|
||||
let card_response = component_card(ui, &card, |ui| {
|
||||
property_row(ui, "Kind", |ui| {
|
||||
egui::ComboBox::from_id_salt("brush_kind")
|
||||
.selected_text(match brush.kind {
|
||||
BrushKind::Additive => "Additive",
|
||||
BrushKind::SubtractiveMarker => "Subtractive Marker",
|
||||
})
|
||||
.show_ui(ui, |ui| {
|
||||
changed |= ui
|
||||
.selectable_value(&mut brush.kind, BrushKind::Additive, "Additive")
|
||||
.changed();
|
||||
changed |= ui
|
||||
.selectable_value(
|
||||
&mut brush.kind,
|
||||
BrushKind::SubtractiveMarker,
|
||||
"Subtractive Marker",
|
||||
)
|
||||
.changed();
|
||||
});
|
||||
});
|
||||
property_row(ui, "Faces", |ui| {
|
||||
ui.label(format!("{}", brush.faces.len()));
|
||||
});
|
||||
property_row(ui, "Shadows", |ui| {
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
changed |= ui.checkbox(&mut brush.cast_shadows, "Cast").changed();
|
||||
changed |= ui.checkbox(&mut brush.receive_shadows, "Receive").changed();
|
||||
});
|
||||
});
|
||||
if ui.button("Reset Cube Brush").clicked() {
|
||||
reset_cube = true;
|
||||
}
|
||||
});
|
||||
apply_component_card_response(world, entity, card_response);
|
||||
|
||||
if reset_cube {
|
||||
brush = BrushDesc::default();
|
||||
changed = true;
|
||||
}
|
||||
if changed && brush != original {
|
||||
set_brush_with_history(world, entity, brush);
|
||||
}
|
||||
}
|
||||
|
||||
fn primitive_editor_ui(world: &mut World, ui: &mut egui::Ui, entity: Entity) {
|
||||
let Some(mut primitive) = world.get::<Primitive>(entity).cloned() else {
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user