cleanup
This commit is contained in:
+132
-40
@@ -12,22 +12,22 @@ fn sized_text(ui: &mut egui::Ui, text: impl Into<String>, size: f32) {
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
|
||||
pub(crate) struct PreviousDebug {
|
||||
pub(crate) bounding_boxes: bool,
|
||||
pub(crate) disable_meshcull: bool,
|
||||
pub(crate) bounding_boxes: bool,
|
||||
pub(crate) disable_meshcull: bool,
|
||||
pub(crate) disable_meshscale1: bool,
|
||||
pub(crate) disable_meshscale2: bool,
|
||||
pub(crate) disable_taskcull: bool,
|
||||
pub(crate) brute_force: bool,
|
||||
pub(crate) disable_taskcull: bool,
|
||||
pub(crate) brute_force: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct GState {
|
||||
pub(crate) cursor_sensitivity: f32,
|
||||
pub(crate) move_speed: f32,
|
||||
pub(crate) move_speed: f32,
|
||||
|
||||
pub(crate) meshes: Vec<Mesh>,
|
||||
pub(crate) lights: Vec<Light>,
|
||||
pub(crate) csg: Vec<CSG>,
|
||||
pub(crate) csg: Vec<CSG>,
|
||||
|
||||
pub(crate) fps: [f64; 128],
|
||||
|
||||
@@ -38,11 +38,11 @@ impl Default for GState {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
cursor_sensitivity: 1.0,
|
||||
move_speed: 1.0,
|
||||
move_speed: 1.0,
|
||||
|
||||
meshes: vec![],
|
||||
lights: vec![],
|
||||
csg: vec![],
|
||||
csg: vec![],
|
||||
|
||||
fps: [0.0; 128],
|
||||
|
||||
@@ -58,31 +58,61 @@ pub(crate) fn gui_up(gui: &mut Gui, state: &mut GState) {
|
||||
.frame(Frame::default().fill(Color32::from_rgba_unmultiplied(50, 50, 50, 200)))
|
||||
.show(&ctx, |ui| {
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.add(egui::widgets::Label::new("Efficient Realtime Rendering of Complex Closed Form Implicit Surfaces Using Modern RTX Enabled GPUs"));
|
||||
ui.add(egui::widgets::Label::new(
|
||||
"Efficient Realtime Rendering of Complex Closed Form Implicit Surfaces \
|
||||
Using Modern RTX Enabled GPUs",
|
||||
));
|
||||
sized_text(ui, "Settings", 32.0);
|
||||
});
|
||||
ui.separator();
|
||||
egui::ScrollArea::vertical().show(ui, |ui| {
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.heading("Camera Control");
|
||||
ui.add(egui::Slider::new(&mut state.cursor_sensitivity, 0.0..=2.0).text("Mouse Sensitivity"));
|
||||
ui.add(egui::Slider::new(&mut state.move_speed, 0.0..=2.0).text("Movement Speed"));
|
||||
ui.add(
|
||||
egui::Slider::new(&mut state.cursor_sensitivity, 0.0..=2.0)
|
||||
.text("Mouse Sensitivity"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut state.move_speed, 0.0..=2.0)
|
||||
.text("Movement Speed"),
|
||||
);
|
||||
ui.heading("Meshes");
|
||||
let mut meshdel = vec![];
|
||||
for mesh in &mut state.meshes {
|
||||
ui.label(mesh.name.clone());
|
||||
meshdel.push(ui.small_button("remove mesh").clicked());
|
||||
ui.add(egui::Slider::new(&mut mesh.pos.x, -100.0..=100.0).text("Position.x"));
|
||||
ui.add(egui::Slider::new(&mut mesh.pos.y, -100.0..=100.0).text("Position.y"));
|
||||
ui.add(egui::Slider::new(&mut mesh.pos.z, -100.0..=100.0).text("Position.z"));
|
||||
ui.add(egui::Slider::new(&mut mesh.rot.x.0, 0.0..=360.0).text("Rotation.x"));
|
||||
ui.add(egui::Slider::new(&mut mesh.rot.y.0, 0.0..=360.0).text("Rotation.y"));
|
||||
ui.add(egui::Slider::new(&mut mesh.rot.z.0, 0.0..=360.0).text("Rotation.z"));
|
||||
ui.add(
|
||||
egui::Slider::new(&mut mesh.pos.x, -100.0..=100.0)
|
||||
.text("Position.x"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut mesh.pos.y, -100.0..=100.0)
|
||||
.text("Position.y"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut mesh.pos.z, -100.0..=100.0)
|
||||
.text("Position.z"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut mesh.rot.x.0, 0.0..=360.0)
|
||||
.text("Rotation.x"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut mesh.rot.y.0, 0.0..=360.0)
|
||||
.text("Rotation.y"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut mesh.rot.z.0, 0.0..=360.0)
|
||||
.text("Rotation.z"),
|
||||
);
|
||||
ui.add(egui::Slider::new(&mut mesh.scale.x, 0.0..=2.0).text("Scale.x"));
|
||||
ui.add(egui::Slider::new(&mut mesh.scale.y, 0.0..=2.0).text("Scale.y"));
|
||||
ui.add(egui::Slider::new(&mut mesh.scale.z, 0.0..=2.0).text("Scale.z"));
|
||||
}
|
||||
for i in meshdel.into_iter().enumerate().filter_map(|(a,b)| if b {Some(a)} else {None})
|
||||
for i in meshdel
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.filter_map(|(a, b)| if b { Some(a) } else { None })
|
||||
{
|
||||
state.meshes.remove(i);
|
||||
}
|
||||
@@ -91,17 +121,35 @@ pub(crate) fn gui_up(gui: &mut Gui, state: &mut GState) {
|
||||
for csg in &mut state.csg {
|
||||
ui.label(csg.name.clone());
|
||||
csgdel.push(ui.small_button("remove csg").clicked());
|
||||
ui.add(egui::Slider::new(&mut csg.pos.x, -100.0..=100.0).text("Position.x"));
|
||||
ui.add(egui::Slider::new(&mut csg.pos.y, -100.0..=100.0).text("Position.y"));
|
||||
ui.add(egui::Slider::new(&mut csg.pos.z, -100.0..=100.0).text("Position.z"));
|
||||
ui.add(egui::Slider::new(&mut csg.rot.x.0, 0.0..=360.0).text("Rotation.x"));
|
||||
ui.add(egui::Slider::new(&mut csg.rot.y.0, 0.0..=360.0).text("Rotation.y"));
|
||||
ui.add(egui::Slider::new(&mut csg.rot.z.0, 0.0..=360.0).text("Rotation.z"));
|
||||
ui.add(
|
||||
egui::Slider::new(&mut csg.pos.x, -100.0..=100.0)
|
||||
.text("Position.x"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut csg.pos.y, -100.0..=100.0)
|
||||
.text("Position.y"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut csg.pos.z, -100.0..=100.0)
|
||||
.text("Position.z"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut csg.rot.x.0, 0.0..=360.0).text("Rotation.x"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut csg.rot.y.0, 0.0..=360.0).text("Rotation.y"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut csg.rot.z.0, 0.0..=360.0).text("Rotation.z"),
|
||||
);
|
||||
ui.add(egui::Slider::new(&mut csg.scale.x, 0.0..=2.0).text("Scale.x"));
|
||||
ui.add(egui::Slider::new(&mut csg.scale.y, 0.0..=2.0).text("Scale.y"));
|
||||
ui.add(egui::Slider::new(&mut csg.scale.z, 0.0..=2.0).text("Scale.z"));
|
||||
}
|
||||
for i in csgdel.into_iter().enumerate().filter_map(|(a,b)| if b {Some(a)} else {None})
|
||||
for i in csgdel
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.filter_map(|(a, b)| if b { Some(a) } else { None })
|
||||
{
|
||||
state.csg.remove(i);
|
||||
}
|
||||
@@ -110,14 +158,32 @@ pub(crate) fn gui_up(gui: &mut Gui, state: &mut GState) {
|
||||
for light in &mut state.lights {
|
||||
ui.label("Light");
|
||||
lightdel.push(ui.small_button("remove light").clicked());
|
||||
ui.add(egui::Slider::new(&mut light.pos.x, -100.0..=100.0).text("Position.x"));
|
||||
ui.add(egui::Slider::new(&mut light.pos.y, -100.0..=100.0).text("Position.y"));
|
||||
ui.add(egui::Slider::new(&mut light.pos.z, -100.0..=100.0).text("Position.z"));
|
||||
ui.add(egui::Slider::new(&mut light.colour.x, 0.0..=1.0).text("Colour.r"));
|
||||
ui.add(egui::Slider::new(&mut light.colour.y, 0.0..=1.0).text("Colour.g"));
|
||||
ui.add(egui::Slider::new(&mut light.colour.z, 0.0..=1.0).text("Colour.b"));
|
||||
ui.add(
|
||||
egui::Slider::new(&mut light.pos.x, -100.0..=100.0)
|
||||
.text("Position.x"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut light.pos.y, -100.0..=100.0)
|
||||
.text("Position.y"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut light.pos.z, -100.0..=100.0)
|
||||
.text("Position.z"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut light.colour.x, 0.0..=1.0).text("Colour.r"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut light.colour.y, 0.0..=1.0).text("Colour.g"),
|
||||
);
|
||||
ui.add(
|
||||
egui::Slider::new(&mut light.colour.z, 0.0..=1.0).text("Colour.b"),
|
||||
);
|
||||
}
|
||||
for i in lightdel.into_iter().enumerate().filter_map(|(a,b)| if b {Some(a)} else {None})
|
||||
for i in lightdel
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.filter_map(|(a, b)| if b { Some(a) } else { None })
|
||||
{
|
||||
state.lights.remove(i);
|
||||
}
|
||||
@@ -125,18 +191,44 @@ pub(crate) fn gui_up(gui: &mut Gui, state: &mut GState) {
|
||||
state.lights.push(Light::default());
|
||||
}
|
||||
|
||||
let fps: PlotPoints = state.fps.iter().enumerate().map(|(x,y)| [x as f64,*y]).collect::<Vec<_>>().into();
|
||||
let fps: PlotPoints = state
|
||||
.fps
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(x, y)| [x as f64, *y])
|
||||
.collect::<Vec<_>>()
|
||||
.into();
|
||||
let line = Line::new(fps);
|
||||
ui.heading("FPS");
|
||||
Plot::new("fps").view_aspect(2.0).show(ui, |plot_ui| plot_ui.line(line));
|
||||
Plot::new("fps")
|
||||
.view_aspect(2.0)
|
||||
.show(ui, |plot_ui| plot_ui.line(line));
|
||||
|
||||
ui.heading("Debug");
|
||||
ui.toggle_value(&mut state.debug.bounding_boxes, "Render bounding boxes instead");
|
||||
ui.toggle_value(&mut state.debug.disable_meshcull, "Disable mesh shader culling");
|
||||
ui.toggle_value(&mut state.debug.disable_meshscale1, "Disable mesh shader scaling part 1");
|
||||
ui.toggle_value(&mut state.debug.disable_meshscale2, "Disable mesh shader scaling part 2");
|
||||
ui.toggle_value(&mut state.debug.disable_taskcull, "Disable task shader culling");
|
||||
ui.toggle_value(&mut state.debug.brute_force, "Brute force the render (use no new techniques)");
|
||||
ui.toggle_value(
|
||||
&mut state.debug.bounding_boxes,
|
||||
"Render bounding boxes instead",
|
||||
);
|
||||
ui.toggle_value(
|
||||
&mut state.debug.disable_meshcull,
|
||||
"Disable mesh shader culling",
|
||||
);
|
||||
ui.toggle_value(
|
||||
&mut state.debug.disable_meshscale1,
|
||||
"Disable mesh shader scaling part 1",
|
||||
);
|
||||
ui.toggle_value(
|
||||
&mut state.debug.disable_meshscale2,
|
||||
"Disable mesh shader scaling part 2",
|
||||
);
|
||||
ui.toggle_value(
|
||||
&mut state.debug.disable_taskcull,
|
||||
"Disable task shader culling",
|
||||
);
|
||||
ui.toggle_value(
|
||||
&mut state.debug.brute_force,
|
||||
"Brute force the render (use no new techniques)",
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+271
-274
File diff suppressed because it is too large
Load Diff
+379
-247
File diff suppressed because it is too large
Load Diff
+26
-23
@@ -1,13 +1,16 @@
|
||||
use std::fmt::Display;
|
||||
use std::io::{BufReader, Read};
|
||||
|
||||
use std::str::Chars;
|
||||
|
||||
use serde::de::{
|
||||
self, DeserializeSeed, EnumAccess, IntoDeserializer, MapAccess, SeqAccess, VariantAccess,
|
||||
Visitor,
|
||||
use std::{
|
||||
fmt::Display,
|
||||
io::{BufReader, Read},
|
||||
str::Chars,
|
||||
};
|
||||
|
||||
use serde::{
|
||||
de::{
|
||||
self, DeserializeSeed, EnumAccess, IntoDeserializer, MapAccess, SeqAccess, VariantAccess,
|
||||
Visitor,
|
||||
},
|
||||
forward_to_deserialize_any, Deserialize,
|
||||
};
|
||||
use serde::{forward_to_deserialize_any, Deserialize};
|
||||
use utf8::BufReadDecoder;
|
||||
|
||||
type Result<T> = core::result::Result<T, Error>;
|
||||
@@ -50,9 +53,9 @@ impl serde::ser::Error for Error {
|
||||
pub(crate) struct Deserializer<'de> {
|
||||
// This string starts with the input data and characters are truncated off
|
||||
// the beginning as data is parsed.
|
||||
input: BufReadDecoder<BufReader<&'de mut dyn Read>>,
|
||||
input: BufReadDecoder<BufReader<&'de mut dyn Read>>,
|
||||
read_buf: String,
|
||||
peek: Option<(char, usize)>,
|
||||
peek: Option<(char, usize)>,
|
||||
}
|
||||
|
||||
impl<'de> Deserializer<'de> {
|
||||
@@ -63,9 +66,9 @@ impl<'de> Deserializer<'de> {
|
||||
|
||||
pub(crate) fn from_reader(input: &'de mut dyn Read) -> Self {
|
||||
Deserializer {
|
||||
input: BufReadDecoder::new(BufReader::new(input)),
|
||||
input: BufReadDecoder::new(BufReader::new(input)),
|
||||
read_buf: String::new(),
|
||||
peek: None,
|
||||
peek: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -128,16 +131,16 @@ impl<'de> Deserializer<'de> {
|
||||
Ok(c) => {
|
||||
self.peek = Some(c);
|
||||
return Ok(c);
|
||||
}
|
||||
},
|
||||
Err(Error::Eof) => match self.input.next_strict() {
|
||||
Some(e) => {
|
||||
match e {
|
||||
Ok(s) => {
|
||||
s.clone_into(&mut self.read_buf);
|
||||
}
|
||||
},
|
||||
Err(e) => return Err(Error::UTF8(format!("{e}"))),
|
||||
};
|
||||
}
|
||||
},
|
||||
None => return Err(Error::Eof),
|
||||
},
|
||||
Err(e) => return Err(e),
|
||||
@@ -168,16 +171,16 @@ impl<'de> Deserializer<'de> {
|
||||
let out = self.read_buf[..len].to_string();
|
||||
self.read_buf = self.read_buf[len + 1..].to_string();
|
||||
return Ok(out);
|
||||
}
|
||||
},
|
||||
None => match self.input.next_strict() {
|
||||
Some(e) => {
|
||||
match e {
|
||||
Ok(s) => {
|
||||
s.clone_into(&mut self.read_buf);
|
||||
}
|
||||
},
|
||||
Err(e) => return Err(Error::UTF8(format!("{e}"))),
|
||||
};
|
||||
}
|
||||
},
|
||||
None => return Err(Error::Eof),
|
||||
},
|
||||
}
|
||||
@@ -188,6 +191,10 @@ impl<'de> Deserializer<'de> {
|
||||
impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> {
|
||||
type Error = Error;
|
||||
|
||||
forward_to_deserialize_any! {
|
||||
bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char bytes byte_buf option unit unit_struct
|
||||
}
|
||||
|
||||
// Look at the input data to decide what Serde data model type to
|
||||
// deserialize as. Not all data formats are able to support this operation.
|
||||
// Formats that support `deserialize_any` are known as self-describing.
|
||||
@@ -371,10 +378,6 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> {
|
||||
{
|
||||
self.deserialize_any(visitor)
|
||||
}
|
||||
|
||||
forward_to_deserialize_any! {
|
||||
bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char bytes byte_buf option unit unit_struct
|
||||
}
|
||||
}
|
||||
|
||||
// In order to handle commas correctly when deserializing a JSON array or map,
|
||||
|
||||
+30
-30
@@ -16,41 +16,41 @@ use vulkano::{
|
||||
pipeline::graphics::vertex_input::Vertex,
|
||||
};
|
||||
|
||||
use crate::instruction_set::InstructionSet;
|
||||
use crate::{mcsg_deserialise::from_reader, MemoryAllocator};
|
||||
use crate::{instruction_set::InstructionSet, mcsg_deserialise::from_reader, MemoryAllocator};
|
||||
|
||||
pub(crate) const PLATONIC_SOLIDS: [(&str, &[u8]); 1] = [("Buny", include_bytes!("bunny.obj"))];
|
||||
pub(crate) const CSG_SOLIDS: [(&str, &[u8]); 1] =
|
||||
[("Primitives", include_bytes!("primitive.mcsg"))];
|
||||
|
||||
// We now create a buffer that will store the shape of our triangle.
|
||||
// We use #[repr(C)] here to force rustc to not do anything funky with our data, although for this
|
||||
// particular example, it doesn't actually change the in-memory representation.
|
||||
// We use #[repr(C)] here to force rustc to not do anything funky with our data,
|
||||
// although for this particular example, it doesn't actually change the
|
||||
// in-memory representation.
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Default, Zeroable, Pod, Vertex)]
|
||||
pub(crate) struct OVertex {
|
||||
#[format(R32G32B32_SFLOAT)]
|
||||
position: [f32; 3],
|
||||
#[format(R32G32B32_SFLOAT)]
|
||||
normal: [f32; 3],
|
||||
normal: [f32; 3],
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct Mesh {
|
||||
pub(crate) name: String,
|
||||
pub(crate) name: String,
|
||||
pub(crate) vertices: Subbuffer<[OVertex]>,
|
||||
pub(crate) indices: Subbuffer<[u32]>,
|
||||
pub(crate) pos: Point3<f32>,
|
||||
pub(crate) rot: Euler<Deg<f32>>,
|
||||
pub(crate) scale: Vector3<f32>,
|
||||
pub(crate) indices: Subbuffer<[u32]>,
|
||||
pub(crate) pos: Point3<f32>,
|
||||
pub(crate) rot: Euler<Deg<f32>>,
|
||||
pub(crate) scale: Vector3<f32>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct CSG {
|
||||
pub(crate) name: String,
|
||||
pub(crate) name: String,
|
||||
pub(crate) parts: Vec<CSGPart>,
|
||||
pub(crate) pos: Point3<f32>,
|
||||
pub(crate) rot: Euler<Deg<f32>>,
|
||||
pub(crate) pos: Point3<f32>,
|
||||
pub(crate) rot: Euler<Deg<f32>>,
|
||||
pub(crate) scale: Vector3<f32>,
|
||||
}
|
||||
|
||||
@@ -78,10 +78,10 @@ pub(crate) enum Inputs {
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) struct CSGPart {
|
||||
pub(crate) code: u16,
|
||||
pub(crate) opcode: InstructionSet,
|
||||
pub(crate) code: u16,
|
||||
pub(crate) opcode: InstructionSet,
|
||||
pub(crate) constants: Vec<Inputs>,
|
||||
pub(crate) material: Option<Mat4>,
|
||||
pub(crate) material: Option<Mat4>,
|
||||
}
|
||||
|
||||
impl CSGPart {
|
||||
@@ -130,9 +130,9 @@ pub(crate) fn load_obj(
|
||||
let mut temp_hash_map = HashMap::<(u32, u32), u32>::new();
|
||||
|
||||
// We're gonna have to remap all the indices that OBJ uses. Annoying.
|
||||
// Get each pair of vertex position to vertex normal and assign it a new index. This might duplicate
|
||||
// vertices or normals but each *pair* needs a unique index
|
||||
// Uses the hash map to check that we're not duplicating unnecessarily
|
||||
// Get each pair of vertex position to vertex normal and assign it a new index.
|
||||
// This might duplicate vertices or normals but each *pair* needs a unique
|
||||
// index Uses the hash map to check that we're not duplicating unnecessarily
|
||||
for g in &object.objects[0].groups {
|
||||
for p in &g.polys {
|
||||
for v in &p.0 {
|
||||
@@ -144,7 +144,7 @@ pub(crate) fn load_obj(
|
||||
} else {
|
||||
vertices.push(OVertex {
|
||||
position: object.position[mapping.0 as usize],
|
||||
normal: object.normal[mapping.1 as usize],
|
||||
normal: object.normal[mapping.1 as usize],
|
||||
});
|
||||
temp_hash_map.insert(mapping, (vertices.len() - 1) as u32);
|
||||
indices.push((vertices.len() - 1) as u32);
|
||||
@@ -194,7 +194,7 @@ pub(crate) fn load_obj(
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct MCSG {
|
||||
object: Vec<MCSGObject>,
|
||||
csg: Vec<MCSGCSG>,
|
||||
csg: Vec<MCSGCSG>,
|
||||
}
|
||||
type MCSGObject = HashMap<String, String>;
|
||||
type MCSGCSG = Vec<MCSGCSGPart>;
|
||||
@@ -234,8 +234,8 @@ fn point3_from_string(input: &str) -> Result<Point3<f32>, String> {
|
||||
}
|
||||
struct TRS {
|
||||
translation: Point3<f32>,
|
||||
rotation: Matrix3<f32>,
|
||||
scale: Vector3<f32>,
|
||||
rotation: Matrix3<f32>,
|
||||
scale: Vector3<f32>,
|
||||
}
|
||||
|
||||
fn get_trs(o: &HashMap<String, String>) -> Result<TRS, String> {
|
||||
@@ -246,13 +246,13 @@ fn get_trs(o: &HashMap<String, String>) -> Result<TRS, String> {
|
||||
.map(point3_from_string)
|
||||
.transpose()?
|
||||
.unwrap_or(Point3::origin()),
|
||||
rotation: o
|
||||
rotation: o
|
||||
.get("r")
|
||||
.map(String::as_str)
|
||||
.map(matrix3_from_string)
|
||||
.transpose()?
|
||||
.unwrap_or(Matrix3::identity()),
|
||||
scale: o
|
||||
scale: o
|
||||
.get("s")
|
||||
.map(String::as_str)
|
||||
.map(vector3_from_string)
|
||||
@@ -379,8 +379,8 @@ pub(crate) fn load_csg(
|
||||
let _rgb = get_rgb(inpart)?;
|
||||
let _trs = get_trs(inpart)?;
|
||||
let _half = get_half(inpart)?;
|
||||
}
|
||||
_ => {} //return Err("unknown type of csg".to_owned()),
|
||||
},
|
||||
_ => {}, //return Err("unknown type of csg".to_owned()),
|
||||
}
|
||||
Ok(csgpart)
|
||||
})
|
||||
@@ -407,7 +407,7 @@ pub(crate) fn load_csg(
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct Light {
|
||||
pub(crate) pos: Point3<f32>,
|
||||
pub(crate) pos: Point3<f32>,
|
||||
pub(crate) colour: Vector3<f32>,
|
||||
}
|
||||
|
||||
@@ -415,7 +415,7 @@ impl Light {
|
||||
pub(crate) fn new(pos: [f32; 3], colour: [f32; 3], intensity: f32) -> Light {
|
||||
let c: Vector3<f32> = colour.into();
|
||||
Light {
|
||||
pos: pos.into(),
|
||||
pos: pos.into(),
|
||||
colour: c * intensity,
|
||||
}
|
||||
}
|
||||
@@ -424,7 +424,7 @@ impl Light {
|
||||
impl Default for Light {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
pos: Point3::origin(),
|
||||
pos: Point3::origin(),
|
||||
colour: Vector3 {
|
||||
x: 1.,
|
||||
y: 1.,
|
||||
|
||||
Reference in New Issue
Block a user