mirror of
https://github.com/bevyengine/bevy
synced 2025-02-16 22:18:33 +00:00
BugFix: Archetype grow with defferent size. (#930)
Co-authored-by: heshuai <heshuai@163.com>
This commit is contained in:
parent
12f29bd38c
commit
7d4cb70d92
1 changed files with 4 additions and 4 deletions
|
@ -272,9 +272,9 @@ impl Archetype {
|
||||||
fn grow(&mut self, increment: usize) {
|
fn grow(&mut self, increment: usize) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let old_count = self.len;
|
let old_count = self.len;
|
||||||
let count = old_count + increment;
|
let new_capacity = self.capacity() + increment;
|
||||||
self.entities.resize(
|
self.entities.resize(
|
||||||
self.entities.len() + increment,
|
new_capacity,
|
||||||
Entity {
|
Entity {
|
||||||
id: u32::MAX,
|
id: u32::MAX,
|
||||||
generation: u32::MAX,
|
generation: u32::MAX,
|
||||||
|
@ -284,7 +284,7 @@ impl Archetype {
|
||||||
for type_state in self.state.values_mut() {
|
for type_state in self.state.values_mut() {
|
||||||
type_state
|
type_state
|
||||||
.component_flags
|
.component_flags
|
||||||
.resize_with(count, ComponentFlags::empty);
|
.resize_with(new_capacity, ComponentFlags::empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
let old_data_size = mem::replace(&mut self.data_size, 0);
|
let old_data_size = mem::replace(&mut self.data_size, 0);
|
||||||
|
@ -294,7 +294,7 @@ impl Archetype {
|
||||||
let ty_state = self.state.get_mut(&ty.id).unwrap();
|
let ty_state = self.state.get_mut(&ty.id).unwrap();
|
||||||
old_offsets.push(ty_state.offset);
|
old_offsets.push(ty_state.offset);
|
||||||
ty_state.offset = self.data_size;
|
ty_state.offset = self.data_size;
|
||||||
self.data_size += ty.layout.size() * count;
|
self.data_size += ty.layout.size() * new_capacity;
|
||||||
}
|
}
|
||||||
let new_data = if self.data_size == 0 {
|
let new_data = if self.data_size == 0 {
|
||||||
NonNull::dangling()
|
NonNull::dangling()
|
||||||
|
|
Loading…
Add table
Reference in a new issue