Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UE 5.3 fixed. Synchronized object transform feature added. #34

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
<Property Name="LocalBinaryDir" Value="$(RootDir)\Engine\Restricted\NotForLicensees\Binaries\$(MayaPlatform)\Maya"/>
<Property Name="LocalExtraDir" Value="$(RootDir)\Engine\Restricted\NotForLicensees\Extras\MayaUnrealLiveLinkPlugin"/>

<Node Name="Compile UnrealHeaderTool Maya">
<Compile Target="UnrealHeaderTool" Platform="$(MayaPlatform)" Configuration="$(BuildTarget)" Arguments="-precompile -nodebuginfo"/>
</Node>

<Node Name="Compile Maya $(MayaVersion)" Requires="Compile UnrealHeaderTool Maya">
<Node Name="Compile Maya $(MayaVersion)">
<Compile Target="MayaUnrealLiveLinkPlugin$(MayaVersion)" Platform="$(MayaPlatform)" Configuration="$(BuildTarget)" Arguments="-noxge"/>
<Copy From="$(LocalSourceDir)\MayaUnrealLiveLinkPlugin.mod" To="$(LocalBinaryDir)\MayaUnrealLiveLinkPlugin.mod" />
</Node>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@REM MIT License

@REM Copyright (c) 2022 Autodesk, Inc.

@REM Permission is hereby granted, free of charge, to any person obtaining a copy
@REM of this software and associated documentation files (the "Software"), to deal
@REM in the Software without restriction, including without limitation the rights
@REM to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@REM copies of the Software, and to permit persons to whom the Software is
@REM furnished to do so, subject to the following conditions:

@REM The above copyright notice and this permission notice shall be included in all
@REM copies or substantial portions of the Software.

@REM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
@REM IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
@REM FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@REM AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
@REM LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
@REM OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
@REM SOFTWARE.

@echo off

@rem If a platform is given then we build for it or we build Win64
if "%~2" == "" (
@echo Missing Maya OS
@echo Building for Win64
SET MAYA_PLATFORM=Win64
) else (
SET MAYA_PLATFORM=%2
)

if exist "%~dp0Staging\" (
RMDIR "%~dp0Staging" /S /Q
)
"%~dp0..\..\..\..\..\Build\BatchFiles\RunUAT.bat" BuildGraph -Script=Engine/Restricted/NotForLicensees/Source/Programs/MayaUnrealLiveLinkPlugin/BuildMayaUnrealLiveLinkPlugin.xml -Target="Stage Maya Plugin Module" -set:MayaVersion=%1 -set:MayaPlatform=%MAYA_PLATFORM% -set:BuildTarget="Debug" -NoXGE
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,57 @@ constexpr char LiveLinkPlayheadSyncCommand::EnableFlag[];
constexpr char LiveLinkPlayheadSyncCommand::EnableFlagLong[];
bool LiveLinkPlayheadSyncCommand::bPlayHeadSync = true;

const MString LiveLinkObjectTransformSyncCommandName("LiveLinkObjectTransformSync");

class LiveLinkObjectTransformSyncCommand : public MPxCommand
{
static bool bObjectTransformSync;

public:
static constexpr char EnableFlag[] = "en";
static constexpr char EnableFlagLong[] = "enable";

static void cleanup() {}
static void* creator() { return new LiveLinkObjectTransformSyncCommand(); }

static MSyntax CreateSyntax()
{
MStatus Status;
MSyntax Syntax;

Syntax.enableQuery(true);

Status = Syntax.addFlag(EnableFlag, EnableFlagLong, MSyntax::kBoolean);
CHECK_MSTATUS(Status);

return Syntax;
}
MStatus doIt(const MArgList& args) override
{
MStatus Status;
MArgDatabase ArgData(syntax(), args, &Status);
CHECK_MSTATUS_AND_RETURN_IT(Status);

const bool bIsObjectTransformSyncEnabled = ArgData.isFlagSet(EnableFlagLong, &Status);
if (ArgData.isQuery())
{
setResult(bObjectTransformSync);
}
else
{
ArgData.getFlagArgument(EnableFlagLong, 0, bObjectTransformSync);
setResult(true);
}

return MS::kSuccess;
}

static bool IsEnabled() { return bObjectTransformSync; }
};
constexpr char LiveLinkObjectTransformSyncCommand::EnableFlag[];
constexpr char LiveLinkObjectTransformSyncCommand::EnableFlagLong[];
bool LiveLinkObjectTransformSyncCommand::bObjectTransformSync = true;

const MString LiveLinkPauseAnimSyncCommandName("LiveLinkPauseAnimSync");

class LiveLinkPauseAnimSyncCommand : public MPxCommand
Expand Down Expand Up @@ -1520,18 +1571,20 @@ std::atomic<bool> SendUpdatedData {false};

