RavEngine
Loading...
Searching...
No Matches
NpPvdSceneClient.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef NP_SCENE_PVD_CLIENT_H
30#define NP_SCENE_PVD_CLIENT_H
31
32#include "PxPhysXConfig.h"
33
34#if PX_SUPPORT_PVD
35
36#include "foundation/PxStrideIterator.h"
37#include "pvd/PxPvdTransport.h"
38#include "pvd/PxPvdSceneClient.h"
39
40#include "PvdMetaDataPvdBinding.h"
41#include "foundation/PxBitMap.h"
42#include "PxPvdClient.h"
43#include "PxPvdUserRenderer.h"
44#include "PsPvd.h"
45
46#include "PxsMaterialCore.h"
47#include "PxsFEMSoftBodyMaterialCore.h"
48#include "PxsFEMClothMaterialCore.h"
49#include "PxsPBDMaterialCore.h"
50#include "PxsFLIPMaterialCore.h"
51#include "PxsMPMMaterialCore.h"
52
53namespace physx
54{
55class PxActor;
56class PxArticulationLink;
57class PxRenderBuffer;
58class NpConstraint;
59class NpShape;
60class NpAggregate;
61class NpRigidStatic;
62class NpRigidDynamic;
63class NpArticulationLink;
64class NpArticulationJointReducedCoordinate;
65class NpArticulationReducedCoordinate;
66class NpArticulationSpatialTendon;
67class NpArticulationFixedTendon;
68class NpArticulationSensor;
69class NpActor;
70class NpScene;
71
72#if PX_SUPPORT_GPU_PHYSX
73class NpSoftBody;
74class NpFEMCloth;
75class NpPBDParticleSystem;
76class NpFLIPParticleSystem;
77class NpMPMParticleSystem;
78class NpCustomParticleSystem;
79class NpHairSystem;
80#endif
81
82namespace Sc
83{
84class ConstraintCore;
85}
86
87namespace Vd
88{
89class PvdSceneClient : public PxPvdSceneClient, public PvdClient, public PvdVisualizer
90{
91 PX_NOCOPY(PvdSceneClient)
92 public:
93 PvdSceneClient(NpScene& scene);
94 virtual ~PvdSceneClient();
95
96 // PxPvdSceneClient
97 virtual void setScenePvdFlag(PxPvdSceneFlag::Enum flag, bool value);
98 virtual void setScenePvdFlags(PxPvdSceneFlags flags) { mFlags = flags; }
99 virtual PxPvdSceneFlags getScenePvdFlags() const { return mFlags; }
100 virtual void updateCamera(const char* name, const PxVec3& origin, const PxVec3& up, const PxVec3& target);
101 virtual void drawPoints(const PxDebugPoint* points, PxU32 count);
102 virtual void drawLines(const PxDebugLine* lines, PxU32 count);
103 virtual void drawTriangles(const PxDebugTriangle* triangles, PxU32 count);
104 virtual void drawText(const PxDebugText& text);
105 virtual PvdClient* getClientInternal() { return this; }
106 //~PxPvdSceneClient
107
108 // pvdClient
109 virtual PvdDataStream* getDataStream() { return mPvdDataStream; }
110 virtual bool isConnected() const { return mIsConnected; }
111 virtual void onPvdConnected();
112 virtual void onPvdDisconnected();
113 virtual void flush() {}
114 //~pvdClient
115
116 PX_FORCE_INLINE bool checkPvdDebugFlag() const
117 {
118 return mIsConnected && (mPvd->getInstrumentationFlags() & PxPvdInstrumentationFlag::eDEBUG);
119 }
120
121 PX_FORCE_INLINE PxPvdSceneFlags getScenePvdFlagsFast() const { return mFlags; }
122 PX_FORCE_INLINE void setPsPvd(PsPvd* pvd) { mPvd = pvd; }
123
124 void frameStart(PxReal simulateElapsedTime);
125 void frameEnd();
126
127 void updatePvdProperties();
128 void releasePvdInstance();
129
130 void createPvdInstance (const PxActor* actor); // temporary for deformables and particle systems - sschirm: deformables and particles are gone...
131 void updatePvdProperties(const PxActor* actor);
132 void releasePvdInstance (const PxActor* actor); // temporary for deformables and particle systems - sschirm: deformables and particles are gone...
133
134 void createPvdInstance (const NpActor* actor); // temporary for deformables and particle systems - sschirm: deformables and particles are gone...
135 void updatePvdProperties(const NpActor* actor);
136 void releasePvdInstance (const NpActor* actor); // temporary for deformables and particle systems - sschirm: deformables and particles are gone...
137
138 void createPvdInstance (const NpRigidDynamic* body);
139 void createPvdInstance (const NpArticulationLink* body);
140 void updatePvdProperties (const NpRigidDynamic* body);
141 void updatePvdProperties (const NpArticulationLink* body);
142 void releasePvdInstance (const NpRigidDynamic* body);
143 void releasePvdInstance (const NpArticulationLink* body);
144 void updateBodyPvdProperties(const NpActor* body);
145 void updateKinematicTarget (const NpActor* body, const PxTransform& p);
146
147 void createPvdInstance (const NpRigidStatic* rigidStatic);
148 void updatePvdProperties (const NpRigidStatic* rigidStatic);
149 void releasePvdInstance (const NpRigidStatic* rigidStatic);
150
151 void createPvdInstance (const NpConstraint* constraint);
152 void updatePvdProperties(const NpConstraint* constraint);
153 void releasePvdInstance (const NpConstraint* constraint);
154
155 void createPvdInstance (const NpArticulationReducedCoordinate* articulation);
156 void updatePvdProperties(const NpArticulationReducedCoordinate* articulation);
157 void releasePvdInstance (const NpArticulationReducedCoordinate* articulation);
158
159 void createPvdInstance (const NpArticulationJointReducedCoordinate* articulationJoint);
160 void updatePvdProperties(const NpArticulationJointReducedCoordinate* articulationJoint);
161 void releasePvdInstance (const NpArticulationJointReducedCoordinate* articulationJoint);
162
163 void createPvdInstance(const NpArticulationSpatialTendon* articulationTendon);
164 void updatePvdProperties(const NpArticulationSpatialTendon* articulationTendon);
165 void releasePvdInstance(const NpArticulationSpatialTendon* articulationTendon);
166
167 void createPvdInstance(const NpArticulationFixedTendon* articulationTendon);
168 void updatePvdProperties(const NpArticulationFixedTendon* articulationTendon);
169 void releasePvdInstance(const NpArticulationFixedTendon* articulationTendon);
170
171 void createPvdInstance(const NpArticulationSensor* sensor);
172 void updatePvdProperties(const NpArticulationSensor* sensor);
173 void releasePvdInstance(const NpArticulationSensor* sensor);
174
176
177 void createPvdInstance (const PxsMaterialCore* materialCore);
178 void updatePvdProperties(const PxsMaterialCore* materialCore);
179 void releasePvdInstance (const PxsMaterialCore* materialCore);
180
181 void createPvdInstance (const PxsFEMSoftBodyMaterialCore* materialCore);
182 void updatePvdProperties(const PxsFEMSoftBodyMaterialCore* materialCore);
183 void releasePvdInstance (const PxsFEMSoftBodyMaterialCore* materialCore);
184
185 void createPvdInstance (const PxsFEMClothMaterialCore* materialCore);
186 void updatePvdProperties(const PxsFEMClothMaterialCore* materialCore);
187 void releasePvdInstance (const PxsFEMClothMaterialCore* materialCore);
188
189 void createPvdInstance (const PxsPBDMaterialCore* materialCore);
190 void updatePvdProperties(const PxsPBDMaterialCore* materialCore);
191 void releasePvdInstance (const PxsPBDMaterialCore* materialCore);
192
193 void createPvdInstance (const PxsFLIPMaterialCore* materialCore);
194 void updatePvdProperties(const PxsFLIPMaterialCore* materialCore);
195 void releasePvdInstance (const PxsFLIPMaterialCore* materialCore);
196
197 void createPvdInstance (const PxsMPMMaterialCore* materialCore);
198 void updatePvdProperties(const PxsMPMMaterialCore* materialCore);
199 void releasePvdInstance (const PxsMPMMaterialCore* materialCore);
200
201 void createPvdInstance (const PxsCustomMaterialCore* materialCore);
202 void updatePvdProperties(const PxsCustomMaterialCore* materialCore);
203 void releasePvdInstance (const PxsCustomMaterialCore* materialCore);
204
206
207 void createPvdInstance (const NpShape* shape, PxActor& owner);
208 void updateMaterials (const NpShape* shape);
209 void updatePvdProperties (const NpShape* shape);
210 void releaseAndRecreateGeometry (const NpShape* shape);
211 void releasePvdInstance (const NpShape* shape, PxActor& owner);
212 void addBodyAndShapesToPvd (NpRigidDynamic& b);
213 void addStaticAndShapesToPvd (NpRigidStatic& s);
214
215 void createPvdInstance (const NpAggregate* aggregate);
216 void updatePvdProperties (const NpAggregate* aggregate);
217 void attachAggregateActor (const NpAggregate* aggregate, NpActor* actor);
218 void detachAggregateActor (const NpAggregate* aggregate, NpActor* actor);
219 void releasePvdInstance (const NpAggregate* aggregate);
220
221#if PX_SUPPORT_GPU_PHYSX
222 void createPvdInstance(const NpSoftBody* softBody);
223 void updatePvdProperties(const NpSoftBody* softBody);
224 void attachAggregateActor(const NpSoftBody* softBody, NpActor* actor);
225 void detachAggregateActor(const NpSoftBody* softBody, NpActor* actor);
226 void releasePvdInstance(const NpSoftBody* softBody);
227
228 void createPvdInstance(const NpFEMCloth* femCloth);
229 void updatePvdProperties(const NpFEMCloth* femCloth);
230 void attachAggregateActor(const NpFEMCloth* femCloth, NpActor* actor);
231 void detachAggregateActor(const NpFEMCloth* femCloth, NpActor* actor);
232 void releasePvdInstance(const NpFEMCloth* femCloth);
233
234 void createPvdInstance(const NpPBDParticleSystem* particleSystem);
235 void updatePvdProperties(const NpPBDParticleSystem* particleSystem);
236 void attachAggregateActor(const NpPBDParticleSystem* particleSystem, NpActor* actor);
237 void detachAggregateActor(const NpPBDParticleSystem* particleSystem, NpActor* actor);
238 void releasePvdInstance(const NpPBDParticleSystem* particleSystem);
239
240 void createPvdInstance(const NpFLIPParticleSystem* particleSystem);
241 void updatePvdProperties(const NpFLIPParticleSystem* particleSystem);
242 void attachAggregateActor(const NpFLIPParticleSystem* particleSystem, NpActor* actor);
243 void detachAggregateActor(const NpFLIPParticleSystem* particleSystem, NpActor* actor);
244 void releasePvdInstance(const NpFLIPParticleSystem* particleSystem);
245
246 void createPvdInstance(const NpMPMParticleSystem* particleSystem);
247 void updatePvdProperties(const NpMPMParticleSystem* particleSystem);
248 void attachAggregateActor(const NpMPMParticleSystem* particleSystem, NpActor* actor);
249 void detachAggregateActor(const NpMPMParticleSystem* particleSystem, NpActor* actor);
250 void releasePvdInstance(const NpMPMParticleSystem* particleSystem);
251
252 void createPvdInstance(const NpCustomParticleSystem* particleSystem);
253 void updatePvdProperties(const NpCustomParticleSystem* particleSystem);
254 void attachAggregateActor(const NpCustomParticleSystem* particleSystem, NpActor* actor);
255 void detachAggregateActor(const NpCustomParticleSystem* particleSystem, NpActor* actor);
256 void releasePvdInstance(const NpCustomParticleSystem* particleSystem);
257
258 void createPvdInstance(const NpHairSystem* hairSystem);
259 void updatePvdProperties(const NpHairSystem* hairSystem);
260 void attachAggregateActor(const NpHairSystem* hairSystem, NpActor* actor);
261 void detachAggregateActor(const NpHairSystem* hairSystem, NpActor* actor);
262 void releasePvdInstance(const NpHairSystem* hairSystem);
263#endif
264
265 void originShift(PxVec3 shift);
266 void updateJoints();
267 void updateContacts();
268 void updateSceneQueries();
269
270 // PvdVisualizer
271 void visualize(PxArticulationLink& link);
272 void visualize(const PxRenderBuffer& debugRenderable);
273
274 private:
275
276 void sendEntireScene();
277 void updateConstraint(const Sc::ConstraintCore& scConstraint, PxU32 updateType);
278
279 PxPvdSceneFlags mFlags;
280 PsPvd* mPvd;
281 NpScene& mScene;
282
283 PvdDataStream* mPvdDataStream;
284 PvdMetaDataBinding mMetaDataBinding;
285 PvdUserRenderer* mUserRender;
286 RendererEventClient* mRenderClient;
287 bool mIsConnected;
288};
289
290} // pvd
291
292} // physx
293#endif // PX_SUPPORT_PVD
294
295#endif // NP_SCENE_PVD_CLIENT_H
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PxFlags< PxPvdSceneFlag::Enum, PxU8 > PxPvdSceneFlags
Bitfield that contains a set of raised flags defined in PxPvdSceneFlag.
Definition PxPvdSceneClient.h:77