Skip to content

Commit 9ed7566

Browse files
committed
Refactored attribute serialization/deserialization
1 parent 7040e58 commit 9ed7566

File tree

5 files changed

+504
-154
lines changed

5 files changed

+504
-154
lines changed

src/PrecompiledHeader.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
#include <sstream>
2020
#include <string>
2121
#include <thread>
22+
#include <tuple>
2223
#include <unordered_set>
2324
#include <utility>
2425
#include <vector>
25-
#include <tuple>
2626

2727
#if __cplusplus >= 202002L
2828
#include <bit>
@@ -61,6 +61,7 @@
6161
#include <UT/UT_Exit.h>
6262
#include <UT/UT_IOTable.h>
6363
#include <UT/UT_Interrupt.h>
64+
#include <UT/UT_JSONValueMap.h>
6465
#include <UT/UT_OFStream.h>
6566
#include <UT/UT_StringHolder.h>
6667

src/ROP/ROP_ZibraVDBCompressor.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -857,16 +857,16 @@ namespace Zibra::ZibraVDBCompressor
857857
{
858858
auto vdbPrim = dynamic_cast<const GEO_PrimVDB*>(prim);
859859

860-
nlohmann::json primAttrDump = Utils::DumpAttributesForSingleEntity(gdp, GA_ATTRIB_PRIMITIVE, prim->getMapOffset());
861-
std::string primKeyName = "houdiniPrimitiveAttributes_"s + vdbPrim->getGridName();
860+
nlohmann::json primAttrDump = Utils::DumpAttributesV2(gdp, GA_ATTRIB_PRIMITIVE, prim->getMapOffset());
861+
std::string primKeyName = "houdiniPrimitiveAttributesV2_"s + vdbPrim->getGridName();
862862
result.emplace_back(primKeyName, primAttrDump.dump());
863863

864864
DumpVisualisationAttributes(result, vdbPrim);
865865
}
866866
}
867867

868-
nlohmann::json detailAttrDump = Utils::DumpAttributesForSingleEntity(gdp, GA_ATTRIB_DETAIL, 0);
869-
result.emplace_back("houdiniDetailAttributes", detailAttrDump.dump());
868+
nlohmann::json detailAttrDump = Utils::DumpAttributesV2(gdp, GA_ATTRIB_DETAIL, 0);
869+
result.emplace_back("houdiniDetailAttributesV2", detailAttrDump.dump());
870870
return result;
871871
}
872872

src/SOP/SOP_ZibraVDBDecompressor.cpp

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -193,23 +193,29 @@ namespace Zibra::ZibraVDBDecompressor
193193

194194
void SOP_ZibraVDBDecompressor::ApplyGridAttributeMetadata(GU_PrimVDB* vdbPrim, FrameHandle* const frameContainer)
195195
{
196-
const std::string attributeMetadataName = "houdiniPrimitiveAttributes_"s + vdbPrim->getGridName();
196+
{
197+
const std::string attributeMetadataNameV2 = "houdiniPrimitiveAttributesV2_"s + vdbPrim->getGridName();
198+
199+
const char* metadataEntryV2 = frameContainer->GetMetadataByKey(attributeMetadataNameV2.c_str());
197200

198-
const char* metadataEntry = frameContainer->GetMetadataByKey(attributeMetadataName.c_str());
201+
if (metadataEntryV2)
202+
{
203+
auto primAttribMeta = nlohmann::json::parse(metadataEntryV2);
204+
Utils::LoadAttributesV2(gdp, GA_ATTRIB_PRIMITIVE, vdbPrim->getMapOffset(), primAttribMeta);
205+
return;
206+
}
207+
}
199208

200-
if (metadataEntry)
201209
{
202-
auto primAttribMeta = nlohmann::json::parse(metadataEntry);
203-
switch (Utils::LoadEntityAttributesFromMeta(gdp, GA_ATTRIB_PRIMITIVE, vdbPrim->getMapOffset(), primAttribMeta))
210+
const std::string attributeMetadataNameV1 = "houdiniPrimitiveAttributes_"s + vdbPrim->getGridName();
211+
212+
const char* metadataEntryV1 = frameContainer->GetMetadataByKey(attributeMetadataNameV1.c_str());
213+
214+
if (metadataEntryV1)
204215
{
205-
case Utils::MetaAttributesLoadStatus::SUCCESS:
206-
break;
207-
case Utils::MetaAttributesLoadStatus::FATAL_ERROR_INVALID_METADATA:
208-
addWarning(SOP_MESSAGE, "Corrupted metadata for channel. Canceling attributes transfer.");
209-
break;
210-
case Utils::MetaAttributesLoadStatus::ERROR_PARTIALLY_INVALID_METADATA:
211-
addWarning(SOP_MESSAGE, "Partially corrupted metadata for channel. Skipping invalid attributes.");
212-
break;
216+
auto primAttribMeta = nlohmann::json::parse(metadataEntryV1);
217+
Utils::LoadAttributesV1(gdp, GA_ATTRIB_PRIMITIVE, vdbPrim->getMapOffset(), primAttribMeta);
218+
return;
213219
}
214220
}
215221
}
@@ -243,24 +249,26 @@ namespace Zibra::ZibraVDBDecompressor
243249

244250
void SOP_ZibraVDBDecompressor::ApplyDetailMetadata(GU_Detail* gdp, FrameHandle* const frameContainer)
245251
{
246-
const char* detailMetadata = frameContainer->GetMetadataByKey("houdiniDetailAttributes");
247-
248-
if (!detailMetadata)
249252
{
250-
return;
253+
const char* detailMetadataV2 = frameContainer->GetMetadataByKey("houdiniDetailAttributesV2");
254+
255+
if (detailMetadataV2)
256+
{
257+
auto detailAttribMeta = nlohmann::json::parse(detailMetadataV2);
258+
Utils::LoadAttributesV2(gdp, GA_ATTRIB_DETAIL, 0, detailAttribMeta);
259+
return;
260+
}
251261
}
252262

253-
auto detailAttribMeta = nlohmann::json::parse(detailMetadata);
254-
switch (Utils::LoadEntityAttributesFromMeta(gdp, GA_ATTRIB_DETAIL, 0, detailAttribMeta))
255263
{
256-
case Utils::MetaAttributesLoadStatus::SUCCESS:
257-
break;
258-
case Utils::MetaAttributesLoadStatus::FATAL_ERROR_INVALID_METADATA:
259-
addWarning(SOP_MESSAGE, "Corrupted metadata for channel. Canceling attributes transfer.");
260-
break;
261-
case Utils::MetaAttributesLoadStatus::ERROR_PARTIALLY_INVALID_METADATA:
262-
addWarning(SOP_MESSAGE, "Partially corrupted metadata for channel. Skipping invalid attributes.");
263-
break;
264+
const char* detailMetadataV1 = frameContainer->GetMetadataByKey("houdiniDetailAttributes");
265+
266+
if (detailMetadataV1)
267+
{
268+
auto detailAttribMeta = nlohmann::json::parse(detailMetadataV1);
269+
Utils::LoadAttributesV1(gdp, GA_ATTRIB_DETAIL, 0, detailAttribMeta);
270+
return;
271+
}
264272
}
265273
}
266274

0 commit comments

Comments
 (0)