fix aabb alignment

This commit is contained in:
2026-10-15 01:18:58 +01:00
parent 5270632d4c
commit 8fb28f2f96
6 changed files with 50 additions and 21 deletions
@@ -23,7 +23,7 @@ use bevy_render::{
};
use wgpu::{BufferUsages, COPY_BUFFER_ALIGNMENT};
use super::{Aabb, RenderTape, TapeMetadata};
use super::{PackedAabb, RenderTape, TapeMetadata};
use crate::tape::Tape;
/// A plugin that manages GPU memory for tape data.
@@ -491,7 +491,7 @@ impl ElementLayout {
/// Creates the appropriate [`ElementLayout`] for the given tape's aabb
/// data.
fn aabb(_tape: &Tape) -> ElementLayout {
ElementLayout::new(ElementClass::Aabb, size_of::<Aabb>() as u64)
ElementLayout::new(ElementClass::Aabb, size_of::<PackedAabb>() as u64)
}
}
+2 -10
View File
@@ -11,7 +11,6 @@ use bevy_ecs::{
system::{SystemParamItem, lifetimeless::SRes},
};
use bevy_math::Vec3;
use bevy_reflect::Reflect;
use bevy_render::{
Render, RenderApp, RenderSystems,
render_asset::{
@@ -38,6 +37,8 @@ use crate::{
pub struct PackedAabb {
min: Vec3,
max: Vec3,
pad_a: u32,
pad_b: u32,
}
/// Per-tape metadata, stored in [`super::allocator::TapeAllocator`].
@@ -168,15 +169,6 @@ pub fn prepare_tape_metadata_fallback_buffer(
commands.insert_resource(TapeMetadataFallbackBuffer { slab_id, buffer });
}
#[derive(Debug, PartialEq, Clone, Copy, Reflect)]
#[reflect(Debug, PartialEq, Clone)]
pub struct Aabb {
/// The minimum point of the box
pub min: Vec3,
/// The maximum point of the box
pub max: Vec3,
}
#[derive(Resource)]
pub struct ReplacementModules {
pub enable_gen: Module,
+3 -2
View File
@@ -7,7 +7,7 @@ use bevy_shader::Shader;
use bevy_shape::Aabb3d;
use rspirv::{binary::Assemble as _, dr::Module};
use crate::{render::Aabb, ssa::*};
use crate::{render::PackedAabb, ssa::*};
/// A tape drive tape.
#[derive(Asset, Clone, Debug, Reflect, PartialEq, Hash)]
@@ -38,7 +38,8 @@ impl Tape {
}
pub fn get_aabb_buffer_size(&self) -> u64 {
((self.subdivision * self.subdivision * self.subdivision) as u64) * size_of::<Aabb>() as u64
((self.subdivision * self.subdivision * self.subdivision) as u64)
* size_of::<PackedAabb>() as u64
}
pub fn get_tape_key(&self) -> u64 {