NvBlastExtPxAssetImpl.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 NVBLASTEXTPXASSETIMPL_H
30 #define NVBLASTEXTPXASSETIMPL_H
31 
32 #include "NvBlastExtPxAsset.h"
33 #include "NvBlastArray.h"
34 
35 
36 namespace Nv
37 {
38 namespace Blast
39 {
40 
41 
42 using namespace physx;
43 using namespace general_PxIOStream2;
44 
45 
46 // Macro to load a uint32_t (or larger) with four characters (move it in some shared header if it's used anywhere else in Ext)
47 #define NVBLASTEXT_FOURCC(_a, _b, _c, _d) ( (uint32_t)(_a) | (uint32_t)(_b)<<8 | (uint32_t)(_c)<<16 | (uint32_t)(_d)<<24 )
48 
49 
50 class ExtPxAssetImpl final : public ExtPxAsset
51 {
53 
54 public:
55  friend class ExtPxAsset;
56 
58 
59  ExtPxAssetImpl(const ExtPxAssetDesc& desc, TkFramework& framework);
60  ExtPxAssetImpl(const TkAssetDesc& desc, ExtPxChunk* pxChunks, ExtPxSubchunk* pxSubchunks, TkFramework& framework);
61  ExtPxAssetImpl(TkAsset* asset, ExtPxAssetDesc::ChunkDesc* chunks, uint32_t chunkCount);
62  ExtPxAssetImpl(TkAsset* asset);
63 
64  ~ExtPxAssetImpl();
65 
66 
68 
69  virtual void release() override;
70 
71  virtual const TkAsset& getTkAsset() const override
72  {
73  return *m_tkAsset;
74  }
75 
76  virtual uint32_t getChunkCount() const override
77  {
78  return m_chunks.size();
79  }
80 
81  virtual const ExtPxChunk* getChunks() const override
82  {
83  return m_chunks.begin();
84  }
85 
86  virtual uint32_t getSubchunkCount() const override
87  {
88  return m_subchunks.size();
89  }
90 
91  virtual const ExtPxSubchunk* getSubchunks() const override
92  {
93  return m_subchunks.begin();
94  }
95 
97  {
98  return m_defaultActorDesc;
99  }
100 
101  virtual const NvBlastActorDesc& getDefaultActorDesc() const override
102  {
103  return m_defaultActorDesc;
104  }
105 
106  virtual void setUniformHealth(bool enabled) override;
107 
108  virtual void setAccelerator(NvBlastExtDamageAccelerator* accelerator) override
109  {
110  m_accelerator = accelerator;
111  }
112 
113  virtual NvBlastExtDamageAccelerator* getAccelerator() const override
114  {
115  return m_accelerator;
116  }
117 
118 
120 
121  /*
122  Get the underlying array for the chunks. Used for serialization.
123  */
124  Array<ExtPxChunk>::type& getChunksArray() { return m_chunks; }
125 
126  /*
127  Get the underlying array for the subchunks. Used for serialization.
128  */
130 
131  /*
132  Get the underlying array for the bond healths. Used for serialization.
133  */
134  Array<float>::type& getBondHealthsArray() { return m_bondHealths; }
135 
136  /*
137  Get the underlying array for the support chunk healths. Used for serialization.
138  */
139  Array<float>::type& getSupportChunkHealthsArray() { return m_supportChunkHealths; }
140 
141 private:
142 
144  void fillPhysicsChunks(ExtPxChunk* pxChunks, ExtPxSubchunk* pxSuchunk, uint32_t chunkCount);
145  void fillPhysicsChunks(ExtPxAssetDesc::ChunkDesc* desc, uint32_t count);
146 
147 
149 
150  TkAsset* m_tkAsset;
151  Array<ExtPxChunk>::type m_chunks;
152  Array<ExtPxSubchunk>::type m_subchunks;
153  Array<float>::type m_bondHealths;
154  Array<float>::type m_supportChunkHealths;
155  NvBlastExtDamageAccelerator* m_accelerator;
156  NvBlastActorDesc m_defaultActorDesc;
157 };
158 
159 } // namespace Blast
160 } // namespace Nv
161 
162 
163 #endif // ifndef NVBLASTEXTPXASSETIMPL_H
Definition: NvBlastExtApexSharedParts.h:34
Definition: NvBlastTypes.h:395
Definition: NvBlastArray.h:46
Definition: NvBlastExtPxAsset.h:110
Array< float >::type & getSupportChunkHealthsArray()
Definition: NvBlastExtPxAssetImpl.h:139
Array< float >::type & getBondHealthsArray()
Definition: NvBlastExtPxAssetImpl.h:134
virtual const ExtPxSubchunk * getSubchunks() const override
Definition: NvBlastExtPxAssetImpl.h:91
physx::shdfnd::Array< T, Allocator > type
Definition: NvBlastArray.h:48
virtual uint32_t getChunkCount() const override
Definition: NvBlastExtPxAssetImpl.h:76
virtual void setAccelerator(NvBlastExtDamageAccelerator *accelerator) override
Definition: NvBlastExtPxAssetImpl.h:108
virtual NvBlastExtDamageAccelerator * getAccelerator() const override
Definition: NvBlastExtPxAssetImpl.h:113
virtual const ExtPxChunk * getChunks() const override
Definition: NvBlastExtPxAssetImpl.h:81
Array< ExtPxChunk >::type & getChunksArray()
Definition: NvBlastExtPxAssetImpl.h:124
Definition: NvBlastTkAsset.h:59
Definition: NvBlastExtPxAsset.h:98
virtual const TkAsset & getTkAsset() const override
Definition: NvBlastExtPxAssetImpl.h:71
Definition: NvBlastTkFramework.h:74
Definition: NvBlastExtPxAsset.h:123
Definition: NvBlastExtDamageShaders.h:45
Definition: NvBlastExtPxAsset.h:64
Definition: NvBlastExtPxAsset.h:82
Definition: NvBlastExtPxAssetImpl.h:50
virtual NvBlastActorDesc & getDefaultActorDesc() override
Definition: NvBlastExtPxAssetImpl.h:96
virtual uint32_t getSubchunkCount() const override
Definition: NvBlastExtPxAssetImpl.h:86
Definition: NvBlastTkFramework.h:160
Array< ExtPxSubchunk >::type & getSubchunksArray()
Definition: NvBlastExtPxAssetImpl.h:129
virtual const NvBlastActorDesc & getDefaultActorDesc() const override
Definition: NvBlastExtPxAssetImpl.h:101
#define NV_NOCOPY(Class)
Definition: NvPreprocessor.h:527
Definition: NvBlastArray.h:37