RavEngine
Loading...
Searching...
No Matches
PxPvdUserRenderImpl.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
27#ifndef PX_PVD_USER_RENDER_IMPL_H
28#define PX_PVD_USER_RENDER_IMPL_H
29
30#include "PxPvdUserRenderer.h"
31
32namespace physx
33{
34namespace pvdsdk
35{
36
38{
39 enum Enum
40 {
41 Unknown = 0,
42#define DECLARE_PVD_IMMEDIATE_RENDER_TYPE(type) type,
43#define DECLARE_PVD_IMMEDIATE_RENDER_TYPE_NO_COMMA(type) type
44#include "PxPvdUserRenderTypes.h"
45#undef DECLARE_PVD_IMMEDIATE_RENDER_TYPE_NO_COMMA
46#undef DECLARE_PVD_IMMEDIATE_RENDER_TYPE
47 };
48};
49
51{
52 protected:
53 virtual ~RenderSerializer()
54 {
55 }
56
57 public:
58 virtual void streamify(uint64_t& val) = 0;
59 virtual void streamify(float& val) = 0;
60 virtual void streamify(uint32_t& val) = 0;
61 virtual void streamify(uint8_t& val) = 0;
62 virtual void streamify(DataRef<uint8_t>& val) = 0;
63 virtual void streamify(DataRef<PxDebugPoint>& val) = 0;
64 virtual void streamify(DataRef<PxDebugLine>& val) = 0;
65 virtual void streamify(DataRef<PxDebugTriangle>& val) = 0;
66 virtual void streamify(PxDebugText& val) = 0;
67 virtual bool isGood() = 0;
68 virtual uint32_t hasData() = 0;
69
70 void streamify(PvdUserRenderTypes::Enum& val)
71 {
72 uint8_t data = static_cast<uint8_t>(val);
73 streamify(data);
74 val = static_cast<PvdUserRenderTypes::Enum>(data);
75 }
76 void streamify(PxVec3& val)
77 {
78 streamify(val[0]);
79 streamify(val[1]);
80 streamify(val[2]);
81 }
82
83 void streamify(PvdColor& val)
84 {
85 streamify(val.r);
86 streamify(val.g);
87 streamify(val.b);
88 streamify(val.a);
89 }
90 void streamify(PxTransform& val)
91 {
92 streamify(val.q.x);
93 streamify(val.q.y);
94 streamify(val.q.z);
95 streamify(val.q.w);
96 streamify(val.p.x);
97 streamify(val.p.y);
98 streamify(val.p.z);
99 }
100 void streamify(bool& val)
101 {
102 uint8_t tempVal = uint8_t(val ? 1 : 0);
103 streamify(tempVal);
104 val = tempVal ? true : false;
105 }
106};
107
108template <typename TBulkRenderType>
110{
112 BulkRenderEvent(const TBulkRenderType* data, uint32_t count) : mData(data, count)
113 {
114 }
116 {
117 }
118 void serialize(RenderSerializer& serializer)
119 {
120 serializer.streamify(mData);
121 }
122};
124{
125 uint64_t mInstanceId;
126 SetInstanceIdRenderEvent(uint64_t iid) : mInstanceId(iid)
127 {
128 }
130 {
131 }
132 void serialize(RenderSerializer& serializer)
133 {
134 serializer.streamify(mInstanceId);
135 }
136};
137struct PointsRenderEvent : BulkRenderEvent<PxDebugPoint>
138{
139 PointsRenderEvent(const PxDebugPoint* data, uint32_t count) : BulkRenderEvent<PxDebugPoint>(data, count)
140 {
141 }
143 {
144 }
145};
147{
148 LinesRenderEvent(const PxDebugLine* data, uint32_t count) : BulkRenderEvent<PxDebugLine>(data, count)
149 {
150 }
152 {
153 }
154};
155struct TrianglesRenderEvent : BulkRenderEvent<PxDebugTriangle>
156{
157 TrianglesRenderEvent(const PxDebugTriangle* data, uint32_t count) : BulkRenderEvent<PxDebugTriangle>(data, count)
158 {
159 }
161 {
162 }
163};
165{
166 DataRef<PxDebugPoint> mPointData;
167 DataRef<PxDebugLine> mLineData;
168 DataRef<PxDebugTriangle> mTriangleData;
169 DebugRenderEvent(const PxDebugPoint* pointData, uint32_t pointCount, const PxDebugLine* lineData,
170 uint32_t lineCount, const PxDebugTriangle* triangleData, uint32_t triangleCount)
171 : mPointData(pointData, pointCount), mLineData(lineData, lineCount), mTriangleData(triangleData, triangleCount)
172 {
173 }
174
176 {
177 }
178 void serialize(RenderSerializer& serializer)
179 {
180 serializer.streamify(mPointData);
181 serializer.streamify(mLineData);
182 serializer.streamify(mTriangleData);
183 }
184};
185
187{
188 PxDebugText mText;
189 TextRenderEvent(const PxDebugText& text)
190 {
191 mText.color = text.color;
192 mText.position = text.position;
193 mText.size = text.size;
194 mText.string = text.string;
195 }
197 {
198 }
199 void serialize(RenderSerializer& serializer)
200 {
201 serializer.streamify(mText);
202 }
203};
204
206{
207 PxTransform parent;
208 PxTransform child;
209 JointFramesRenderEvent(const PxTransform& p, const PxTransform& c) : parent(p), child(c)
210 {
211 }
213 {
214 }
215 void serialize(RenderSerializer& serializer)
216 {
217 serializer.streamify(parent);
218 serializer.streamify(child);
219 }
220};
222{
223 PxTransform t0;
224 PxTransform t1;
225 float value;
226 bool active;
227 LinearLimitRenderEvent(const PxTransform& _t0, const PxTransform& _t1, float _value, bool _active)
228 : t0(_t0), t1(_t1), value(_value), active(_active)
229 {
230 }
232 {
233 }
234 void serialize(RenderSerializer& serializer)
235 {
236 serializer.streamify(t0);
237 serializer.streamify(t1);
238 serializer.streamify(value);
239 serializer.streamify(active);
240 }
241};
243{
244 PxTransform t0;
245 float lower;
246 float upper;
247 bool active;
248 AngularLimitRenderEvent(const PxTransform& _t0, float _lower, float _upper, bool _active)
249 : t0(_t0), lower(_lower), upper(_upper), active(_active)
250 {
251 }
253 {
254 }
255 void serialize(RenderSerializer& serializer)
256 {
257 serializer.streamify(t0);
258 serializer.streamify(lower);
259 serializer.streamify(upper);
260 serializer.streamify(active);
261 }
262};
264{
265 PxTransform t;
266 float ySwing;
267 float zSwing;
268 bool active;
269 LimitConeRenderEvent(const PxTransform& _t, float _ySwing, float _zSwing, bool _active)
270 : t(_t), ySwing(_ySwing), zSwing(_zSwing), active(_active)
271 {
272 }
274 {
275 }
276 void serialize(RenderSerializer& serializer)
277 {
278 serializer.streamify(t);
279 serializer.streamify(ySwing);
280 serializer.streamify(zSwing);
281 serializer.streamify(active);
282 }
283};
285{
286 PxTransform t;
287 float angle;
288 bool active;
289 DoubleConeRenderEvent(const PxTransform& _t, float _angle, bool _active) : t(_t), angle(_angle), active(_active)
290 {
291 }
293 {
294 }
295 void serialize(RenderSerializer& serializer)
296 {
297 serializer.streamify(t);
298 serializer.streamify(angle);
299 serializer.streamify(active);
300 }
301};
302
303template <typename TDataType>
305{
306 void serialize(RenderSerializer& s, TDataType& d)
307 {
308 d.serialize(s);
309 }
310};
311template <>
312struct RenderSerializerMap<uint8_t>
313{
314 void serialize(RenderSerializer& s, uint8_t& d)
315 {
316 s.streamify(d);
317 }
318};
319
320template <>
322{
323 void serialize(RenderSerializer& s, PxDebugPoint& d)
324 {
325 s.streamify(d.pos);
326 s.streamify(d.color);
327 }
328};
329
330template <>
332{
333 void serialize(RenderSerializer& s, PxDebugLine& d)
334 {
335 s.streamify(d.pos0);
336 s.streamify(d.color0);
337 s.streamify(d.pos1);
338 s.streamify(d.color1);
339 }
340};
341
342template <>
344{
345 void serialize(RenderSerializer& s, PxDebugTriangle& d)
346 {
347 s.streamify(d.pos0);
348 s.streamify(d.color0);
349 s.streamify(d.pos1);
350 s.streamify(d.color1);
351 s.streamify(d.pos2);
352 s.streamify(d.color2);
353 }
354};
355
356template <typename TDataType>
358{
359 bool compile_error;
360};
361
362#define DECLARE_PVD_IMMEDIATE_RENDER_TYPE(type) \
363 template <> \
364 struct PvdTypeToRenderType<type##RenderEvent> \
365 { \
366 enum Enum \
367 { \
368 EnumVal = PvdUserRenderTypes::type \
369 }; \
370 };
371
372#include "PxPvdUserRenderTypes.h"
373#undef DECLARE_PVD_IMMEDIATE_RENDER_TYPE
374
375template <typename TDataType>
376PvdUserRenderTypes::Enum getPvdRenderTypeFromType()
377{
378 return static_cast<PvdUserRenderTypes::Enum>(PvdTypeToRenderType<TDataType>::EnumVal);
379}
380
381}
382}
383
384#endif
385
float x
Definition PxQuat.h:395
class representing a rigid euclidean transform as a quaternion and a vector
Definition PxTransform.h:49
3 Element vector class.
Definition PxVec3.h:50
Definition PxPvdObjectModelBaseTypes.h:345
Definition PxPvdUserRenderImpl.h:51
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Used to store a single line and colour for debug rendering.
Definition PxRenderBuffer.h:85
Used to store a single point and colour for debug rendering.
Definition PxRenderBuffer.h:73
Used to store a text for debug rendering. Doesn't own 'string' array.
Definition PxRenderBuffer.h:115
Used to store a single triangle and colour for debug rendering.
Definition PxRenderBuffer.h:99
Definition PxPvdUserRenderImpl.h:243
Definition PxPvdUserRenderImpl.h:110
Definition PxPvdUserRenderImpl.h:165
Definition PxPvdUserRenderImpl.h:285
Definition PxPvdUserRenderImpl.h:206
Definition PxPvdUserRenderImpl.h:264
Definition PxPvdUserRenderImpl.h:222
Definition PxPvdUserRenderImpl.h:147
Definition PxPvdUserRenderImpl.h:138
Definition PxPvdObjectModelBaseTypes.h:114
Definition PxPvdUserRenderImpl.h:358
Definition PxPvdUserRenderImpl.h:38
Definition PxPvdUserRenderImpl.h:305
Definition PxPvdUserRenderImpl.h:124
Definition PxPvdUserRenderImpl.h:187
Definition PxPvdUserRenderImpl.h:156