mirror of
https://codeberg.org/icewind/vbspview.git
synced 2026-06-03 18:24:09 +02:00
add bsp/prop toggle
This commit is contained in:
parent
7dec8aa2c6
commit
7b627c1140
3 changed files with 36 additions and 13 deletions
|
|
@ -85,7 +85,7 @@ fn model_to_model(model: Handle<vbsp::data::Model>, loader: &Loader) -> CpuModel
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
CpuModel {
|
CpuModel {
|
||||||
name: "".to_string(),
|
name: "bsp".to_string(),
|
||||||
geometries,
|
geometries,
|
||||||
materials,
|
materials,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -105,14 +105,23 @@ impl<C: Control> Renderer<C> {
|
||||||
let geometries = self
|
let geometries = self
|
||||||
.models
|
.models
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|model| model.iter())
|
.enumerate()
|
||||||
.map(|gm| &gm.geometry);
|
.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 {
|
match self.gui.debug_type {
|
||||||
DebugType::Normal => target.render_with_material(
|
DebugType::Normal => target.render_with_material(
|
||||||
&NormalMaterial::default(),
|
&NormalMaterial::default(),
|
||||||
&self.camera,
|
&self.camera,
|
||||||
geometries,
|
geometries.map(|gm| &gm.geometry),
|
||||||
lights,
|
lights,
|
||||||
),
|
),
|
||||||
DebugType::Depth => {
|
DebugType::Depth => {
|
||||||
|
|
@ -125,28 +134,34 @@ impl<C: Control> Renderer<C> {
|
||||||
DebugType::Orm => target.render_with_material(
|
DebugType::Orm => target.render_with_material(
|
||||||
&ORMMaterial::default(),
|
&ORMMaterial::default(),
|
||||||
&self.camera,
|
&self.camera,
|
||||||
geometries,
|
geometries.map(|gm| &gm.geometry),
|
||||||
lights,
|
lights,
|
||||||
),
|
),
|
||||||
DebugType::Position => {
|
DebugType::Position => {
|
||||||
let position_material = PositionMaterial::default();
|
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 => {
|
DebugType::Uv => {
|
||||||
let uv_material = UVMaterial::default();
|
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(
|
DebugType::Color => target.render_with_material(
|
||||||
&ColorMaterial::default(),
|
&ColorMaterial::default(),
|
||||||
&self.camera,
|
&self.camera,
|
||||||
geometries,
|
geometries.map(|gm| &gm.geometry),
|
||||||
lights,
|
|
||||||
),
|
|
||||||
DebugType::None => target.render(
|
|
||||||
&self.camera,
|
|
||||||
self.models.iter().flat_map(|model| model.iter()),
|
|
||||||
lights,
|
lights,
|
||||||
),
|
),
|
||||||
|
DebugType::None => target.render(&self.camera, geometries, lights),
|
||||||
};
|
};
|
||||||
|
|
||||||
if self.debug_toggle.enabled {
|
if self.debug_toggle.enabled {
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ pub enum DebugType {
|
||||||
|
|
||||||
pub struct DebugUI {
|
pub struct DebugUI {
|
||||||
ui: GUI,
|
ui: GUI,
|
||||||
|
pub show_bsp: bool,
|
||||||
|
pub show_props: bool,
|
||||||
pub shadows_enabled: bool,
|
pub shadows_enabled: bool,
|
||||||
pub directional_intensity: f32,
|
pub directional_intensity: f32,
|
||||||
pub ambient_intensity: f32,
|
pub ambient_intensity: f32,
|
||||||
|
|
@ -28,6 +30,8 @@ impl DebugUI {
|
||||||
pub fn new(context: &Context) -> Self {
|
pub fn new(context: &Context) -> Self {
|
||||||
DebugUI {
|
DebugUI {
|
||||||
ui: three_d::GUI::new(context),
|
ui: three_d::GUI::new(context),
|
||||||
|
show_bsp: true,
|
||||||
|
show_props: true,
|
||||||
shadows_enabled: false,
|
shadows_enabled: false,
|
||||||
directional_intensity: 1.0,
|
directional_intensity: 1.0,
|
||||||
ambient_intensity: 0.2,
|
ambient_intensity: 0.2,
|
||||||
|
|
@ -54,6 +58,10 @@ impl DebugUI {
|
||||||
ui.heading("Debug Panel");
|
ui.heading("Debug Panel");
|
||||||
ui.label(" toggle panel with <`>");
|
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.label("Light options");
|
||||||
ui.add(
|
ui.add(
|
||||||
Slider::new(&mut self.ambient_intensity, 0.0..=1.0)
|
Slider::new(&mut self.ambient_intensity, 0.0..=1.0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue