00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef NVBLASTTKFRAMEWORKIMPL_H
00030 #define NVBLASTTKFRAMEWORKIMPL_H
00031
00032 #include "NvBlastTkFramework.h"
00033 #include "NvBlastProfilerInternal.h"
00034
00035 #include "NvBlastTkCommon.h"
00036
00037 #include "NvBlastArray.h"
00038 #include "NvBlastHashMap.h"
00039 #include "NvBlastHashSet.h"
00040
00041
00042 namespace Nv
00043 {
00044 namespace Blast
00045 {
00046
00047
00048 class TkTypeImpl;
00049 class TkJointImpl;
00050
00054 class TkFrameworkImpl : public TkFramework
00055 {
00056 public:
00057 TkFrameworkImpl();
00058 ~TkFrameworkImpl();
00059
00060
00061 virtual void release() override;
00062
00063 virtual const TkType* getType(TkTypeIndex::Enum typeIndex) const override;
00064
00065 virtual TkIdentifiable* findObjectByID(const NvBlastID& id) const override;
00066
00067 virtual uint32_t getObjectCount(const TkType& type) const override;
00068
00069 virtual uint32_t getObjects(TkIdentifiable** buffer, uint32_t bufferSize, const TkType& type, uint32_t indexStart = 0) const override;
00070
00071 virtual bool reorderAssetDescChunks(NvBlastChunkDesc* chunkDescs, uint32_t chunkCount, NvBlastBondDesc* bondDescs, uint32_t bondCount, uint32_t* chunkReorderMap = nullptr, bool keepBondNormalChunkOrder = false) const override;
00072
00073 virtual bool ensureAssetExactSupportCoverage(NvBlastChunkDesc* chunkDescs, uint32_t chunkCount) const override;
00074
00075 virtual TkAsset* createAsset(const TkAssetDesc& desc) override;
00076
00077 virtual TkAsset* createAsset(const NvBlastAsset* assetLL, Nv::Blast::TkAssetJointDesc* jointDescs = nullptr, uint32_t jointDescCount = 0, bool ownsAsset = false) override;
00078
00079 virtual TkGroup* createGroup(const TkGroupDesc& desc) override;
00080
00081 virtual TkActor* createActor(const TkActorDesc& desc) override;
00082
00083 virtual TkJoint* createJoint(const TkJointDesc& desc) override;
00084
00085
00086
00090 void onCreate(TkIdentifiable& object);
00091
00095 void onDestroy(TkIdentifiable& object);
00096
00100 void onCreate(TkJointImpl& joint);
00101
00105 void onDestroy(TkJointImpl& joint);
00106
00110 void onIDChange(TkIdentifiable& object, const NvBlastID& IDPrev, const NvBlastID& IDCurr);
00111
00115 TkIdentifiable* findObjectByIDInternal(const NvBlastID& id) const;
00116
00117
00118
00120 static TkFrameworkImpl* get();
00121
00123 static bool set(TkFrameworkImpl* framework);
00124
00125 private:
00126
00127 enum { ClassID = NVBLAST_FOURCC('T', 'K', 'F', 'W') };
00128
00129
00130 static TkFrameworkImpl* s_framework;
00131
00132
00133 InlineArray<const TkTypeImpl*, TkTypeIndex::TypeCount>::type m_types;
00134 HashMap<uint32_t, uint32_t>::type m_typeIDToIndex;
00135
00136
00137 HashMap<NvBlastID, TkIdentifiable*>::type m_IDToObject;
00138 InlineArray<Array<TkIdentifiable*>::type, TkTypeIndex::TypeCount>::type m_objects;
00139
00140
00141 HashSet<TkJointImpl*>::type m_joints;
00142 };
00143
00144
00146
00147 NV_INLINE TkIdentifiable* TkFrameworkImpl::findObjectByIDInternal(const NvBlastID& id) const
00148 {
00149 const auto entry = m_IDToObject.find(id);
00150 if (entry == nullptr)
00151 {
00152 return nullptr;
00153 }
00154
00155 return entry->second;
00156 }
00157
00158 }
00159 }
00160
00161
00162 #endif // ifndef NVBLASTTKFRAMEWORKIMPL_H