NvBlastExtSync.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 NVBLASTEXTSYNC_H
30 #define NVBLASTEXTSYNC_H
31 
32 #include "NvBlastTk.h"
33 #include "foundation/PxTransform.h"
34 #include "NvPreprocessor.h"
35 #include "NvBlastGlobals.h"
36 
37 
38 namespace Nv
39 {
40 namespace Blast
41 {
42 
43 class ExtPxFamily;
44 class ExtPxManager;
45 
46 
51 {
52  enum Enum
53  {
54  Fracture = 0,
57 
59  };
60 };
61 
62 
66 struct NV_DLL_EXPORT ExtSyncEvent
67 {
69  virtual ~ExtSyncEvent() {}
70 
71  template<class T>
72  const T* getEvent() const { return reinterpret_cast<const T*>(this); }
73 
79  virtual ExtSyncEvent* clone() const = 0;
80 
81  void release();
82 
84  uint64_t timestamp;
86 };
87 
88 
92 template <class T, ExtSyncEventType::Enum eventType>
94 {
96 
97  static const ExtSyncEventType::Enum EVENT_TYPE = eventType;
98 
99  ExtSyncEvent* clone() const override
100  {
101  return NVBLAST_NEW (T) (*(T*)this);
102  }
103 };
104 
105 
109 struct ExtSyncEventFracture : public ExtSyncEventInstance<ExtSyncEventFracture, ExtSyncEventType::Fracture>
110 {
111  std::vector<NvBlastBondFractureData> bondFractures;
112  std::vector<NvBlastChunkFractureData> chunkFractures;
113 };
114 
115 
119 struct ExtSyncEventFamilySync : public ExtSyncEventInstance<ExtSyncEventFamilySync, ExtSyncEventType::FamilySync>
120 {
121  std::vector<char> family;
122 };
123 
124 
128 struct ExtSyncEventPhysicsSync : public ExtSyncEventInstance<ExtSyncEventPhysicsSync, ExtSyncEventType::Physics>
129 {
130  struct ActorData
131  {
132  uint32_t actorIndex;
133  physx::PxTransform transform;
134  };
135 
136  std::vector<ActorData> data;
137 };
138 
139 
145 class NV_DLL_EXPORT ExtSync : public TkEventListener
146 {
147 public:
149 
155  static ExtSync* create();
156 
157 
159 
163  virtual void release() = 0;
164 
165 
167 
174  virtual void receive(const TkEvent* events, uint32_t eventCount) = 0;
175 
181  virtual void syncFamily(const TkFamily& family) = 0;
182 
188  virtual void syncFamily(const ExtPxFamily& family) = 0;
189 
195  virtual uint32_t getSyncBufferSize() const = 0;
196 
203  virtual void acquireSyncBuffer(const ExtSyncEvent*const*& buffer, uint32_t& size) const = 0;
204 
208  virtual void releaseSyncBuffer() = 0;
209 
210 
212 
223  virtual void applySyncBuffer(TkFramework& framework, const ExtSyncEvent** buffer, uint32_t size, TkGroup* groupForNewActors, ExtPxManager* manager = nullptr) = 0;
224 
225 };
226 
227 } // namespace Blast
228 } // namespace Nv
229 
230 
231 #endif // ifndef NVBLASTEXTSYNC_H
Definition: NvBlastTkFamily.h:55
std::vector< ActorData > data
actors data
Definition: NvBlastExtSync.h:136
ExtSyncEventInstance()
Definition: NvBlastExtSync.h:95
Definition: NvBlastExtSync.h:58
Definition: NvBlastExtSync.h:109
std::vector< NvBlastBondFractureData > bondFractures
bond fracture data
Definition: NvBlastExtSync.h:111
Definition: NvBlastTkEvent.h:65
ExtSyncEventType::Enum type
Event type.
Definition: NvBlastExtSync.h:83
virtual ~ExtSyncEvent()
Definition: NvBlastExtSync.h:69
Definition: NvBlastExtSync.h:119
Definition: NvBlastExtSync.h:128
const T * getEvent() const
Definition: NvBlastExtSync.h:72
std::vector< char > family
family binary blob
Definition: NvBlastExtSync.h:121
ExtSyncEvent(ExtSyncEventType::Enum t)
Definition: NvBlastExtSync.h:68
Definition: NvBlastTkEvent.h:168
uint32_t actorIndex
actor index in family
Definition: NvBlastExtSync.h:132
Definition: NvBlastExtSync.h:66
Definition: NvBlastExtSync.h:130
Definition: NvBlastExtSync.h:145
std::vector< NvBlastChunkFractureData > chunkFractures
chunk fracture data
Definition: NvBlastExtSync.h:112
Enum
Definition: NvBlastExtSync.h:52
#define NVBLAST_NEW(T)
Definition: NvBlastGlobals.h:228
Definition: NvBlastExtSync.h:50
Definition: NvBlastTypes.h:69
physx::PxTransform transform
actor world transform
Definition: NvBlastExtSync.h:133
NvBlastID familyID
TkFamily ID.
Definition: NvBlastExtSync.h:85
Definition: NvBlastExtPxFamily.h:105
Contains full family Family blob.
Definition: NvBlastExtSync.h:55
Definition: NvBlastExtSync.h:93
Definition: NvBlastTkFramework.h:160
Contains Fracture commands.
Definition: NvBlastExtSync.h:54
Definition: NvBlastExtPxManager.h:99
Definition: NvBlastTkGroup.h:101
Contains actor&#39;s physical info, like transforms.
Definition: NvBlastExtSync.h:56
Definition: NvBlastExtAuthoring.h:34
uint64_t timestamp
Event timestamp.
Definition: NvBlastExtSync.h:84
ExtSyncEvent * clone() const override
Definition: NvBlastExtSync.h:99