1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
|
// This code contains NVIDIA Confidential Information and is disclosed to you
// under a form of NVIDIA software license agreement provided separately to you.
//
// Notice
// NVIDIA Corporation and its licensors retain all intellectual property and
// proprietary rights in and to this software and related documentation and
// any modifications thereto. Any use, reproduction, disclosure, or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA Corporation is strictly prohibited.
//
// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
//
// Information and code furnished is believed to be accurate and reliable.
// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
// information or for any infringement of patents or other rights of third parties that may
// result from its use. No license is granted by implication or otherwise under any patent
// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
// This code supersedes and replaces all information previously supplied.
// NVIDIA Corporation products are not authorized for use as critical
// components in life support devices or systems without express written approval of
// NVIDIA Corporation.
//
// Copyright (c) 2016-2018 NVIDIA Corporation. All rights reserved.
#ifndef NVBLASTEXTPXFAMILY_H
#define NVBLASTEXTPXFAMILY_H
#include "PxFiltering.h"
// Forward declarations
namespace physx
{
class PxRigidDynamic;
class PxMaterial;
class PxScene;
class PxTransform;
}
struct NvBlastExtMaterial;
namespace Nv
{
namespace Blast
{
// Forward declarations
class ExtPxActor;
class ExtPxAsset;
class ExtPxListener;
class TkFamily;
/**
PxShape Desc.
Used to set settings for newly created PxShapes.
@see PxShape
*/
struct ExtPxShapeDescTemplate
{
uint8_t flags; //!< PxShapeFlags flags
physx::PxFilterData simulationFilterData; //!< user definable collision filter data
physx::PxFilterData queryFilterData; //!< user definable query filter data.
float contactOffset; //!< contact offset
float restOffset; //!< rest offset
};
/**
PxActor Desc.
Used to set settings for newly created PxActors.
*/
struct ExtPxActorDescTemplate
{
uint8_t flags; //!< actor flags
};
/**
Physics Spawn Settings.
This Struct unifies setting to be used when PhysX actors are created.
*/
struct ExtPxSpawnSettings
{
physx::PxScene* scene; //!< PxScene for PxActors to be spawned
physx::PxMaterial* material; //!< default PxMaterial
float density; //!< default density for PhysX
};
/**
PxFamily.
A collection of actors. Maps 1 to 1 with TkFamily.
*/
class ExtPxFamily
{
public:
/**
Spawn ExtPxFamily. Can be called only once. Actual PhysX actors will created and placed in PxScene
\param[in] pose World transform.
\param[in] scale Scale applied to spawned actors.
\param[in] settings Spawn settings.
\return true if spawn was successful, false otherwise.
*/
virtual bool spawn(const physx::PxTransform& pose, const physx::PxVec3& scale, const ExtPxSpawnSettings& settings) = 0;
/**
Despawn this ExtPxFamily. This removes the PhysX actors from PxScene and deletes them, as well as
deleting the created ExtPxActors
This does not call release() on the family.
\returns true if successful.
*/
virtual bool despawn() = 0;
/**
The number of actors currently in this family.
\return the number of ExtPxActor that currently exist in this family.
*/
virtual uint32_t getActorCount() const = 0;
/**
Retrieve an array of pointers (into the user-supplied buffer) to actors.
\param[out] buffer A user-supplied array of ExtPxActor pointers.
\param[in] bufferSize The number of elements available to write into buffer.
\return the number of ExtPxActor pointers written to the buffer.
*/
virtual uint32_t getActors(ExtPxActor** buffer, uint32_t bufferSize) const = 0;
/**
Every family has corresponding TkFamily.
/return a pointer to TkFamily actor.
*/
virtual TkFamily& getTkFamily() const = 0;
/**
Access an array of shapes of subchunks. The size of array is equal getPxAsset()->getSubchunkCount().
For every corresponding subchunk it contains pointer to created PxShape or nullptr.
\return the pointer to subchunk shapes array.
*/
virtual const physx::PxShape* const* getSubchunkShapes() const = 0;
/**
Every family has an associated asset.
\return a pointer to the (const) ExtPxAsset object.
*/
virtual ExtPxAsset& getPxAsset() const = 0;
/**
Set the default material to be used for PxRigidDynamic creation.
\param[in] material The material to be the new default.
*/
virtual void setMaterial(physx::PxMaterial& material) = 0;
/*
Set ExtPxPxShapeDesc to be used on all newly created PxShapes.
NOTE: Using it will override marking LEAF_CHUNK in simulationFilterData.word3 now.
\param[in] pxShapeDesc The PxShape desc to be the new default. Can be nullptr.
*/
virtual void setPxShapeDescTemplate(const ExtPxShapeDescTemplate* pxShapeDesc) = 0;
/**
Get the default ExtPxPxShapeDesc to be used on all newly created PxShapes.
\return a pointer to the default PxShape desc. Can be nullptr.
*/
virtual const ExtPxShapeDescTemplate* getPxShapeDescTemplate() const = 0;
/*
Set ExtPxPxActorDesc to be used on all newly created PxActors.
\param[in] pxActorDesc The PxActor desc to be the new default. Can be nullptr.
*/
virtual void setPxActorDesc(const ExtPxActorDescTemplate* pxActorDesc) = 0;
/**
Get the default ExtPxPxActorDesc to be used on all newly created PxActors.
\return a pointer to the default PxActor desc. Can be nullptr.
*/
virtual const ExtPxActorDescTemplate* getPxActorDesc() const = 0;
/**
The default material associated with this actor family.
\return a pointer to the default material.
*/
virtual const NvBlastExtMaterial* getMaterial() const = 0;
/**
Set the default material associated with this actor family.
\param[in] material The material to be the new default.
*/
virtual void setMaterial(const NvBlastExtMaterial* material) = 0;
/**
Add a user implementation of ExtPxListener to this family's list of listeners.
\param[in] listener The event listener to add.
*/
virtual void subscribe(ExtPxListener& listener) = 0;
/**
Remove a user implementation of ExtPxListener from this family's list of listeners.
\param[in] listener The event listener to remove.
*/
virtual void unsubscribe(ExtPxListener& listener) = 0;
/**
Call after split.
*/
virtual void postSplitUpdate() = 0;
/**
Release this family.
*/
virtual void release() = 0;
/**
UserData pointer. Free to be used by user in any way.
*/
void* userData;
};
} // namespace Blast
} // namespace Nv
#endif // ifndef NVBLASTEXTPXFAMILY_H
|