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 /NvBlast/sdk/extensions/serialization | |
| 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 'NvBlast/sdk/extensions/serialization')
49 files changed, 0 insertions, 2605 deletions
diff --git a/NvBlast/sdk/extensions/serialization/include/NvBlastExtSerializationInterface.h b/NvBlast/sdk/extensions/serialization/include/NvBlastExtSerializationInterface.h deleted file mode 100644 index e4f27e0..0000000 --- a/NvBlast/sdk/extensions/serialization/include/NvBlastExtSerializationInterface.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -* 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 this file to get the C interface to serialization for all asset types (LL, Tk and Ext) -*/ -#pragma once -#include <ostream> -#include "NvBlastTkAsset.h" -#include "NvBlastExtPxAsset.h" - -#include "NvBlastExtSerializationLLInterface.h" - -namespace physx -{ - class PxPhysics; -} - -NVBLAST_API void setPhysXSDK(physx::PxPhysics* physXSDK); - -NVBLAST_API Nv::Blast::TkAsset* deserializeTkAsset(const unsigned char* input, uint32_t size); -NVBLAST_API Nv::Blast::TkAsset* deserializeTkAssetFromStream(std::istream &inputStream); -NVBLAST_API bool serializeTkAssetIntoStream(const Nv::Blast::TkAsset *asset, std::ostream &outputStream); -NVBLAST_API bool serializeTkAssetIntoNewBuffer(const Nv::Blast::TkAsset *asset, unsigned char **outBuffer, uint32_t &outSize); -NVBLAST_API bool serializeTkAssetIntoExistingBuffer(const Nv::Blast::TkAsset *asset, unsigned char *buffer, uint32_t maxSize, uint32_t &usedSize); - -NVBLAST_API Nv::Blast::ExtPxAsset* deserializeExtPxAsset(const unsigned char* input, uint32_t size); -NVBLAST_API Nv::Blast::ExtPxAsset* deserializeExtPxAssetFromStream(std::istream &inputStream); -NVBLAST_API bool serializeExtPxAssetIntoStream(const Nv::Blast::ExtPxAsset *asset, std::ostream &outputStream); -NVBLAST_API bool serializeExtPxAssetIntoNewBuffer(const Nv::Blast::ExtPxAsset *asset, unsigned char **outBuffer, uint32_t &outSize); -NVBLAST_API bool serializeExtPxAssetIntoExistingBuffer(const Nv::Blast::ExtPxAsset *asset, unsigned char *buffer, uint32_t maxSize, uint32_t &usedSize); diff --git a/NvBlast/sdk/extensions/serialization/include/NvBlastExtSerializationLLInterface.h b/NvBlast/sdk/extensions/serialization/include/NvBlastExtSerializationLLInterface.h deleted file mode 100644 index d21c7ca..0000000 --- a/NvBlast/sdk/extensions/serialization/include/NvBlastExtSerializationLLInterface.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -* 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 this file to access the C API for serialization, for Low Level assets only. - -For Serialization of Tk and Ext assets, include only NvBlastExtSerializationInterface.h, which will include this file as well. - -*/ -#pragma once -#include <ostream> -#include "NvBlastPreprocessor.h" -#include "NvBlastTypes.h" - -#include "NvBlastExtGlobals.h" - -/* - Set a global NvBlastAlloc signature allocation function that the deserialization will use when required. - - NOTE: This will NOT be used when using the combined serialization library, as it will use the TkFramework's allocation and logging -*/ -NVBLAST_API void setAllocator(NvBlastExtAlloc alloc); - -/* - Set a global NvBlastLog signature allocation function that the library will use when required. - - NOTE: This will NOT be used when using the combined serialization library, as it will use the TkFramework's allocation and logging -*/ -NVBLAST_API void setLog(NvBlastLog log); - - -NVBLAST_API NvBlastAsset* deserializeAsset(const unsigned char* input, uint32_t size); -NVBLAST_API NvBlastAsset* deserializeAssetFromStream(std::istream &inputStream); -NVBLAST_API bool serializeAssetIntoStream(const NvBlastAsset *asset, std::ostream &outputStream); -NVBLAST_API bool serializeAssetIntoNewBuffer(const NvBlastAsset *asset, unsigned char **outBuffer, uint32_t &outSize); -NVBLAST_API bool serializeAssetIntoExistingBuffer(const NvBlastAsset *asset, unsigned char *buffer, uint32_t maxSize, uint32_t &usedSize); diff --git a/NvBlast/sdk/extensions/serialization/source/BlastSerialization.capn b/NvBlast/sdk/extensions/serialization/source/BlastSerialization.capn deleted file mode 100644 index 49b1dbb..0000000 --- a/NvBlast/sdk/extensions/serialization/source/BlastSerialization.capn +++ /dev/null @@ -1,162 +0,0 @@ -@0xaffe4498f275ee58; - -using Cxx = import "/capnp/c++.capnp"; - -$Cxx.namespace("Nv::Blast::Serialization"); - -struct Asset -{ - header @0 :NvBlastDataBlock; - - iD @1 :UUID; - - chunkCount @2 :UInt32; - - graph @3 :NvBlastSupportGraph; - - leafChunkCount @4 :UInt32; - - firstSubsupportChunkIndex @5 :UInt32; - - bondCount @6 :UInt32; - - chunks @7: List(NvBlastChunk); - - bonds @8: List(NvBlastBond); - - subtreeLeafChunkCounts @9: List(UInt32); - - chunkToGraphNodeMap @10: List(UInt32); -} - -struct TkAsset -{ - assetLL @0 :Asset; - - jointDescs @1 :List(TkAssetJointDesc); - -} - -struct ExtPxAsset -{ - asset @0 :TkAsset; - chunks @1 :List(ExtPxChunk); - subchunks @2 :List(ExtPxSubchunk); -} - -struct ExtPxChunk -{ - firstSubchunkIndex @0 :UInt32; - subchunkCount @1 :UInt32; - isStatic @2 :Bool; -} - -struct ExtPxSubchunk -{ - transform @0 :PxTransform; - geometry @1 :PxConvexMeshGeometry; -} - -struct PxConvexMeshGeometry -{ - scale @0 :PxMeshScale; - convexMesh @1 :Data; - meshFlags @2 :UInt8; - - enum Type - { - eSPHERE @0; - ePLANE @1; - eCAPSULE @2; - eBOX @3; - eCONVEXMESH @4; - eTRIANGLEMESH @5; - eHEIGHTFIELD @6; - } - - type @3 :Type; -} - -struct NvBlastDataBlock -{ - enum Type - { - assetDataBlock @0; - instanceDataBlock @1; - } - - dataType @0 :Type; - - formatVersion @1 :UInt32; - - size @2 :UInt32; -} - -struct NvBlastChunk -{ - centroid @0 :List(Float32); - - volume @1 :Float32; - - parentChunkIndex @2 :UInt32; - firstChildIndex @3 :UInt32; - childIndexStop @4 :UInt32; - userData @5 :UInt32; -} - -struct NvBlastBond -{ - normal @0 :List(Float32); - area @1 :Float32; - centroid @2 :List(Float32); - userData @3 :UInt32; -} - -struct TkAssetJointDesc -{ - nodeIndices @0 :List(UInt32); - attachPositions @1 :List(PxVec3); -} - -struct PxVec3 -{ - x @0 :Float32; - y @1 :Float32; - z @2 :Float32; -} - -struct PxQuat -{ - x @0 :Float32; - y @1 :Float32; - z @2 :Float32; - w @3 :Float32; -} - -struct PxMeshScale -{ - scale @0 :PxVec3; - rotation @1 :PxQuat; -} - -struct PxTransform -{ - q @0 :PxQuat; - p @1 :PxVec3; -} - -struct NvBlastSupportGraph -{ - nodeCount @0 : UInt32; - - chunkIndices @1 : List(UInt32); - adjacencyPartition @2 : List(UInt32); - adjacentNodeIndices @3 : List(UInt32); - adjacentBondIndices @4 : List(UInt32); -} - -struct UUID -{ - value @0 : Data; -} - diff --git a/NvBlast/sdk/extensions/serialization/source/DTO/AssetDTO.cpp b/NvBlast/sdk/extensions/serialization/source/DTO/AssetDTO.cpp deleted file mode 100644 index 8d035fc..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/AssetDTO.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/* -* 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 deleted file mode 100644 index c090b5f..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/AssetDTO.h +++ /dev/null @@ -1,16 +0,0 @@ -/* -* 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 deleted file mode 100644 index a234aec..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/DTOMacros.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -* 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 deleted file mode 100644 index cf4cadc..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* -* 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 deleted file mode 100644 index a35d38a..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/ExtPxAssetDTO.h +++ /dev/null @@ -1,16 +0,0 @@ -/* -* 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 deleted file mode 100644 index e096bc1..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/ExtPxChunkDTO.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* -* 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 deleted file mode 100644 index 1ff36df..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/ExtPxChunkDTO.h +++ /dev/null @@ -1,16 +0,0 @@ -/* -* 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 deleted file mode 100644 index cc2be96..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/ExtPxSubchunkDTO.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* -* 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 deleted file mode 100644 index 91f78e0..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/ExtPxSubchunkDTO.h +++ /dev/null @@ -1,16 +0,0 @@ -/* -* 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 deleted file mode 100644 index 27cbb11..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/NvBlastBondDTO.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* -* 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 deleted file mode 100644 index 8b67bd7..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/NvBlastBondDTO.h +++ /dev/null @@ -1,16 +0,0 @@ -/* -* 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 deleted file mode 100644 index 38814ed..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/NvBlastChunkDTO.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* -* 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 deleted file mode 100644 index 5fec498..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/NvBlastChunkDTO.h +++ /dev/null @@ -1,18 +0,0 @@ -/* -* 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 deleted file mode 100644 index e540cd8..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/NvBlastIDDTO.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* -* 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 deleted file mode 100644 index afe6cf0..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/NvBlastIDDTO.h +++ /dev/null @@ -1,16 +0,0 @@ -/* -* 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 deleted file mode 100644 index 1c46f9e..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/PxConvexMeshGeometryDTO.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* -* 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 deleted file mode 100644 index 27b3754..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/PxConvexMeshGeometryDTO.h +++ /dev/null @@ -1,17 +0,0 @@ -/* -* 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 deleted file mode 100644 index 8fee6ad..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/PxMeshScaleDTO.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* -* 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 deleted file mode 100644 index 7b758c8..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/PxMeshScaleDTO.h +++ /dev/null @@ -1,17 +0,0 @@ -/* -* 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 deleted file mode 100644 index 8faeaa6..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/PxQuatDTO.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* -* 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 deleted file mode 100644 index 460d6c5..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/PxQuatDTO.h +++ /dev/null @@ -1,17 +0,0 @@ -/* -* 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 deleted file mode 100644 index 20a7cbb..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/PxTransformDTO.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* -* 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 deleted file mode 100644 index 49a6b73..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/PxTransformDTO.h +++ /dev/null @@ -1,17 +0,0 @@ -/* -* 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 deleted file mode 100644 index 9827cd0..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/PxVec3DTO.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* -* 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 deleted file mode 100644 index 8a04c8b..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/PxVec3DTO.h +++ /dev/null @@ -1,17 +0,0 @@ -/* -* 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 deleted file mode 100644 index acc55ba..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/TkAssetDTO.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* -* 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 deleted file mode 100644 index 1b21eba..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/TkAssetDTO.h +++ /dev/null @@ -1,17 +0,0 @@ -/* -* 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 deleted file mode 100644 index 9118d19..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/TkAssetJointDescDTO.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* -* 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 deleted file mode 100644 index 88364bd..0000000 --- a/NvBlast/sdk/extensions/serialization/source/DTO/TkAssetJointDescDTO.h +++ /dev/null @@ -1,17 +0,0 @@ -/* -* 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) diff --git a/NvBlast/sdk/extensions/serialization/source/NvBlastExtGlobals.h b/NvBlast/sdk/extensions/serialization/source/NvBlastExtGlobals.h deleted file mode 100644 index dd50afd..0000000 --- a/NvBlast/sdk/extensions/serialization/source/NvBlastExtGlobals.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -/** -Function pointer type for allocation - has same signature as stdlib malloc. -*/ -typedef void* (*NvBlastExtAlloc)(size_t size); - -extern NvBlastExtAlloc gAlloc; -extern NvBlastLog gLog; - diff --git a/NvBlast/sdk/extensions/serialization/source/NvBlastExtInputStream.cpp b/NvBlast/sdk/extensions/serialization/source/NvBlastExtInputStream.cpp deleted file mode 100644 index 7ef9b62..0000000 --- a/NvBlast/sdk/extensions/serialization/source/NvBlastExtInputStream.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* -* 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 "NvBlastExtInputStream.h" - - -Nv::Blast::ExtInputStream::ExtInputStream(std::istream &inputStream): - m_inputStream(inputStream) -{ - -} - - -size_t Nv::Blast::ExtInputStream::tryRead(void* buffer, size_t /*minBytes*/, size_t maxBytes) -{ - m_inputStream.read((char *) buffer, maxBytes); - - if (m_inputStream.fail()) - { - // Throw exception, log error -// NVBLASTEXT_LOG_ERROR("Failure when reading from stream"); - } - - // Since we're using a blocking read above, if we don't have maxBytes we're probably done - if ((size_t) m_inputStream.gcount() < maxBytes) - { -// NVBLASTEXT_LOG_ERROR("Failed to read requested number of bytes during blocking read."); - } - - return m_inputStream.gcount(); -} diff --git a/NvBlast/sdk/extensions/serialization/source/NvBlastExtInputStream.h b/NvBlast/sdk/extensions/serialization/source/NvBlastExtInputStream.h deleted file mode 100644 index 9b19d9c..0000000 --- a/NvBlast/sdk/extensions/serialization/source/NvBlastExtInputStream.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -* 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 "kj/io.h" -#include <istream> - -namespace Nv -{ - namespace Blast - { - class ExtInputStream : public kj::InputStream - { - public: - ExtInputStream() = delete; - ExtInputStream(std::istream &inputStream); - - // Returns a read of maxBytes. This is supposed to be happy doing partial reads, but currently isn't. - virtual size_t tryRead(void* buffer, size_t minBytes, size_t maxBytes) override; - - private: - std::istream &m_inputStream; - }; - } -}
\ No newline at end of file diff --git a/NvBlast/sdk/extensions/serialization/source/NvBlastExtKJPxInputStream.cpp b/NvBlast/sdk/extensions/serialization/source/NvBlastExtKJPxInputStream.cpp deleted file mode 100644 index 9af13a9..0000000 --- a/NvBlast/sdk/extensions/serialization/source/NvBlastExtKJPxInputStream.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* -* 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 "NvBlastExtKJPxInputStream.h" - -namespace Nv -{ - namespace Blast - { - ExtKJPxInputStream::ExtKJPxInputStream(capnp::Data::Reader inReader) : - dataReader(inReader), - inputStream(nullptr) - { - kj::ArrayPtr<const unsigned char> buffer(inReader.begin(), inReader.size()); - - inputStream = std::make_shared<kj::ArrayInputStream>(buffer); - } - - uint32_t ExtKJPxInputStream::read(void* dest, uint32_t count) - { - return inputStream->tryRead(dest, count, count); - } - } -} - diff --git a/NvBlast/sdk/extensions/serialization/source/NvBlastExtKJPxInputStream.h b/NvBlast/sdk/extensions/serialization/source/NvBlastExtKJPxInputStream.h deleted file mode 100644 index 452892d..0000000 --- a/NvBlast/sdk/extensions/serialization/source/NvBlastExtKJPxInputStream.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -* 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 "PxIO.h" -#include "capnp/common.h" -#include "kj/io.h" -#include <memory> -#include "generated/NvBlastExtSerialization.capn.h" - -namespace Nv -{ - namespace Blast - { - /* - A wrapper around a Capn Proto Data reader. - - Since it needs to behave like a stream, it's internally wrapped in a stream. - - */ - class ExtKJPxInputStream : public physx::PxInputStream - { - public: - ExtKJPxInputStream(capnp::Data::Reader inReader); - ~ExtKJPxInputStream() = default; - - virtual uint32_t read(void* dest, uint32_t count) override; - - private: - capnp::Data::Reader dataReader; - std::shared_ptr<kj::ArrayInputStream> inputStream; - }; - } -} diff --git a/NvBlast/sdk/extensions/serialization/source/NvBlastExtKJPxOutputStream.cpp b/NvBlast/sdk/extensions/serialization/source/NvBlastExtKJPxOutputStream.cpp deleted file mode 100644 index 0f17a01..0000000 --- a/NvBlast/sdk/extensions/serialization/source/NvBlastExtKJPxOutputStream.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* -* 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 "NvBlastExtKJPxOutputStream.h" - -namespace Nv -{ - namespace Blast - { - ExtKJPxOutputStream::ExtKJPxOutputStream(kj::ArrayPtr<unsigned char> inBuffer) : - writtenBytes(0), - Buffer(inBuffer), - outputStream(nullptr) - { - outputStream = std::make_shared<kj::ArrayOutputStream>(inBuffer); - } - - uint32_t ExtKJPxOutputStream::write(const void* src, uint32_t count) - { - outputStream->write(src, count); - - writtenBytes += count; - - return count; - } - } -} - diff --git a/NvBlast/sdk/extensions/serialization/source/NvBlastExtKJPxOutputStream.h b/NvBlast/sdk/extensions/serialization/source/NvBlastExtKJPxOutputStream.h deleted file mode 100644 index 0ed563f..0000000 --- a/NvBlast/sdk/extensions/serialization/source/NvBlastExtKJPxOutputStream.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -* 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 "PxIO.h" -#include "kj/common.h" -#include <memory> -#include "kj/io.h" - -namespace Nv -{ - namespace Blast - { - class ExtKJPxOutputStream : public physx::PxOutputStream - { - public: - ExtKJPxOutputStream(kj::ArrayPtr<unsigned char> inBuffer); - ~ExtKJPxOutputStream() = default; - - virtual uint32_t write(const void* src, uint32_t count) override; - - uint32_t getWrittenBytes() { return writtenBytes; } - - kj::ArrayPtr<unsigned char> getBuffer() { return Buffer; } - - private: - uint32_t writtenBytes; - - kj::ArrayPtr<unsigned char> Buffer; - std::shared_ptr<kj::ArrayOutputStream> outputStream; - }; - } -} diff --git a/NvBlast/sdk/extensions/serialization/source/NvBlastExtOutputStream.cpp b/NvBlast/sdk/extensions/serialization/source/NvBlastExtOutputStream.cpp deleted file mode 100644 index cf6e31f..0000000 --- a/NvBlast/sdk/extensions/serialization/source/NvBlastExtOutputStream.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* -* 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 "NvBlastExtOutputStream.h" - - - -Nv::Blast::ExtOutputStream::ExtOutputStream(std::ostream &outputStream): - m_outputStream(outputStream) -{ - -} - -void Nv::Blast::ExtOutputStream::write(const void* buffer, size_t size) -{ - m_outputStream.write((char *) buffer, size); -} diff --git a/NvBlast/sdk/extensions/serialization/source/NvBlastExtOutputStream.h b/NvBlast/sdk/extensions/serialization/source/NvBlastExtOutputStream.h deleted file mode 100644 index ba0044e..0000000 --- a/NvBlast/sdk/extensions/serialization/source/NvBlastExtOutputStream.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -* 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 "kj/io.h" -#include <ostream> - -namespace Nv -{ - namespace Blast - { - class ExtOutputStream : public kj::OutputStream - { - - public: - ExtOutputStream() = delete; - ExtOutputStream(std::ostream &outputStream); - - virtual void write(const void* buffer, size_t size) override; - private: - std::ostream &m_outputStream; - }; - } -} diff --git a/NvBlast/sdk/extensions/serialization/source/NvBlastExtSerialization.capn b/NvBlast/sdk/extensions/serialization/source/NvBlastExtSerialization.capn deleted file mode 100644 index ddc439a..0000000 --- a/NvBlast/sdk/extensions/serialization/source/NvBlastExtSerialization.capn +++ /dev/null @@ -1,95 +0,0 @@ -# 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. - -@0xaffe4498f275ee58; - -using Cxx = import "/capnp/c++.capnp"; - -using LL = import "NvBlastExtSerializationLL.capn"; - -$Cxx.namespace("Nv::Blast::Serialization"); - -struct TkAsset -{ - assetLL @0 :LL.Asset; - - jointDescs @1 :List(TkAssetJointDesc); -} - -struct ExtPxAsset -{ - asset @0 :TkAsset; - chunks @1 :List(ExtPxChunk); - subchunks @2 :List(ExtPxSubchunk); -} - -struct ExtPxChunk -{ - firstSubchunkIndex @0 :UInt32; - subchunkCount @1 :UInt32; - isStatic @2 :Bool; -} - -struct ExtPxSubchunk -{ - transform @0 :PxTransform; - geometry @1 :PxConvexMeshGeometry; -} - -struct PxConvexMeshGeometry -{ - scale @0 :PxMeshScale; - convexMesh @1 :Data; - meshFlags @2 :UInt8; - - enum Type - { - eSPHERE @0; - ePLANE @1; - eCAPSULE @2; - eBOX @3; - eCONVEXMESH @4; - eTRIANGLEMESH @5; - eHEIGHTFIELD @6; - } - - type @3 :Type; -} - -struct TkAssetJointDesc -{ - nodeIndices @0 :List(UInt32); - attachPositions @1 :List(PxVec3); -} - -struct PxVec3 -{ - x @0 :Float32; - y @1 :Float32; - z @2 :Float32; -} - -struct PxQuat -{ - x @0 :Float32; - y @1 :Float32; - z @2 :Float32; - w @3 :Float32; -} - -struct PxMeshScale -{ - scale @0 :PxVec3; - rotation @1 :PxQuat; -} - -struct PxTransform -{ - q @0 :PxQuat; - p @1 :PxVec3; -} diff --git a/NvBlast/sdk/extensions/serialization/source/NvBlastExtSerialization.cpp b/NvBlast/sdk/extensions/serialization/source/NvBlastExtSerialization.cpp deleted file mode 100644 index 28a1553..0000000 --- a/NvBlast/sdk/extensions/serialization/source/NvBlastExtSerialization.cpp +++ /dev/null @@ -1,146 +0,0 @@ -#include "NvBlastExtSerialization.h" -#include "BlastSerialization.h" -#include <memory> -#include "PxPhysicsVersion.h" -#include "PxConvexMeshGeometryDTO.h" -#include "NvBlastExtDefs.h" - - -// This is terrible. -physx::PxPhysics* g_Physics = nullptr; - - -std::shared_ptr<physx::PxCooking> getCooking() -{ - physx::PxCookingParams cookingParams(g_Physics->getTolerancesScale()); - cookingParams.buildGPUData = true; - - std::shared_ptr<physx::PxCooking> m_Cooking = std::shared_ptr<physx::PxCooking>(PxCreateCooking(PX_PHYSICS_VERSION, g_Physics->getFoundation(), cookingParams), [=](physx::PxCooking* cooking) - { - cooking->release(); - }); - - NVBLASTEXT_CHECK_ERROR(m_Cooking, "Error: failed to create PhysX Cooking\n", return nullptr); - - return m_Cooking; -} - - -extern "C" -{ - NVBLAST_API void setPhysXSDK(physx::PxPhysics* physXSDK) - { - g_Physics = physXSDK; - } - - NVBLAST_API NvBlastAsset* deserializeAsset(const unsigned char* input, uint32_t size) - { - return Nv::Blast::BlastSerialization<Nv::Blast::Asset, Nv::Blast::Serialization::Asset::Reader, Nv::Blast::Serialization::Asset::Builder>::deserialize(input, size); - } - - NVBLAST_API NvBlastAsset* deserializeAssetFromStream(std::istream &inputStream) - { - return Nv::Blast::BlastSerialization<Nv::Blast::Asset, Nv::Blast::Serialization::Asset::Reader, Nv::Blast::Serialization::Asset::Builder>::deserializeFromStream(inputStream); - } - - NVBLAST_API bool serializeAssetIntoStream(const NvBlastAsset *asset, std::ostream &outputStream) - { - return Nv::Blast::BlastSerialization<Nv::Blast::Asset, Nv::Blast::Serialization::Asset::Reader, Nv::Blast::Serialization::Asset::Builder>::serializeIntoStream(reinterpret_cast<const Nv::Blast::Asset *>(asset), outputStream); - } - - NVBLAST_API bool serializeAssetIntoNewBuffer(const NvBlastAsset *asset, unsigned char **outBuffer, uint32_t &outSize) - { - return Nv::Blast::BlastSerialization<Nv::Blast::Asset, Nv::Blast::Serialization::Asset::Reader, Nv::Blast::Serialization::Asset::Builder>::serializeIntoNewBuffer(reinterpret_cast<const Nv::Blast::Asset *>(asset), outBuffer, outSize); - } - - NVBLAST_API bool serializeAssetIntoExistingBuffer(const NvBlastAsset *asset, unsigned char *buffer, uint32_t maxSize, uint32_t &usedSize) - { - return Nv::Blast::BlastSerialization<Nv::Blast::Asset, Nv::Blast::Serialization::Asset::Reader, Nv::Blast::Serialization::Asset::Builder>::serializeIntoExistingBuffer(reinterpret_cast<const Nv::Blast::Asset *>(asset), buffer, maxSize, usedSize); - } - - ////////////////////////////////////////////////////////////////////////// - // TkAsset - ////////////////////////////////////////////////////////////////////////// - - NVBLAST_API Nv::Blast::TkAsset* deserializeTkAsset(const unsigned char* input, uint32_t size) - { - return Nv::Blast::BlastSerialization<Nv::Blast::TkAsset, Nv::Blast::Serialization::TkAsset::Reader, Nv::Blast::Serialization::TkAsset::Builder>::deserialize(input, size); - } - - NVBLAST_API Nv::Blast::TkAsset* deserializeTkAssetFromStream(std::istream &inputStream) - { - return Nv::Blast::BlastSerialization<Nv::Blast::TkAsset, Nv::Blast::Serialization::TkAsset::Reader, Nv::Blast::Serialization::TkAsset::Builder>::deserializeFromStream(inputStream); - } - - NVBLAST_API bool serializeTkAssetIntoStream(const Nv::Blast::TkAsset *asset, std::ostream &outputStream) - { - return Nv::Blast::BlastSerialization<Nv::Blast::TkAsset, Nv::Blast::Serialization::TkAsset::Reader, Nv::Blast::Serialization::TkAsset::Builder>::serializeIntoStream(reinterpret_cast<const Nv::Blast::TkAsset *>(asset), outputStream); - } - - NVBLAST_API bool serializeTkAssetIntoNewBuffer(const Nv::Blast::TkAsset *asset, unsigned char **outBuffer, uint32_t &outSize) - { - return Nv::Blast::BlastSerialization<Nv::Blast::TkAsset, Nv::Blast::Serialization::TkAsset::Reader, Nv::Blast::Serialization::TkAsset::Builder>::serializeIntoNewBuffer(reinterpret_cast<const Nv::Blast::TkAsset *>(asset), outBuffer, outSize); - } - - NVBLAST_API bool serializeTkAssetIntoExistingBuffer(const Nv::Blast::TkAsset *asset, unsigned char *buffer, uint32_t maxSize, uint32_t &usedSize) - { - return Nv::Blast::BlastSerialization<Nv::Blast::TkAsset, Nv::Blast::Serialization::TkAsset::Reader, Nv::Blast::Serialization::TkAsset::Builder>::serializeIntoExistingBuffer(reinterpret_cast<const Nv::Blast::TkAsset *>(asset), buffer, maxSize, usedSize); - } - - ////////////////////////////////////////////////////////////////////////// - // ExtPxAsset - ////////////////////////////////////////////////////////////////////////// - - NVBLAST_API Nv::Blast::ExtPxAsset* deserializeExtPxAsset(const unsigned char* input, uint32_t size) - { - NVBLAST_ASSERT(g_Physics != nullptr); - - return Nv::Blast::BlastSerialization<Nv::Blast::ExtPxAsset, Nv::Blast::Serialization::ExtPxAsset::Reader, Nv::Blast::Serialization::ExtPxAsset::Builder>::deserialize(input, size); - } - - NVBLAST_API Nv::Blast::ExtPxAsset* deserializeExtPxAssetFromStream(std::istream &inputStream) - { - NVBLAST_ASSERT(g_Physics != nullptr); - - return Nv::Blast::BlastSerialization<Nv::Blast::ExtPxAsset, Nv::Blast::Serialization::ExtPxAsset::Reader, Nv::Blast::Serialization::ExtPxAsset::Builder>::deserializeFromStream(inputStream); - } - - NVBLAST_API bool serializeExtPxAssetIntoStream(const Nv::Blast::ExtPxAsset *asset, std::ostream &outputStream) - { - NVBLAST_ASSERT(g_Physics != nullptr); - - auto cooking = getCooking(); - - PxConvexMeshGeometryDTO::Cooking = cooking.get(); - PxConvexMeshGeometryDTO::Physics = g_Physics; - - return Nv::Blast::BlastSerialization<Nv::Blast::ExtPxAsset, Nv::Blast::Serialization::ExtPxAsset::Reader, Nv::Blast::Serialization::ExtPxAsset::Builder>::serializeIntoStream(reinterpret_cast<const Nv::Blast::ExtPxAsset *>(asset), outputStream); - } - - NVBLAST_API bool serializeExtPxAssetIntoNewBuffer(const Nv::Blast::ExtPxAsset *asset, unsigned char **outBuffer, uint32_t &outSize) - { - NVBLAST_ASSERT(g_Physics != nullptr); - - auto cooking = getCooking(); - - PxConvexMeshGeometryDTO::Cooking = cooking.get(); - PxConvexMeshGeometryDTO::Physics = g_Physics; - - return Nv::Blast::BlastSerialization<Nv::Blast::ExtPxAsset, Nv::Blast::Serialization::ExtPxAsset::Reader, Nv::Blast::Serialization::ExtPxAsset::Builder>::serializeIntoNewBuffer(reinterpret_cast<const Nv::Blast::ExtPxAsset *>(asset), outBuffer, outSize); - } - - NVBLAST_API bool serializeExtPxAssetIntoExistingBuffer(const Nv::Blast::ExtPxAsset *asset, unsigned char *buffer, uint32_t maxSize, uint32_t &usedSize) - { - NVBLAST_ASSERT(g_Physics != nullptr); - - auto cooking = getCooking(); - - PxConvexMeshGeometryDTO::Cooking = cooking.get(); - PxConvexMeshGeometryDTO::Physics = g_Physics; - - return Nv::Blast::BlastSerialization<Nv::Blast::ExtPxAsset, Nv::Blast::Serialization::ExtPxAsset::Reader, Nv::Blast::Serialization::ExtPxAsset::Builder>::serializeIntoExistingBuffer(reinterpret_cast<const Nv::Blast::ExtPxAsset *>(asset), buffer, maxSize, usedSize); - } - - -} - diff --git a/NvBlast/sdk/extensions/serialization/source/NvBlastExtSerialization.h b/NvBlast/sdk/extensions/serialization/source/NvBlastExtSerialization.h deleted file mode 100644 index 5d44554..0000000 --- a/NvBlast/sdk/extensions/serialization/source/NvBlastExtSerialization.h +++ /dev/null @@ -1,172 +0,0 @@ -/* -* 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 "kj/io.h" -#include "capnp/serialize.h" -#include "generated/NvBlastExtSerializationLL.capn.h" -#include <vector> -#include "NvBlastExtInputStream.h" -#include "NvBlastExtOutputStream.h" - -#if !defined(BLAST_LL_ALLOC) -#include "NvBlastExtAllocator.h" -#endif -#include "NvBlastExtGlobals.h" - -namespace Nv -{ - namespace Blast - { - template<typename TAsset, typename TSerializationReader, typename TSerializationBuilder> - class ExtSerialization - { - public: - static TAsset* deserialize(const unsigned char* input, uint32_t size); - static TAsset* deserializeFromStream(std::istream &inputStream); - - static bool serializeIntoExistingBuffer(const TAsset *asset, unsigned char *buffer, uint32_t maxSize, uint32_t &usedSize); - static bool serializeIntoNewBuffer(const TAsset *asset, unsigned char **outBuffer, uint32_t &outSize); - static bool serializeIntoStream(const TAsset *asset, std::ostream &outputStream); - - private: - - static void serializeMessageIntoNewBuffer(capnp::MallocMessageBuilder& message, unsigned char ** outBuffer, uint32_t &outSize); - - // Specialized - static bool serializeIntoBuilder(TSerializationBuilder& assetBuilder, const TAsset* asset); - static bool serializeIntoMessage(capnp::MallocMessageBuilder& message, const TAsset* asset); - static TAsset* deserializeFromStreamReader(capnp::InputStreamMessageReader &message); - }; - - template<typename TAsset, typename TSerializationReader, typename TSerializationBuilder> - TAsset* ExtSerialization<TAsset, TSerializationReader, TSerializationBuilder>::deserialize(const unsigned char* input, uint32_t size) - { - kj::ArrayPtr<const unsigned char> source(input, size); - - kj::ArrayInputStream inputStream(source); - - std::vector<uint64_t> scratch; - scratch.resize(size); - kj::ArrayPtr<capnp::word> scratchArray((capnp::word*) scratch.data(), size); - - capnp::InputStreamMessageReader message(inputStream, capnp::ReaderOptions(), scratchArray); - - return deserializeFromStreamReader(message); - } - - template<typename TAsset, typename TSerializationReader, typename TSerializationBuilder> - TAsset* ExtSerialization<TAsset, TSerializationReader, TSerializationBuilder>::deserializeFromStream(std::istream &inputStream) - { - Nv::Blast::ExtInputStream readStream(inputStream); - - capnp::InputStreamMessageReader message(readStream); - - return deserializeFromStreamReader(message); - } - - template<typename TAsset, typename TSerializationReader, typename TSerializationBuilder> - bool ExtSerialization<TAsset, TSerializationReader, TSerializationBuilder>::serializeIntoExistingBuffer(const TAsset *asset, unsigned char *buffer, uint32_t maxSize, uint32_t &usedSize) - { - capnp::MallocMessageBuilder message; - - bool result = serializeIntoMessage(message, asset); - - if (result == false) - { - usedSize = 0; - return false; - } - - uint32_t messageSize = computeSerializedSizeInWords(message) * sizeof(uint64_t); - - if (maxSize < messageSize) - { - NvBlastLog logFn = gLog; - -#if !defined(BLAST_LL_ALLOC) - logFn = NvBlastTkFrameworkGet()->getLogFn(); -#endif - - NVBLAST_LOG_ERROR(logFn, "When attempting to serialize into an existing buffer, the provided buffer was too small."); - usedSize = 0; - return false; - } - - kj::ArrayPtr<unsigned char> outputBuffer(buffer, maxSize); - kj::ArrayOutputStream outputStream(outputBuffer); - - capnp::writeMessage(outputStream, message); - - usedSize = messageSize;; - return true; - } - - template<typename TAsset, typename TSerializationReader, typename TSerializationBuilder> - bool ExtSerialization<TAsset, TSerializationReader, TSerializationBuilder>::serializeIntoNewBuffer(const TAsset *asset, unsigned char **outBuffer, uint32_t &outSize) - { - capnp::MallocMessageBuilder message; - - bool result = serializeIntoMessage(message, asset); - - if (result == false) - { - *outBuffer = nullptr; - outSize = 0; - return false; - } - - serializeMessageIntoNewBuffer(message, outBuffer, outSize); - - return true; - } - - template<typename TAsset, typename TSerializationReader, typename TSerializationBuilder> - bool ExtSerialization<TAsset, TSerializationReader, TSerializationBuilder>::serializeIntoStream(const TAsset *asset, std::ostream &outputStream) - { - capnp::MallocMessageBuilder message; - - bool result = serializeIntoMessage(message, asset); - - if (result == false) - { - return false; - } - - Nv::Blast::ExtOutputStream blastOutputStream(outputStream); - - writeMessage(blastOutputStream, message); - - return true; - } - - template<typename TAsset, typename TSerializationReader, typename TSerializationBuilder> - void ExtSerialization<TAsset, TSerializationReader, TSerializationBuilder>::serializeMessageIntoNewBuffer(capnp::MallocMessageBuilder& message, unsigned char ** outBuffer, uint32_t &outSize) - { - uint32_t messageSize = computeSerializedSizeInWords(message) * sizeof(uint64_t); - - NvBlastExtAlloc allocFn = gAlloc; - -#if !defined(BLAST_LL_ALLOC) - allocFn = ExtAllocator::alignedAlloc16; -#endif - - unsigned char* buffer = static_cast<unsigned char *>(allocFn(messageSize)); - - kj::ArrayPtr<unsigned char> outputBuffer(buffer, messageSize); - kj::ArrayOutputStream outputStream(outputBuffer); - - capnp::writeMessage(outputStream, message); - - *outBuffer = buffer; - outSize = messageSize; - } - } -} diff --git a/NvBlast/sdk/extensions/serialization/source/NvBlastExtSerializationImpl.h b/NvBlast/sdk/extensions/serialization/source/NvBlastExtSerializationImpl.h deleted file mode 100644 index 7f9fbc9..0000000 --- a/NvBlast/sdk/extensions/serialization/source/NvBlastExtSerializationImpl.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -* 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 "NvBlastExtSerialization.h" -#include "NvBlastTkAsset.h" -#include "NvBlastExtPxAsset.h" -#include "TkAssetDTO.h" -#include "ExtPxAssetDTO.h" - -namespace Nv -{ - namespace Blast - { - /* - Specializations here - one set for each top level asset. (TkAsset, ExtPxAsset) - */ - - - // TkAsset - template<> - NV_INLINE bool ExtSerialization<Nv::Blast::TkAsset, Nv::Blast::Serialization::TkAsset::Reader, Nv::Blast::Serialization::TkAsset::Builder>::serializeIntoBuilder(Nv::Blast::Serialization::TkAsset::Builder& assetBuilder, const Nv::Blast::TkAsset* asset) - { - return TkAssetDTO::serialize(assetBuilder, asset); - } - - template<> - NV_INLINE Nv::Blast::TkAsset* ExtSerialization<Nv::Blast::TkAsset, Nv::Blast::Serialization::TkAsset::Reader, Nv::Blast::Serialization::TkAsset::Builder>::deserializeFromStreamReader(capnp::InputStreamMessageReader &message) - { - Nv::Blast::Serialization::TkAsset::Reader reader = message.getRoot<Nv::Blast::Serialization::TkAsset>(); - - return TkAssetDTO::deserialize(reader); - } - - template<> - NV_INLINE bool ExtSerialization<Nv::Blast::TkAsset, Nv::Blast::Serialization::TkAsset::Reader, Nv::Blast::Serialization::TkAsset::Builder>::serializeIntoMessage(capnp::MallocMessageBuilder& message, const Nv::Blast::TkAsset* asset) - { - Nv::Blast::Serialization::TkAsset::Builder assetBuilder = message.initRoot<Nv::Blast::Serialization::TkAsset>(); - - return serializeIntoBuilder(assetBuilder, asset); - } - - - //ExtPxAsset - template<> - NV_INLINE bool ExtSerialization<Nv::Blast::ExtPxAsset, Nv::Blast::Serialization::ExtPxAsset::Reader, Nv::Blast::Serialization::ExtPxAsset::Builder>::serializeIntoBuilder(Nv::Blast::Serialization::ExtPxAsset::Builder& assetBuilder, const Nv::Blast::ExtPxAsset* asset) - { - return ExtPxAssetDTO::serialize(assetBuilder, asset); - } - - template<> - NV_INLINE Nv::Blast::ExtPxAsset* ExtSerialization<Nv::Blast::ExtPxAsset, Nv::Blast::Serialization::ExtPxAsset::Reader, Nv::Blast::Serialization::ExtPxAsset::Builder>::deserializeFromStreamReader(capnp::InputStreamMessageReader &message) - { - Nv::Blast::Serialization::ExtPxAsset::Reader reader = message.getRoot<Nv::Blast::Serialization::ExtPxAsset>(); - - return ExtPxAssetDTO::deserialize(reader); - } - - template<> - NV_INLINE bool ExtSerialization<Nv::Blast::ExtPxAsset, Nv::Blast::Serialization::ExtPxAsset::Reader, Nv::Blast::Serialization::ExtPxAsset::Builder>::serializeIntoMessage(capnp::MallocMessageBuilder& message, const Nv::Blast::ExtPxAsset* asset) - { - Nv::Blast::Serialization::ExtPxAsset::Builder assetBuilder = message.initRoot<Nv::Blast::Serialization::ExtPxAsset>(); - - return serializeIntoBuilder(assetBuilder, asset); - } - } -} diff --git a/NvBlast/sdk/extensions/serialization/source/NvBlastExtSerializationInterface.cpp b/NvBlast/sdk/extensions/serialization/source/NvBlastExtSerializationInterface.cpp deleted file mode 100644 index bebee5b..0000000 --- a/NvBlast/sdk/extensions/serialization/source/NvBlastExtSerializationInterface.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* -* 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 "NvBlastExtSerializationImpl.h" -#include <memory> -#include "PxPhysicsVersion.h" -#include "PxConvexMeshGeometryDTO.h" -#include "NvBlastExtDefs.h" -#include "PxPhysics.h" -#include "NvBlastAssert.h" - - -// This is terrible. -physx::PxPhysics* g_Physics = nullptr; - -using namespace Nv::Blast; - -std::shared_ptr<physx::PxCooking> getCooking() -{ - physx::PxCookingParams cookingParams(g_Physics->getTolerancesScale()); - cookingParams.buildGPUData = true; - - std::shared_ptr<physx::PxCooking> m_Cooking = std::shared_ptr<physx::PxCooking>(PxCreateCooking(PX_PHYSICS_VERSION, g_Physics->getFoundation(), cookingParams), [=](physx::PxCooking* cooking) - { - cooking->release(); - }); - - NVBLASTEXT_CHECK_ERROR(m_Cooking, "Error: failed to create PhysX Cooking\n", return nullptr); - - return m_Cooking; -} - - -extern "C" -{ - NVBLAST_API void setPhysXSDK(physx::PxPhysics* physXSDK) - { - g_Physics = physXSDK; - } - - ////////////////////////////////////////////////////////////////////////// - // TkAsset - ////////////////////////////////////////////////////////////////////////// - - NVBLAST_API Nv::Blast::TkAsset* deserializeTkAsset(const unsigned char* input, uint32_t size) - { - return Nv::Blast::ExtSerialization<Nv::Blast::TkAsset, Nv::Blast::Serialization::TkAsset::Reader, Nv::Blast::Serialization::TkAsset::Builder>::deserialize(input, size); - } - - NVBLAST_API Nv::Blast::TkAsset* deserializeTkAssetFromStream(std::istream &inputStream) - { - return Nv::Blast::ExtSerialization<Nv::Blast::TkAsset, Nv::Blast::Serialization::TkAsset::Reader, Nv::Blast::Serialization::TkAsset::Builder>::deserializeFromStream(inputStream); - } - - NVBLAST_API bool serializeTkAssetIntoStream(const Nv::Blast::TkAsset *asset, std::ostream &outputStream) - { - return Nv::Blast::ExtSerialization<Nv::Blast::TkAsset, Nv::Blast::Serialization::TkAsset::Reader, Nv::Blast::Serialization::TkAsset::Builder>::serializeIntoStream(reinterpret_cast<const Nv::Blast::TkAsset *>(asset), outputStream); - } - - NVBLAST_API bool serializeTkAssetIntoNewBuffer(const Nv::Blast::TkAsset *asset, unsigned char **outBuffer, uint32_t &outSize) - { - return Nv::Blast::ExtSerialization<Nv::Blast::TkAsset, Nv::Blast::Serialization::TkAsset::Reader, Nv::Blast::Serialization::TkAsset::Builder>::serializeIntoNewBuffer(reinterpret_cast<const Nv::Blast::TkAsset *>(asset), outBuffer, outSize); - } - - NVBLAST_API bool serializeTkAssetIntoExistingBuffer(const Nv::Blast::TkAsset *asset, unsigned char *buffer, uint32_t maxSize, uint32_t &usedSize) - { - return Nv::Blast::ExtSerialization<Nv::Blast::TkAsset, Nv::Blast::Serialization::TkAsset::Reader, Nv::Blast::Serialization::TkAsset::Builder>::serializeIntoExistingBuffer(reinterpret_cast<const Nv::Blast::TkAsset *>(asset), buffer, maxSize, usedSize); - } - - ////////////////////////////////////////////////////////////////////////// - // ExtPxAsset - ////////////////////////////////////////////////////////////////////////// - - NVBLAST_API Nv::Blast::ExtPxAsset* deserializeExtPxAsset(const unsigned char* input, uint32_t size) - { - NVBLAST_ASSERT(g_Physics != nullptr); - - return Nv::Blast::ExtSerialization<Nv::Blast::ExtPxAsset, Nv::Blast::Serialization::ExtPxAsset::Reader, Nv::Blast::Serialization::ExtPxAsset::Builder>::deserialize(input, size); - } - - NVBLAST_API Nv::Blast::ExtPxAsset* deserializeExtPxAssetFromStream(std::istream &inputStream) - { - NVBLAST_ASSERT(g_Physics != nullptr); - - return Nv::Blast::ExtSerialization<Nv::Blast::ExtPxAsset, Nv::Blast::Serialization::ExtPxAsset::Reader, Nv::Blast::Serialization::ExtPxAsset::Builder>::deserializeFromStream(inputStream); - } - - NVBLAST_API bool serializeExtPxAssetIntoStream(const Nv::Blast::ExtPxAsset *asset, std::ostream &outputStream) - { - NVBLAST_ASSERT(g_Physics != nullptr); - - auto cooking = getCooking(); - - PxConvexMeshGeometryDTO::Cooking = cooking.get(); - PxConvexMeshGeometryDTO::Physics = g_Physics; - - return Nv::Blast::ExtSerialization<Nv::Blast::ExtPxAsset, Nv::Blast::Serialization::ExtPxAsset::Reader, Nv::Blast::Serialization::ExtPxAsset::Builder>::serializeIntoStream(reinterpret_cast<const Nv::Blast::ExtPxAsset *>(asset), outputStream); - } - - NVBLAST_API bool serializeExtPxAssetIntoNewBuffer(const Nv::Blast::ExtPxAsset *asset, unsigned char **outBuffer, uint32_t &outSize) - { - NVBLAST_ASSERT(g_Physics != nullptr); - - auto cooking = getCooking(); - - PxConvexMeshGeometryDTO::Cooking = cooking.get(); - PxConvexMeshGeometryDTO::Physics = g_Physics; - - return Nv::Blast::ExtSerialization<Nv::Blast::ExtPxAsset, Nv::Blast::Serialization::ExtPxAsset::Reader, Nv::Blast::Serialization::ExtPxAsset::Builder>::serializeIntoNewBuffer(reinterpret_cast<const Nv::Blast::ExtPxAsset *>(asset), outBuffer, outSize); - } - - NVBLAST_API bool serializeExtPxAssetIntoExistingBuffer(const Nv::Blast::ExtPxAsset *asset, unsigned char *buffer, uint32_t maxSize, uint32_t &usedSize) - { - NVBLAST_ASSERT(g_Physics != nullptr); - - auto cooking = getCooking(); - - PxConvexMeshGeometryDTO::Cooking = cooking.get(); - PxConvexMeshGeometryDTO::Physics = g_Physics; - - return Nv::Blast::ExtSerialization<Nv::Blast::ExtPxAsset, Nv::Blast::Serialization::ExtPxAsset::Reader, Nv::Blast::Serialization::ExtPxAsset::Builder>::serializeIntoExistingBuffer(reinterpret_cast<const Nv::Blast::ExtPxAsset *>(asset), buffer, maxSize, usedSize); - } - - -} - diff --git a/NvBlast/sdk/extensions/serialization/source/NvBlastExtSerializationLL.capn b/NvBlast/sdk/extensions/serialization/source/NvBlastExtSerializationLL.capn deleted file mode 100644 index 026056f..0000000 --- a/NvBlast/sdk/extensions/serialization/source/NvBlastExtSerializationLL.capn +++ /dev/null @@ -1,89 +0,0 @@ -# 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. - -@0x9a4a58fac38375e0; - -using Cxx = import "/capnp/c++.capnp"; - -$Cxx.namespace("Nv::Blast::Serialization"); - -struct Asset -{ - header @0 :NvBlastDataBlock; - - iD @1 :UUID; - - chunkCount @2 :UInt32; - - graph @3 :NvBlastSupportGraph; - - leafChunkCount @4 :UInt32; - - firstSubsupportChunkIndex @5 :UInt32; - - bondCount @6 :UInt32; - - chunks @7: List(NvBlastChunk); - - bonds @8: List(NvBlastBond); - - subtreeLeafChunkCounts @9: List(UInt32); - - chunkToGraphNodeMap @10: List(UInt32); -} - -struct NvBlastDataBlock -{ - enum Type - { - assetDataBlock @0; - instanceDataBlock @1; - } - - dataType @0 :Type; - - formatVersion @1 :UInt32; - - size @2 :UInt32; -} - -struct NvBlastChunk -{ - centroid @0 :List(Float32); - - volume @1 :Float32; - - parentChunkIndex @2 :UInt32; - firstChildIndex @3 :UInt32; - childIndexStop @4 :UInt32; - userData @5 :UInt32; -} - -struct NvBlastBond -{ - normal @0 :List(Float32); - area @1 :Float32; - centroid @2 :List(Float32); - userData @3 :UInt32; -} - -struct NvBlastSupportGraph -{ - nodeCount @0 : UInt32; - - chunkIndices @1 : List(UInt32); - adjacencyPartition @2 : List(UInt32); - adjacentNodeIndices @3 : List(UInt32); - adjacentBondIndices @4 : List(UInt32); -} - -struct UUID -{ - value @0 : Data; -} - diff --git a/NvBlast/sdk/extensions/serialization/source/NvBlastExtSerializationLLImpl.h b/NvBlast/sdk/extensions/serialization/source/NvBlastExtSerializationLLImpl.h deleted file mode 100644 index d7595ba..0000000 --- a/NvBlast/sdk/extensions/serialization/source/NvBlastExtSerializationLLImpl.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -* 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 "NvBlastExtSerialization.h" -#include "NvBlastAsset.h" -#include "AssetDTO.h" - -namespace Nv -{ - namespace Blast - { - /* - Specializations here - LL asset only - */ - - // Asset - template<> - NV_INLINE bool ExtSerialization<Nv::Blast::Asset, Nv::Blast::Serialization::Asset::Reader, Nv::Blast::Serialization::Asset::Builder>::serializeIntoBuilder(Nv::Blast::Serialization::Asset::Builder& assetBuilder, const Nv::Blast::Asset* asset) - { - return AssetDTO::serialize(assetBuilder, asset); - } - - template<> - NV_INLINE Nv::Blast::Asset* ExtSerialization<Nv::Blast::Asset, Nv::Blast::Serialization::Asset::Reader, Nv::Blast::Serialization::Asset::Builder>::deserializeFromStreamReader(capnp::InputStreamMessageReader &message) - { - Nv::Blast::Serialization::Asset::Reader reader = message.getRoot<Nv::Blast::Serialization::Asset>(); - - return AssetDTO::deserialize(reader); - } - - template<> - NV_INLINE bool ExtSerialization<Nv::Blast::Asset, Nv::Blast::Serialization::Asset::Reader, Nv::Blast::Serialization::Asset::Builder>::serializeIntoMessage(capnp::MallocMessageBuilder& message, const Nv::Blast::Asset* asset) - { - Nv::Blast::Serialization::Asset::Builder assetBuilder = message.initRoot<Nv::Blast::Serialization::Asset>(); - - return serializeIntoBuilder(assetBuilder, asset); - } - } -} diff --git a/NvBlast/sdk/extensions/serialization/source/NvBlastExtSerializationLLInterface.cpp b/NvBlast/sdk/extensions/serialization/source/NvBlastExtSerializationLLInterface.cpp deleted file mode 100644 index 26d8667..0000000 --- a/NvBlast/sdk/extensions/serialization/source/NvBlastExtSerializationLLInterface.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* -* 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 "NvBlastExtSerializationLLInterface.h" -#include "NvBlastExtSerializationLLImpl.h" -#include <memory> -#include "NvBlastExtSerialization.h" -#include "NvBlastAsset.h" -#include <iostream> -#include "NvBlastExtGlobals.h" - - -NvBlastExtAlloc gAlloc = nullptr; -NvBlastLog gLog = nullptr; - -extern "C" -{ - NVBLAST_API void setAllocator(NvBlastExtAlloc alloc) - { - gAlloc = alloc; - } - - NVBLAST_API void setLog(NvBlastLog log) - { - gLog = log; - } - - NVBLAST_API NvBlastAsset* deserializeAsset(const unsigned char* input, uint32_t size) - { -#if defined(BLAST_LL_ALLOC) - if (gAlloc == nullptr || gLog == nullptr) - { - std::cerr << "Must set allocator and log when using low level serialization library. See setAllocator() and setLog() functions." << std::endl; - return nullptr; - } -#endif - - return Nv::Blast::ExtSerialization<Nv::Blast::Asset, Nv::Blast::Serialization::Asset::Reader, Nv::Blast::Serialization::Asset::Builder>::deserialize(input, size); - } - - NVBLAST_API NvBlastAsset* deserializeAssetFromStream(std::istream &inputStream) - { -#if defined(BLAST_LL_ALLOC) - if (gAlloc == nullptr || gLog == nullptr) - { - std::cerr << "Must set allocator and log when using low level serialization library. See setAllocator() and setLog() functions." << std::endl; - return nullptr; - } -#endif - - return Nv::Blast::ExtSerialization<Nv::Blast::Asset, Nv::Blast::Serialization::Asset::Reader, Nv::Blast::Serialization::Asset::Builder>::deserializeFromStream(inputStream); - } - - NVBLAST_API bool serializeAssetIntoStream(const NvBlastAsset *asset, std::ostream &outputStream) - { -#if defined(BLAST_LL_ALLOC) - if (gAlloc == nullptr || gLog == nullptr) - { - std::cerr << "Must set allocator and log when using low level serialization library. See setAllocator() and setLog() functions." << std::endl; - return false; - } -#endif - - return Nv::Blast::ExtSerialization<Nv::Blast::Asset, Nv::Blast::Serialization::Asset::Reader, Nv::Blast::Serialization::Asset::Builder>::serializeIntoStream(reinterpret_cast<const Nv::Blast::Asset *>(asset), outputStream); - } - - NVBLAST_API bool serializeAssetIntoNewBuffer(const NvBlastAsset *asset, unsigned char **outBuffer, uint32_t &outSize) - { -#if defined(BLAST_LL_ALLOC) - if (gAlloc == nullptr || gLog == nullptr) - { - std::cerr << "Must set allocator and log when using low level serialization library. See setAllocator() and setLog() functions." << std::endl; - return false; - } -#endif - - return Nv::Blast::ExtSerialization<Nv::Blast::Asset, Nv::Blast::Serialization::Asset::Reader, Nv::Blast::Serialization::Asset::Builder>::serializeIntoNewBuffer(reinterpret_cast<const Nv::Blast::Asset *>(asset), outBuffer, outSize); - } - - NVBLAST_API bool serializeAssetIntoExistingBuffer(const NvBlastAsset *asset, unsigned char *buffer, uint32_t maxSize, uint32_t &usedSize) - { -#if defined(BLAST_LL_ALLOC) - if (gAlloc == nullptr || gLog == nullptr) - { - std::cerr << "Must set allocator and log when using low level serialization library. See setAllocator() and setLog() functions." << std::endl; - return false; - } -#endif - - return Nv::Blast::ExtSerialization<Nv::Blast::Asset, Nv::Blast::Serialization::Asset::Reader, Nv::Blast::Serialization::Asset::Builder>::serializeIntoExistingBuffer(reinterpret_cast<const Nv::Blast::Asset *>(asset), buffer, maxSize, usedSize); - } - -} - |