pre-refactor
This commit is contained in:
parent
e2b9aa3313
commit
640987b9b8
|
@ -7,7 +7,7 @@ use crate::vvlib::oct_asset::{self, OctAssetMarker, OctTreeAsset};
|
|||
mod editor_bevy_input_shim;
|
||||
pub mod editor_ui;
|
||||
mod orbit_camera;
|
||||
pub mod ui_extensions;
|
||||
pub mod string_tree;
|
||||
|
||||
pub fn setup(app: &mut App) -> &mut App {
|
||||
app.add_plugins(DefaultPlugins.set(WindowPlugin {
|
||||
|
|
|
@ -37,7 +37,7 @@ use crate::{
|
|||
use super::{
|
||||
editor_bevy_input_shim::setup_inputs,
|
||||
orbit_camera::orbit_camera::{pan_orbit_camera, spawn_camera},
|
||||
ui_extensions::{StringTree, StringTreeElement},
|
||||
string_tree::{StringTree, StringTreeElement},
|
||||
};
|
||||
|
||||
use std::fmt::Write;
|
||||
|
@ -48,13 +48,26 @@ pub struct AssetEditData {
|
|||
has_changed_since_last_save: bool,
|
||||
}
|
||||
|
||||
#[derive(Default, Resource)]
|
||||
#[derive(Resource)]
|
||||
pub struct EditWindowUIState {
|
||||
brush_color: Hsva,
|
||||
meshes: Vec<AssetEditData>,
|
||||
structure: StringTree,
|
||||
egui: EditWindowEguiState,
|
||||
popup: PopupWindowData,
|
||||
selected_structure_element: String,
|
||||
}
|
||||
impl Default for EditWindowUIState {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
brush_color: Default::default(),
|
||||
meshes: Default::default(),
|
||||
structure: Default::default(),
|
||||
egui: Default::default(),
|
||||
popup: Default::default(),
|
||||
selected_structure_element: "".into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
#[derive(Default)]
|
||||
pub enum PopupWindowData {
|
||||
|
@ -489,7 +502,6 @@ pub fn edit_window_ui(
|
|||
});
|
||||
show_editable_stringtree(ui, &mut shared_ui_state);
|
||||
if ui.button("Save Any Changes").clicked() {
|
||||
//save all files.
|
||||
for each in &mut shared_ui_state.meshes {
|
||||
if each.has_changed_since_last_save {
|
||||
let handle = each.id.clone();
|
||||
|
@ -573,15 +585,17 @@ pub fn show_popup(state: &mut EditWindowUIState, contexts: &mut EguiContexts) {
|
|||
}
|
||||
|
||||
pub fn show_editable_stringtree(ui: &mut egui::Ui, state: &mut EditWindowUIState) {
|
||||
let mut string_selected = state.selected_structure_element.clone();
|
||||
ui.collapsing("Model Structure", |ui| {
|
||||
ui.vertical(|ui| {
|
||||
for each in &state.structure.root {
|
||||
match each {
|
||||
super::ui_extensions::StringTreeElement::None => {}
|
||||
super::ui_extensions::StringTreeElement::Element(name, children) => {
|
||||
super::string_tree::StringTreeElement::None => {}
|
||||
super::string_tree::StringTreeElement::Element(name, children) => {
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(">".to_owned());
|
||||
ui.label(name.clone());
|
||||
//ui.label(name.clone());
|
||||
ui.radio_value(&mut string_selected, name.clone(), name.clone());
|
||||
let but = egui::Button::new("...");
|
||||
|
||||
if ui.add_enabled(true, but).clicked() {
|
||||
|
@ -599,19 +613,21 @@ pub fn show_editable_stringtree(ui: &mut egui::Ui, state: &mut EditWindowUIState
|
|||
}
|
||||
});
|
||||
for each in children.as_ref() {
|
||||
show_child(ui, each, 1, &mut state.popup);
|
||||
show_child(ui, each, 1, &mut state.popup, &mut string_selected);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
state.selected_structure_element = string_selected;
|
||||
}
|
||||
pub fn show_child(
|
||||
ui: &mut egui::Ui,
|
||||
subject: &StringTreeElement,
|
||||
depth: usize,
|
||||
state: &mut PopupWindowData,
|
||||
selection: &mut String,
|
||||
) {
|
||||
match subject {
|
||||
StringTreeElement::None => {}
|
||||
|
@ -627,7 +643,8 @@ pub fn show_child(
|
|||
prec = prec + ">";
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(prec);
|
||||
ui.label(name.clone());
|
||||
//ui.label(name.clone());
|
||||
ui.radio_value(selection, name.clone(), name.clone());
|
||||
if ui.button("...").clicked() {
|
||||
let mut should_close = false;
|
||||
if let PopupWindowData::StructureElement(val) = state {
|
||||
|
@ -643,7 +660,7 @@ pub fn show_child(
|
|||
}
|
||||
});
|
||||
for each in children.as_ref() {
|
||||
show_child(ui, each, depth + 1, state);
|
||||
show_child(ui, each, depth + 1, state, selection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -341,6 +341,7 @@ impl StringTree {
|
|||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_string_tree() {
|
||||
let parent = &String::from("parent1");
|
|
@ -6,6 +6,7 @@ pub mod intersections;
|
|||
pub mod obb;
|
||||
pub mod oct_asset;
|
||||
pub mod octtree;
|
||||
pub mod structure_asset;
|
||||
|
||||
pub const RANDOM_SPACE: f32 = 5.; // size of the random possibility space.
|
||||
pub const INTERVAL: f32 = 0.3; // how often to add ^ that many and remove ^ that many random locations
|
||||
|
|
25
src/vvlib/structure_asset.rs
Normal file
25
src/vvlib/structure_asset.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
use bevy::{
|
||||
math::{Quat, Vec3},
|
||||
transform::components::Transform,
|
||||
};
|
||||
|
||||
pub struct StructureElement {
|
||||
euler: Vec3,
|
||||
translation: Vec3,
|
||||
scale: Vec3,
|
||||
}
|
||||
pub enum StructureOptions {
|
||||
None,
|
||||
}
|
||||
impl StructureElement {
|
||||
pub fn into_transform(&self) -> Transform {
|
||||
Transform::from_rotation(
|
||||
Quat::from_rotation_x(self.euler.x)
|
||||
+ Quat::from_rotation_y(self.euler.y)
|
||||
+ Quat::from_rotation_z(self.euler.z),
|
||||
) * Transform::from_scale(self.scale)
|
||||
* Transform::from_translation(self.translation)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct StructureAsset {}
|
Loading…
Reference in a new issue