init
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
// KawaiiPhysics : Copyright (c) 2019-2024 pafuhana1213, MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "AnimGraphNode_Base.h"
|
||||
#include "AnimNode_KawaiiPhysics.h"
|
||||
#include "AnimGraphNode_SkeletalControlBase.h"
|
||||
#include "EdGraph/EdGraphNodeUtils.h"
|
||||
|
||||
#include "AnimGraphNode_KawaiiPhysics.generated.h"
|
||||
|
||||
class FCompilerResultsLog;
|
||||
|
||||
UCLASS()
|
||||
class UAnimGraphNode_KawaiiPhysics : public UAnimGraphNode_SkeletalControlBase
|
||||
{
|
||||
GENERATED_UCLASS_BODY()
|
||||
UPROPERTY(EditAnywhere, Category = Settings)
|
||||
FAnimNode_KawaiiPhysics Node;
|
||||
|
||||
virtual FText GetNodeTitle(ENodeTitleType::Type TitleType) const override;
|
||||
|
||||
// UObject interface
|
||||
virtual void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) override;
|
||||
|
||||
protected:
|
||||
// UAnimGraphNode_Base interface
|
||||
virtual FEditorModeID GetEditorMode() const override;
|
||||
virtual void ValidateAnimNodePostCompile(FCompilerResultsLog& MessageLog,
|
||||
UAnimBlueprintGeneratedClass* CompiledClass,
|
||||
int32 CompiledNodeIndex) override;
|
||||
virtual void CopyNodeDataToPreviewNode(FAnimNode_Base* AnimNode) override;
|
||||
virtual void CustomizeDetails(IDetailLayoutBuilder& DetailBuilder) override;
|
||||
// End of UAnimGraphNode_Base interface
|
||||
|
||||
//virtual FText GetControllerDescription() const override;
|
||||
virtual FText GetControllerDescription() const override;
|
||||
virtual const FAnimNode_SkeletalControlBase* GetNode() const override { return &Node; }
|
||||
// End of UAnimGraphNode_SkeletalControlBase interface
|
||||
|
||||
// UObject interface
|
||||
virtual void Serialize(FArchive& Ar) override;
|
||||
|
||||
// End of UObject interface
|
||||
|
||||
virtual void CustomizeDetailTools(IDetailLayoutBuilder& DetailBuilder);
|
||||
virtual void CustomizeDetailDebugVisualizations(IDetailLayoutBuilder& DetailBuilder);
|
||||
|
||||
private:
|
||||
/** Creates the export data asset path. */
|
||||
void CreateExportDataAssetPath(FString& PackageName, const FString& DefaultSuffix) const;
|
||||
|
||||
/** Creates the data asset package. */
|
||||
UPackage* CreateDataAssetPackage(const FString& DialogTitle, const FString& DefaultSuffix,
|
||||
FString& AssetName) const;
|
||||
|
||||
/** Shows the export asset notification. */
|
||||
void ShowExportAssetNotification(UObject* NewAsset, FText NotificationText);
|
||||
|
||||
/** Exports the limits data asset. */
|
||||
void ExportLimitsDataAsset();
|
||||
|
||||
/** Exports the bone constraints data asset. */
|
||||
void ExportBoneConstraintsDataAsset();
|
||||
|
||||
public:
|
||||
/** Enables or disables debug drawing for bones. */
|
||||
UPROPERTY()
|
||||
bool bEnableDebugDrawBone = true;
|
||||
|
||||
/** Enables or disables debug drawing for bone length rate. */
|
||||
UPROPERTY()
|
||||
bool bEnableDebugBoneLengthRate = true;
|
||||
|
||||
/** Enables or disables debug drawing for limit angles. */
|
||||
UPROPERTY()
|
||||
bool bEnableDebugDrawLimitAngle = true;
|
||||
|
||||
/** Enables or disables debug drawing for spherical limits. */
|
||||
UPROPERTY()
|
||||
bool bEnableDebugDrawSphereLimit = true;
|
||||
|
||||
/** Enables or disables debug drawing for capsule limits. */
|
||||
UPROPERTY()
|
||||
bool bEnableDebugDrawCapsuleLimit = true;
|
||||
|
||||
/** Enables or disables debug drawing for box limits. */
|
||||
UPROPERTY()
|
||||
bool bEnableDebugDrawBoxLimit = true;
|
||||
|
||||
/** Enables or disables debug drawing for planar limits. */
|
||||
UPROPERTY()
|
||||
bool bEnableDebugDrawPlanerLimit = true;
|
||||
|
||||
/** Enables or disables debug drawing for bone constraints. */
|
||||
UPROPERTY()
|
||||
bool bEnableDebugDrawBoneConstraint = true;
|
||||
|
||||
/** Enables or disables debug drawing for external forces. */
|
||||
UPROPERTY()
|
||||
bool bEnableDebugDrawExternalForce = true;
|
||||
|
||||
private:
|
||||
/** Constructing FText strings can be costly, so we cache the node's title */
|
||||
FNodeTitleTextTable CachedNodeTitles;
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
// KawaiiPhysics : Copyright (c) 2019-2024 pafuhana1213, MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
class FKawaiiPhysicsEdModule : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
/** IModuleInterface implementation */
|
||||
virtual void StartupModule() override;
|
||||
virtual void ShutdownModule() override;
|
||||
};
|
||||
@@ -0,0 +1,95 @@
|
||||
// KawaiiPhysics : Copyright (c) 2019-2024 pafuhana1213, MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "AnimNodeEditMode.h"
|
||||
#include "AnimGraphNode_KawaiiPhysics.h"
|
||||
#include "AnimNode_KawaiiPhysics.h"
|
||||
|
||||
#define UE_WIDGET UE::Widget
|
||||
|
||||
class FEditorViewportClient;
|
||||
class FPrimitiveDrawInterface;
|
||||
class USkeletalMeshComponent;
|
||||
struct FViewportClick;
|
||||
|
||||
class FKawaiiPhysicsEditMode : public FAnimNodeEditMode
|
||||
{
|
||||
public:
|
||||
FKawaiiPhysicsEditMode();
|
||||
|
||||
/** IAnimNodeEditMode interface */
|
||||
virtual void EnterMode(class UAnimGraphNode_Base* InEditorNode, struct FAnimNode_Base* InRuntimeNode) override;
|
||||
virtual void ExitMode() override;
|
||||
virtual FVector GetWidgetLocation() const override;
|
||||
virtual UE_WIDGET::EWidgetMode GetWidgetMode() const override;
|
||||
virtual ECoordSystem GetWidgetCoordinateSystem() const override;
|
||||
virtual void DoTranslation(FVector& InTranslation) override;
|
||||
virtual void DoRotation(FRotator& InRotation) override;
|
||||
virtual void DoScale(FVector& InScale) override;
|
||||
|
||||
/** FEdMode interface */
|
||||
virtual void Render(const FSceneView* View, FViewport* Viewport, FPrimitiveDrawInterface* PDI) override;
|
||||
virtual bool HandleClick(FEditorViewportClient* InViewportClient, HHitProxy* HitProxy,
|
||||
const FViewportClick& Click) override;
|
||||
virtual bool GetCustomDrawingCoordinateSystem(FMatrix& InMatrix, void* InData) override;
|
||||
virtual bool InputKey(FEditorViewportClient* InViewportClient, FViewport* InViewport, FKey InKey,
|
||||
EInputEvent InEvent) override;
|
||||
virtual bool ShouldDrawWidget() const override;
|
||||
virtual void DrawHUD(FEditorViewportClient* ViewportClient, FViewport* Viewport, const FSceneView* View,
|
||||
FCanvas* Canvas) override;
|
||||
|
||||
protected:
|
||||
void OnExternalNodePropertyChange(FPropertyChangedEvent& InPropertyEvent);
|
||||
FDelegateHandle NodePropertyDelegateHandle;
|
||||
|
||||
void OnLimitDataAssetPropertyChange(FPropertyChangedEvent& InPropertyEvent);
|
||||
bool IsSelectAnimNodeCollision() const;
|
||||
FDelegateHandle LimitsDataAssetPropertyDelegateHandle;
|
||||
|
||||
private:
|
||||
void RenderModifyBones(FPrimitiveDrawInterface* PDI) const;
|
||||
void RenderLimitAngle(FPrimitiveDrawInterface* PDI) const;
|
||||
|
||||
/** Render each collisions */
|
||||
void RenderSphericalLimits(FPrimitiveDrawInterface* PDI) const;
|
||||
void RenderCapsuleLimit(FPrimitiveDrawInterface* PDI) const;
|
||||
void RenderBoxLimit(FPrimitiveDrawInterface* PDI) const;
|
||||
void RenderPlanerLimit(FPrimitiveDrawInterface* PDI);
|
||||
|
||||
void RenderBoneConstraint(FPrimitiveDrawInterface* PDI) const;
|
||||
void RenderExternalForces(FPrimitiveDrawInterface* PDI) const;
|
||||
|
||||
/** Helper function for GetWidgetLocation() and joint rendering */
|
||||
FVector GetWidgetLocation(ECollisionLimitType CollisionType, int32 Index) const;
|
||||
|
||||
// methods to find a valid widget mode for gizmo because doesn't need to show gizmo when the mode is "Ignore"
|
||||
UE_WIDGET::EWidgetMode FindValidWidgetMode(UE_WIDGET::EWidgetMode InWidgetMode) const;
|
||||
|
||||
/** Checking if a collision is selected and the collision is valid */
|
||||
bool IsValidSelectCollision() const;
|
||||
|
||||
// Get Select Colliison Info
|
||||
FCollisionLimitBase* GetSelectCollisionLimitRuntime() const;
|
||||
FCollisionLimitBase* GetSelectCollisionLimitGraph() const;
|
||||
|
||||
/** Draw text func for DrawHUD */
|
||||
void DrawTextItem(const FText& Text, FCanvas* Canvas, float X, float& Y, float FontHeight);
|
||||
void Draw3DTextItem(const FText& Text, FCanvas* Canvas, const FSceneView* View, const FViewport* Viewport,
|
||||
FVector Location);
|
||||
|
||||
/** Cache the typed nodes */
|
||||
struct FAnimNode_KawaiiPhysics* RuntimeNode;
|
||||
UAnimGraphNode_KawaiiPhysics* GraphNode;
|
||||
|
||||
/** The current bone selection mode */
|
||||
ECollisionLimitType SelectCollisionType = ECollisionLimitType::None;
|
||||
int32 SelectCollisionIndex = -1;
|
||||
ECollisionSourceType SelectCollisionSourceType = ECollisionSourceType::AnimNode;
|
||||
|
||||
// storing current widget mode
|
||||
mutable UE_WIDGET::EWidgetMode CurWidgetMode;
|
||||
|
||||
// physics asset body material
|
||||
TObjectPtr<UMaterialInstanceDynamic> PhysicsAssetBodyMaterial;
|
||||
};
|
||||
Reference in New Issue
Block a user