RavEngine
Loading...
Searching...
No Matches
ExtPvd.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 EXT_PVD_H
30#define EXT_PVD_H
31
32#if PX_SUPPORT_PVD
33
34#include "extensions/PxJoint.h"
35
36#include "foundation/PxUserAllocated.h"
37#include "PxPvdDataStream.h"
38#include "PvdTypeNames.h"
39#include "PxPvdObjectModelBaseTypes.h"
40
41#if PX_LINUX && PX_CLANG
42#pragma clang diagnostic push
43#pragma clang diagnostic ignored "-Wreserved-identifier"
44#endif
45#include "PxExtensionMetaDataObjects.h"
46#if PX_LINUX && PX_CLANG
47#pragma clang diagnostic pop
48#endif
49
50namespace physx
51{
52
53class PxJoint;
54class PxD6Joint;
55class PxDistanceJoint;
56class PxFixedJoint;
57class PxPrismaticJoint;
58class PxRevoluteJoint;
59class PxSphericalJoint;
60class PxContactJoint;
61class PxGearJoint;
62class PxRackAndPinionJoint;
63}
64
65#define JOINT_GROUP 3
66namespace physx
67{
68namespace pvdsdk {
69 #define DEFINE_NATIVE_PVD_PHYSX3_TYPE_MAP( type ) DEFINE_PVD_TYPE_NAME_MAP( physx::type, "physx3", #type )
70
71 DEFINE_NATIVE_PVD_PHYSX3_TYPE_MAP(PxJoint)
72 DEFINE_NATIVE_PVD_PHYSX3_TYPE_MAP(PxJointGeneratedValues)
73 DEFINE_NATIVE_PVD_PHYSX3_TYPE_MAP(PxFixedJoint)
74 DEFINE_NATIVE_PVD_PHYSX3_TYPE_MAP(PxFixedJointGeneratedValues)
75 DEFINE_NATIVE_PVD_PHYSX3_TYPE_MAP(PxDistanceJoint)
76 DEFINE_NATIVE_PVD_PHYSX3_TYPE_MAP(PxDistanceJointGeneratedValues)
77 DEFINE_NATIVE_PVD_PHYSX3_TYPE_MAP(PxContactJoint)
78 DEFINE_NATIVE_PVD_PHYSX3_TYPE_MAP(PxContactJointGeneratedValues)
79 DEFINE_NATIVE_PVD_PHYSX3_TYPE_MAP(PxPrismaticJoint)
80 DEFINE_NATIVE_PVD_PHYSX3_TYPE_MAP(PxPrismaticJointGeneratedValues)
81 DEFINE_NATIVE_PVD_PHYSX3_TYPE_MAP(PxRevoluteJoint)
82 DEFINE_NATIVE_PVD_PHYSX3_TYPE_MAP(PxRevoluteJointGeneratedValues)
83 DEFINE_NATIVE_PVD_PHYSX3_TYPE_MAP(PxSphericalJoint)
84 DEFINE_NATIVE_PVD_PHYSX3_TYPE_MAP(PxSphericalJointGeneratedValues)
85 DEFINE_NATIVE_PVD_PHYSX3_TYPE_MAP(PxD6Joint)
86 DEFINE_NATIVE_PVD_PHYSX3_TYPE_MAP(PxD6JointGeneratedValues)
87 DEFINE_NATIVE_PVD_PHYSX3_TYPE_MAP(PxGearJoint)
88 DEFINE_NATIVE_PVD_PHYSX3_TYPE_MAP(PxGearJointGeneratedValues)
89 DEFINE_NATIVE_PVD_PHYSX3_TYPE_MAP(PxRackAndPinionJoint)
90 DEFINE_NATIVE_PVD_PHYSX3_TYPE_MAP(PxRackAndPinionJointGeneratedValues)
91#undef DEFINE_NATIVE_PVD_PHYSX3_TYPE_MAP
92} //pvdsdk
93} // physx
94
95namespace physx
96{
97namespace Ext
98{
99 using namespace physx::pvdsdk;
100
101 class Pvd: public physx::PxUserAllocated
102 {
103 Pvd& operator=(const Pvd&);
104 public:
105 class PvdNameSpace
106 {
107
108 public:
109 PvdNameSpace(PvdDataStream& conn, const char* name);
110 ~PvdNameSpace();
111 private:
112 PvdNameSpace& operator=(const PvdNameSpace&);
113 PvdDataStream& mConnection;
114 };
115
116 static void setActors( PvdDataStream& PvdDataStream,
117 const PxJoint& inJoint, const PxConstraint& c, const PxActor* newActor0, const PxActor* newActor1 );
118
119 template<typename TObjType>
120 static void createInstance( PvdDataStream& inStream, const PxConstraint& c, const TObjType& inSource )
121 {
122 inStream.createInstance( &inSource );
123 inStream.pushBackObjectRef( c.getScene(), "Joints", &inSource );
124
125 class ConstraintUpdateCmd : public PvdDataStream::PvdCommand
126 {
127 ConstraintUpdateCmd &operator=(const ConstraintUpdateCmd&) { PX_ASSERT(0); return *this; } //PX_NOCOPY doesn't work for local classes
128 public:
129
130 const PxConstraint& mConstraint;
131 const PxJoint& mJoint;
132
133 PxRigidActor* actor0, *actor1;
134 ConstraintUpdateCmd(const PxConstraint& constraint, const PxJoint& joint):PvdDataStream::PvdCommand(), mConstraint(constraint), mJoint(joint)
135 {
136 mConstraint.getActors( actor0, actor1 );
137 }
138
139 //Assigned is needed for copying
140 ConstraintUpdateCmd(const ConstraintUpdateCmd& cmd)
141 :PvdDataStream::PvdCommand(), mConstraint(cmd.mConstraint), mJoint(cmd.mJoint)
142 {
143 }
144
145 virtual bool canRun(PvdInstanceDataStream &inStream_ )
146 {
147 PX_ASSERT(inStream_.isInstanceValid(&mJoint));
148 //When run this command, the constraint maybe buffer removed
149 return ((actor0 == NULL) || inStream_.isInstanceValid(actor0))
150 && ((actor1 == NULL) || inStream_.isInstanceValid(actor1));
151 }
152 virtual void run( PvdInstanceDataStream &inStream_ )
153 {
154 //When run this command, the constraint maybe buffer removed
155 if(!inStream_.isInstanceValid(&mJoint))
156 return;
157
158 PxRigidActor* actor0_, *actor1_;
159 mConstraint.getActors( actor0_, actor1_ );
160
161 if ( actor0_ && (inStream_.isInstanceValid(actor0_)) )
162 inStream_.pushBackObjectRef( actor0_, "Joints", &mJoint );
163 if ( actor1_ && (inStream_.isInstanceValid(actor1_)) )
164 inStream_.pushBackObjectRef( actor1_, "Joints", &mJoint );
165 const void* parent = actor0_ ? actor0_ : actor1_;
166 inStream_.setPropertyValue( &mJoint, "Parent", parent );
167 }
168 };
169
170 ConstraintUpdateCmd* cmd = PX_PLACEMENT_NEW(inStream.allocateMemForCmd(sizeof(ConstraintUpdateCmd)),
171 ConstraintUpdateCmd)(c, inSource);
172
173 if(cmd->canRun( inStream ))
174 cmd->run( inStream );
175 else
176 inStream.pushPvdCommand( *cmd );
177 }
178
179 template<typename jointtype, typename structValue>
180 static void updatePvdProperties(PvdDataStream& pvdConnection, const jointtype& joint)
181 {
182 structValue theValueStruct( &joint );
183 pvdConnection.setPropertyMessage( &joint, theValueStruct );
184 }
185
186 template<typename jointtype>
187 static void simUpdate(PvdDataStream& /*pvdConnection*/, const jointtype& /*joint*/) {}
188
189 template<typename jointtype>
190 static void createPvdInstance(PvdDataStream& pvdConnection, const PxConstraint& c, const jointtype& joint)
191 {
192 createInstance<jointtype>( pvdConnection, c, joint );
193 }
194
195 static void releasePvdInstance(PvdDataStream& pvdConnection, const PxConstraint& c, const PxJoint& joint);
196 static void sendClassDescriptions(PvdDataStream& pvdConnection);
197 };
198} // ext
199
200} // physx
201
202#endif // PX_SUPPORT_PVD
203#endif // EXT_PVD_H
PxActor is the base class for the main simulation objects in the physics SDK.
Definition PxActor.h:201
A plugin class for implementing constraints.
Definition PxConstraint.h:100
virtual void getActors(PxRigidActor *&actor0, PxRigidActor *&actor1) const =0
Retrieves the actors for this constraint.
a base interface providing common functionality for PhysX joints
Definition PxJoint.h:105
PxRigidActor represents a base class shared between dynamic and static rigid bodies in the physics SD...
Definition PxRigidActor.h:53
Definition PxUserAllocated.h:43
Definition PxPvdDataStream.h:241
Definition PxPvdDataStream.h:203
Definition PxPvdDataStream.h:98
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Definition PxExtensionAutoGeneratedMetaDataObjects.h:493
Definition PxExtensionAutoGeneratedMetaDataObjects.h:293
Definition PxExtensionAutoGeneratedMetaDataObjects.h:409
Definition PxExtensionAutoGeneratedMetaDataObjects.h:565
Definition PxExtensionAutoGeneratedMetaDataObjects.h:207
Definition PxExtensionAutoGeneratedMetaDataObjects.h:47
Definition PxExtensionAutoGeneratedMetaDataObjects.h:631
Definition PxExtensionAutoGeneratedMetaDataObjects.h:151
Definition PxExtensionAutoGeneratedMetaDataObjects.h:715
Definition PxExtensionAutoGeneratedMetaDataObjects.h:809