mirror of
https://github.com/lisk77/comet.git
synced 2025-10-23 21:38:50 +00:00
fix: got back to the old render_scene_2d because my Camera2D way is kind of borked.
This commit is contained in:
parent
ca3c3dd5e6
commit
c79e69f8f4
3 changed files with 205 additions and 112 deletions
|
|
@ -84,4 +84,59 @@ impl SparseSet {
|
|||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*#[derive(Debug, Clone)]
|
||||
pub struct SparseSet {
|
||||
sparse: Vec<Option<usize>>,
|
||||
dense: Column,
|
||||
}
|
||||
|
||||
impl SparseSet {
|
||||
pub fn new<T: 'static>(capacity: usize) -> Self {
|
||||
Self {
|
||||
sparse: Vec::new(),
|
||||
dense: Column::new::<T>(capacity),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn insert<T: 'static>(&mut self, index: usize, value: T) {
|
||||
if index >= self.sparse.len() {
|
||||
self.sparse.resize(index + 1, None);
|
||||
}
|
||||
self.sparse[index] = Some(self.dense.data.len());
|
||||
self.dense.push(value);
|
||||
}
|
||||
|
||||
pub fn remove<T: 'static>(&mut self, index: usize) -> Option<T>{
|
||||
if let Some(sparse_index) = self.sparse.get(index).and_then(|x| x.as_ref()) {
|
||||
let dense_index = *sparse_index;
|
||||
let last_index = self.dense.data.len() - 1;
|
||||
if dense_index != last_index {
|
||||
self.dense.swap(dense_index, last_index);
|
||||
if let Some(sparse) = self.sparse.get_mut(last_index) {
|
||||
*sparse = Some(dense_index);
|
||||
}
|
||||
}
|
||||
self.sparse[index] = None;
|
||||
self.dense.remove::<T>(last_index)
|
||||
}
|
||||
else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get<T: 'static>(&self, index: usize) -> Option<&T> {
|
||||
match self.sparse.get(index).and_then(|x| x.as_ref()) {
|
||||
Some(sparse_index) => self.dense.get::<T>(*sparse_index),
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_mut<T: 'static>(&mut self, index: usize) -> Option<&mut T> {
|
||||
match self.sparse.get(index).and_then(|x| x.as_ref()) {
|
||||
Some(sparse_index) => self.dense.get_mut::<T>(*sparse_index),
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
}*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue