add bsp/prop toggle

This commit is contained in:
Robin Appelman 2023-12-13 16:14:44 +01:00
commit 7b627c1140
3 changed files with 36 additions and 13 deletions

View file

@ -85,7 +85,7 @@ fn model_to_model(model: Handle<vbsp::data::Model>, loader: &Loader) -> CpuModel
.collect();
CpuModel {
name: "".to_string(),
name: "bsp".to_string(),
geometries,
materials,
}

View file

@ -105,14 +105,23 @@ impl<C: Control> Renderer<C> {
let geometries = self
.models
.iter()
.flat_map(|model| model.iter())
.map(|gm| &gm.geometry);
.enumerate()
.filter_map(|(i, model)| {
if !self.gui.show_bsp && i == 0 {
None
} else if !self.gui.show_props && i == 1 {
None
} else {
Some(model)
}
})
.flat_map(|model| model.iter());
match self.gui.debug_type {
DebugType::Normal => target.render_with_material(
&NormalMaterial::default(),
&self.camera,
geometries,
geometries.map(|gm| &gm.geometry),
lights,
),
DebugType::Depth => {
@ -125,28 +134,34 @@ impl<C: Control> Renderer<C> {
DebugType::Orm => target.render_with_material(
&ORMMaterial::default(),
&self.camera,
geometries,
geometries.map(|gm| &gm.geometry),
lights,
),
DebugType::Position => {
let position_material = PositionMaterial::default();
target.render_with_material(&position_material, &self.camera, geometries, lights)
target.render_with_material(
&position_material,
&self.camera,
geometries.map(|gm| &gm.geometry),
lights,
)
}
DebugType::Uv => {
let uv_material = UVMaterial::default();
target.render_with_material(&uv_material, &self.camera, geometries, lights)
target.render_with_material(
&uv_material,
&self.camera,
geometries.map(|gm| &gm.geometry),
lights,
)
}
DebugType::Color => target.render_with_material(
&ColorMaterial::default(),
&self.camera,
geometries,
lights,
),
DebugType::None => target.render(
&self.camera,
self.models.iter().flat_map(|model| model.iter()),
geometries.map(|gm| &gm.geometry),
lights,
),
DebugType::None => target.render(&self.camera, geometries, lights),
};
if self.debug_toggle.enabled {

View file

@ -16,6 +16,8 @@ pub enum DebugType {
pub struct DebugUI {
ui: GUI,
pub show_bsp: bool,
pub show_props: bool,
pub shadows_enabled: bool,
pub directional_intensity: f32,
pub ambient_intensity: f32,
@ -28,6 +30,8 @@ impl DebugUI {
pub fn new(context: &Context) -> Self {
DebugUI {
ui: three_d::GUI::new(context),
show_bsp: true,
show_props: true,
shadows_enabled: false,
directional_intensity: 1.0,
ambient_intensity: 0.2,
@ -54,6 +58,10 @@ impl DebugUI {
ui.heading("Debug Panel");
ui.label(" toggle panel with <`>");
ui.label("Visibility options");
ui.checkbox(&mut self.show_bsp, "Map");
ui.checkbox(&mut self.show_props, "Props");
ui.label("Light options");
ui.add(
Slider::new(&mut self.ambient_intensity, 0.0..=1.0)