Adds feature for creating multiple physics scenes

This commit is contained in:
Iain Mckay
2021-12-01 15:30:31 +01:00
parent cc3617b5c2
commit a4e102672d
30 changed files with 2312 additions and 1337 deletions

View File

@@ -22,6 +22,7 @@
#include "Engine/Profiler/ProfilerCPU.h"
#include "Engine/Scripting/Script.h"
#include "Engine/Engine/Time.h"
#include "Engine/Physics/Physics.h"
#include "Engine/Scripting/ManagedCLR/MAssembly.h"
#include "Engine/Scripting/ManagedCLR/MClass.h"
#include "Engine/Scripting/ManagedCLR/MDomain.h"
@@ -164,6 +165,8 @@ bool LevelImpl::spawnActor(Actor* actor, Actor* parent)
}
if (parent == nullptr)
parent = Level::Scenes[0];
actor->SetPhysicsScene(parent->GetPhysicsScene());
actor->SetParent(parent, true, true);
}
@@ -776,6 +779,8 @@ bool LevelImpl::unloadScene(Scene* scene)
// Force flush deleted objects so we actually delete unloaded scene objects (prevent from reloading their managed objects, etc.)
ObjectsRemovalService::Flush();
Physics::EndPlay();
return false;
}
@@ -1026,6 +1031,8 @@ bool Level::loadScene(rapidjson_flax::Value& data, int32 engineBuild, Scene** ou
{
PROFILE_CPU_NAMED("BeginPlay");
Physics::BeginPlay();
ScopeLock lock(ScenesLock);
Scenes.Add(scene);
SceneBeginData beginData;