aboutsummaryrefslogtreecommitdiff
path: root/NvBlast/sdk/extensions/serialization/source/DTO
diff options
context:
space:
mode:
authorBryan Galdrikian <[email protected]>2017-02-21 12:07:59 -0800
committerBryan Galdrikian <[email protected]>2017-02-21 12:07:59 -0800
commit446ce137c6823ba9eff273bdafdaf266287c7c98 (patch)
treed20aab3e2ed08d7b3ca71c2f40db6a93ea00c459 /NvBlast/sdk/extensions/serialization/source/DTO
downloadblast-1.0.0-beta.tar.xz
blast-1.0.0-beta.zip
first commitv1.0.0-beta
Diffstat (limited to 'NvBlast/sdk/extensions/serialization/source/DTO')
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/AssetDTO.cpp187
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/AssetDTO.h16
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/DTOMacros.h44
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.cpp78
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.h16
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/ExtPxChunkDTO.cpp43
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/ExtPxChunkDTO.h16
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/ExtPxSubchunkDTO.cpp43
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/ExtPxSubchunkDTO.h16
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/NvBlastBondDTO.cpp63
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/NvBlastBondDTO.h16
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/NvBlastChunkDTO.cpp60
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/NvBlastChunkDTO.h18
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/NvBlastIDDTO.cpp48
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/NvBlastIDDTO.h16
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/PxConvexMeshGeometryDTO.cpp127
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/PxConvexMeshGeometryDTO.h17
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/PxMeshScaleDTO.cpp42
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/PxMeshScaleDTO.h17
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/PxQuatDTO.cpp45
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/PxQuatDTO.h17
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/PxTransformDTO.cpp42
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/PxTransformDTO.h17
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/PxVec3DTO.cpp45
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/PxVec3DTO.h17
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/TkAssetDTO.cpp67
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/TkAssetDTO.h17
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/TkAssetJointDescDTO.cpp53
-rw-r--r--NvBlast/sdk/extensions/serialization/source/DTO/TkAssetJointDescDTO.h17
29 files changed, 1220 insertions, 0 deletions
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/AssetDTO.cpp b/NvBlast/sdk/extensions/serialization/source/DTO/AssetDTO.cpp
new file mode 100644
index 0000000..8d035fc
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/AssetDTO.cpp
@@ -0,0 +1,187 @@
+/*
+* 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 "AssetDTO.h"
+#include "NvBlastIDDTO.h"
+#include "NvBlastChunkDTO.h"
+#include "NvBlastBondDTO.h"
+#include "NvBlastAsset.h"
+#include "NvBlastExtSerializationLLImpl.h"
+#include "NvBlastExtGlobals.h"
+
+#if !defined(BLAST_LL_ALLOC)
+#include "NvBlastExtAllocator.h"
+#endif
+
+namespace Nv
+{
+ namespace Blast
+ {
+ bool AssetDTO::serialize(Nv::Blast::Serialization::Asset::Builder builder, const Nv::Blast::Asset * poco)
+ {
+ NvBlastIDDTO::serialize(builder.initID(), &poco->m_ID);
+
+ builder.setLeafChunkCount(poco->m_leafChunkCount);
+
+ builder.setFirstSubsupportChunkIndex(poco->m_firstSubsupportChunkIndex);
+
+ capnp::List<Nv::Blast::Serialization::NvBlastChunk>::Builder chunks = builder.initChunks(poco->m_chunkCount);
+
+ builder.setChunkCount(poco->m_chunkCount);
+
+ NVBLAST_ASSERT_WITH_MESSAGE(builder.getChunkCount() == poco->m_chunkCount, "WTF");
+
+ for (uint32_t i = 0; i < poco->m_chunkCount; i++)
+ {
+ NvBlastChunk& chunk = poco->getChunks()[i];
+
+ NvBlastChunkDTO::serialize(chunks[i], &chunk);
+ }
+
+ NVBLAST_ASSERT_WITH_MESSAGE(builder.getChunkCount() == poco->m_chunkCount, "WTF");
+
+ capnp::List<Nv::Blast::Serialization::NvBlastBond>::Builder bonds = builder.initBonds(poco->m_bondCount);
+
+ builder.setBondCount(poco->m_bondCount);
+
+ for (uint32_t i = 0; i < poco->m_bondCount; i++)
+ {
+ NvBlastBond& bond = poco->getBonds()[i];
+
+ NvBlastBondDTO::serialize(bonds[i], &bond);
+ }
+
+ kj::ArrayPtr<uint32_t> stlcArray(poco->getSubtreeLeafChunkCounts(), poco->m_chunkCount);
+ builder.initSubtreeLeafChunkCounts(poco->m_chunkCount);
+ builder.setSubtreeLeafChunkCounts(stlcArray);
+
+ kj::ArrayPtr<uint32_t> ctgnArray(poco->getChunkToGraphNodeMap(), poco->m_chunkCount);
+ builder.setChunkToGraphNodeMap(ctgnArray);
+
+ Nv::Blast::Serialization::NvBlastSupportGraph::Builder graphBulder = builder.initGraph();
+
+ graphBulder.setNodeCount(poco->m_graph.m_nodeCount);
+
+ uint32_t* ciPtr = poco->m_graph.getChunkIndices();
+
+ kj::ArrayPtr<const uint32_t> ciArray(ciPtr, poco->m_graph.m_nodeCount);
+ graphBulder.setChunkIndices(ciArray);
+
+ kj::ArrayPtr<const uint32_t> adjPart(poco->m_graph.getAdjacencyPartition(), poco->m_graph.m_nodeCount + 1);
+ graphBulder.setAdjacencyPartition(adjPart);
+
+ NVBLAST_ASSERT(graphBulder.getAdjacencyPartition().size() == poco->m_graph.m_nodeCount + 1);
+
+ kj::ArrayPtr<const uint32_t> nodeIndices(poco->m_graph.getAdjacentNodeIndices(), poco->m_bondCount * 2);
+ graphBulder.setAdjacentNodeIndices(nodeIndices);
+
+ NVBLAST_ASSERT(graphBulder.getAdjacentNodeIndices().size() == poco->m_bondCount * 2);
+
+ kj::ArrayPtr<const uint32_t> bondIndices(poco->m_graph.getAdjacentBondIndices(), poco->m_bondCount * 2);
+ graphBulder.setAdjacentBondIndices(bondIndices);
+
+ return true;
+ }
+
+ Nv::Blast::Asset* AssetDTO::deserialize(Nv::Blast::Serialization::Asset::Reader reader)
+ {
+ NvBlastID EmptyId = {};
+
+ NvBlastExtAlloc allocFn = gAlloc;
+ NvBlastLog logFn = gLog;
+
+#if !defined(BLAST_LL_ALLOC)
+ allocFn = ExtAllocator::alignedAlloc16;
+ logFn = NvBlastTkFrameworkGet()->getLogFn();
+#endif
+
+ void* mem = allocFn(reader.totalSize().wordCount * sizeof(uint64_t));
+
+ auto asset = Nv::Blast::initializeAsset(mem, EmptyId, reader.getChunkCount(), reader.getGraph().getNodeCount(), reader.getLeafChunkCount(), reader.getFirstSubsupportChunkIndex(), reader.getBondCount(),
+ logFn);
+
+ bool result = deserializeInto(reader, asset);
+
+ return result ? asset : nullptr;
+ }
+
+ bool AssetDTO::deserializeInto(Nv::Blast::Serialization::Asset::Reader reader, Nv::Blast::Asset * poco)
+ {
+ NvBlastIDDTO::deserializeInto(reader.getID(), &poco->m_ID);
+
+ NvBlastBond* bonds = poco->getBonds();
+
+ uint32_t bondCount = reader.getBondCount();
+ for (uint32_t i = 0; i < bondCount; i++)
+ {
+ auto bondReader = reader.getBonds()[i];
+
+ NvBlastBondDTO::deserializeInto(bondReader, &bonds[i]);
+ }
+
+ NvBlastChunk* chunks = poco->getChunks();
+
+ uint32_t chunkCount = reader.getChunkCount();
+ for (uint32_t i = 0; i < chunkCount; i++)
+ {
+ auto chunkReader = reader.getChunks()[i];
+
+ NvBlastChunkDTO::deserializeInto(chunkReader, &chunks[i]);
+ }
+
+ poco->m_graph.m_nodeCount = reader.getGraph().getNodeCount();
+
+ NVBLAST_ASSERT(reader.getSubtreeLeafChunkCounts().size() == poco->m_chunkCount);
+ for (uint32_t i = 0; i < poco->m_chunkCount; i++)
+ {
+ poco->getSubtreeLeafChunkCounts()[i] = reader.getSubtreeLeafChunkCounts()[i];
+ }
+
+ for (uint32_t i = 0; i < chunkCount; i++)
+ {
+ poco->getChunkToGraphNodeMap()[i] = reader.getChunkToGraphNodeMap()[i];
+ }
+
+ uint32_t* ciPtr = poco->m_graph.getChunkIndices();
+
+ NVBLAST_ASSERT(reader.getGraph().getChunkIndices().size() == poco->m_graph.m_nodeCount);
+ for (uint32_t i = 0; i < poco->m_graph.m_nodeCount; i++)
+ {
+ ciPtr[i] = reader.getGraph().getChunkIndices()[i];
+ }
+
+ uint32_t* adjPartition = poco->m_graph.getAdjacencyPartition();
+ uint32_t idx = 0;
+
+ for (uint32_t adjPartIndex : reader.getGraph().getAdjacencyPartition())
+ {
+ adjPartition[idx++] = adjPartIndex;
+ }
+
+ uint32_t* adjNodes = poco->m_graph.getAdjacentNodeIndices();
+ idx = 0;
+
+ for (uint32_t adjNodeIndex : reader.getGraph().getAdjacentNodeIndices())
+ {
+ adjNodes[idx++] = adjNodeIndex;
+ }
+
+ uint32_t* adjBonds = poco->m_graph.getAdjacentBondIndices();
+ idx = 0;
+
+ for (uint32_t adjBondIndex : reader.getGraph().getAdjacentBondIndices())
+ {
+ adjBonds[idx++] = adjBondIndex;
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/AssetDTO.h b/NvBlast/sdk/extensions/serialization/source/DTO/AssetDTO.h
new file mode 100644
index 0000000..c090b5f
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/AssetDTO.h
@@ -0,0 +1,16 @@
+/*
+* 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.
+*/
+
+#pragma once
+#include "DTOMacros.h"
+#include "NvBlastAsset.h"
+#include "generated/NvBlastExtSerializationLL.capn.h"
+
+DTO_CLASS_LL(Asset, Nv::Blast::Asset, Nv::Blast::Serialization::Asset)
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/DTOMacros.h b/NvBlast/sdk/extensions/serialization/source/DTO/DTOMacros.h
new file mode 100644
index 0000000..a234aec
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/DTOMacros.h
@@ -0,0 +1,44 @@
+/*
+* 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.
+*/
+
+#pragma once
+
+#define DTO_CLASS(_NAME, _POCO, _SERIALIZER) \
+namespace Nv { \
+namespace Blast { \
+class _NAME ## DTO \
+{ \
+public: \
+ static class physx::PxCooking* Cooking; \
+ static class physx::PxPhysics* Physics; \
+ \
+ static bool serialize(_SERIALIZER::Builder builder, const _POCO * poco); \
+ static _POCO* deserialize(_SERIALIZER::Reader reader); \
+ static bool deserializeInto(_SERIALIZER::Reader reader, _POCO * poco); \
+}; \
+} \
+} \
+ \
+
+#define DTO_CLASS_LL(_NAME, _POCO, _SERIALIZER) \
+namespace Nv { \
+namespace Blast { \
+class _NAME ## DTO \
+{ \
+public: \
+ \
+ static bool serialize(_SERIALIZER::Builder builder, const _POCO * poco); \
+ static _POCO* deserialize(_SERIALIZER::Reader reader); \
+ static bool deserializeInto(_SERIALIZER::Reader reader, _POCO * poco); \
+}; \
+} \
+} \
+ \
+
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.cpp b/NvBlast/sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.cpp
new file mode 100644
index 0000000..cf4cadc
--- /dev/null
+++ b/NvBlast/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;
+ }
+ }
+}
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.h b/NvBlast/sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.h
new file mode 100644
index 0000000..a35d38a
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.h
@@ -0,0 +1,16 @@
+/*
+* 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.
+*/
+
+#pragma once
+#include "NvBlastBondDTO.h"
+#include "NvBlastExtPxAsset.h"
+#include "generated/NvBlastExtSerialization.capn.h"
+
+DTO_CLASS(ExtPxAsset, Nv::Blast::ExtPxAsset, Nv::Blast::Serialization::ExtPxAsset)
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/ExtPxChunkDTO.cpp b/NvBlast/sdk/extensions/serialization/source/DTO/ExtPxChunkDTO.cpp
new file mode 100644
index 0000000..e096bc1
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/ExtPxChunkDTO.cpp
@@ -0,0 +1,43 @@
+/*
+* 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 "ExtPxChunkDTO.h"
+
+namespace Nv
+{
+ namespace Blast
+ {
+ bool ExtPxChunkDTO::serialize(Nv::Blast::Serialization::ExtPxChunk::Builder builder, const Nv::Blast::ExtPxChunk * poco)
+ {
+ builder.setFirstSubchunkIndex(poco->firstSubchunkIndex);
+ builder.setSubchunkCount(poco->subchunkCount);
+ builder.setIsStatic(poco->isStatic);
+
+ return true;
+ }
+
+ Nv::Blast::ExtPxChunk* ExtPxChunkDTO::deserialize(Nv::Blast::Serialization::ExtPxChunk::Reader reader)
+ {
+ reader = reader;
+ //TODO: Allocate with ExtContext and return
+
+ return nullptr;
+ }
+
+ bool ExtPxChunkDTO::deserializeInto(Nv::Blast::Serialization::ExtPxChunk::Reader reader, Nv::Blast::ExtPxChunk * poco)
+ {
+ poco->firstSubchunkIndex = reader.getFirstSubchunkIndex();
+ poco->subchunkCount = reader.getSubchunkCount();
+ poco->isStatic = reader.getIsStatic();
+
+ return true;
+ }
+ }
+} \ No newline at end of file
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/ExtPxChunkDTO.h b/NvBlast/sdk/extensions/serialization/source/DTO/ExtPxChunkDTO.h
new file mode 100644
index 0000000..1ff36df
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/ExtPxChunkDTO.h
@@ -0,0 +1,16 @@
+/*
+* 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.
+*/
+
+#pragma once
+#include "DTOMacros.h"
+#include "NvBlastExtPxAsset.h"
+#include "generated/NvBlastExtSerialization.capn.h"
+
+DTO_CLASS(ExtPxChunk, Nv::Blast::ExtPxChunk, Nv::Blast::Serialization::ExtPxChunk)
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/ExtPxSubchunkDTO.cpp b/NvBlast/sdk/extensions/serialization/source/DTO/ExtPxSubchunkDTO.cpp
new file mode 100644
index 0000000..cc2be96
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/ExtPxSubchunkDTO.cpp
@@ -0,0 +1,43 @@
+/*
+* 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 "ExtPxSubchunkDTO.h"
+#include "PxTransformDTO.h"
+#include "PxConvexMeshGeometryDTO.h"
+
+namespace Nv
+{
+ namespace Blast
+ {
+ bool ExtPxSubchunkDTO::serialize(Nv::Blast::Serialization::ExtPxSubchunk::Builder builder, const Nv::Blast::ExtPxSubchunk * poco)
+ {
+ PxTransformDTO::serialize(builder.getTransform(), &poco->transform);
+ PxConvexMeshGeometryDTO::serialize(builder.getGeometry(), &poco->geometry);
+
+ return true;
+ }
+
+ Nv::Blast::ExtPxSubchunk* ExtPxSubchunkDTO::deserialize(Nv::Blast::Serialization::ExtPxSubchunk::Reader reader)
+ {
+ reader = reader;
+ //TODO: Allocate with ExtContext and return
+
+ return nullptr;
+ }
+
+ bool ExtPxSubchunkDTO::deserializeInto(Nv::Blast::Serialization::ExtPxSubchunk::Reader reader, Nv::Blast::ExtPxSubchunk * poco)
+ {
+ PxTransformDTO::deserializeInto(reader.getTransform(), &poco->transform);
+
+ return true;
+ }
+
+ }
+}
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/ExtPxSubchunkDTO.h b/NvBlast/sdk/extensions/serialization/source/DTO/ExtPxSubchunkDTO.h
new file mode 100644
index 0000000..91f78e0
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/ExtPxSubchunkDTO.h
@@ -0,0 +1,16 @@
+/*
+* 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.
+*/
+
+#pragma once
+#include "NvBlastExtPxAsset.h"
+#include "generated/NvBlastExtSerialization.capn.h"
+#include "DTOMacros.h"
+
+DTO_CLASS(ExtPxSubchunk, Nv::Blast::ExtPxSubchunk, Nv::Blast::Serialization::ExtPxSubchunk)
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/NvBlastBondDTO.cpp b/NvBlast/sdk/extensions/serialization/source/DTO/NvBlastBondDTO.cpp
new file mode 100644
index 0000000..27cbb11
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/NvBlastBondDTO.cpp
@@ -0,0 +1,63 @@
+/*
+* 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 "NvBlastBondDTO.h"
+#include "NvBlastAssert.h"
+
+namespace Nv
+{
+ namespace Blast
+ {
+
+ bool NvBlastBondDTO::serialize(Nv::Blast::Serialization::NvBlastBond::Builder builder, const NvBlastBond * poco)
+ {
+ NVBLAST_ASSERT(poco != nullptr);
+
+ kj::ArrayPtr<const float> normArray(poco->normal, 3);
+
+ builder.setNormal(normArray);
+
+ builder.setArea(poco->area);
+
+ kj::ArrayPtr<const float> centArray(poco->centroid, 3);
+
+ builder.setCentroid(centArray);
+
+ builder.setUserData(poco->userData);
+
+ return true;
+ }
+
+ NvBlastBond* NvBlastBondDTO::deserialize(Nv::Blast::Serialization::NvBlastBond::Reader reader)
+ {
+ //FIXME
+ reader = reader;
+ //TODO: Allocate with ExtContext and return
+ return nullptr;
+ }
+
+ bool NvBlastBondDTO::deserializeInto(Nv::Blast::Serialization::NvBlastBond::Reader reader, NvBlastBond * poco)
+ {
+ poco->area = reader.getArea();
+
+ poco->centroid[0] = reader.getCentroid()[0];
+ poco->centroid[1] = reader.getCentroid()[1];
+ poco->centroid[2] = reader.getCentroid()[2];
+
+ poco->normal[0] = reader.getNormal()[0];
+ poco->normal[1] = reader.getNormal()[1];
+ poco->normal[2] = reader.getNormal()[2];
+
+ poco->userData = reader.getUserData();
+
+ return true;
+ }
+ }
+}
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/NvBlastBondDTO.h b/NvBlast/sdk/extensions/serialization/source/DTO/NvBlastBondDTO.h
new file mode 100644
index 0000000..8b67bd7
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/NvBlastBondDTO.h
@@ -0,0 +1,16 @@
+/*
+* 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.
+*/
+
+#pragma once
+#include "DTOMacros.h"
+#include "NvBlastTypes.h"
+#include "generated/NvBlastExtSerializationLL.capn.h"
+
+DTO_CLASS_LL(NvBlastBond, NvBlastBond, Nv::Blast::Serialization::NvBlastBond)
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/NvBlastChunkDTO.cpp b/NvBlast/sdk/extensions/serialization/source/DTO/NvBlastChunkDTO.cpp
new file mode 100644
index 0000000..38814ed
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/NvBlastChunkDTO.cpp
@@ -0,0 +1,60 @@
+/*
+* 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 "NvBlastChunkDTO.h"
+#include "NvBlastAssert.h"
+
+namespace Nv
+{
+ namespace Blast
+ {
+ bool NvBlastChunkDTO::serialize(Nv::Blast::Serialization::NvBlastChunk::Builder builder, const NvBlastChunk* poco)
+ {
+ NVBLAST_ASSERT(poco != nullptr);
+
+ kj::ArrayPtr<const float> centArray(poco->centroid, 3);
+ builder.setCentroid(centArray);
+
+ builder.setVolume(poco->volume);
+
+ builder.setParentChunkIndex(poco->parentChunkIndex);
+ builder.setFirstChildIndex(poco->firstChildIndex);
+ builder.setChildIndexStop(poco->childIndexStop);
+ builder.setUserData(poco->userData);
+
+ return true;
+ }
+
+ NvBlastChunk* NvBlastChunkDTO::deserialize(Nv::Blast::Serialization::NvBlastChunk::Reader reader)
+ {
+ //FIXME
+ reader = reader;
+
+ return nullptr;
+ }
+
+ bool NvBlastChunkDTO::deserializeInto(Nv::Blast::Serialization::NvBlastChunk::Reader reader, NvBlastChunk* target)
+ {
+ NVBLAST_ASSERT(target != nullptr);
+
+ target->centroid[0] = reader.getCentroid()[0];
+ target->centroid[1] = reader.getCentroid()[1];
+ target->centroid[2] = reader.getCentroid()[2];
+
+ target->childIndexStop = reader.getChildIndexStop();
+ target->firstChildIndex = reader.getFirstChildIndex();
+ target->parentChunkIndex = reader.getParentChunkIndex();
+ target->userData = reader.getUserData();
+ target->volume = reader.getVolume();
+
+ return true;
+ }
+ }
+}
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/NvBlastChunkDTO.h b/NvBlast/sdk/extensions/serialization/source/DTO/NvBlastChunkDTO.h
new file mode 100644
index 0000000..5fec498
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/NvBlastChunkDTO.h
@@ -0,0 +1,18 @@
+/*
+* 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.
+*/
+
+#pragma once
+#include "DTOMacros.h"
+#include "NvBlastTypes.h"
+#include "generated/NvBlastExtSerializationLL.capn.h"
+
+
+DTO_CLASS_LL(NvBlastChunk, NvBlastChunk, Nv::Blast::Serialization::NvBlastChunk)
+
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/NvBlastIDDTO.cpp b/NvBlast/sdk/extensions/serialization/source/DTO/NvBlastIDDTO.cpp
new file mode 100644
index 0000000..e540cd8
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/NvBlastIDDTO.cpp
@@ -0,0 +1,48 @@
+/*
+* 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 "NvBlastIDDTO.h"
+#include "NvBlastTypes.h"
+#include "NvBlastAssert.h"
+#include "generated/NvBlastExtSerializationLL.capn.h"
+
+
+namespace Nv
+{
+ namespace Blast
+ {
+
+ bool NvBlastIDDTO::serialize(Nv::Blast::Serialization::UUID::Builder builder, const NvBlastID * poco)
+ {
+ capnp::Data::Reader idArrayReader((unsigned char *)poco->data, 16);
+ builder.setValue(idArrayReader);
+
+ return true;
+ }
+
+ NvBlastID* NvBlastIDDTO::deserialize(Nv::Blast::Serialization::UUID::Reader reader)
+ {
+ //FIXME
+ reader = reader;
+ //TODO: Allocate with ExtContext and return
+
+ return nullptr;
+ }
+
+ bool NvBlastIDDTO::deserializeInto(Nv::Blast::Serialization::UUID::Reader reader, NvBlastID * poco)
+ {
+ NVBLAST_ASSERT_WITH_MESSAGE(reader.getValue().size() == 16, "BlastID must be 16 bytes");
+
+ memcpy(poco, reader.getValue().begin(), 16);
+
+ return true;
+ }
+ }
+} \ No newline at end of file
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/NvBlastIDDTO.h b/NvBlast/sdk/extensions/serialization/source/DTO/NvBlastIDDTO.h
new file mode 100644
index 0000000..afe6cf0
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/NvBlastIDDTO.h
@@ -0,0 +1,16 @@
+/*
+* 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.
+*/
+
+#pragma once
+#include "NvBlastTypes.h"
+#include "generated/NvBlastExtSerializationLL.capn.h"
+#include "DTOMacros.h"
+
+DTO_CLASS_LL(NvBlastID, NvBlastID, ::Nv::Blast::Serialization::UUID)
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/PxConvexMeshGeometryDTO.cpp b/NvBlast/sdk/extensions/serialization/source/DTO/PxConvexMeshGeometryDTO.cpp
new file mode 100644
index 0000000..1c46f9e
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/PxConvexMeshGeometryDTO.cpp
@@ -0,0 +1,127 @@
+/*
+* 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 "PxConvexMeshGeometryDTO.h"
+#include "PxMeshScaleDTO.h"
+#include "NvBlastAssert.h"
+#include "NvBlastExtKJPxInputStream.h"
+#include "NvBlastExtKJPxOutputStream.h"
+#include "PxConvexMeshDesc.h"
+#include "NvBlastExtSerialization.h"
+#include "PxVec3.h"
+#include <algorithm>
+#include "PxPhysics.h"
+
+
+namespace Nv
+{
+ namespace Blast
+ {
+ physx::PxCooking* PxConvexMeshGeometryDTO::Cooking = nullptr;
+ physx::PxPhysics* PxConvexMeshGeometryDTO::Physics = nullptr;
+
+ bool PxConvexMeshGeometryDTO::serialize(Nv::Blast::Serialization::PxConvexMeshGeometry::Builder builder, const physx::PxConvexMeshGeometry * poco)
+ {
+ PxMeshScaleDTO::serialize(builder.getScale(), &poco->scale);
+
+ //TODO: Use cooking.cookConvexMesh to cook the mesh to a stream - then get that backing buffer and put it into the Data field
+
+ physx::PxConvexMeshDesc desc;
+ desc.points.data = poco->convexMesh->getVertices();
+ desc.points.count = poco->convexMesh->getNbVertices();
+ desc.points.stride = sizeof(physx::PxVec3);
+
+ std::vector<uint32_t> indicesScratch;
+ std::vector<physx::PxHullPolygon> hullPolygonsScratch;
+
+ hullPolygonsScratch.resize(poco->convexMesh->getNbPolygons());
+
+ uint32_t indexCount = 0;
+ for (uint32_t i = 0; i < hullPolygonsScratch.size(); i++)
+ {
+ physx::PxHullPolygon polygon;
+ poco->convexMesh->getPolygonData(i, polygon);
+ if (polygon.mNbVerts)
+ {
+ indexCount = std::max<uint32_t>(indexCount, polygon.mIndexBase + polygon.mNbVerts);
+ }
+ }
+ indicesScratch.resize(indexCount);
+
+ for (uint32_t i = 0; i < hullPolygonsScratch.size(); i++)
+ {
+ physx::PxHullPolygon polygon;
+ poco->convexMesh->getPolygonData(i, polygon);
+ for (uint32_t j = 0; j < polygon.mNbVerts; j++)
+ {
+ indicesScratch[polygon.mIndexBase + j] = poco->convexMesh->getIndexBuffer()[polygon.mIndexBase + j];
+ }
+
+ hullPolygonsScratch[i] = polygon;
+ }
+
+ desc.indices.count = indexCount;
+ desc.indices.data = indicesScratch.data();
+ desc.indices.stride = sizeof(uint32_t);
+
+ desc.polygons.count = poco->convexMesh->getNbPolygons();
+ desc.polygons.data = hullPolygonsScratch.data();
+ desc.polygons.stride = sizeof(physx::PxHullPolygon);
+
+
+ std::vector<unsigned char> buffer;
+ buffer.resize(16 * 1024 * 1024); // No idea how much memory is needed! Allocate 16MB
+ kj::ArrayPtr<unsigned char> bufferArray(buffer.data(), buffer.size());
+
+ Nv::Blast::ExtKJPxOutputStream outputStream(bufferArray);
+
+ bool cookResult = Cooking->cookConvexMesh(desc, outputStream);
+
+ if (!cookResult)
+ {
+ return false;
+ }
+
+ kj::ArrayPtr<unsigned char> cookedBuffer(outputStream.getBuffer().begin(), outputStream.getWrittenBytes());
+
+ builder.setConvexMesh(cookedBuffer);
+
+ // builder.getConvexMesh().
+
+ return true;
+ }
+
+ physx::PxConvexMeshGeometry* PxConvexMeshGeometryDTO::deserialize(Nv::Blast::Serialization::PxConvexMeshGeometry::Reader reader)
+ {
+ NVBLAST_ASSERT(PxConvexMeshGeometryDTO::Cooking != nullptr);
+
+ reader = reader;
+
+ return nullptr;
+ }
+
+ bool PxConvexMeshGeometryDTO::deserializeInto(Nv::Blast::Serialization::PxConvexMeshGeometry::Reader reader, physx::PxConvexMeshGeometry * poco)
+ {
+ NVBLAST_ASSERT(PxConvexMeshGeometryDTO::Cooking != nullptr);
+
+ PxMeshScaleDTO::deserializeInto(reader.getScale(), &poco->scale);
+
+ Nv::Blast::ExtKJPxInputStream inputStream(reader.getConvexMesh());
+
+ //NOTE: Naive approach, no shared convex hulls
+ poco->convexMesh = Physics->createConvexMesh(inputStream);
+
+ return false;
+ }
+
+
+
+ }
+}
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/PxConvexMeshGeometryDTO.h b/NvBlast/sdk/extensions/serialization/source/DTO/PxConvexMeshGeometryDTO.h
new file mode 100644
index 0000000..27b3754
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/PxConvexMeshGeometryDTO.h
@@ -0,0 +1,17 @@
+/*
+* 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.
+*/
+
+#pragma once
+#include "DTOMacros.h"
+#include "generated/NvBlastExtSerialization.capn.h"
+#include "PxConvexMeshGeometry.h"
+#include "PxCooking.h"
+
+DTO_CLASS(PxConvexMeshGeometry, physx::PxConvexMeshGeometry, Nv::Blast::Serialization::PxConvexMeshGeometry)
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/PxMeshScaleDTO.cpp b/NvBlast/sdk/extensions/serialization/source/DTO/PxMeshScaleDTO.cpp
new file mode 100644
index 0000000..8fee6ad
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/PxMeshScaleDTO.cpp
@@ -0,0 +1,42 @@
+/*
+* 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 "PxMeshScaleDTO.h"
+#include "PxVec3DTO.h"
+#include "PxQuatDTO.h"
+
+namespace Nv
+{
+ namespace Blast
+ {
+ bool PxMeshScaleDTO::serialize(Nv::Blast::Serialization::PxMeshScale::Builder builder, const physx::PxMeshScale * poco)
+ {
+ PxVec3DTO::serialize(builder.getScale(), &poco->scale);
+ PxQuatDTO::serialize(builder.getRotation(), &poco->rotation);
+
+ return true;
+ }
+
+ physx::PxMeshScale* PxMeshScaleDTO::deserialize(Nv::Blast::Serialization::PxMeshScale::Reader reader)
+ {
+ reader = reader;
+ return nullptr;
+ }
+
+ bool PxMeshScaleDTO::deserializeInto(Nv::Blast::Serialization::PxMeshScale::Reader reader, physx::PxMeshScale * poco)
+ {
+ PxVec3DTO::deserializeInto(reader.getScale(), &poco->scale);
+ PxQuatDTO::deserializeInto(reader.getRotation(), &poco->rotation);
+
+ return true;
+ }
+ }
+}
+
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/PxMeshScaleDTO.h b/NvBlast/sdk/extensions/serialization/source/DTO/PxMeshScaleDTO.h
new file mode 100644
index 0000000..7b758c8
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/PxMeshScaleDTO.h
@@ -0,0 +1,17 @@
+/*
+* 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.
+*/
+
+#pragma once
+#include "DTOMacros.h"
+#include "PxMeshScale.h"
+#include "generated/NvBlastExtSerialization.capn.h"
+#include "PxCooking.h"
+
+DTO_CLASS(PxMeshScale, physx::PxMeshScale, Nv::Blast::Serialization::PxMeshScale)
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/PxQuatDTO.cpp b/NvBlast/sdk/extensions/serialization/source/DTO/PxQuatDTO.cpp
new file mode 100644
index 0000000..8faeaa6
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/PxQuatDTO.cpp
@@ -0,0 +1,45 @@
+/*
+* 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 "PxQuatDTO.h"
+
+namespace Nv
+{
+ namespace Blast
+ {
+
+ bool PxQuatDTO::serialize(Nv::Blast::Serialization::PxQuat::Builder builder, const physx::PxQuat * poco)
+ {
+ builder.setX(poco->x);
+ builder.setY(poco->y);
+ builder.setZ(poco->z);
+ builder.setW(poco->w);
+
+ return true;
+ }
+
+ physx::PxQuat* PxQuatDTO::deserialize(Nv::Blast::Serialization::PxQuat::Reader reader)
+ {
+ reader = reader;
+ return nullptr;
+ }
+
+ bool PxQuatDTO::deserializeInto(Nv::Blast::Serialization::PxQuat::Reader reader, physx::PxQuat * poco)
+ {
+ poco->x = reader.getX();
+ poco->y = reader.getY();
+ poco->z = reader.getZ();
+ poco->w = reader.getW();
+
+ return true;
+ }
+
+ }
+}
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/PxQuatDTO.h b/NvBlast/sdk/extensions/serialization/source/DTO/PxQuatDTO.h
new file mode 100644
index 0000000..460d6c5
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/PxQuatDTO.h
@@ -0,0 +1,17 @@
+/*
+* 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.
+*/
+
+#pragma once
+#include "DTOMacros.h"
+#include "PxQuat.h"
+#include "generated/NvBlastExtSerialization.capn.h"
+#include "PxCooking.h"
+
+DTO_CLASS(PxQuat, physx::PxQuat, Nv::Blast::Serialization::PxQuat)
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/PxTransformDTO.cpp b/NvBlast/sdk/extensions/serialization/source/DTO/PxTransformDTO.cpp
new file mode 100644
index 0000000..20a7cbb
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/PxTransformDTO.cpp
@@ -0,0 +1,42 @@
+/*
+* 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 "PxTransformDTO.h"
+#include "PxQuatDTO.h"
+#include "PxVec3DTO.h"
+
+namespace Nv
+{
+ namespace Blast
+ {
+
+ bool PxTransformDTO::serialize(Nv::Blast::Serialization::PxTransform::Builder builder, const physx::PxTransform * poco)
+ {
+ PxQuatDTO::serialize(builder.getQ(), &poco->q);
+ PxVec3DTO::serialize(builder.getP(), &poco->p);
+
+ return true;
+ }
+
+ physx::PxTransform* PxTransformDTO::deserialize(Nv::Blast::Serialization::PxTransform::Reader reader)
+ {
+ reader = reader;
+ return nullptr;
+ }
+
+ bool PxTransformDTO::deserializeInto(Nv::Blast::Serialization::PxTransform::Reader reader, physx::PxTransform * poco)
+ {
+ PxQuatDTO::deserializeInto(reader.getQ(), &poco->q);
+ PxVec3DTO::deserializeInto(reader.getP(), &poco->p);
+
+ return true;
+ }
+ }
+}
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/PxTransformDTO.h b/NvBlast/sdk/extensions/serialization/source/DTO/PxTransformDTO.h
new file mode 100644
index 0000000..49a6b73
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/PxTransformDTO.h
@@ -0,0 +1,17 @@
+/*
+* 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.
+*/
+
+#pragma once
+#include "DTOMacros.h"
+#include "PxTransform.h"
+#include "generated/NvBlastExtSerialization.capn.h"
+#include "PxCooking.h"
+
+DTO_CLASS(PxTransform, physx::PxTransform, Nv::Blast::Serialization::PxTransform)
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/PxVec3DTO.cpp b/NvBlast/sdk/extensions/serialization/source/DTO/PxVec3DTO.cpp
new file mode 100644
index 0000000..9827cd0
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/PxVec3DTO.cpp
@@ -0,0 +1,45 @@
+/*
+* 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 "PxVec3DTO.h"
+#include "NvBlastAssert.h"
+
+namespace Nv
+{
+ namespace Blast
+ {
+ bool PxVec3DTO::serialize(Nv::Blast::Serialization::PxVec3::Builder builder, const physx::PxVec3 * poco)
+ {
+ NVBLAST_ASSERT(poco != nullptr);
+
+ builder.setX(poco->x);
+ builder.setY(poco->y);
+ builder.setZ(poco->z);
+
+ return true;
+ }
+
+ physx::PxVec3* PxVec3DTO::deserialize(Nv::Blast::Serialization::PxVec3::Reader reader)
+ {
+ //TODO: Allocate using ExtContext and return
+ reader = reader;
+ return nullptr;
+ }
+
+ bool PxVec3DTO::deserializeInto(Nv::Blast::Serialization::PxVec3::Reader reader, physx::PxVec3* target)
+ {
+ target->x = reader.getX();
+ target->y = reader.getY();
+ target->z = reader.getZ();
+
+ return true;
+ }
+ }
+}
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/PxVec3DTO.h b/NvBlast/sdk/extensions/serialization/source/DTO/PxVec3DTO.h
new file mode 100644
index 0000000..8a04c8b
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/PxVec3DTO.h
@@ -0,0 +1,17 @@
+/*
+* 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.
+*/
+
+#pragma once
+#include "DTOMacros.h"
+#include "generated/NvBlastExtSerialization.capn.h"
+#include "PxVec3.h"
+#include "PxCooking.h"
+
+DTO_CLASS(PxVec3, physx::PxVec3, Nv::Blast::Serialization::PxVec3)
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/TkAssetDTO.cpp b/NvBlast/sdk/extensions/serialization/source/DTO/TkAssetDTO.cpp
new file mode 100644
index 0000000..acc55ba
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/TkAssetDTO.cpp
@@ -0,0 +1,67 @@
+/*
+* 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 "TkAssetDTO.h"
+#include "AssetDTO.h"
+#include "TkAssetJointDescDTO.h"
+#include <vector>
+#include "NvBlastTkFramework.h"
+
+
+
+namespace Nv
+{
+ namespace Blast
+ {
+ bool TkAssetDTO::serialize(Nv::Blast::Serialization::TkAsset::Builder builder, const Nv::Blast::TkAsset * poco)
+ {
+ const Asset* assetLL = reinterpret_cast<const Nv::Blast::Asset*>(poco->getAssetLL());
+
+ Nv::Blast::AssetDTO::serialize(builder.getAssetLL(), assetLL);
+
+ uint32_t jointDescCount = poco->getJointDescCount();
+
+ capnp::List<Nv::Blast::Serialization::TkAssetJointDesc>::Builder jointDescs = builder.initJointDescs(jointDescCount);
+
+ for (uint32_t i = 0; i < jointDescCount; i++)
+ {
+ TkAssetJointDescDTO::serialize(jointDescs[i], &poco->getJointDescs()[i]);
+ }
+
+ return true;
+ }
+
+ Nv::Blast::TkAsset* TkAssetDTO::deserialize(Nv::Blast::Serialization::TkAsset::Reader reader)
+ {
+ const NvBlastAsset* assetLL = reinterpret_cast<const NvBlastAsset*>(AssetDTO::deserialize(reader.getAssetLL()));
+
+ std::vector<Nv::Blast::TkAssetJointDesc> jointDescs;
+ jointDescs.resize(reader.getJointDescs().size());
+
+ for (uint32_t i = 0; i < jointDescs.size(); i++)
+ {
+ TkAssetJointDescDTO::deserializeInto(reader.getJointDescs()[i], &jointDescs[i]);
+ }
+
+ // Make sure to set ownsAsset to true - this is serialization and no one else owns it.
+ Nv::Blast::TkAsset* asset = NvBlastTkFrameworkGet()->createAsset(assetLL, jointDescs.data(), jointDescs.size(), true);
+
+ return asset;
+ }
+
+ bool TkAssetDTO::deserializeInto(Nv::Blast::Serialization::TkAsset::Reader reader, Nv::Blast::TkAsset * poco)
+ {
+ reader = reader;
+ poco = nullptr;
+ // NOTE: Because of the way TkAsset is currently structured, this won't work.
+ return false;
+ }
+ }
+}
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/TkAssetDTO.h b/NvBlast/sdk/extensions/serialization/source/DTO/TkAssetDTO.h
new file mode 100644
index 0000000..1b21eba
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/TkAssetDTO.h
@@ -0,0 +1,17 @@
+/*
+* 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.
+*/
+
+#pragma once
+#include "DTOMacros.h"
+#include "NvBlastTkAsset.h"
+#include "generated/NvBlastExtSerialization.capn.h"
+#include "PxCooking.h"
+
+DTO_CLASS(TkAsset, Nv::Blast::TkAsset, Nv::Blast::Serialization::TkAsset)
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/TkAssetJointDescDTO.cpp b/NvBlast/sdk/extensions/serialization/source/DTO/TkAssetJointDescDTO.cpp
new file mode 100644
index 0000000..9118d19
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/TkAssetJointDescDTO.cpp
@@ -0,0 +1,53 @@
+/*
+* 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 "TkAssetJointDescDTO.h"
+#include "PxVec3DTO.h"
+
+
+namespace Nv
+{
+ namespace Blast
+ {
+
+ bool TkAssetJointDescDTO::serialize(Nv::Blast::Serialization::TkAssetJointDesc::Builder builder, const Nv::Blast::TkAssetJointDesc * poco)
+ {
+ kj::ArrayPtr<const uint32_t> nodeIndices(poco->nodeIndices, 2);
+ builder.setNodeIndices(nodeIndices);
+
+ for (int i = 0; i < 2; i++)
+ {
+ PxVec3DTO::serialize(builder.getAttachPositions()[i], &poco->attachPositions[i]);
+ }
+
+ return true;
+ }
+
+ Nv::Blast::TkAssetJointDesc* TkAssetJointDescDTO::deserialize(Nv::Blast::Serialization::TkAssetJointDesc::Reader reader)
+ {
+ //TODO: Allocate with ExtContent and return
+
+ reader = reader;
+
+ return nullptr;
+ }
+
+ bool TkAssetJointDescDTO::deserializeInto(Nv::Blast::Serialization::TkAssetJointDesc::Reader reader, Nv::Blast::TkAssetJointDesc * poco)
+ {
+ PxVec3DTO::deserializeInto(reader.getAttachPositions()[0], &poco->attachPositions[0]);
+ PxVec3DTO::deserializeInto(reader.getAttachPositions()[1], &poco->attachPositions[1]);
+
+ poco->nodeIndices[0] = reader.getNodeIndices()[0];
+ poco->nodeIndices[1] = reader.getNodeIndices()[1];
+
+ return true;
+ }
+ }
+} \ No newline at end of file
diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/TkAssetJointDescDTO.h b/NvBlast/sdk/extensions/serialization/source/DTO/TkAssetJointDescDTO.h
new file mode 100644
index 0000000..88364bd
--- /dev/null
+++ b/NvBlast/sdk/extensions/serialization/source/DTO/TkAssetJointDescDTO.h
@@ -0,0 +1,17 @@
+/*
+* 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.
+*/
+
+#pragma once
+#include "DTOMacros.h"
+#include "NvBlastTkAsset.h"
+#include "generated/NvBlastExtSerialization.capn.h"
+#include "PxCooking.h"
+
+DTO_CLASS(TkAssetJointDesc, Nv::Blast::TkAssetJointDesc, Nv::Blast::Serialization::TkAssetJointDesc)