Working version of original project
This commit is contained in:
@@ -1 +1,2 @@
|
|||||||
/target
|
/target
|
||||||
|
pipeline_cache.bin
|
||||||
|
|||||||
Generated
+17
-10
@@ -1,6 +1,6 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ab_glyph"
|
name = "ab_glyph"
|
||||||
@@ -546,6 +546,17 @@ dependencies = [
|
|||||||
"winit",
|
"winit",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "egui_plot"
|
||||||
|
version = "0.30.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c226cae80a6ee10c4d3aaf9e33bd9e9b2f1c0116b6036bdc2a1cfc9d2d0dcc10"
|
||||||
|
dependencies = [
|
||||||
|
"ahash",
|
||||||
|
"egui",
|
||||||
|
"emath",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "egui_winit_vulkano"
|
name = "egui_winit_vulkano"
|
||||||
version = "0.27.0"
|
version = "0.27.0"
|
||||||
@@ -621,6 +632,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"egui",
|
"egui",
|
||||||
|
"egui_plot",
|
||||||
"egui_winit_vulkano",
|
"egui_winit_vulkano",
|
||||||
"foldhash",
|
"foldhash",
|
||||||
"glam",
|
"glam",
|
||||||
@@ -2083,9 +2095,9 @@ checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.93"
|
version = "2.0.94"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9c786062daee0d6db1132800e623df74274a0a87322d8e183338e01b3d98d058"
|
checksum = "987bc0be1cdea8b10216bd06e2ca407d40b9543468fafd3ddfb02f36e77f71f3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -2897,9 +2909,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winnow"
|
name = "winnow"
|
||||||
version = "0.6.20"
|
version = "0.6.21"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b"
|
checksum = "e6f5bb5257f2407a5425c6e749bfd9692192a73e70a6060516ac04f889087d68"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
@@ -3101,8 +3113,3 @@ dependencies = [
|
|||||||
name = "vulkano-taskgraph"
|
name = "vulkano-taskgraph"
|
||||||
version = "0.34.0"
|
version = "0.34.0"
|
||||||
source = "git+https://github.com/vulkano-rs/vulkano#ea30f65280360b1e1bc907cd42d4eb355fed3c9d"
|
source = "git+https://github.com/vulkano-rs/vulkano#ea30f65280360b1e1bc907cd42d4eb355fed3c9d"
|
||||||
|
|
||||||
[[patch.unused]]
|
|
||||||
name = "vulkano-win"
|
|
||||||
version = "0.34.0"
|
|
||||||
source = "git+https://github.com/vulkano-rs/vulkano#ea30f65280360b1e1bc907cd42d4eb355fed3c9d"
|
|
||||||
|
|||||||
+1
-1
@@ -22,6 +22,7 @@ glam = "0.29"
|
|||||||
|
|
||||||
egui = "0.30"
|
egui = "0.30"
|
||||||
egui_winit_vulkano = "0.27"
|
egui_winit_vulkano = "0.27"
|
||||||
|
egui_plot = "0.30.0"
|
||||||
|
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
@@ -40,5 +41,4 @@ vulkano-macros = { git = "https://github.com/vulkano-rs/vulkano" }
|
|||||||
vulkano-shaders = { git = "https://github.com/vulkano-rs/vulkano" }
|
vulkano-shaders = { git = "https://github.com/vulkano-rs/vulkano" }
|
||||||
vulkano-taskgraph = { git = "https://github.com/vulkano-rs/vulkano" }
|
vulkano-taskgraph = { git = "https://github.com/vulkano-rs/vulkano" }
|
||||||
vulkano-util = { git = "https://github.com/vulkano-rs/vulkano" }
|
vulkano-util = { git = "https://github.com/vulkano-rs/vulkano" }
|
||||||
vulkano-win = { git = "https://github.com/vulkano-rs/vulkano" }
|
|
||||||
egui_winit_vulkano = { git = "https://github.com/Molive-0/egui_winit_vulkano" }
|
egui_winit_vulkano = { git = "https://github.com/Molive-0/egui_winit_vulkano" }
|
||||||
|
|||||||
+9
-14
@@ -1,10 +1,8 @@
|
|||||||
use egui::{
|
use egui::{Color32, Frame, Id};
|
||||||
plot::{Line, Plot, PlotPoints},
|
use egui_plot::{Line, Plot, PlotPoints};
|
||||||
Color32, Frame, Id,
|
|
||||||
};
|
|
||||||
use egui_winit_vulkano::Gui;
|
use egui_winit_vulkano::Gui;
|
||||||
|
|
||||||
use crate::objects::{Light, Mesh, CSG};
|
use crate::objects::{CSG, Light, Mesh};
|
||||||
|
|
||||||
fn sized_text(ui: &mut egui::Ui, text: impl Into<String>, size: f32) {
|
fn sized_text(ui: &mut egui::Ui, text: impl Into<String>, size: f32) {
|
||||||
ui.label(egui::RichText::new(text).size(size));
|
ui.label(egui::RichText::new(text).size(size));
|
||||||
@@ -94,16 +92,13 @@ pub(crate) fn gui_up(gui: &mut Gui, state: &mut GState) {
|
|||||||
.text("Position.z"),
|
.text("Position.z"),
|
||||||
);
|
);
|
||||||
ui.add(
|
ui.add(
|
||||||
egui::Slider::new(&mut mesh.rot.x.0, 0.0..=360.0)
|
egui::Slider::new(&mut mesh.rot.x, 0.0..=360.0).text("Rotation.x"),
|
||||||
.text("Rotation.x"),
|
|
||||||
);
|
);
|
||||||
ui.add(
|
ui.add(
|
||||||
egui::Slider::new(&mut mesh.rot.y.0, 0.0..=360.0)
|
egui::Slider::new(&mut mesh.rot.y, 0.0..=360.0).text("Rotation.y"),
|
||||||
.text("Rotation.y"),
|
|
||||||
);
|
);
|
||||||
ui.add(
|
ui.add(
|
||||||
egui::Slider::new(&mut mesh.rot.z.0, 0.0..=360.0)
|
egui::Slider::new(&mut mesh.rot.z, 0.0..=360.0).text("Rotation.z"),
|
||||||
.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.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.y, 0.0..=2.0).text("Scale.y"));
|
||||||
@@ -134,13 +129,13 @@ pub(crate) fn gui_up(gui: &mut Gui, state: &mut GState) {
|
|||||||
.text("Position.z"),
|
.text("Position.z"),
|
||||||
);
|
);
|
||||||
ui.add(
|
ui.add(
|
||||||
egui::Slider::new(&mut csg.rot.x.0, 0.0..=360.0).text("Rotation.x"),
|
egui::Slider::new(&mut csg.rot.x, 0.0..=360.0).text("Rotation.x"),
|
||||||
);
|
);
|
||||||
ui.add(
|
ui.add(
|
||||||
egui::Slider::new(&mut csg.rot.y.0, 0.0..=360.0).text("Rotation.y"),
|
egui::Slider::new(&mut csg.rot.y, 0.0..=360.0).text("Rotation.y"),
|
||||||
);
|
);
|
||||||
ui.add(
|
ui.add(
|
||||||
egui::Slider::new(&mut csg.rot.z.0, 0.0..=360.0).text("Rotation.z"),
|
egui::Slider::new(&mut csg.rot.z, 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.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.y, 0.0..=2.0).text("Scale.y"));
|
||||||
|
|||||||
+36
-120
@@ -1,9 +1,6 @@
|
|||||||
use cgmath::{Array, ElementWise, InnerSpace, MetricSpace, VectorSpace};
|
use glam::{self, FloatExt, Mat2, Mat3, Mat4, Vec2, Vec3, Vec4};
|
||||||
|
|
||||||
use crate::{
|
use crate::{CSG, Float, instruction_set::InstructionSet::*, objects::Inputs};
|
||||||
instruction_set::InstructionSet::*, objects::Inputs, Float, Mat2, Mat3, Mat4, Vec2, Vec3, Vec4,
|
|
||||||
CSG,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub(crate) struct Interpreter<'csg> {
|
pub(crate) struct Interpreter<'csg> {
|
||||||
@@ -169,85 +166,61 @@ impl<'csg> Interpreter<'csg> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! mul {
|
macro_rules! mul {
|
||||||
($self:ident, $instruction:ident, $type1:ty,Float) => {
|
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
|
||||||
let in2: Float = $self.pull($instruction.constants[1]);
|
|
||||||
$self.push(in1 * in2);
|
|
||||||
};
|
|
||||||
($self:ident, $instruction:ident, $type1:ty, $type2:ty) => {
|
($self:ident, $instruction:ident, $type1:ty, $type2:ty) => {
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
let in1: $type1 = $self.pull($instruction.constants[0]);
|
||||||
let in2: $type2 = $self.pull($instruction.constants[1]);
|
let in2: $type2 = $self.pull($instruction.constants[1]);
|
||||||
$self.push(in1.mul_element_wise(in2));
|
$self.push(in1 * in2);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! div {
|
macro_rules! div {
|
||||||
($self:ident, $instruction:ident, $type1:ty,Float) => {
|
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
|
||||||
let in2: Float = $self.pull($instruction.constants[1]);
|
|
||||||
$self.push(in1 / in2);
|
|
||||||
};
|
|
||||||
($self:ident, $instruction:ident, $type1:ty, $type2:ty) => {
|
($self:ident, $instruction:ident, $type1:ty, $type2:ty) => {
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
let in1: $type1 = $self.pull($instruction.constants[0]);
|
||||||
let in2: $type2 = $self.pull($instruction.constants[1]);
|
let in2: $type2 = $self.pull($instruction.constants[1]);
|
||||||
$self.push(in1.div_element_wise(in2));
|
$self.push(in1 / in2);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! add {
|
macro_rules! add {
|
||||||
($self:ident, $instruction:ident,Float,Float) => {
|
|
||||||
let in1: Float = $self.pull($instruction.constants[0]);
|
|
||||||
let in2: Float = $self.pull($instruction.constants[1]);
|
|
||||||
$self.push(in1 + in2);
|
|
||||||
};
|
|
||||||
($self:ident, $instruction:ident, $type1:ty, $type2:ty) => {
|
($self:ident, $instruction:ident, $type1:ty, $type2:ty) => {
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
let in1: $type1 = $self.pull($instruction.constants[0]);
|
||||||
let in2: $type2 = $self.pull($instruction.constants[1]);
|
let in2: $type2 = $self.pull($instruction.constants[1]);
|
||||||
$self.push(in1.add_element_wise(in2));
|
$self.push(in1 + in2);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! sub {
|
macro_rules! sub {
|
||||||
($self:ident, $instruction:ident,Float,Float) => {
|
|
||||||
let in1: Float = $self.pull($instruction.constants[0]);
|
|
||||||
let in2: Float = $self.pull($instruction.constants[1]);
|
|
||||||
$self.push(in1 - in2);
|
|
||||||
};
|
|
||||||
($self:ident, $instruction:ident, $type1:ty, $type2:ty) => {
|
($self:ident, $instruction:ident, $type1:ty, $type2:ty) => {
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
let in1: $type1 = $self.pull($instruction.constants[0]);
|
||||||
let in2: $type2 = $self.pull($instruction.constants[1]);
|
let in2: $type2 = $self.pull($instruction.constants[1]);
|
||||||
$self.push(in1.sub_element_wise(in2));
|
$self.push(in1 - in2);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! modulo {
|
macro_rules! modulo {
|
||||||
($self:ident, $instruction:ident,Float,Float) => {
|
|
||||||
let in1: Float = $self.pull($instruction.constants[0]);
|
|
||||||
let in2: Float = $self.pull($instruction.constants[1]);
|
|
||||||
$self.push(in1 % in2);
|
|
||||||
};
|
|
||||||
($self:ident, $instruction:ident, $type1:ty, $type2:ty) => {
|
($self:ident, $instruction:ident, $type1:ty, $type2:ty) => {
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
let in1: $type1 = $self.pull($instruction.constants[0]);
|
||||||
let in2: $type2 = $self.pull($instruction.constants[1]);
|
let in2: $type2 = $self.pull($instruction.constants[1]);
|
||||||
$self.push(in1.rem_element_wise(in2));
|
$self.push(in1 % in2);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! pow {
|
macro_rules! pow {
|
||||||
($self:ident, $instruction:ident,Float,Float) => {
|
|
||||||
let in1: Float = $self.pull($instruction.constants[0]);
|
|
||||||
let in2: Float = $self.pull($instruction.constants[1]);
|
|
||||||
$self.push(in1.powf(in2));
|
|
||||||
};
|
|
||||||
($self:ident, $instruction:ident, $type1:ty,Float) => {
|
($self:ident, $instruction:ident, $type1:ty,Float) => {
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
let in1: $type1 = $self.pull($instruction.constants[0]);
|
||||||
let in2: Float = $self.pull($instruction.constants[1]);
|
let in2: Float = $self.pull($instruction.constants[1]);
|
||||||
$self.push(in1.map(|x| x.powf(in2)));
|
$self.push(in1.powf(in2));
|
||||||
};
|
};
|
||||||
($self:ident, $instruction:ident, $type1:ty, $type2:ty) => {
|
($self:ident, $instruction:ident, $type1:ty, $type2:ty) => {
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
let in1: $type1 = $self.pull($instruction.constants[0]);
|
||||||
let in2: $type2 = $self.pull($instruction.constants[1]);
|
let in2: $type2 = $self.pull($instruction.constants[1]);
|
||||||
$self.push(in1.zip(in2, Float::powf));
|
$self.push(<$type1>::from_slice(
|
||||||
|
&in1.to_array()
|
||||||
|
.iter()
|
||||||
|
.zip(in2.to_array().iter())
|
||||||
|
.map(|(x, y)| x.powf(*y))
|
||||||
|
.collect::<Vec<_>>(),
|
||||||
|
));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,17 +257,11 @@ macro_rules! clamp {
|
|||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
let in1: $type1 = $self.pull($instruction.constants[0]);
|
||||||
let in2: $type2 = $self.pull($instruction.constants[1]);
|
let in2: $type2 = $self.pull($instruction.constants[1]);
|
||||||
let in3: $type3 = $self.pull($instruction.constants[2]);
|
let in3: $type3 = $self.pull($instruction.constants[2]);
|
||||||
$self.push(in1.zip(in2, Float::max).zip(in3, Float::min));
|
$self.push(in1.clamp(in2, in3));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! mix {
|
macro_rules! mix {
|
||||||
($self:ident, $instruction:ident,Float,Float,Float) => {
|
|
||||||
let in1: Float = $self.pull($instruction.constants[0]);
|
|
||||||
let in2: Float = $self.pull($instruction.constants[1]);
|
|
||||||
let in3: Float = $self.pull($instruction.constants[2]);
|
|
||||||
$self.push((in1 * ((1 as Float) - in3)) + (in2 * in3));
|
|
||||||
};
|
|
||||||
($self:ident, $instruction:ident, $type1:ty, $type2:ty,Float) => {
|
($self:ident, $instruction:ident, $type1:ty, $type2:ty,Float) => {
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
let in1: $type1 = $self.pull($instruction.constants[0]);
|
||||||
let in2: $type2 = $self.pull($instruction.constants[1]);
|
let in2: $type2 = $self.pull($instruction.constants[1]);
|
||||||
@@ -305,54 +272,37 @@ macro_rules! mix {
|
|||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
let in1: $type1 = $self.pull($instruction.constants[0]);
|
||||||
let in2: $type2 = $self.pull($instruction.constants[1]);
|
let in2: $type2 = $self.pull($instruction.constants[1]);
|
||||||
let in3: $type3 = $self.pull($instruction.constants[2]);
|
let in3: $type3 = $self.pull($instruction.constants[2]);
|
||||||
$self.push(
|
$self.push((in1 * (<$type3>::splat(1 as Float) - in3)) + (in2 * in3));
|
||||||
(in1.mul_element_wise(<$type3>::from_value(1 as Float).sub_element_wise(in3)))
|
|
||||||
+ (in2.mul_element_wise(in3)),
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! fma {
|
macro_rules! fma {
|
||||||
($self:ident, $instruction:ident,Float,Float,Float) => {
|
|
||||||
let in1: Float = $self.pull($instruction.constants[0]);
|
|
||||||
let in2: Float = $self.pull($instruction.constants[1]);
|
|
||||||
let in3: Float = $self.pull($instruction.constants[2]);
|
|
||||||
$self.push(in1.mul_add(in2, in3));
|
|
||||||
};
|
|
||||||
($self:ident, $instruction:ident, $type1:ty, $type2:ty, $type3:ty) => {
|
($self:ident, $instruction:ident, $type1:ty, $type2:ty, $type3:ty) => {
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
let in1: $type1 = $self.pull($instruction.constants[0]);
|
||||||
let in2: $type1 = $self.pull($instruction.constants[1]);
|
let in2: $type1 = $self.pull($instruction.constants[1]);
|
||||||
let in3: $type3 = $self.pull($instruction.constants[2]);
|
let in3: $type3 = $self.pull($instruction.constants[2]);
|
||||||
$self.push((in1.mul_element_wise(in2)) + in3);
|
$self.push(in1.mul_add(in2, in3));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! square {
|
macro_rules! square {
|
||||||
($self:ident, $instruction:ident,Float) => {
|
|
||||||
let in1: Float = $self.pull($instruction.constants[0]);
|
|
||||||
$self.push(in1 * in1);
|
|
||||||
};
|
|
||||||
($self:ident, $instruction:ident, $type1:ty) => {
|
($self:ident, $instruction:ident, $type1:ty) => {
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
let in1: $type1 = $self.pull($instruction.constants[0]);
|
||||||
$self.push(in1.mul_element_wise(in1));
|
$self.push(in1 * in1);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! cube {
|
macro_rules! cube {
|
||||||
($self:ident, $instruction:ident,Float) => {
|
|
||||||
let in1: Float = $self.pull($instruction.constants[0]);
|
|
||||||
$self.push(in1 * in1 * in1);
|
|
||||||
};
|
|
||||||
($self:ident, $instruction:ident, $type1:ty) => {
|
($self:ident, $instruction:ident, $type1:ty) => {
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
let in1: $type1 = $self.pull($instruction.constants[0]);
|
||||||
$self.push(in1.mul_element_wise(in1).mul_element_wise(in1));
|
$self.push(in1 * in1 * in1);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! len {
|
macro_rules! len {
|
||||||
($self:ident, $instruction:ident, $type1:ty) => {
|
($self:ident, $instruction:ident, $type1:ty) => {
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
let in1: $type1 = $self.pull($instruction.constants[0]);
|
||||||
$self.push(in1.magnitude());
|
$self.push(in1.length());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,13 +328,9 @@ macro_rules! matinvert {
|
|||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! absolute {
|
macro_rules! absolute {
|
||||||
($self:ident, $instruction:ident,Float) => {
|
|
||||||
let in1: Float = $self.pull($instruction.constants[0]);
|
|
||||||
$self.push(in1.abs());
|
|
||||||
};
|
|
||||||
($self:ident, $instruction:ident, $type1:ty) => {
|
($self:ident, $instruction:ident, $type1:ty) => {
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
let in1: $type1 = $self.pull($instruction.constants[0]);
|
||||||
$self.push(in1.map(Float::abs));
|
$self.push(in1.abs());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,35 +351,27 @@ macro_rules! sign {
|
|||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! floor {
|
macro_rules! floor {
|
||||||
($self:ident, $instruction:ident,Float) => {
|
|
||||||
let in1: Float = $self.pull($instruction.constants[0]);
|
|
||||||
$self.push(in1.floor());
|
|
||||||
};
|
|
||||||
($self:ident, $instruction:ident, $type1:ty) => {
|
($self:ident, $instruction:ident, $type1:ty) => {
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
let in1: $type1 = $self.pull($instruction.constants[0]);
|
||||||
$self.push(in1.map(Float::floor));
|
$self.push(in1.floor());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! ceiling {
|
macro_rules! ceiling {
|
||||||
($self:ident, $instruction:ident,Float) => {
|
|
||||||
let in1: Float = $self.pull($instruction.constants[0]);
|
|
||||||
$self.push(in1.ceil());
|
|
||||||
};
|
|
||||||
($self:ident, $instruction:ident, $type1:ty) => {
|
($self:ident, $instruction:ident, $type1:ty) => {
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
let in1: $type1 = $self.pull($instruction.constants[0]);
|
||||||
$self.push(in1.map(Float::ceil));
|
$self.push(in1.ceil());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! fract {
|
macro_rules! fract {
|
||||||
($self:ident, $instruction:ident,Float) => {
|
($self:ident, $instruction:ident,Float) => {
|
||||||
let in1: Float = $self.pull($instruction.constants[0]);
|
let in1: Float = $self.pull($instruction.constants[0]);
|
||||||
$self.push(in1.fract());
|
$self.push(in1 - in1.floor());
|
||||||
};
|
};
|
||||||
($self:ident, $instruction:ident, $type1:ty) => {
|
($self:ident, $instruction:ident, $type1:ty) => {
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
let in1: $type1 = $self.pull($instruction.constants[0]);
|
||||||
$self.push(in1.map(Float::fract));
|
$self.push(in1.fract_gl());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,22 +389,18 @@ macro_rules! squareroot {
|
|||||||
macro_rules! inversesquareroot {
|
macro_rules! inversesquareroot {
|
||||||
($self:ident, $instruction:ident,Float) => {
|
($self:ident, $instruction:ident,Float) => {
|
||||||
let in1: Float = $self.pull($instruction.constants[0]);
|
let in1: Float = $self.pull($instruction.constants[0]);
|
||||||
$self.push((1 as Float) / in1.sqrt());
|
$self.push(in1.sqrt().recip());
|
||||||
};
|
};
|
||||||
($self:ident, $instruction:ident, $type1:ty) => {
|
($self:ident, $instruction:ident, $type1:ty) => {
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
let in1: $type1 = $self.pull($instruction.constants[0]);
|
||||||
$self.push(in1.map(|x| (1 as Float) / x.sqrt()));
|
$self.push(in1.map(|x| x.sqrt().recip()));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! exponent {
|
macro_rules! exponent {
|
||||||
($self:ident, $instruction:ident,Float) => {
|
|
||||||
let in1: Float = $self.pull($instruction.constants[0]);
|
|
||||||
$self.push(in1.exp());
|
|
||||||
};
|
|
||||||
($self:ident, $instruction:ident, $type1:ty) => {
|
($self:ident, $instruction:ident, $type1:ty) => {
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
let in1: $type1 = $self.pull($instruction.constants[0]);
|
||||||
$self.push(in1.map(Float::exp));
|
$self.push(in1.exp());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -636,50 +570,32 @@ macro_rules! hyperbolicarctangent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! min {
|
macro_rules! min {
|
||||||
($self:ident, $instruction:ident, $type1:ty,Float) => {
|
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
|
||||||
let in2: Float = $self.pull($instruction.constants[1]);
|
|
||||||
$self.push(in1.min(in2));
|
|
||||||
};
|
|
||||||
($self:ident, $instruction:ident, $type1:ty, $type2:ty) => {
|
($self:ident, $instruction:ident, $type1:ty, $type2:ty) => {
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
let in1: $type1 = $self.pull($instruction.constants[0]);
|
||||||
let in2: $type2 = $self.pull($instruction.constants[1]);
|
let in2: $type2 = $self.pull($instruction.constants[1]);
|
||||||
$self.push(in1.zip(in2, Float::min));
|
$self.push(in1.min(in2));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! max {
|
macro_rules! max {
|
||||||
($self:ident, $instruction:ident, $type1:ty,Float) => {
|
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
|
||||||
let in2: Float = $self.pull($instruction.constants[1]);
|
|
||||||
$self.push(in1.max(in2));
|
|
||||||
};
|
|
||||||
($self:ident, $instruction:ident, $type1:ty, $type2:ty) => {
|
($self:ident, $instruction:ident, $type1:ty, $type2:ty) => {
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
let in1: $type1 = $self.pull($instruction.constants[0]);
|
||||||
let in2: $type2 = $self.pull($instruction.constants[1]);
|
let in2: $type2 = $self.pull($instruction.constants[1]);
|
||||||
$self.push(in1.zip(in2, Float::max));
|
$self.push(in1.max(in2));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! round {
|
macro_rules! round {
|
||||||
($self:ident, $instruction:ident,Float) => {
|
|
||||||
let in1: Float = $self.pull($instruction.constants[0]);
|
|
||||||
$self.push(in1.round());
|
|
||||||
};
|
|
||||||
($self:ident, $instruction:ident, $type1:ty) => {
|
($self:ident, $instruction:ident, $type1:ty) => {
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
let in1: $type1 = $self.pull($instruction.constants[0]);
|
||||||
$self.push(in1.map(Float::round));
|
$self.push(in1.round());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! trunc {
|
macro_rules! trunc {
|
||||||
($self:ident, $instruction:ident,Float) => {
|
|
||||||
let in1: Float = $self.pull($instruction.constants[0]);
|
|
||||||
$self.push(in1.trunc());
|
|
||||||
};
|
|
||||||
($self:ident, $instruction:ident, $type1:ty) => {
|
($self:ident, $instruction:ident, $type1:ty) => {
|
||||||
let in1: $type1 = $self.pull($instruction.constants[0]);
|
let in1: $type1 = $self.pull($instruction.constants[0]);
|
||||||
$self.push(in1.map(Float::trunc));
|
$self.push(in1.trunc());
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1649,7 +1565,7 @@ impl<'csg> Interpreter<'csg> {
|
|||||||
OPSDFSphere => {
|
OPSDFSphere => {
|
||||||
let r: Float = self.pull(instruction.constants[0]);
|
let r: Float = self.pull(instruction.constants[0]);
|
||||||
let p: Vec3 = self.pull(instruction.constants[1]);
|
let p: Vec3 = self.pull(instruction.constants[1]);
|
||||||
self.push(p.magnitude() - r);
|
self.push(p.length() - r);
|
||||||
},
|
},
|
||||||
|
|
||||||
OPSDFBox => {
|
OPSDFBox => {
|
||||||
@@ -1657,7 +1573,7 @@ impl<'csg> Interpreter<'csg> {
|
|||||||
let p: Vec3 = self.pull(instruction.constants[1]);
|
let p: Vec3 = self.pull(instruction.constants[1]);
|
||||||
let q = p.map(Float::abs) - r;
|
let q = p.map(Float::abs) - r;
|
||||||
self.push(
|
self.push(
|
||||||
(q.map(|x| x.max(0 as Float))).magnitude() + q.x.max(q.y.max(q.z)).min(0.),
|
(q.map(|x| x.max(0 as Float))).length() + q.x.max(q.y.max(q.z)).min(0.),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -1665,7 +1581,7 @@ impl<'csg> Interpreter<'csg> {
|
|||||||
let t: Vec2 = self.pull(instruction.constants[0]);
|
let t: Vec2 = self.pull(instruction.constants[0]);
|
||||||
let p: Vec3 = self.pull(instruction.constants[1]);
|
let p: Vec3 = self.pull(instruction.constants[1]);
|
||||||
let q = Vec2::new(((p.x * p.x) + (p.z * p.z)).sqrt() - t.x, p.y);
|
let q = Vec2::new(((p.x * p.x) + (p.z * p.z)).sqrt() - t.x, p.y);
|
||||||
self.push(q.magnitude() - t.y);
|
self.push(q.length() - t.y);
|
||||||
},
|
},
|
||||||
|
|
||||||
OPNop => {},
|
OPNop => {},
|
||||||
|
|||||||
+297
-353
File diff suppressed because it is too large
Load Diff
@@ -5,11 +5,12 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use serde::{
|
use serde::{
|
||||||
|
Deserialize,
|
||||||
de::{
|
de::{
|
||||||
self, DeserializeSeed, EnumAccess, IntoDeserializer, MapAccess, SeqAccess, VariantAccess,
|
self, DeserializeSeed, EnumAccess, IntoDeserializer, MapAccess, SeqAccess, VariantAccess,
|
||||||
Visitor,
|
Visitor,
|
||||||
},
|
},
|
||||||
forward_to_deserialize_any, Deserialize,
|
forward_to_deserialize_any,
|
||||||
};
|
};
|
||||||
use utf8::BufReadDecoder;
|
use utf8::BufReadDecoder;
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -155,7 +155,8 @@ pub(crate) fn load_obj(
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
AllocationCreateInfo {
|
AllocationCreateInfo {
|
||||||
memory_type_filter: MemoryTypeFilter::PREFER_DEVICE,
|
memory_type_filter: MemoryTypeFilter::PREFER_HOST
|
||||||
|
| MemoryTypeFilter::HOST_SEQUENTIAL_WRITE,
|
||||||
allocate_preference: MemoryAllocatePreference::AlwaysAllocate,
|
allocate_preference: MemoryAllocatePreference::AlwaysAllocate,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
@@ -170,7 +171,8 @@ pub(crate) fn load_obj(
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
AllocationCreateInfo {
|
AllocationCreateInfo {
|
||||||
memory_type_filter: MemoryTypeFilter::PREFER_DEVICE,
|
memory_type_filter: MemoryTypeFilter::PREFER_HOST
|
||||||
|
| MemoryTypeFilter::HOST_SEQUENTIAL_WRITE,
|
||||||
allocate_preference: MemoryAllocatePreference::AlwaysAllocate,
|
allocate_preference: MemoryAllocatePreference::AlwaysAllocate,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user