Skip to content

Commit

Permalink
Add missing FO76 blocks #47
Browse files Browse the repository at this point in the history
- NiPSysRotDampeningCtlr
- BSDistantObjectExtraData
- BSCollisionQueryProxyExtraData
- BSDistantObjectInstancedNode
  • Loading branch information
ousnius committed Sep 18, 2024
1 parent 4ae1d4a commit 9dfe61e
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 18 deletions.
7 changes: 7 additions & 0 deletions include/Animation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,13 @@ class NiPSysEmitterPlanarAngleVarCtlr
const char* GetBlockName() override { return BlockName; }
};

class NiPSysRotDampeningCtlr
: public NiCloneable<NiPSysRotDampeningCtlr, NiPSysModifierFloatCtlr> {
public:
static constexpr const char* BlockName = "NiPSysRotDampeningCtlr";
const char* GetBlockName() override { return BlockName; }
};

class NiStringPalette : public NiCloneableStreamable<NiStringPalette, NiObject> {
public:
NiString palette;
Expand Down
17 changes: 12 additions & 5 deletions include/BasicTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,11 +523,6 @@ class NiStringRef {
bool operator!=(const std::string& rhs) const { return !operator==(rhs); }
};

struct NiPlane {
Vector3 normal;
float constant = 0.0f;
};

class NiRef {
public:
uint32_t index = NIF_NPOS;
Expand Down Expand Up @@ -1181,6 +1176,18 @@ class NiHeader : public NiHeaderBase, public NiCloneable<NiHeader, NiObject> {
void Put(NiOStream& stream) override;
};

struct NiPlane {
Vector3 normal;
float constant = 0.0f;
};

class BSTextureArray {
public:
NiStringVector<> textureArray;

void Sync(NiStreamReversible& stream) { textureArray.Sync(stream); }
};

// Used for all unknown block types
class NiUnknown : public NiCloneableStreamable<NiUnknown, NiObject> {
public:
Expand Down
21 changes: 21 additions & 0 deletions include/ExtraData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,17 @@ class BSDistantObjectLargeRefExtraData
void Sync(NiStreamReversible& stream);
};

class BSDistantObjectExtraData
: public NiCloneableStreamable<BSDistantObjectExtraData, NiExtraData> {
public:
uint32_t distantObjectFlags = 0;

static constexpr const char* BlockName = "BSDistantObjectExtraData";
const char* GetBlockName() override { return BlockName; }

void Sync(NiStreamReversible& stream);
};

class BSConnectPoint {
public:
NiString root;
Expand Down Expand Up @@ -427,6 +438,16 @@ class BSClothExtraData : public NiCloneableStreamable<BSClothExtraData, BSExtraD
bool FromHKX(const std::string& fileName);
};

class BSCollisionQueryProxyExtraData : public NiCloneableStreamable<BSCollisionQueryProxyExtraData, BSExtraData> {
public:
NiVector<char> data;

static constexpr const char* BlockName = "BSCollisionQueryProxyExtraData";
const char* GetBlockName() override { return BlockName; }

void Sync(NiStreamReversible& stream);
};

class SkinAttach : public NiCloneableStreamable<SkinAttach, NiExtraData> {
public:
NiStringVector<> bones;
Expand Down
52 changes: 46 additions & 6 deletions include/Nodes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,52 @@ class BSMultiBoundNode : public NiCloneableStreamable<BSMultiBoundNode, NiNode>
void GetChildIndices(std::vector<uint32_t>& indices) override;
};

struct BSResourceID {
uint32_t fileHash = 0;
char extension[4];
uint32_t dirHash = 0;
};

#pragma pack(push, 1)
struct BSDistantObjectUnknown {
uint64_t unknown1 = 0;
uint32_t unknown2 = 0;
};
#pragma pack(pop)

struct BSDistantObjectInstance {
BSResourceID resourceID;
NiVector<BSDistantObjectUnknown> unknownData;
NiVector<Matrix4> transforms;

void Sync(NiStreamReversible& stream) {
stream.Sync(resourceID);
unknownData.Sync(stream);
transforms.Sync(stream);
}
};

struct BSShaderTextureArray {
uint8_t unknownByte = 1;
NiSyncVector<BSTextureArray> textureArrays;

void Sync(NiStreamReversible& stream) {
stream.Sync(unknownByte);
textureArrays.Sync(stream);
}
};

class BSDistantObjectInstancedNode : public NiCloneableStreamable<BSDistantObjectInstancedNode, BSMultiBoundNode> {
public:
NiSyncVector<BSDistantObjectInstance> instances;
BSShaderTextureArray textureArrays[3]{};

static constexpr const char* BlockName = "BSDistantObjectInstancedNode";
const char* GetBlockName() override { return BlockName; }

void Sync(NiStreamReversible& stream);
};

class BSRangeNode : public NiCloneableStreamable<BSRangeNode, NiNode> {
public:
uint8_t min = 0;
Expand Down Expand Up @@ -179,12 +225,6 @@ class BSDamageStage : public NiCloneable<BSDamageStage, BSBlastNode> {
const char* GetBlockName() override { return BlockName; }
};

struct BSResourceID {
uint32_t fileHash = 0;
char extension[4];
uint32_t dirHash = 0;
};

struct UnkMaterialStruct {
uint32_t biomeFormID = 0;
uint32_t dirHash = 0;
Expand Down
7 changes: 0 additions & 7 deletions include/Shaders.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,13 +556,6 @@ class VolumetricFogShaderProperty : public NiCloneable<VolumetricFogShaderProper
const char* GetBlockName() override { return BlockName; }
};

class BSTextureArray {
public:
NiStringVector<> textureArray;

void Sync(NiStreamReversible& stream) { textureArray.Sync(stream); }
};

class BSLightingShaderProperty : public NiCloneableStreamable<BSLightingShaderProperty, BSShaderProperty> {
public:
NiBlockRef<BSShaderTextureSet> textureSetRef;
Expand Down
10 changes: 10 additions & 0 deletions src/ExtraData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,11 @@ void BSDistantObjectLargeRefExtraData::Sync(NiStreamReversible& stream) {
}


void BSDistantObjectExtraData::Sync(NiStreamReversible& stream) {
stream.Sync(distantObjectFlags);
}


void BSConnectPoint::Sync(NiStreamReversible& stream) {
root.Sync(stream, 4);
variableName.Sync(stream, 4);
Expand Down Expand Up @@ -423,6 +428,11 @@ bool BSClothExtraData::FromHKX(const std::string& fileName) {
}


void BSCollisionQueryProxyExtraData::Sync(NiStreamReversible& stream) {
data.SyncByteArray(stream);
}


void SkinAttach::Sync(NiStreamReversible& stream) {
bones.Sync(stream);
}
Expand Down
4 changes: 4 additions & 0 deletions src/Factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ NiFactoryRegister::NiFactoryRegister() {
RegisterFactory<BSTreeNode>();
RegisterFactory<BSOrderedNode>();
RegisterFactory<BSMultiBoundNode>();
RegisterFactory<BSDistantObjectInstancedNode>();
RegisterFactory<BSDebrisNode>();
RegisterFactory<BSBlastNode>();
RegisterFactory<BSDamageStage>();
Expand Down Expand Up @@ -212,6 +213,7 @@ NiFactoryRegister::NiFactoryRegister() {
RegisterFactory<NiPSysInitialRotAngleVarCtlr>();
RegisterFactory<NiPSysEmitterPlanarAngleCtlr>();
RegisterFactory<NiPSysEmitterPlanarAngleVarCtlr>();
RegisterFactory<NiPSysRotDampeningCtlr>();
RegisterFactory<NiPSysEmitterCtlr>();
RegisterFactory<BSPSysMultiTargetEmitterCtlr>();
RegisterFactory<NiControllerManager>();
Expand Down Expand Up @@ -271,7 +273,9 @@ NiFactoryRegister::NiFactoryRegister() {
RegisterFactory<BSBoneLODExtraData>();
RegisterFactory<NiTextKeyExtraData>();
RegisterFactory<BSDistantObjectLargeRefExtraData>();
RegisterFactory<BSDistantObjectExtraData>();
RegisterFactory<BSClothExtraData>();
RegisterFactory<BSCollisionQueryProxyExtraData>();
RegisterFactory<BSConnectPointParents>();
RegisterFactory<BSConnectPointChildren>();
RegisterFactory<BSMultiBound>();
Expand Down
8 changes: 8 additions & 0 deletions src/Nodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ void BSMultiBoundNode::GetChildIndices(std::vector<uint32_t>& indices) {
}


void BSDistantObjectInstancedNode::Sync(NiStreamReversible& stream) {
instances.Sync(stream);

for (int i = 0; i < 3; i++)
textureArrays[i].Sync(stream);
}


void BSRangeNode::Sync(NiStreamReversible& stream) {
stream.Sync(min);
stream.Sync(max);
Expand Down

0 comments on commit 9dfe61e

Please sign in to comment.