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 {
|
||||
const allocator = self.allocator;
|
||||
|
||||
self.system.optimizeBroadPhase();
|
||||
for (PhysicsCharacter.BaseContainer.list.items) |physChar| {
|
||||
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();
|
||||
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.system.update(0.01, .{}) catch {};
|
||||
// self.system.update(0.01, .{}) catch {};
|
||||
|
||||
self.idToEntity.deinit(self.allocator);
|
||||
// core.undefineComponent(PhysicsCharacter);
|
||||
|
|
|
|||
Loading…
Reference in New Issue