1/*
2 * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
3 *
4 * NVIDIA CORPORATION and its licensors retain all intellectual property
5 * and proprietary rights in and to this software, related documentation
6 * and any modifications thereto. Any use, reproduction, disclosure or
7 * distribution of this software and related documentation without an express
8 * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 */
10// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
11// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
12
13
14#ifndef PX_PHYSICS_EXTENSIONS_VISUAL_DEBUGGER_H
15#define PX_PHYSICS_EXTENSIONS_VISUAL_DEBUGGER_H
16/** \addtogroup extensions
17 @{
18*/
19#include "pvd/PxVisualDebugger.h"
20#include "foundation/Px.h"
21#include "PxPhysXConfig.h"
22#include "foundation/PxFlags.h"
23#include "physxvisualdebuggersdk/PvdConnectionManager.h"
24#include "physxvisualdebuggersdk/PvdConnection.h"
25
26
27#ifndef PX_DOXYGEN
28namespace physx { namespace debugger { namespace comm {
29#endif
30 class PvdConnectionManager;
31 class PvdConnection;
32#ifndef PX_DOXYGEN
33}}}
34#endif
35
36#ifndef PX_DOXYGEN
37namespace physx
38{
39#endif
40
41/**
42 This class has a direct mapping to the PVD::TConnectionType datatype. It is redefined here
43 because not all classes including this header have the PVDSDK in their include path.
44
45*/
46struct PxVisualDebuggerConnectionFlag
47{
48 enum Enum
49 {
50 /**
51 \brief Send debugging information to PVD.
52
53 This information is the actual object data
54 of the rigid statics, shapes, articulations, etc. Sending this information has
55 a noticeable impact on performance and thus this flag should not be set
56 if you want an accurate performance profile.
57 */
58 eDEBUG = 1 << 0,
59 /**
60 \brief Send profile information to PVD.
61
62 This information populates PVD's profile view. It has (at this time) negligible cost
63 compared to Debug information and makes PVD *much* more useful so it is quite
64 highly recommended.
65
66 This flag works together with a PxCreatePhysics parameter,
67 profileZoneManager. Using both of them together allows SDK to send profile
68 events to PVD.
69 */
70 ePROFILE = 1 << 1,
71 /**
72 \brief Send memory information to PVD.
73
74 The PVD sdk side hooks into the Foundation memory controller and listens to
75 allocation/deallocation events. This has a noticable hit on the first frame,
76 however, this data is somewhat compressed and the PhysX SDK doesn't allocate much
77 once it hits a steady state. This information also has a fairly negligible
78 impact and thus is also highly recommended.
79
80 This flag works together with a PxCreatePhysics parameter,
81 trackOutstandingAllocations. Using both of them together allows users to have
82 an accurate view of the overall memory usage of the simulation at the cost of
83 a hashtable lookup per allocation/deallocation. Again, PhysX makes a best effort
84 attempt not to allocate or deallocate during simulation so this hashtable lookup
85 tends to have no effect past the first frame.
86
87 Sending memory information without tracking outstanding allocations means that
88 PVD will accurate information about the state of the memory system before the
89 actual connection happened.
90 */
91 eMEMORY = 1 << 2
92 };
93};
94
95typedef physx::PxFlags<PxVisualDebuggerConnectionFlag::Enum, PxU32> PxVisualDebuggerConnectionFlags;
96PX_FLAGS_OPERATORS( PxVisualDebuggerConnectionFlag::Enum, PxU32 )
97
98/**
99class that contains all the data relevant for updating and visualizing extensions like joints in PVD
100*/
101class PxVisualDebuggerExt
102{
103public:
104
105 /**
106 Connect to pvd using a network socket. This blocks for at most inTimeoutInMilliseconds
107 before returning a new connection (or nothing). PVD needs to be started before this call
108 is made.
109
110 \note Since this call increment the reference count of PvdConnection,
111 please call PvdConnection::release() after this funtion is called.
112
113 \param inMgr The manager to use to host the connection.
114 \param inHost Host in x.x.x.x network notation
115 \param inPort Port to connect to. The default is 5425.
116 \param inTimeoutInMilliseconds How long to block waiting for a new connection
117 \param inConnectionType The type information you want sent over the connection.
118 */
119 static PxVisualDebuggerConnection* createConnection( PxVisualDebuggerConnectionManager* inMgr
120 , const char* inHost
121 , int inPort //defaults to 5425
122 , unsigned int inTimeoutInMilliseconds
123 , PxVisualDebuggerConnectionFlags inConnectionType = getDefaultConnectionFlags() );
124
125
126 /**
127 Connect to pvd, writing out the connection data to a file stream. You can then parse this data later
128 with PVDUI.
129
130 \note Since this call increment the reference count of PvdConnection,
131 please call PvdConnection::release() after this funtion is called.
132
133 \param inMgr The manager to use to host the connection.
134 \param filename The filename to write connection data.
135 \param inConnectionType The type information you want sent over the connection.
136 */
137 static PxVisualDebuggerConnection* createConnection( PxVisualDebuggerConnectionManager* inMgr
138 , const char* filename
139 , PxVisualDebuggerConnectionFlags inConnectionType = getDefaultConnectionFlags() );
140
141
142 /** get the default connection flags
143
144 \return the default connection flags: debug data and profiling
145 */
146
147 static PX_FORCE_INLINE PxVisualDebuggerConnectionFlags getDefaultConnectionFlags() { return PxVisualDebuggerConnectionFlags( PxVisualDebuggerConnectionFlag::eDEBUG | PxVisualDebuggerConnectionFlag::ePROFILE); }
148
149 /** get all connection flags
150
151 \return all visual debugger connection flags: debug data, profiling and memory
152 */
153 static PX_FORCE_INLINE PxVisualDebuggerConnectionFlags getAllConnectionFlags() { return PxVisualDebuggerConnectionFlags( PxVisualDebuggerConnectionFlag::eDEBUG | PxVisualDebuggerConnectionFlag::ePROFILE| PxVisualDebuggerConnectionFlag::eMEMORY ); }
154
155};
156
157#ifndef PX_DOXYGEN
158} // namespace physx
159#endif
160
161/** @} */
162#endif // PX_PHYSICS_EXTENSIONS_VISUAL_DEBUGGER_H
163