Adds feature for creating multiple physics scenes
This commit is contained in:
@@ -2,10 +2,14 @@
|
||||
|
||||
#include "RigidBody.h"
|
||||
#include "PxMaterial.h"
|
||||
#include <iterator>
|
||||
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Physics/Utilities.h"
|
||||
#include "Engine/Physics/Colliders/Collider.h"
|
||||
#include "Engine/Physics/Physics.h"
|
||||
#include "Engine/Physics/PhysicalMaterial.h"
|
||||
#include "Engine/Physics/PhysicsScene.h"
|
||||
#include "Engine/Serialization/Serialization.h"
|
||||
#include <ThirdParty/PhysX/extensions/PxRigidBodyExt.h>
|
||||
#include <ThirdParty/PhysX/PxRigidActor.h>
|
||||
@@ -476,7 +480,7 @@ void RigidBody::CreateActor()
|
||||
|
||||
// Register actor
|
||||
const bool putToSleep = !_startAwake && GetEnableSimulation() && !GetIsKinematic() && IsActiveInHierarchy();
|
||||
Physics::AddActor(_actor, putToSleep);
|
||||
GetPhysicsScene()->AddActor(_actor, putToSleep);
|
||||
|
||||
// Update cached data
|
||||
UpdateBounds();
|
||||
@@ -580,7 +584,7 @@ void RigidBody::EndPlay()
|
||||
if (_actor)
|
||||
{
|
||||
// Remove actor
|
||||
Physics::RemoveActor(_actor);
|
||||
GetPhysicsScene()->RemoveActor(_actor);
|
||||
_actor = nullptr;
|
||||
}
|
||||
}
|
||||
@@ -627,3 +631,15 @@ void RigidBody::OnTransformChanged()
|
||||
PhysicsActor::OnTransformChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void RigidBody::OnPhysicsSceneChanged(PhysicsScene* previous)
|
||||
{
|
||||
ASSERT(previous);
|
||||
|
||||
PhysicsActor::OnPhysicsSceneChanged(previous);
|
||||
|
||||
previous->UnlinkActor(_actor);
|
||||
|
||||
const bool putToSleep = !_startAwake && GetEnableSimulation() && !GetIsKinematic() && IsActiveInHierarchy();
|
||||
GetPhysicsScene()->AddActor(_actor, putToSleep);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user