Skip to content

Commit 0de58c7

Browse files
committed
feat: havok misc
1 parent 54ca33f commit 0de58c7

140 files changed

Lines changed: 4147 additions & 802 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

include/RE/B/BSHavok.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#pragma once
2+
3+
#include "RE/N/NiTransform.h"
4+
#include "RE/H/hkTransform.h"
5+
6+
namespace RE
7+
{
8+
constexpr auto HK_TO_BS_SCALE{ 69.99125F };
9+
constexpr auto BS_TO_HK_SCALE{ 0.0142875F };
10+
11+
template <class T1, class T2>
12+
constexpr T1 HK_TO_NI(const T2& a_hk) noexcept
13+
{
14+
if constexpr (std::is_same_v<T1, NiPoint3> && std::is_same_v<T2, hkVector4f>) {
15+
return NiPoint3(a_hk.x, a_hk.y, a_hk.z) * HK_TO_BS_SCALE;
16+
} else if constexpr (std::is_same_v<T1, NiPoint3A> && std::is_same_v<T2, hkVector4f>) {
17+
return NiPoint3A(a_hk.x, a_hk.y, a_hk.z) * HK_TO_BS_SCALE;
18+
} else if constexpr (std::is_same_v<T1, NiPoint4> && std::is_same_v<T2, hkVector4f>) {
19+
return NiPoint4(a_hk.x, a_hk.y, a_hk.z, a_hk.w) * HK_TO_BS_SCALE;
20+
} else if constexpr (std::is_same_v<T1, NiMatrix3> && (std::is_same_v<T2, hkMatrix3f> || std::is_same_v<T2, hkRotationf>)) {
21+
NiMatrix3 ni;
22+
ni[0] = { a_hk[0][0], a_hk[1][0], a_hk[2][0], 0.0F };
23+
ni[1] = { a_hk[0][1], a_hk[1][1], a_hk[2][1], 0.0F };
24+
ni[2] = { a_hk[0][2], a_hk[1][2], a_hk[2][2], 0.0F };
25+
return ni;
26+
} else if constexpr (std::is_same_v<T1, NiTransform> && std::is_same_v<T2, hkTransform>) {
27+
return NiTransform(HK_TO_NI<NiMatrix3>(a_hk.rotation), HK_TO_NI<NiPoint3>(a_hk.translation));
28+
}
29+
}
30+
31+
template <class T1, class T2>
32+
constexpr T1 NI_TO_HK(const T2& a_ni) noexcept
33+
{
34+
if constexpr (std::is_same_v<T1, hkVector4f> && std::is_same_v<T2, NiPoint3>) {
35+
return hkVector4f(a_ni.x, a_ni.y, a_ni.z, 0.0F) * BS_TO_HK_SCALE;
36+
} else if constexpr (std::is_same_v<T1, hkVector4f> && std::is_same_v<T2, NiPoint3A>) {
37+
return hkVector4f(a_ni.x, a_ni.y, a_ni.z, 0.0F) * BS_TO_HK_SCALE;
38+
} else if constexpr (std::is_same_v<T1, hkVector4f> && std::is_same_v<T2, NiPoint4>) {
39+
return hkVector4f(a_ni.x, a_ni.y, a_ni.z, a_ni.w) * BS_TO_HK_SCALE;
40+
} else if constexpr ((std::is_same_v<T1, hkMatrix3f> || std::is_same_v<T1, hkRotationf>) && std::is_same_v<T2, NiMatrix3>) {
41+
hkMatrix3f hk;
42+
hk[0] = { a_ni[0][0], a_ni[1][0], a_ni[2][0], 0.0F };
43+
hk[1] = { a_ni[0][1], a_ni[1][1], a_ni[2][1], 0.0F };
44+
hk[2] = { a_ni[0][2], a_ni[1][2], a_ni[2][2], 0.0F };
45+
return hk;
46+
} else if constexpr (std::is_same_v<T1, hkTransform> && std::is_same_v<T2, NiTransform>) {
47+
return hkTransform(NI_TO_HK<hkMatrix3f>(a_ni.rotate), NI_TO_HK<hkVector4f>(a_ni.translate));
48+
}
49+
}
50+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#pragma once
2+
3+
#include "RE/I/IRendererResourceManager.h"
4+
5+
namespace RE
6+
{
7+
class __declspec(novtable) BSShaderResourceManager :
8+
public IRendererResourceManager
9+
{
10+
public:
11+
static constexpr auto RTTI{ RTTI::BSShaderResourceManager };
12+
static constexpr auto VTABLE{ VTABLE::BSShaderResourceManager };
13+
14+
virtual ~BSShaderResourceManager();
15+
16+
virtual BSTriShape* CreateTriShape(std::uint32_t a_numTriangles, std::uint16_t* a_indices, std::uint32_t a_numVertices, NiPoint3* a_positions, NiPoint2* a_texCoords0, NiColorA* a_texCoords1, NiPoint3* a_normals, NiPoint3* a_binormals, NiPoint3* a_tangents, NiColorA* a_colors, NiColorA* a_skinBoneWeights, std::uint8_t* a_skinBoneIndices, NiColorA* a_landscapeData1, NiColorA* a_landscapeData2, float* a_eyeData, bool a_generatePositionData) override;
17+
virtual BSTriShape* CreateTriShape(std::uint32_t a_numTriangles, std::uint32_t a_numVertices, NiPoint3* a_positions, NiPoint2* a_texCoords, NiColorA* a_colors, std::uint16_t* a_indices) override;
18+
virtual void* CreateTriShape(NiStream* a_stream, std::uint64_t a_vertexDesc, std::uint32_t a_vertexCount, std::uint32_t a_indexCount, char** a_dynamicData) override;
19+
virtual void* CreateTriShapeRendererData(void* a_vertexBuffer, std::uint64_t a_vertexDesc, std::uint16_t* a_indices, std::uint32_t a_indexCount) override;
20+
virtual BSSubIndexTriShape* CreateSubIndexTriShape(std::uint32_t a_numTriangles, std::uint32_t a_numSegments, std::uint16_t* a_indices, std::uint32_t a_numVertices, NiPoint3* a_positions, NiPoint2* a_texCoords0, NiColorA* a_texCoords1, NiPoint3* a_normals, NiPoint3* a_binormals, NiPoint3* a_tangents, NiColorA* a_colors, NiColorA* a_skinBoneWeights, std::uint8_t* a_skinBoneIndices, NiColorA* a_landscapeData1, NiColorA* a_landscapeData2, float* a_eyeData) override;
21+
virtual void IncRefTriShape(void* a_rendererData) override;
22+
virtual void DecRefTriShape(void* a_rendererData) override;
23+
virtual BSDynamicTriShape* CreateDynamicTriShape(std::uint32_t a_dynamicFlags, std::uint32_t a_numTriangles, std::uint16_t* a_indices, std::uint32_t a_numVertices, NiPoint3* a_positions, NiPoint2* a_texCoords0, NiColorA* a_texCoords1, NiPoint3* a_normals, NiPoint3* a_binormals, NiPoint3* a_tangents, NiColorA* a_colors, NiColorA* a_skinBoneWeights, std::uint8_t* a_skinBoneIndices, NiColorA* a_landscapeData1, NiColorA* a_landscapeData2, float* a_eyeData) override;
24+
virtual BSDynamicTriShape* CreateDynamicTriShape(std::uint32_t, std::uint32_t, std::uint32_t, NiPoint3*, NiPoint2*, NiColorA*, std::uint16_t*) override;
25+
virtual void IncRefDynamicTriShape(void* a_rendererData) override;
26+
virtual void DecRefDynamicTriShape(void* a_rendererData) override;
27+
virtual void ConvertBSTriShapeToBSDynamicTriShape(NiNode* a_root, NiDefaultAVObjectPalette* a_objectPalette) override;
28+
virtual void ApplyMaterials(NiAVObject* a_root) override;
29+
virtual void SetTriShapeStreamDynamicFlags(std::uint32_t) override;
30+
virtual void* CreateParticleShape() override;
31+
virtual void IncRefParticleShape(void* a_rendererData) override;
32+
virtual void DecRefParticleShape(void* a_rendererData) override;
33+
virtual BSLines* CreateLineShape(std::uint32_t a_numLines, std::uint16_t* a_indices, std::uint32_t a_numVertices, NiPoint3* a_positions, NiPoint2* a_texCoords0, NiColorA* a_texCoords1, NiPoint3* a_normals, NiPoint3* a_binormals, NiPoint3* a_tangents, NiColorA* a_colors, NiColorA* a_skinBoneWeights, std::uint8_t* a_skinBoneIndices, NiColorA* a_landscapeData1, NiColorA* a_landscapeData2, float* a_eyeData) override;
34+
virtual BSDynamicLines* CreateDynamicLineShape(std::uint32_t, std::uint32_t, std::uint32_t, NiPoint3*, NiPoint2*, NiColorA*, std::uint16_t*) override;
35+
virtual void* CreateDynamicLineShape(NiStream*, std::uint64_t, std::uint32_t, std::uint32_t) override;
36+
virtual BSDynamicLines* CreateDynamicLineShape(std::uint32_t, std::uint32_t, std::uint16_t*, std::uint32_t, NiPoint3*, NiPoint2*, NiColorA*, NiPoint3*, NiPoint3*, NiPoint3*, NiColorA*, NiColorA*, std::uint8_t*, NiColorA*, NiColorA*, float*) override;
37+
virtual void IncRefLines(void* a_rendererData) override;
38+
virtual void DecRefLines(void* a_rendererData) override;
39+
virtual void IncRefDynamicLines(void* a_rendererData) override;
40+
virtual void DecRefDynamicLines(void* a_rendererData) override;
41+
virtual void LoadTexture(NiTexture* apTexture) override;
42+
virtual void CreateStreamingTexture(NiTexture* a_texture, const void* a_userDataIn, void* a_userDataOut) override;
43+
virtual bool ReadStreamingTextureData(NiTexture* a_texture, void* a_userDataIn) override;
44+
virtual bool CreateStreamingTextureArraySlice(NiTexture* a_texture, const void* a_userDataIn, void* a_userDataOut, std::uint32_t a_slice) override;
45+
virtual bool ReadStreamingTextureDataToArraySlice(NiTexture* a_texture, void* a_userDataIn, std::uint32_t a_slice) override;
46+
virtual void FinishStreamingTexture(NiTexture* a_texture) override;
47+
virtual void IncRefTexture(BSGraphics::Texture* a_rendererData) override;
48+
virtual void DecRefTexture(BSGraphics::Texture* a_rendererData) override;
49+
virtual void GetTextureWidthHeight(NiTexture* a_texture, std::uint32_t* a_width, std::uint32_t* a_height) override;
50+
virtual std::uint32_t GetTextureFormat(NiTexture* a_texture) override;
51+
virtual bool UpdateTextureToDesiredMipLevel(NiTexture* a_texture, std::uint32_t*) override;
52+
virtual void LoadUpgradeTextureData(NiTexture* a_texture) override;
53+
virtual bool UpdateStreamingTextureToDesiredMipLevel(NiTexture* a_texture, std::uint32_t*, void*, void*) override;
54+
virtual void FinishStreamingTextureUpgade(NiTexture* a_texture) override;
55+
virtual void* CreateVertexBuffer(std::uint32_t* a_dataSize, void* a_data, std::uint32_t a_stride, std::uint64_t) override;
56+
virtual void DecRefVertexBuffer(void* a_rendererData) override;
57+
virtual NiShadeProperty* CreateDefaultEffectShaderProperty(bool a_vertexColors, bool a_skinned) override;
58+
virtual BSMeshLODTriShape* CreateMeshLODTriShape(std::uint32_t*, std::uint32_t, std::uint64_t, std::uint32_t, std::uint32_t, void*) override;
59+
virtual BSMeshLODTriShape* CreateMeshLODTriShape(BSTriShape*, std::uint32_t*, std::uint32_t) override;
60+
virtual std::uint32_t UpdateIndexBufferForInstancing(BSMultiStreamInstanceTriShape*, std::uint32_t) override;
61+
virtual bool FindIntersectionsTriShapeFastPath(const NiPoint3*, const NiPoint3*, NiPick*, BSTriShape*) override;
62+
virtual void CreateTangentSpace(std::uint32_t, std::uint16_t*, std::uint32_t, NiPoint3*, NiPoint2*, NiPoint3*, NiPoint3*, NiPoint3*) override;
63+
virtual float GetShaderFrameCount() override;
64+
virtual float GetShaderTimerDelta() override;
65+
virtual void GetFadeNodeSettings(FadeNodeSettings* a_skinned) override;
66+
virtual void GetCameraVectors(NiPoint3* a_up, NiPoint3* a_right, NiPoint3* a_direction) override;
67+
68+
static inline BSShaderResourceManager* GetSingleton()
69+
{
70+
static REL::Relocation<BSShaderResourceManager**> ptr{ ID::BSShaderResourceManager::Singleton };
71+
return *ptr;
72+
}
73+
};
74+
}

include/RE/B/BSSoundHandle.h

Lines changed: 96 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace RE
44
{
55
class BSISoundOutputModel;
6+
class NiAVObject;
7+
class NiPoint3;
68

79
class BSSoundHandle
810
{
@@ -25,6 +27,13 @@ namespace RE
2527
kEnvSlow = 0x3
2628
};
2729

30+
void ClearFollowedObject()
31+
{
32+
using func_t = decltype(&BSSoundHandle::ClearFollowedObject);
33+
static REL::Relocation<func_t> func{ ID::BSSoundHandle::ClearFollowedObject };
34+
func(this);
35+
}
36+
2837
bool FadeInPlay(std::uint16_t a_milliseconds)
2938
{
3039
using func_t = decltype(&BSSoundHandle::FadeInPlay);
@@ -39,27 +48,111 @@ namespace RE
3948
return func(this, a_milliseconds);
4049
}
4150

51+
bool FadeTo(const std::uint16_t a_targetAttenuation, const std::uint16_t a_milliseconds)
52+
{
53+
using func_t = decltype(&BSSoundHandle::FadeTo);
54+
static REL::Relocation<func_t> func{ ID::BSSoundHandle::FadeTo };
55+
return func(this, a_targetAttenuation, a_milliseconds);
56+
}
57+
58+
std::uint64_t GetDuration()
59+
{
60+
using func_t = decltype(&BSSoundHandle::GetDuration);
61+
static REL::Relocation<func_t> func{ ID::BSSoundHandle::GetDuration };
62+
return func(this);
63+
}
64+
65+
bool IsEnvelopeLoop()
66+
{
67+
using func_t = decltype(&BSSoundHandle::IsEnvelopeLoop);
68+
static REL::Relocation<func_t> func{ ID::BSSoundHandle::IsEnvelopeLoop };
69+
return func(this);
70+
}
71+
72+
bool IsPaused()
73+
{
74+
using func_t = decltype(&BSSoundHandle::IsPaused);
75+
static REL::Relocation<func_t> func{ ID::BSSoundHandle::IsPaused };
76+
return func(this);
77+
}
78+
4279
bool IsPlaying() const
4380
{
4481
using func_t = decltype(&BSSoundHandle::IsPlaying);
4582
static REL::Relocation<func_t> func{ ID::BSSoundHandle::IsPlaying };
4683
return func(this);
4784
}
4885

86+
bool IsValid()
87+
{
88+
using func_t = decltype(&BSSoundHandle::IsValid);
89+
static REL::Relocation<func_t> func{ ID::BSSoundHandle::IsValid };
90+
return func(this);
91+
}
92+
93+
bool Pause()
94+
{
95+
using func_t = decltype(&BSSoundHandle::Pause);
96+
static REL::Relocation<func_t> func{ ID::BSSoundHandle::Pause };
97+
return func(this);
98+
}
99+
49100
bool Play()
50101
{
51102
using func_t = decltype(&BSSoundHandle::Play);
52103
static REL::Relocation<func_t> func{ ID::BSSoundHandle::Play };
53104
return func(this);
54105
}
55106

107+
bool PlayAfter(const std::uint64_t a_delay)
108+
{
109+
using func_t = decltype(&BSSoundHandle::PlayAfter);
110+
static REL::Relocation<func_t> func{ ID::BSSoundHandle::PlayAfter };
111+
return func(this, a_delay);
112+
}
113+
114+
bool SetFrequency(const float a_frequency)
115+
{
116+
using func_t = decltype(&BSSoundHandle::SetFrequency);
117+
static REL::Relocation<func_t> func{ ID::BSSoundHandle::SetFrequency };
118+
return func(this, a_frequency);
119+
}
120+
121+
bool SetFrequencyVariance(const std::uint8_t a_variance)
122+
{
123+
using func_t = decltype(&BSSoundHandle::SetFrequencyVariance);
124+
static REL::Relocation<func_t> func{ ID::BSSoundHandle::SetFrequencyVariance };
125+
return func(this, a_variance);
126+
}
127+
128+
void SetObjectToFollow(const NiAVObject* a_object)
129+
{
130+
using func_t = decltype(&BSSoundHandle::SetObjectToFollow);
131+
static REL::Relocation<func_t> func{ ID::BSSoundHandle::SetObjectToFollow };
132+
func(this, a_object);
133+
}
134+
56135
bool SetOutputModel(const BSISoundOutputModel* a_outputModel)
57136
{
58137
using func_t = decltype(&BSSoundHandle::SetOutputModel);
59138
static REL::Relocation<func_t> func{ ID::BSSoundHandle::SetOutputModel };
60139
return func(this, a_outputModel);
61140
}
62141

142+
bool SetPosition(const NiPoint3& a_position)
143+
{
144+
using func_t = decltype(&BSSoundHandle::SetPosition);
145+
static REL::Relocation<func_t> func{ ID::BSSoundHandle::SetPosition };
146+
return func(this, a_position);
147+
}
148+
149+
bool SetStaticAttenuation(const std::uint16_t a_attenuation)
150+
{
151+
using func_t = decltype(&BSSoundHandle::SetStaticAttenuation);
152+
static REL::Relocation<func_t> func{ ID::BSSoundHandle::SetStaticAttenuation };
153+
return func(this, a_attenuation);
154+
}
155+
63156
bool Stop()
64157
{
65158
using func_t = decltype(&BSSoundHandle::Stop);
@@ -68,9 +161,9 @@ namespace RE
68161
}
69162

70163
// members
71-
std::uint32_t soundID; // 0
72-
bool assumeSuccess; // 4
73-
std::int8_t state; // 5
164+
std::uint32_t soundID; // 0x0
165+
bool assumeSuccess; // 0x4
166+
std::uint8_t state; // 0x5
74167
};
75168
static_assert(sizeof(BSSoundHandle) == 0x8);
76169
}

