change visibility

This commit is contained in:
John Hunter
2023-04-27 14:27:27 +01:00
parent 6dfc99b4ef
commit ca9479d2d1
6 changed files with 76 additions and 84 deletions
+7 -13
View File
@@ -15,7 +15,7 @@ fn main() -> io::Result<()> {
let f = BufReader::new(f); let f = BufReader::new(f);
let mut out = "#[allow(non_snake_case)] let mut out = "#[allow(non_snake_case)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum InputTypes{ pub(crate) enum InputTypes{
#[allow(non_snake_case)] #[allow(non_snake_case)]
Float, Float,
#[allow(non_snake_case)] #[allow(non_snake_case)]
@@ -35,13 +35,13 @@ fn main() -> io::Result<()> {
#[repr(u16)] #[repr(u16)]
#[allow(non_snake_case)] #[allow(non_snake_case)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum InstructionSet{ pub(crate) enum InstructionSet{
" "
.to_owned(); .to_owned();
let mut outputimpl = " let mut outputimpl = "
pub fn output(&self) -> Vec<InputTypes> pub(crate) fn output(&self) -> Vec<InputTypes>
{ {
match self { match self {
@@ -49,7 +49,7 @@ fn main() -> io::Result<()> {
.to_owned(); .to_owned();
let mut inputimpl = " let mut inputimpl = "
pub fn input(&self) -> Vec<InputTypes> pub(crate) fn input(&self) -> Vec<InputTypes>
{ {
match self { match self {
@@ -65,13 +65,9 @@ fn main() -> io::Result<()> {
let name = &entries[0][11..entries[0].len() - 12]; let name = &entries[0][11..entries[0].len() - 12];
out += &format!( out += &format!("#[allow(non_snake_case)]\n#[allow(dead_code)]\n{name}={index},\n");
"#[allow(non_snake_case)]\n#[allow(dead_code)]\n{name}={index},\n"
);
inputimpl += &format!( inputimpl += &format!("#[allow(non_snake_case)]\nInstructionSet::{name} => vec![");
"#[allow(non_snake_case)]\nInstructionSet::{name} => vec!["
);
for input in entries[1].split(' ').map(str::trim) { for input in entries[1].split(' ').map(str::trim) {
if input.is_empty() { if input.is_empty() {
continue; continue;
@@ -89,9 +85,7 @@ fn main() -> io::Result<()> {
} }
inputimpl += "],\n"; inputimpl += "],\n";
outputimpl += &format!( outputimpl += &format!("#[allow(non_snake_case)]\nInstructionSet::{name} => vec![");
"#[allow(non_snake_case)]\nInstructionSet::{name} => vec!["
);
for output in entries[2].split(' ').map(str::trim) { for output in entries[2].split(' ').map(str::trim) {
if output.is_empty() { if output.is_empty() {
continue; continue;
+17 -20
View File
@@ -11,27 +11,27 @@ fn sized_text(ui: &mut egui::Ui, text: impl Into<String>, size: f32) {
} }
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] #[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub struct PreviousDebug { pub(crate) struct PreviousDebug {
pub bounding_boxes: bool, pub(crate) bounding_boxes: bool,
pub disable_meshcull: bool, pub(crate) disable_meshcull: bool,
pub disable_meshscale1: bool, pub(crate) disable_meshscale1: bool,
pub disable_meshscale2: bool, pub(crate) disable_meshscale2: bool,
pub disable_taskcull: bool, pub(crate) disable_taskcull: bool,
pub brute_force: bool, pub(crate) brute_force: bool,
} }
#[derive(Debug)] #[derive(Debug)]
pub struct GState { pub(crate) struct GState {
pub cursor_sensitivity: f32, pub(crate) cursor_sensitivity: f32,
pub move_speed: f32, pub(crate) move_speed: f32,
pub meshes: Vec<Mesh>, pub(crate) meshes: Vec<Mesh>,
pub lights: Vec<Light>, pub(crate) lights: Vec<Light>,
pub csg: Vec<CSG>, pub(crate) csg: Vec<CSG>,
pub fps: [f64; 128], pub(crate) fps: [f64; 128],
pub debug: PreviousDebug, pub(crate) debug: PreviousDebug,
} }
impl Default for GState { impl Default for GState {
@@ -51,7 +51,7 @@ impl Default for GState {
} }
} }
pub fn gui_up(gui: &mut Gui, state: &mut GState) { pub(crate) fn gui_up(gui: &mut Gui, state: &mut GState) {
gui.immediate_ui(|gui| { gui.immediate_ui(|gui| {
let ctx = gui.context(); let ctx = gui.context();
egui::SidePanel::left(Id::new("main_left")) egui::SidePanel::left(Id::new("main_left"))
@@ -121,12 +121,9 @@ pub fn gui_up(gui: &mut Gui, state: &mut GState) {
{ {
state.lights.remove(i); state.lights.remove(i);
} }
if (state.lights.len() < 32) { if state.lights.len() < 32 && ui.small_button("add light").clicked() {
if ui.small_button("add light").clicked()
{
state.lights.push(Light::default()); 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); let line = Line::new(fps);
+3 -3
View File
@@ -6,7 +6,7 @@ use crate::{
use cgmath::{Array, ElementWise, InnerSpace, MetricSpace, VectorSpace}; use cgmath::{Array, ElementWise, InnerSpace, MetricSpace, VectorSpace};
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct Interpreter<'csg> { pub(crate) struct Interpreter<'csg> {
float_stack: Vec<Float>, float_stack: Vec<Float>,
vec2_stack: Vec<Vec2>, vec2_stack: Vec<Vec2>,
vec3_stack: Vec<Vec3>, vec3_stack: Vec<Vec3>,
@@ -694,7 +694,7 @@ macro_rules! normalise {
} }
impl<'csg> Interpreter<'csg> { impl<'csg> Interpreter<'csg> {
pub fn new(csg: &'csg CSG) -> Self { pub(crate) fn new(csg: &'csg CSG) -> Self {
Interpreter { Interpreter {
float_stack: vec![], float_stack: vec![],
vec2_stack: vec![], vec2_stack: vec![],
@@ -755,7 +755,7 @@ impl<'csg> Interpreter<'csg> {
); );
}*/ }*/
pub fn scene(&mut self, p: Vec3) -> Float { pub(crate) fn scene(&mut self, p: Vec3) -> Float {
self.clear_stacks(); self.clear_stacks();
self.push(p); self.push(p);
+2 -2
View File
@@ -79,7 +79,7 @@ use crate::instruction_set::InstructionSet;
mod interpreter; mod interpreter;
pub type MemoryAllocator = StandardMemoryAllocator; pub(crate) type MemoryAllocator = StandardMemoryAllocator;
fn main() { fn main() {
let library = VulkanLibrary::new().expect("Vulkan is not installed???"); let library = VulkanLibrary::new().expect("Vulkan is not installed???");
@@ -1103,7 +1103,7 @@ where
println!("Recompiling implicit pipeline... (may take up to 10 minutes)"); println!("Recompiling implicit pipeline... (may take up to 10 minutes)");
let mut implicit_pipeline = GraphicsPipeline::start() let implicit_pipeline = GraphicsPipeline::start()
.render_pass(Subpass::from(render_pass.clone(), 0).unwrap()) .render_pass(Subpass::from(render_pass.clone(), 0).unwrap())
.vertex_input_state(OVertex::per_vertex()) .vertex_input_state(OVertex::per_vertex())
.input_assembly_state(InputAssemblyState::new()) .input_assembly_state(InputAssemblyState::new())
+6 -6
View File
@@ -8,12 +8,12 @@ use serde::de::{
Visitor, Visitor,
}; };
use serde::{forward_to_deserialize_any, Deserialize}; use serde::{forward_to_deserialize_any, Deserialize};
use utf8::{BufReadDecoder}; use utf8::BufReadDecoder;
type Result<T> = core::result::Result<T, Error>; type Result<T> = core::result::Result<T, Error>;
#[derive(Debug)] #[derive(Debug)]
pub enum Error { pub(crate) enum Error {
Message(String), Message(String),
UTF8(String), UTF8(String),
TrailingCharacters, TrailingCharacters,
@@ -47,7 +47,7 @@ impl serde::ser::Error for Error {
} }
} }
pub struct Deserializer<'de> { pub(crate) struct Deserializer<'de> {
// This string starts with the input data and characters are truncated off // This string starts with the input data and characters are truncated off
// the beginning as data is parsed. // the beginning as data is parsed.
input: BufReadDecoder<BufReader<&'de mut dyn Read>>, input: BufReadDecoder<BufReader<&'de mut dyn Read>>,
@@ -61,7 +61,7 @@ impl<'de> Deserializer<'de> {
// `serde_json::from_str(...)` while advanced use cases that require a // `serde_json::from_str(...)` while advanced use cases that require a
// deserializer can make one with `serde_json::Deserializer::from_str(...)`. // deserializer can make one with `serde_json::Deserializer::from_str(...)`.
pub fn from_reader(input: &'de mut dyn Read) -> Self { pub(crate) fn from_reader(input: &'de mut dyn Read) -> Self {
Deserializer { Deserializer {
input: BufReadDecoder::new(BufReader::new(input)), input: BufReadDecoder::new(BufReader::new(input)),
read_buf: String::new(), read_buf: String::new(),
@@ -70,12 +70,12 @@ impl<'de> Deserializer<'de> {
} }
} }
// By convention, the public API of a Serde deserializer is one or more // By convention, the pub(crate)lic API of a Serde deserializer is one or more
// `from_xyz` methods such as `from_str`, `from_bytes`, or `from_reader` // `from_xyz` methods such as `from_str`, `from_bytes`, or `from_reader`
// depending on what Rust types the deserializer is able to consume as input. // depending on what Rust types the deserializer is able to consume as input.
// //
// This basic deserializer supports only `from_str`. // This basic deserializer supports only `from_str`.
pub fn from_reader<'a, T>(s: &'a mut dyn Read) -> Result<T> pub(crate) fn from_reader<'a, T>(s: &'a mut dyn Read) -> Result<T>
where where
T: Deserialize<'a>, T: Deserialize<'a>,
{ {
+40 -39
View File
@@ -6,8 +6,8 @@ use std::{
use bytemuck::{Pod, Zeroable}; use bytemuck::{Pod, Zeroable};
use cgmath::{ use cgmath::{
Deg, EuclideanSpace, Euler, Matrix2, Matrix3, Matrix4, Point3, SquareMatrix, Deg, EuclideanSpace, Euler, Matrix2, Matrix3, Matrix4, Point3, SquareMatrix, Vector2, Vector3,
Vector2, Vector3, Vector4, Vector4,
}; };
use obj::{LoadConfig, ObjData, ObjError}; use obj::{LoadConfig, ObjData, ObjError};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@@ -19,15 +19,16 @@ use vulkano::{
use crate::instruction_set::InstructionSet; use crate::instruction_set::InstructionSet;
use crate::{mcsg_deserialise::from_reader, MemoryAllocator}; use crate::{mcsg_deserialise::from_reader, MemoryAllocator};
pub const PLATONIC_SOLIDS: [(&str, &[u8]); 1] = [("Buny", include_bytes!("bunny.obj"))]; pub(crate) const PLATONIC_SOLIDS: [(&str, &[u8]); 1] = [("Buny", include_bytes!("bunny.obj"))];
pub const CSG_SOLIDS: [(&str, &[u8]); 1] = [("Primitives", include_bytes!("primitive.mcsg"))]; 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 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 // 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. // particular example, it doesn't actually change the in-memory representation.
#[repr(C)] #[repr(C)]
#[derive(Clone, Copy, Debug, Default, Zeroable, Pod, Vertex)] #[derive(Clone, Copy, Debug, Default, Zeroable, Pod, Vertex)]
pub struct OVertex { pub(crate) struct OVertex {
#[format(R32G32B32_SFLOAT)] #[format(R32G32B32_SFLOAT)]
position: [f32; 3], position: [f32; 3],
#[format(R32G32B32_SFLOAT)] #[format(R32G32B32_SFLOAT)]
@@ -35,34 +36,34 @@ pub struct OVertex {
} }
#[derive(Debug)] #[derive(Debug)]
pub struct Mesh { pub(crate) struct Mesh {
pub name: String, pub(crate) name: String,
pub vertices: Subbuffer<[OVertex]>, pub(crate) vertices: Subbuffer<[OVertex]>,
pub indices: Subbuffer<[u32]>, pub(crate) indices: Subbuffer<[u32]>,
pub pos: Point3<f32>, pub(crate) pos: Point3<f32>,
pub rot: Euler<Deg<f32>>, pub(crate) rot: Euler<Deg<f32>>,
pub scale: Vector3<f32>, pub(crate) scale: Vector3<f32>,
} }
#[derive(Debug)] #[derive(Debug)]
pub struct CSG { pub(crate) struct CSG {
pub name: String, pub(crate) name: String,
pub parts: Vec<CSGPart>, pub(crate) parts: Vec<CSGPart>,
pub pos: Point3<f32>, pub(crate) pos: Point3<f32>,
pub rot: Euler<Deg<f32>>, pub(crate) rot: Euler<Deg<f32>>,
pub scale: Vector3<f32>, pub(crate) scale: Vector3<f32>,
} }
pub type Float = f64; pub(crate) type Float = f64;
pub type Vec2 = Vector2<Float>; pub(crate) type Vec2 = Vector2<Float>;
pub type Vec3 = Vector3<Float>; pub(crate) type Vec3 = Vector3<Float>;
pub type Vec4 = Vector4<Float>; pub(crate) type Vec4 = Vector4<Float>;
pub type Mat2 = Matrix2<Float>; pub(crate) type Mat2 = Matrix2<Float>;
pub type Mat3 = Matrix3<Float>; pub(crate) type Mat3 = Matrix3<Float>;
pub type Mat4 = Matrix4<Float>; pub(crate) type Mat4 = Matrix4<Float>;
#[derive(Clone, Copy, Debug, Default, PartialEq)] #[derive(Clone, Copy, Debug, Default, PartialEq)]
pub enum Inputs { pub(crate) enum Inputs {
#[default] #[default]
Variable, Variable,
Float(Float), Float(Float),
@@ -76,15 +77,15 @@ pub enum Inputs {
#[repr(C)] #[repr(C)]
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct CSGPart { pub(crate) struct CSGPart {
pub code: u16, pub(crate) code: u16,
pub opcode: InstructionSet, pub(crate) opcode: InstructionSet,
pub constants: Vec<Inputs>, pub(crate) constants: Vec<Inputs>,
pub material: Option<Mat4>, pub(crate) material: Option<Mat4>,
} }
impl CSGPart { impl CSGPart {
pub fn opcode(opcode: InstructionSet, inputs: Vec<Inputs>) -> CSGPart { pub(crate) fn opcode(opcode: InstructionSet, inputs: Vec<Inputs>) -> CSGPart {
CSGPart { CSGPart {
code: (opcode as u16 & 1023) code: (opcode as u16 & 1023)
| inputs | inputs
@@ -104,7 +105,7 @@ impl CSGPart {
} }
} }
pub fn opcode_with_material( pub(crate) fn opcode_with_material(
opcode: InstructionSet, opcode: InstructionSet,
inputs: Vec<Inputs>, inputs: Vec<Inputs>,
material: Mat4, material: Mat4,
@@ -115,7 +116,7 @@ impl CSGPart {
} }
} }
pub fn load_obj( pub(crate) fn load_obj(
memory_allocator: &MemoryAllocator, memory_allocator: &MemoryAllocator,
input: &mut dyn Read, input: &mut dyn Read,
name: String, name: String,
@@ -331,7 +332,7 @@ fn get_half(o: &HashMap<String, String>) -> Result<Half, String> {
}) })
} }
pub fn load_csg( pub(crate) fn load_csg(
_memory_allocator: &MemoryAllocator, _memory_allocator: &MemoryAllocator,
input: &mut dyn Read, input: &mut dyn Read,
name: String, name: String,
@@ -400,13 +401,13 @@ pub fn load_csg(
} }
#[derive(Debug)] #[derive(Debug)]
pub struct Light { pub(crate) struct Light {
pub pos: Point3<f32>, pub(crate) pos: Point3<f32>,
pub colour: Vector3<f32>, pub(crate) colour: Vector3<f32>,
} }
impl Light { impl Light {
pub fn new(pos: [f32; 3], colour: [f32; 3], intensity: f32) -> Light { pub(crate) fn new(pos: [f32; 3], colour: [f32; 3], intensity: f32) -> Light {
let c: Vector3<f32> = colour.into(); let c: Vector3<f32> = colour.into();
Light { Light {
pos: pos.into(), pos: pos.into(),