Main Page   Class List   Class Members  

  • Main Page
  • User's Guide
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

sdk/extensions/shaders/source/NvBlastExtDamageAcceleratorAABBTree.h

Go to the documentation of this file.
00001 // This code contains NVIDIA Confidential Information and is disclosed to you
00002 // under a form of NVIDIA software license agreement provided separately to you.
00003 //
00004 // Notice
00005 // NVIDIA Corporation and its licensors retain all intellectual property and
00006 // proprietary rights in and to this software and related documentation and
00007 // any modifications thereto. Any use, reproduction, disclosure, or
00008 // distribution of this software and related documentation without an express
00009 // license agreement from NVIDIA Corporation is strictly prohibited.
00010 //
00011 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
00012 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
00013 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
00014 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
00015 //
00016 // Information and code furnished is believed to be accurate and reliable.
00017 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
00018 // information or for any infringement of patents or other rights of third parties that may
00019 // result from its use. No license is granted by implication or otherwise under any patent
00020 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
00021 // This code supersedes and replaces all information previously supplied.
00022 // NVIDIA Corporation products are not authorized for use as critical
00023 // components in life support devices or systems without express written approval of
00024 // NVIDIA Corporation.
00025 //
00026 // Copyright (c) 2016-2020 NVIDIA Corporation. All rights reserved.
00027 
00028 #pragma once
00029 
00030 #include "NvBlastExtDamageAcceleratorInternal.h"
00031 #include "NvBlast.h"
00032 #include "NvBlastArray.h"
00033 
00034 
00035 namespace Nv
00036 {
00037 namespace Blast
00038 {
00039 
00040 class ExtDamageAcceleratorAABBTree final : public ExtDamageAcceleratorInternal
00041 {
00042 public:
00044 
00045     ExtDamageAcceleratorAABBTree() :
00046          m_root(nullptr)
00047     {
00048     }
00049 
00050     virtual ~ExtDamageAcceleratorAABBTree()
00051     {
00052     }
00053 
00054     static ExtDamageAcceleratorAABBTree* create(const NvBlastAsset* asset);
00055 
00056 
00058 
00059     virtual void release() override;
00060 
00061     virtual void findBondCentroidsInBounds(const physx::PxBounds3& bounds, ResultCallback& resultCallback) const override
00062     {
00063         const_cast<ExtDamageAcceleratorAABBTree*>(this)->findInBounds(bounds, resultCallback, false);
00064     }
00065 
00066     virtual void findBondSegmentsInBounds(const physx::PxBounds3& bounds, ResultCallback& resultCallback) const override
00067     {
00068         const_cast<ExtDamageAcceleratorAABBTree*>(this)->findInBounds(bounds, resultCallback, true);
00069 
00070     }
00071 
00072     virtual void findBondSegmentsPlaneIntersected(const physx::PxPlane& plane, ResultCallback& resultCallback) const override;
00073 
00074     virtual Nv::Blast::DebugBuffer fillDebugRender(int depth, bool segments) override;
00075 
00076     virtual void* getImmediateScratch(size_t size) override
00077     {
00078         m_scratch.resizeUninitialized(size);
00079         return m_scratch.begin();
00080     }
00081 
00082 
00083 private:
00084     // no copy/assignment
00085     ExtDamageAcceleratorAABBTree(ExtDamageAcceleratorAABBTree&);
00086     ExtDamageAcceleratorAABBTree& operator=(const ExtDamageAcceleratorAABBTree& tree);
00087 
00088     // Tree node 
00089     struct Node
00090     {
00091         int child[2];
00092         uint32_t first;
00093         uint32_t last;
00094         physx::PxBounds3 pointsBound;
00095         physx::PxBounds3 segmentsBound;
00096     };
00097 
00098 
00099     void build(const NvBlastAsset* asset);
00100 
00101     int createNode(uint32_t startIdx, uint32_t endIdx, uint32_t depth);
00102 
00103     void pushResult(ResultCallback& callback, uint32_t pointIndex) const
00104     {
00105         callback.push(pointIndex, m_bonds[pointIndex].node0, m_bonds[pointIndex].node1);
00106     }
00107 
00108     void findInBounds(const physx::PxBounds3& bounds, ResultCallback& callback, bool segments) const;
00109 
00110     void findPointsInBounds(const Node& node, ResultCallback& callback, const physx::PxBounds3& bounds) const;
00111 
00112     void findSegmentsInBounds(const Node& node, ResultCallback& callback, const physx::PxBounds3& bounds) const;
00113 
00114     void findSegmentsPlaneIntersected(const Node& node, ResultCallback& callback, const physx::PxPlane& plane) const;
00115 
00116     void fillDebugBuffer(const Node& node, int currentDepth, int depth, bool segments);
00117 
00118 
00120 
00121     Node*                                 m_root;
00122     Array<Node>::type                     m_nodes;
00123     Array<uint32_t>::type                 m_indices;
00124 
00125     Array<physx::PxVec3>::type            m_points;
00126 
00127     struct Segment
00128     {
00129         physx::PxVec3   p0;
00130         physx::PxVec3   p1;
00131     };
00132     Array<Segment>::type                  m_segments;
00133 
00134     struct BondData
00135     {
00136         uint32_t        node0;
00137         uint32_t        node1;
00138     };
00139     Array<BondData>::type                 m_bonds;
00140 
00141     Array<Nv::Blast::DebugLine>::type     m_debugLineBuffer;
00142 
00143     Array<char>::type                     m_scratch;
00144 };
00145 
00146 
00147 } // namespace Blast
00148 } // namespace Nv
Copyright © 2015-2017 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com