include/RE/B/BSVisit.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22

33
namespace RE
44
{
5-
class bhkNiCollisionObject;
5+
class bhkNPCollisionObject;
66
class BSGeometry;
77
class NiAVObject;
88

9-
namespace BSVisit
9+
enum class BSVisitControl
1010
{
11-
enum class BSVisitControl
12-
{
13-
kContinue = 0x0,
14-
kStop = 0x1
15-
};
11+
kContinue = 0x0,
12+
kStop = 0x1
13+
};
1614

17-
BSVisitControl TraverseScenegraphGeometries(NiAVObject* a_object, std::function<BSVisitControl(BSGeometry*)> a_func);
18-
BSVisitControl TraverseScenegraphObjects(NiAVObject* a_object, std::function<BSVisitControl(NiAVObject*)> a_func);
15+
namespace BSVisit
16+
{
17+
BSVisitControl TraverseScenegraphGeometries(const NiAVObject* a_object, std::function<BSVisitControl(BSGeometry*)> a_func);
18+
BSVisitControl TraverseScenegraphObjects(const NiAVObject* a_object, std::function<BSVisitControl(NiAVObject*)> a_func);
19+
BSVisitControl TraverseScenegraphCollision(const NiAVObject* a_object, std::function<BSVisitControl(bhkNPCollisionObject*)> a_func);
1920
}
2021
}

include/RE/B/BSXFlags.h

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#pragma once
2+
3+
#include "RE/N/NiIntegerExtraData.h"
4+
#include "RE/N/NiObjectNET.h"
5+
6+
namespace RE
7+
{
8+
class __declspec(novtable) BSXFlags :
9+
public NiIntegerExtraData
10+
{
11+
public:
12+
static constexpr auto RTTI{ RTTI::BSXFlags };
13+
static constexpr auto VTABLE{ VTABLE::BSXFlags };
14+
static constexpr auto Ni_RTTI{ Ni_RTTI::BSXFlags };
15+
16+
enum class Flag : std::int32_t
17+
{
18+
kNone = 0,
19+
kAnimated = 1 << 0,
20+
kHavok = 1 << 1,
21+
kRagdoll = 1 << 2,
22+
kComplex = 1 << 3,
23+
kAddon = 1 << 4,
24+
kEditorMarker = 1 << 5,
25+
kDynamic = 1 << 6,
26+
kArticulated = 1 << 7,
27+
kNeedsTransformUpdate = 1 << 8,
28+
kExternalEmit = 1 << 9,
29+
kMagicShaderParticles = 1 << 10,
30+
kLights = 1 << 11,
31+
kBreakable = 1 << 12,
32+
kSearchedBreakable = 1 << 13
33+
};
34+
35+
BSXFlags() :
36+
NiIntegerExtraData("BSX", 0)
37+
{
38+
REX::EMPLACE_VTABLE(this);
39+
}
40+
41+
BSXFlags(const REX::TEnumSet<Flag> a_value) :
42+
NiIntegerExtraData("BSX", a_value.underlying())
43+
{
44+
REX::EMPLACE_VTABLE(this);
45+
}
46+
47+
REX::TEnumSet<Flag> GetFlags() const
48+
{
49+
return static_cast<Flag>(value);
50+
}
51+
52+
void SetFlags(const REX::TEnumSet<Flag> a_value)
53+
{
54+
value = a_value.underlying();
55+
}
56+
57+
static BSXFlags* Find(NiObjectNET* a_object)
58+
{
59+
return a_object ? a_object->GetExtraData<BSXFlags>("BSX") : nullptr;
60+
}
61+
};
62+
static_assert(sizeof(BSXFlags) == 0x20);
63+
}

include/RE/B/bhkCharacterController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "RE/B/bhkNPCollisionObjectUnlinked.h"
77
#include "RE/H/hkRefPtr.h"
88
#include "RE/H/hkStepInfo.h"
9-
#include "RE/H/hkVector4f.h"
9+
#include "RE/H/hkVector4.h"
1010
#include "RE/H/hknpCharacterContext.h"
1111
#include "RE/H/hknpCharacterState.h"
1212
#include "RE/H/hknpCharacterSurfaceInfo.h"

0 commit comments

Comments
 (0)