From 052fb416c61f9310806d0eb9351168311db68e66 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Mon, 25 Sep 2023 14:47:37 +0300 Subject: [PATCH] Read BSSegmentedTriShape --- components/nif/niffile.cpp | 1 + components/nif/node.cpp | 14 ++++++++++++++ components/nif/node.hpp | 14 ++++++++++++++ components/nif/record.hpp | 1 + 4 files changed, 30 insertions(+) diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index 57bd45ca4d..d5faebb55f 100644 --- a/components/nif/niffile.cpp +++ b/components/nif/niffile.cpp @@ -272,6 +272,7 @@ namespace Nif { "BSDynamicTriShape", &construct }, { "BSLODTriShape", &construct }, { "BSMeshLODTriShape", &construct }, + { "BSSegmentedTriShape", &construct }, // PARTICLES diff --git a/components/nif/node.cpp b/components/nif/node.cpp index 9a40acc99a..860e75671f 100644 --- a/components/nif/node.cpp +++ b/components/nif/node.cpp @@ -196,6 +196,7 @@ namespace Nif { case RC_NiTriShape: case RC_BSLODTriShape: + case RC_BSSegmentedTriShape: if (mData->recType != RC_NiTriShapeData) mData = NiGeometryDataPtr(nullptr); break; @@ -217,6 +218,19 @@ namespace Nif } } + void BSSegmentedTriShape::read(NIFStream* nif) + { + NiTriShape::read(nif); + + mSegments.resize(nif->get()); + for (SegmentData& segment : mSegments) + { + nif->read(segment.mFlags); + nif->read(segment.mStartIndex); + nif->read(segment.mNumTriangles); + } + } + void BSLODTriShape::read(NIFStream* nif) { NiTriBasedGeom::read(nif); diff --git a/components/nif/node.hpp b/components/nif/node.hpp index d2857752c3..f560932e22 100644 --- a/components/nif/node.hpp +++ b/components/nif/node.hpp @@ -161,6 +161,20 @@ namespace Nif { }; + struct BSSegmentedTriShape : NiTriShape + { + struct SegmentData + { + uint8_t mFlags; + uint32_t mStartIndex; + uint32_t mNumTriangles; + }; + + std::vector mSegments; + + void read(NIFStream* nif); + }; + struct NiTriStrips : NiTriBasedGeom { }; diff --git a/components/nif/record.hpp b/components/nif/record.hpp index 6c7f802f8c..00eec64b24 100644 --- a/components/nif/record.hpp +++ b/components/nif/record.hpp @@ -120,6 +120,7 @@ namespace Nif RC_BSStripPSysData, RC_BSRefractionFirePeriodController, RC_BSRefractionStrengthController, + RC_BSSegmentedTriShape, RC_BSShaderNoLightingProperty, RC_BSShaderPPLightingProperty, RC_BSShaderProperty,