NvBlastTkFrameworkImpl.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 NVBLASTTKFRAMEWORKIMPL_H
30 #define NVBLASTTKFRAMEWORKIMPL_H
31 
32 #include "NvBlastTkFramework.h"
34 
35 #include "NvBlastTkCommon.h"
36 
37 #include "NvBlastArray.h"
38 #include "NvBlastHashMap.h"
39 #include "NvBlastHashSet.h"
40 
41 
42 namespace Nv
43 {
44 namespace Blast
45 {
46 
47 // Forward declarations
48 class TkTypeImpl;
49 class TkJointImpl;
50 
55 {
56 public:
59 
60  // Begin TkFramework
61  virtual void release() override;
62 
63  virtual const TkType* getType(TkTypeIndex::Enum typeIndex) const override;
64 
65  virtual TkIdentifiable* findObjectByID(const NvBlastID& id) const override;
66 
67  virtual uint32_t getObjectCount(const TkType& type) const override;
68 
69  virtual uint32_t getObjects(TkIdentifiable** buffer, uint32_t bufferSize, const TkType& type, uint32_t indexStart = 0) const override;
70 
71  virtual bool reorderAssetDescChunks(NvBlastChunkDesc* chunkDescs, uint32_t chunkCount, NvBlastBondDesc* bondDescs, uint32_t bondCount, uint32_t* chunkReorderMap = nullptr, bool keepBondNormalChunkOrder = false) const override;
72 
73  virtual bool ensureAssetExactSupportCoverage(NvBlastChunkDesc* chunkDescs, uint32_t chunkCount) const override;
74 
75  virtual TkAsset* createAsset(const TkAssetDesc& desc) override;
76 
77  virtual TkAsset* createAsset(const NvBlastAsset* assetLL, Nv::Blast::TkAssetJointDesc* jointDescs = nullptr, uint32_t jointDescCount = 0, bool ownsAsset = false) override;
78 
79  virtual TkGroup* createGroup(const TkGroupDesc& desc) override;
80 
81  virtual TkActor* createActor(const TkActorDesc& desc) override;
82 
83  virtual TkJoint* createJoint(const TkJointDesc& desc) override;
84  // End TkFramework
85 
86  // Public methods
90  void onCreate(TkIdentifiable& object);
91 
95  void onDestroy(TkIdentifiable& object);
96 
100  void onCreate(TkJointImpl& joint);
101 
105  void onDestroy(TkJointImpl& joint);
106 
110  void onIDChange(TkIdentifiable& object, const NvBlastID& IDPrev, const NvBlastID& IDCurr);
111 
116 
117  // Access to singleton
118 
120  static TkFrameworkImpl* get();
121 
123  static bool set(TkFrameworkImpl* framework);
124 
125 private:
126  // Enums
127  enum { ClassID = NVBLAST_FOURCC('T', 'K', 'F', 'W') };
128 
129  // Static data
130  static TkFrameworkImpl* s_framework;
131 
132  // Types
134  HashMap<uint32_t, uint32_t>::type m_typeIDToIndex;
135 
136  // Objects and object names
139 
140  // Track external joints (to do: make this a pool)
141  HashSet<TkJointImpl*>::type m_joints;
142 };
143 
144 
146 
148 {
149  const auto entry = m_IDToObject.find(id);
150  if (entry == nullptr)
151  {
152  return nullptr;
153  }
154 
155  return entry->second;
156 }
157 
158 } // namespace Blast
159 } // namespace Nv
160 
161 
162 #endif // ifndef NVBLASTTKFRAMEWORKIMPL_H
virtual TkGroup * createGroup(const TkGroupDesc &desc) override
virtual uint32_t getObjectCount(const TkType &type) const override
void onIDChange(TkIdentifiable &object, const NvBlastID &IDPrev, const NvBlastID &IDCurr)
Enum
Definition: NvBlastTkFramework.h:143
Definition: NvBlastTkFramework.h:149
physx::shdfnd::InlineArray< T, N, Allocator > type
Definition: NvBlastArray.h:60
virtual TkAsset * createAsset(const TkAssetDesc &desc) override
Definition: NvBlastTkJoint.h:63
physx::shdfnd::HashSet< Key, HashFn, Allocator > type
Definition: NvBlastHashSet.h:47
Definition: NvBlastArray.h:58
Definition: NvBlastTkActor.h:57
Definition: NvBlastHashMap.h:46
Definition: NvBlastTkAsset.h:59
Definition: NvBlastTypes.h:322
Definition: NvBlastTkFramework.h:74
Definition: NvBlastTkGroup.h:48
physx::shdfnd::HashMap< Key, Value, HashFn, Allocator > type
Definition: NvBlastHashMap.h:48
Definition: NvBlastTkFramework.h:130
Definition: NvBlastTkIdentifiable.h:50
virtual void release() override
virtual const TkType * getType(TkTypeIndex::Enum typeIndex) const override
virtual bool reorderAssetDescChunks(NvBlastChunkDesc *chunkDescs, uint32_t chunkCount, NvBlastBondDesc *bondDescs, uint32_t bondCount, uint32_t *chunkReorderMap=nullptr, bool keepBondNormalChunkOrder=false) const override
Definition: NvBlastTkType.h:46
#define NV_INLINE
Definition: NvPreprocessor.h:350
Definition: NvBlastTypes.h:69
#define NVBLAST_FOURCC(_a, _b, _c, _d)
Definition: NvBlastGlobals.h:274
virtual bool ensureAssetExactSupportCoverage(NvBlastChunkDesc *chunkDescs, uint32_t chunkCount) const override
void onDestroy(TkIdentifiable &object)
Definition: NvBlastTypes.h:292
virtual TkJoint * createJoint(const TkJointDesc &desc) override
Definition: NvBlastTkFramework.h:114
Definition: NvBlastTkFrameworkImpl.h:54
virtual TkActor * createActor(const TkActorDesc &desc) override
Definition: NvBlastTypes.h:286
Definition: NvBlastTkFramework.h:160
virtual TkIdentifiable * findObjectByID(const NvBlastID &id) const override
void onCreate(TkIdentifiable &object)
Definition: NvBlastTkJointImpl.h:67
Definition: NvBlastTkAsset.h:48
Definition: NvBlastTkGroup.h:101
Definition: NvBlastArray.h:37
TkIdentifiable * findObjectByIDInternal(const NvBlastID &id) const
Definition: NvBlastTkFrameworkImpl.h:147
virtual uint32_t getObjects(TkIdentifiable **buffer, uint32_t bufferSize, const TkType &type, uint32_t indexStart=0) const override