UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PhysicsUserData_Chaos.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "CoreMinimal.h"
5#include "EngineDefines.h"
7
9struct FBodyInstance;
11
12// Note: this must match the enum EChaosUserDataType in PhysicsInterfaceTypesCore
14{
15private:
16 enum EType
17 {
18 Invalid,
19 BodyInstance,
20 PhysicalMaterial,
21 PhysScene,
22 ConstraintInstanceBase
23 };
24
25 EType Type;
26 void* Payload;
27
28public:
29 FPhysicsUserData_Chaos() : Type(EType::Invalid), Payload(nullptr) { }
30 FPhysicsUserData_Chaos(FBodyInstance* InPayload) : Type(EType::BodyInstance), Payload(InPayload) { }
31 FPhysicsUserData_Chaos(UPhysicalMaterial* InPayload) : Type(EType::PhysicalMaterial), Payload(InPayload) { }
32 FPhysicsUserData_Chaos(FPhysScene* InPayload) : Type(EType::PhysScene), Payload(InPayload) { }
33 FPhysicsUserData_Chaos(FConstraintInstanceBase* InPayload) : Type(EType::ConstraintInstanceBase), Payload(InPayload) { }
34
35 template <class T> static T* Get(void* UserData);
36 template <class T> static void Set(void* UserData, T* InPayload);
37
38 /*
39 template <class T> static T* Get(intptr_t UserData)
40 {
41 return Get<T>((void*)UserData);
42 }
43
44 template <class T> static void Set(intptr_t UserData, T* InPayload)
45 {
46 return Get<T>((void*)UserData);
47 }
48 */
49
50private:
51
52 template <class T, EType TType> static T* Get(void* UserData)
53 {
54 FPhysicsUserData_Chaos* ChaosUserData = (FPhysicsUserData_Chaos*)UserData;
55 return UserData && ChaosUserData->Type == TType ? (T*)(ChaosUserData->Payload) : nullptr;
56 }
57};
58
59template<> inline FBodyInstance* FPhysicsUserData_Chaos::Get(void* UserData)
60{
62}
63
64template<> inline UPhysicalMaterial* FPhysicsUserData_Chaos::Get(void* UserData)
65{
67}
68
69template<> inline FPhysScene* FPhysicsUserData_Chaos::Get(void* UserData)
70{
71 return Get<FPhysScene, EType::PhysScene>(UserData);
72}
73
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition PhysScene_Chaos.h:116
Definition PhysicsUserData_Chaos.h:14
FPhysicsUserData_Chaos(FBodyInstance *InPayload)
Definition PhysicsUserData_Chaos.h:30
static void Set(void *UserData, T *InPayload)
FPhysicsUserData_Chaos(UPhysicalMaterial *InPayload)
Definition PhysicsUserData_Chaos.h:31
static T * Get(void *UserData)
FPhysicsUserData_Chaos(FPhysScene *InPayload)
Definition PhysicsUserData_Chaos.h:32
FPhysicsUserData_Chaos(FConstraintInstanceBase *InPayload)
Definition PhysicsUserData_Chaos.h:33
FPhysicsUserData_Chaos()
Definition PhysicsUserData_Chaos.h:29
Definition PhysicalMaterial.h:104
Definition BodyInstance.h:320
Definition ConstraintInstance.h:210