diff options
| author | Bryan Galdrikian <[email protected]> | 2017-02-24 09:32:20 -0800 |
|---|---|---|
| committer | Bryan Galdrikian <[email protected]> | 2017-02-24 09:32:20 -0800 |
| commit | e1bf674c16e3c8472b29574159c789cd3f0c64e0 (patch) | |
| tree | 9f0cfce09c71a2c27ff19589fcad6cd83504477c /sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.cpp | |
| parent | first commit (diff) | |
| download | blast-e1bf674c16e3c8472b29574159c789cd3f0c64e0.tar.xz blast-e1bf674c16e3c8472b29574159c789cd3f0c64e0.zip | |
Updating to [email protected] and [email protected] with a new directory structure.
NvBlast folder is gone, files have been moved to top level directory. README is changed to reflect this.
Diffstat (limited to 'sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.cpp')
| -rw-r--r-- | sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.cpp | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.cpp b/sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.cpp new file mode 100644 index 0000000..cf4cadc --- /dev/null +++ b/sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.cpp @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. +* +* NVIDIA CORPORATION and its licensors retain all intellectual property +* and proprietary rights in and to this software, related documentation +* and any modifications thereto. Any use, reproduction, disclosure or +* distribution of this software and related documentation without an express +* license agreement from NVIDIA CORPORATION is strictly prohibited. +*/ + +#include "ExtPxAssetDTO.h" +#include "TkAssetDTO.h" +#include "ExtPxChunkDTO.h" +#include "ExtPxSubchunkDTO.h" +#include "physics/NvBlastExtPxAssetImpl.h" +#include "NvBlastAssert.h" + +namespace Nv +{ + namespace Blast + { + bool ExtPxAssetDTO::serialize(Nv::Blast::Serialization::ExtPxAsset::Builder builder, const Nv::Blast::ExtPxAsset * poco) + { + TkAssetDTO::serialize(builder.getAsset(), &poco->getTkAsset()); + + auto chunks = builder.initChunks(poco->getChunkCount()); + + for (uint32_t i = 0; i <poco->getChunkCount(); i++) + { + ExtPxChunkDTO::serialize(chunks[i], &poco->getChunks()[i]); + } + + auto subchunks = builder.initSubchunks(poco->getSubchunkCount()); + + for (uint32_t i = 0; i < poco->getSubchunkCount(); i++) + { + ExtPxSubchunkDTO::serialize(subchunks[i], &poco->getSubchunks()[i]); + } + + return true; + } + + Nv::Blast::ExtPxAsset* ExtPxAssetDTO::deserialize(Nv::Blast::Serialization::ExtPxAsset::Reader reader) + { + auto tkAsset = TkAssetDTO::deserialize(reader.getAsset()); + + Nv::Blast::ExtPxAssetImpl* asset = reinterpret_cast<Nv::Blast::ExtPxAssetImpl*>(Nv::Blast::ExtPxAsset::create(tkAsset)); + + NVBLAST_ASSERT(asset != nullptr); + + auto chunks = asset->getChunksArray(); + + chunks.resize(reader.getChunks().size()); + for (uint32_t i = 0; i < reader.getChunks().size(); i++) + { + ExtPxChunkDTO::deserializeInto(reader.getChunks()[i], &chunks[i]); + } + + auto subchunks = asset->getSubchunksArray(); + + subchunks.resize(reader.getSubchunks().size()); + for (uint32_t i = 0; i < reader.getSubchunks().size(); i++) + { + ExtPxSubchunkDTO::deserializeInto(reader.getSubchunks()[i], &subchunks[i]); + } + + return asset; + } + + bool ExtPxAssetDTO::deserializeInto(Nv::Blast::Serialization::ExtPxAsset::Reader reader, Nv::Blast::ExtPxAsset * poco) + { + reader = reader; + poco = nullptr; + //NOTE: Because of the way this is structured, can't do this. + return false; + } + } +} |