This commit is contained in:
John Hunter
2025-01-02 00:01:05 +00:00
parent 041d876fe5
commit c19386bca5
4 changed files with 42 additions and 50 deletions
+1 -1
View File
@@ -141,7 +141,7 @@ impl From<Float> for Inputs {
} }
} }
impl<'csg> Interpreter<'csg> { impl Interpreter<'_> {
fn pull<T: Pull + From<Inputs>>(&mut self, consider: Inputs) -> T { fn pull<T: Pull + From<Inputs>>(&mut self, consider: Inputs) -> T {
if consider == Inputs::Variable { if consider == Inputs::Variable {
T::pull(self) T::pull(self)
+29 -36
View File
@@ -596,7 +596,7 @@ impl ApplicationHandler for App {
// Create an egui GUI // Create an egui GUI
let gui = Gui::new_with_subpass( let gui = Gui::new_with_subpass(
&event_loop, event_loop,
surface.clone(), surface.clone(),
self.graphics_queue.clone(), self.graphics_queue.clone(),
Subpass::from(render_pass.clone(), 1).unwrap(), Subpass::from(render_pass.clone(), 1).unwrap(),
@@ -647,16 +647,13 @@ impl ApplicationHandler for App {
_device_id: winit::event::DeviceId, _device_id: winit::event::DeviceId,
event: DeviceEvent, event: DeviceEvent,
) { ) {
match &event { if let DeviceEvent::MouseMotion { delta } = &event {
DeviceEvent::MouseMotion { delta } => { if self.cstate.looking {
if self.cstate.looking { self.cstate.forward.x -= delta.1 as f32 * self.gstate.cursor_sensitivity * 0.3;
self.cstate.forward.x -= delta.1 as f32 * self.gstate.cursor_sensitivity * 0.3; self.cstate.forward.y += delta.0 as f32 * self.gstate.cursor_sensitivity * 0.3;
self.cstate.forward.y += delta.0 as f32 * self.gstate.cursor_sensitivity * 0.3; self.cstate.forward.x += 360f32 % 360f32;
self.cstate.forward.x += 360f32 % 360f32; self.cstate.forward.y += 360f32 % 360f32;
self.cstate.forward.y += 360f32 % 360f32; }
}
},
_ => {},
} }
} }
@@ -1038,7 +1035,7 @@ impl App {
let content = compute_result_buffer.read().unwrap(); let content = compute_result_buffer.read().unwrap();
for (val, csg) in content.iter().zip(fake_csg.iter()) { for (val, csg) in content.iter().zip(fake_csg.iter()) {
println!("{val:?}"); println!("{val:?}");
let expected = Interpreter::new(csg).scene(Vec3::ONE) as f32; let expected = Interpreter::new(csg).scene(Vec3::ONE);
if expected != val.f[0] { if expected != val.f[0] {
println!("ERROR: expected {}, got {}", expected, val.f[0]); println!("ERROR: expected {}, got {}", expected, val.f[0]);
} }
@@ -1486,7 +1483,7 @@ impl PartialEq<InputTypes> for Inputs {
fn gpu_buffer<T>( fn gpu_buffer<T>(
input: Vec<T>, input: Vec<T>,
allocator: Arc<StandardMemoryAllocator>, allocator: Arc<StandardMemoryAllocator>,
sub_allocator: Arc<SubbufferAllocator>, sub_allocator: &SubbufferAllocator,
command_allocator: Arc<StandardCommandBufferAllocator>, command_allocator: Arc<StandardCommandBufferAllocator>,
transfer_queue: Arc<Queue>, transfer_queue: Arc<Queue>,
) -> Subbuffer<[T]> ) -> Subbuffer<[T]>
@@ -1729,10 +1726,10 @@ fn object_size_dependent_setup(
} }
} else { } else {
match *actual { match *actual {
Inputs::Float(f) => floats.push(f as f32), Inputs::Float(f) => floats.push(f),
Inputs::Vec2(f) => vec2s.push(f.map(|x| x as f32).into()), Inputs::Vec2(f) => vec2s.push(f.map(|x| x).into()),
Inputs::Vec3(f) => vec4s.push(f.map(|x| x as f32).extend(1.).into()), Inputs::Vec3(f) => vec4s.push(f.map(|x| x).extend(1.).into()),
Inputs::Vec4(f) => vec4s.push(f.map(|x| x as f32).into()), Inputs::Vec4(f) => vec4s.push(f.map(|x| x).into()),
Inputs::Mat2(f) => mat2s.push(f.to_cols_array_2d()), Inputs::Mat2(f) => mat2s.push(f.to_cols_array_2d()),
Inputs::Mat3(f) => mat3s.push(f.to_cols_array_2d()), Inputs::Mat3(f) => mat3s.push(f.to_cols_array_2d()),
Inputs::Mat4(f) => mat4s.push(f.to_cols_array_2d()), Inputs::Mat4(f) => mat4s.push(f.to_cols_array_2d()),
@@ -1835,41 +1832,37 @@ fn object_size_dependent_setup(
) )
.unwrap(); .unwrap();
let staging = Arc::new(SubbufferAllocator::new( let staging = SubbufferAllocator::new(allocator.clone(), SubbufferAllocatorCreateInfo {
allocator.clone(), buffer_usage: BufferUsage::TRANSFER_SRC,
SubbufferAllocatorCreateInfo { memory_type_filter: MemoryTypeFilter::PREFER_HOST | MemoryTypeFilter::HOST_SEQUENTIAL_WRITE,
buffer_usage: BufferUsage::TRANSFER_SRC, ..Default::default()
memory_type_filter: MemoryTypeFilter::PREFER_HOST });
| MemoryTypeFilter::HOST_SEQUENTIAL_WRITE,
..Default::default()
},
));
let csg_scene = gpu_buffer( let csg_scene = gpu_buffer(
scene, scene,
allocator.clone(), allocator.clone(),
staging.clone(), &staging,
command_allocator.clone(), command_allocator.clone(),
queue.clone(), queue.clone(),
); );
let csg_desc = gpu_buffer( let csg_desc = gpu_buffer(
desc, desc,
allocator.clone(), allocator.clone(),
staging.clone(), &staging,
command_allocator.clone(), command_allocator.clone(),
queue.clone(), queue.clone(),
); );
let csg_floats = gpu_buffer( let csg_floats = gpu_buffer(
floats, floats,
allocator.clone(), allocator.clone(),
staging.clone(), &staging,
command_allocator.clone(), command_allocator.clone(),
queue.clone(), queue.clone(),
); );
let csg_vec2s = gpu_buffer( let csg_vec2s = gpu_buffer(
vec2s, vec2s,
allocator.clone(), allocator.clone(),
staging.clone(), &staging,
command_allocator.clone(), command_allocator.clone(),
queue.clone(), queue.clone(),
); );
@@ -1878,42 +1871,42 @@ fn object_size_dependent_setup(
let csg_vec4s = gpu_buffer( let csg_vec4s = gpu_buffer(
vec4s, vec4s,
allocator.clone(), allocator.clone(),
staging.clone(), &staging,
command_allocator.clone(), command_allocator.clone(),
queue.clone(), queue.clone(),
); );
let csg_mat2s = gpu_buffer( let csg_mat2s = gpu_buffer(
mat2s, mat2s,
allocator.clone(), allocator.clone(),
staging.clone(), &staging,
command_allocator.clone(), command_allocator.clone(),
queue.clone(), queue.clone(),
); );
let csg_mat3s = gpu_buffer( let csg_mat3s = gpu_buffer(
mat3s, mat3s,
allocator.clone(), allocator.clone(),
staging.clone(), &staging,
command_allocator.clone(), command_allocator.clone(),
queue.clone(), queue.clone(),
); );
let csg_mat4s = gpu_buffer( let csg_mat4s = gpu_buffer(
mat4s, mat4s,
allocator.clone(), allocator.clone(),
staging.clone(), &staging,
command_allocator.clone(), command_allocator.clone(),
queue.clone(), queue.clone(),
); );
let csg_mats = gpu_buffer( let csg_mats = gpu_buffer(
mats, mats,
allocator.clone(), allocator.clone(),
staging.clone(), &staging,
command_allocator.clone(), command_allocator.clone(),
queue.clone(), queue.clone(),
); );
let csg_deps = gpu_buffer( let csg_deps = gpu_buffer(
deps, deps,
allocator.clone(), allocator.clone(),
staging.clone(), &staging,
command_allocator.clone(), command_allocator.clone(),
queue, queue,
); );
+10 -10
View File
@@ -97,12 +97,12 @@ fn get_char(mut s: Chars) -> Result<(char, usize)> {
loop { loop {
let next = s.next().ok_or(Error::Eof); let next = s.next().ok_or(Error::Eof);
count += 1; count += 1;
if next.as_ref().map_or(false, |&c| c.is_whitespace()) { if next.as_ref().is_ok_and(|&c| c.is_whitespace()) {
continue; continue;
} }
if next.as_ref().map_or(false, |this| this == &'/') { if next.as_ref().is_ok_and(|this| this == &'/') {
if s.next().map_or(false, |this| this == '/') { if s.next() == Some('/') {
while s.next().map_or(false, |s| s != '\n' && s != '\r') { while s.next().is_some_and(|s| s != '\n' && s != '\r') {
count += 1; count += 1;
} }
count += 1; count += 1;
@@ -117,7 +117,7 @@ fn get_char(mut s: Chars) -> Result<(char, usize)> {
// SERDE IS NOT A PARSING LIBRARY. This impl block defines a few basic parsing // SERDE IS NOT A PARSING LIBRARY. This impl block defines a few basic parsing
// functions from scratch. More complicated formats may wish to use a dedicated // functions from scratch. More complicated formats may wish to use a dedicated
// parsing library to help implement their Serde deserializer. // parsing library to help implement their Serde deserializer.
impl<'de> Deserializer<'de> { impl Deserializer<'_> {
fn check_end(&mut self) -> bool { fn check_end(&mut self) -> bool {
self.input.next_strict().is_none() self.input.next_strict().is_none()
} }
@@ -189,7 +189,7 @@ impl<'de> Deserializer<'de> {
} }
} }
impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> { impl<'de> de::Deserializer<'de> for &mut Deserializer<'de> {
type Error = Error; type Error = Error;
forward_to_deserialize_any! { forward_to_deserialize_any! {
@@ -396,7 +396,7 @@ impl<'a, 'de> CommaSeparated<'a, 'de> {
// `SeqAccess` is provided to the `Visitor` to give it the ability to iterate // `SeqAccess` is provided to the `Visitor` to give it the ability to iterate
// through elements of the sequence. // through elements of the sequence.
impl<'de, 'a> SeqAccess<'de> for CommaSeparated<'a, 'de> { impl<'de> SeqAccess<'de> for CommaSeparated<'_, 'de> {
type Error = Error; type Error = Error;
fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>> fn next_element_seed<T>(&mut self, seed: T) -> Result<Option<T::Value>>
@@ -414,7 +414,7 @@ impl<'de, 'a> SeqAccess<'de> for CommaSeparated<'a, 'de> {
// `MapAccess` is provided to the `Visitor` to give it the ability to iterate // `MapAccess` is provided to the `Visitor` to give it the ability to iterate
// through entries of the map. // through entries of the map.
impl<'de, 'a> MapAccess<'de> for CommaSeparated<'a, 'de> { impl<'de> MapAccess<'de> for CommaSeparated<'_, 'de> {
type Error = Error; type Error = Error;
fn next_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>> fn next_key_seed<K>(&mut self, seed: K) -> Result<Option<K::Value>>
@@ -459,7 +459,7 @@ impl<'a, 'de> Enum<'a, 'de> {
// //
// Note that all enum deserialization methods in Serde refer exclusively to the // Note that all enum deserialization methods in Serde refer exclusively to the
// "externally tagged" enum representation. // "externally tagged" enum representation.
impl<'de, 'a> EnumAccess<'de> for Enum<'a, 'de> { impl<'de> EnumAccess<'de> for Enum<'_, 'de> {
type Error = Error; type Error = Error;
type Variant = Self; type Variant = Self;
@@ -482,7 +482,7 @@ impl<'de, 'a> EnumAccess<'de> for Enum<'a, 'de> {
// `VariantAccess` is provided to the `Visitor` to give it the ability to see // `VariantAccess` is provided to the `Visitor` to give it the ability to see
// the content of the single variant that it decided to deserialize. // the content of the single variant that it decided to deserialize.
impl<'de, 'a> VariantAccess<'de> for Enum<'a, 'de> { impl<'de> VariantAccess<'de> for Enum<'_, 'de> {
type Error = Error; type Error = Error;
// If the `Visitor` expected this variant to be a unit variant, the input // If the `Visitor` expected this variant to be a unit variant, the input
+2 -3
View File
@@ -309,7 +309,7 @@ fn get_half(o: &HashMap<String, String>) -> Result<Half, String> {
if half as usize >= mem::variant_count::<Half>() { if half as usize >= mem::variant_count::<Half>() {
return Err("invalid enum".to_owned()); return Err("invalid enum".to_owned());
} }
unsafe { mem::transmute(half) } unsafe { mem::transmute::<u8, Half>(half) }
}) })
} }
@@ -323,8 +323,7 @@ pub(crate) fn load_csg(
mcsg.object mcsg.object
.iter() .iter()
.enumerate() .map(|o| {
.map(|(_i, o)| {
let name = name.clone() + "_" + o.get("name").unwrap_or(&"unknown".to_owned()); let name = name.clone() + "_" + o.get("name").unwrap_or(&"unknown".to_owned());
let _trs = get_trs(o)?; let _trs = get_trs(o)?;
let _color = get_color(o)?; let _color = get_color(o)?;