You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
- Add UE::ToolTarget::CommitMaterialSetUpdate() and ::CommitDynamicMeshUpdate(). ::GetDynamicMeshCopy() can now return tangents if requested. - Add IMeshDescriptionProvider::CalculateAutoGeneratedAttributes(). Default implementation does nothing, UStaticMeshComponentToolTarget implementation initializes auto-generated MeshDescription attributes. Used in ::GetDynamicMeshCopy() to get tangents (but requires a MeshDescription copy). - Clean up handling of Tangents in Simple/OctreeDynamicMeshComponent. Add local MakeTangentsFunc() to generate the Tangents lambda, handle different cases and no-tangents fallbacks consistently. - UDynamicMesh: add optional info arguments to EditMesh() and ChangeInfo struct. Add support for deferring change events from Edit funcs. - Remove UBaseDynamicMeshComponent::InitializeMesh(), ::Bake() APIs, and add ::SetMesh(). Implement in Simple/Octree implementations, update all Tools that used those APIs. - Add USimpleDynamicMeshComponent::ProcessMesh(), EditMesh(). These are now the preferred ways to read/write mesh. - Update USimpleDynamicMeshComponent tangents handling. Externally-computed tangents are now taken directly from the FDynamicMesh3 attribute set. Autogenerated tangents are still computed and stored in an internal FMeshTangentsf, but this is no longer exposed for external updates. - Remove UPreviewMesh pass-through functions for Tangents access, InitializeMesh() and Bake(). Add ProcessMesh() - Update all affected Tools. In most cases these Tools have also been converted to use ModelingToolTargetUtil functions, instead of direct ToolTarget interface casting. #rb none #rnx #jira none #preflight 60c3e71d3e1b3c00015668af [CL 16650666 by Ryan Schmidt in ue5-main branch]
147 lines
6.4 KiB
C++
147 lines
6.4 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "DynamicMesh/DynamicMesh3.h"
|
|
#include "TargetInterfaces/MaterialProvider.h" // FComponentMaterialSet
|
|
#include "MeshConversionOptions.h"
|
|
|
|
class UToolTarget;
|
|
class UPrimitiveComponent;
|
|
class AActor;
|
|
struct FMeshDescription;
|
|
struct FCreateMeshObjectParams;
|
|
|
|
//
|
|
// UE::ToolTarget:: namespace contains utility/helper functions for interacting with UToolTargets.
|
|
// Generally these are meant to be used by UInteractiveTools to handle standard tasks that would
|
|
// otherwise require each Tool to figure out things like which ToolTargetInterface to cast to, etc.
|
|
// Using these functions ideally avoids all the boilerplate inherent in the ToolTarget system.
|
|
//
|
|
// However, the cost is that it is not necessarily the most efficient, as each one of these functions
|
|
// may potentially do many repeated Cast<>'s internally. So, use sparingly, or cache the outputs.
|
|
//
|
|
namespace UE
|
|
{
|
|
namespace ToolTarget
|
|
{
|
|
|
|
/**
|
|
* @return the AActor backing a ToolTarget, or nullptr if there is no such Actor
|
|
*/
|
|
MODELINGCOMPONENTS_API AActor* GetTargetActor(UToolTarget* Target);
|
|
|
|
/**
|
|
* @return the UPrimitiveComponent backing a ToolTarget, or nullptr if there is no such Component
|
|
*/
|
|
MODELINGCOMPONENTS_API UPrimitiveComponent* GetTargetComponent(UToolTarget* Target);
|
|
|
|
/**
|
|
* Hide the "Source Object" (eg PrimitiveComponent, Actor, etc) backing a ToolTarget
|
|
* @return true on success
|
|
*/
|
|
MODELINGCOMPONENTS_API bool HideSourceObject(UToolTarget* Target);
|
|
|
|
/**
|
|
* Show the "Source Object" (eg PrimitiveComponent, Actor, etc) backing a ToolTarget
|
|
* @return true on success
|
|
*/
|
|
MODELINGCOMPONENTS_API bool ShowSourceObject(UToolTarget* Target);
|
|
|
|
/**
|
|
* @return the local-to-world Transform underlying a ToolTarget, eg the Component or Actor transform
|
|
*/
|
|
MODELINGCOMPONENTS_API UE::Geometry::FTransform3d GetLocalToWorldTransform(UToolTarget* Target);
|
|
|
|
/**
|
|
* Fetch the Material Set on the object underlying a ToolTarget. In cases where there are (eg)
|
|
* separate Component and Asset material sets, prefers the Component material set
|
|
* @param bPreferAssetMaterials if true, prefer an Asset material set, if available
|
|
* @return a valid MaterialSet
|
|
*/
|
|
MODELINGCOMPONENTS_API FComponentMaterialSet GetMaterialSet(UToolTarget* Target, bool bPreferAssetMaterials = false);
|
|
|
|
|
|
/**
|
|
* Update the material set of the Target
|
|
* @param bApplyToAsset In situations where the Target has both Component-level and Asset-level materials, this specifies which should be updated (this flag is passed to the IMaterialProvider, which may or may not respect it)
|
|
*/
|
|
MODELINGCOMPONENTS_API bool CommitMaterialSetUpdate(
|
|
UToolTarget* Target,
|
|
const FComponentMaterialSet& UpdatedMaterials,
|
|
bool bApplyToAsset = true);
|
|
|
|
|
|
/**
|
|
* @return the MeshDescription underlying a ToolTarget, if it has such a mesh. May be generated internally by the ToolTarget. May be nullptr if the Target does not have a mesh.
|
|
*/
|
|
MODELINGCOMPONENTS_API const FMeshDescription* GetMeshDescription(UToolTarget* Target);
|
|
|
|
/**
|
|
* Fetch a DynamicMesh3 representing the given ToolTarget. This may be a conersion of the output of GetMeshDescription().
|
|
* This function returns a copy, so the caller can take ownership of this Mesh.
|
|
* @param bWantMeshTangents if true, tangents will be returned if the target has them available. This may require that they be auto-calculated in some cases (which may be expensive)
|
|
* @return a created DynamicMesh3, which may be empty if the Target doesn't have a mesh
|
|
*/
|
|
MODELINGCOMPONENTS_API UE::Geometry::FDynamicMesh3 GetDynamicMeshCopy(UToolTarget* Target, bool bWantMeshTangents = false);
|
|
|
|
|
|
/**
|
|
* EDynamicMeshUpdateResult is returned by functions below that update a ToolTarget with a new Mesh
|
|
*/
|
|
enum class EDynamicMeshUpdateResult
|
|
{
|
|
/** Update was successful */
|
|
Ok = 0,
|
|
/** Update failed */
|
|
Failed = 1,
|
|
/** Update was successful, but required that the entire target mesh be replaced, instead of a (requested) partial update */
|
|
Ok_ForcedFullUpdate = 2
|
|
};
|
|
|
|
|
|
/**
|
|
* Update the Mesh in a ToolTarget based on the provided MeshDescription, and optional material set
|
|
* @return EDynamicMeshUpdateResult::Ok on success
|
|
*/
|
|
MODELINGCOMPONENTS_API EDynamicMeshUpdateResult CommitMeshDescriptionUpdate(
|
|
UToolTarget* Target,
|
|
const FMeshDescription* UpdatedMesh,
|
|
const FComponentMaterialSet* UpdatedMaterials = nullptr);
|
|
|
|
/**
|
|
* Update the Mesh in a ToolTarget based on the provided DynamicMesh, and optional material set
|
|
* @param bHaveModifiedTopology If the update only changes vertex or attribute values (but not counts), then in some cases a more efficient and/or less destructive update can be applied to the Target
|
|
* @param ConversionOptions if the commit to the Target involves conversion to MeshDescription, these options can configure that conversion
|
|
* @param UpdatedMaterials optional new material set that will be applied to the updated Target, and the Target Asset if available. If more control is needed use CommitMaterialSetUpdate()
|
|
* @return EDynamicMeshUpdateResult::Ok on success
|
|
*/
|
|
MODELINGCOMPONENTS_API EDynamicMeshUpdateResult CommitDynamicMeshUpdate(
|
|
UToolTarget* Target,
|
|
const UE::Geometry::FDynamicMesh3& UpdatedMesh,
|
|
bool bHaveModifiedTopology,
|
|
const FConversionToMeshDescriptionOptions& ConversionOptions = FConversionToMeshDescriptionOptions(),
|
|
const FComponentMaterialSet* UpdatedMaterials = nullptr);
|
|
|
|
/**
|
|
* Update the UV sets of the ToolTarget's mesh (assuming it has one) based on the provided UpdatedMesh.
|
|
* @todo: support updating a specific UV set/index, rather than all sets
|
|
* @return EDynamicMeshUpdateResult::Ok on success, or Ok_ForcedFullUpdate if any dependent mesh topology was modified
|
|
*/
|
|
MODELINGCOMPONENTS_API EDynamicMeshUpdateResult CommitDynamicMeshUVUpdate(UToolTarget* Target, const UE::Geometry::FDynamicMesh3* UpdatedMesh);
|
|
|
|
|
|
/**
|
|
* FCreateMeshObjectParams::TypeHint is used by the ModelingObjectsCreationAPI to suggest what type of mesh object to create
|
|
* inside various Tools. This should often be derived from the input mesh object type (eg if you plane-cut a Volume, the output
|
|
* should be Volumes). This function interrogates the ToolTarget to try to determine this information
|
|
* @return true if a known type was detected and configured in FCreateMeshObjectParams::TypeHint (and possibly FCreateMeshObjectParams::TypeHintClass)
|
|
*/
|
|
MODELINGCOMPONENTS_API bool ConfigureCreateMeshObjectParams(UToolTarget* SourceTarget, FCreateMeshObjectParams& DerivedParamsOut);
|
|
|
|
|
|
|
|
|
|
} // end namespace ToolTarget
|
|
} // end namespace UE
|