A Demo Project for the UnrealEngineSDK
Loading...
Searching...
No Matches
VREPhysicalAnimationComponent.h
Go to the documentation of this file.
1#pragma once
2
3#include "PhysicsEngine/PhysicalAnimationComponent.h"
4#include "CoreMinimal.h"
5#include "UObject/ObjectMacros.h"
6#include "Components/ActorComponent.h"
7#include "ReferenceSkeleton.h"
8#include "EngineDefines.h"
9#include "PhysicsEngine/ConstraintInstance.h"
10#include "VREPhysicalAnimationComponent.generated.h"
11
12USTRUCT()
13struct VREXPANSIONPLUGIN_API FWeldedBoneDriverData
14{
15 GENERATED_BODY()
16public:
17 FTransform RelativeTransform;
18 FName BoneName;
19 FPhysicsShapeHandle ShapeHandle;
21 FTransform LastLocal;
22
24 RelativeTransform(FTransform::Identity),
25 BoneName(NAME_None)
26 {
27 }
28
29 FORCEINLINE bool operator==(const FPhysicsShapeHandle& Other) const
30 {
31 return (ShapeHandle == Other);
32 }
33};
34
35UCLASS(meta = (BlueprintSpawnableComponent), ClassGroup = Physics)
36class VREXPANSIONPLUGIN_API UVREPhysicalAnimationComponent : public UPhysicalAnimationComponent
37{
38 GENERATED_UCLASS_BODY()
39
40public:
41
43 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = WeldedBoneDriver)
44 bool bIsPaused;
45
47 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = WeldedBoneDriver)
48 bool bAutoSetPhysicsSleepSensitivity;
49
51 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = WeldedBoneDriver)
52 float SleepThresholdMultiplier;
53
55 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = WeldedBoneDriver)
56 TArray<FName> BaseWeldedBoneDriverNames;
57
58 UPROPERTY()
59 TArray<FWeldedBoneDriverData> BoneDriverMap;
61 // Call to setup the welded body driver, initializes all mappings and caches shape contexts
62 // Requires that SetSkeletalMesh be called first
63 UFUNCTION(BlueprintCallable, Category = PhysicalAnimation)
64 void SetupWeldedBoneDriver(TArray<FName> BaseBoneNames);
65
66 // Refreshes the welded bone driver, use this in cases where the body may have changed (such as welding to another body or switching physics)
67 UFUNCTION(BlueprintCallable, Category = PhysicalAnimation)
68 void RefreshWeldedBoneDriver();
69
70 // Sets the welded bone driver to be paused, you can also stop the component from ticking but that will also stop any physical animations going on
71 UFUNCTION(BlueprintCallable, Category = PhysicalAnimation)
72 void SetWeldedBoneDriverPaused(bool bPaused);
73
74 UFUNCTION(BlueprintPure, Category = PhysicalAnimation)
75 bool IsWeldedBoneDriverPaused();
77 void SetupWeldedBoneDriver_Implementation(bool bReInit = false);
78
79 //void OnWeldedMassUpdated(FBodyInstance* BodyInstance);
80 void UpdateWeldedBoneDriver(float DeltaTime);
82 FTransform GetWorldSpaceRefBoneTransform(FReferenceSkeleton& RefSkel, int32 BoneIndex, int32 ParentBoneIndex);
83 FTransform GetRefPoseBoneRelativeTransform(USkeletalMeshComponent* SkeleMesh, FName BoneName, FName ParentBoneName);
84
85 //FCalculateCustomPhysics OnCalculateCustomPhysics;
86 //void CustomPhysics(float DeltaTime, FBodyInstance* BodyInstance);
87
88 virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;
89};
UCLASS(meta = (BlueprintSpawnableComponent), ClassGroup = Physics)
bool bIsPaused
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = WeldedBoneDriver)
TArray< FName > BaseWeldedBoneDriverNames
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = WeldedBoneDriver)
TArray< FWeldedBoneDriverData > BoneDriverMap
UPROPERTY()
float SleepThresholdMultiplier
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = WeldedBoneDriver)
bool bAutoSetPhysicsSleepSensitivity
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = WeldedBoneDriver)
FORCEINLINE bool operator==(const FPhysicsShapeHandle &Other) const