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 NVBLASTEXTSYNC_H
00030 #define NVBLASTEXTSYNC_H
00031
00032 #include "NvBlastTk.h"
00033 #include "foundation/PxTransform.h"
00034 #include "NvPreprocessor.h"
00035 #include "NvBlastGlobals.h"
00036
00037
00038 namespace Nv
00039 {
00040 namespace Blast
00041 {
00042
00043 class ExtPxFamily;
00044 class ExtPxManager;
00045
00046
00050 struct ExtSyncEventType
00051 {
00052 enum Enum
00053 {
00054 Fracture = 0,
00055 FamilySync,
00056 Physics,
00057
00058 Count
00059 };
00060 };
00061
00062
00066 struct NV_DLL_EXPORT ExtSyncEvent
00067 {
00068 ExtSyncEvent(ExtSyncEventType::Enum t) : type(t) {}
00069 virtual ~ExtSyncEvent() {}
00070
00071 template<class T>
00072 const T* getEvent() const { return reinterpret_cast<const T*>(this); }
00073
00079 virtual ExtSyncEvent* clone() const = 0;
00080
00081 void release();
00082
00083 ExtSyncEventType::Enum type;
00084 uint64_t timestamp;
00085 NvBlastID familyID;
00086 };
00087
00088
00092 template <class T, ExtSyncEventType::Enum eventType>
00093 struct ExtSyncEventInstance : public ExtSyncEvent
00094 {
00095 ExtSyncEventInstance() : ExtSyncEvent(eventType) {}
00096
00097 static const ExtSyncEventType::Enum EVENT_TYPE = eventType;
00098
00099 ExtSyncEvent* clone() const override
00100 {
00101 return NVBLAST_NEW (T) (*(T*)this);
00102 }
00103 };
00104
00105
00109 struct ExtSyncEventFracture : public ExtSyncEventInstance<ExtSyncEventFracture, ExtSyncEventType::Fracture>
00110 {
00111 std::vector<NvBlastBondFractureData> bondFractures;
00112 std::vector<NvBlastChunkFractureData> chunkFractures;
00113 };
00114
00115
00119 struct ExtSyncEventFamilySync : public ExtSyncEventInstance<ExtSyncEventFamilySync, ExtSyncEventType::FamilySync>
00120 {
00121 std::vector<char> family;
00122 };
00123
00124
00128 struct ExtSyncEventPhysicsSync : public ExtSyncEventInstance<ExtSyncEventPhysicsSync, ExtSyncEventType::Physics>
00129 {
00130 struct ActorData
00131 {
00132 uint32_t actorIndex;
00133 physx::PxTransform transform;
00134 };
00135
00136 std::vector<ActorData> data;
00137 };
00138
00139
00145 class NV_DLL_EXPORT ExtSync : public TkEventListener
00146 {
00147 public:
00149
00155 static ExtSync* create();
00156
00157
00159
00163 virtual void release() = 0;
00164
00165
00167
00174 virtual void receive(const TkEvent* events, uint32_t eventCount) = 0;
00175
00181 virtual void syncFamily(const TkFamily& family) = 0;
00182
00188 virtual void syncFamily(const ExtPxFamily& family) = 0;
00189
00195 virtual uint32_t getSyncBufferSize() const = 0;
00196
00203 virtual void acquireSyncBuffer(const ExtSyncEvent*const*& buffer, uint32_t& size) const = 0;
00204
00208 virtual void releaseSyncBuffer() = 0;
00209
00210
00212
00223 virtual void applySyncBuffer(TkFramework& framework, const ExtSyncEvent** buffer, uint32_t size, TkGroup* groupForNewActors, ExtPxManager* manager = nullptr) = 0;
00224
00225 };
00226
00227 }
00228 }
00229
00230
00231 #endif // ifndef NVBLASTEXTSYNC_H