// Helper method to send data to unreal when SendUpdatedData is set.
void StreamDataToUnreal()
{
// Stream data only when this flag is set.
if (!SendUpdatedData)
{
return;
}
{
if (!LiveLinkObjectTransformSyncCommand::IsEnabled()) {
// Stream data only when this flag is set.
if (!SendUpdatedData)
{
return;
}

// Do we need this?
if (gTimeChangedReceived)
{
gTimeChangedReceived = false;
return;
// Do we need this?
if (gTimeChangedReceived)
{
gTimeChangedReceived = false;
return;
}
}

auto& StreamManager = MayaLiveLinkStreamManager::TheOne();
Expand Down Expand Up @@ -2478,7 +2531,7 @@ void OnPlaybackRangeChanged(void* ClientData)
if (DetectIdleEvent.IsValid())
{
DetectIdleEvent->Stop();
DetectIdleEvent.Release();
DetectIdleEvent.Reset();
}

// Start the worker thread that will wait for additional user input before rebuilding the subjects
Expand Down Expand Up @@ -2672,6 +2725,9 @@ MStatus initializePlugin(MObject MayaPluginObject)
MayaPlugin.registerCommand(LiveLinkPlayheadSyncCommandName,
LiveLinkPlayheadSyncCommand::creator,
LiveLinkPlayheadSyncCommand::CreateSyntax);
MayaPlugin.registerCommand(LiveLinkObjectTransformSyncCommandName,
LiveLinkObjectTransformSyncCommand::creator,
LiveLinkObjectTransformSyncCommand::CreateSyntax);
MayaPlugin.registerCommand(LiveLinkPauseAnimSyncCommandName, LiveLinkPauseAnimSyncCommand::creator,
LiveLinkPauseAnimSyncCommand::CreateSyntax);

Expand Down Expand Up @@ -2700,7 +2756,7 @@ MStatus initializePlugin(MObject MayaPluginObject)
*/
MStatus uninitializePlugin(MObject MayaPluginObject)
{
DetectIdleEvent.Release();
DetectIdleEvent.Reset();

// Get the plugin API for the plugin object
MFnPlugin MayaPlugin(MayaPluginObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,21 @@ class MayaUnrealLiveLinkModel():
except:
pass

@staticmethod
def isObjectTransformSyncEnabled():
try:
return cmds.LiveLinkObjectTransformSync(q=True, enable=True)
except:
return True


@staticmethod
def enableObjectTransformSync(state):
try:
cmds.LiveLinkObjectTransformSync(enable=state)
except:
pass

@staticmethod
def pauseAnimSeqSync(state):
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "MLiveLinkPropSubject.h"
#include "../MayaLiveLinkStreamManager.h"
#include "MayaUnrealLiveLinkPlugin/MayaUnrealLiveLinkUtils.h"
#include "../MayaUnrealLiveLinkUtils.h"
#include "LiveLinkTypes.h"
#include "Roles/MayaLiveLinkTimelineTypes.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ void UnrealInitializer::InitializeUnreal()
// Load UdpMessaging module needed by message bus.
FModuleManager::Get().LoadModule(TEXT("UdpMessaging"));

IPluginManager::Get().LoadModulesForEnabledPlugins(ELoadingPhase::PreDefault);
IPluginManager::Get().LoadModulesForEnabledPlugins(ELoadingPhase::Default);
IPluginManager::Get().LoadModulesForEnabledPlugins(ELoadingPhase::PostDefault);

InitializedOnce = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,15 @@ def enablePlayheadSync(self, state):
if self._Model:
self._Model.enablePlayheadSync(state)

def isObjectTransformSyncEnabled(self):
if self._Model:
self._Model.isObjectTransformSyncEnabled(state)
return False

def enableObjectTransformSync(self, state):
if self._Model:
self._Model.enableObjectTransformSync(state)

def pauseAnimSeqSync(self, state):
if self._Model:
self._Model.pauseAnimSeqSync(state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,18 @@ def initUI(self):
self.syncTimeAction.setCheckable(True)
self.syncTimeAction.setChecked(False)
self.syncTimeAction.triggered.connect(self._enablePlayheadSync)

# Sync Object Transform
self.syncObjectTransformAction = QAction('Sync Object Transform', self)
self.syncObjectTransformAction.setToolTip('Enable to synchronize Maya object transform with Unreal in real time')
self.syncObjectTransformAction.setCheckable(True)
self.syncObjectTransformAction.setChecked(True)
self.syncObjectTransformAction.triggered.connect(self._enableObjectTransformSync)

# Add actions to Option Menu
self.optionsMenu.addAction(self.settingsAction)
self.optionsMenu.addAction(self.syncTimeAction)
self.optionsMenu.addAction(self.syncObjectTransformAction)

# Help Menu
helpMenu = menuBar.addMenu('Help')
Expand Down Expand Up @@ -317,6 +326,7 @@ def refreshUI(self):
if self.table:
self.table._refreshUI()
self.syncTimeAction.setChecked(self.Controller.isPlayheadSyncEnabled())
self.syncObjectTransformAction.setChecked(self.Controller.isObjectTransformSyncEnabled())

def showEvent(self, event):
unrealVersion = self.Controller.getLoadedUnrealVersion()
Expand Down Expand Up @@ -383,6 +393,9 @@ def enableControls(self, enable):
def _enablePlayheadSync(self, state):
self.Controller.enablePlayheadSync(self.syncTimeAction.isChecked())

def _enableObjectTransformSync(self, state):
self.Controller.enableObjectTransformSync(self.syncObjectTransformAction.isChecked())

def _pauseAnimSeqSync(self, state):
self.Controller.pauseAnimSeqSync(self._pauseAnimSyncButtonPauseState)
if self._pauseAnimSyncButtonPauseState:
Expand Down