aboutsummaryrefslogtreecommitdiff
path: root/samples/SampleBase
diff options
context:
space:
mode:
authorAnton Novoselov <[email protected]>2017-08-01 12:53:38 +0300
committerAnton Novoselov <[email protected]>2017-08-01 12:53:38 +0300
commit236f03c0b9a4982328ed1201978f7f69d192d9b2 (patch)
treee486f2fa39dba203563895541e92c60ed3e25759 /samples/SampleBase
parentAdded screens to welcome page (diff)
downloadblast-236f03c0b9a4982328ed1201978f7f69d192d9b2.tar.xz
blast-236f03c0b9a4982328ed1201978f7f69d192d9b2.zip
Blast 1.1 release (windows / linux)
see docs/release_notes.txt for details
Diffstat (limited to 'samples/SampleBase')
-rw-r--r--samples/SampleBase/Sample.h39
-rw-r--r--samples/SampleBase/blast/BlastAsset.cpp70
-rw-r--r--samples/SampleBase/blast/BlastAsset.h50
-rw-r--r--samples/SampleBase/blast/BlastAssetBoxes.cpp42
-rw-r--r--samples/SampleBase/blast/BlastAssetBoxes.h36
-rw-r--r--samples/SampleBase/blast/BlastAssetModel.cpp227
-rw-r--r--samples/SampleBase/blast/BlastAssetModel.h41
-rw-r--r--samples/SampleBase/blast/BlastAssetModelSimple.cpp41
-rw-r--r--samples/SampleBase/blast/BlastAssetModelSimple.h38
-rw-r--r--samples/SampleBase/blast/BlastAssetModelSkinned.cpp42
-rw-r--r--samples/SampleBase/blast/BlastAssetModelSkinned.h38
-rw-r--r--samples/SampleBase/blast/BlastController.cpp247
-rw-r--r--samples/SampleBase/blast/BlastController.h57
-rw-r--r--samples/SampleBase/blast/BlastFamily.cpp196
-rw-r--r--samples/SampleBase/blast/BlastFamily.h67
-rw-r--r--samples/SampleBase/blast/BlastFamilyBoxes.cpp35
-rw-r--r--samples/SampleBase/blast/BlastFamilyBoxes.h36
-rw-r--r--samples/SampleBase/blast/BlastFamilyModelSimple.cpp39
-rw-r--r--samples/SampleBase/blast/BlastFamilyModelSimple.h36
-rw-r--r--samples/SampleBase/blast/BlastFamilyModelSkinned.cpp36
-rw-r--r--samples/SampleBase/blast/BlastFamilyModelSkinned.h36
-rw-r--r--samples/SampleBase/blast/BlastModel.cpp102
-rw-r--r--samples/SampleBase/blast/BlastModel.h37
-rw-r--r--samples/SampleBase/blast/BlastReplay.cpp36
-rw-r--r--samples/SampleBase/blast/BlastReplay.h36
-rw-r--r--samples/SampleBase/core/Application.cpp36
-rw-r--r--samples/SampleBase/core/Application.h36
-rw-r--r--samples/SampleBase/core/SampleController.cpp40
-rw-r--r--samples/SampleBase/core/SampleController.h41
-rw-r--r--samples/SampleBase/core/SampleManager.cpp36
-rw-r--r--samples/SampleBase/core/SampleManager.h36
-rw-r--r--samples/SampleBase/physx/PhysXController.cpp196
-rw-r--r--samples/SampleBase/physx/PhysXController.h67
-rw-r--r--samples/SampleBase/renderer/ConvexRenderMesh.cpp36
-rw-r--r--samples/SampleBase/renderer/ConvexRenderMesh.h36
-rw-r--r--samples/SampleBase/renderer/CustomRenderMesh.cpp36
-rw-r--r--samples/SampleBase/renderer/CustomRenderMesh.h36
-rw-r--r--samples/SampleBase/renderer/DebugRenderBuffer.h36
-rw-r--r--samples/SampleBase/renderer/Mesh.cpp35
-rw-r--r--samples/SampleBase/renderer/Mesh.h36
-rw-r--r--samples/SampleBase/renderer/PrimitiveRenderMesh.cpp35
-rw-r--r--samples/SampleBase/renderer/PrimitiveRenderMesh.h36
-rw-r--r--samples/SampleBase/renderer/RenderMaterial.cpp36
-rw-r--r--samples/SampleBase/renderer/RenderMaterial.h36
-rw-r--r--samples/SampleBase/renderer/RenderUtils.h59
-rw-r--r--samples/SampleBase/renderer/Renderable.cpp36
-rw-r--r--samples/SampleBase/renderer/Renderable.h36
-rw-r--r--samples/SampleBase/renderer/Renderer.cpp36
-rw-r--r--samples/SampleBase/renderer/Renderer.h43
-rw-r--r--samples/SampleBase/renderer/RendererHBAO.cpp35
-rw-r--r--samples/SampleBase/renderer/RendererHBAO.h36
-rw-r--r--samples/SampleBase/renderer/RendererShadow.cpp35
-rw-r--r--samples/SampleBase/renderer/RendererShadow.h36
-rw-r--r--samples/SampleBase/renderer/ResourceManager.cpp36
-rw-r--r--samples/SampleBase/renderer/ResourceManager.h36
-rw-r--r--samples/SampleBase/renderer/ShaderUtils.h36
-rw-r--r--samples/SampleBase/renderer/SkinnedRenderMesh.cpp35
-rw-r--r--samples/SampleBase/renderer/SkinnedRenderMesh.h36
-rw-r--r--samples/SampleBase/scene/SampleAssetListParser.cpp48
-rw-r--r--samples/SampleBase/scene/SampleAssetListParser.h36
-rw-r--r--samples/SampleBase/scene/SceneController.cpp106
-rw-r--r--samples/SampleBase/scene/SceneController.h38
-rw-r--r--samples/SampleBase/ui/CommonUIController.cpp36
-rw-r--r--samples/SampleBase/ui/CommonUIController.h36
-rw-r--r--samples/SampleBase/ui/DamageToolController.cpp337
-rw-r--r--samples/SampleBase/ui/DamageToolController.h96
-rw-r--r--samples/SampleBase/utils/PxInputDataFromPxFileBuf.h36
-rw-r--r--samples/SampleBase/utils/SampleProfiler.cpp35
-rw-r--r--samples/SampleBase/utils/SampleProfiler.h36
-rw-r--r--samples/SampleBase/utils/SampleTime.h36
-rw-r--r--samples/SampleBase/utils/UIHelpers.h36
-rw-r--r--samples/SampleBase/utils/Utils.cpp28
-rw-r--r--samples/SampleBase/utils/Utils.h28
73 files changed, 2946 insertions, 1095 deletions
diff --git a/samples/SampleBase/Sample.h b/samples/SampleBase/Sample.h
index c9fa503..701e4a5 100644
--- a/samples/SampleBase/Sample.h
+++ b/samples/SampleBase/Sample.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef SAMPLE_H
#define SAMPLE_H
@@ -21,7 +39,7 @@ struct AssetList
struct BoxAsset
{
BoxAsset() : staticHeight(-std::numeric_limits<float>().infinity()),
- jointAllBonds(false), extents(20, 20, 20)
+ jointAllBonds(false), extents(20, 20, 20), bondFlags(7)
{}
struct Level
@@ -38,6 +56,7 @@ struct AssetList
float staticHeight;
bool jointAllBonds;
std::vector<Level> levels;
+ uint32_t bondFlags;
};
struct ModelAsset
diff --git a/samples/SampleBase/blast/BlastAsset.cpp b/samples/SampleBase/blast/BlastAsset.cpp
index b3b5d84..3900e2c 100644
--- a/samples/SampleBase/blast/BlastAsset.cpp
+++ b/samples/SampleBase/blast/BlastAsset.cpp
@@ -1,25 +1,73 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#include "BlastAsset.h"
#include "NvBlastExtPxAsset.h"
#include "NvBlastTkAsset.h"
+#include <algorithm>
BlastAsset::BlastAsset(Renderer& renderer)
- : m_renderer(renderer)
+ : m_renderer(renderer), m_bondHealthMax(1.0f), m_supportChunkHealthMax(1.0f)
{
}
-void BlastAsset::validate()
+void BlastAsset::initialize()
{
+ // calc max healths
+ const auto& actorDesc = m_pxAsset->getDefaultActorDesc();
+ if (actorDesc.initialBondHealths)
+ {
+ m_bondHealthMax = FLT_MIN;
+ const uint32_t bondCount = m_pxAsset->getTkAsset().getBondCount();
+ for (uint32_t i = 0; i < bondCount; ++i)
+ {
+ m_bondHealthMax = std::max<float>(m_bondHealthMax, actorDesc.initialBondHealths[i]);
+ }
+ }
+ else
+ {
+ m_bondHealthMax = actorDesc.uniformInitialBondHealth;
+ }
+
+ if(actorDesc.initialSupportChunkHealths)
+ {
+ m_supportChunkHealthMax = FLT_MIN;
+ const uint32_t nodeCount = m_pxAsset->getTkAsset().getGraph().nodeCount;
+ for (uint32_t i = 0; i < nodeCount; ++i)
+ {
+ m_supportChunkHealthMax = std::max<float>(m_supportChunkHealthMax, actorDesc.initialSupportChunkHealths[i]);
+ }
+ }
+ else
+ {
+ m_supportChunkHealthMax = actorDesc.uniformInitialLowerSupportChunkHealth;
+ }
}
size_t BlastAsset::getBlastAssetSize() const
diff --git a/samples/SampleBase/blast/BlastAsset.h b/samples/SampleBase/blast/BlastAsset.h
index 4740791..7eafddf 100644
--- a/samples/SampleBase/blast/BlastAsset.h
+++ b/samples/SampleBase/blast/BlastAsset.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef BLAST_ASSET_H
#define BLAST_ASSET_H
@@ -74,11 +92,21 @@ public:
size_t getBlastAssetSize() const;
+ float getBondHealthMax() const
+ {
+ return m_bondHealthMax;
+ }
+
+ float getSupportChunkHealthMax() const
+ {
+ return m_bondHealthMax;
+ }
+
protected:
//////// internal operations ////////
- void validate();
+ void initialize();
//////// input data ////////
@@ -89,6 +117,8 @@ protected:
//////// internal data ////////
ExtPxAsset* m_pxAsset;
+ float m_bondHealthMax;
+ float m_supportChunkHealthMax;
};
diff --git a/samples/SampleBase/blast/BlastAssetBoxes.cpp b/samples/SampleBase/blast/BlastAssetBoxes.cpp
index dfa0138..4bd9766 100644
--- a/samples/SampleBase/blast/BlastAssetBoxes.cpp
+++ b/samples/SampleBase/blast/BlastAssetBoxes.cpp
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#include "BlastAssetBoxes.h"
#include "BlastFamilyBoxes.h"
@@ -23,9 +41,9 @@ BlastAssetBoxes::BlastAssetBoxes(TkFramework& framework, PxPhysics& physics, PxC
// asset desc / tk asset
ExtPxAssetDesc assetDesc;
- assetDesc.chunkDescs = &m_generatorAsset.solverChunks[0];
+ assetDesc.chunkDescs = m_generatorAsset.solverChunks.data();
assetDesc.chunkCount = (uint32_t)m_generatorAsset.solverChunks.size();
- assetDesc.bondDescs = m_generatorAsset.solverBonds.size() > 0 ? &m_generatorAsset.solverBonds[0] : nullptr;
+ assetDesc.bondDescs = m_generatorAsset.solverBonds.data();
assetDesc.bondCount = (uint32_t)m_generatorAsset.solverBonds.size();
std::vector<uint8_t> bondFlags(assetDesc.bondCount);
std::fill(bondFlags.begin(), bondFlags.end(), desc.jointAllBonds ? 1 : 0);
@@ -67,7 +85,7 @@ BlastAssetBoxes::BlastAssetBoxes(TkFramework& framework, PxPhysics& physics, PxC
assetDesc.pxChunks = pxChunks.data();
m_pxAsset = ExtPxAsset::create(assetDesc, framework);
- validate();
+ initialize();
}
diff --git a/samples/SampleBase/blast/BlastAssetBoxes.h b/samples/SampleBase/blast/BlastAssetBoxes.h
index 518e93d..d4f8dd2 100644
--- a/samples/SampleBase/blast/BlastAssetBoxes.h
+++ b/samples/SampleBase/blast/BlastAssetBoxes.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef BLAST_ASSET_BOXES_H
#define BLAST_ASSET_BOXES_H
diff --git a/samples/SampleBase/blast/BlastAssetModel.cpp b/samples/SampleBase/blast/BlastAssetModel.cpp
index c42215e..28ef44d 100644
--- a/samples/SampleBase/blast/BlastAssetModel.cpp
+++ b/samples/SampleBase/blast/BlastAssetModel.cpp
@@ -1,60 +1,229 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#include "BlastAssetModel.h"
#include "Renderer.h"
#include "BlastController.h"
#include "Utils.h"
#include "ResourceManager.h"
-#include "PsFileBuffer.h"
#include "NvBlastExtPxAsset.h"
#include <sstream>
+#include <fstream>
+#include "NvBlastExtExporter.h"
+#include "PxPhysics.h"
+#include <NvBlastGlobals.h>
+#include "NvBlastExtAssetUtils.h"
+#include "NvBlastExtPxAsset.h"
+#include "NvBlastTkAsset.h"
+#include "NvBlastExtSerialization.h"
+#include "NvBlastExtLlSerialization.h"
+#include "NvBlastExtTkSerialization.h"
+#include "NvBlastExtPxSerialization.h"
+#include "NvBlastExtAuthoring.h"
+#include "NvBlastExtAuthoringCollisionBuilder.h"
-
-BlastAssetModel::BlastAssetModel(TkFramework& framework, PxPhysics& physics, PxCooking& cooking, Renderer& renderer, const char* modelName)
+BlastAssetModel::BlastAssetModel(TkFramework& framework, PxPhysics& physics, PxCooking& cooking, ExtSerialization& serialization, Renderer& renderer, const char* modelName)
: BlastAsset(renderer)
{
- ResourceManager& resourceManager = m_renderer.getResourceManager();
+ const float unitConversion = 1.f;
- // Physics Asset
- std::ostringstream blastFileName;
- blastFileName << modelName << ".bpxa";
+ const NvcVec3 inputScale = { unitConversion, unitConversion, unitConversion };
+
+ ResourceManager& resourceManager = m_renderer.getResourceManager();
std::string path;
- if (resourceManager.findFile(blastFileName.str(), path))
- {
- PsFileBuffer fileBuf(path.c_str(), PxFileBuf::OPEN_READ_ONLY);
- m_pxAsset = ExtPxAsset::deserialize(fileBuf, framework, physics);
- ASSERT_PRINT(m_pxAsset != nullptr, "can't load bpxa file");
- }
- else
- {
- ASSERT_PRINT(false, "wrong blastFilename");
- }
// load obj file
std::ostringstream objFileName;
objFileName << modelName << ".obj";
+
if (resourceManager.findFile(objFileName.str(), path))
{
m_model = BlastModel::loadFromFileTinyLoader(path.c_str());
if (!m_model)
{
ASSERT_PRINT(false, "obj load failed");
+ }
+ }
+ else // Obj is not found, try FBX
+ {
+ objFileName.clear();
+ objFileName.str("");
+ objFileName << modelName << ".fbx";
+ if (resourceManager.findFile(objFileName.str(), path))
+ {
+ m_model = BlastModel::loadFromFbxFile(path.c_str());
+ if (!m_model)
+ {
+ ASSERT_PRINT(false, "fbx load failed");
+ }
+
+ }
+ else
+ {
+ ASSERT_PRINT(false, "mesh file not found");
}
}
- else
+
+ for (auto& chunk : m_model->chunks)
{
- ASSERT_PRINT(false, "wrong objFileName");
+ for (auto& mesh : chunk.meshes)
+ {
+ SimpleMesh& smesh = const_cast<SimpleMesh&>(mesh.mesh);
+ smesh.center *= unitConversion;
+ smesh.extents *= unitConversion;
+ for (auto& vertex : smesh.vertices)
+ {
+ vertex.position *= unitConversion;
+ }
+ }
+ }
+
+ // Physics Asset
+
+ // Read file into buffer
+ std::ostringstream blastFileName;
+ blastFileName << modelName << ".blast";
+ if (resourceManager.findFile(blastFileName.str(), path))
+ {
+ std::ifstream stream(path.c_str(), std::ios::binary);
+ std::streampos size = stream.tellg();
+ stream.seekg(0, std::ios::end);
+ size = stream.tellg() - size;
+ stream.seekg(0, std::ios::beg);
+ std::vector<char> buffer(size);
+ stream.read(buffer.data(), buffer.size());
+ stream.close();
+ uint32_t objectTypeID;
+ void* asset = serialization.deserializeFromBuffer(buffer.data(), buffer.size(), &objectTypeID);
+ if (asset == nullptr)
+ {
+ ASSERT_PRINT(asset != nullptr, "can't load .blast file.");
+ }
+ else
+ if (objectTypeID == Nv::Blast::ExtPxObjectTypeID::Asset)
+ {
+ m_pxAsset = reinterpret_cast<ExtPxAsset*>(asset);
+ const TkAsset& tkAsset = m_pxAsset->getTkAsset();
+ NvBlastAsset* llasset = const_cast<NvBlastAsset*>(tkAsset.getAssetLL());
+ NvBlastExtAssetTransformInPlace(llasset, &inputScale, nullptr, nullptr);
+ ExtPxSubchunk* subchunks = const_cast<ExtPxSubchunk*>(m_pxAsset->getSubchunks());
+ for (uint32_t i = 0; i < m_pxAsset->getSubchunkCount(); ++i)
+ {
+ subchunks[i].geometry.scale.scale = PxVec3(unitConversion);
+ }
+ }
+ else
+ {
+ TkAsset* tkAsset = nullptr;
+ if (objectTypeID == Nv::Blast::TkObjectTypeID::Asset)
+ {
+ tkAsset = reinterpret_cast<TkAsset*>(asset);
+ NvBlastAsset* llasset = const_cast<NvBlastAsset*>(tkAsset->getAssetLL());
+ NvBlastExtAssetTransformInPlace(llasset, &inputScale, nullptr, nullptr);
+ }
+ else
+ if (objectTypeID == Nv::Blast::LlObjectTypeID::Asset)
+ {
+ NvBlastAsset* llasset = reinterpret_cast<NvBlastAsset*>(asset);
+ NvBlastExtAssetTransformInPlace(llasset, &inputScale, nullptr, nullptr);
+ tkAsset = framework.createAsset(llasset, nullptr, 0, true);
+ }
+ else
+ {
+ ASSERT_PRINT(false, ".blast file contains unknown object.");
+ }
+
+ if (tkAsset != nullptr)
+ {
+ std::vector<ExtPxAssetDesc::ChunkDesc> physicsChunks;
+ std::vector<std::vector<ExtPxAssetDesc::SubchunkDesc> > physicsSubchunks;
+ /**
+ Try find FBX and check whether it contains collision geometry.
+ */
+ objFileName.str("");
+ objFileName << modelName << ".fbx";
+ if (resourceManager.findFile(objFileName.str(), path))
+ {
+ std::shared_ptr<IFbxFileReader> rdr(NvBlastExtExporterCreateFbxFileReader(), [](IFbxFileReader* p) {p->release(); });
+ rdr->loadFromFile(path.c_str());
+ if (rdr->isCollisionLoaded() == 0)
+ {
+ ASSERT_PRINT(false, "fbx doesn't contain collision geometry");
+ }
+ uint32_t* hullsOffsets = nullptr;
+ CollisionHull** hulls = nullptr;
+ uint32_t meshCount = rdr->getCollision(hullsOffsets, hulls);
+
+ /**
+ Create physics meshes;
+ */
+ std::shared_ptr<Nv::Blast::ConvexMeshBuilder> collisionBuilder(
+ NvBlastExtAuthoringCreateConvexMeshBuilder(&cooking, &physics.getPhysicsInsertionCallback()),
+ [](Nv::Blast::ConvexMeshBuilder* cmb) {cmb->release(); });
+
+ physicsChunks.resize(meshCount);
+ physicsSubchunks.resize(meshCount);
+
+ for (uint32_t i = 0; i < meshCount; ++i)
+ {
+ for (uint32_t sbHulls = hullsOffsets[i]; sbHulls < hullsOffsets[i+1]; ++sbHulls)
+ {
+ PxConvexMeshGeometry temp = physx::PxConvexMeshGeometry(collisionBuilder.get()->buildConvexMesh(*hulls[sbHulls]));
+ if (temp.isValid())
+ {
+ physicsSubchunks[i].push_back(ExtPxAssetDesc::SubchunkDesc());
+ physicsSubchunks[i].back().geometry = temp;
+ physicsSubchunks[i].back().transform = physx::PxTransform(physx::PxIdentity);
+ }
+ }
+ }
+ for (uint32_t i = 0; i < meshCount; ++i)
+ {
+ physicsChunks[i].isStatic = false;
+ physicsChunks[i].subchunkCount = (uint32_t)physicsSubchunks[i].size();
+ physicsChunks[i].subchunks = physicsSubchunks[i].data();
+ }
+ if (hullsOffsets)
+ {
+ NVBLAST_FREE(hullsOffsets);
+ }
+ if (hulls)
+ {
+ NVBLAST_FREE(hulls);
+ }
+ }
+ m_pxAsset = ExtPxAsset::create(tkAsset, physicsChunks.data(), (uint32_t)physicsChunks.size());
+ ASSERT_PRINT(m_pxAsset != nullptr, "can't create asset");
+ }
+ }
}
- validate();
+ initialize();
}
diff --git a/samples/SampleBase/blast/BlastAssetModel.h b/samples/SampleBase/blast/BlastAssetModel.h
index 03045d4..2c66273 100644
--- a/samples/SampleBase/blast/BlastAssetModel.h
+++ b/samples/SampleBase/blast/BlastAssetModel.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef BLAST_ASSET_MODEL_H
#define BLAST_ASSET_MODEL_H
@@ -26,6 +44,7 @@ namespace Nv
namespace Blast
{
class TkFramework;
+class ExtSerialization;
}
}
@@ -35,7 +54,7 @@ class BlastAssetModel : public BlastAsset
public:
//////// ctor ////////
- BlastAssetModel(TkFramework& framework, PxPhysics& physics, PxCooking& cooking, Renderer& renderer, const char* modelName);
+ BlastAssetModel(TkFramework& framework, PxPhysics& physics, PxCooking& cooking, ExtSerialization& serialization, Renderer& renderer, const char* modelName);
virtual ~BlastAssetModel();
@@ -49,7 +68,7 @@ public:
private:
//////// private internal data ////////
- BlastModelPtr m_model;
+ BlastModelPtr m_model;
};
#endif //BLAST_ASSET_MODEL_H \ No newline at end of file
diff --git a/samples/SampleBase/blast/BlastAssetModelSimple.cpp b/samples/SampleBase/blast/BlastAssetModelSimple.cpp
index fa423e2..9de52d2 100644
--- a/samples/SampleBase/blast/BlastAssetModelSimple.cpp
+++ b/samples/SampleBase/blast/BlastAssetModelSimple.cpp
@@ -1,12 +1,29 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
#include "BlastAssetModelSimple.h"
@@ -19,8 +36,8 @@
// BlastAssetModelSimple
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-BlastAssetModelSimple::BlastAssetModelSimple(TkFramework& framework, PxPhysics& physics, PxCooking& cooking, Renderer& renderer, const char* modelName)
- : BlastAssetModel(framework, physics, cooking, renderer, modelName)
+BlastAssetModelSimple::BlastAssetModelSimple(TkFramework& framework, PxPhysics& physics, PxCooking& cooking, ExtSerialization& serialization, Renderer& renderer, const char* modelName)
+ : BlastAssetModel(framework, physics, cooking, serialization, renderer, modelName)
{
// prepare materials
for (const BlastModel::Material& material : getModel().materials)
@@ -31,7 +48,7 @@ BlastAssetModelSimple::BlastAssetModelSimple(TkFramework& framework, PxPhysics&
m_renderMaterials.push_back(new RenderMaterial(renderer.getResourceManager(), "model_simple_textured", material.diffuseTexture.c_str()));
}
- validate();
+ initialize();
}
diff --git a/samples/SampleBase/blast/BlastAssetModelSimple.h b/samples/SampleBase/blast/BlastAssetModelSimple.h
index 7e61616..7a8a9ba 100644
--- a/samples/SampleBase/blast/BlastAssetModelSimple.h
+++ b/samples/SampleBase/blast/BlastAssetModelSimple.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef BLAST_ASSET_MODEL_SIMPLE_H
#define BLAST_ASSET_MODEL_SIMPLE_H
@@ -21,7 +39,7 @@ class BlastAssetModelSimple : public BlastAssetModel
public:
//////// ctor ////////
- BlastAssetModelSimple(TkFramework& framework, PxPhysics& physics, PxCooking& cooking, Renderer& renderer, const char* modelName);
+ BlastAssetModelSimple(TkFramework& framework, PxPhysics& physics, PxCooking& cooking, ExtSerialization& serialization, Renderer& renderer, const char* modelName);
virtual ~BlastAssetModelSimple();
diff --git a/samples/SampleBase/blast/BlastAssetModelSkinned.cpp b/samples/SampleBase/blast/BlastAssetModelSkinned.cpp
index 6b96580..2cef227 100644
--- a/samples/SampleBase/blast/BlastAssetModelSkinned.cpp
+++ b/samples/SampleBase/blast/BlastAssetModelSkinned.cpp
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#include "BlastAssetModelSkinned.h"
#include "BlastFamilyModelSkinned.h"
@@ -14,8 +32,8 @@
#include "Renderer.h"
-BlastAssetModelSkinned::BlastAssetModelSkinned(TkFramework& framework, PxPhysics& physics, PxCooking& cooking, Renderer& renderer, const char* modelName)
- : BlastAssetModel(framework, physics, cooking, renderer, modelName)
+BlastAssetModelSkinned::BlastAssetModelSkinned(TkFramework& framework, PxPhysics& physics, PxCooking& cooking, ExtSerialization& serialization, Renderer& renderer, const char* modelName)
+ : BlastAssetModel(framework, physics, cooking, serialization, renderer, modelName)
{
for (const BlastModel::Material& material : getModel().materials)
{
@@ -25,7 +43,7 @@ BlastAssetModelSkinned::BlastAssetModelSkinned(TkFramework& framework, PxPhysics
m_renderMaterials.push_back(new RenderMaterial(renderer.getResourceManager(), "model_skinned_textured", material.diffuseTexture.c_str()));
}
- validate();
+ initialize();
}
BlastAssetModelSkinned::~BlastAssetModelSkinned()
diff --git a/samples/SampleBase/blast/BlastAssetModelSkinned.h b/samples/SampleBase/blast/BlastAssetModelSkinned.h
index 149c8e8..e9c6784 100644
--- a/samples/SampleBase/blast/BlastAssetModelSkinned.h
+++ b/samples/SampleBase/blast/BlastAssetModelSkinned.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef BLAST_ASSET_MODEL_SKINNED_H
#define BLAST_ASSET_MODEL_SKINNED_H
@@ -20,7 +38,7 @@ class BlastAssetModelSkinned : public BlastAssetModel
public:
//////// ctor ////////
- BlastAssetModelSkinned(TkFramework& framework, PxPhysics& physics, PxCooking& cooking, Renderer& renderer, const char* modelName);
+ BlastAssetModelSkinned(TkFramework& framework, PxPhysics& physics, PxCooking& cooking, ExtSerialization& serialization, Renderer& renderer, const char* modelName);
virtual ~BlastAssetModelSkinned();
diff --git a/samples/SampleBase/blast/BlastController.cpp b/samples/SampleBase/blast/BlastController.cpp
index 77e2047..cc3d5af 100644
--- a/samples/SampleBase/blast/BlastController.cpp
+++ b/samples/SampleBase/blast/BlastController.cpp
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#include "BlastController.h"
#include "BlastFamily.h"
@@ -18,10 +36,16 @@
#include "Utils.h"
#include "Renderer.h"
+#include "NvBlastExtPxTask.h"
+
#include "NvBlast.h"
+#include "NvBlastPxCallbacks.h"
#include "NvBlastExtPxManager.h"
#include "NvBlastExtPxFamily.h"
#include "NvBlastExtPxActor.h"
+#include "NvBlastExtSerialization.h"
+#include "NvBlastExtTkSerialization.h"
+#include "NvBlastExtPxSerialization.h"
#include "NvBlastTkFramework.h"
@@ -40,65 +64,6 @@
#include "imgui.h"
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// AllocatorCallback
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-class BlastAllocatorCallback : public PxAllocatorCallback
-{
-public:
- virtual void* allocate(size_t size, const char* typeName, const char* filename, int line) override
- {
- NV_UNUSED(typeName);
- NV_UNUSED(filename);
- NV_UNUSED(line);
- return malloc(size);
- }
-
- virtual void deallocate(void* ptr) override
- {
- free(ptr);
- }
-};
-BlastAllocatorCallback g_allocatorCallback;
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// ErrorCallback
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-class BlastErrorCallback : public PxErrorCallback
-{
-public:
- virtual void reportError(PxErrorCode::Enum code, const char* msg, const char* file, int line) override
- {
- std::stringstream str;
- str << "NvBlastTk ";
- bool critical = false;
- switch (code)
- {
- case PxErrorCode::eNO_ERROR: critical = false; break;
- case PxErrorCode::eDEBUG_INFO: str << "[Debug Info]"; critical = false; break;
- case PxErrorCode::eDEBUG_WARNING: str << "[Debug Warning]"; critical = false; break;
- case PxErrorCode::eINVALID_PARAMETER: str << "[Invalid Parameter]"; critical = true; break;
- case PxErrorCode::eINVALID_OPERATION: str << "[Invalid Operation]"; critical = true; break;
- case PxErrorCode::eOUT_OF_MEMORY: str << "[Out of] Memory"; critical = true; break;
- case PxErrorCode::eINTERNAL_ERROR: str << "[Internal Error]"; critical = true; break;
- case PxErrorCode::eABORT: str << "[Abort]"; critical = true; break;
- case PxErrorCode::ePERF_WARNING: str << "[Perf Warning]"; critical = false; break;
- default: PX_ALWAYS_ASSERT();
- }
- str << file << "(" << line << "): " << msg << "\n";
-
- std::string message = str.str();
- shdfnd::printString(message.c_str());
- PX_ASSERT_WITH_MESSAGE(!critical, message.c_str());
- }
-};
-BlastErrorCallback g_errorCallback;
-
-
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Joint creation
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -117,10 +82,9 @@ static physx::PxJoint* createPxJointCallback(ExtPxActor* actor0, const physx::Px
BlastController::BlastController()
: m_eventCallback(nullptr), debugRenderMode(BlastFamily::DEBUG_RENDER_DISABLED), m_impactDamageEnabled(true),
-m_impactDamageToStressEnabled(false), m_rigidBodyLimitEnabled(true), m_rigidBodyLimit(40000), m_blastAssetsSize(0), debugRenderScale(0.01f)
+m_impactDamageToStressEnabled(false), m_rigidBodyLimitEnabled(true), m_rigidBodyLimit(40000), m_blastAssetsSize(0), debugRenderScale(0.01f),
+m_taskManager(nullptr), m_extGroupTaskManager(nullptr)
{
- m_extImpactDamageManagerSettings.fragility = 500.0f;
-
m_impactDamageToStressFactor = 0.01f;
m_draggingToStressFactor = 100.0f;
}
@@ -138,17 +102,14 @@ void BlastController::reinitialize()
void BlastController::onSampleStart()
{
- TkFrameworkDesc desc;
- desc.allocatorCallback = &g_allocatorCallback;
- desc.errorCallback = &g_errorCallback;
- m_tkFramework = NvBlastTkFrameworkCreate(desc);
+ m_tkFramework = NvBlastTkFrameworkCreate();
m_replay = new BlastReplay();
- m_taskManager = PxTaskManager::createTaskManager(g_errorCallback, getPhysXController().getCPUDispatcher(), 0);
+ m_taskManager = PxTaskManager::createTaskManager(NvBlastGetPxErrorCallback(), getPhysXController().getCPUDispatcher(), 0);
TkGroupDesc gdesc;
- gdesc.pxTaskManager = m_taskManager;
+ gdesc.workerCount = m_taskManager->getCpuDispatcher()->getWorkerCount();
m_tkGroup = m_tkFramework->createGroup(gdesc);
m_extPxManager = ExtPxManager::create(getPhysXController().getPhysics(), *m_tkFramework, createPxJointCallback);
@@ -156,12 +117,24 @@ void BlastController::onSampleStart()
m_extImpactDamageManager = ExtImpactDamageManager::create(m_extPxManager, m_extImpactDamageManagerSettings);
m_eventCallback = new EventCallback(m_extImpactDamageManager);
+ m_extGroupTaskManager = ExtGroupTaskManager::create(*m_taskManager);
+ m_extGroupTaskManager->setGroup(m_tkGroup);
+
setImpactDamageEnabled(m_impactDamageEnabled, true);
+
+ m_extSerialization = NvBlastExtSerializationCreate();
+ if (m_extSerialization != nullptr)
+ {
+ NvBlastExtTkSerializerLoadSet(*m_tkFramework, *m_extSerialization);
+ NvBlastExtPxSerializerLoadSet(*m_tkFramework, getPhysXController().getPhysics(), getPhysXController().getCooking(), *m_extSerialization);
+ }
}
void BlastController::onSampleStop()
{
+ getPhysXController().simualtionSyncEnd();
+
removeAllFamilies();
m_extImpactDamageManager->release();
@@ -174,20 +147,54 @@ void BlastController::onSampleStop()
m_tkFramework->release();
- m_taskManager->release();
+ if (m_extGroupTaskManager != nullptr)
+ {
+ m_extGroupTaskManager->release();
+ m_extGroupTaskManager = nullptr;
+ }
+
+ if (m_taskManager != nullptr)
+ {
+ m_taskManager->release();
+ }
+}
+
+
+void BlastController::notifyPhysXControllerRelease()
+{
+ if (m_extGroupTaskManager != nullptr)
+ {
+ m_extGroupTaskManager->release();
+ m_extGroupTaskManager = nullptr;
+ }
+
+ if (m_taskManager != nullptr)
+ {
+ m_taskManager->release();
+ m_taskManager = nullptr;
+ }
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Impact damage
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+void BlastController::updateImpactDamage()
+{
+ if (m_impactDamageUpdatePending)
+ {
+ getPhysXController().getPhysXScene().setSimulationEventCallback(m_impactDamageEnabled ? m_eventCallback : nullptr);
+ refreshImpactDamageSettings();
+ m_impactDamageUpdatePending = false;
+ }
+}
+
void BlastController::setImpactDamageEnabled(bool enabled, bool forceUpdate)
{
if (m_impactDamageEnabled != enabled || forceUpdate)
{
m_impactDamageEnabled = enabled;
- getPhysXController().getPhysXScene().setSimulationEventCallback(m_impactDamageEnabled ? m_eventCallback : nullptr);
- refreshImpactDamageSettings();
+ m_impactDamageUpdatePending = true;
}
}
@@ -203,8 +210,8 @@ bool BlastController::stressDamage(ExtPxActor *actor, physx::PxVec3 position, ph
void* userData = actor->getFamily().userData;
if (userData)
{
- ExtStressSolver* solver = reinterpret_cast<ExtStressSolver*>(userData);
- solver->applyImpulse(*actor, position, force * m_impactDamageToStressFactor);
+ ExtPxStressSolver* solver = reinterpret_cast<ExtPxStressSolver*>(userData);
+ solver->getSolver().addForce(*actor->getTkActor().getActorLL(), position, force * m_impactDamageToStressFactor);
return true;
}
}
@@ -236,11 +243,11 @@ void BlastController::updateDraggingStress()
void* userData = pxActor->getFamily().userData;
if (userData)
{
- ExtStressSolver* solver = reinterpret_cast<ExtStressSolver*>(userData);
+ ExtPxStressSolver* solver = reinterpret_cast<ExtPxStressSolver*>(userData);
PxTransform t(pxActor->getPhysXActor().getGlobalPose().getInverse());
PxVec3 dragVector = t.rotate(physxController.getDragVector());
const float factor = dragVector.magnitudeSquared() * m_draggingToStressFactor;
- solver->applyImpulse(*pxActor, physxController.getDragActorHookLocalPoint(), dragVector.getNormalized() * factor);
+ solver->getSolver().addForce(*pxActor->getTkActor().getActorLL(), physxController.getDragActorHookLocalPoint(), dragVector.getNormalized() * factor);
}
}
}
@@ -297,7 +304,11 @@ void BlastController::Animate(double dt)
updateDraggingStress();
- m_replay->update();
+ fillDebugRender();
+
+ getPhysXController().simualtionSyncEnd();
+
+ updateImpactDamage();
Time blastTime;
for (uint32_t i = 0; i < m_families.size(); ++i)
@@ -308,13 +319,25 @@ void BlastController::Animate(double dt)
}
}
- fillDebugRender();
+ m_replay->update();
PROFILER_BEGIN("Tk Group Process/Sync");
+
+#if 1
+
+ m_extGroupTaskManager->process();
+ m_extGroupTaskManager->wait();
+
+#else // process group on main thread
+
m_tkGroup->process();
- m_tkGroup->sync(true);
+
+#endif
+
PROFILER_END();
+ getPhysXController().simulationBegin(dt);
+
TkGroupStats gstats;
m_tkGroup->getStats(gstats);
@@ -342,15 +365,20 @@ void BlastController::drawUI()
{
setImpactDamageEnabled(impactEnabled);
}
-
- if (ImGui::DragFloat("Fragility", &m_extImpactDamageManagerSettings.fragility))
{
- refreshImpactDamageSettings();
- }
-
- if (ImGui::Checkbox("Impact Damage To Stress Solver", &m_impactDamageToStressEnabled))
- {
- refreshImpactDamageSettings();
+ bool refresh = false;
+ refresh |= ImGui::Checkbox("Use Shear Damage", &m_extImpactDamageManagerSettings.shearDamage);
+ refresh |= ImGui::DragFloat("Impulse Threshold (Min)", &m_extImpactDamageManagerSettings.impulseMinThreshold);
+ refresh |= ImGui::DragFloat("Impulse Threshold (Max)", &m_extImpactDamageManagerSettings.impulseMaxThreshold);
+ refresh |= ImGui::DragFloat("Damage (Max)", &m_extImpactDamageManagerSettings.damageMax);
+ refresh |= ImGui::DragFloat("Damage Radius (Max)", &m_extImpactDamageManagerSettings.damageRadiusMax);
+ refresh |= ImGui::DragFloat("Damage Attenuation", &m_extImpactDamageManagerSettings.damageAttenuation, 1.0f, 0.0f, 1.0f);
+ refresh |= ImGui::Checkbox("Impact Damage To Stress Solver", &m_impactDamageToStressEnabled);
+
+ if (refresh)
+ {
+ refreshImpactDamageSettings();
+ }
}
ImGui::DragFloat("Impact Damage To Stress Factor", &m_impactDamageToStressFactor, 0.001f, 0.0f, 1000.0f, "%.4f");
@@ -409,40 +437,19 @@ void BlastController::recalculateAssetsSize()
}
}
-void BlastController::blast(PxVec3 worldPos, float damageRadius, float explosiveImpulse, std::function<void(ExtPxActor*)> damageFunction)
+bool BlastController::overlap(const PxGeometry& geometry, const PxTransform& pose, std::function<void(ExtPxActor*)> hitCall)
{
PROFILER_SCOPED_FUNCTION();
+ bool anyHit = false;
for (uint32_t i = 0; i < m_families.size(); ++i)
{
if (m_families[i])
{
- m_families[i]->blast(worldPos, damageRadius, explosiveImpulse, damageFunction);
+ anyHit |= m_families[i]->overlap(geometry, pose, hitCall);
}
}
-}
-
-
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// context/log
-///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-void BlastController::blastLog(int type, const char* msg, const char* file, int line)
-{
- std::stringstream str;
- bool critical = false;
- switch (type)
- {
- case NvBlastMessage::Error: str << "[NvBlast ERROR] "; critical = true; break;
- case NvBlastMessage::Warning: str << "[NvBlast WARNING] "; critical = true; break;
- case NvBlastMessage::Info: str << "[NvBlast INFO] "; critical = false; break;
- case NvBlastMessage::Debug: str << "[NvBlast DEBUG] "; critical = false; break;
- }
- str << file << "(" << line << "): " << msg << "\n";
-
- std::string message = str.str();
- shdfnd::printString(message.c_str());
- PX_ASSERT_WITH_MESSAGE(!critical, message.c_str());
+ return anyHit;
}
diff --git a/samples/SampleBase/blast/BlastController.h b/samples/SampleBase/blast/BlastController.h
index f7f362f..a019339 100644
--- a/samples/SampleBase/blast/BlastController.h
+++ b/samples/SampleBase/blast/BlastController.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef BLAST_CONTROLLER_H
#define BLAST_CONTROLLER_H
@@ -31,6 +49,8 @@ namespace Nv
namespace Blast
{
class TkFramework;
+class ExtGroupTaskManager;
+class ExtSerialization;
}
}
@@ -68,7 +88,7 @@ public:
//////// public API ////////
- void blast(PxVec3 worldPos, float damageRadius, float explosiveImpulse, std::function<void(ExtPxActor*)> damageFunction);
+ bool overlap(const PxGeometry& geometry, const PxTransform& pose, std::function<void(ExtPxActor*)> hitCall);
bool stressDamage(ExtPxActor *actor, PxVec3 position, PxVec3 force);
@@ -77,11 +97,6 @@ public:
void removeAllFamilies();
- //////// public static ////////
-
- static void blastLog(int type, const char* msg, const char* file, int line);
-
-
//////// public getters/setters ////////
TkFramework& getTkFramework() const
@@ -139,6 +154,13 @@ public:
float getLastStressDelta() const;
+ void notifyPhysXControllerRelease();
+
+ ExtSerialization* getExtSerialization() const
+ {
+ return m_extSerialization;
+ }
+
//////// public variables for UI ////////
BlastFamily::DebugRenderMode debugRenderMode;
@@ -183,6 +205,8 @@ private:
void updateDraggingStress();
+ void updateImpactDamage();
+
void refreshImpactDamageSettings();
void fillDebugRender();
@@ -215,11 +239,14 @@ private:
ExtImpactSettings m_extImpactDamageManagerSettings;
EventCallback* m_eventCallback;
ExtStressSolverSettings m_extStressSolverSettings;
+ ExtGroupTaskManager* m_extGroupTaskManager;
+ ExtSerialization* m_extSerialization;
std::vector<BlastFamilyPtr> m_families;
DebugRenderBuffer m_debugRenderBuffer;
bool m_impactDamageEnabled;
+ bool m_impactDamageUpdatePending;
bool m_impactDamageToStressEnabled;
float m_impactDamageToStressFactor;
diff --git a/samples/SampleBase/blast/BlastFamily.cpp b/samples/SampleBase/blast/BlastFamily.cpp
index 95444b3..a966372 100644
--- a/samples/SampleBase/blast/BlastFamily.cpp
+++ b/samples/SampleBase/blast/BlastFamily.cpp
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#include "BlastFamily.h"
#include "SampleProfiler.h"
@@ -32,8 +50,6 @@
const float RIGIDBODY_DENSITY = 2000.0f;
-const float BlastFamily::BOND_HEALTH_MAX = 1.0f;
-
BlastFamily::BlastFamily(PhysXController& physXController, ExtPxManager& pxManager, const BlastAsset& blastAsset)
: m_physXController(physXController)
, m_pxManager(pxManager)
@@ -41,11 +57,10 @@ BlastFamily::BlastFamily(PhysXController& physXController, ExtPxManager& pxManag
, m_listener(this)
, m_totalVisibleChunkCount(0)
, m_stressSolver(nullptr)
+ , m_spawned(false)
{
m_settings.stressSolverEnabled = false;
m_settings.stressDamageEnabled = false;
-
- m_settings.material = { 3.0f, 0.1f, 0.2f, 1.5f + 1e-5f, 0.95f };;
}
BlastFamily::~BlastFamily()
@@ -63,10 +78,7 @@ BlastFamily::~BlastFamily()
void BlastFamily::initialize(const BlastAsset::ActorDesc& desc)
{
ExtPxFamilyDesc familyDesc;
- familyDesc.actorDesc.initialBondHealths = nullptr;
- familyDesc.actorDesc.initialSupportChunkHealths = nullptr;
- familyDesc.actorDesc.uniformInitialBondHealth = BOND_HEALTH_MAX;
- familyDesc.actorDesc.uniformInitialLowerSupportChunkHealth = 1.0f;
+ familyDesc.actorDesc = nullptr; // if you use it one day, consider changing code which needs getBondHealthMax() from BlastAsset.
familyDesc.group = desc.group;
familyDesc.pxAsset = m_blastAsset.getPxAsset();
m_pxFamily = m_pxManager.createFamily(familyDesc);
@@ -79,28 +91,24 @@ void BlastFamily::initialize(const BlastAsset::ActorDesc& desc)
m_pxFamily->subscribe(m_listener);
- ExtPxSpawnSettings spawnSettings = {
- &m_physXController.getPhysXScene(),
- m_physXController.getDefaultMaterial(),
- RIGIDBODY_DENSITY
- };
- m_pxFamily->spawn(desc.transform, PxVec3(1.0f), spawnSettings);
-
- reloadStressSolver();
+ m_initialTransform = desc.transform;
}
void BlastFamily::updatePreSplit(float dt)
{
- PROFILER_BEGIN("Stress Solver");
- // update stress
- m_stressSolveTime = 0;
- if (m_stressSolver)
+ if (!m_spawned)
{
- Time t;
- m_stressSolver->update(m_settings.stressDamageEnabled);
- m_stressSolveTime += t.getElapsedSeconds();
+ ExtPxSpawnSettings spawnSettings = {
+ &m_physXController.getPhysXScene(),
+ m_physXController.getDefaultMaterial(),
+ RIGIDBODY_DENSITY
+ };
+
+ m_pxFamily->spawn(m_initialTransform, PxVec3(1.0f), spawnSettings);
+ reloadStressSolver();
+
+ m_spawned = true;
}
- PROFILER_END();
// collect potential actors to health update
m_actorsToUpdateHealth.clear();
@@ -128,6 +136,17 @@ void BlastFamily::updateAfterSplit(float dt)
}
PROFILER_END();
+ PROFILER_BEGIN("Stress Solver");
+ // update stress
+ m_stressSolveTime = 0;
+ if (m_stressSolver)
+ {
+ Time t;
+ m_stressSolver->update(m_settings.stressDamageEnabled);
+ m_stressSolveTime += t.getElapsedSeconds();
+ }
+ PROFILER_END();
+
PROFILER_BEGIN("Actor Misc Update");
onUpdate();
PROFILER_END();
@@ -173,11 +192,9 @@ void BlastFamily::drawUI()
// Blast Material
ImGui::Spacing();
ImGui::Text("Blast Material:");
- ImGui::DragFloat("singleChunkThreshold", &m_settings.material.singleChunkThreshold);
- ImGui::DragFloat("graphChunkThreshold", &m_settings.material.graphChunkThreshold);
- ImGui::DragFloat("bondNormalThreshold", &m_settings.material.bondNormalThreshold);
- ImGui::DragFloat("bondTangentialThreshold", &m_settings.material.bondTangentialThreshold);
- ImGui::DragFloat("damageAttenuation", &m_settings.material.damageAttenuation);
+ ImGui::DragFloat("Health", &m_settings.material.health);
+ ImGui::DragFloat("Min Damage Threshold", &m_settings.material.minDamageThreshold, 0.01f, 0.f, m_settings.material.maxDamageThreshold);
+ ImGui::DragFloat("Max Damage Threshold", &m_settings.material.maxDamageThreshold, 0.01f, m_settings.material.minDamageThreshold, 1.f);
ImGui::Spacing();
@@ -193,8 +210,9 @@ void BlastFamily::drawUI()
bool changed = false;
changed |= ImGui::DragInt("Bond Iterations Per Frame", (int*)&m_settings.stressSolverSettings.bondIterationsPerFrame, 100, 0, 500000);
- changed |= ImGui::DragFloat("Stress Linear Factor", &m_settings.stressSolverSettings.stressLinearFactor, 0.00001f, 0.0f, 10.0f, "%.6f");
- changed |= ImGui::DragFloat("Stress Angular Factor", &m_settings.stressSolverSettings.stressAngularFactor, 0.00001f, 0.0f, 10.0f, "%.6f");
+ changed |= ImGui::DragFloat("Material Hardness", &m_settings.stressSolverSettings.hardness, 10.0f, 0.01f, 100000.0f, "%.2f");
+ changed |= ImGui::DragFloat("Stress Linear Factor", &m_settings.stressSolverSettings.stressLinearFactor, 0.01f, 0.0f, 100.0f, "%.2f");
+ changed |= ImGui::DragFloat("Stress Angular Factor", &m_settings.stressSolverSettings.stressAngularFactor, 0.01f, 0.0f, 100.0f, "%.2f");
changed |= ImGui::SliderInt("Graph Reduction Level", (int*)&m_settings.stressSolverSettings.graphReductionLevel, 0, 32);
if (changed)
{
@@ -213,22 +231,22 @@ void BlastFamily::drawUI()
void BlastFamily::drawStatsUI()
{
ImGui::PushStyleColor(ImGuiCol_Text, ImColor(10, 255, 10, 255));
- const ExtStressSolver* stressSolver = m_stressSolver;
- if (stressSolver)
+ if (m_stressSolver)
{
- const float errorLinear = stressSolver->getStressErrorLinear();
- const float errorAngular = stressSolver->getStressErrorAngular();
+ const ExtStressSolver& stressSolver = m_stressSolver->getSolver();
+ const float errorLinear = stressSolver.getStressErrorLinear();
+ const float errorAngular = stressSolver.getStressErrorAngular();
- ImGui::Text("Stress Bond Count: %d", stressSolver->getBondCount());
- ImGui::Text("Stress Iterations: %d (+%d)", stressSolver->getIterationCount(), stressSolver->getIterationsPerFrame());
- ImGui::Text("Stress Frames: %d", stressSolver->getFrameCount());
+ ImGui::Text("Stress Bond Count: %d", stressSolver.getBondCount());
+ ImGui::Text("Stress Frame Iter: %d", stressSolver.getIterationsPerFrame());
+ ImGui::Text("Stress Frames: %d", stressSolver.getFrameCount());
ImGui::Text("Stress Error Lin / Ang: %.4f / %.4f", errorLinear, errorAngular);
ImGui::Text("Stress Solve Time: %.3f ms", m_stressSolveTime * 1000);
// plot errors
{
static float scale = 1.0f;
- scale = stressSolver->getFrameCount() <= 1 ? 1.0f : scale;
+ scale = stressSolver.getFrameCount() <= 1 ? 1.0f : scale;
scale = std::max<float>(scale, errorLinear);
scale = std::max<float>(scale, errorAngular);
@@ -269,13 +287,16 @@ void BlastFamily::refreshStressSolverSettings()
{
if (m_stressSolver)
{
- m_stressSolver->setSettings(m_settings.stressSolverSettings);
+ m_stressSolver->getSolver().setSettings(m_settings.stressSolverSettings);
}
}
void BlastFamily::resetStress()
{
- m_stressSolver->reset();
+ if (m_stressSolver)
+ {
+ m_stressSolver->getSolver().reset();
+ }
}
void BlastFamily::reloadStressSolver()
@@ -288,7 +309,7 @@ void BlastFamily::reloadStressSolver()
if (m_settings.stressSolverEnabled)
{
- m_stressSolver = ExtStressSolver::create(*m_pxFamily, m_settings.stressSolverSettings);
+ m_stressSolver = ExtPxStressSolver::create(*m_pxFamily, m_settings.stressSolverSettings);
m_pxFamily->userData = m_stressSolver;
}
}
@@ -351,6 +372,8 @@ void BlastFamily::fillDebugRender(DebugRenderBuffer& debugRenderBuffer, DebugRen
const NvBlastChunk* chunks = m_tkFamily->getAsset()->getChunks();
const NvBlastBond* bonds = m_tkFamily->getAsset()->getBonds();
const NvBlastSupportGraph graph = m_tkFamily->getAsset()->getGraph();
+ const float bondHealthMax = m_blastAsset.getBondHealthMax();
+ const uint32_t chunkCount = m_tkFamily->getAsset()->getChunkCount();
for (const ExtPxActor* pxActor : m_actors)
{
@@ -361,7 +384,7 @@ void BlastFamily::fillDebugRender(DebugRenderBuffer& debugRenderBuffer, DebugRen
if (nodeCount == 0) // subsupport chunks don't have graph nodes
continue;
- std::vector<uint32_t> nodes(actor.getGraphNodeCount());
+ std::vector<uint32_t> nodes(nodeCount);
actor.getGraphNodeIndices(nodes.data(), static_cast<uint32_t>(nodes.size()));
if (DEBUG_RENDER_HEALTH_GRAPH <= mode && mode <= DEBUG_RENDER_HEALTH_GRAPH_CENTROIDS)
@@ -385,11 +408,11 @@ void BlastFamily::fillDebugRender(DebugRenderBuffer& debugRenderBuffer, DebugRen
if (node0 > node1)
continue;
- bool invisibleBond = assetChunk0.subchunkCount == 0 || assetChunk1.subchunkCount == 0;
+ bool invisibleBond = chunkIndex0 >= chunkCount || chunkIndex1 >= chunkCount || assetChunk0.subchunkCount == 0 || assetChunk1.subchunkCount == 0;
// health
uint32_t bondIndex = graph.adjacentBondIndices[adjacencyIndex];
- float healthVal = PxClamp(bondHealths[bondIndex] / BOND_HEALTH_MAX, 0.0f, 1.0f);
+ float healthVal = PxClamp(bondHealths[bondIndex] / bondHealthMax, 0.0f, 1.0f);
DirectX::XMFLOAT4 color = bondHealthColor(healthVal);
@@ -419,7 +442,12 @@ void BlastFamily::fillDebugRender(DebugRenderBuffer& debugRenderBuffer, DebugRen
{
if (m_stressSolver)
{
- m_stressSolver->fillDebugRender(nodes, debugRenderBuffer.m_lines, (ExtStressSolver::DebugRenderMode)(mode - DEBUG_RENDER_STRESS_GRAPH), renderScale);
+ const auto buffer = m_stressSolver->getSolver().fillDebugRender(nodes.data(), (uint32_t)nodes.size(), (ExtStressSolver::DebugRenderMode)(mode - DEBUG_RENDER_STRESS_GRAPH), renderScale);
+ if (buffer.lineCount)
+ {
+ const auto lines = reinterpret_cast<const PxDebugLine*>(buffer.lines);
+ debugRenderBuffer.m_lines.insert(debugRenderBuffer.m_lines.end(), lines, lines + buffer.lineCount);
+ }
}
}
@@ -497,12 +525,12 @@ private:
PxOverlapHit m_hitBuffer[1000];
};
-void BlastFamily::blast(PxVec3 worldPos, float damageRadius, float explosiveImpulse, std::function<void(ExtPxActor*)> damageFunction)
+bool BlastFamily::overlap(const PxGeometry& geometry, const PxTransform& pose, std::function<void(ExtPxActor*)> hitCall)
{
std::set<ExtPxActor*> actorsToDamage;
#if 1
BlastOverlapCallback overlapCallback(m_pxManager, actorsToDamage);
- m_physXController.getPhysXScene().overlap(PxSphereGeometry(damageRadius), PxTransform(worldPos), overlapCallback);
+ m_physXController.getPhysXScene().overlap(geometry, pose, overlapCallback);
#else
for (std::map<NvBlastActor*, PhysXController::Actor*>::iterator it = m_actorsMap.begin(); it != m_actorsMap.end(); it++)
{
@@ -512,59 +540,9 @@ void BlastFamily::blast(PxVec3 worldPos, float damageRadius, float explosiveImpu
for (auto actor : actorsToDamage)
{
- damageFunction(actor);
+ hitCall(actor);
}
- if (explosiveImpulse > 0.0f)
- {
- explode(worldPos, damageRadius, explosiveImpulse);
- }
+ return !actorsToDamage.empty();
}
-
-class ExplodeOverlapCallback : public PxOverlapCallback
-{
-public:
- ExplodeOverlapCallback(PxVec3 worldPos, float radius, float explosiveImpulse)
- : m_worldPos(worldPos)
- , m_radius(radius)
- , m_explosiveImpulse(explosiveImpulse)
- , PxOverlapCallback(m_hitBuffer, sizeof(m_hitBuffer) / sizeof(m_hitBuffer[0])) {}
-
- PxAgain processTouches(const PxOverlapHit* buffer, PxU32 nbHits)
- {
- for (PxU32 i = 0; i < nbHits; ++i)
- {
- PxRigidActor* actor = buffer[i].actor;
- PxRigidDynamic* rigidDynamic = actor->is<PxRigidDynamic>();
- if (rigidDynamic && !(rigidDynamic->getRigidBodyFlags() & PxRigidBodyFlag::eKINEMATIC))
- {
- if (m_actorBuffer.find(rigidDynamic) == m_actorBuffer.end())
- {
- m_actorBuffer.insert(rigidDynamic);
- PxVec3 dr = rigidDynamic->getGlobalPose().transform(rigidDynamic->getCMassLocalPose()).p - m_worldPos;
- float distance = dr.magnitude();
- float factor = PxClamp(1.0f - (distance * distance) / (m_radius * m_radius), 0.0f, 1.0f);
- float impulse = factor * m_explosiveImpulse * RIGIDBODY_DENSITY;
- PxVec3 vel = dr.getNormalized() * impulse / rigidDynamic->getMass();
- rigidDynamic->setLinearVelocity(rigidDynamic->getLinearVelocity() + vel);
- }
- }
- }
- return true;
- }
-
-private:
- PxOverlapHit m_hitBuffer[1000];
- float m_explosiveImpulse;
- std::set<PxRigidDynamic*> m_actorBuffer;
- PxVec3 m_worldPos;
- float m_radius;
-};
-
-void BlastFamily::explode(PxVec3 worldPos, float damageRadius, float explosiveImpulse)
-{
- ExplodeOverlapCallback overlapCallback(worldPos, damageRadius, explosiveImpulse);
- m_physXController.getPhysXScene().overlap(PxSphereGeometry(damageRadius), PxTransform(worldPos), overlapCallback);
-
-}
diff --git a/samples/SampleBase/blast/BlastFamily.h b/samples/SampleBase/blast/BlastFamily.h
index 0cb9bb3..5a8000e 100644
--- a/samples/SampleBase/blast/BlastFamily.h
+++ b/samples/SampleBase/blast/BlastFamily.h
@@ -1,19 +1,37 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef BLAST_FAMILY_H
#define BLAST_FAMILY_H
#include "BlastAsset.h"
#include "NvBlastExtPxListener.h"
-#include "NvBlastExtStressSolver.h"
+#include "NvBlastExtPxStressSolver.h"
#include "NvBlastExtDamageShaders.h"
#include <functional>
#include <set>
@@ -30,6 +48,13 @@ class ExtPxManager;
}
}
+namespace physx
+{
+class PxGeometry;
+class PxTransform;
+}
+
+
/**
BlastFamily class represents 1 spawned BlastAsset, contains and manipulates all physx/blast actors spawned by fracturing it.
@@ -41,8 +66,7 @@ public:
//////// public API ////////
- void blast(PxVec3 worldPos, float damageRadius, float explosiveImpulse, std::function<void(ExtPxActor*)> damageFunction);
- void explode(PxVec3 worldPos, float damageRadius, float explosiveImpulse);
+ bool overlap(const PxGeometry& geometry, const PxTransform& pose, std::function<void(ExtPxActor*)> hitCall);
void updatePreSplit(float dt);
void updateAfterSplit(float dt);
@@ -100,11 +124,6 @@ public:
void reloadStressSolver();
- //////// consts ////////
-
- static const float BOND_HEALTH_MAX;
-
-
//////// settings ////////
struct Settings
@@ -149,7 +168,7 @@ protected:
//////// protected data ////////
PhysXController& m_physXController;
- ExtPxManager& m_pxManager;
+ ExtPxManager& m_pxManager;
const BlastAsset& m_blastAsset;
private:
@@ -186,15 +205,17 @@ private:
//////// private data ////////
TkFamily* m_tkFamily;
- ExtPxFamily* m_pxFamily;
- PxManagerListener m_listener;
+ ExtPxFamily* m_pxFamily;
+ PxManagerListener m_listener;
Settings m_settings;
+ PxTransform m_initialTransform;
+ bool m_spawned;
size_t m_familySize;
uint32_t m_totalVisibleChunkCount;
- ExtStressSolver* m_stressSolver;
+ ExtPxStressSolver* m_stressSolver;
double m_stressSolveTime;
- std::set<ExtPxActor*> m_actors;
- std::set<const ExtPxActor*> m_actorsToUpdateHealth;
+ std::set<ExtPxActor*> m_actors;
+ std::set<const ExtPxActor*> m_actorsToUpdateHealth;
};
diff --git a/samples/SampleBase/blast/BlastFamilyBoxes.cpp b/samples/SampleBase/blast/BlastFamilyBoxes.cpp
index e8b7b27..7011612 100644
--- a/samples/SampleBase/blast/BlastFamilyBoxes.cpp
+++ b/samples/SampleBase/blast/BlastFamilyBoxes.cpp
@@ -1,12 +1,29 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
#include "BlastFamilyBoxes.h"
diff --git a/samples/SampleBase/blast/BlastFamilyBoxes.h b/samples/SampleBase/blast/BlastFamilyBoxes.h
index 1f70451..b67ec31 100644
--- a/samples/SampleBase/blast/BlastFamilyBoxes.h
+++ b/samples/SampleBase/blast/BlastFamilyBoxes.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef BLAST_FAMILY_BOXES
#define BLAST_FAMILY_BOXES
diff --git a/samples/SampleBase/blast/BlastFamilyModelSimple.cpp b/samples/SampleBase/blast/BlastFamilyModelSimple.cpp
index 858758f..d8a1e33 100644
--- a/samples/SampleBase/blast/BlastFamilyModelSimple.cpp
+++ b/samples/SampleBase/blast/BlastFamilyModelSimple.cpp
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#include "BlastFamilyModelSimple.h"
#include "RenderUtils.h"
@@ -284,6 +302,7 @@ void BlastFamilyModelSimple::onActorHealthUpdate(const ExtPxActor& actor)
const NvBlastBond* bonds = tkAsset->getBonds();
const NvBlastSupportGraph graph = tkAsset->getGraph();
+ const float bondHealthMax = m_blastAsset.getBondHealthMax();
std::vector<float> healthBuffer;
@@ -316,7 +335,7 @@ void BlastFamilyModelSimple::onActorHealthUpdate(const ExtPxActor& actor)
{
uint32_t node1 = graph.adjacentNodeIndices[adjacencyIndex];
uint32_t bondIndex = graph.adjacentBondIndices[adjacencyIndex];
- float bondHealth = PxClamp(bondHealths[bondIndex] / BOND_HEALTH_MAX, 0.0f, 1.0f);
+ float bondHealth = PxClamp(bondHealths[bondIndex] / bondHealthMax, 0.0f, 1.0f);
const NvBlastBond& solverBond = bonds[bondIndex];
const PxVec3& centroid = reinterpret_cast<const PxVec3&>(solverBond.centroid);
diff --git a/samples/SampleBase/blast/BlastFamilyModelSimple.h b/samples/SampleBase/blast/BlastFamilyModelSimple.h
index 7816690..c1e73ff 100644
--- a/samples/SampleBase/blast/BlastFamilyModelSimple.h
+++ b/samples/SampleBase/blast/BlastFamilyModelSimple.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef BLAST_FAMILY_MODEL_SIMPLE_H
#define BLAST_FAMILY_MODEL_SIMPLE_H
diff --git a/samples/SampleBase/blast/BlastFamilyModelSkinned.cpp b/samples/SampleBase/blast/BlastFamilyModelSkinned.cpp
index c0731d5..a0319ff 100644
--- a/samples/SampleBase/blast/BlastFamilyModelSkinned.cpp
+++ b/samples/SampleBase/blast/BlastFamilyModelSkinned.cpp
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#include "BlastFamilyModelSkinned.h"
#include "RenderUtils.h"
diff --git a/samples/SampleBase/blast/BlastFamilyModelSkinned.h b/samples/SampleBase/blast/BlastFamilyModelSkinned.h
index aeb9353..d76b18e 100644
--- a/samples/SampleBase/blast/BlastFamilyModelSkinned.h
+++ b/samples/SampleBase/blast/BlastFamilyModelSkinned.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef BLAST_FAMILY_MODEL_SKINNED_H
#define BLAST_FAMILY_MODEL_SKINNED_H
diff --git a/samples/SampleBase/blast/BlastModel.cpp b/samples/SampleBase/blast/BlastModel.cpp
index 88ddf3c..8e503d3 100644
--- a/samples/SampleBase/blast/BlastModel.cpp
+++ b/samples/SampleBase/blast/BlastModel.cpp
@@ -1,21 +1,101 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#include "BlastModel.h"
#define TINYOBJLOADER_IMPLEMENTATION
#include "tiny_obj_loader.h"
-
+#include "NvBlastExtExporter.h"
+#include "NvBlastGlobals.h"
using namespace physx;
+BlastModelPtr BlastModel::loadFromFbxFile(const char* path)
+{
+ std::shared_ptr<BlastModel> model = std::shared_ptr<BlastModel>(new BlastModel());
+
+
+ std::shared_ptr<Nv::Blast::IFbxFileReader> rdr(NvBlastExtExporterCreateFbxFileReader(), [](Nv::Blast::IFbxFileReader* p) {p->release(); });
+ rdr->loadFromFile(path);
+ if (rdr->getBoneCount() == 0)
+ {
+ return nullptr;
+ }
+
+ model->chunks.resize(rdr->getBoneCount());
+
+ model->materials.push_back(BlastModel::Material());
+
+
+ /**
+ Produce buffers of appropriate for AssetViewer format
+ */
+ uint32_t* infl;
+ rdr->getBoneInfluences(infl);
+ for (uint32_t i = 0; i < rdr->getBoneCount(); ++i)
+ {
+ std::vector<int32_t> indRemap(rdr->getVerticesCount(), -1);
+ std::vector<uint32_t> indices;
+ SimpleMesh cmesh;
+ for (uint32_t j = 0; j < rdr->getVerticesCount(); ++j)
+ {
+ if (i == infl[j])
+ {
+ indRemap[j] = (int32_t)cmesh.vertices.size();
+ cmesh.vertices.push_back(SimpleMesh::Vertex());
+ cmesh.vertices.back().normal = rdr->getNormalsArray()[j];
+ cmesh.vertices.back().position = rdr->getPositionArray()[j];
+ cmesh.vertices.back().uv = rdr->getUvArray()[j];
+ }
+ }
+ for (uint32_t j = 0; j < rdr->getIdicesCount(); j += 3)
+ {
+ if (i == infl[rdr->getIndexArray()[j]])
+ {
+ int32_t lind = rdr->getIndexArray()[j + 2];
+ cmesh.indices.push_back(indRemap[lind]);
+ lind = rdr->getIndexArray()[j + 1];
+ cmesh.indices.push_back(indRemap[lind]);
+ lind = rdr->getIndexArray()[j];
+ cmesh.indices.push_back(indRemap[lind]);
+ }
+ }
+
+ model->chunks[i].meshes.push_back(Chunk::Mesh());
+ model->chunks[i].meshes.back().materialIndex = 0;
+ model->chunks[i].meshes.back().mesh = cmesh;
+
+ NVBLAST_FREE(infl);
+ }
+ return model;
+}
+
+
BlastModelPtr BlastModel::loadFromFileTinyLoader(const char* path)
{
std::shared_ptr<BlastModel> model = std::shared_ptr<BlastModel>(new BlastModel());
@@ -33,7 +113,7 @@ BlastModelPtr BlastModel::loadFromFileTinyLoader(const char* path)
break;
}
}
-
+
bool ret = tinyobj::LoadObj(shapes, mats, err, path, mtlPath.data());
diff --git a/samples/SampleBase/blast/BlastModel.h b/samples/SampleBase/blast/BlastModel.h
index 2ef39f6..bedcd32 100644
--- a/samples/SampleBase/blast/BlastModel.h
+++ b/samples/SampleBase/blast/BlastModel.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2016-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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef BLAST_MODEL_H
#define BLAST_MODEL_H
@@ -48,6 +66,7 @@ public:
std::vector<Chunk> chunks;
static BlastModelPtr loadFromFileTinyLoader(const char* path);
+ static BlastModelPtr loadFromFbxFile(const char* path);
private:
BlastModel() {}
};
diff --git a/samples/SampleBase/blast/BlastReplay.cpp b/samples/SampleBase/blast/BlastReplay.cpp
index 13d2b33..678cec2 100644
--- a/samples/SampleBase/blast/BlastReplay.cpp
+++ b/samples/SampleBase/blast/BlastReplay.cpp
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#include "BlastReplay.h"
#include "NvBlastTk.h"
diff --git a/samples/SampleBase/blast/BlastReplay.h b/samples/SampleBase/blast/BlastReplay.h
index a85c996..effa2ed 100644
--- a/samples/SampleBase/blast/BlastReplay.h
+++ b/samples/SampleBase/blast/BlastReplay.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2016-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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef BLAST_REPLAY_H
#define BLAST_REPLAY_H
diff --git a/samples/SampleBase/core/Application.cpp b/samples/SampleBase/core/Application.cpp
index 40d975b..e68554a 100644
--- a/samples/SampleBase/core/Application.cpp
+++ b/samples/SampleBase/core/Application.cpp
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#include "Application.h"
#include <DirectXMath.h>
diff --git a/samples/SampleBase/core/Application.h b/samples/SampleBase/core/Application.h
index b4bd75b..f6ad392 100644
--- a/samples/SampleBase/core/Application.h
+++ b/samples/SampleBase/core/Application.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef APPLICATION_H
#define APPLICATION_H
diff --git a/samples/SampleBase/core/SampleController.cpp b/samples/SampleBase/core/SampleController.cpp
index 163b3b4..cd8ea4c 100644
--- a/samples/SampleBase/core/SampleController.cpp
+++ b/samples/SampleBase/core/SampleController.cpp
@@ -1,18 +1,37 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#include "SampleController.h"
#include "SceneController.h"
#include "CommonUIController.h"
#include "BlastController.h"
#include "PhysXController.h"
+#include "Renderer.h"
#include "imgui.h"
@@ -45,9 +64,12 @@ void SampleController::setUseGPUPhysics(bool useGPUPhysics)
int assetNum = getSceneController().releaseAll();
+ getBlastController().notifyPhysXControllerRelease();
getPhysXController().setUseGPUPhysics(useGPUPhysics);
getBlastController().reinitialize();
+ getRenderer().clearQueue();
+
getSceneController().spawnAsset(assetNum);
}
diff --git a/samples/SampleBase/core/SampleController.h b/samples/SampleBase/core/SampleController.h
index a52c2fe..6d478c1 100644
--- a/samples/SampleBase/core/SampleController.h
+++ b/samples/SampleBase/core/SampleController.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef SAMPLE_CONTROLLER_H
#define SAMPLE_CONTROLLER_H
@@ -48,6 +66,11 @@ private:
return getManager()->getCommonUIController();
}
+ Renderer& getRenderer() const
+ {
+ return getManager()->getRenderer();
+ }
+
//////// private methods ////////
diff --git a/samples/SampleBase/core/SampleManager.cpp b/samples/SampleBase/core/SampleManager.cpp
index da5cb22..2535919 100644
--- a/samples/SampleBase/core/SampleManager.cpp
+++ b/samples/SampleBase/core/SampleManager.cpp
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#include "SampleManager.h"
diff --git a/samples/SampleBase/core/SampleManager.h b/samples/SampleBase/core/SampleManager.h
index 59ecc8c..d44523e 100644
--- a/samples/SampleBase/core/SampleManager.h
+++ b/samples/SampleBase/core/SampleManager.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef SAMPLE_MANAGER_H
#define SAMPLE_MANAGER_H
diff --git a/samples/SampleBase/physx/PhysXController.cpp b/samples/SampleBase/physx/PhysXController.cpp
index 1df06be..b473c8e 100644
--- a/samples/SampleBase/physx/PhysXController.cpp
+++ b/samples/SampleBase/physx/PhysXController.cpp
@@ -1,12 +1,30 @@
-/*
- * Copyright (c) 2008-2015, 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.
- */
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#include "PhysXController.h"
#include "RenderMaterial.h"
@@ -19,7 +37,8 @@
#include "ConvexRenderMesh.h"
#include "RenderUtils.h"
#include "SampleProfiler.h"
-#include "NvBlastProfiler.h"
+#include "NvBlastExtCustomProfiler.h"
+#include "NvBlastPxCallbacks.h"
#include "PxPhysicsVersion.h"
#include "PxPvdTransport.h"
@@ -47,9 +66,12 @@ const DirectX::XMFLOAT4 PLANE_COLOR(1.0f, 1.0f, 1.0f, 1.0f);
const DirectX::XMFLOAT4 HOOK_LINE_COLOR(1.0f, 1.0f, 1.0f, 1.0f);
const float DEFAULT_FIXED_TIMESTEP = 1.0f / 60.0f;
+static Nv::Blast::ExtCustomProfiler gBlastProfiler;
+
PhysXController::PhysXController(PxSimulationFilterShader filterShader)
: m_filterShader(filterShader)
, m_gpuPhysicsAvailable(true)
+, m_isSimulating(false)
, m_useGPUPhysics(true)
, m_lastSimulationTime(0)
, m_paused(false)
@@ -77,6 +99,7 @@ void PhysXController::onInitialize()
void PhysXController::onTerminate()
{
+ simualtionSyncEnd();
releasePhysXPrimitives();
releasePhysX();
}
@@ -88,13 +111,13 @@ void PhysXController::onTerminate()
void PhysXController::initPhysX()
{
- m_foundation = PxCreateFoundation(PX_FOUNDATION_VERSION, m_allocator, m_errorCallback);
+ m_foundation = PxCreateFoundation(PX_FOUNDATION_VERSION, NvBlastGetPxAllocatorCallback(), NvBlastGetPxErrorCallback());
m_pvd = PxCreatePvd(*m_foundation);
- NvBlastProfilerSetCallback(m_pvd);
- NvBlastProfilerEnablePlatform(false);
- NvBlastProfilerSetDetail(NvBlastProfilerDetail::LOW);
+ NvBlastProfilerSetCallback(&gBlastProfiler);
+ NvBlastProfilerSetDetail(Nv::Blast::ProfilerDetail::LOW);
+ gBlastProfiler.setPlatformEnabled(false);
PxTolerancesScale scale;
@@ -237,54 +260,77 @@ void PhysXController::notifyRigidDynamicDestroyed(PxRigidDynamic* rigidDynamic)
}
-
-
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-// Controller events
+// Simulation control
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-void PhysXController::Animate(double dt)
+void PhysXController::simulationBegin(float dt)
{
PROFILER_SCOPED_FUNCTION();
if (m_paused)
return;
- // slower physics if fps is too low
- dt = PxClamp(dt, 0.0, 0.033333);
-
updateDragging(dt);
+ processExplosionQueue();
+
+ // slower physics if fps is too low
+ dt = PxClamp(dt, 0.0f, 0.0333f);
{
- PROFILER_SCOPED("PhysX simulate");
- steady_clock::time_point start = steady_clock::now();
+ PROFILER_SCOPED("PhysX simulate call");
if (m_useFixedTimeStep)
{
m_timeAccumulator += dt;
m_substepCount = (uint32_t)std::floor(m_timeAccumulator / m_fixedTimeStep);
m_timeAccumulator -= m_fixedTimeStep * m_substepCount;
m_substepCount = m_maxSubstepCount > 0 ? physx::PxClamp<uint32_t>(m_substepCount, 0, m_maxSubstepCount) : m_substepCount;
- for (uint32_t i = 0; i < m_substepCount; ++i)
+ if (m_substepCount > 0)
{
- PROFILER_SCOPED("PhysX simulate (substep)");
m_physicsScene->simulate(m_fixedTimeStep);
- m_physicsScene->fetchResults(true);
+ m_isSimulating = true;
}
}
else
{
m_substepCount = 1;
+ PX_ASSERT(!m_isSimulating);
m_physicsScene->simulate(dt);
- m_physicsScene->fetchResults(true);
+ m_isSimulating = true;
+
}
- m_lastSimulationTime = duration_cast<microseconds>(steady_clock::now() - start).count() * 0.000001;
}
+}
+
+void PhysXController::simualtionSyncEnd()
+{
+ PROFILER_SCOPED_FUNCTION();
- PROFILER_BEGIN("Debug Render Buffer");
- getRenderer().queueRenderBuffer(&m_physicsScene->getRenderBuffer());
- PROFILER_END();
+ if (m_isSimulating)
+ {
+ steady_clock::time_point start = steady_clock::now();
+ m_physicsScene->fetchResults(true);
- updateActorTransforms();
+ // For fixed time step case it could be that we need more then one step (m_maxSubstepCount > 1). We will run leftover steps synchronously right there.
+ // Ideally is to make them overlap with other logic too, but it's much harder and requires more synchronization logic. Don't want to obfuscate sample code.
+ if (m_useFixedTimeStep && m_substepCount > 1)
+ {
+ for (uint32_t i = 0; i < m_substepCount - 1; i++)
+ {
+ m_physicsScene->simulate(m_fixedTimeStep);
+ m_physicsScene->fetchResults(true);
+ }
+ }
+ m_lastSimulationTime = duration_cast<microseconds>(steady_clock::now() - start).count() * 0.000001;
+
+ m_isSimulating = false;
+
+ updateActorTransforms();
+
+ PROFILER_BEGIN("Debug Render Buffer");
+ getRenderer().queueRenderBuffer(&m_physicsScene->getRenderBuffer());
+ PROFILER_END();
+ }
}
@@ -352,8 +398,11 @@ void PhysXController::updateDragging(double dt)
PxVec3 hookPoint = m_draggingActor->getGlobalPose().transform(m_draggingActorHookLocalPoint);
m_draggingActorLastHookWorldPoint = hookPoint;
m_dragVector = (m_dragAttractionPoint - hookPoint);
- PxVec3 dragVeloctiy = (m_dragVector * DRAGGING_FORCE_FACTOR - DRAGGING_VELOCITY_FACTOR * m_draggingActor->getLinearVelocity()) * dt;
- PxRigidBodyExt::addForceAtLocalPos(*m_draggingActor, dragVeloctiy * m_draggingActor->getMass(), m_draggingActorHookLocalPoint, PxForceMode::eIMPULSE, true);
+ if (!m_draggingActor->getRigidBodyFlags().isSet(PxRigidBodyFlag::eKINEMATIC))
+ {
+ PxVec3 dragVeloctiy = (m_dragVector * DRAGGING_FORCE_FACTOR - DRAGGING_VELOCITY_FACTOR * m_draggingActor->getLinearVelocity()) * dt;
+ PxRigidBodyExt::addForceAtLocalPos(*m_draggingActor, dragVeloctiy * m_draggingActor->getMass(), m_draggingActorHookLocalPoint, PxForceMode::eIMPULSE, true);
+ }
// debug render line
m_dragDebugRenderBuffer.clear();
@@ -393,9 +442,12 @@ LRESULT PhysXController::MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPa
m_dragDistance = (eyePos - hit.position).magnitude();
m_draggingActor = hit.actor->is<PxRigidDynamic>();
m_draggingActorHookLocalPoint = m_draggingActor->getGlobalPose().getInverse().transform(hit.position);
- m_draggingActor->setLinearVelocity(PxVec3(0, 0, 0));
- m_draggingActor->setAngularVelocity(PxVec3(0, 0, 0));
m_dragAttractionPoint = hit.position;
+ if (!m_draggingActor->getRigidBodyFlags().isSet(PxRigidBodyFlag::eKINEMATIC))
+ {
+ m_draggingActor->setLinearVelocity(PxVec3(0, 0, 0));
+ m_draggingActor->setAngularVelocity(PxVec3(0, 0, 0));
+ }
}
}
}
@@ -422,6 +474,71 @@ LRESULT PhysXController::MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPa
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Explosion
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+class ExplodeOverlapCallback : public PxOverlapCallback
+{
+public:
+ ExplodeOverlapCallback(PxVec3 worldPos, float radius, float explosiveImpulse)
+ : m_worldPos(worldPos)
+ , m_radius(radius)
+ , m_explosiveImpulse(explosiveImpulse)
+ , PxOverlapCallback(m_hitBuffer, sizeof(m_hitBuffer) / sizeof(m_hitBuffer[0])) {}
+
+ PxAgain processTouches(const PxOverlapHit* buffer, PxU32 nbHits)
+ {
+ for (PxU32 i = 0; i < nbHits; ++i)
+ {
+ PxRigidActor* actor = buffer[i].actor;
+ PxRigidDynamic* rigidDynamic = actor->is<PxRigidDynamic>();
+ if (rigidDynamic && !(rigidDynamic->getRigidBodyFlags() & PxRigidBodyFlag::eKINEMATIC))
+ {
+ if (m_actorBuffer.find(rigidDynamic) == m_actorBuffer.end())
+ {
+ m_actorBuffer.insert(rigidDynamic);
+ PxVec3 dr = rigidDynamic->getGlobalPose().transform(rigidDynamic->getCMassLocalPose()).p - m_worldPos;
+ float distance = dr.magnitude();
+ float factor = PxClamp(1.0f - (distance * distance) / (m_radius * m_radius), 0.0f, 1.0f);
+ float impulse = factor * m_explosiveImpulse * 1000.0f;
+ PxVec3 vel = dr.getNormalized() * impulse / rigidDynamic->getMass();
+ rigidDynamic->setLinearVelocity(rigidDynamic->getLinearVelocity() + vel);
+ }
+ }
+ }
+ return true;
+ }
+
+private:
+ PxOverlapHit m_hitBuffer[1000];
+ float m_explosiveImpulse;
+ std::set<PxRigidDynamic*> m_actorBuffer;
+ PxVec3 m_worldPos;
+ float m_radius;
+};
+
+void PhysXController::explode(PxVec3 worldPos, float damageRadius, float explosiveImpulse)
+{
+ ExplodeOverlapCallback overlapCallback(worldPos, damageRadius, explosiveImpulse);
+ m_physicsScene->overlap(PxSphereGeometry(damageRadius), PxTransform(worldPos), overlapCallback);
+}
+
+void PhysXController::explodeDelayed(PxVec3 worldPos, float damageRadius, float explosiveImpulse)
+{
+ m_explosionQueue.push_back({ worldPos, damageRadius, explosiveImpulse });
+}
+
+void PhysXController::processExplosionQueue()
+{
+ for (auto& e : m_explosionQueue)
+ {
+ explode(e.worldPos, e.damageRadius, e.explosiveImpulse);
+ }
+ m_explosionQueue.clear();
+}
+
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// UI
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -435,8 +552,7 @@ void PhysXController::drawUI()
}
ImGui::Text("Substep Count: %d", m_substepCount);
- ImGui::Text("Simulation Time (total): %4.2f ms", getLastSimulationTime() * 1000);
- ImGui::Text("Simulation Time (substep): %4.2f ms", m_substepCount > 0 ? (getLastSimulationTime() / m_substepCount) * 1000 : 0.0);
+ ImGui::Text("Sync Simulation Time (total): %4.2f ms", getLastSimulationTime() * 1000);
}
@@ -544,7 +660,7 @@ void PhysXController::removeUnownedPhysXActors()
{
if (m_physXActorsToRemove.size())
{
- m_physicsScene->removeActors(&m_physXActorsToRemove[0], (PxU32)m_physXActorsToRemove.size());
+ m_physicsScene->removeActors(m_physXActorsToRemove.data(), (PxU32)m_physXActorsToRemove.size());
for (size_t i = 0; i < m_physXActorsToRemove.size(); ++i)
{
m_physXActorsToRemove[i]->release();
@@ -567,7 +683,7 @@ PhysXController::Actor::Actor(PhysXController* controller, PxRigidActor* actor,
uint32_t shapesCount = actor->getNbShapes();
m_shapes.resize(shapesCount);
- actor->getShapes(&m_shapes[0], shapesCount);
+ actor->getShapes(m_shapes.data(), shapesCount);
m_renderables.resize(m_shapes.size());
for (uint32_t i = 0; i < m_shapes.size(); i++)
diff --git a/samples/SampleBase/physx/PhysXController.h b/samples/SampleBase/physx/PhysXController.h
index 625de0c..4692bad 100644
--- a/samples/SampleBase/physx/PhysXController.h
+++ b/samples/SampleBase/physx/PhysXController.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef PHYSX_CONTROLLER_H
#define PHYSX_CONTROLLER_H
@@ -15,8 +33,6 @@
#include <DirectXMath.h>
#include "DebugRenderBuffer.h"
#include "PxFiltering.h"
-#include "PxDefaultAllocator.h"
-#include "PxDefaultErrorCallback.h"
#include <set>
#include <map>
@@ -32,8 +48,6 @@ namespace physx
{
class PxCpuDispatcher;
class PxFoundation;
-class PxDefaultAllocator;
-class PxDefaultErrorCallback;
class PxPhysics;
class PxCooking;
class PxPvd;
@@ -95,16 +109,17 @@ class PhysXController : public ISampleController
//////// virtual callbacks ////////
- virtual void onInitialize();
- virtual void onTerminate();
-
- virtual void Animate(double dt);
+ virtual void onInitialize() override;
+ virtual void onTerminate() override;
virtual LRESULT MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
//////// public API ////////
+ void simulationBegin(float dt);
+ void simualtionSyncEnd();
+
void getEyePoseAndPickDir(float mouseX, float mouseY, PxVec3& eyePos, PxVec3& pickDir);
// wrappers to physx calls
@@ -138,6 +153,9 @@ class PhysXController : public ISampleController
void notifyRigidDynamicDestroyed(PxRigidDynamic*);
+ void explode(PxVec3 worldPos, float damageRadius, float explosiveImpulse);
+ void explodeDelayed(PxVec3 worldPos, float damageRadius, float explosiveImpulse);
+
void drawUI();
//////// public getters ////////
@@ -219,6 +237,7 @@ class PhysXController : public ISampleController
void releasePhysXPrimitives();
void updateActorTransforms();
void updateDragging(double dt);
+ void processExplosionQueue();
//////// used controllers ////////
@@ -233,8 +252,6 @@ class PhysXController : public ISampleController
// PhysX
PxFoundation* m_foundation;
- PxDefaultAllocator m_allocator;
- PxDefaultErrorCallback m_errorCallback;
PxPhysics* m_physics;
PxCooking* m_cooking;
PxPvd* m_pvd;
@@ -255,9 +272,10 @@ class PhysXController : public ISampleController
RenderMaterial* m_physXPrimitiveTransparentRenderMaterial;
// simulation
+ bool m_isSimulating;
bool m_gpuPhysicsAvailable;
bool m_useGPUPhysics;
- double m_lastSimulationTime;
+ double m_lastSimulationTime;
LARGE_INTEGER m_performanceFreq;
bool m_paused;
bool m_useFixedTimeStep;
@@ -280,6 +298,15 @@ class PhysXController : public ISampleController
// Performance writer
PerformanceDataWriter* m_perfWriter;
+ // explosion
+ struct ExplosionData
+ {
+ PxVec3 worldPos;
+ float damageRadius;
+ float explosiveImpulse;
+ };
+
+ std::vector<ExplosionData> m_explosionQueue;
};
diff --git a/samples/SampleBase/renderer/ConvexRenderMesh.cpp b/samples/SampleBase/renderer/ConvexRenderMesh.cpp
index 074cc2d..dc938b9 100644
--- a/samples/SampleBase/renderer/ConvexRenderMesh.cpp
+++ b/samples/SampleBase/renderer/ConvexRenderMesh.cpp
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#include "ConvexRenderMesh.h"
#include "Renderer.h"
diff --git a/samples/SampleBase/renderer/ConvexRenderMesh.h b/samples/SampleBase/renderer/ConvexRenderMesh.h
index dfe8d8f..f7bc5c6 100644
--- a/samples/SampleBase/renderer/ConvexRenderMesh.h
+++ b/samples/SampleBase/renderer/ConvexRenderMesh.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef CONVEX_RENDER_MESH_H
#define CONVEX_RENDER_MESH_H
diff --git a/samples/SampleBase/renderer/CustomRenderMesh.cpp b/samples/SampleBase/renderer/CustomRenderMesh.cpp
index 61ae9e0..0feae3f 100644
--- a/samples/SampleBase/renderer/CustomRenderMesh.cpp
+++ b/samples/SampleBase/renderer/CustomRenderMesh.cpp
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#include "CustomRenderMesh.h"
diff --git a/samples/SampleBase/renderer/CustomRenderMesh.h b/samples/SampleBase/renderer/CustomRenderMesh.h
index b0ddea1..025d3bf 100644
--- a/samples/SampleBase/renderer/CustomRenderMesh.h
+++ b/samples/SampleBase/renderer/CustomRenderMesh.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef CUSTOM_RENDER_MESH_H
#define CUSTOM_RENDER_MESH_H
diff --git a/samples/SampleBase/renderer/DebugRenderBuffer.h b/samples/SampleBase/renderer/DebugRenderBuffer.h
index 7810733..06cd509 100644
--- a/samples/SampleBase/renderer/DebugRenderBuffer.h
+++ b/samples/SampleBase/renderer/DebugRenderBuffer.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef DEBUGRENDERBUFFER_H
#define DEBUGRENDERBUFFER_H
diff --git a/samples/SampleBase/renderer/Mesh.cpp b/samples/SampleBase/renderer/Mesh.cpp
index cdf63f2..c6c8398 100644
--- a/samples/SampleBase/renderer/Mesh.cpp
+++ b/samples/SampleBase/renderer/Mesh.cpp
@@ -1,12 +1,29 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
#include "Mesh.h"
diff --git a/samples/SampleBase/renderer/Mesh.h b/samples/SampleBase/renderer/Mesh.h
index 6951198..8423af8 100644
--- a/samples/SampleBase/renderer/Mesh.h
+++ b/samples/SampleBase/renderer/Mesh.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef MESH_H
#define MESH_H
diff --git a/samples/SampleBase/renderer/PrimitiveRenderMesh.cpp b/samples/SampleBase/renderer/PrimitiveRenderMesh.cpp
index 329f47b..64dc51b 100644
--- a/samples/SampleBase/renderer/PrimitiveRenderMesh.cpp
+++ b/samples/SampleBase/renderer/PrimitiveRenderMesh.cpp
@@ -1,12 +1,29 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
#include "PrimitiveRenderMesh.h"
diff --git a/samples/SampleBase/renderer/PrimitiveRenderMesh.h b/samples/SampleBase/renderer/PrimitiveRenderMesh.h
index f72c191..1139336 100644
--- a/samples/SampleBase/renderer/PrimitiveRenderMesh.h
+++ b/samples/SampleBase/renderer/PrimitiveRenderMesh.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef PRIMITIVE_RENDER_MESH_H
#define PRIMITIVE_RENDER_MESH_H
diff --git a/samples/SampleBase/renderer/RenderMaterial.cpp b/samples/SampleBase/renderer/RenderMaterial.cpp
index cb40ec7..6ef9458 100644
--- a/samples/SampleBase/renderer/RenderMaterial.cpp
+++ b/samples/SampleBase/renderer/RenderMaterial.cpp
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#include "RenderMaterial.h"
#include <DirectXMath.h>
diff --git a/samples/SampleBase/renderer/RenderMaterial.h b/samples/SampleBase/renderer/RenderMaterial.h
index a342459..833b721 100644
--- a/samples/SampleBase/renderer/RenderMaterial.h
+++ b/samples/SampleBase/renderer/RenderMaterial.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef RENDER_MATERIAL_H
#define RENDER_MATERIAL_H
diff --git a/samples/SampleBase/renderer/RenderUtils.h b/samples/SampleBase/renderer/RenderUtils.h
index 12df9f2..098f7a9 100644
--- a/samples/SampleBase/renderer/RenderUtils.h
+++ b/samples/SampleBase/renderer/RenderUtils.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef RENDER_UTILS_H
#define RENDER_UTILS_H
@@ -75,4 +93,27 @@ static DirectX::XMFLOAT4 XMFLOAT4Lerp(const DirectX::XMFLOAT4 v0, const DirectX:
return v;
}
+static const physx::PxVec3 forwardVector = physx::PxVec3(0, 0, 1);
+static const physx::PxVec3 upVector = physx::PxVec3(0, 1, 0);
+static const physx::PxVec3 rightVector = physx::PxVec3(1, 0, 0);
+
+PX_INLINE physx::PxQuat quatLookAt(const physx::PxVec3 direction)
+{
+ float d = direction.dot(forwardVector);
+ if (physx::PxAbs(d + 1.0f) < 1e-5f)
+ {
+ return physx::PxQuat(physx::PxPi, upVector);
+ }
+ else if (physx::PxAbs(d - 1.0f) < 1e-5f)
+ {
+ return physx::PxQuat(physx::PxIdentity);
+ }
+ else
+ {
+ float angle = physx::PxAcos(d);
+ physx::PxVec3 axis = forwardVector.cross(direction).getNormalized();
+ return physx::PxQuat(angle, axis);
+ }
+}
+
#endif //RENDER_UTILS_H \ No newline at end of file
diff --git a/samples/SampleBase/renderer/Renderable.cpp b/samples/SampleBase/renderer/Renderable.cpp
index 340874b..6047052 100644
--- a/samples/SampleBase/renderer/Renderable.cpp
+++ b/samples/SampleBase/renderer/Renderable.cpp
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#include "Renderable.h"
#include "Renderer.h"
diff --git a/samples/SampleBase/renderer/Renderable.h b/samples/SampleBase/renderer/Renderable.h
index f1faa52..9495513 100644
--- a/samples/SampleBase/renderer/Renderable.h
+++ b/samples/SampleBase/renderer/Renderable.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef RENDERABLE_H
#define RENDERABLE_H
diff --git a/samples/SampleBase/renderer/Renderer.cpp b/samples/SampleBase/renderer/Renderer.cpp
index 94ea3c3..b708f89 100644
--- a/samples/SampleBase/renderer/Renderer.cpp
+++ b/samples/SampleBase/renderer/Renderer.cpp
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#include "Renderer.h"
#include "RenderUtils.h"
diff --git a/samples/SampleBase/renderer/Renderer.h b/samples/SampleBase/renderer/Renderer.h
index 56e6e4a..9c358de 100644
--- a/samples/SampleBase/renderer/Renderer.h
+++ b/samples/SampleBase/renderer/Renderer.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef RENDERER_H
#define RENDERER_H
@@ -95,7 +113,12 @@ class Renderer : public ISampleController
m_queuedRenderBuffers.push_back(buffer);
}
- ResourceManager& getResourceManager()
+ void clearQueue()
+ {
+ m_queuedRenderBuffers.clear();
+ }
+
+ ResourceManager& getResourceManager()
{
return m_resourceManager;
}
diff --git a/samples/SampleBase/renderer/RendererHBAO.cpp b/samples/SampleBase/renderer/RendererHBAO.cpp
index 5e20a49..c674b2b 100644
--- a/samples/SampleBase/renderer/RendererHBAO.cpp
+++ b/samples/SampleBase/renderer/RendererHBAO.cpp
@@ -1,12 +1,29 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
#include "RendererHBAO.h"
diff --git a/samples/SampleBase/renderer/RendererHBAO.h b/samples/SampleBase/renderer/RendererHBAO.h
index 2478628..3237ddf 100644
--- a/samples/SampleBase/renderer/RendererHBAO.h
+++ b/samples/SampleBase/renderer/RendererHBAO.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef RENDERER_HBAO_H
#define RENDERER_HBAO_H
diff --git a/samples/SampleBase/renderer/RendererShadow.cpp b/samples/SampleBase/renderer/RendererShadow.cpp
index 28a79e5..71527de 100644
--- a/samples/SampleBase/renderer/RendererShadow.cpp
+++ b/samples/SampleBase/renderer/RendererShadow.cpp
@@ -1,12 +1,29 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
#include "RendererShadow.h"
diff --git a/samples/SampleBase/renderer/RendererShadow.h b/samples/SampleBase/renderer/RendererShadow.h
index cc81c67..328da58 100644
--- a/samples/SampleBase/renderer/RendererShadow.h
+++ b/samples/SampleBase/renderer/RendererShadow.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef RENDERER_SHADOW_H
#define RENDERER_SHADOW_H
diff --git a/samples/SampleBase/renderer/ResourceManager.cpp b/samples/SampleBase/renderer/ResourceManager.cpp
index f8a4b7b..8650ceb 100644
--- a/samples/SampleBase/renderer/ResourceManager.cpp
+++ b/samples/SampleBase/renderer/ResourceManager.cpp
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#include "ResourceManager.h"
#include "PxAssert.h"
diff --git a/samples/SampleBase/renderer/ResourceManager.h b/samples/SampleBase/renderer/ResourceManager.h
index 6a9b8cd..2bc8f02 100644
--- a/samples/SampleBase/renderer/ResourceManager.h
+++ b/samples/SampleBase/renderer/ResourceManager.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef RESOURCE_MANAGER_H
#define RESOURCE_MANAGER_H
diff --git a/samples/SampleBase/renderer/ShaderUtils.h b/samples/SampleBase/renderer/ShaderUtils.h
index 778c811..da9caa0 100644
--- a/samples/SampleBase/renderer/ShaderUtils.h
+++ b/samples/SampleBase/renderer/ShaderUtils.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef SHADER_UTILS_H
#define SHADER_UTILS_H
diff --git a/samples/SampleBase/renderer/SkinnedRenderMesh.cpp b/samples/SampleBase/renderer/SkinnedRenderMesh.cpp
index c575d6c..ff121d6 100644
--- a/samples/SampleBase/renderer/SkinnedRenderMesh.cpp
+++ b/samples/SampleBase/renderer/SkinnedRenderMesh.cpp
@@ -1,12 +1,29 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
#include "SkinnedRenderMesh.h"
diff --git a/samples/SampleBase/renderer/SkinnedRenderMesh.h b/samples/SampleBase/renderer/SkinnedRenderMesh.h
index 2f690d8..f3643d8 100644
--- a/samples/SampleBase/renderer/SkinnedRenderMesh.h
+++ b/samples/SampleBase/renderer/SkinnedRenderMesh.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef SKINNED_RENDER_MESH_H
#define SKINNED_RENDER_MESH_H
diff --git a/samples/SampleBase/scene/SampleAssetListParser.cpp b/samples/SampleBase/scene/SampleAssetListParser.cpp
index 00cf4df..b58f9f1 100644
--- a/samples/SampleBase/scene/SampleAssetListParser.cpp
+++ b/samples/SampleBase/scene/SampleAssetListParser.cpp
@@ -1,18 +1,37 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#include "SampleAssetListParser.h"
#include <PsFastXml.h>
#include "Sample.h"
#include "PxVec4.h"
#include "PxInputDataFromPxFileBuf.h"
+#include <bitset>
using namespace physx;
@@ -104,11 +123,6 @@ protected:
{
m_boxTemp.name = std::string(attr.getValue(i));
}
- else if (::strcmp(attr.getKey(i), "staticHeight") == 0)
- {
- std::string str = attr.getValue(i);
- sscanf(&str[0], "%f", &m_boxTemp.staticHeight);
- }
else if (::strcmp(attr.getKey(i), "jointAllBonds") == 0)
{
std::string str = attr.getValue(i);
@@ -122,6 +136,12 @@ protected:
std::string str = attr.getValue(i);
sscanf(&str[0], "%f %f %f", &m_boxTemp.extents.x, &m_boxTemp.extents.y, &m_boxTemp.extents.z);
}
+ else if (::strcmp(attr.getKey(i), "bondFlagsMask") == 0)
+ {
+ std::string str = attr.getValue(i);
+ std::bitset<8> bondFlags(str);
+ m_boxTemp.bondFlags = static_cast<uint32_t>(bondFlags.to_ulong());
+ }
}
if (m_boxTemp.id.empty())
diff --git a/samples/SampleBase/scene/SampleAssetListParser.h b/samples/SampleBase/scene/SampleAssetListParser.h
index b6303ec..5d22833 100644
--- a/samples/SampleBase/scene/SampleAssetListParser.h
+++ b/samples/SampleBase/scene/SampleAssetListParser.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef SAMPLEASSETLISTPARSER_H
#define SAMPLEASSETLISTPARSER_H
diff --git a/samples/SampleBase/scene/SceneController.cpp b/samples/SampleBase/scene/SceneController.cpp
index eeaca25..390682c 100644
--- a/samples/SampleBase/scene/SceneController.cpp
+++ b/samples/SampleBase/scene/SceneController.cpp
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#include "SceneController.h"
#include "RenderUtils.h"
@@ -94,6 +112,8 @@ protected:
class SceneActor
{
public:
+ SceneActor() : removeOnReload(false) {}
+
virtual ~SceneActor() {}
virtual const char* getName() const = 0;
virtual const char* getSubname(int subindex) const { return nullptr; }
@@ -104,6 +124,8 @@ public:
virtual PxVec3 getSpawnShift() const { return PxVec3(PxZero); }
virtual void reload() {}
virtual void removeSubactor(int subindex) {}
+
+ bool removeOnReload;
};
@@ -116,7 +138,7 @@ public:
int subindex;
ActorIndex() { reset(); }
- ActorIndex(int i, int s) : index(i), subindex(s) {}
+ ActorIndex(int i, int s = -1) : index(i), subindex(s) {}
bool operator==(const ActorIndex& other) const
{
@@ -402,10 +424,28 @@ public:
void reloadAllActors()
{
- for (SceneActor* a : m_sceneActors)
+ SceneActor* selectedActor = getSelectedActor();
+ ActorIndex selectIndex(0);
+
+ for (uint32_t i = 0; i < m_sceneActors.size(); i++)
+ {
+ if (m_sceneActors[i]->removeOnReload)
+ {
+ removeSceneActor(ActorIndex(i));
+ i--;
+ }
+ }
+
+ for (uint32_t i = 0; i < m_sceneActors.size(); i++)
{
- a->reload();
+ if (m_sceneActors[i] == selectedActor)
+ {
+ selectIndex.index = i;
+ }
+ m_sceneActors[i]->reload();
}
+
+ setSelectedActor(selectIndex.index, selectIndex.subindex);
}
void registerTkAsset(const TkAsset& tkAsset, SingleSceneAsset* asset)
@@ -544,7 +584,7 @@ public:
virtual BlastAsset* createAsset()
{
return new BlastAssetModelSimple(m_scene->getBlastController().getTkFramework(), m_scene->getPhysXController().getPhysics(),
- m_scene->getPhysXController().getCooking(), m_scene->getRenderer(), desc.file.c_str());
+ m_scene->getPhysXController().getCooking(), *m_scene->getBlastController().getExtSerialization(), m_scene->getRenderer(), desc.file.c_str());
}
virtual ImVec4 getUIColor() const override
@@ -557,10 +597,10 @@ public:
class SkinnedModelSceneAsset : public ModelSceneAsset
{
public:
- virtual BlastAsset* createAsset()
+ virtual BlastAsset* createAsset()
{
return new BlastAssetModelSkinned(m_scene->getBlastController().getTkFramework(), m_scene->getPhysXController().getPhysics(),
- m_scene->getPhysXController().getCooking(), m_scene->getRenderer(), desc.file.c_str());
+ m_scene->getPhysXController().getCooking(), *m_scene->getBlastController().getExtSerialization(), m_scene->getRenderer(), desc.file.c_str());
}
virtual ImVec4 getUIColor() const override
@@ -584,6 +624,7 @@ public:
assetDesc.generatorSettings.extents = GeneratorAsset::Vec3(desc.extents.x, desc.extents.y, desc.extents.z);
assetDesc.staticHeight = desc.staticHeight;
assetDesc.jointAllBonds = desc.jointAllBonds;
+ assetDesc.generatorSettings.bondFlags = (CubeAssetGenerator::BondFlags)desc.bondFlags;
}
virtual ImVec4 getUIColor() const override
@@ -1078,7 +1119,7 @@ protected:
// Controller
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-SceneController::SceneController() : m_cubeScale(1.0f)
+SceneController::SceneController() : m_cubeScale(1.0f), m_cubeThrowDownTime(-1.f)
{
m_scene = NULL;
}
@@ -1220,12 +1261,28 @@ LRESULT SceneController::MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPa
m_scene->reloadAllActors();
return 0;
case 'F':
- throwCube();
+ if (m_cubeThrowDownTime == -1.f)
+ {
+ m_cubeThrowDownTime = ImGui::GetTime();
+ }
return 0;
default:
break;
}
}
+ else if (uMsg == WM_KEYUP)
+ {
+ int iKeyPressed = static_cast<int>(wParam);
+ switch (iKeyPressed)
+ {
+ case 'F':
+ throwCube();
+ m_cubeThrowDownTime = -1.f;
+ return 0;
+ default:
+ break;
+ }
+ }
return 1;
}
@@ -1325,6 +1382,7 @@ void SceneController::drawUI()
{
ImGui::Text("Thrown Cube Params (F)");
ImGui::DragFloat("Cube Size", &m_cubeScale, 1.0f, 0.0f, 100.0f);
+ ImGui::Text("Cube Speed (hold F): %1.f", getCubeSpeed());
}
}
@@ -1334,9 +1392,15 @@ void SceneController::drawStatsUI()
m_scene->drawStatsUI();
}
+float SceneController::getCubeSpeed()
+{
+ const float CUBE_VELOCITY_SPEED_MIN = 70;
+ const float CUBE_VELOCITY_CHARGE_PER_SECOND = 300;
+ return m_cubeThrowDownTime > 0 ? CUBE_VELOCITY_SPEED_MIN + (ImGui::GetTime() - m_cubeThrowDownTime) * CUBE_VELOCITY_CHARGE_PER_SECOND : 0.f;
+}
+
void SceneController::throwCube()
{
- const float CUBE_VELOCITY = 100;
const float CUBE_DENSITY = 20000.0f;
CFirstPersonCamera* camera = &getRenderer().getCamera();
@@ -1347,9 +1411,11 @@ void SceneController::throwCube()
cube->setColor(DirectX::XMFLOAT4(1, 0, 0, 1));
PxVec3 dir = (lookAtPos - eyePos).getNormalized();
- rigidDynamic->setLinearVelocity(dir * CUBE_VELOCITY);
+ rigidDynamic->setLinearVelocity(dir * getCubeSpeed());
- m_scene->addSceneActor(new PhysXSceneActor(getPhysXController(), cube, "Cube"));
+ PhysXSceneActor* actor = new PhysXSceneActor(getPhysXController(), cube, "Cube");
+ actor->removeOnReload = true;
+ m_scene->addSceneActor(actor);
}
void SceneController::spawnAsset(int32_t num)
diff --git a/samples/SampleBase/scene/SceneController.h b/samples/SampleBase/scene/SceneController.h
index 0b13878..54a5ff1 100644
--- a/samples/SampleBase/scene/SceneController.h
+++ b/samples/SampleBase/scene/SceneController.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef SCENE_CONTROLLER_H
#define SCENE_CONTROLLER_H
@@ -47,6 +65,7 @@ public:
private:
void addAssets(const AssetList& assetList, bool loadModels = true);
void throwCube();
+ float getCubeSpeed();
SceneController& operator= (SceneController&);
@@ -78,6 +97,7 @@ private:
Scene* m_scene;
float m_cubeScale;
+ float m_cubeThrowDownTime;
};
#endif \ No newline at end of file
diff --git a/samples/SampleBase/ui/CommonUIController.cpp b/samples/SampleBase/ui/CommonUIController.cpp
index e56a124..f9e218b 100644
--- a/samples/SampleBase/ui/CommonUIController.cpp
+++ b/samples/SampleBase/ui/CommonUIController.cpp
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#include "CommonUIController.h"
diff --git a/samples/SampleBase/ui/CommonUIController.h b/samples/SampleBase/ui/CommonUIController.h
index da62674..4656203 100644
--- a/samples/SampleBase/ui/CommonUIController.h
+++ b/samples/SampleBase/ui/CommonUIController.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef COMMON_UI_CONTROLLER_H
#define COMMON_UI_CONTROLLER_H
diff --git a/samples/SampleBase/ui/DamageToolController.cpp b/samples/SampleBase/ui/DamageToolController.cpp
index 1850b26..2f8837c 100644
--- a/samples/SampleBase/ui/DamageToolController.cpp
+++ b/samples/SampleBase/ui/DamageToolController.cpp
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#include "DamageToolController.h"
#include "RenderUtils.h"
@@ -18,6 +36,7 @@
#include <imgui.h>
#include "NvBlastTkActor.h"
+#include "NvBlastTkFamily.h"
#include "NvBlastExtDamageShaders.h"
#include "NvBlastExtPxActor.h"
@@ -32,44 +51,84 @@ using namespace physx;
// Setup
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
const DirectX::XMFLOAT4 PICK_POINTER_ACTIVE_COLOR(1.0f, 0.f, 0.f, 0.6f);
+static const PxVec3 WEAPON_POSITION_IN_VIEW(0, -7, 23);
+static const float SEGMENT_DAMAGE_MAX_DISTANCE = 100.0f;
+
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
DamageToolController::DamageToolController()
- : m_damageRadius(5.0f), m_compressiveDamage(1.0f), m_pickPointerColor(1.0f, 1.0f, 1.0f, 0.4f),
- m_pickPointerRenderMaterial(nullptr), m_pickPointerRenderable(nullptr), m_explosiveImpulse(100), m_damageProfile(0), m_stressForceFactor(1.0f)
+ : m_damage(100.0f), m_toolColor(1.0f, 1.0f, 1.0f, 0.4f),
+ m_toolRenderMaterial(nullptr), m_sphereToolRenderable(nullptr), m_lineToolRenderable(nullptr),
+ m_explosiveImpulse(100), m_damagerIndex(0), m_stressForceFactor(1.0f), m_isMousePressed(false), m_damageCountWhilePressed(0)
{
+ // damage amount calc using NvBlastExtMaterial
+ auto getDamageAmountFn = [](const float damage, ExtPxActor* actor)
+ {
+ const void* material = actor->getTkActor().getFamily().getMaterial();
+ return material ? reinterpret_cast<const NvBlastExtMaterial*>(material)->getNormalizedDamage(damage) : 0.f;
+ };
+
// Damage functions
- auto radialDamageExecute = [&](const Damager* damager, ExtPxActor* actor, PxVec3 position, PxVec3 normal)
+ auto radialDamageExecute = [&](const Damager* damager, ExtPxActor* actor, PxVec3 origin, PxVec3 position, PxVec3 normal)
{
- NvBlastExtRadialDamageDesc desc =
+ const float damage = getDamageAmountFn(m_damage, actor);
+ if (damage > 0.f)
{
- m_compressiveDamage,
- { position.x, position.y, position.z },
- m_damageRadius,
- m_damageRadius + 2.0f
- };
+ NvBlastExtRadialDamageDesc desc =
+ {
+ damage,
+ { position.x, position.y, position.z },
+ damager->radius,
+ damager->radius * 1.6f
+ };
- actor->getTkActor().damage(damager->program, &desc, sizeof(desc));
+ actor->getTkActor().damage(damager->program, &desc, sizeof(desc));
+ }
};
- auto shearDamageExecute = [&](const Damager* damager, ExtPxActor* actor, PxVec3 position, PxVec3 normal)
+ auto lineSegmentDamageExecute = [&](const Damager* damager, ExtPxActor* actor, PxVec3 origin, PxVec3 position, PxVec3 normal)
{
- PxVec3 force = -2 * normal;
+ const float damage = getDamageAmountFn(m_damage, actor);
+ if (damage > 0.f)
+ {
+ PxVec3 dir = (position - origin).getNormalized();
+ PxVec3 farEnd = origin + dir * 10000.0f;
- NvBlastExtShearDamageDesc desc =
+ NvBlastExtSegmentRadialDamageDesc desc =
+ {
+ damage,
+ { origin.x, origin.y, origin.z },
+ { farEnd.x, farEnd.y, farEnd.z },
+ damager->radius,
+ damager->radius * 1.6f
+ };
+
+ actor->getTkActor().damage(damager->program, &desc, sizeof(desc));
+ }
+ };
+ auto shearDamageExecute = [&](const Damager* damager, ExtPxActor* actor, PxVec3 origin, PxVec3 position, PxVec3 normal)
+ {
+ const float damage = getDamageAmountFn(m_damage, actor);
+ if (damage > 0.f)
{
- { force.x, force.y, force.z },
- { position.x, position.y, position.z }
- };
+ PxVec3 impactNormal = -normal;
- actor->getTkActor().damage(damager->program, &desc, sizeof(desc));
+ NvBlastExtShearDamageDesc desc =
+ {
+ damage,
+ { impactNormal.x, impactNormal.y, impactNormal.z },
+ { position.x, position.y, position.z },
+ damager->radius,
+ damager->radius * 1.6f
+ };
+
+ actor->getTkActor().damage(damager->program, &desc, sizeof(desc));
+ }
};
- auto stressDamageExecute = [&](const Damager* damager, ExtPxActor* actor, PxVec3 position, PxVec3 normal)
+ auto stressDamageExecute = [&](const Damager* damager, ExtPxActor* actor, PxVec3 origin, PxVec3 position, PxVec3 normal)
{
PxVec3 force = -m_stressForceFactor * normal * actor->getPhysXActor().getMass();
@@ -81,40 +140,57 @@ DamageToolController::DamageToolController()
Damager dam;
dam.uiName = "Radial Damage (Falloff)";
dam.program = NvBlastDamageProgram { NvBlastExtFalloffGraphShader, NvBlastExtFalloffSubgraphShader };
+ dam.pointerType = Damager::PointerType::Sphere;
dam.pointerColor = DirectX::XMFLOAT4(1.0f, 1.0f, 1.0f, 0.4f);
dam.executeFunction = radialDamageExecute;
- m_armory.push_back(dam);
+ m_damagers.push_back(dam);
}
{
Damager dam;
dam.uiName = "Radial Damage (Cutter)";
dam.program = NvBlastDamageProgram { NvBlastExtCutterGraphShader, NvBlastExtCutterSubgraphShader };
+ dam.pointerType = Damager::PointerType::Sphere;
dam.pointerColor = DirectX::XMFLOAT4(0.5f, 0.5f, 1.0f, 0.4f);
dam.executeFunction = radialDamageExecute;
- m_armory.push_back(dam);
+ m_damagers.push_back(dam);
+ }
+
+ {
+ Damager dam;
+ dam.uiName = "Segment Damage (Falloff)";
+ dam.program = NvBlastDamageProgram{ NvBlastExtSegmentFalloffGraphShader, NvBlastExtSegmentFalloffSubgraphShader };
+ dam.pointerType = Damager::PointerType::Line;
+ dam.pointerColor = DirectX::XMFLOAT4(0.1f, 1.0f, 0.1f, 0.4f);
+ dam.executeFunction = lineSegmentDamageExecute;
+ dam.damageWhilePressed = true;
+ dam.radius = .2f;
+ dam.radiusLimit = 20.0f;
+ m_damagers.push_back(dam);
}
{
Damager dam;
dam.uiName = "Shear Damage";
dam.program = NvBlastDamageProgram { NvBlastExtShearGraphShader, NvBlastExtShearSubgraphShader };
+ dam.pointerType = Damager::PointerType::Sphere;
dam.pointerColor = DirectX::XMFLOAT4(0.5f, 1.0f, 0.5f, 0.4f);
dam.executeFunction = shearDamageExecute;
- m_armory.push_back(dam);
+ m_damagers.push_back(dam);
}
{
Damager dam;
dam.uiName = "Stress Damage";
dam.program = { nullptr, nullptr };
+ dam.pointerType = Damager::PointerType::Sphere;
dam.pointerColor = DirectX::XMFLOAT4(0.5f, 0.5f, 1.0f, 0.4f);
dam.executeFunction = stressDamageExecute;
- m_armory.push_back(dam);
+ m_damagers.push_back(dam);
}
- for (const Damager& d : m_armory)
+ for (const Damager& d : m_damagers)
{
- m_armoryNames.push_back(d.uiName);
+ m_damagerNames.push_back(d.uiName);
}
}
@@ -124,14 +200,19 @@ DamageToolController::~DamageToolController()
void DamageToolController::onSampleStart()
{
- // pick pointer
- m_pickPointerRenderMaterial = new RenderMaterial(getRenderer().getResourceManager(), "physx_primitive_transparent", "", RenderMaterial::BLEND_ALPHA_BLENDING);
- IRenderMesh* mesh = getRenderer().getPrimitiveRenderMesh(PrimitiveRenderMeshType::Sphere);
- m_pickPointerRenderable = getRenderer().createRenderable(*mesh, *m_pickPointerRenderMaterial);
- m_pickPointerRenderable->setScale(PxVec3(m_damageRadius));
+ // damage tool pointer
+ m_toolRenderMaterial = new RenderMaterial(getRenderer().getResourceManager(), "physx_primitive_transparent", "", RenderMaterial::BLEND_ALPHA_BLENDING);
+ {
+ IRenderMesh* mesh = getRenderer().getPrimitiveRenderMesh(PrimitiveRenderMeshType::Sphere);
+ m_sphereToolRenderable = getRenderer().createRenderable(*mesh, *m_toolRenderMaterial);
+ }
+ {
+ IRenderMesh* mesh = getRenderer().getPrimitiveRenderMesh(PrimitiveRenderMeshType::Box);
+ m_lineToolRenderable = getRenderer().createRenderable(*mesh, *m_toolRenderMaterial);
+ }
// default tool
- setDamageProfile(0);
+ m_damagerIndex = 0;
// start with damage mode by default
setDamageMode(true);
@@ -144,59 +225,124 @@ void DamageToolController::onInitialize()
void DamageToolController::onSampleStop()
{
- getRenderer().removeRenderable(m_pickPointerRenderable);
- SAFE_DELETE(m_pickPointerRenderMaterial);
+ getRenderer().removeRenderable(m_sphereToolRenderable);
+ getRenderer().removeRenderable(m_lineToolRenderable);
+ SAFE_DELETE(m_toolRenderMaterial);
}
+
void DamageToolController::Animate(double dt)
{
PROFILER_SCOPED_FUNCTION();
- m_pickPointerColor = XMFLOAT4Lerp(m_pickPointerColor, m_armory[m_damageProfile].pointerColor, dt * 5.0f);
- m_pickPointerRenderable->setColor(m_pickPointerColor);
-}
-
+ m_toolColor = XMFLOAT4Lerp(m_toolColor, m_damagers[m_damagerIndex].pointerColor, dt * 5.0f);
-LRESULT DamageToolController::MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- PROFILER_SCOPED_FUNCTION();
+ m_sphereToolRenderable->setHidden(true);
+ m_lineToolRenderable->setHidden(true);
- if (uMsg == WM_LBUTTONDOWN || uMsg == WM_MOUSEMOVE || uMsg == WM_LBUTTONUP)
+ // damage mode
+ if (m_damageMode)
{
- float mouseX = (short)LOWORD(lParam) / getRenderer().getScreenWidth();
- float mouseY = (short)HIWORD(lParam) / getRenderer().getScreenHeight();
- bool press = uMsg == WM_LBUTTONDOWN;
+ // ray cast according to camera + mouse ray
+ PxVec3 eyePos, pickDir;
+ getPhysXController().getEyePoseAndPickDir(m_lastMousePos.x, m_lastMousePos.y, eyePos, pickDir);
+ pickDir = pickDir.getNormalized();
- // damage mode
- if (m_damageMode && m_pickPointerRenderable)
+ PxRaycastHit hit; hit.shape = NULL;
+ PxRaycastBuffer hit1;
+ getPhysXController().getPhysXScene().raycast(eyePos, pickDir, PX_MAX_F32, hit1, PxHitFlag::ePOSITION | PxHitFlag::eNORMAL);
+ hit = hit1.block;
+
+ if (hit.shape)
{
- PxVec3 eyePos, pickDir;
- getPhysXController().getEyePoseAndPickDir(mouseX, mouseY, eyePos, pickDir);
- pickDir = pickDir.getNormalized();
+ PxMat44 cameraViewInv = XMMATRIXToPxMat44(getRenderer().getCamera().GetViewMatrix()).inverseRT();
+ PxVec3 weaponOrigin = eyePos + cameraViewInv.rotate(WEAPON_POSITION_IN_VIEW);
+
+ // damage function
+ const Damager& damager = m_damagers[m_damagerIndex];
+ auto damageFunction = [&](ExtPxActor* actor)
+ {
+ auto t0 = actor->getPhysXActor().getGlobalPose();
+ PxTransform t(t0.getInverse());
+ PxVec3 localNormal = t.rotate(hit.normal);
+ PxVec3 localPosition = t.transform(hit.position);
+ PxVec3 localOrigin = t.transform(weaponOrigin);
+ damager.executeFunction(&damager, actor, localOrigin, localPosition, localNormal);
+ };
+
+ // should damage?
+ bool shouldDamage = false;
+ if (m_isMousePressed)
+ {
+ shouldDamage = damager.damageWhilePressed || m_damageCountWhilePressed == 0;
+ m_damageCountWhilePressed++;
+ }
+ else
+ {
+ m_damageCountWhilePressed = 0;
+ }
- PxRaycastHit hit; hit.shape = NULL;
- PxRaycastBuffer hit1;
- getPhysXController().getPhysXScene().raycast(eyePos, pickDir, PX_MAX_F32, hit1, PxHitFlag::ePOSITION | PxHitFlag::eNORMAL);
- hit = hit1.block;
+ // Update tool pointer and do damage with specific overlap
+ if (damager.pointerType == Damager::Sphere)
+ {
+ m_sphereToolRenderable->setHidden(false);
+ m_sphereToolRenderable->setColor(m_toolColor);
+ m_sphereToolRenderable->setScale(PxVec3(damager.radius));
+ m_sphereToolRenderable->setTransform(PxTransform(hit.position));
- if (hit.shape)
+ if (shouldDamage)
+ {
+ if (getBlastController().overlap(PxSphereGeometry(damager.radius), PxTransform(hit.position), damageFunction))
+ {
+ m_toolColor = PICK_POINTER_ACTIVE_COLOR;
+ }
+ getPhysXController().explodeDelayed(hit.position, damager.radius, m_explosiveImpulse);
+ }
+ }
+ else if (damager.pointerType == Damager::Line)
{
- PxRigidActor* actor = hit.actor;
- m_pickPointerRenderable->setHidden(false);
- m_pickPointerRenderable->setTransform(PxTransform(hit.position));
+ m_lineToolRenderable->setHidden(false);
+ m_lineToolRenderable->setColor(m_toolColor);
+
+ PxVec3 scale(damager.radius, damager.radius, SEGMENT_DAMAGE_MAX_DISTANCE);
+ PxVec3 direction = (hit.position - weaponOrigin).getNormalized();
+ PxVec3 position = weaponOrigin + direction * SEGMENT_DAMAGE_MAX_DISTANCE;
+
+ m_lineToolRenderable->setScale(scale);
+ PxTransform t(position, quatLookAt(direction));
+ m_lineToolRenderable->setTransform(t);
- if (press)
+ if (shouldDamage)
{
- damage(hit.position, hit.normal);
- m_pickPointerColor = PICK_POINTER_ACTIVE_COLOR;
+ if (this->getBlastController().overlap(PxBoxGeometry(scale), t, damageFunction))
+ {
+ m_toolColor = PICK_POINTER_ACTIVE_COLOR;
+ }
}
}
else
{
- m_pickPointerRenderable->setHidden(true);
+ PX_ASSERT(false);
}
}
}
+}
+
+
+LRESULT DamageToolController::MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ PROFILER_SCOPED_FUNCTION();
+
+ if (uMsg == WM_LBUTTONDOWN || uMsg == WM_MOUSEMOVE || uMsg == WM_LBUTTONUP)
+ {
+ m_lastMousePos.x = (short)LOWORD(lParam) / getRenderer().getScreenWidth();
+ m_lastMousePos.y = (short)HIWORD(lParam) / getRenderer().getScreenHeight();
+ }
+
+ if (uMsg == WM_LBUTTONDOWN || uMsg == WM_LBUTTONUP)
+ {
+ m_isMousePressed = (uMsg == WM_LBUTTONDOWN);
+ }
if (uMsg == WM_MOUSEWHEEL)
{
@@ -217,14 +363,12 @@ LRESULT DamageToolController::MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
}
else if (iKeyPressed >= '1' && iKeyPressed <= '9')
{
- uint32_t num = PxClamp<uint32_t>(iKeyPressed - '1', 0, (uint32_t)m_armory.size() - 1);
- setDamageProfile(num);
+ m_damagerIndex = PxClamp<uint32_t>(iKeyPressed - '1', 0, (uint32_t)m_damagers.size() - 1);
}
else if (iKeyPressed == VK_SPACE)
{
setDamageMode(!isDamageMode());
}
-
}
return 1;
@@ -232,22 +376,20 @@ LRESULT DamageToolController::MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
void DamageToolController::drawUI()
{
- ImGui::DragFloat("Compressive Damage", &m_compressiveDamage, 0.05f);
+ ImGui::DragFloat("Damage Amount", &m_damage, 1.0f);
ImGui::DragFloat("Explosive Impulse", &m_explosiveImpulse);
- ImGui::DragFloat("Damage Radius (Mouse WH)", &m_damageRadius);
ImGui::DragFloat("Stress Damage Force", &m_stressForceFactor);
// - - - - - - - -
ImGui::Spacing();
// Armory
- if (ImGui::Combo("Damage Profile", (int*)&m_damageProfile, m_armoryNames.data(), (int)m_armoryNames.size(), -1))
- {
- setDamageProfile(m_damageProfile);
- }
+ ImGui::Combo("Damage Profile", (int*)&m_damagerIndex, m_damagerNames.data(), (int)m_damagerNames.size(), -1);
+ Damager& damager = m_damagers[m_damagerIndex];
+ ImGui::DragFloat("Damage Radius (Mouse WH)", &damager.radius);
+ ImGui::Checkbox("Damage Continuously", &damager.damageWhilePressed);
}
-
void DamageToolController::setDamageMode(bool enabled)
{
m_damageMode = enabled;
@@ -256,37 +398,14 @@ void DamageToolController::setDamageMode(bool enabled)
if (!m_damageMode)
{
- m_pickPointerRenderable->setHidden(true);
+ m_sphereToolRenderable->setHidden(true);
+ m_lineToolRenderable->setHidden(true);
}
}
-
-void DamageToolController::setDamageProfile(uint32_t profile)
-{
- m_damageProfile = profile;
-}
-
-
void DamageToolController::changeDamageRadius(float dr)
{
- m_damageRadius += dr;
- m_damageRadius = PxMax(1.0f, m_damageRadius);
- m_pickPointerRenderable->setScale(PxVec3(m_damageRadius));
-}
-
-
-void DamageToolController::damage(physx::PxVec3 position, physx::PxVec3 normal)
-{
- auto damageFunction = [&](ExtPxActor* actor)
- {
- auto t0 = actor->getPhysXActor().getGlobalPose();
- PxTransform t(t0.getInverse());
- PxVec3 localNormal = t.rotate(normal);
- PxVec3 localPosition = t.transform(position);
- Damager& damager = m_armory[m_damageProfile];
- damager.execute(actor, localPosition, localNormal);
- };
-
- this->getBlastController().blast(position, m_damageRadius, m_explosiveImpulse, damageFunction);
-
+ Damager& damager = m_damagers[m_damagerIndex];
+ damager.radius += dr;
+ damager.radius = PxClamp<float>(damager.radius, 0.05f, damager.radiusLimit);
}
diff --git a/samples/SampleBase/ui/DamageToolController.h b/samples/SampleBase/ui/DamageToolController.h
index 9dcea39..ae14064 100644
--- a/samples/SampleBase/ui/DamageToolController.h
+++ b/samples/SampleBase/ui/DamageToolController.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef DAMAGE_TOOL_CONTROLLER_H
#define DAMAGE_TOOL_CONTROLLER_H
@@ -15,6 +33,7 @@
#include "NvBlastTypes.h"
#include <DirectXMath.h>
#include <functional>
+#include "PxVec2.h"
#include "PxVec3.h"
@@ -57,14 +76,6 @@ private:
//////// private methods ////////
- void damage(physx::PxVec3 position, physx::PxVec3 normal);
-
- void setDamageProfile(uint32_t profile);
- uint32_t getDamageProfile() const
- {
- return m_damageProfile;
- }
-
void changeDamageRadius(float dr);
void setDamageMode(bool enabled);
@@ -90,33 +101,48 @@ private:
//////// internal data ////////
- Renderable* m_pickPointerRenderable;
- RenderMaterial* m_pickPointerRenderMaterial;
- DirectX::XMFLOAT4 m_pickPointerColor;
+ RenderMaterial* m_toolRenderMaterial;
+ Renderable* m_sphereToolRenderable;
+ DirectX::XMFLOAT4 m_toolColor;
+ Renderable* m_lineToolRenderable;
- float m_damageRadius;
- float m_compressiveDamage;
- float m_explosiveImpulse;
- float m_stressForceFactor;
- uint32_t m_damageProfile;
+ float m_damage;
+ float m_explosiveImpulse;
+ float m_stressForceFactor;
struct Damager
{
- const char* uiName;
- NvBlastDamageProgram program;
- DirectX::XMFLOAT4 pointerColor;
- std::function<void(const Damager* damager, Nv::Blast::ExtPxActor* actor, physx::PxVec3 position, physx::PxVec3 normal)> executeFunction;
-
- void execute(Nv::Blast::ExtPxActor* actor, physx::PxVec3 position, physx::PxVec3 normal)
+ Damager() : damageWhilePressed(false), radius(5.0f), radiusLimit(1000.0f)
{
- executeFunction(this, actor, position, normal);
}
+
+ enum PointerType
+ {
+ Sphere,
+ Line
+ };
+
+ typedef std::function<void(const Damager* damager, Nv::Blast::ExtPxActor* actor, physx::PxVec3 origin, physx::PxVec3 position, physx::PxVec3 normal)> ExecuteFn;
+
+ const char* uiName;
+ NvBlastDamageProgram program;
+ PointerType pointerType;
+ DirectX::XMFLOAT4 pointerColor;
+ float radius;
+ float radiusLimit;
+ bool damageWhilePressed;
+ ExecuteFn executeFunction;
};
- std::vector<Damager> m_armory;
- std::vector<const char*> m_armoryNames;
+ std::vector<Damager> m_damagers;
+ std::vector<const char*> m_damagerNames;
+ uint32_t m_damagerIndex;
+
+ bool m_damageMode;
- bool m_damageMode;
+ physx::PxVec2 m_lastMousePos;
+ bool m_isMousePressed;
+ uint32_t m_damageCountWhilePressed;
};
#endif \ No newline at end of file
diff --git a/samples/SampleBase/utils/PxInputDataFromPxFileBuf.h b/samples/SampleBase/utils/PxInputDataFromPxFileBuf.h
index dfa8260..e309abd 100644
--- a/samples/SampleBase/utils/PxInputDataFromPxFileBuf.h
+++ b/samples/SampleBase/utils/PxInputDataFromPxFileBuf.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef PXINPUTDATAFROMPXFILEBUF_H
#define PXINPUTDATAFROMPXFILEBUF_H
diff --git a/samples/SampleBase/utils/SampleProfiler.cpp b/samples/SampleBase/utils/SampleProfiler.cpp
index 4df23fd..cb63eeb 100644
--- a/samples/SampleBase/utils/SampleProfiler.cpp
+++ b/samples/SampleBase/utils/SampleProfiler.cpp
@@ -1,12 +1,29 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
#include "SampleProfiler.h"
diff --git a/samples/SampleBase/utils/SampleProfiler.h b/samples/SampleBase/utils/SampleProfiler.h
index 1ea3663..5f8a326 100644
--- a/samples/SampleBase/utils/SampleProfiler.h
+++ b/samples/SampleBase/utils/SampleProfiler.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef SAMPLEPROFILER_H
#define SAMPLEPROFILER_H
diff --git a/samples/SampleBase/utils/SampleTime.h b/samples/SampleBase/utils/SampleTime.h
index c62ced2..8226cd4 100644
--- a/samples/SampleBase/utils/SampleTime.h
+++ b/samples/SampleBase/utils/SampleTime.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef SAMPLE_TIME_H
#define SAMPLE_TIME_H
diff --git a/samples/SampleBase/utils/UIHelpers.h b/samples/SampleBase/utils/UIHelpers.h
index b23eb84..cdd50ff 100644
--- a/samples/SampleBase/utils/UIHelpers.h
+++ b/samples/SampleBase/utils/UIHelpers.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2008-2015, 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.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef UI_HELPERS_H
#define UI_HELPERS_H
diff --git a/samples/SampleBase/utils/Utils.cpp b/samples/SampleBase/utils/Utils.cpp
index a271137..9eafabc 100644
--- a/samples/SampleBase/utils/Utils.cpp
+++ b/samples/SampleBase/utils/Utils.cpp
@@ -1,3 +1,31 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
+
#include "Utils.h"
#include <string>
diff --git a/samples/SampleBase/utils/Utils.h b/samples/SampleBase/utils/Utils.h
index 5d4addc..42bf713 100644
--- a/samples/SampleBase/utils/Utils.h
+++ b/samples/SampleBase/utils/Utils.h
@@ -1,3 +1,31 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and 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.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
+
+
#ifndef UTILS_H
#define UTILS_H