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
|
/*
* Copyright (c) 2008-2017, NVIDIA CORPORATION. All rights reserved.
*
* NVIDIA CORPORATION and its licensors retain all intellectual property
* and proprietary rights in and to this software, 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.
*/
#ifndef __APEX_STREAM_H__
#define __APEX_STREAM_H__
#include "ApexDefs.h"
#include "PxPlane.h"
namespace nvidia
{
namespace apex
{
// Public, useful operators for serializing nonversioned data follow.
PX_INLINE physx::PxFileBuf& operator >> (physx::PxFileBuf& stream, bool& b)
{
b = (0 != stream.readByte());
return stream;
}
PX_INLINE physx::PxFileBuf& operator >> (physx::PxFileBuf& stream, int8_t& b)
{
b = (int8_t)stream.readByte();
return stream;
}
PX_INLINE physx::PxFileBuf& operator >> (physx::PxFileBuf& stream, int16_t& w)
{
w = (int16_t)stream.readWord();
return stream;
}
PX_INLINE physx::PxFileBuf& operator >> (physx::PxFileBuf& stream, int32_t& d)
{
d = (int32_t)stream.readDword();
return stream;
}
PX_INLINE physx::PxFileBuf& operator >> (physx::PxFileBuf& stream, uint8_t& b)
{
b = stream.readByte();
return stream;
}
PX_INLINE physx::PxFileBuf& operator >> (physx::PxFileBuf& stream, uint16_t& w)
{
w = stream.readWord();
return stream;
}
PX_INLINE physx::PxFileBuf& operator >> (physx::PxFileBuf& stream, uint32_t& d)
{
d = stream.readDword();
return stream;
}
PX_INLINE physx::PxFileBuf& operator >> (physx::PxFileBuf& stream, float& f)
{
f = stream.readFloat();
return stream;
}
PX_INLINE physx::PxFileBuf& operator >> (physx::PxFileBuf& stream, double& f)
{
f = stream.readDouble();
return stream;
}
PX_INLINE physx::PxFileBuf& operator >> (physx::PxFileBuf& stream, physx::PxVec2& v)
{
stream >> v.x >> v.y;
return stream;
}
PX_INLINE physx::PxFileBuf& operator >> (physx::PxFileBuf& stream, physx::PxVec3& v)
{
stream >> v.x >> v.y >> v.z;
return stream;
}
PX_INLINE physx::PxFileBuf& operator >> (physx::PxFileBuf& stream, physx::PxVec4& v)
{
stream >> v.x >> v.y >> v.z >> v.w;
return stream;
}
PX_INLINE physx::PxFileBuf& operator >> (physx::PxFileBuf& stream, physx::PxBounds3& b)
{
stream >> b.minimum >> b.maximum;
return stream;
}
PX_INLINE physx::PxFileBuf& operator >> (physx::PxFileBuf& stream, physx::PxQuat& q)
{
stream >> q.x >> q.y >> q.z >> q.w;
return stream;
}
PX_INLINE physx::PxFileBuf& operator >> (physx::PxFileBuf& stream, physx::PxPlane& p)
{
stream >> p.n.x >> p.n.y >> p.n.z >> p.d;
return stream;
}
PX_INLINE physx::PxFileBuf& operator >> (physx::PxFileBuf& stream, physx::PxMat44& m)
{
stream >> m.column0 >> m.column1 >> m.column2 >> m.column3;
return stream;
}
// The opposite of the above operators--takes data and writes it to a stream.
PX_INLINE physx::PxFileBuf& operator << (physx::PxFileBuf& stream, const bool b)
{
stream.storeByte(b ? (uint8_t)1 : (uint8_t)0);
return stream;
}
PX_INLINE physx::PxFileBuf& operator << (physx::PxFileBuf& stream, const int8_t b)
{
stream.storeByte((uint8_t)b);
return stream;
}
PX_INLINE physx::PxFileBuf& operator << (physx::PxFileBuf& stream, const int16_t w)
{
stream.storeWord((uint16_t)w);
return stream;
}
PX_INLINE physx::PxFileBuf& operator << (physx::PxFileBuf& stream, const int32_t d)
{
stream.storeDword((uint32_t)d);
return stream;
}
PX_INLINE physx::PxFileBuf& operator << (physx::PxFileBuf& stream, const uint8_t b)
{
stream.storeByte(b);
return stream;
}
PX_INLINE physx::PxFileBuf& operator << (physx::PxFileBuf& stream, const uint16_t w)
{
stream.storeWord(w);
return stream;
}
PX_INLINE physx::PxFileBuf& operator << (physx::PxFileBuf& stream, const uint32_t d)
{
stream.storeDword(d);
return stream;
}
PX_INLINE physx::PxFileBuf& operator << (physx::PxFileBuf& stream, const float f)
{
stream.storeFloat(f);
return stream;
}
PX_INLINE physx::PxFileBuf& operator << (physx::PxFileBuf& stream, const double f)
{
stream.storeDouble(f);
return stream;
}
PX_INLINE physx::PxFileBuf& operator << (physx::PxFileBuf& stream, const physx::PxVec2& v)
{
stream << v.x << v.y;
return stream;
}
PX_INLINE physx::PxFileBuf& operator << (physx::PxFileBuf& stream, const physx::PxVec3& v)
{
stream << v.x << v.y << v.z;
return stream;
}
PX_INLINE physx::PxFileBuf& operator << (physx::PxFileBuf& stream, const physx::PxVec4& v)
{
stream << v.x << v.y << v.z << v.w;
return stream;
}
PX_INLINE physx::PxFileBuf& operator << (physx::PxFileBuf& stream, const physx::PxBounds3& b)
{
stream << b.minimum << b.maximum;
return stream;
}
PX_INLINE physx::PxFileBuf& operator << (physx::PxFileBuf& stream, const physx::PxQuat& q)
{
stream << q.x << q.y << q.z << q.w;
return stream;
}
PX_INLINE physx::PxFileBuf& operator << (physx::PxFileBuf& stream, const physx::PxPlane& p)
{
stream << p.n.x << p.n.y << p.n.z << p.d;
return stream;
}
PX_INLINE physx::PxFileBuf& operator << (physx::PxFileBuf& stream, const physx::PxMat44& m)
{
stream << m.column0 << m.column1 << m.column2 << m.column3;
return stream;
}
}
} // end namespace apex
#endif // __APEX_STREAM_H__
|