Main Page Class List Class Members

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"
33 #include "NvBlastProfilerInternal.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
54 class TkFrameworkImpl : public TkFramework
55 {
56 public:
57 TkFrameworkImpl();
58 ~TkFrameworkImpl();
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
115 TkIdentifiable* findObjectByIDInternal(const NvBlastID& id) const;
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
133 InlineArray<const TkTypeImpl*, TkTypeIndex::TypeCount>::type m_types;
134 HashMap<uint32_t, uint32_t>::type m_typeIDToIndex;
135
136 // Objects and object names
137 HashMap<NvBlastID, TkIdentifiable*>::type m_IDToObject;
138 InlineArray<Array<TkIdentifiable*>::type, TkTypeIndex::TypeCount>::type m_objects;
139
140 // Track external joints (to do: make this a pool)
141 HashSet<TkJointImpl*>::type m_joints;
142 };
143
144
146
147 NV_INLINE TkIdentifiable* TkFrameworkImpl::findObjectByIDInternal(const NvBlastID& id) const
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
Nv::Blast::TkFrameworkImpl::createGroup
virtual TkGroup * createGroup(const TkGroupDesc &desc) override
Nv::Blast::TkFrameworkImpl::getObjectCount
virtual uint32_t getObjectCount(const TkType &type) const override
NvBlastArray.h
Nv::Blast::TkFrameworkImpl::onIDChange
void onIDChange(TkIdentifiable &object, const NvBlastID &IDPrev, const NvBlastID &IDCurr)
Nv::Blast::TkTypeIndex::Enum
Enum
Definition: NvBlastTkFramework.h:143
Nv::Blast::TkTypeIndex::TypeCount
Definition: NvBlastTkFramework.h:149
Nv::Blast::InlineArray::type
physx::shdfnd::InlineArray< T, N, Allocator > type
Definition: NvBlastArray.h:60
Nv::Blast::TkFrameworkImpl::~TkFrameworkImpl
~TkFrameworkImpl()
Nv::Blast::TkFrameworkImpl::createAsset
virtual TkAsset * createAsset(const TkAssetDesc &desc) override
Nv::Blast::TkJoint
Definition: NvBlastTkJoint.h:63
Nv::Blast::HashSet::type
physx::shdfnd::HashSet< Key, HashFn, Allocator > type
Definition: NvBlastHashSet.h:47
Nv::Blast::InlineArray
Definition: NvBlastArray.h:58
Nv::Blast::TkActor
Definition: NvBlastTkActor.h:57
Nv::Blast::HashMap
Definition: NvBlastHashMap.h:46
Nv::Blast::TkAsset
Definition: NvBlastTkAsset.h:59
NvBlastBondDesc
Definition: NvBlastTypes.h:322
Nv::Blast::TkAssetDesc
Definition: NvBlastTkFramework.h:74
Nv::Blast::TkGroupDesc
Definition: NvBlastTkGroup.h:48
NvBlastHashMap.h
Nv::Blast::HashMap::type
physx::shdfnd::HashMap< Key, Value, HashFn, Allocator > type
Definition: NvBlastHashMap.h:48
Nv::Blast::TkJointDesc
Definition: NvBlastTkFramework.h:130
Nv::Blast::TkIdentifiable
Definition: NvBlastTkIdentifiable.h:50
Nv::Blast::TkFrameworkImpl::release
virtual void release() override
Nv::Blast::TkFrameworkImpl::getType
virtual const TkType * getType(TkTypeIndex::Enum typeIndex) const override
Nv::Blast::TkFrameworkImpl::reorderAssetDescChunks
virtual bool reorderAssetDescChunks(NvBlastChunkDesc *chunkDescs, uint32_t chunkCount, NvBlastBondDesc *bondDescs, uint32_t bondCount, uint32_t *chunkReorderMap=nullptr, bool keepBondNormalChunkOrder=false) const override
Nv::Blast::TkType
Definition: NvBlastTkType.h:46
Nv::Blast::TkFrameworkImpl::TkFrameworkImpl
TkFrameworkImpl()
NV_INLINE
#define NV_INLINE
Definition: NvPreprocessor.h:350
NvBlastTkFramework.h
NvBlastID
Definition: NvBlastTypes.h:69
NvBlastTkCommon.h
NVBLAST_FOURCC
#define NVBLAST_FOURCC(_a, _b, _c, _d)
Definition: NvBlastGlobals.h:274
NvBlastHashSet.h
Nv::Blast::TkFrameworkImpl::ensureAssetExactSupportCoverage
virtual bool ensureAssetExactSupportCoverage(NvBlastChunkDesc *chunkDescs, uint32_t chunkCount) const override
Nv::Blast::TkFrameworkImpl::onDestroy
void onDestroy(TkIdentifiable &object)
NvBlastChunkDesc
Definition: NvBlastTypes.h:292
Nv::Blast::TkFrameworkImpl::createJoint
virtual TkJoint * createJoint(const TkJointDesc &desc) override
Nv::Blast::TkActorDesc
Definition: NvBlastTkFramework.h:114
Nv::Blast::TkFrameworkImpl
Definition: NvBlastTkFrameworkImpl.h:54
Nv::Blast::TkFrameworkImpl::createActor
virtual TkActor * createActor(const TkActorDesc &desc) override
NvBlastAsset
Definition: NvBlastTypes.h:286
Nv::Blast::TkFramework
Definition: NvBlastTkFramework.h:160
Nv::Blast::TkFrameworkImpl::findObjectByID
virtual TkIdentifiable * findObjectByID(const NvBlastID &id) const override
Nv::Blast::TkFrameworkImpl::onCreate
void onCreate(TkIdentifiable &object)
Nv::Blast::TkJointImpl
Definition: NvBlastTkJointImpl.h:67
Nv::Blast::TkAssetJointDesc
Definition: NvBlastTkAsset.h:48
Nv::Blast::TkGroup
Definition: NvBlastTkGroup.h:101
NvBlastProfilerInternal.h
Nv
Definition: NvBlastArray.h:37
Nv::Blast::TkFrameworkImpl::findObjectByIDInternal
TkIdentifiable * findObjectByIDInternal(const NvBlastID &id) const
Definition: NvBlastTkFrameworkImpl.h:147
Nv::Blast::TkFrameworkImpl::getObjects
virtual uint32_t getObjects(TkIdentifiable **buffer, uint32_t bufferSize, const TkType &type, uint32_t indexStart=0) const override