mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-24 02:18:11 +08:00
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:
@@ -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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user