Main Page Class List Class Members

NvBlastTkActorImpl.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 NVBLASTTKACTORIMPL_H
30 #define NVBLASTTKACTORIMPL_H
31
32
33 #include "NvBlastTkCommon.h"
34
35 #include "NvBlastAssert.h"
36 #include "NvBlastDLink.h"
37 #include "NvBlastIteratorBase.h"
38
39 #include "NvBlastTkJointImpl.h"
40
41 #include "NvBlast.h"
42
43 #include "NvBlastTkActor.h"
44
45 #include "PxFlags.h"
46
47 namespace Nv
48 {
49 namespace Blast
50 {
51
52 // Forward declarations:
53 class TkGroupImpl;
54 class TkFamilyImpl;
55 class TkAssetImpl;
56 class TkJointImpl;
57
58
62 struct TkActorFlag
63 {
64 enum Enum
65 {
66 DAMAGED = (1 << 0),
67 PENDING = (1 << 1),
68 };
69 };
70
71
75 class TkActorImpl : public TkActor
76 {
77 public:
78 TkActorImpl();
79 ~TkActorImpl();
80
81 // Begin TkActor
82 virtual const NvBlastActor* getActorLL() const override;
83
84 virtual TkFamily& getFamily() const override;
85
86 virtual uint32_t getIndex() const override;
87
88 virtual TkGroup* getGroup() const override;
89
90 virtual TkGroup* removeFromGroup() override;
91
92 virtual const TkAsset* getAsset() const override;
93
94 virtual uint32_t getVisibleChunkCount() const override;
95
96 virtual uint32_t getVisibleChunkIndices(uint32_t* visibleChunkIndices, uint32_t visibleChunkIndicesSize) const override;
97
98 virtual uint32_t getGraphNodeCount() const override;
99
100 virtual uint32_t getGraphNodeIndices(uint32_t* graphNodeIndices, uint32_t graphNodeIndicesSize) const override;
101
102 virtual const float* getBondHealths() const override;
103
104 virtual uint32_t getSplitMaxActorCount() const override;
105
106 virtual void damage(const NvBlastDamageProgram& program, const void* programParams) override;
107
108 virtual bool isPending() const override;
109
110 virtual void generateFracture(NvBlastFractureBuffers* commands, const NvBlastDamageProgram& program, const void* programParams) const override;
111
112 virtual void applyFracture(NvBlastFractureBuffers* eventBuffers, const NvBlastFractureBuffers* commands) override;
113
114 virtual uint32_t getJointCount() const override;
115
116 virtual uint32_t getJoints(TkJoint** joints, uint32_t jointsSize) const override;
117
118 virtual bool isBoundToWorld() const override;
119 // End TkActor
120
121 // Begin TkObject
122 virtual void release() override;
123 // End TkObject
124
125
126 // Public methods
127
135 static TkActorImpl* create(const TkActorDesc& desc);
136
144 bool isActive() const;
145
151 NvBlastFamily* getFamilyLL() const;
152
158 TkFamilyImpl& getFamilyImpl() const;
159
163 uint32_t getIndexInternal() const;
164
170 TkGroupImpl* getGroupImpl() const;
171
177 NvBlastActor* getActorLLInternal() const;
178
182 uint32_t getJointCountInternal() const;
183
195 class JointIt : public DList::It
196 {
197 public:
199 JointIt(const TkActorImpl& actor, Direction dir = Forward);
200
202 TkJointImpl* operator * () const;
203 };
204
208 operator Nv::Blast::TkActorData() const;
209
210 private:
215 void markAsDamaged();
216 bool isDamaged() const;
217
222 void makePending();
223
227 void addJoint(TkJointLink& jointLink);
228 void removeJoint(TkJointLink& jointLink);
229
230 struct DamageData
231 {
232 NvBlastDamageProgram program;
233 const void* programParams;
234 };
235
236 // Data
237
238 NvBlastActor* m_actorLL;
239 TkFamilyImpl* m_family;
240 TkGroupImpl* m_group;
241 uint32_t m_groupJobIndex;
242 physx::PxFlags<TkActorFlag::Enum, char> m_flags;
243 Array<DamageData>::type m_damageBuffer;
244 uint32_t m_jointCount;
245 DList m_jointList;
246
247 //#if NV_PROFILE
248 NvBlastTimers m_timers;
249 //#endif
250
251 friend class TkWorker; // m_damageBuffer and m_flags
252 friend class TkGroupImpl;
253 friend class TkFamilyImpl;
254 friend class TkJointImpl;
255 friend class TkFrameworkImpl;
256 };
257
258
260
261 NV_INLINE TkFamilyImpl& TkActorImpl::getFamilyImpl() const
262 {
263 NVBLAST_ASSERT(m_family != nullptr);
264
265 return *m_family;
266 }
267
268
269 NV_INLINE uint32_t TkActorImpl::getIndexInternal() const
270 {
271 NVBLAST_ASSERT(isActive());
272 return NvBlastActorGetIndex(m_actorLL, logLL);
273 }
274
275
276 NV_INLINE NvBlastActor* TkActorImpl::getActorLLInternal() const
277 {
278 return m_actorLL;
279 }
280
281
282 NV_INLINE uint32_t TkActorImpl::getJointCountInternal() const
283 {
284 return m_jointCount;
285 }
286
287
288 NV_INLINE TkGroupImpl* TkActorImpl::getGroupImpl() const
289 {
290 return m_group;
291 }
292
293
294 NV_INLINE bool TkActorImpl::isActive() const
295 {
296 return m_actorLL != nullptr;
297 }
298
299
300 NV_INLINE bool TkActorImpl::isPending() const
301 {
302 return m_flags.isSet(TkActorFlag::PENDING);
303 }
304
305
306 NV_INLINE void TkActorImpl::addJoint(TkJointLink& jointLink)
307 {
308 NVBLAST_ASSERT(m_jointList.isSolitary(jointLink));
309
310 m_jointList.insertHead(jointLink);
311 ++m_jointCount;
312 }
313
314
315 NV_INLINE void TkActorImpl::removeJoint(TkJointLink& jointLink)
316 {
317 NVBLAST_ASSERT(!m_jointList.isSolitary(jointLink));
318 NVBLAST_ASSERT(m_jointCount > 0);
319 if (m_jointCount > 0)
320 {
321 --m_jointCount;
322 m_jointList.remove(jointLink);
323 }
324 }
325
326
328
329 NV_INLINE TkActorImpl::JointIt::JointIt(const TkActorImpl& actor, Direction dir) : DList::It(actor.m_jointList, dir) {}
330
331
332 NV_INLINE TkJointImpl* TkActorImpl::JointIt::operator * () const
333 {
334 const DLink* link = (const DLink*)(*this);
335 return reinterpret_cast<const TkJointLink*>(link)->m_joint;
336 }
337
338 } // namespace Blast
339 } // namespace Nv
340
341
342 #endif // ifndef NVBLASTTKACTORIMPL_H
Nv::Blast::TkFamily
Definition: NvBlastTkFamily.h:55
Nv::Blast::Array
Definition: NvBlastArray.h:46
Nv::Blast::TkActorImpl::isActive
bool isActive() const
Definition: NvBlastTkActorImpl.h:294
NvBlast.h
Nv::Blast::TkActorImpl
Definition: NvBlastTkActorImpl.h:75
Nv::Blast::TkJoint
Definition: NvBlastTkJoint.h:63
Nv::Blast::TkActorImpl::isPending
virtual bool isPending() const override
Definition: NvBlastTkActorImpl.h:300
Nv::Blast::TkActor
Definition: NvBlastTkActor.h:57
Nv::Blast::TkAsset
Definition: NvBlastTkAsset.h:59
Nv::Blast::logLL
NV_INLINE void logLL(int type, const char *msg, const char *file, int line)
Definition: NvBlastGlobals.h:195
Nv::Blast::TkActorFlag
Definition: NvBlastTkActorImpl.h:62
Nv::Blast::TkJointLink
Definition: NvBlastTkJointImpl.h:58
NvBlastActorGetIndex
NVBLAST_API uint32_t NvBlastActorGetIndex(const NvBlastActor *actor, NvBlastLog logFn)
Nv::Blast::DLink
Definition: NvBlastDLink.h:142
Nv::Blast::TkActorImpl::JointIt::JointIt
JointIt(const TkActorImpl &actor, Direction dir=Forward)
Definition: NvBlastTkActorImpl.h:329
Nv::Blast::TkWorker
Definition: NvBlastTkTaskImpl.h:346
NVBLAST_ASSERT
#define NVBLAST_ASSERT(exp)
Definition: NvBlastAssert.h:37
NvBlastIteratorBase.h
NvBlastTimers
Definition: NvBlastTypes.h:85
Nv::Blast::TkActorFlag::Enum
Enum
Definition: NvBlastTkActorImpl.h:64
Nv::Blast::TkActorImpl::getFamilyImpl
TkFamilyImpl & getFamilyImpl() const
Definition: NvBlastTkActorImpl.h:261
NvBlastDamageProgram
Definition: NvBlastTypes.h:584
NvBlastTkJointImpl.h
Nv::Blast::TkActorImpl::getGroupImpl
TkGroupImpl * getGroupImpl() const
Definition: NvBlastTkActorImpl.h:288
Nv::Blast::TkActorImpl::getIndexInternal
uint32_t getIndexInternal() const
Definition: NvBlastTkActorImpl.h:269
NvBlastDLink.h
Nv::Blast::TkActorFlag::DAMAGED
The actor had fractures applied successfully and will take the split step.
Definition: NvBlastTkActorImpl.h:66
NV_INLINE
#define NV_INLINE
Definition: NvPreprocessor.h:350
NvBlastTkCommon.h
NvBlastTkActor.h
Nv::Blast::TkActorDesc
Definition: NvBlastTkFramework.h:114
Nv::Blast::DList::It::Direction
Direction
Definition: NvBlastDLink.h:262
Nv::Blast::TkFrameworkImpl
Definition: NvBlastTkFrameworkImpl.h:54
operator*
NvcVec2 operator*(const NvcVec2 &v, float f)
Definition: NvBlastPxSharedHelpers.h:145
NvBlastFractureBuffers
Definition: NvBlastTypes.h:468
Nv::Blast::TkActorData
Definition: NvBlastTkEvent.h:53
Nv::Blast::DList
Definition: NvBlastDLink.h:164
Nv::Blast::DList::It
Definition: NvBlastDLink.h:259
Nv::Blast::TkActorImpl::JointIt
Definition: NvBlastTkActorImpl.h:195
Nv::Blast::TkActorFlag::PENDING
The actor will be processed when its group executes, used to update job queues when moving group...
Definition: NvBlastTkActorImpl.h:67
Nv::Blast::TkJointImpl
Definition: NvBlastTkJointImpl.h:67
Nv::Blast::TkActorImpl::getJointCountInternal
uint32_t getJointCountInternal() const
Definition: NvBlastTkActorImpl.h:282
Nv::Blast::TkGroup
Definition: NvBlastTkGroup.h:101
Nv
Definition: NvBlastArray.h:37
Nv::Blast::TkActorImpl::JointIt::operator*
TkJointImpl * operator*() const
Definition: NvBlastTkActorImpl.h:332
NvBlastAssert.h
NvBlastActor
Definition: NvBlastTypes.h:387
Nv::Blast::TkActorImpl::getActorLLInternal
NvBlastActor * getActorLLInternal() const
Definition: NvBlastTkActorImpl.h:276
NvBlastFamily
Definition: NvBlastTypes.h:376