Fix the crash when switching between sim obj and physix layout in animation editor. (#4185)
* Update the simulated object layout Signed-off-by: rhhong <rhhong@amazon.com> * Fixed the bug. Do not store uncessory cached selected model indices which would become stall. Signed-off-by: rhhong <rhhong@amazon.com> * update the simulted object layout. Signed-off-by: rhhong <rhhong@amazon.com> * Get rid of locally cached selectedIndices variable. Signed-off-by: rhhong <rhhong@amazon.com> * Remove debug code Signed-off-by: rhhong <rhhong@amazon.com>
This commit is contained in:
+12
-8
@@ -131,7 +131,8 @@ namespace EMotionFX
|
||||
|
||||
void SimulatedObjectColliderWidget::InternalReinit()
|
||||
{
|
||||
if (m_selectedModelIndices.size() == 1)
|
||||
const QModelIndexList& selectedModelIndices = GetSelectedModelIndices();
|
||||
if (selectedModelIndices.size() == 1)
|
||||
{
|
||||
Physics::CharacterColliderNodeConfiguration* nodeConfig = GetNodeConfig();
|
||||
if (nodeConfig)
|
||||
@@ -172,12 +173,13 @@ namespace EMotionFX
|
||||
}
|
||||
|
||||
AZStd::string labelText;
|
||||
const QModelIndexList& selectedModelIndices = GetSelectedModelIndices();
|
||||
const AZStd::vector<SimulatedObject*>& simObjs = actor->GetSimulatedObjectSetup()->GetSimulatedObjects();
|
||||
for (const SimulatedObject* obj : simObjs)
|
||||
{
|
||||
for (int i = 0; i < m_selectedModelIndices.size(); ++i)
|
||||
for (int i = 0; i < selectedModelIndices.size(); ++i)
|
||||
{
|
||||
Node* node = m_selectedModelIndices[i].data(SkeletonModel::ROLE_POINTER).value<Node*>();
|
||||
Node* node = selectedModelIndices[i].data(SkeletonModel::ROLE_POINTER).value<Node*>();
|
||||
if (obj->FindSimulatedJointBySkeletonJointIndex(node->GetNodeIndex()))
|
||||
{
|
||||
if (!labelText.empty())
|
||||
@@ -208,8 +210,9 @@ namespace EMotionFX
|
||||
return;
|
||||
}
|
||||
|
||||
const QModelIndexList& selectedModelIndices = GetSelectedModelIndices();
|
||||
// Only show the notification when it is single selection.
|
||||
if (m_selectedModelIndices.size() != 1)
|
||||
if (selectedModelIndices.size() != 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -250,17 +253,18 @@ namespace EMotionFX
|
||||
|
||||
void SimulatedObjectColliderWidget::OnAddCollider(const AZ::TypeId& colliderType)
|
||||
{
|
||||
ColliderHelpers::AddCollider(m_selectedModelIndices, PhysicsSetup::SimulatedObjectCollider, colliderType);
|
||||
ColliderHelpers::AddCollider(GetSelectedModelIndices(), PhysicsSetup::SimulatedObjectCollider, colliderType);
|
||||
}
|
||||
|
||||
void SimulatedObjectColliderWidget::OnCopyCollider(size_t colliderIndex)
|
||||
{
|
||||
ColliderHelpers::CopyColliderToClipboard(m_selectedModelIndices.first(), colliderIndex, PhysicsSetup::SimulatedObjectCollider);
|
||||
ColliderHelpers::CopyColliderToClipboard(GetSelectedModelIndices().first(), colliderIndex, PhysicsSetup::SimulatedObjectCollider);
|
||||
}
|
||||
|
||||
void SimulatedObjectColliderWidget::OnPasteCollider(size_t colliderIndex, bool replace)
|
||||
{
|
||||
ColliderHelpers::PasteColliderFromClipboard(m_selectedModelIndices.first(), colliderIndex, PhysicsSetup::SimulatedObjectCollider, replace);
|
||||
ColliderHelpers::PasteColliderFromClipboard(
|
||||
GetSelectedModelIndices().first(), colliderIndex, PhysicsSetup::SimulatedObjectCollider, replace);
|
||||
}
|
||||
|
||||
void SimulatedObjectColliderWidget::OnRemoveCollider(size_t colliderIndex)
|
||||
@@ -270,7 +274,7 @@ namespace EMotionFX
|
||||
|
||||
Physics::CharacterColliderNodeConfiguration* SimulatedObjectColliderWidget::GetNodeConfig() const
|
||||
{
|
||||
AZ_Assert(m_selectedModelIndices.size() == 1, "Get Node config function only return the config when it is single seleted");
|
||||
AZ_Assert(GetSelectedModelIndices().size() == 1, "Get Node config function only return the config when it is single seleted");
|
||||
Actor* actor = GetActor();
|
||||
Node* joint = GetNode();
|
||||
if (!actor || !joint)
|
||||
|
||||
Reference in New Issue
Block a user