fixed out of order deinit crash
This commit is contained in:
parent
e78d01b547
commit
a6ae7f02f0
|
|
@ -239,10 +239,22 @@ pub const PhysicsRuntime = struct {
|
||||||
|
|
||||||
pub fn deinit(self: *@This()) void {
|
pub fn deinit(self: *@This()) void {
|
||||||
const allocator = self.allocator;
|
const allocator = self.allocator;
|
||||||
|
self.system.optimizeBroadPhase();
|
||||||
for (PhysicsCharacter.BaseContainer.list.items) |physChar| {
|
for (PhysicsCharacter.BaseContainer.list.items) |physChar| {
|
||||||
physChar.deinit();
|
physChar.deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// self.system.update(0.01, .{}) catch {};
|
||||||
|
{
|
||||||
|
const interface = self.system.getBodyInterfaceMut();
|
||||||
|
|
||||||
|
var iterator = self.idToEntity.keyIterator();
|
||||||
|
while (iterator.next()) |bodyId| {
|
||||||
|
self.system.optimizeBroadPhase();
|
||||||
|
interface.removeAndDestroyBody(bodyId.*);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
var iterator = self.shapes.iterator();
|
var iterator = self.shapes.iterator();
|
||||||
while (iterator.next()) |n| {
|
while (iterator.next()) |n| {
|
||||||
|
|
@ -250,18 +262,8 @@ pub const PhysicsRuntime = struct {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.system.update(0.01, .{}) catch {};
|
|
||||||
{
|
|
||||||
const interface = self.system.getBodyInterfaceMut();
|
|
||||||
|
|
||||||
var iterator = self.idToEntity.keyIterator();
|
|
||||||
while (iterator.next()) |bodyId| {
|
|
||||||
interface.removeAndDestroyBody(bodyId.*);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
self.bodyIdsToDestroy.deinit(self.allocator);
|
self.bodyIdsToDestroy.deinit(self.allocator);
|
||||||
self.system.update(0.01, .{}) catch {};
|
// self.system.update(0.01, .{}) catch {};
|
||||||
|
|
||||||
self.idToEntity.deinit(self.allocator);
|
self.idToEntity.deinit(self.allocator);
|
||||||
// core.undefineComponent(PhysicsCharacter);
|
// core.undefineComponent(PhysicsCharacter);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue