CommonLibSSE NG
NiCamera.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/B/BSTArray.h"
4 #include "RE/N/NiAVObject.h"
5 #include "RE/N/NiFrustum.h"
6 #include "RE/N/NiPoint3.h"
7 #include "RE/N/NiRect.h"
8 
9 namespace RE
10 {
11  class NiCamera : public NiAVObject
12  {
13  public:
14  inline static constexpr auto RTTI = RTTI_NiCamera;
15  inline static auto Ni_RTTI = NiRTTI_NiCamera;
16 
17  struct RUNTIME_DATA
18  {
19 #ifndef ENABLE_SKYRIM_VR
20 # define RUNTIME_DATA_CONTENT float worldToCam[4][4]; /* 0 */
22  };
23  static_assert(sizeof(RUNTIME_DATA) == 0x40);
24 #elif !defined(ENABLE_SKYRIM_AE) && !defined(ENABLE_SKYRIM_SE)
25 # define RUNTIME_DATA_CONTENT \
26  float worldToCam[4][4]; /* 0 */ \
27  NiFrustum* viewFrustumPtr; /* 40 */ \
28  BSTArray<void*> unk180; /* 48 */ \
29  BSTArray<void*> unk198; /* 60 */ \
30  BSTArray<void*> unk1B0; /* 78 */ \
31  std::uint32_t unk1C8; /* 90 */
32 
34  };
35  static_assert(sizeof(RUNTIME_DATA) == 0x98);
36 #else
37 # define RUNTIME_DATA_CONTENT float worldToCam[4][4]; /* 0 */
39  };
40 #endif
41 
43  {
44 #define RUNTIME_DATA2_CONTENT \
45  NiFrustum viewFrustum; /* 00 */ \
46  float minNearPlaneDist; /* 1C */ \
47  float maxFarNearRatio; /* 20 */ \
48  NiRect<float> port; /* 24 */ \
49  float lodAdjust; /* 34 */
50 
52  };
53  static_assert(sizeof(RUNTIME_DATA2) == 0x38);
54 
55  ~NiCamera() override; // 00
56 
57  // override (NiAVObject)
58  const NiRTTI* GetRTTI() const override; // 02
59  NiObject* CreateClone(NiCloningProcess& a_cloning) override; // 17 - { return this; }
60  void LoadBinary(NiStream& a_stream) override; // 18 - { return; }
61  void LinkObject(NiStream& a_stream) override; // 19 - { return; }
62  bool RegisterStreamables(NiStream& a_stream) override; // 1A
63  void SaveBinary(NiStream& a_stream) override; // 1B - { return; }
64  bool IsEqual(NiObject* a_object) override; // 1C
65 #if !defined(ENABLE_SKYRIM_VR) || (!defined(ENABLE_SKYRIM_AE) && !defined(ENABLE_SKYRIM_VR))
66  // The following are virtual functions past the point where VR compatibility breaks.
67  void UpdateWorldBound() override; // 2F - { return; }
68  void UpdateWorldData(NiUpdateData* a_data) override; // 30
69 #endif
70 
71  static bool BoundInFrustum(const NiBound& a_bound, NiCamera* a_camera);
72  static bool NodeInFrustum(NiAVObject* a_node, NiCamera* a_camera);
73  static bool PointInFrustum(const NiPoint3& a_point, NiCamera* a_camera, float a_radius);
74 
75  static bool WorldPtToScreenPt3(const float a_matrix[4][4], const NiRect<float>& a_port, const NiPoint3& a_point, float& a_xOut, float& a_yOut, float& a_zOut, float a_zeroTolerance);
76 
77  [[nodiscard]] inline RUNTIME_DATA& GetRuntimeData() noexcept
78  {
79  return REL::RelocateMember<RUNTIME_DATA>(this, 0x110, 0x138);
80  }
81 
82  [[nodiscard]] inline const RUNTIME_DATA& GetRuntimeData() const noexcept
83  {
84  return REL::RelocateMember<RUNTIME_DATA>(this, 0x110, 0x138);
85  }
86 
87  [[nodiscard]] inline RUNTIME_DATA2& GetRuntimeData2() noexcept
88  {
89  return REL::RelocateMember<RUNTIME_DATA2>(this, 0x150, 0x1CC);
90  }
91 
92  [[nodiscard]] inline const RUNTIME_DATA2& GetRuntimeData2() const noexcept
93  {
94  return REL::RelocateMember<RUNTIME_DATA2>(this, 0x150, 0x1CC);
95  }
96 
97  // members
98 #ifndef SKYRIM_CROSS_VR
99  RUNTIME_DATA_CONTENT; // 110, 138
101 #endif
102  };
103 #ifndef ENABLE_SKYRIM_VR
104  static_assert(sizeof(NiCamera) == 0x188);
105 #elif !defined(ENABLE_SKYRIM_AE) && !defined(ENABLE_SKYRIM_SE)
106  static_assert(sizeof(NiCamera) == 0x208);
107 #endif
108 }
109 #undef RUNTIME_DATA_CONTENT
110 #undef RUNTIME_DATA2_CONTENT
#define RUNTIME_DATA_CONTENT
Definition: NiCamera.h:20
#define RUNTIME_DATA2_CONTENT
Definition: NiCamera.h:44
Definition: NiAVObject.h:50
Definition: NiBound.h:8
Definition: NiCamera.h:12
void SaveBinary(NiStream &a_stream) override
const RUNTIME_DATA & GetRuntimeData() const noexcept
Definition: NiCamera.h:82
static bool BoundInFrustum(const NiBound &a_bound, NiCamera *a_camera)
static bool PointInFrustum(const NiPoint3 &a_point, NiCamera *a_camera, float a_radius)
bool IsEqual(NiObject *a_object) override
RUNTIME_DATA_CONTENT
Definition: NiCamera.h:99
void LinkObject(NiStream &a_stream) override
NiObject * CreateClone(NiCloningProcess &a_cloning) override
RUNTIME_DATA2 & GetRuntimeData2() noexcept
Definition: NiCamera.h:87
RUNTIME_DATA & GetRuntimeData() noexcept
Definition: NiCamera.h:77
bool RegisterStreamables(NiStream &a_stream) override
static bool WorldPtToScreenPt3(const float a_matrix[4][4], const NiRect< float > &a_port, const NiPoint3 &a_point, float &a_xOut, float &a_yOut, float &a_zOut, float a_zeroTolerance)
static bool NodeInFrustum(NiAVObject *a_node, NiCamera *a_camera)
static auto Ni_RTTI
Definition: NiCamera.h:15
const NiRTTI * GetRTTI() const override
void UpdateWorldBound() override
~NiCamera() override
const RUNTIME_DATA2 & GetRuntimeData2() const noexcept
Definition: NiCamera.h:92
RUNTIME_DATA2_CONTENT
Definition: NiCamera.h:100
void LoadBinary(NiStream &a_stream) override
static constexpr auto RTTI
Definition: NiCamera.h:14
void UpdateWorldData(NiUpdateData *a_data) override
Definition: NiCloningProcess.h:10
Definition: NiObject.h:37
Definition: NiPoint3.h:6
Definition: NiRTTI.h:6
Definition: NiRect.h:7
Definition: NiStream.h:29
Definition: NiAVObject.h:25
Definition: AbsorbEffect.h:6
constexpr REL::VariantID NiRTTI_NiCamera(523926, 410506, 0x316ad98)
constexpr REL::VariantID RTTI_NiCamera(690424, 398279, 0x1f61eb0)
Definition: NiCamera.h:43
Definition: NiCamera.h:18