Main Page Class List Class Members

NvBlastExtPxFamilyImpl.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
29 #ifndef NVBLASTEXTPXFAMILYIMPL_H
30 #define NVBLASTEXTPXFAMILYIMPL_H
31
32 #include "NvBlastExtPxFamily.h"
33 #include "NvBlastArray.h"
34 #include "NvBlastHashSet.h"
35 #include "PxTransform.h"
36 #include "NvBlastTkEvent.h"
37
38
39 using namespace physx;
40
41
42 namespace Nv
43 {
44 namespace Blast
45 {
46
47 // Forward declarations
48 class ExtPxManagerImpl;
49 class ExtPxActorImpl;
50 struct PxActorCreateInfo;
51
52
53 class ExtPxFamilyImpl final : public ExtPxFamily, TkEventListener
54 {
55 NV_NOCOPY(ExtPxFamilyImpl)
56
57 public:
58 friend ExtPxActorImpl;
59 friend ExtPxManagerImpl;
60
62
63 ExtPxFamilyImpl(ExtPxManagerImpl& manager, TkFamily& tkFamily, ExtPxAsset& pxAsset);
64 ~ExtPxFamilyImpl();
65
66 virtual void release() override;
67
68
70
71 // virtual bool spawn(const PxTransform& pose, const ExtPxSpawnSettings& settings) override;
72 virtual bool spawn(const physx::PxTransform& pose, const physx::PxVec3& scale, const ExtPxSpawnSettings& settings) override;
73 virtual bool despawn() override;
74
75
76 virtual uint32_t getActorCount() const override
77 {
78 return m_actors.size();
79 }
80
81 virtual uint32_t getActors(ExtPxActor** buffer, uint32_t bufferSize) const override
82 {
83 uint32_t index = 0;
84 for (auto it = const_cast<ExtPxFamilyImpl*>(this)->m_actors.getIterator(); !it.done() && index < bufferSize; ++it)
85 {
86 buffer[index++] = *it;
87 }
88 return index;
89 }
90
91 virtual TkFamily& getTkFamily() const override
92 {
93 return m_tkFamily;
94 }
95
96 virtual const physx::PxShape* const* getSubchunkShapes() const override
97 {
98 return m_subchunkShapes.begin();
99 }
100
101 virtual ExtPxAsset& getPxAsset() const override
102 {
103 return m_pxAsset;
104 }
105
106 virtual void setMaterial(PxMaterial& material) override
107 {
108 m_spawnSettings.material = &material;
109 }
110
111 virtual void setPxShapeDescTemplate(const ExtPxShapeDescTemplate* pxShapeDesc) override
112 {
113 m_pxShapeDescTemplate = pxShapeDesc;
114 }
115
116 virtual const ExtPxShapeDescTemplate* getPxShapeDescTemplate() const override
117 {
118 return m_pxShapeDescTemplate;
119 }
120
121 virtual void setPxActorDesc(const ExtPxActorDescTemplate* pxActorDesc) override
122 {
123 m_pxActorDescTemplate = pxActorDesc;
124 }
125
126 virtual const ExtPxActorDescTemplate* getPxActorDesc() const override
127 {
128 return m_pxActorDescTemplate;
129 }
130
131 virtual const NvBlastExtMaterial* getMaterial() const override
132 {
133 return m_material;
134 }
135
136 virtual void setMaterial(const NvBlastExtMaterial* material) override
137 {
138 m_material = material;
139 }
140
141 virtual void subscribe(ExtPxListener& listener) override
142 {
143 m_listeners.pushBack(&listener);
144 }
145
146 virtual void unsubscribe(ExtPxListener& listener) override
147 {
148 m_listeners.findAndReplaceWithLast(&listener);
149 }
150
151 virtual void postSplitUpdate() override;
152
154
155 virtual void receive(const TkEvent* events, uint32_t eventCount) override;
156
157
159
160 void dispatchActorCreated(ExtPxActor& actor);
161 void dispatchActorDestroyed(ExtPxActor& actor);
162
163
164 private:
166
167 void createActors(TkActor** tkActors, const PxActorCreateInfo* pxActorInfos, uint32_t count);
168 void destroyActors(ExtPxActor** actors, uint32_t count);
169
171
172 ExtPxManagerImpl& m_manager;
173 TkFamily& m_tkFamily;
174 ExtPxAsset& m_pxAsset;
175 ExtPxSpawnSettings m_spawnSettings;
176 const ExtPxShapeDescTemplate* m_pxShapeDescTemplate;
177 const ExtPxActorDescTemplate* m_pxActorDescTemplate;
178 const NvBlastExtMaterial* m_material;
179 bool m_isSpawned;
180 PxTransform m_initialTransform;
181 PxVec3 m_initialScale;
182 HashSet<ExtPxActor*>::type m_actors;
183 Array<TkActor*>::type m_culledActors;
184 InlineArray<ExtPxListener*, 4>::type m_listeners;
185 Array<PxShape*>::type m_subchunkShapes;
186 Array<TkActor*>::type m_newActorsBuffer;
187 Array<PxActorCreateInfo>::type m_newActorCreateInfo;
188 Array<PxActor*>::type m_physXActorsBuffer;
189 Array<ExtPxActor*>::type m_actorsBuffer;
190 Array<uint32_t>::type m_indicesScratch;
191 };
192
193 } // namespace Blast
194 } // namespace Nv
195
196
197 #endif // ifndef NVBLASTEXTPXFAMILYIMPL_H
physx
Definition: NvBlastExtApexSharedParts.h:34
Nv::Blast::TkFamily
Definition: NvBlastTkFamily.h:55
Nv::Blast::ExtPxFamilyImpl::setMaterial
virtual void setMaterial(const NvBlastExtMaterial *material) override
Definition: NvBlastExtPxFamilyImpl.h:136
NvBlastArray.h
Nv::Blast::Array
Definition: NvBlastArray.h:46
Nv::Blast::ExtPxFamilyImpl::unsubscribe
virtual void unsubscribe(ExtPxListener &listener) override
Definition: NvBlastExtPxFamilyImpl.h:146
Nv::Blast::ExtPxFamilyImpl::ExtPxActorImpl
friend ExtPxActorImpl
Definition: NvBlastExtPxFamilyImpl.h:58
Nv::Blast::InlineArray::type
physx::shdfnd::InlineArray< T, N, Allocator > type
Definition: NvBlastArray.h:60
Nv::Blast::ExtPxFamilyImpl::setPxShapeDescTemplate
virtual void setPxShapeDescTemplate(const ExtPxShapeDescTemplate *pxShapeDesc) override
Definition: NvBlastExtPxFamilyImpl.h:111
Nv::Blast::ExtPxFamilyImpl::getPxAsset
virtual ExtPxAsset & getPxAsset() const override
Definition: NvBlastExtPxFamilyImpl.h:101
Nv::Blast::TkEvent
Definition: NvBlastTkEvent.h:65
Nv::Blast::HashSet::type
physx::shdfnd::HashSet< Key, HashFn, Allocator > type
Definition: NvBlastHashSet.h:47
Nv::Blast::ExtPxManagerImpl
Definition: NvBlastExtPxManagerImpl.h:52
Nv::Blast::Array::type
physx::shdfnd::Array< T, Allocator > type
Definition: NvBlastArray.h:48
Nv::Blast::ExtPxShapeDescTemplate
Definition: NvBlastExtPxFamily.h:66
Nv::Blast::ExtPxFamilyImpl::setMaterial
virtual void setMaterial(PxMaterial &material) override
Definition: NvBlastExtPxFamilyImpl.h:106
Nv::Blast::TkActor
Definition: NvBlastTkActor.h:57
Nv::Blast::ExtPxFamilyImpl::getPxActorDesc
virtual const ExtPxActorDescTemplate * getPxActorDesc() const override
Definition: NvBlastExtPxFamilyImpl.h:126
Nv::Blast::ExtPxFamilyImpl::getMaterial
virtual const NvBlastExtMaterial * getMaterial() const override
Definition: NvBlastExtPxFamilyImpl.h:131
Nv::Blast::ExtPxActorDescTemplate
Definition: NvBlastExtPxFamily.h:81
Nv::Blast::ExtPxAsset
Definition: NvBlastExtPxAsset.h:123
Nv::Blast::ExtPxFamilyImpl::getPxShapeDescTemplate
virtual const ExtPxShapeDescTemplate * getPxShapeDescTemplate() const override
Definition: NvBlastExtPxFamilyImpl.h:116
NvBlastExtPxFamily.h
Nv::Blast::ExtPxSpawnSettings
Definition: NvBlastExtPxFamily.h:92
Nv::Blast::ExtPxFamilyImpl::setPxActorDesc
virtual void setPxActorDesc(const ExtPxActorDescTemplate *pxActorDesc) override
Definition: NvBlastExtPxFamilyImpl.h:121
Nv::Blast::TkEventListener
Definition: NvBlastTkEvent.h:168
Nv::Blast::ExtPxListener
Definition: NvBlastExtPxListener.h:48
Nv::Blast::ExtPxActor
Definition: NvBlastExtPxActor.h:57
Nv::Blast::ExtPxFamilyImpl::subscribe
virtual void subscribe(ExtPxListener &listener) override
Definition: NvBlastExtPxFamilyImpl.h:141
NvBlastHashSet.h
Nv::Blast::ExtPxFamily
Definition: NvBlastExtPxFamily.h:105
Nv::Blast::PxActorCreateInfo
Definition: NvBlastExtPxActorImpl.h:48
Nv::Blast::ExtPxFamilyImpl::ExtPxManagerImpl
friend ExtPxManagerImpl
Definition: NvBlastExtPxFamilyImpl.h:59
Nv::Blast::ExtPxFamilyImpl::getActors
virtual uint32_t getActors(ExtPxActor **buffer, uint32_t bufferSize) const override
Definition: NvBlastExtPxFamilyImpl.h:81
Nv::Blast::ExtPxFamilyImpl
Definition: NvBlastExtPxFamilyImpl.h:53
Nv::Blast::ExtPxFamilyImpl::getSubchunkShapes
virtual const physx::PxShape *const * getSubchunkShapes() const override
Definition: NvBlastExtPxFamilyImpl.h:96
Nv::Blast::ExtPxFamilyImpl::getActorCount
virtual uint32_t getActorCount() const override
Definition: NvBlastExtPxFamilyImpl.h:76
NV_NOCOPY
#define NV_NOCOPY(Class)
Definition: NvPreprocessor.h:527
Nv::Blast::ExtPxFamilyImpl::getTkFamily
virtual TkFamily & getTkFamily() const override
Definition: NvBlastExtPxFamilyImpl.h:91
Nv
Definition: NvBlastArray.h:37
NvBlastTkEvent.h
NvBlastExtMaterial
Definition: NvBlastExtDamageShaders.h:94