添加 Source/FLESH/Public/SoftBodyVisceraComponent.h

This commit is contained in:
2025-04-21 18:09:09 +08:00
parent 282975cf99
commit 8c135d10b5

View File

@@ -0,0 +1,114 @@
#pragma once
#include "CoreMinimal.h"
#include "Components/SkeletalMeshComponent.h"
#include "SoftBodyPhysicsTool.h"
#include "BooleanCutTool.h"
#include "SoftBodyVisceraComponent.generated.h"
/**
* Component for handling soft body viscera simulation and cutting
*/
UCLASS(ClassGroup = (FLESH), meta = (BlueprintSpawnableComponent))
class FLESH_API USoftBodyVisceraComponent : public USkeletalMeshComponent
{
GENERATED_BODY()
public:
// Constructor
USoftBodyVisceraComponent();
// Begin UActorComponent interface
virtual void BeginPlay() override;
virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
// End UActorComponent interface
/**
* Initialize soft body physics
* @param SimulationSettings - Simulation settings
* @return Whether initialization was successful
*/
UFUNCTION(BlueprintCallable, Category = "FLESH|Physics")
bool InitializeSoftBodyPhysics(const FSoftBodySimulationSettings& SimulationSettings);
/**
* Add an anchor point to the soft body
* @param AnchorPoint - Anchor point definition
* @return Whether the anchor was added successfully
*/
UFUNCTION(BlueprintCallable, Category = "FLESH|Physics")
bool AddAnchorPoint(const FSoftBodyAnchorPoint& AnchorPoint);
/**
* Add a line chain to the soft body
* @param LineChain - Line chain definition
* @return Whether the line chain was added successfully
*/
UFUNCTION(BlueprintCallable, Category = "FLESH|Physics")
bool AddLineChain(const FSoftBodyLineChain& LineChain);
/**
* Add a tetrahedron to the soft body
* @param Tetrahedron - Tetrahedron definition
* @return Whether the tetrahedron was added successfully
*/
UFUNCTION(BlueprintCallable, Category = "FLESH|Physics")
bool AddTetrahedron(const FSoftBodyTetrahedron& Tetrahedron);
/**
* Add a plane constraint to the soft body
* @param PlaneConstraint - Plane constraint definition
* @return Whether the plane constraint was added successfully
*/
UFUNCTION(BlueprintCallable, Category = "FLESH|Physics")
bool AddPlaneConstraint(const FSoftBodyPlaneConstraint& PlaneConstraint);
/**
* Update simulation settings
* @param SimulationSettings - New simulation settings
*/
UFUNCTION(BlueprintCallable, Category = "FLESH|Physics")
void UpdateSimulationSettings(const FSoftBodySimulationSettings& SimulationSettings);
/**
* Enable or disable simulation
* @param bEnable - Whether to enable simulation
*/
UFUNCTION(BlueprintCallable, Category = "FLESH|Physics")
void SetSimulationEnabled(bool bEnable);
/**
* Perform a cut on the soft body
* @param CutPlane - Cut plane definition
* @param CapMethod - Method to generate cap mesh
* @return Whether the cut was successful
*/
UFUNCTION(BlueprintCallable, Category = "FLESH|Cutting")
bool PerformCut(const FCutPlane& CutPlane, ECapMeshMethod CapMethod = ECapMeshMethod::TriangleFan);
/**
* Get the soft body physics tool
* @return Soft body physics tool
*/
UFUNCTION(BlueprintCallable, Category = "FLESH|Physics")
USoftBodyPhysicsTool* GetSoftBodyPhysicsTool() const { return SoftBodyPhysicsTool; }
/**
* Get the boolean cut tool
* @return Boolean cut tool
*/
UFUNCTION(BlueprintCallable, Category = "FLESH|Cutting")
UBooleanCutTool* GetBooleanCutTool() const { return BooleanCutTool; }
private:
// Soft body physics tool
UPROPERTY()
TObjectPtr<USoftBodyPhysicsTool> SoftBodyPhysicsTool;
// Boolean cut tool
UPROPERTY()
TObjectPtr<UBooleanCutTool> BooleanCutTool;
// Internal methods
void SetupPhysicsTools();
};