Replace Instances<T>::empty() with Instances<T>::default() and make it return an empty table for vector data instead of one empty row (#2689)

Make Instances<T>::default() return an empty table for everything, even vector, and replace ::empty() with ::default()
This commit is contained in:
Keavon Chambers
2025-06-04 21:00:21 -07:00
committed by GitHub
parent cb4289169d
commit 2696abc6b3
18 changed files with 110 additions and 115 deletions
+6 -16
View File
@@ -26,15 +26,6 @@ impl<T> Instances<T> {
}
}
pub fn empty() -> Self {
Self {
instance: Vec::new(),
transform: Vec::new(),
alpha_blending: Vec::new(),
source_node_id: Vec::new(),
}
}
pub fn push(&mut self, instance: Instance<T>) {
self.instance.push(instance.instance);
self.transform.push(instance.transform);
@@ -119,14 +110,13 @@ impl<T> Instances<T> {
}
}
impl<T: Default + Hash + 'static> Default for Instances<T> {
impl<T> Default for Instances<T> {
fn default() -> Self {
use core::any::TypeId;
if TypeId::of::<T>() != TypeId::of::<crate::vector::VectorData>() {
// TODO: Remove the 'static trait bound when this special casing is removed by making all types return empty
Self::empty()
} else {
Self::new(T::default())
Self {
instance: Vec::new(),
transform: Vec::new(),
alpha_blending: Vec::new(),
source_node_id: Vec::new(),
}
}
}