Defer the render plugin reinit to main thread (#1626)

Fix a problem with reloading actor in emfx studio crashes the editor 
Signed-off-by: rhhong <rhhong@amazon.com>
main
Roman 5 years ago committed by GitHub
parent 0095e5aa6a
commit e1f6d45b04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -168,7 +168,7 @@ namespace EMotionFX
AZ::SceneAPI::Events::ProcessingResult ActorGroupBehavior::BuildDefault(AZ::SceneAPI::Containers::Scene& scene) const
{
// Skip adding the actor group if it's already exist.
// Skip adding the actor group if it already exists.
if (SceneHasActorGroup(scene))
{
return AZ::SceneAPI::Events::ProcessingResult::Ignored;
@ -185,7 +185,7 @@ namespace EMotionFX
}
const bool hasAnimationData = AZ::SceneAPI::Utilities::DoesSceneGraphContainDataLike<AZ::SceneAPI::DataTypes::IAnimationData>(scene, true);
// Skip adding the actor group if it's contain animation data but don't contain any skindata or blendshapedata.
// Skip adding the actor group if it contains animation data but doesn't contain any skin or blendshape data.
if (hasAnimationData && !hasSkinData && !hasBlendShapeData)
{
return AZ::SceneAPI::Events::ProcessingResult::Ignored;

@ -313,7 +313,7 @@ namespace EMStudio
void RenderPlugin::OnActorReady([[maybe_unused]] EMotionFX::Actor* actor)
{
ReInit(/*resetViewCloseup=*/true);
m_reinitRequested = true;
}
// try to locate the helper actor for a given instance
@ -535,6 +535,7 @@ namespace EMStudio
}
mFirstFrameAfterReInit = true;
m_reinitRequested = false;
// zoom the camera to the available character only in case we're dealing with a single instance
if (resetViewCloseup && numActorInstances == 1)
@ -851,6 +852,11 @@ namespace EMStudio
return;
}
if (m_reinitRequested)
{
ReInit(/*resetViewCloseup=*/true);
}
// update EMotion FX, but don't render
UpdateActorInstances(timePassedInSeconds);

@ -226,6 +226,7 @@ namespace EMStudio
QWidget* mInnerWidget;
CommandSystem::SelectionList* mCurrentSelection;
bool mFirstFrameAfterReInit;
bool m_reinitRequested = false;
// command callbacks
MCORE_DEFINECOMMANDCALLBACK(UpdateRenderActorsCallback);

Loading…
Cancel
Save