From 7c5df1bae45cde63c55a37f7ecb7e788e27b1131 Mon Sep 17 00:00:00 2001 From: Drew Warwick Date: Fri, 12 Jan 2024 03:02:21 -0800 Subject: [PATCH 1/2] RE constraints --- include/RE/H/hkpConstraintAtom.h | 26 ++--- include/RE/H/hkpConstraintMotor.h | 108 +++++++++++++++++++ include/RE/H/hkpLimitedHingeConstraintData.h | 30 ++++++ include/RE/H/hkpRagdollConstraintData.h | 31 ++++++ include/RE/H/hkpSolverResults.h | 14 +++ include/RE/Skyrim.h | 2 + 6 files changed, 199 insertions(+), 12 deletions(-) create mode 100644 include/RE/H/hkpConstraintMotor.h create mode 100644 include/RE/H/hkpSolverResults.h diff --git a/include/RE/H/hkpConstraintAtom.h b/include/RE/H/hkpConstraintAtom.h index 55c5aef08..54174c9f5 100644 --- a/include/RE/H/hkpConstraintAtom.h +++ b/include/RE/H/hkpConstraintAtom.h @@ -2,6 +2,8 @@ namespace RE { + class hkpConstraintMotor; + struct hkpConstraintAtom { public: @@ -150,23 +152,23 @@ namespace RE struct hkpAngMotorConstraintAtom : public hkpConstraintAtom { - bool enabled; // 02 - uint8_t motorAxis; // 03 - int16_t initializedOffset; // 04 - int16_t previousTargetAngleOffset; // 06 - int16_t correspondingAngLimitSolverResultOffset; // 08 - float targetAngle; // 0C - uintptr_t motor; // 10 + bool enabled; // 02 + uint8_t motorAxis; // 03 + int16_t initializedOffset; // 04 + int16_t previousTargetAngleOffset; // 06 + int16_t correspondingAngLimitSolverResultOffset; // 08 + float targetAngle; // 0C + hkpConstraintMotor* motor; // 10 }; static_assert(sizeof(hkpAngMotorConstraintAtom) == 0x18); struct hkpRagdollMotorConstraintAtom : public hkpConstraintAtom { - bool enabled; // 02 - int16_t initializedOffset; // 04 - int16_t previousTargetAnglesOffset; // 06 - hkMatrix3 target_bRca; // 10 - uintptr_t motors[3]; // 40 + bool enabled; // 02 + int16_t initializedOffset; // 04 + int16_t previousTargetAnglesOffset; // 06 + hkMatrix3 target_bRca; // 10 + hkpConstraintMotor* motors[3]; // 40 }; static_assert(sizeof(hkpRagdollMotorConstraintAtom) == 0x60); } diff --git a/include/RE/H/hkpConstraintMotor.h b/include/RE/H/hkpConstraintMotor.h new file mode 100644 index 000000000..46e87d520 --- /dev/null +++ b/include/RE/H/hkpConstraintMotor.h @@ -0,0 +1,108 @@ +#pragma once + +#include "RE/H/hkReferencedObject.h" + +namespace RE +{ + class hkpConstraintMotor : public hkReferencedObject + { + public: + enum class MotorType + { + kInvalid = 0, + + kPosition, + kVelocity, + kSpring, + kCallback, + + kNUM + }; + + inline static constexpr auto RTTI = RTTI_hkpConstraintMotor; + inline static constexpr auto VTABLE = VTABLE_hkpConstraintMotor; + + // members + stl::enumeration type; // 10 + }; + static_assert(sizeof(hkpConstraintMotor) == 0x18); + + class hkpLimitedForceConstraintMotor : public hkpConstraintMotor + { + public: + inline static constexpr auto RTTI = RTTI_hkpLimitedForceConstraintMotor; + inline static constexpr auto VTABLE = VTABLE_hkpLimitedForceConstraintMotor; + + // members + float minForce; // 18 + float maxForce; // 1C + }; + static_assert(sizeof(hkpLimitedForceConstraintMotor) == 0x20); + + class hkpPositionConstraintMotor : public hkpLimitedForceConstraintMotor + { + public: + inline static constexpr auto RTTI = RTTI_hkpPositionConstraintMotor; + inline static constexpr auto VTABLE = VTABLE_hkpPositionConstraintMotor; + + // members + float tau; // 20 + float damping; // 24 + float proportionalRecoveryVelocity; // 28 + float constantRecoveryVelocity; // 2C + }; + static_assert(sizeof(hkpPositionConstraintMotor) == 0x30); + + class hkpVelocityConstraintMotor : public hkpLimitedForceConstraintMotor + { + public: + inline static constexpr auto RTTI = RTTI_hkpVelocityConstraintMotor; + inline static constexpr auto VTABLE = VTABLE_hkpVelocityConstraintMotor; + + // members + float tau; // 20 + float targetVelocity; // 24 + bool useConstraintTarget; // 28 + }; + static_assert(sizeof(hkpVelocityConstraintMotor) == 0x30); + + class hkpSpringDamperConstraintMotor : public hkpLimitedForceConstraintMotor + { + public: + inline static constexpr auto RTTI = RTTI_hkpSpringDamperConstraintMotor; + inline static constexpr auto VTABLE = VTABLE_hkpSpringDamperConstraintMotor; + + // members + float springConstant; // 20 + float springDamping; // 24 + }; + static_assert(sizeof(hkpSpringDamperConstraintMotor) == 0x28); + + class hkpCallbackConstraintMotor : public hkpLimitedForceConstraintMotor + { + public: + enum class CallbackType + { + kUnk = 0, + + kUser0, + kUser1, + kUser2, + + kNUM + }; + + inline static constexpr auto RTTI = RTTI_hkpCallbackConstraintMotor; + inline static constexpr auto VTABLE = VTABLE_hkpCallbackConstraintMotor; + + using CallbackFunction = void(const hkpCallbackConstraintMotor& motor, const void* unk0, void* unk1); + + // members + CallbackFunction* func; // 20 + stl::enumeration callbackType; // 28 + std::uint64_t userData0; // 30 + std::uint64_t userData1; // 38 + std::uint64_t userData2; // 40 + }; + static_assert(sizeof(hkpCallbackConstraintMotor) == 0x48); +} \ No newline at end of file diff --git a/include/RE/H/hkpLimitedHingeConstraintData.h b/include/RE/H/hkpLimitedHingeConstraintData.h index 2ba81a8e0..4830a79bd 100644 --- a/include/RE/H/hkpLimitedHingeConstraintData.h +++ b/include/RE/H/hkpLimitedHingeConstraintData.h @@ -2,12 +2,29 @@ #include "RE/H/hkpConstraintAtom.h" #include "RE/H/hkpConstraintData.h" +#include "RE/H/hkpSolverResults.h" namespace RE { class hkpLimitedHingeConstraintData : public hkpConstraintData { public: + enum SolverResultType + { + kMotor = 0, + kFriction, + kLimit, + + kAngle0, + kAngle1, + + kLinear0, + kLinear1, + kLinear2, + + kNUM + }; + inline static constexpr auto RTTI = RTTI_hkpLimitedHingeConstraintData; inline static constexpr auto VTABLE = VTABLE_hkpLimitedHingeConstraintData; @@ -23,6 +40,19 @@ namespace RE }; static_assert(sizeof(Atoms) == 0xF0); + struct Runtime + { + inline float getCurrentAngle() + { + return solverResults[SolverResultType::kLimit].data * -1.f; + } + + hkpSolverResults solverResults[SolverResultType::kNUM]; // 00 + bool previousTargetInitialized; // 40 + float previousTargetAngle; // 44 + }; + static_assert(sizeof(Runtime) == 0x48); + // members Atoms atoms; // 18 }; diff --git a/include/RE/H/hkpRagdollConstraintData.h b/include/RE/H/hkpRagdollConstraintData.h index 6195f6409..8f4956ef4 100644 --- a/include/RE/H/hkpRagdollConstraintData.h +++ b/include/RE/H/hkpRagdollConstraintData.h @@ -2,12 +2,34 @@ #include "RE/H/hkpConstraintAtom.h" #include "RE/H/hkpConstraintData.h" +#include "RE/H/hkpSolverResults.h" namespace RE { class hkpRagdollConstraintData : public hkpConstraintData { public: + enum SolverResultType + { + kMotor0 = 0, + kMotor1, + kMotor2, + + kFriction0, + kFriction1, + kFriction2, + + kTwist, + kCone, + kPlane, + + kLinear0, + kLinear1, + kLinear2, + + kNUM + }; + inline static constexpr auto RTTI = RTTI_hkpRagdollConstraintData; inline static constexpr auto VTABLE = VTABLE_hkpRagdollConstraintData; @@ -24,6 +46,15 @@ namespace RE }; static_assert(sizeof(Atoms) == 0x160); + struct Runtime + { + hkpSolverResults solverResults[SolverResultType::kNUM]; // 00 + bool previousTargetInitialized[3]; // 60 + float previousTargetAngle[3]; // 64 + float coneAngle; // 70 + }; + static_assert(sizeof(Runtime) == 0x74); + // members Atoms atoms; // 18 }; diff --git a/include/RE/H/hkpSolverResults.h b/include/RE/H/hkpSolverResults.h new file mode 100644 index 000000000..52da57080 --- /dev/null +++ b/include/RE/H/hkpSolverResults.h @@ -0,0 +1,14 @@ +#pragma once + +namespace RE +{ + + class hkpSolverResults + { + public: + float impulse; // 00 + float data; // 04 + }; + static_assert(sizeof(hkpSolverResults) == 0x08); + +} \ No newline at end of file diff --git a/include/RE/Skyrim.h b/include/RE/Skyrim.h index 579e38545..9c0ca6d3f 100644 --- a/include/RE/Skyrim.h +++ b/include/RE/Skyrim.h @@ -986,6 +986,7 @@ #include "RE/H/hkpConstraintData.h" #include "RE/H/hkpConstraintInfo.h" #include "RE/H/hkpConstraintInstance.h" +#include "RE/H/hkpConstraintMotor.h" #include "RE/H/hkpConstraintOwner.h" #include "RE/H/hkpContactListener.h" #include "RE/H/hkpContactPointEvent.h" @@ -1030,6 +1031,7 @@ #include "RE/H/hkpSimulationIsland.h" #include "RE/H/hkpSingleShapeContainer.h" #include "RE/H/hkpSolverInfo.h" +#include "RE/H/hkpSolverResults.h" #include "RE/H/hkpSphereRepShape.h" #include "RE/H/hkpSphereShape.h" #include "RE/H/hkpTypedBroadPhaseHandle.h" From d8d82ef9ddb07dac50b3bf19c957d896cd653b49 Mon Sep 17 00:00:00 2001 From: W-Drew Date: Fri, 12 Jan 2024 18:56:53 +0000 Subject: [PATCH 2/2] maintenance --- cmake/sourcelist.cmake | 2 + include/RE/H/hkpConstraintMotor.h | 164 +++++++++---------- include/RE/H/hkpLimitedHingeConstraintData.h | 2 +- include/RE/H/hkpRagdollConstraintData.h | 2 +- include/RE/H/hkpSolverResults.h | 14 +- 5 files changed, 93 insertions(+), 91 deletions(-) diff --git a/cmake/sourcelist.cmake b/cmake/sourcelist.cmake index e94d783bb..10ddee0a5 100644 --- a/cmake/sourcelist.cmake +++ b/cmake/sourcelist.cmake @@ -984,6 +984,7 @@ set(SOURCES include/RE/H/hkpConstraintData.h include/RE/H/hkpConstraintInfo.h include/RE/H/hkpConstraintInstance.h + include/RE/H/hkpConstraintMotor.h include/RE/H/hkpConstraintOwner.h include/RE/H/hkpContactListener.h include/RE/H/hkpContactPointEvent.h @@ -1028,6 +1029,7 @@ set(SOURCES include/RE/H/hkpSimulationIsland.h include/RE/H/hkpSingleShapeContainer.h include/RE/H/hkpSolverInfo.h + include/RE/H/hkpSolverResults.h include/RE/H/hkpSphereRepShape.h include/RE/H/hkpSphereShape.h include/RE/H/hkpTypedBroadPhaseHandle.h diff --git a/include/RE/H/hkpConstraintMotor.h b/include/RE/H/hkpConstraintMotor.h index 46e87d520..dec9efe0a 100644 --- a/include/RE/H/hkpConstraintMotor.h +++ b/include/RE/H/hkpConstraintMotor.h @@ -4,105 +4,105 @@ namespace RE { - class hkpConstraintMotor : public hkReferencedObject - { - public: - enum class MotorType - { - kInvalid = 0, - - kPosition, - kVelocity, - kSpring, - kCallback, - - kNUM - }; - - inline static constexpr auto RTTI = RTTI_hkpConstraintMotor; + class hkpConstraintMotor : public hkReferencedObject + { + public: + enum class MotorType + { + kInvalid = 0, + + kPosition, + kVelocity, + kSpring, + kCallback, + + kNUM + }; + + inline static constexpr auto RTTI = RTTI_hkpConstraintMotor; inline static constexpr auto VTABLE = VTABLE_hkpConstraintMotor; - // members - stl::enumeration type; // 10 - }; - static_assert(sizeof(hkpConstraintMotor) == 0x18); + // members + stl::enumeration type; // 10 + }; + static_assert(sizeof(hkpConstraintMotor) == 0x18); - class hkpLimitedForceConstraintMotor : public hkpConstraintMotor - { - public: - inline static constexpr auto RTTI = RTTI_hkpLimitedForceConstraintMotor; + class hkpLimitedForceConstraintMotor : public hkpConstraintMotor + { + public: + inline static constexpr auto RTTI = RTTI_hkpLimitedForceConstraintMotor; inline static constexpr auto VTABLE = VTABLE_hkpLimitedForceConstraintMotor; - // members - float minForce; // 18 - float maxForce; // 1C - }; - static_assert(sizeof(hkpLimitedForceConstraintMotor) == 0x20); + // members + float minForce; // 18 + float maxForce; // 1C + }; + static_assert(sizeof(hkpLimitedForceConstraintMotor) == 0x20); - class hkpPositionConstraintMotor : public hkpLimitedForceConstraintMotor - { - public: - inline static constexpr auto RTTI = RTTI_hkpPositionConstraintMotor; + class hkpPositionConstraintMotor : public hkpLimitedForceConstraintMotor + { + public: + inline static constexpr auto RTTI = RTTI_hkpPositionConstraintMotor; inline static constexpr auto VTABLE = VTABLE_hkpPositionConstraintMotor; - // members - float tau; // 20 - float damping; // 24 - float proportionalRecoveryVelocity; // 28 - float constantRecoveryVelocity; // 2C - }; - static_assert(sizeof(hkpPositionConstraintMotor) == 0x30); - - class hkpVelocityConstraintMotor : public hkpLimitedForceConstraintMotor - { - public: - inline static constexpr auto RTTI = RTTI_hkpVelocityConstraintMotor; + // members + float tau; // 20 + float damping; // 24 + float proportionalRecoveryVelocity; // 28 + float constantRecoveryVelocity; // 2C + }; + static_assert(sizeof(hkpPositionConstraintMotor) == 0x30); + + class hkpVelocityConstraintMotor : public hkpLimitedForceConstraintMotor + { + public: + inline static constexpr auto RTTI = RTTI_hkpVelocityConstraintMotor; inline static constexpr auto VTABLE = VTABLE_hkpVelocityConstraintMotor; - // members - float tau; // 20 - float targetVelocity; // 24 - bool useConstraintTarget; // 28 - }; - static_assert(sizeof(hkpVelocityConstraintMotor) == 0x30); - - class hkpSpringDamperConstraintMotor : public hkpLimitedForceConstraintMotor - { - public: - inline static constexpr auto RTTI = RTTI_hkpSpringDamperConstraintMotor; + // members + float tau; // 20 + float targetVelocity; // 24 + bool useConstraintTarget; // 28 + }; + static_assert(sizeof(hkpVelocityConstraintMotor) == 0x30); + + class hkpSpringDamperConstraintMotor : public hkpLimitedForceConstraintMotor + { + public: + inline static constexpr auto RTTI = RTTI_hkpSpringDamperConstraintMotor; inline static constexpr auto VTABLE = VTABLE_hkpSpringDamperConstraintMotor; - // members - float springConstant; // 20 - float springDamping; // 24 - }; - static_assert(sizeof(hkpSpringDamperConstraintMotor) == 0x28); + // members + float springConstant; // 20 + float springDamping; // 24 + }; + static_assert(sizeof(hkpSpringDamperConstraintMotor) == 0x28); - class hkpCallbackConstraintMotor : public hkpLimitedForceConstraintMotor - { - public: - enum class CallbackType - { - kUnk = 0, + class hkpCallbackConstraintMotor : public hkpLimitedForceConstraintMotor + { + public: + enum class CallbackType + { + kUnk = 0, - kUser0, - kUser1, - kUser2, + kUser0, + kUser1, + kUser2, - kNUM - }; + kNUM + }; - inline static constexpr auto RTTI = RTTI_hkpCallbackConstraintMotor; + inline static constexpr auto RTTI = RTTI_hkpCallbackConstraintMotor; inline static constexpr auto VTABLE = VTABLE_hkpCallbackConstraintMotor; - using CallbackFunction = void(const hkpCallbackConstraintMotor& motor, const void* unk0, void* unk1); + using CallbackFunction = void(const hkpCallbackConstraintMotor& motor, const void* unk0, void* unk1); - // members - CallbackFunction* func; // 20 - stl::enumeration callbackType; // 28 - std::uint64_t userData0; // 30 - std::uint64_t userData1; // 38 - std::uint64_t userData2; // 40 - }; - static_assert(sizeof(hkpCallbackConstraintMotor) == 0x48); + // members + CallbackFunction* func; // 20 + stl::enumeration callbackType; // 28 + std::uint64_t userData0; // 30 + std::uint64_t userData1; // 38 + std::uint64_t userData2; // 40 + }; + static_assert(sizeof(hkpCallbackConstraintMotor) == 0x48); } \ No newline at end of file diff --git a/include/RE/H/hkpLimitedHingeConstraintData.h b/include/RE/H/hkpLimitedHingeConstraintData.h index 4830a79bd..13349d088 100644 --- a/include/RE/H/hkpLimitedHingeConstraintData.h +++ b/include/RE/H/hkpLimitedHingeConstraintData.h @@ -45,7 +45,7 @@ namespace RE inline float getCurrentAngle() { return solverResults[SolverResultType::kLimit].data * -1.f; - } + } hkpSolverResults solverResults[SolverResultType::kNUM]; // 00 bool previousTargetInitialized; // 40 diff --git a/include/RE/H/hkpRagdollConstraintData.h b/include/RE/H/hkpRagdollConstraintData.h index 8f4956ef4..283be4267 100644 --- a/include/RE/H/hkpRagdollConstraintData.h +++ b/include/RE/H/hkpRagdollConstraintData.h @@ -22,7 +22,7 @@ namespace RE kTwist, kCone, kPlane, - + kLinear0, kLinear1, kLinear2, diff --git a/include/RE/H/hkpSolverResults.h b/include/RE/H/hkpSolverResults.h index 52da57080..96ea565cd 100644 --- a/include/RE/H/hkpSolverResults.h +++ b/include/RE/H/hkpSolverResults.h @@ -3,12 +3,12 @@ namespace RE { - class hkpSolverResults - { - public: - float impulse; // 00 - float data; // 04 - }; - static_assert(sizeof(hkpSolverResults) == 0x08); + class hkpSolverResults + { + public: + float impulse; // 00 + float data; // 04 + }; + static_assert(sizeof(hkpSolverResults) == 0x08); } \ No newline at end of file