diff --git a/Cargo.lock b/Cargo.lock index d656e22..e9cde19 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1678,6 +1678,7 @@ dependencies = [ "derive_more", "tracing", "wgpu", + "wgpu-types", ] [[package]] diff --git a/crates/bevy_tape_drive_solari/Cargo.toml b/crates/bevy_tape_drive_solari/Cargo.toml index 0c7fe6b..4e41a64 100644 --- a/crates/bevy_tape_drive_solari/Cargo.toml +++ b/crates/bevy_tape_drive_solari/Cargo.toml @@ -49,6 +49,7 @@ bytemuck = { version = "1" } derive_more = { version = "2", default-features = false, features = ["from"] } tracing = { version = "0.1", default-features = false, features = ["std"] } wgpu = { version = "30", default-features = false } +wgpu-types = { version = "30", default-features = false } [features] dlss = ["bevy_anti_alias/dlss"] diff --git a/crates/bevy_tape_drive_solari/src/scene/binder/bind_group.rs b/crates/bevy_tape_drive_solari/src/scene/binder/bind_group.rs index 02b3fb4..74190ec 100644 --- a/crates/bevy_tape_drive_solari/src/scene/binder/bind_group.rs +++ b/crates/bevy_tape_drive_solari/src/scene/binder/bind_group.rs @@ -103,6 +103,7 @@ impl RaytracingSceneBindings { &mut self.instances.index_buffers.dirty, &mut self.instances.aabb_buffers.dirty, &mut self.instances.tape_metadata_buffers.dirty, + &mut self.instances.spatial_textures.dirty, &mut self.assets.textures.dirty, ] { invalid |= core::mem::replace(dirty, false); @@ -159,6 +160,19 @@ impl RaytracingSceneBindings { return None; } + let mut spatial_textures: Vec<_> = self + .instances + .spatial_textures + .iter() + .map(|texture| match texture { + Some(view) => view.deref(), + None => fallback_texture.d3.texture_view.deref(), + }) + .collect(); + if spatial_textures.is_empty() { + spatial_textures.push(fallback_texture.d3.texture_view.deref()); + } + let (mut textures, mut samplers): (Vec<_>, Vec<_>) = self .assets .textures @@ -199,6 +213,7 @@ impl RaytracingSceneBindings { index_buffers.as_slice(), aabb_buffers.as_slice(), tape_metadata_buffers.as_slice(), + spatial_textures.as_slice(), textures.as_slice(), samplers.as_slice(), self.assets.materials.binding().unwrap(), diff --git a/crates/bevy_tape_drive_solari/src/scene/binder/instances.rs b/crates/bevy_tape_drive_solari/src/scene/binder/instances.rs index 9d70734..7483243 100644 --- a/crates/bevy_tape_drive_solari/src/scene/binder/instances.rs +++ b/crates/bevy_tape_drive_solari/src/scene/binder/instances.rs @@ -13,13 +13,16 @@ use bevy_platform::collections::HashMap; use bevy_render::{ impl_atomic_pod, mesh::allocator::MeshAllocator, - render_resource::{AtomicPod, AtomicSparseBufferVec, Buffer, BufferId, BufferUsages}, + render_resource::{ + AtomicPod, AtomicSparseBufferVec, Buffer, BufferId, BufferUsages, TextureId, TextureView, + }, }; use bevy_tape_load::{Tape, render::allocator::TapeAllocator}; use bevy_transform::components::GlobalTransform; use bevy_utils::once; use bytemuck::{Pod, Zeroable}; use tracing::{info_span, warn}; +use wgpu_types::TextureViewDescriptor; use super::{ MeshBlasKey, MeshBlasManager, MeshBlasOpacity, RaytracingMesh3d, RaytracingSceneBindings, @@ -31,6 +34,7 @@ use super::{ pub const MAX_MESH_SLAB_COUNT: NonZeroU32 = NonZeroU32::new(500).unwrap(); pub const MAX_TAPE_SLAB_COUNT: NonZeroU32 = NonZeroU32::new(500).unwrap(); +pub const MAX_SPATIAL_TEXTURE_COUNT: NonZeroU32 = NonZeroU32::new(5000).unwrap(); #[derive(Clone, Copy, Default, PartialEq, Pod, Zeroable)] #[repr(C)] @@ -48,6 +52,7 @@ pub struct GpuInstanceTapeIds { aabb_buffer_id: u32, aabb_buffer_offset: u32, aabb_count: u32, + spatial_texture_id: u32, metadata_buffer_id: u32, metadata_buffer_offset: u32, } @@ -97,6 +102,30 @@ pub enum BlasKey { Tape(TapeBlasKey), } +type MeshBuffers = (BufferId, BufferId); +type TapeBuffers = (BufferId, BufferId, TextureId); + +pub enum Buffers { + Mesh(MeshBuffers), + Tape(TapeBuffers), +} + +impl Buffers { + fn as_mesh(self) -> MeshBuffers { + match self { + Buffers::Mesh(b) => b, + Buffers::Tape(_) => unreachable!(), + } + } + + fn as_tape(self) -> TapeBuffers { + match self { + Buffers::Mesh(_) => unreachable!(), + Buffers::Tape(b) => b, + } + } +} + /// Everything tracked per raytracing instance. #[derive(Clone, Copy)] struct MeshInstance { @@ -104,7 +133,7 @@ struct MeshInstance { mesh: AssetId, material: AssetId, opacity: MeshBlasOpacity, - buffers: Option<(BufferId, BufferId)>, + buffers: Option, } /// Everything tracked per raytracing instance. @@ -114,7 +143,7 @@ struct TapeInstance { tape: AssetId, material: AssetId, opacity: TapeBlasOpacity, - buffers: Option<(BufferId, BufferId)>, + buffers: Option, } impl MeshInstance { @@ -163,10 +192,10 @@ impl Instance { } } - fn get_buffers(&self) -> Option<(BufferId, BufferId)> { + fn get_buffers(&self) -> Option { match self { - Instance::Mesh(mesh_instance) => mesh_instance.buffers, - Instance::Tape(tape_instance) => tape_instance.buffers, + Instance::Mesh(mesh_instance) => mesh_instance.buffers.map(|b| Buffers::Mesh(b)), + Instance::Tape(tape_instance) => tape_instance.buffers.map(|b| Buffers::Tape(b)), } } @@ -181,7 +210,7 @@ impl Instance { slot: u32, object: Object, material: AssetId, - buffers: Option<(BufferId, BufferId)>, + buffers: Option, ) -> Self { match object { Object::Mesh(mesh) => Instance::Mesh(MeshInstance { @@ -189,25 +218,18 @@ impl Instance { mesh, material, opacity: MeshBlasOpacity::Opaque, - buffers, + buffers: buffers.map(Buffers::as_mesh), }), Object::Tape(tape) => Instance::Tape(TapeInstance { slot, tape, material, opacity: TapeBlasOpacity::Opaque, - buffers, + buffers: buffers.map(Buffers::as_tape), }), } } - fn take_buffers(&mut self) -> Option<(BufferId, BufferId)> { - match self { - Instance::Mesh(mesh_instance) => mesh_instance.buffers.take(), - Instance::Tape(tape_instance) => tape_instance.buffers.take(), - } - } - fn set_slot(&mut self, slot: u32) { match self { Instance::Mesh(mesh_instance) => mesh_instance.slot = slot, @@ -222,14 +244,14 @@ impl Instance { } } - fn set_buffers(&mut self, buffers: Option<(BufferId, BufferId)>) { + fn set_buffers(&mut self, buffers: Option) { match self { - Instance::Mesh(mesh_instance) => mesh_instance.buffers = buffers, - Instance::Tape(tape_instance) => tape_instance.buffers = buffers, + Instance::Mesh(mesh_instance) => mesh_instance.buffers = buffers.map(Buffers::as_mesh), + Instance::Tape(tape_instance) => tape_instance.buffers = buffers.map(Buffers::as_tape), } } - fn get_shared(&self) -> (u32, AssetId, Option<(BufferId, BufferId)>) { + fn get_shared(&self) -> (u32, AssetId, Option) { (self.get_slot(), self.get_material(), self.get_buffers()) } } @@ -241,6 +263,7 @@ pub struct InstanceState { pub index_buffers: RetainedBindingArray, pub aabb_buffers: RetainedBindingArray, pub tape_metadata_buffers: RetainedBindingArray, + pub spatial_textures: RetainedBindingArray, pub transforms: AtomicSparseBufferVec, pub previous_frame_transforms: AtomicSparseBufferVec, pub geometry_ids: AtomicSparseBufferVec, @@ -250,8 +273,8 @@ pub struct InstanceState { pub slots: IndexAllocator, /// Slab buffer references dropped this frame, released next frame since the /// previous frame's TLAS can still reach them through `geometry_ids`. - retired_mesh_buffers: Vec<(BufferId, BufferId)>, - retired_tape_buffers: Vec<(BufferId, BufferId)>, + retired_mesh_buffers: Vec, + retired_tape_buffers: Vec, records: EntityHashMap, pub live_count: u32, pub pending_refresh: EntityHashSet, @@ -266,6 +289,7 @@ impl InstanceState { index_buffers: RetainedBindingArray::new(), aabb_buffers: RetainedBindingArray::new(), tape_metadata_buffers: RetainedBindingArray::new(), + spatial_textures: RetainedBindingArray::new(), transforms: storage_buffer("solari_transforms"), previous_frame_transforms: storage_buffer("solari_previous_frame_transforms"), geometry_ids: storage_buffer("solari_geometry_ids"), @@ -380,9 +404,11 @@ impl InstanceState { self.vertex_buffers.release(&vertex_key); self.index_buffers.release(&index_key); } - for (aabb_key, metadata_key) in core::mem::take(&mut self.retired_tape_buffers) { + for (aabb_key, metadata_key, spatial_key) in core::mem::take(&mut self.retired_tape_buffers) + { self.aabb_buffers.release(&aabb_key); self.tape_metadata_buffers.release(&metadata_key); + self.spatial_textures.release(&spatial_key); } } @@ -674,12 +700,20 @@ impl InstanceState { )); } - let (Some(aabb_slice), Some(metadata_slice), Some(material_slot), Some(blas_address)) = ( + let ( + Some(aabb_slice), + Some(metadata_slice), + Some(spatial_texture), + Some(material_slot), + Some(blas_address), + ) = ( inputs.tape_allocator.tape_aabb_slice(&instance.tape), inputs.tape_allocator.tape_metadata_slice(&instance.tape), + inputs.tape_allocator.tape_spatial_texture(&instance.tape), material_slot, blas_address, - ) else { + ) + else { bevy_log::info!("Deactivating tape instance {}", instance.tape); self.deactivate_tape_instance(lights, entity, instance); return false; @@ -711,6 +745,21 @@ impl InstanceState { return false; } + let spatial_texture_key = spatial_texture.id(); + let spatial_capacity = MAX_SPATIAL_TEXTURE_COUNT.get(); + if !self + .spatial_textures + .has_room(&spatial_texture_key, spatial_capacity) + { + once!(warn!( + "Solari scene needs more than {} spatial textures. Instances past that limit will not \ + be rendered.", + MAX_SPATIAL_TEXTURE_COUNT.get() + )); + self.deactivate_tape_instance(lights, entity, instance); + return false; + } + let previous_buffers = instance.buffers.take(); let aabb_buffer_id = self .aabb_buffers @@ -722,7 +771,19 @@ impl InstanceState { metadata_slice.buffer.clone() }) .expect("tape metadata slab binding array had room but handed out no slot"); - instance.buffers = Some((aabb_buffer_key, metadata_buffer_key)); + let spatial_texture_id = self + .spatial_textures + .acquire(spatial_texture_key, spatial_capacity, || { + spatial_texture.create_view(&TextureViewDescriptor { + label: Some(&format!( + "Tape {} slot {} spatial texture view", + instance.tape, instance.slot + )), + ..Default::default() + }) + }) + .expect("spatial vslab binding array had room but handed out no slot"); + instance.buffers = Some((aabb_buffer_key, metadata_buffer_key, spatial_texture_key)); self.release_tape_buffers(previous_buffers); let aabb_count = (aabb_slice.range.len()) as u32; @@ -732,6 +793,7 @@ impl InstanceState { aabb_buffer_id, aabb_buffer_offset: aabb_slice.range.start, aabb_count, + spatial_texture_id, metadata_buffer_id, metadata_buffer_offset: metadata_slice.range.start, }, @@ -822,11 +884,11 @@ impl InstanceState { self.release_tape_buffers(instance.buffers.take()); } - fn release_mesh_buffers(&mut self, buffers: Option<(BufferId, BufferId)>) { + fn release_mesh_buffers(&mut self, buffers: Option) { self.retired_mesh_buffers.extend(buffers); } - fn release_tape_buffers(&mut self, buffers: Option<(BufferId, BufferId)>) { + fn release_tape_buffers(&mut self, buffers: Option) { self.retired_tape_buffers.extend(buffers); } diff --git a/crates/bevy_tape_drive_solari/src/scene/binder/mod.rs b/crates/bevy_tape_drive_solari/src/scene/binder/mod.rs index b83122a..7585628 100644 --- a/crates/bevy_tape_drive_solari/src/scene/binder/mod.rs +++ b/crates/bevy_tape_drive_solari/src/scene/binder/mod.rs @@ -49,7 +49,7 @@ use super::{ }, }; use crate::scene::{ - binder::instances::MAX_TAPE_SLAB_COUNT, + binder::instances::{MAX_SPATIAL_TEXTURE_COUNT, MAX_TAPE_SLAB_COUNT}, extract::{ ExtractedRaytracingDirectionalLight, ExtractedRaytracingPointLight, ExtractedRaytracingRectLight, ExtractedRaytracingSpotLight, @@ -101,6 +101,8 @@ impl FromWorld for RaytracingSceneBindings { storage_buffer_read_only_sized(false, None).count(MAX_MESH_SLAB_COUNT), storage_buffer_read_only_sized(false, None).count(MAX_TAPE_SLAB_COUNT), storage_buffer_read_only_sized(false, None).count(MAX_TAPE_SLAB_COUNT), + texture_3d(TextureSampleType::Float { filterable: true }) + .count(MAX_SPATIAL_TEXTURE_COUNT), texture_2d(TextureSampleType::Float { filterable: true }) .count(MAX_TEXTURE_COUNT), sampler(SamplerBindingType::Filtering).count(MAX_TEXTURE_COUNT), diff --git a/crates/bevy_tape_drive_solari/src/scene/bindings.wesl b/crates/bevy_tape_drive_solari/src/scene/bindings.wesl index 5cf0a26..dcf86a5 100644 --- a/crates/bevy_tape_drive_solari/src/scene/bindings.wesl +++ b/crates/bevy_tape_drive_solari/src/scene/bindings.wesl @@ -18,6 +18,7 @@ struct InstanceTapeIds { aabb_buffer_id: u32, aabb_buffer_offset: u32, aabb_count: u32, + spatial_texture_id: u32, metadata_buffer_id: u32, metadata_buffer_offset: u32, } @@ -143,31 +144,29 @@ const LIGHT_NOT_PRESENT_THIS_FRAME = 0xFFFFFFFFu; @group(0) @binding(0) var vertex_buffers: binding_array; @group(0) @binding(1) var index_buffers: binding_array; -@group(0) @binding(2) -var aabb_buffers: binding_array; -@group(0) @binding(3) -var tape_metadata_buffers: binding_array; -@group(0) @binding(4) var textures: binding_array>; -@group(0) @binding(5) var samplers: binding_array; -@group(0) @binding(6) var materials: array; -@group(0) @binding(7) var tlas: acceleration_structure; -@group(0) @binding(8) var previous_frame_tlas: acceleration_structure; -@group(0) @binding(9) var transforms: array>; -@group(0) @binding(10) var previous_frame_transforms: array>; -@group(0) @binding(11) var geometry_ids: array; -@group(0) @binding(12) -var tape_ids: array; -@group(0) @binding(13) var material_ids: array; -@group(0) @binding(14) var brdf_dfg_lut: texture_2d; -@group(0) @binding(15) var brdf_dfg_lut_sampler: sampler; -@group(0) @binding(16) var light_sources: array; -@group(0) @binding(17) var directional_lights: array; -@group(0) @binding(18) var point_lights: array; -@group(0) @binding(19) var rect_lights: array; -@group(0) @binding(20) var environment_map: texture_cube; -@group(0) @binding(21) var environment_map_sampler: sampler; -@group(0) @binding(22) var environment_map_light: EnvironmentMapLight; -@group(0) @binding(23) var previous_frame_light_id_translations: array; +@group(0) @binding(2) var aabb_buffers: binding_array; +@group(0) @binding(3) var tape_metadata_buffers: binding_array; +@group(0) @binding(4) var spatial_textures: binding_array>; +@group(0) @binding(5) var textures: binding_array>; +@group(0) @binding(6) var samplers: binding_array; +@group(0) @binding(7) var materials: array; +@group(0) @binding(8) var tlas: acceleration_structure; +@group(0) @binding(9) var previous_frame_tlas: acceleration_structure; +@group(0) @binding(10) var transforms: array>; +@group(0) @binding(11) var previous_frame_transforms: array>; +@group(0) @binding(12) var geometry_ids: array; +@group(0) @binding(13) var tape_ids: array; +@group(0) @binding(14) var material_ids: array; +@group(0) @binding(15) var brdf_dfg_lut: texture_2d; +@group(0) @binding(16) var brdf_dfg_lut_sampler: sampler; +@group(0) @binding(17) var light_sources: array; +@group(0) @binding(18) var directional_lights: array; +@group(0) @binding(19) var point_lights: array; +@group(0) @binding(20) var rect_lights: array; +@group(0) @binding(21) var environment_map: texture_cube; +@group(0) @binding(22) var environment_map_sampler: sampler; +@group(0) @binding(23) var environment_map_light: EnvironmentMapLight; +@group(0) @binding(24) var previous_frame_light_id_translations: array; const RAY_T_MIN = 0.001f; const RAY_T_MAX = 100000.0f; diff --git a/crates/bevy_tape_load/src/render/allocator.rs b/crates/bevy_tape_load/src/render/allocator.rs index 23d52a0..aa87058 100644 --- a/crates/bevy_tape_load/src/render/allocator.rs +++ b/crates/bevy_tape_load/src/render/allocator.rs @@ -12,16 +12,21 @@ use bevy_ecs::{ world::{FromWorld, World}, }; use bevy_log::warn; +use bevy_platform::collections::HashMap; use bevy_render::{ GpuResourceAppExt, Render, RenderApp, RenderSystems, render_asset::{ExtractedAssets, prepare_assets}, + render_resource::Texture, renderer::{RenderDevice, RenderQueue}, slab_allocator::{ Slab, SlabAllocationBufferSlice, SlabAllocator, SlabAllocatorSettings, SlabId, SlabItem, SlabItemLayout, }, }; -use wgpu::{BufferUsages, COPY_BUFFER_ALIGNMENT}; +use wgpu::{ + BufferUsages, COPY_BUFFER_ALIGNMENT, Extent3d, TextureDimension, TextureFormat, TextureUsages, +}; +use wgpu_types::TextureDescriptor; use super::{PackedAabb, RenderTape, TapeMetadata}; use crate::tape::Tape; @@ -43,6 +48,7 @@ pub struct TapeAllocator { /// Holds all buffers and offset allocators. #[deref] slab_allocator: SlabAllocator, + spatial_texture_allocator: HashMap, Texture>, } /// Tunable parameters that customize the behavior of the allocator. @@ -94,7 +100,7 @@ pub struct TapeSlabs { /// The slab storing the tape's aabb data. pub aabb_slab_id: TapeSlabId, /// The slab storing the tape's metadata. - pub metadata_slab_id: Option, + pub metadata_slab_id: TapeSlabId, } /// Returns the type of buffer that this is: vertex, index, metadata. @@ -192,7 +198,10 @@ impl FromWorld for TapeAllocator { let mut slab_allocator = SlabAllocator::new(); slab_allocator.extra_buffer_usages |= tape_allocator_settings.extra_buffer_usages; - Self { slab_allocator } + Self { + slab_allocator, + spatial_texture_allocator: HashMap::new(), + } } } @@ -266,6 +275,13 @@ impl TapeAllocator { ) } + /// Returns the spatial texture for the tape with the given ID. + /// + /// If the tape wasn't allocated, returns None. + pub fn tape_spatial_texture(&self, tape_id: &AssetId) -> Option<&Texture> { + self.spatial_texture_allocator.get(tape_id) + } + /// Returns the IDs of the vertex buffer and index buffer respectively for /// the tape with the given ID. /// @@ -275,7 +291,7 @@ impl TapeAllocator { pub fn tape_slabs(&self, tape_id: &AssetId) -> Option { Some(TapeSlabs { aabb_slab_id: self.tape_id_to_aabb_slab(tape_id).cloned()?, - metadata_slab_id: self.tape_id_to_metadata_slab(tape_id).cloned(), + metadata_slab_id: self.tape_id_to_metadata_slab(tape_id).cloned()?, }) } @@ -359,6 +375,25 @@ impl TapeAllocator { aabb_element_layout, tape_allocator_settings, ); + + // Allocate spatial texture. + self.spatial_texture_allocator.insert( + *tape_id, + render_device.create_texture(&TextureDescriptor { + label: Some(&format!("Tape {} spatial texture", tape_id)), + format: TextureFormat::R32Float, + dimension: TextureDimension::D3, + usage: TextureUsages::TEXTURE_BINDING | TextureUsages::STORAGE_BINDING, + mip_level_count: 1, + sample_count: 1, + view_formats: &[TextureFormat::R32Float], + size: Extent3d { + width: tape.subdivision, + height: tape.subdivision, + depth_or_array_layers: tape.subdivision, + }, + }), + ); } // Perform growth. @@ -450,6 +485,7 @@ impl TapeAllocator { for tape_id in tapes_to_free { deallocation_stage.free(&TapeAllocationKey::new(*tape_id, ElementClass::Metadata)); deallocation_stage.free(&TapeAllocationKey::new(*tape_id, ElementClass::Aabb)); + self.spatial_texture_allocator.remove(tape_id); } deallocation_stage.commit(); diff --git a/crates/bevy_tape_load/src/render/mod.rs b/crates/bevy_tape_load/src/render/mod.rs index 84f60a7..135a92e 100644 --- a/crates/bevy_tape_load/src/render/mod.rs +++ b/crates/bevy_tape_load/src/render/mod.rs @@ -187,6 +187,8 @@ pub struct ReplacementModules { pub struct RenderTape { pub seed: u64, pub subdivision: u32, + pub time: f32, + pub key: u64, pub enable_gen: Handle, pub fuzz: Handle, @@ -224,10 +226,29 @@ impl RenderAsset for RenderTape { tape: Self::SourceAsset, _tape_id: AssetId, (asset_server, replacement_modules, pipeline_cache): &mut SystemParamItem, - _: Option<&Self>, + previous_asset: Option<&Self>, ) -> Result> { let key = tape.get_tape_key(); + if let Some(previous) = previous_asset + && previous.key == key + { + return Ok(RenderTape { + seed: tape.seed, + subdivision: tape.subdivision, + time: tape.time, + key, + enable_gen: previous.enable_gen.clone(), + fuzz: previous.fuzz.clone(), + normals: previous.normals.clone(), + spatial_texture: previous.spatial_texture.clone(), + trace: previous.trace.clone(), + enable_gen_pipeline: previous.enable_gen_pipeline, + fuzz_pipeline: previous.fuzz_pipeline, + spatial_texture_pipeline: previous.spatial_texture_pipeline, + }); + } + let enable_gen = asset_server.add(tape.sdf_specialize_module_with_key( key, replacement_modules.enable_gen.clone(), @@ -286,6 +307,8 @@ impl RenderAsset for RenderTape { Ok(RenderTape { seed: tape.seed, subdivision: tape.subdivision, + time: tape.time, + key, enable_gen, fuzz, normals, diff --git a/crates/bevy_tape_load/src/tape.rs b/crates/bevy_tape_load/src/tape.rs index e871630..eb09082 100644 --- a/crates/bevy_tape_load/src/tape.rs +++ b/crates/bevy_tape_load/src/tape.rs @@ -10,13 +10,14 @@ use rspirv::{binary::Assemble as _, dr::Module}; use crate::{render::PackedAabb, ssa::*}; /// A tape drive tape. -#[derive(Asset, Clone, Debug, Reflect, PartialEq, Hash)] +#[derive(Asset, Clone, Debug, Reflect, PartialEq)] #[reflect(Clone)] pub struct Tape { pub raytracing: MeshRaytracingFlags, pub parts: SSATape, pub seed: u64, pub subdivision: u32, + pub time: f32, } impl Default for Tape { @@ -26,10 +27,21 @@ impl Default for Tape { parts: Default::default(), seed: 0, subdivision: 8, + time: 0.0, } } } +impl Hash for Tape { + fn hash(&self, state: &mut H) { + self.raytracing.hash(state); + self.parts.hash(state); + self.seed.hash(state); + self.subdivision.hash(state); + self.time.to_bits().hash(state); + } +} + impl Tape { pub fn get_aabb(&self, time: f32) -> Aabb3d { let (lowest_corner, highest_corner) = self.parts.get_aabb(time); diff --git a/examples/pica_pica.rs b/examples/pica_pica.rs index 578be36..f983627 100644 --- a/examples/pica_pica.rs +++ b/examples/pica_pica.rs @@ -324,6 +324,7 @@ fn setup_pica_pica( parts: csg, seed: 0, subdivision: 8, + time: 0.0, }; let loaded_tape = asset_server.add(tape);