Main Page Class List Class Members

NvBlastExtDamageAcceleratorAABBTree.h
Go to the documentation of this file.
1 // This code contains NVIDIA Confidential Information and is disclosed to you
2 // under a form of NVIDIA software license agreement provided separately to you.
3 //
4 // Notice
5 // NVIDIA Corporation and its licensors retain all intellectual property and
6 // proprietary rights in and to this software and related documentation and
7 // any modifications thereto. Any use, reproduction, disclosure, or
8 // distribution of this software and related documentation without an express
9 // license agreement from NVIDIA Corporation is strictly prohibited.
10 //
11 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
12 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
13 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
14 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
15 //
16 // Information and code furnished is believed to be accurate and reliable.
17 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
18 // information or for any infringement of patents or other rights of third parties that may
19 // result from its use. No license is granted by implication or otherwise under any patent
20 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
21 // This code supersedes and replaces all information previously supplied.
22 // NVIDIA Corporation products are not authorized for use as critical
23 // components in life support devices or systems without express written approval of
24 // NVIDIA Corporation.
25 //
26 // Copyright (c) 2016-2020 NVIDIA Corporation. All rights reserved.
27
28 #pragma once
29
30 #include "NvBlastExtDamageAcceleratorInternal.h"
31 #include "NvBlast.h"
32 #include "NvBlastArray.h"
33
34
35 namespace Nv
36 {
37 namespace Blast
38 {
39
40 class ExtDamageAcceleratorAABBTree final : public ExtDamageAcceleratorInternal
41 {
42 public:
44
45 ExtDamageAcceleratorAABBTree() :
46 m_root(nullptr)
47 {
48 }
49
50 virtual ~ExtDamageAcceleratorAABBTree()
51 {
52 }
53
54 static ExtDamageAcceleratorAABBTree* create(const NvBlastAsset* asset);
55
56
58
59 virtual void release() override;
60
61 virtual void findBondCentroidsInBounds(const physx::PxBounds3& bounds, ResultCallback& resultCallback) const override
62 {
63 const_cast<ExtDamageAcceleratorAABBTree*>(this)->findInBounds(bounds, resultCallback, false);
64 }
65
66 virtual void findBondSegmentsInBounds(const physx::PxBounds3& bounds, ResultCallback& resultCallback) const override
67 {
68 const_cast<ExtDamageAcceleratorAABBTree*>(this)->findInBounds(bounds, resultCallback, true);
69
70 }
71
72 virtual void findBondSegmentsPlaneIntersected(const physx::PxPlane& plane, ResultCallback& resultCallback) const override;
73
74 virtual Nv::Blast::DebugBuffer fillDebugRender(int depth, bool segments) override;
75
76 virtual void* getImmediateScratch(size_t size) override
77 {
78 m_scratch.resizeUninitialized(size);
79 return m_scratch.begin();
80 }
81
82
83 private:
84 // no copy/assignment
85 ExtDamageAcceleratorAABBTree(ExtDamageAcceleratorAABBTree&);
86 ExtDamageAcceleratorAABBTree& operator=(const ExtDamageAcceleratorAABBTree& tree);
87
88 // Tree node
89 struct Node
90 {
91 int child[2];
92 uint32_t first;
93 uint32_t last;
94 physx::PxBounds3 pointsBound;
95 physx::PxBounds3 segmentsBound;
96 };
97
98
99 void build(const NvBlastAsset* asset);
100
101 int createNode(uint32_t startIdx, uint32_t endIdx, uint32_t depth);
102
103 void pushResult(ResultCallback& callback, uint32_t pointIndex) const
104 {
105 callback.push(pointIndex, m_bonds[pointIndex].node0, m_bonds[pointIndex].node1);
106 }
107
108 void findInBounds(const physx::PxBounds3& bounds, ResultCallback& callback, bool segments) const;
109
110 void findPointsInBounds(const Node& node, ResultCallback& callback, const physx::PxBounds3& bounds) const;
111
112 void findSegmentsInBounds(const Node& node, ResultCallback& callback, const physx::PxBounds3& bounds) const;
113
114 void findSegmentsPlaneIntersected(const Node& node, ResultCallback& callback, const physx::PxPlane& plane) const;
115
116 void fillDebugBuffer(const Node& node, int currentDepth, int depth, bool segments);
117
118
120
121 Node* m_root;
122 Array<Node>::type m_nodes;
123 Array<uint32_t>::type m_indices;
124
125 Array<physx::PxVec3>::type m_points;
126
127 struct Segment
128 {
129 physx::PxVec3 p0;
130 physx::PxVec3 p1;
131 };
132 Array<Segment>::type m_segments;
133
134 struct BondData
135 {
136 uint32_t node0;
137 uint32_t node1;
138 };
139 Array<BondData>::type m_bonds;
140
141 Array<Nv::Blast::DebugLine>::type m_debugLineBuffer;
142
143 Array<char>::type m_scratch;
144 };
145
146
147 } // namespace Blast
148 } // namespace Nv
Nv::Blast::ExtDamageAcceleratorAABBTree::release
virtual void release() override
NvBlastArray.h
Nv::Blast::Array
Definition: NvBlastArray.h:46
NvBlast.h
Nv::Blast::ExtDamageAcceleratorInternal::ResultCallback::push
void push(uint32_t bond, uint32_t node0, uint32_t node1)
Definition: NvBlastExtDamageAcceleratorInternal.h:58
Nv::Blast::DebugBuffer
Definition: NvBlastDebugRender.h:56
Nv::Blast::ExtDamageAcceleratorAABBTree::findBondSegmentsInBounds
virtual void findBondSegmentsInBounds(const physx::PxBounds3 &bounds, ResultCallback &resultCallback) const override
Definition: NvBlastExtDamageAcceleratorAABBTree.h:66
Nv::Blast::ExtDamageAcceleratorAABBTree::fillDebugRender
virtual Nv::Blast::DebugBuffer fillDebugRender(int depth, bool segments) override
Nv::Blast::ExtDamageAcceleratorAABBTree::ExtDamageAcceleratorAABBTree
ExtDamageAcceleratorAABBTree()
Definition: NvBlastExtDamageAcceleratorAABBTree.h:45
Nv::Blast::ExtDamageAcceleratorInternal
Definition: NvBlastExtDamageAcceleratorInternal.h:40
Nv::Blast::ExtDamageAcceleratorAABBTree::findBondSegmentsPlaneIntersected
virtual void findBondSegmentsPlaneIntersected(const physx::PxPlane &plane, ResultCallback &resultCallback) const override
Nv::Blast::ExtDamageAcceleratorAABBTree::create
static ExtDamageAcceleratorAABBTree * create(const NvBlastAsset *asset)
Nv::Blast::ExtDamageAcceleratorAABBTree
Definition: NvBlastExtDamageAcceleratorAABBTree.h:40
Nv::Blast::ExtDamageAcceleratorInternal::ResultCallback
Definition: NvBlastExtDamageAcceleratorInternal.h:50
Nv::Blast::ExtDamageAcceleratorAABBTree::~ExtDamageAcceleratorAABBTree
virtual ~ExtDamageAcceleratorAABBTree()
Definition: NvBlastExtDamageAcceleratorAABBTree.h:50
NvBlastAsset
Definition: NvBlastTypes.h:286
Nv
Definition: NvBlastArray.h:37
NvBlastExtDamageAcceleratorInternal.h
Nv::Blast::ExtDamageAcceleratorAABBTree::getImmediateScratch
virtual void * getImmediateScratch(size_t size) override
Definition: NvBlastExtDamageAcceleratorAABBTree.h:76
Nv::Blast::ExtDamageAcceleratorAABBTree::findBondCentroidsInBounds
virtual void findBondCentroidsInBounds(const physx::PxBounds3 &bounds, ResultCallback &resultCallback) const override
Definition: NvBlastExtDamageAcceleratorAABBTree.h:61