proof of bevy egui color picker in UI. needs to and from bevy color, stuffed in a resource, to transmit between systems
This commit is contained in:
parent
ec020a03b5
commit
50749acacb
|
@ -7,7 +7,10 @@ use bevy::{
|
||||||
transform::components::GlobalTransform,
|
transform::components::GlobalTransform,
|
||||||
window::Window,
|
window::Window,
|
||||||
};
|
};
|
||||||
use bevy_egui::{egui, EguiContexts, EguiPlugin};
|
use bevy_egui::{
|
||||||
|
egui::{self, color_picker, Color32},
|
||||||
|
EguiContexts, EguiPlugin,
|
||||||
|
};
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -86,13 +89,7 @@ pub fn edit_click_events(
|
||||||
if collision.is_some() {
|
if collision.is_some() {
|
||||||
let col = collision.unwrap();
|
let col = collision.unwrap();
|
||||||
|
|
||||||
let x = edit_octtree.remove_voxel(col.voxel_index_location);
|
edit_octtree.remove_voxel(col.voxel_index_location);
|
||||||
if x == 0 {
|
|
||||||
dbg!(edit_octtree);
|
|
||||||
dbg!(col.voxel_index_location);
|
|
||||||
} else {
|
|
||||||
println!("Successfully culled {} voxels!", x);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if let Some(_) = insert.filter(|input| input.pressed()) {
|
} else if let Some(_) = insert.filter(|input| input.pressed()) {
|
||||||
if collision.is_some() {
|
if collision.is_some() {
|
||||||
|
@ -114,6 +111,7 @@ pub fn edit_window_ui(
|
||||||
mut oct_assets: ResMut<Assets<OctTreeAsset>>,
|
mut oct_assets: ResMut<Assets<OctTreeAsset>>,
|
||||||
mut pairs: ResMut<MeshingOctTreePairs>,
|
mut pairs: ResMut<MeshingOctTreePairs>,
|
||||||
) {
|
) {
|
||||||
|
let mut color: Color32 = Default::default();
|
||||||
egui::Window::new("VVEdit").show(contexts.ctx_mut(), |ui| {
|
egui::Window::new("VVEdit").show(contexts.ctx_mut(), |ui| {
|
||||||
let mut label = String::from("Pre-Alpha");
|
let mut label = String::from("Pre-Alpha");
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
|
@ -122,6 +120,7 @@ pub fn edit_window_ui(
|
||||||
writeln!(label, "R+click removes a voxel:").ok();
|
writeln!(label, "R+click removes a voxel:").ok();
|
||||||
writeln!(label, "E+click paints (edits) a voxel:").ok();
|
writeln!(label, "E+click paints (edits) a voxel:").ok();
|
||||||
|
|
||||||
|
color_picker::color_picker_color32(ui, &mut color, color_picker::Alpha::Opaque);
|
||||||
ui.label(label);
|
ui.label(label);
|
||||||
if ui.button("Add Origin Voxel").clicked() {
|
if ui.button("Add Origin Voxel").clicked() {
|
||||||
//
|
//
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
|
|
||||||
use std::mem::swap;
|
use std::mem::swap;
|
||||||
|
|
||||||
use bevy::math::{vec3, Vec3};
|
use bevy::math::Vec3;
|
||||||
use rand::Rng;
|
|
||||||
|
|
||||||
use crate::vvlib::intersections::aa_bounds_contains;
|
use crate::vvlib::intersections::aa_bounds_contains;
|
||||||
|
|
||||||
|
@ -627,6 +626,7 @@ pub fn test_path() {
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
pub fn fuzztestpath() {
|
pub fn fuzztestpath() {
|
||||||
|
use rand::Rng;
|
||||||
let origin = Vec3::ZERO;
|
let origin = Vec3::ZERO;
|
||||||
let mut test_oct = OctTree::<i32>::new(origin, 1);
|
let mut test_oct = OctTree::<i32>::new(origin, 1);
|
||||||
let range = 10000.;
|
let range = 10000.;
|
||||||
|
|
Loading…
Reference in a new issue