Files
UnrealEngineUWP/Engine/Source/Runtime/InteractiveToolsFramework/Public/TargetInterfaces/MeshDescriptionCommitter.h
ryan schmidt 17cefb1dd1 ModelingTools:
Reduce surface area of MeshDescriptionProvider/Committer, replace with UE::ToolTarget:: calls where possible.

Add new UE::ToolTarget::CommitMeshDescriptionUpdateViaDynamicMesh() function. This is being used for now to avoid potential regressions as UE::ToolTarget::CommitDynamicMeshUpdate will preferentially use DynamicMeshCommitter, and I am not certain it is functionally equivalent in all cases.
Add new UE::ToolTarget::CommitDynamicMeshNormalsUpdate(), similar to existing UV version
Add new Move-variant of UE::ToolTarget::CommitMeshDescriptionUpdate(), uses new Move-variant of IMeshDescriptionCommitter::CommitMeshDescription.
Make existing IMeshDescriptionCommitter::CommitMeshDescription callback interface protected, to prevent usage of this function at public API level (will be removed in future).

Tool updates should not change, just using cleaner APIs.
EditNormalsTool now uses CommitDynamicMeshNormalsUpdate(), which does go via DynamicMeshCommitter preferentially, where it previously went via MeshDescriptionCommitter. In light testing the results appear equivalent.
AttributeEditorTool now operates on MeshDescription copies in various update functions. These are not performance-critical.

#rb rinat.abdrashitov
#rnx
#preflight 61ae45998358693a22c28d1b

#ROBOMERGE-AUTHOR: ryan.schmidt
#ROBOMERGE-SOURCE: CL 18384350 in //UE5/Release-5.0/... via CL 18384361
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v896-18170469)

[CL 18384373 by ryan schmidt in ue5-release-engine-test branch]
2021-12-06 12:42:19 -05:00

86 lines
2.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "MeshDescription.h"
#include "UObject/Interface.h"
#include "MeshDescriptionCommitter.generated.h"
UINTERFACE()
class INTERACTIVETOOLSFRAMEWORK_API UMeshDescriptionCommitter : public UInterface
{
GENERATED_BODY()
};
class INTERACTIVETOOLSFRAMEWORK_API IMeshDescriptionCommitter
{
GENERATED_BODY()
public:
/**
* Commits the given FMeshDescription.
*/
virtual bool CommitMeshDescription(const FMeshDescription& Mesh)
{
// It seems reasonable to have this function, but we'll go ahead and give a default implementation
// if users want to just implement the other one.
bool bSuccess = false;
CommitMeshDescription([&](const FCommitterParams& CommitParams)
{
if (CommitParams.MeshDescriptionOut)
{
*CommitParams.MeshDescriptionOut = Mesh;
bSuccess = true;
}
});
return bSuccess;
}
/**
* Commits the given FMeshDescription.
*/
virtual bool CommitMeshDescription(FMeshDescription&& Mesh)
{
// It seems reasonable to have this function, but we'll go ahead and give a default implementation
// if users want to just implement the other one.
bool bSuccess = false;
CommitMeshDescription([&](const FCommitterParams& CommitParams)
{
if (CommitParams.MeshDescriptionOut)
{
*CommitParams.MeshDescriptionOut = MoveTemp(Mesh);
bSuccess = true;
}
});
return bSuccess;
}
protected:
struct FCommitterParams
{
/**
* Mesh description that should be populated/updated by the passed-in function and which
* will be committed to the target.
*/
FMeshDescription* MeshDescriptionOut = nullptr;
};
using FCommitter = TFunction<void(const FCommitterParams&)>;
/**
* Commit a mesh description. The mesh description to be committed will be passed to the
* given function as a parameter, and it is up to the function to update it properly.
*
* @param Committer A function that takes in const IMeshDescriptionCommitter::FCommitParams&
* and populates the FMeshDescription pointed to by the MeshDescription pointer inside.
*/
virtual void CommitMeshDescription(const FCommitter& Committer) = 0;
};