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
|
// 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) 2008-2016 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_FOUNDATION_PSRENDEROUTPUT_H
#define PX_FOUNDATION_PSRENDEROUTPUT_H
#include "foundation/PxMat44.h"
#include "CmRenderBuffer.h"
namespace physx
{
namespace Cm
{
struct DebugText;
#if PX_VC
#pragma warning(push)
#pragma warning( disable : 4251 ) // class needs to have dll-interface to be used by clients of class
#endif
/**
Output stream to fill RenderBuffer
*/
class PX_PHYSX_COMMON_API RenderOutput
{
public:
enum Primitive {
POINTS,
LINES,
LINESTRIP,
TRIANGLES,
TRIANGLESTRIP,
TEXT
};
RenderOutput(RenderBuffer& buffer)
: mPrim(POINTS), mColor(0), mVertex0(0.0f), mVertex1(0.0f)
, mVertexCount(0), mTransform(PxMat44(PxIdentity)), mBuffer(buffer)
{}
RenderOutput& operator<<(Primitive prim);
RenderOutput& operator<<(PxU32 color); // 0xbbggrr
RenderOutput& operator<<(const PxMat44& transform);
RenderOutput& operator<<(const PxTransform&);
RenderOutput& operator<<(PxVec3 vertex);
RenderOutput& operator<<(const DebugText& text);
PX_FORCE_INLINE PxDebugLine* reserveSegments(PxU32 nbSegments)
{
const PxU32 currentSize = mBuffer.mLines.size();
mBuffer.mLines.resizeUninitialized(currentSize + nbSegments);
return mBuffer.mLines.begin() + currentSize;
}
// PT: using the operators is just too slow.
PX_FORCE_INLINE void outputSegment(const PxVec3& v0, const PxVec3& v1)
{
// PT: TODO: replace pushBack with something faster like the versions below
mBuffer.mLines.pushBack(PxDebugLine(v0, v1, mColor));
// PT: TODO: use the "pushBackUnsafe" version or replace with ICE containers
/* PxDebugLine& l = mBuffer.mLines.insert();
l.pos0 = v0;
l.pos1 = v1;
l.color0 = l.color1 = mColor;
PxDebugLine& l = mBuffer.mLines.pushBackUnsafe();
l.pos0 = v0;
l.pos1 = v1;
l.color0 = l.color1 = mColor;*/
}
RenderOutput& outputCapsule(PxF32 radius, PxF32 halfHeight, const PxMat44& absPose);
private:
RenderOutput& operator=(const RenderOutput&);
Primitive mPrim;
PxU32 mColor;
PxVec3 mVertex0, mVertex1;
PxU32 mVertexCount;
PxMat44 mTransform;
RenderBuffer& mBuffer;
};
/** debug render helper types */
struct PX_PHYSX_COMMON_API DebugText
{
DebugText(const PxVec3& position, PxReal size, const char* string, ...);
static const int sBufferSize = 1008; // sizeof(DebugText)==1kB
char buffer[sBufferSize];
PxVec3 position;
PxReal size;
};
struct DebugBox
{
explicit DebugBox(const PxVec3& extents, bool wireframe_ = true)
: minimum(-extents), maximum(extents), wireframe(wireframe_) {}
explicit DebugBox(const PxVec3& pos, const PxVec3& extents, bool wireframe_ = true)
: minimum(pos-extents), maximum(pos+extents), wireframe(wireframe_) {}
explicit DebugBox(const PxBounds3& bounds, bool wireframe_ = true)
: minimum(bounds.minimum), maximum(bounds.maximum), wireframe(wireframe_) {}
PxVec3 minimum, maximum;
bool wireframe;
};
PX_PHYSX_COMMON_API RenderOutput& operator<<(RenderOutput& out, const DebugBox& box);
struct DebugArrow
{
DebugArrow(const PxVec3& pos, const PxVec3& vec)
: base(pos), tip(pos+vec), headLength(vec.magnitude()*0.15f) {}
DebugArrow(const PxVec3& pos, const PxVec3& vec, PxReal headLength_)
: base(pos), tip(pos+vec), headLength(headLength_) {}
PxVec3 base, tip;
PxReal headLength;
};
PX_PHYSX_COMMON_API RenderOutput& operator<<(RenderOutput& out, const DebugArrow& arrow);
struct DebugBasis
{
DebugBasis(const PxVec3& ext, PxU32 cX = PxDebugColor::eARGB_RED,
PxU32 cY = PxDebugColor::eARGB_GREEN, PxU32 cZ = PxDebugColor::eARGB_BLUE)
: extends(ext), colorX(cX), colorY(cY), colorZ(cZ) {}
PxVec3 extends;
PxU32 colorX, colorY, colorZ;
};
PX_PHYSX_COMMON_API RenderOutput& operator<<(RenderOutput& out, const DebugBasis& basis);
#if PX_VC
#pragma warning(pop)
#endif
struct DebugCircle
{
DebugCircle(PxU32 s, PxReal r)
: nSegments(s), radius(r) {}
PxU32 nSegments;
PxReal radius;
};
PX_PHYSX_COMMON_API RenderOutput& operator<<(RenderOutput& out, const DebugCircle& circle);
struct DebugArc
{
DebugArc(PxU32 s, PxReal r, PxReal minAng, PxReal maxAng)
: nSegments(s), radius(r), minAngle(minAng), maxAngle(maxAng) {}
PxU32 nSegments;
PxReal radius;
PxReal minAngle, maxAngle;
};
PX_PHYSX_COMMON_API RenderOutput& operator<<(RenderOutput& out, const DebugArc& arc);
} // namespace Cm
}
#endif
|