You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
A primitive skin weights paint tool for skeletal meshes.
#jira UE-93689 #rb ryan.schmidt #preflight 60942eeb4a6341000184add9 [CL 16321464 by halfdan ingvarsson in ue5-main branch]
This commit is contained in:
@@ -14,14 +14,12 @@ public class MeshModelingTools : ModuleRules
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
PrivateIncludePaths.AddRange(
|
||||
PublicIncludePathModuleNames.AddRange(
|
||||
new string[] {
|
||||
// ... add other private include paths required here ...
|
||||
"AnimationCore", // For the BoneWeights.h include
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
);
|
||||
|
||||
PublicDependencyModuleNames.AddRange(
|
||||
new string[]
|
||||
{
|
||||
@@ -42,6 +40,7 @@ public class MeshModelingTools : ModuleRules
|
||||
"MeshConversion",
|
||||
"MeshDescription",
|
||||
"StaticMeshDescription",
|
||||
"SkeletalMeshDescription",
|
||||
"ModelingComponents",
|
||||
"ModelingOperators",
|
||||
|
||||
@@ -75,7 +74,8 @@ public class MeshModelingTools : ModuleRules
|
||||
"RenderCore",
|
||||
"ModelingOperators",
|
||||
"InputCore",
|
||||
"PhysicsCore"
|
||||
"PhysicsCore",
|
||||
|
||||
// ... add private dependencies that you statically link with here ...
|
||||
}
|
||||
);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,172 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "DynamicMeshBrushTool.h"
|
||||
#include "Changes/ValueWatcher.h"
|
||||
#include "MeshDescription.h"
|
||||
#include "DynamicVerticesOctree3.h"
|
||||
#include "BoneContainer.h"
|
||||
#include "Interfaces/Interface_BoneReferenceSkeletonProvider.h"
|
||||
#include "Misc/Optional.h"
|
||||
#include "Containers/Map.h"
|
||||
#include "TargetInterfaces/MeshDescriptionCommitter.h"
|
||||
|
||||
#include "SkinWeightsPaintTool.generated.h"
|
||||
|
||||
|
||||
struct FMeshDescription;
|
||||
class USkinWeightsPaintTool;
|
||||
class IMeshDescriptionCommitter;
|
||||
|
||||
|
||||
|
||||
class MESHMODELINGTOOLS_API FMeshSkinWeightsChange : public FToolCommandChange
|
||||
{
|
||||
public:
|
||||
FMeshSkinWeightsChange(const FName& InBoneName) :
|
||||
FToolCommandChange(),
|
||||
BoneName(InBoneName)
|
||||
{ }
|
||||
|
||||
virtual FString ToString() const override
|
||||
{
|
||||
return FString(TEXT("Paint Skin Weights"));
|
||||
}
|
||||
|
||||
void Apply(UObject* Object) override;
|
||||
|
||||
void Revert(UObject* Object) override;
|
||||
|
||||
void UpdateValues(const TArray<int32>& Indices, const TArray<float>& OldValues, const TArray<float>& NewValues);
|
||||
|
||||
private:
|
||||
FName BoneName;
|
||||
TMap<int32, float> OldWeights;
|
||||
TMap<int32, float> NewWeights;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class MESHMODELINGTOOLS_API USkinWeightsPaintToolBuilder : public UMeshSurfacePointToolBuilder
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UMeshSurfacePointTool* CreateNewTool(const FToolBuilderState& SceneState) const override;
|
||||
};
|
||||
|
||||
|
||||
UCLASS()
|
||||
class MESHMODELINGTOOLS_API USkinWeightsPaintToolProperties :
|
||||
public UInteractiveToolPropertySet,
|
||||
public IBoneReferenceSkeletonProvider
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
UPROPERTY(VisibleAnywhere, Category = Skeleton)
|
||||
FBoneReference CurrentBone;
|
||||
|
||||
// IBoneReferenceSkeletonProvider
|
||||
USkeleton* GetSkeleton(bool& bInvalidSkeletonIsError) override;
|
||||
|
||||
TObjectPtr<USkeletalMesh> SkeletalMesh;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class MESHMODELINGTOOLS_API USkinWeightsPaintTool : public UDynamicMeshBrushTool
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
void RegisterActions(FInteractiveToolActionSet& ActionSet) override;
|
||||
|
||||
void Setup() override;
|
||||
void Render(IToolsContextRenderAPI* RenderAPI) override;
|
||||
|
||||
bool HasCancel() const override { return true; }
|
||||
bool HasAccept() const override { return true; }
|
||||
bool CanAccept() const override { return true; }
|
||||
|
||||
// UBaseBrushTool overrides
|
||||
bool HitTest(const FRay& Ray, FHitResult& OutHit) override;
|
||||
void OnBeginDrag(const FRay& Ray) override;
|
||||
void OnUpdateDrag(const FRay& Ray) override;
|
||||
void OnEndDrag(const FRay& Ray) override;
|
||||
bool OnUpdateHover(const FInputDeviceRay& DevicePos) override;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void ApplyStamp(const FBrushStampData& Stamp);
|
||||
|
||||
void OnShutdown(EToolShutdownType ShutdownType) override;
|
||||
void OnTick(float DeltaTime) override;
|
||||
|
||||
double CalculateBrushFalloff(double Distance) const;
|
||||
void CalculateVertexROI(const FBrushStampData& Stamp, TArray<int>& VertexROI);
|
||||
|
||||
UPROPERTY()
|
||||
USkinWeightsPaintToolProperties* ToolProps;
|
||||
|
||||
TValueWatcher<FBoneReference> CurrentBoneWatcher;
|
||||
|
||||
bool bInRemoveStroke = false;
|
||||
bool bInSmoothStroke = false;
|
||||
FBrushStampData StartStamp;
|
||||
FBrushStampData LastStamp;
|
||||
bool bStampPending;
|
||||
|
||||
TUniquePtr<FMeshDescription> EditedMesh;
|
||||
|
||||
FBoneContainer BoneContainer;
|
||||
|
||||
UE::Geometry::TDynamicVerticesOctree3<FDynamicMesh3> VerticesOctree;
|
||||
TArray<int> PreviewBrushROI;
|
||||
|
||||
using BoneInfluenceMapType = TMap<FName, TArray<float>>;
|
||||
BoneInfluenceMapType SkinWeightsMap;
|
||||
FName CurrentBone = NAME_None;
|
||||
TOptional<FName> PendingCurrentBone;
|
||||
|
||||
|
||||
bool bVisibleWeightsValid = false;
|
||||
|
||||
static FVector4f WeightToColor(float Value);
|
||||
|
||||
void InitializeSkinWeights();
|
||||
void UpdateBoneVisualization();
|
||||
void UpdateCurrentBone(const FName &BoneName);
|
||||
|
||||
void ExternalUpdateAttributes(TUniquePtr<TAttributesSet<FVertexID>>& NewAttrib, int32 NewSelecedIndex);
|
||||
|
||||
struct FBonePositionInfo
|
||||
{
|
||||
FName BoneName;
|
||||
int32 ParentBoneIndex;
|
||||
FVector Position;
|
||||
float Radius;
|
||||
TMap<FName, int32> ChildBones;
|
||||
};
|
||||
TArray<FBonePositionInfo> BonePositionInfos;
|
||||
float MaxDrawRadius;
|
||||
|
||||
void UpdateBonePositionInfos(float MinRadius);
|
||||
void RenderBonePositions(FPrimitiveDrawInterface *PDI);
|
||||
|
||||
TUniquePtr<FMeshSkinWeightsChange> ActiveChange;
|
||||
|
||||
void BeginChange();
|
||||
TUniquePtr<FMeshSkinWeightsChange> EndChange();
|
||||
|
||||
friend class FMeshSkinWeightsChange;
|
||||
void ExternalUpdateValues(const FName &BoneName, const TMap<int32, float>& IndexValues);
|
||||
|
||||
void CommitSkinWeights(const IMeshDescriptionCommitter::FCommitterParams& CommitParams);
|
||||
};
|
||||
@@ -101,6 +101,8 @@ void FModelingToolsManagerCommands::RegisterCommands()
|
||||
UI_COMMAND(BeginBakeMeshAttributeMapsTool, "BakeTx", "Bake Image Maps for Target Mesh (optionally from second Source Mesh)", EUserInterfaceActionType::ToggleButton, FInputChord());
|
||||
UI_COMMAND(BeginUVSeamEditTool, "SeamEd", "Add UV Seams to Mesh", EUserInterfaceActionType::ToggleButton, FInputChord());
|
||||
|
||||
UI_COMMAND(BeginSkinWeightsPaintTool, "SkinWts", "Start the Paint Skin Weights Tool", EUserInterfaceActionType::Button, FInputChord());
|
||||
|
||||
UI_COMMAND(BeginGroomToMeshTool, "Helmet", "Generate Helmet Mesh for Selected Groom", EUserInterfaceActionType::ToggleButton, FInputChord());
|
||||
UI_COMMAND(BeginGenerateLODMeshesTool, "HlmLOD", "Generate LODS for Hair Helmet", EUserInterfaceActionType::ToggleButton, FInputChord());
|
||||
UI_COMMAND(BeginGroomCardsToMeshTool, "CardsToMesh", "Hair Cards to Mesh Tool", EUserInterfaceActionType::ToggleButton, FInputChord());
|
||||
|
||||
@@ -92,6 +92,7 @@ public:
|
||||
TSharedPtr<FUICommandInfo> BeginEditMeshMaterialsTool;
|
||||
TSharedPtr<FUICommandInfo> BeginTransformUVIslandsTool;
|
||||
TSharedPtr<FUICommandInfo> BeginMeshAttributePaintTool;
|
||||
TSharedPtr<FUICommandInfo> BeginSkinWeightsPaintTool;
|
||||
TSharedPtr<FUICommandInfo> BeginAttributeEditorTool;
|
||||
TSharedPtr<FUICommandInfo> BeginBakeMeshAttributeMapsTool;
|
||||
TSharedPtr<FUICommandInfo> BeginUVSeamEditTool;
|
||||
|
||||
Reference in New Issue
Block a user