CommonLibVR
TESWorldSpace.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/B/BSString.h"
4 #include "RE/B/BSTArray.h"
5 #include "RE/B/BSTHashMap.h"
6 #include "RE/B/BSTList.h"
7 #include "RE/F/FormTypes.h"
8 #include "RE/N/NiPoint2.h"
9 #include "RE/N/NiSmartPointer.h"
10 #include "RE/N/NiTPointerMap.h"
11 #include "RE/T/TESForm.h"
12 #include "RE/T/TESFullName.h"
13 #include "RE/T/TESModel.h"
14 #include "RE/T/TESTexture.h"
15 
16 namespace RE
17 {
18  class BGSTerrainManager;
19  class BSPortalGraph;
20  class NiNode;
21 
22  struct WORLD_MAP_DATA // MNAM
23  {
24  public:
25  struct CameraData
26  {
27  float minHeight; // 0
28  float maxHeight; // 4
29  float initialPitch; // 8
30  };
31  static_assert(sizeof(CameraData) == 0xC);
32 
33  // members
34  std::uint32_t usableWidth; // 00
35  std::uint32_t usableHeight; // 04
36  std::int16_t nwCellX; // 08
37  std::int16_t nwCellY; // 0A
38  std::int16_t seCellX; // 0C
39  std::int16_t seCellY; // 0E
41  };
42  static_assert(sizeof(WORLD_MAP_DATA) == 0x1C);
43 
44  struct WORLD_MAP_OFFSET_DATA // ONAM
45  {
46  public:
47  // members
48  float mapScale; // 00
49  float mapOffsetX; // 04
50  float mapOffsetY; // 08
51  float mapOffsetZ; // 0C
52  };
53  static_assert(sizeof(WORLD_MAP_OFFSET_DATA) == 0x10);
54 
55  struct CellID
56  {
57  public:
58  constexpr CellID() noexcept :
59  CellID(0, 0)
60  {}
61 
62  constexpr CellID(std::int16_t a_y, std::int16_t a_x) noexcept :
63  y(a_y),
64  x(a_x)
65  {}
66 
67  [[nodiscard]] friend constexpr bool operator==(const CellID& a_lhs, const CellID& a_rhs) noexcept
68  {
69  return a_lhs[0] == a_rhs[0] && a_lhs[1] == a_rhs[1];
70  }
71 
72  [[nodiscard]] constexpr std::int16_t& operator[](std::size_t a_idx) noexcept
73  {
74  assert(a_idx < 2);
75  return std::addressof(y)[a_idx];
76  }
77 
78  [[nodiscard]] constexpr const std::int16_t& operator[](std::size_t a_idx) const noexcept
79  {
80  assert(a_idx < 2);
81  return std::addressof(y)[a_idx];
82  }
83 
84  // members
85  std::int16_t y;
86  std::int16_t x;
87  };
88  static_assert(sizeof(CellID) == 0x4);
89 
90  template <>
91  struct BSCRC32_<CellID>
92  {
93  public:
94  [[nodiscard]] inline std::uint32_t operator()(CellID a_key) const noexcept
95  {
96  return BSCRC32_<std::uint32_t>()(reinterpret_cast<const std::uint32_t&>(a_key));
97  }
98  };
99 
100  class BGSLargeRefData // RNAM
101  {
102  public:
103  // RNAM format in plugins is cell x,y -> formID + cell that contains refr x,y
104  // a lot of RNAM data is for refrs that are actually in adjacent cells, it is currently unknown what behavior this has in game
105  BSTHashMap<CellID, FormID*> cellFormIDMap; // 00 - full data merged at runtime, value is an array of FormIDs with array size as the first entry
106  BSTHashMap<FormID, CellID> formIDCellMap; // 30 - maps FormID to cell so opposite of above map
107 
108  // this filtered version of the full data removes all duplicate RNAM entries and also all entries where cell x,y doesn't match cell that contains refr x,y
109  // this is the one actually used for loading large references on cell attach
111  private:
112  KEEP_FOR_RE()
113  };
114  static_assert(sizeof(BGSLargeRefData) == 0x90);
115 
117  public TESForm, // 000
118  public TESFullName, // 020
119  public TESModel // 030
120  {
121  public:
122  inline static constexpr auto RTTI = RTTI_TESWorldSpace;
123  inline static constexpr auto VTABLE = VTABLE_TESWorldSpace;
124  inline static constexpr auto FORMTYPE = FormType::WorldSpace;
125 
126  enum class Flag
127  {
128  kNone = 0,
129  kSmallWorld = 1 << 0,
130  kCantFastTravel = 1 << 1,
131  kNoLODWater = 1 << 3,
132  kNoLandscape = 1 << 4,
133  kNoSky = 1 << 5,
134  kFixedDimensions = 1 << 6,
135  kNoGrass = 1 << 7,
136  };
137 
138  enum class ParentUseFlag
139  {
140  kNone = 0,
141  kUseLandData = 1 << 0,
142  kUseLODData = 1 << 1,
143  kUseMapData = 1 << 2,
144  kUseWaterData = 1 << 3,
145  kUseClimateData = 1 << 4,
146  kUseImageSpaceData = 1 << 5, // unused
147  kUseSkyCell = 1 << 6,
148  };
149 
150  struct RecordFlags
151  {
152  enum RecordFlag : std::uint32_t
153  {
154  kDeleted = 1 << 5,
155  kIgnored = 1 << 12,
156  kCantWait = 1 << 19
157  };
158  };
159 
160  struct ShortPoint
161  {
162  public:
163  // members
164  std::int16_t x;
165  std::int16_t y;
166  };
167  static_assert(sizeof(ShortPoint) == 0x4);
168 
169  ~TESWorldSpace() override; // 00
170 
171  // override (TESForm)
172  void InitializeData() override; // 04
173  void ClearData() override; // 05
174  bool Load(TESFile* a_mod) override; // 06
175  bool LoadPartial(TESFile* a_mod) override; // 07
176  TESForm* CreateDuplicateForm(bool a_createEditorID, void* a_arg2) override; // 09
177  bool FindInFileFast(TESFile* a_mod) override; // 0C
178  void InitItemImpl() override; // 13
179  const char* GetFormEditorID() const override; // 32 - { return editorID.c_str(); }
180  bool SetFormEditorID(const char* a_str) override; // 33 - { editorID = a_str; }
181  bool IsParentForm() override; // 34 - { return true; }
182  bool IsFormTypeChild(FormType a_type) override; // 36
183 
184  [[nodiscard]] bool HasMaxHeightData() const;
185  [[nodiscard]] TESObjectCELL* GetSkyCell();
186  [[nodiscard]] float GetDefaultWaterHeight() const;
187 
188  // members
192  TESClimate* climate; // 098 - CNAM
194  std::uint8_t unk0A1; // 0A1 - more flags
196  ShortPoint fixedCenter; // 0A4 - WCTR
203  void* unk138; // 138
204  void* unk140; // 140
205  NiPointer<NiNode> multiBoundNode; // 148 - smart ptr
207  TESWorldSpace* parentWorld; // 158 - WNAM
209  TESWaterForm* worldWater; // 168 - NAM2
210  TESWaterForm* lodWater; // 170 - NAM3
211  float lodWaterHeight; // 178 - NAM4
212  std::uint32_t pad17C; // 17C
213  std::uint64_t unk180; // 180
216  std::uint32_t pad1B4; // 1B4
217  BGSMusicType* musicType; // 1B8 - ZNAM
220  BSTHashMap<UnkKey, UnkValue> unk1D0; // 1D0 - BSTHashMap<TESFile*, OFFSET_DATA*> offsetDataMap?
221  BSString editorID; // 200 - EDID
222  float defaultLandHeight; // 210 - DNAM~
223  float defaultWaterHeight; // 214 - ~DNAM
224  float distantLODMult; // 218 - NAMA
225  std::uint32_t pad21C; // 21C
227  BGSLocation* location; // 228 - XLCN
229  TESTexture waterEnvMap; // 240 - UNAM
231  std::uint64_t unk2E0; // 2E0
234  float northRotation; // 348
235  std::uint32_t pad34C; // 34C
236  std::int8_t* maxHeightData; // 350 - MHDT
237  private:
238  KEEP_FOR_RE()
239  };
240  static_assert(sizeof(TESWorldSpace) == 0x358);
241 }
#define KEEP_FOR_RE()
Definition: PCH.h:713
Definition: BGSEncounterZone.h:43
Definition: TESWorldSpace.h:101
BSTHashMap< FormID, CellID > formIDCellMap
Definition: TESWorldSpace.h:106
BSTHashMap< CellID, FormID * > cellFormIDMap
Definition: TESWorldSpace.h:105
BSTHashMap< CellID, FormID * > cellFormIDMapFiltered
Definition: TESWorldSpace.h:110
Definition: BGSLightingTemplate.h:11
Definition: BGSLocation.h:68
Definition: BGSMusicType.h:13
Definition: BGSTerrainManager.h:6
Definition: BSTArray.h:378
Definition: BSTHashMap.h:21
Definition: NiPoint2.h:6
Definition: NiSmartPointer.h:9
Definition: NiTPointerMap.h:10
Definition: TESClimate.h:13
Definition: TESFile.h:17
Definition: TESForm.h:40
Definition: TESFullName.h:9
Definition: TESModel.h:16
Definition: TESObjectCELL.h:119
Definition: TESTexture.h:10
Definition: TESWaterForm.h:83
Definition: TESWorldSpace.h:120
std::uint8_t unk0A1
Definition: TESWorldSpace.h:194
bool FindInFileFast(TESFile *a_mod) override
void * unk138
Definition: TESWorldSpace.h:203
TESObjectCELL * persistentCell
Definition: TESWorldSpace.h:190
BGSLargeRefData largeRefData
Definition: TESWorldSpace.h:230
BSTHashMap< UnkKey, UnkValue > unk1D0
Definition: TESWorldSpace.h:220
ShortPoint fixedCenter
Definition: TESWorldSpace.h:196
std::uint32_t pad21C
Definition: TESWorldSpace.h:225
TESForm * CreateDuplicateForm(bool a_createEditorID, void *a_arg2) override
TESTexture canopyShadowTexture
Definition: TESWorldSpace.h:228
NiTPointerMap< std::uint32_t, BSSimpleList< TESObjectREFR * > * > * overlappedMultiboundMap
Definition: TESWorldSpace.h:199
TESTexture waterEnvMap
Definition: TESWorldSpace.h:229
TESWorldSpace * parentWorld
Definition: TESWorldSpace.h:207
void * unk140
Definition: TESWorldSpace.h:204
BGSLightingTemplate * lightingTemplate
Definition: TESWorldSpace.h:208
WORLD_MAP_OFFSET_DATA worldMapOffsetData
Definition: TESWorldSpace.h:215
NiPoint2 maximumCoords
Definition: TESWorldSpace.h:219
BSTHashMap< CellID, TESObjectCELL * > cellMap
Definition: TESWorldSpace.h:189
static constexpr auto FORMTYPE
Definition: TESWorldSpace.h:124
BSTHashMap< FormID, BGSLocation * > locationMap
Definition: TESWorldSpace.h:201
std::uint32_t pad1B4
Definition: TESWorldSpace.h:216
float defaultWaterHeight
Definition: TESWorldSpace.h:223
NiPointer< NiNode > portalSharedNode
Definition: TESWorldSpace.h:206
TESWaterForm * worldWater
Definition: TESWorldSpace.h:209
TESObjectCELL * skyCell
Definition: TESWorldSpace.h:200
Flag
Definition: TESWorldSpace.h:127
static constexpr auto VTABLE
Definition: TESWorldSpace.h:123
BGSMusicType * musicType
Definition: TESWorldSpace.h:217
NiPoint2 minimumCoords
Definition: TESWorldSpace.h:218
BSTHashMap< UnkKey, UnkValue > unk318
Definition: TESWorldSpace.h:233
BSString editorID
Definition: TESWorldSpace.h:221
ParentUseFlag
Definition: TESWorldSpace.h:139
bool HasMaxHeightData() const
BGSTerrainManager * terrainManager
Definition: TESWorldSpace.h:191
WORLD_MAP_DATA worldMapData
Definition: TESWorldSpace.h:214
bool IsFormTypeChild(FormType a_type) override
BSTArray< NiPointer< TESObjectREFR > > mobilePersistentRefs
Definition: TESWorldSpace.h:198
bool SetFormEditorID(const char *a_str) override
stl::enumeration< Flag, std::uint8_t > flags
Definition: TESWorldSpace.h:193
bool IsParentForm() override
float defaultLandHeight
Definition: TESWorldSpace.h:222
std::uint64_t unk180
Definition: TESWorldSpace.h:213
float distantLODMult
Definition: TESWorldSpace.h:224
BSTHashMap< UnkKey, UnkValue > unk2E8
Definition: TESWorldSpace.h:232
std::int8_t * maxHeightData
Definition: TESWorldSpace.h:236
float lodWaterHeight
Definition: TESWorldSpace.h:211
const char * GetFormEditorID() const override
NiPointer< BSPortalGraph > portalGraph
Definition: TESWorldSpace.h:202
bool LoadPartial(TESFile *a_mod) override
BGSEncounterZone * encounterZone
Definition: TESWorldSpace.h:226
~TESWorldSpace() override
BSTHashMap< std::uint32_t, BSTArray< NiPointer< TESObjectREFR > > > fixedPersistentRefMap
Definition: TESWorldSpace.h:197
TESWaterForm * lodWater
Definition: TESWorldSpace.h:210
BGSLocation * location
Definition: TESWorldSpace.h:227
float northRotation
Definition: TESWorldSpace.h:234
stl::enumeration< ParentUseFlag, std::uint16_t > parentUseFlags
Definition: TESWorldSpace.h:195
std::uint32_t pad17C
Definition: TESWorldSpace.h:212
float GetDefaultWaterHeight() const
static constexpr auto RTTI
Definition: TESWorldSpace.h:122
NiPointer< NiNode > multiBoundNode
Definition: TESWorldSpace.h:205
std::uint32_t pad34C
Definition: TESWorldSpace.h:235
void ClearData() override
bool Load(TESFile *a_mod) override
void InitializeData() override
TESObjectCELL * GetSkyCell()
void InitItemImpl() override
std::uint64_t unk2E0
Definition: TESWorldSpace.h:231
TESClimate * climate
Definition: TESWorldSpace.h:192
Definition: AbsorbEffect.h:6
FormType
Definition: FormTypes.h:139
constexpr REL::ID RTTI_TESWorldSpace(static_cast< std::uint64_t >(513891))
constexpr std::array< REL::ID, 3 > VTABLE_TESWorldSpace
Definition: Offsets_VTABLE.h:12922
std::uint32_t operator()(CellID a_key) const noexcept
Definition: TESWorldSpace.h:94
Definition: CRC.h:72
Definition: TESWorldSpace.h:56
constexpr friend bool operator==(const CellID &a_lhs, const CellID &a_rhs) noexcept
Definition: TESWorldSpace.h:67
std::int16_t x
Definition: TESWorldSpace.h:86
constexpr const std::int16_t & operator[](std::size_t a_idx) const noexcept
Definition: TESWorldSpace.h:78
constexpr CellID() noexcept
Definition: TESWorldSpace.h:58
constexpr std::int16_t & operator[](std::size_t a_idx) noexcept
Definition: TESWorldSpace.h:72
std::int16_t y
Definition: TESWorldSpace.h:85
constexpr CellID(std::int16_t a_y, std::int16_t a_x) noexcept
Definition: TESWorldSpace.h:62
Definition: TESWorldSpace.h:151
RecordFlag
Definition: TESWorldSpace.h:153
@ kDeleted
Definition: TESWorldSpace.h:154
@ kIgnored
Definition: TESWorldSpace.h:155
@ kCantWait
Definition: TESWorldSpace.h:156
Definition: TESWorldSpace.h:161
std::int16_t x
Definition: TESWorldSpace.h:164
std::int16_t y
Definition: TESWorldSpace.h:165
Definition: TESWorldSpace.h:26
float minHeight
Definition: TESWorldSpace.h:27
float maxHeight
Definition: TESWorldSpace.h:28
float initialPitch
Definition: TESWorldSpace.h:29
Definition: TESWorldSpace.h:23
std::int16_t nwCellX
Definition: TESWorldSpace.h:36
std::uint32_t usableWidth
Definition: TESWorldSpace.h:31
std::int16_t seCellX
Definition: TESWorldSpace.h:38
CameraData cameraData
Definition: TESWorldSpace.h:40
std::uint32_t usableHeight
Definition: TESWorldSpace.h:35
std::int16_t seCellY
Definition: TESWorldSpace.h:39
std::int16_t nwCellY
Definition: TESWorldSpace.h:37
Definition: TESWorldSpace.h:45
float mapOffsetZ
Definition: TESWorldSpace.h:51
float mapOffsetX
Definition: TESWorldSpace.h:49
float mapOffsetY
Definition: TESWorldSpace.h:50
float mapScale
Definition: TESWorldSpace.h:48