From f4be035f04a19a9f34ca68288ec32df91c042a71 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 3 Jun 2026 05:03:32 +0200 Subject: [PATCH] Add `Physics::DeleteScene` --- Source/Engine/Physics/Physics.cpp | 9 +++++++++ Source/Engine/Physics/Physics.h | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/Source/Engine/Physics/Physics.cpp b/Source/Engine/Physics/Physics.cpp index ecd7c1093..24bb4c1a6 100644 --- a/Source/Engine/Physics/Physics.cpp +++ b/Source/Engine/Physics/Physics.cpp @@ -184,6 +184,15 @@ PhysicsScene* Physics::FindScene(const StringView& name) return nullptr; } +void Physics::DeleteScene(PhysicsScene* scene) +{ + if (scene == nullptr || scene == DefaultScene) + return; + scene->CollectResults(); + Scenes.RemoveKeepOrder(scene); + Delete(scene); +} + bool Physics::GetAutoSimulation() { return !DefaultScene || DefaultScene->GetAutoSimulation(); diff --git a/Source/Engine/Physics/Physics.h b/Source/Engine/Physics/Physics.h index 85cd5e77b..11fd3fb80 100644 --- a/Source/Engine/Physics/Physics.h +++ b/Source/Engine/Physics/Physics.h @@ -32,6 +32,11 @@ API_CLASS(Static) class FLAXENGINE_API Physics /// API_FUNCTION() static PhysicsScene* FindScene(const StringView& name); + /// + /// Delete an existing scene (excluding the default one). + /// + API_FUNCTION() static void DeleteScene(PhysicsScene* scene); + public: /// /// The automatic simulation feature. True if perform physics simulation after on fixed update by auto, otherwise user should do it.