Merge pull request #693 from aws-lumberyard-dev/shape_collider_editor_body
fixing bug with shape collider editor body not being deleted when it …
This commit is contained in:
@@ -1057,7 +1057,14 @@ namespace PhysX
|
||||
|
||||
bool EditorColliderComponent::IsPhysicsEnabled() const
|
||||
{
|
||||
return m_editorBodyHandle != AzPhysics::InvalidSimulatedBodyHandle;
|
||||
if (m_sceneInterface && m_editorBodyHandle != AzPhysics::InvalidSimulatedBodyHandle)
|
||||
{
|
||||
if (auto* body = m_sceneInterface->GetSimulatedBodyFromHandle(m_editorSceneHandle, m_editorBodyHandle))
|
||||
{
|
||||
return body->m_simulating;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
AZ::Aabb EditorColliderComponent::GetAabb() const
|
||||
|
||||
@@ -267,8 +267,14 @@ namespace PhysX
|
||||
|
||||
if (m_sceneInterface)
|
||||
{
|
||||
//remove the previous body if any
|
||||
if (m_editorBodyHandle != AzPhysics::InvalidSimulatedBodyHandle)
|
||||
{
|
||||
m_sceneInterface->RemoveSimulatedBody(m_editorSceneHandle, m_editorBodyHandle);
|
||||
m_editorBodyHandle = AzPhysics::InvalidSimulatedBodyHandle;
|
||||
}
|
||||
|
||||
m_editorBodyHandle = m_sceneInterface->AddSimulatedBody(m_editorSceneHandle, &configuration);
|
||||
m_editorBody = azdynamic_cast<StaticRigidBody*>(m_sceneInterface->GetSimulatedBodyFromHandle(m_editorSceneHandle, m_editorBodyHandle));
|
||||
}
|
||||
|
||||
AzPhysics::SimulatedBodyComponentRequestsBus::Handler::BusConnect(GetEntityId());
|
||||
@@ -676,7 +682,6 @@ namespace PhysX
|
||||
{
|
||||
m_sceneInterface->RemoveSimulatedBody(m_editorSceneHandle, m_editorBodyHandle);
|
||||
m_editorBodyHandle = AzPhysics::InvalidSimulatedBodyHandle;
|
||||
m_editorBody = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -747,21 +752,38 @@ namespace PhysX
|
||||
|
||||
bool EditorShapeColliderComponent::IsPhysicsEnabled() const
|
||||
{
|
||||
return m_editorBody != nullptr && m_editorBody->m_simulating;
|
||||
if (m_sceneInterface && m_editorBodyHandle != AzPhysics::InvalidSimulatedBodyHandle)
|
||||
{
|
||||
if (auto* body = m_sceneInterface->GetSimulatedBodyFromHandle(m_editorSceneHandle, m_editorBodyHandle))
|
||||
{
|
||||
return body->m_simulating;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
AZ::Aabb EditorShapeColliderComponent::GetAabb() const
|
||||
{
|
||||
if (m_editorBody)
|
||||
if (m_sceneInterface && m_editorBodyHandle != AzPhysics::InvalidSimulatedBodyHandle)
|
||||
{
|
||||
return m_editorBody->GetAabb();
|
||||
if (auto* body = m_sceneInterface->GetSimulatedBodyFromHandle(m_editorSceneHandle, m_editorBodyHandle))
|
||||
{
|
||||
return body->GetAabb();
|
||||
}
|
||||
}
|
||||
return AZ::Aabb::CreateNull();
|
||||
}
|
||||
|
||||
AzPhysics::SimulatedBody* EditorShapeColliderComponent::GetSimulatedBody()
|
||||
{
|
||||
return m_editorBody;
|
||||
if (m_sceneInterface && m_editorBodyHandle != AzPhysics::InvalidSimulatedBodyHandle)
|
||||
{
|
||||
if (auto* body = m_sceneInterface->GetSimulatedBodyFromHandle(m_editorSceneHandle, m_editorBodyHandle))
|
||||
{
|
||||
return body;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AzPhysics::SimulatedBodyHandle EditorShapeColliderComponent::GetSimulatedBodyHandle() const
|
||||
@@ -771,9 +793,12 @@ namespace PhysX
|
||||
|
||||
AzPhysics::SceneQueryHit EditorShapeColliderComponent::RayCast(const AzPhysics::RayCastRequest& request)
|
||||
{
|
||||
if (m_editorBody)
|
||||
if (m_sceneInterface && m_editorBodyHandle != AzPhysics::InvalidSimulatedBodyHandle)
|
||||
{
|
||||
return m_editorBody->RayCast(request);
|
||||
if (auto* body = m_sceneInterface->GetSimulatedBodyFromHandle(m_editorSceneHandle, m_editorBodyHandle))
|
||||
{
|
||||
return body->RayCast(request);
|
||||
}
|
||||
}
|
||||
return AzPhysics::SceneQueryHit();
|
||||
}
|
||||
|
||||
@@ -143,7 +143,6 @@ namespace PhysX
|
||||
DebugDraw::Collider m_colliderDebugDraw; //!< Handles drawing the collider based on global and local
|
||||
AzPhysics::SceneInterface* m_sceneInterface = nullptr;
|
||||
AzPhysics::SceneHandle m_editorSceneHandle = AzPhysics::InvalidSceneHandle;
|
||||
StaticRigidBody* m_editorBody = nullptr; //!< Body in the editor physics scene if there is no rigid body component.
|
||||
AzPhysics::SimulatedBodyHandle m_editorBodyHandle = AzPhysics::InvalidSimulatedBodyHandle; //!< Handle to the body in the editor physics scene if there is no rigid body component.
|
||||
bool m_shapeTypeWarningIssued = false; //!< Records whether a warning about unsupported shapes has been previously issued.
|
||||
PolygonPrismMeshUtils::Mesh2D m_mesh; //!< Used for storing decompositions of the polygon prism.
|
||||
|
||||
Reference in New Issue
Block a user