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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
|
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "PxVehicleUtilTelemetry.h"
#include "PsFoundation.h"
#include "PsUtilities.h"
#include "stdio.h"
#include "CmPhysXCommon.h"
namespace physx
{
#if PX_DEBUG_VEHICLE_ON
PxVehicleGraphDesc::PxVehicleGraphDesc()
: mPosX(PX_MAX_F32),
mPosY(PX_MAX_F32),
mSizeX(PX_MAX_F32),
mSizeY(PX_MAX_F32),
mBackgroundColor(PxVec3(PX_MAX_F32,PX_MAX_F32,PX_MAX_F32)),
mAlpha(PX_MAX_F32)
{
}
bool PxVehicleGraphDesc::isValid() const
{
PX_CHECK_AND_RETURN_VAL(mPosX != PX_MAX_F32, "PxVehicleGraphDesc.mPosX must be initialised", false);
PX_CHECK_AND_RETURN_VAL(mPosY != PX_MAX_F32, "PxVehicleGraphDesc.mPosY must be initialised", false);
PX_CHECK_AND_RETURN_VAL(mSizeX != PX_MAX_F32, "PxVehicleGraphDesc.mSizeX must be initialised", false);
PX_CHECK_AND_RETURN_VAL(mSizeY != PX_MAX_F32, "PxVehicleGraphDesc.mSizeY must be initialised", false);
PX_CHECK_AND_RETURN_VAL(mBackgroundColor.x != PX_MAX_F32 && mBackgroundColor.y != PX_MAX_F32 && mBackgroundColor.z != PX_MAX_F32, "PxVehicleGraphDesc.mBackgroundColor must be initialised", false);
PX_CHECK_AND_RETURN_VAL(mAlpha != PX_MAX_F32, "PxVehicleGraphDesc.mAlpha must be initialised", false);
return true;
}
PxVehicleGraphChannelDesc::PxVehicleGraphChannelDesc()
: mMinY(PX_MAX_F32),
mMaxY(PX_MAX_F32),
mMidY(PX_MAX_F32),
mColorLow(PxVec3(PX_MAX_F32,PX_MAX_F32,PX_MAX_F32)),
mColorHigh(PxVec3(PX_MAX_F32,PX_MAX_F32,PX_MAX_F32)),
mTitle(NULL)
{
}
bool PxVehicleGraphChannelDesc::isValid() const
{
PX_CHECK_AND_RETURN_VAL(mMinY != PX_MAX_F32, "PxVehicleGraphChannelDesc.mMinY must be initialised", false);
PX_CHECK_AND_RETURN_VAL(mMaxY != PX_MAX_F32, "PxVehicleGraphChannelDesc.mMaxY must be initialised", false);
PX_CHECK_AND_RETURN_VAL(mMidY != PX_MAX_F32, "PxVehicleGraphChannelDesc.mMidY must be initialised", false);
PX_CHECK_AND_RETURN_VAL(mColorLow.x != PX_MAX_F32 && mColorLow.y != PX_MAX_F32 && mColorLow.z != PX_MAX_F32, "PxVehicleGraphChannelDesc.mColorLow must be initialised", false);
PX_CHECK_AND_RETURN_VAL(mColorHigh.x != PX_MAX_F32 && mColorHigh.y != PX_MAX_F32 && mColorHigh.z != PX_MAX_F32, "PxVehicleGraphChannelDesc.mColorHigh must be initialised", false);
PX_CHECK_AND_RETURN_VAL(mTitle, "PxVehicleGraphChannelDesc.mTitle must be initialised", false);
return true;
}
PxVehicleGraph::PxVehicleGraph()
{
mBackgroundMinX=0;
mBackgroundMaxX=0;
mBackgroundMinY=0;
mBackgroundMaxY=0;
mSampleTide=0;
mBackgroundColor=PxVec3(255.f,255.f,255.f);
mBackgroundAlpha=1.0f;
for(PxU32 i=0;i<eMAX_NB_CHANNELS;i++)
{
mChannelMinY[i]=0;
mChannelMaxY[i]=0;
mChannelMidY[i]=0;
mChannelColorLow[i]=PxVec3(0,0,255.f);
mChannelColorHigh[i]=PxVec3(255.f,0,0);
memset(mChannelSamples[i], 0, sizeof(PxReal)*eMAX_NB_SAMPLES);
}
mNbChannels = 0;
PX_COMPILE_TIME_ASSERT(size_t(PxVehicleGraph::eMAX_NB_CHANNELS) >= size_t(PxVehicleDriveGraphChannel::eMAX_NB_DRIVE_CHANNELS) && size_t(PxVehicleGraph::eMAX_NB_CHANNELS) >= size_t(PxVehicleWheelGraphChannel::eMAX_NB_WHEEL_CHANNELS));
}
PxVehicleGraph::~PxVehicleGraph()
{
}
void PxVehicleGraph::setup(const PxVehicleGraphDesc& desc, const PxVehicleGraphType::Enum graphType)
{
mBackgroundMinX = (desc.mPosX - 0.5f*desc.mSizeX);
mBackgroundMaxX = (desc.mPosX + 0.5f*desc.mSizeX);
mBackgroundMinY = (desc.mPosY - 0.5f*desc.mSizeY);
mBackgroundMaxY = (desc.mPosY + 0.5f*desc.mSizeY);
mBackgroundColor=desc.mBackgroundColor;
mBackgroundAlpha=desc.mAlpha;
mNbChannels = (PxVehicleGraphType::eWHEEL==graphType) ? PxU32(PxVehicleWheelGraphChannel::eMAX_NB_WHEEL_CHANNELS) : PxU32(PxVehicleDriveGraphChannel::eMAX_NB_DRIVE_CHANNELS);
}
void PxVehicleGraph::setChannel(PxVehicleGraphChannelDesc& desc, const PxU32 channel)
{
PX_ASSERT(channel<eMAX_NB_CHANNELS);
mChannelMinY[channel]=desc.mMinY;
mChannelMaxY[channel]=desc.mMaxY;
mChannelMidY[channel]=desc.mMidY;
PX_CHECK_MSG(mChannelMinY[channel]<=mChannelMidY[channel], "mChannelMinY must be less than or equal to mChannelMidY");
PX_CHECK_MSG(mChannelMidY[channel]<=mChannelMaxY[channel], "mChannelMidY must be less than or equal to mChannelMaxY");
mChannelColorLow[channel]=desc.mColorLow;
mChannelColorHigh[channel]=desc.mColorHigh;
strcpy(mChannelTitle[channel], desc.mTitle);
}
void PxVehicleGraph::clearRecordedChannelData()
{
mSampleTide=0;
for(PxU32 i=0;i<eMAX_NB_CHANNELS;i++)
{
memset(mChannelSamples[i], 0, sizeof(PxReal)*eMAX_NB_SAMPLES);
}
}
void PxVehicleGraph::updateTimeSlice(const PxReal* const samples)
{
mSampleTide++;
mSampleTide=mSampleTide%eMAX_NB_SAMPLES;
for(PxU32 i=0;i<mNbChannels;i++)
{
mChannelSamples[i][mSampleTide]=samples[i];
}
}
void PxVehicleGraph::computeGraphChannel(const PxU32 channel, PxReal* xy, PxVec3* colors, char* title) const
{
PX_ASSERT(channel<mNbChannels);
const PxReal sizeX=mBackgroundMaxX-mBackgroundMinX;
const PxReal sizeY=mBackgroundMaxY-mBackgroundMinY;
const PxF32 minVal=mChannelMinY[channel];
const PxF32 maxVal=mChannelMaxY[channel];
const PxF32 midVal=mChannelMidY[channel];
const PxVec3 colorLow=mChannelColorLow[channel];
const PxVec3 colorHigh=mChannelColorHigh[channel];
for(PxU32 i=0;i<PxVehicleGraph::eMAX_NB_SAMPLES;i++)
{
const PxU32 index = (mSampleTide+1+i)%PxVehicleGraph::eMAX_NB_SAMPLES;
xy[2*i+0] = mBackgroundMinX+sizeX*i/(1.0f * PxVehicleGraph::eMAX_NB_SAMPLES);
const PxF32 sampleVal = PxClamp(mChannelSamples[channel][index],minVal,maxVal);
const PxReal y = (sampleVal-minVal)/(maxVal-minVal);
xy[2*i+1] = mBackgroundMinY+sizeY*y;
colors[i] = sampleVal < midVal ? colorLow : colorHigh;
}
strcpy(title,mChannelTitle[channel]);
}
PxF32 PxVehicleGraph::getLatestValue(const PxU32 channel) const
{
PX_CHECK_AND_RETURN_VAL(channel < mNbChannels, "PxVehicleGraph::getLatestValue: Illegal channel", 0.0f);
return mChannelSamples[channel][mSampleTide];
}
void PxVehicleGraph::setupEngineGraph
(const PxF32 sizeX, const PxF32 sizeY, const PxF32 posX, const PxF32 posY,
const PxVec3& backgoundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow)
{
PxVehicleGraphDesc desc;
desc.mSizeX=sizeX;
desc.mSizeY=sizeY;
desc.mPosX=posX;
desc.mPosY=posY;
desc.mBackgroundColor=backgoundColor;
desc.mAlpha=0.5f;
setup(desc,PxVehicleGraphType::eDRIVE);
//Engine revs
{
PxVehicleGraphChannelDesc desc2;
desc2.mColorHigh=lineColorHigh;
desc2.mColorLow=lineColorLow;
desc2.mMinY=0.0f;
desc2.mMaxY=800.0f;
desc2.mMidY=400.0f;
char title[64];
sprintf(title, "engineRevs");
desc2.mTitle=title;
setChannel(desc2,PxVehicleDriveGraphChannel::eENGINE_REVS);
}
//Engine torque
{
PxVehicleGraphChannelDesc desc2;
desc2.mColorHigh=lineColorHigh;
desc2.mColorLow=lineColorLow;
desc2.mMinY=0.0f;
desc2.mMaxY=1000.0f;
desc2.mMidY=0.0f;
char title[64];
sprintf(title, "engineDriveTorque");
desc2.mTitle=title;
setChannel(desc2,PxVehicleDriveGraphChannel::eENGINE_DRIVE_TORQUE);
}
//Clutch slip
{
PxVehicleGraphChannelDesc desc2;
desc2.mColorHigh=lineColorHigh;
desc2.mColorLow=lineColorLow;
desc2.mMinY=-200.0f;
desc2.mMaxY=200.0f;
desc2.mMidY=0.0f;
char title[64];
sprintf(title, "clutchSlip");
desc2.mTitle=title;
setChannel(desc2,PxVehicleDriveGraphChannel::eCLUTCH_SLIP);
}
//Accel control
{
PxVehicleGraphChannelDesc desc2;
desc2.mColorHigh=lineColorHigh;
desc2.mColorLow=lineColorLow;
desc2.mMinY=0.0f;
desc2.mMaxY=1.1f;
desc2.mMidY=0.0f;
char title[64];
sprintf(title, "accel");
desc2.mTitle=title;
setChannel(desc2,PxVehicleDriveGraphChannel::eACCEL_CONTROL);
}
//Brake control
{
PxVehicleGraphChannelDesc desc2;
desc2.mColorHigh=lineColorHigh;
desc2.mColorLow=lineColorLow;
desc2.mMinY=0.0f;
desc2.mMaxY=1.1f;
desc2.mMidY=0.0f;
char title[64];
sprintf(title, "brake/tank brake left");
desc2.mTitle=title;
setChannel(desc2,PxVehicleDriveGraphChannel::eBRAKE_CONTROL);
}
//HandBrake control
{
PxVehicleGraphChannelDesc desc2;
desc2.mColorHigh=lineColorHigh;
desc2.mColorLow=lineColorLow;
desc2.mMinY=0.0f;
desc2.mMaxY=1.1f;
desc2.mMidY=0.0f;
char title[64];
sprintf(title, "handbrake/tank brake right");
desc2.mTitle=title;
setChannel(desc2,PxVehicleDriveGraphChannel::eHANDBRAKE_CONTROL);
}
//Steer control
{
PxVehicleGraphChannelDesc desc2;
desc2.mColorHigh=lineColorHigh;
desc2.mColorLow=lineColorLow;
desc2.mMinY=-1.1f;
desc2.mMaxY=1.1f;
desc2.mMidY=0.0f;
char title[64];
sprintf(title, "steerLeft/tank thrust left");
desc2.mTitle=title;
setChannel(desc2,PxVehicleDriveGraphChannel::eSTEER_LEFT_CONTROL);
}
//Steer control
{
PxVehicleGraphChannelDesc desc2;
desc2.mColorHigh=lineColorHigh;
desc2.mColorLow=lineColorLow;
desc2.mMinY=-1.1f;
desc2.mMaxY=1.1f;
desc2.mMidY=0.0f;
char title[64];
sprintf(title, "steerRight/tank thrust right");
desc2.mTitle=title;
setChannel(desc2,PxVehicleDriveGraphChannel::eSTEER_RIGHT_CONTROL);
}
//Gear
{
PxVehicleGraphChannelDesc desc2;
desc2.mColorHigh=lineColorHigh;
desc2.mColorLow=lineColorLow;
desc2.mMinY=-4.f;
desc2.mMaxY=20.f;
desc2.mMidY=0.0f;
char title[64];
sprintf(title, "gearRatio");
desc2.mTitle=title;
setChannel(desc2,PxVehicleDriveGraphChannel::eGEAR_RATIO);
}
}
void PxVehicleGraph::setupWheelGraph
(const PxF32 sizeX, const PxF32 sizeY, const PxF32 posX, const PxF32 posY,
const PxVec3& backgoundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow)
{
PxVehicleGraphDesc desc;
desc.mSizeX=sizeX;
desc.mSizeY=sizeY;
desc.mPosX=posX;
desc.mPosY=posY;
desc.mBackgroundColor=backgoundColor;
desc.mAlpha=0.5f;
setup(desc,PxVehicleGraphType::eWHEEL);
//Jounce data channel
{
PxVehicleGraphChannelDesc desc2;
desc2.mColorHigh=lineColorHigh;
desc2.mColorLow=lineColorLow;
desc2.mMinY=-0.2f;
desc2.mMaxY=0.4f;
desc2.mMidY=0.0f;
char title[64];
sprintf(title, "suspJounce");
desc2.mTitle=title;
setChannel(desc2,PxVehicleWheelGraphChannel::eJOUNCE);
}
//Jounce susp force channel
{
PxVehicleGraphChannelDesc desc2;
desc2.mColorHigh=lineColorHigh;
desc2.mColorLow=lineColorLow;
desc2.mMinY=0.0f;
desc2.mMaxY=20000.0f;
desc2.mMidY=0.0f;
char title[64];
sprintf(title, "suspForce");
desc2.mTitle=title;
setChannel(desc2,PxVehicleWheelGraphChannel::eSUSPFORCE);
}
//Tire load channel.
{
PxVehicleGraphChannelDesc desc2;
desc2.mColorHigh=lineColorHigh;
desc2.mColorLow=lineColorLow;
desc2.mMinY=0.0f;
desc2.mMaxY=20000.0f;
desc2.mMidY=0.0f;
char title[64];
sprintf(title, "tireLoad");
desc2.mTitle=title;
setChannel(desc2,PxVehicleWheelGraphChannel::eTIRELOAD);
}
//Normalised tire load channel.
{
PxVehicleGraphChannelDesc desc2;
desc2.mColorHigh=lineColorHigh;
desc2.mColorLow=lineColorLow;
desc2.mMinY=0.0f;
desc2.mMaxY=3.0f;
desc2.mMidY=1.0f;
char title[64];
sprintf(title, "normTireLoad");
desc2.mTitle=title;
setChannel(desc2,PxVehicleWheelGraphChannel::eNORMALIZED_TIRELOAD);
}
//Wheel omega channel
{
PxVehicleGraphChannelDesc desc2;
desc2.mColorHigh=lineColorHigh;
desc2.mColorLow=lineColorLow;
desc2.mMinY=-50.0f;
desc2.mMaxY=250.0f;
desc2.mMidY=0.0f;
char title[64];
sprintf(title, "wheelOmega");
desc2.mTitle=title;
setChannel(desc2,PxVehicleWheelGraphChannel::eWHEEL_OMEGA);
}
//Tire friction
{
PxVehicleGraphChannelDesc desc2;
desc2.mColorHigh=lineColorHigh;
desc2.mColorLow=lineColorLow;
desc2.mMinY=0.0f;
desc2.mMaxY=1.1f;
desc2.mMidY=1.0f;
char title[64];
sprintf(title, "friction");
desc2.mTitle=title;
setChannel(desc2,PxVehicleWheelGraphChannel::eTIRE_FRICTION);
}
//Tire long slip
{
PxVehicleGraphChannelDesc desc2;
desc2.mColorHigh=lineColorHigh;
desc2.mColorLow=lineColorLow;
desc2.mMinY=-0.2f;
desc2.mMaxY=0.2f;
desc2.mMidY=0.0f;
char title[64];
sprintf(title, "tireLongSlip");
desc2.mTitle=title;
setChannel(desc2,PxVehicleWheelGraphChannel::eTIRE_LONG_SLIP);
}
//Normalised tire long force
{
PxVehicleGraphChannelDesc desc2;
desc2.mColorHigh=lineColorHigh;
desc2.mColorLow=lineColorLow;
desc2.mMinY=0.0f;
desc2.mMaxY=2.0f;
desc2.mMidY=1.0f;
char title[64];
sprintf(title, "normTireLongForce");
desc2.mTitle=title;
setChannel(desc2,PxVehicleWheelGraphChannel::eNORM_TIRE_LONG_FORCE);
}
//Tire lat slip
{
PxVehicleGraphChannelDesc desc2;
desc2.mColorHigh=lineColorHigh;
desc2.mColorLow=lineColorLow;
desc2.mMinY=-1.0f;
desc2.mMaxY=1.0f;
desc2.mMidY=0.0f;
char title[64];
sprintf(title, "tireLatSlip");
desc2.mTitle=title;
setChannel(desc2,PxVehicleWheelGraphChannel::eTIRE_LAT_SLIP);
}
//Normalised tire lat force
{
PxVehicleGraphChannelDesc desc2;
desc2.mColorHigh=lineColorHigh;
desc2.mColorLow=lineColorLow;
desc2.mMinY=0.0f;
desc2.mMaxY=2.0f;
desc2.mMidY=1.0f;
char title[64];
sprintf(title, "normTireLatForce");
desc2.mTitle=title;
setChannel(desc2,PxVehicleWheelGraphChannel::eNORM_TIRE_LAT_FORCE);
}
//Normalized aligning moment
{
PxVehicleGraphChannelDesc desc2;
desc2.mColorHigh=lineColorHigh;
desc2.mColorLow=lineColorLow;
desc2.mMinY=0.0f;
desc2.mMaxY=2.0f;
desc2.mMidY=1.0f;
char title[64];
sprintf(title, "normTireAlignMoment");
desc2.mTitle=title;
setChannel(desc2,PxVehicleWheelGraphChannel::eNORM_TIRE_ALIGNING_MOMENT);
}
}
PxVehicleTelemetryData* physx::PxVehicleTelemetryData::allocate(const PxU32 numWheels)
{
//Work out the byte size required.
PxU32 size = sizeof(PxVehicleTelemetryData);
size += sizeof(PxVehicleGraph); //engine graph
size += sizeof(PxVehicleGraph)*numWheels; //wheel graphs
size += sizeof(PxVec3)*numWheels; //tire force app points
size += sizeof(PxVec3)*numWheels; //susp force app points
//Allocate the memory.
PxVehicleTelemetryData* vehTelData=static_cast<PxVehicleTelemetryData*>(PX_ALLOC(size, "PxVehicleNWTelemetryData"));
//Patch up the pointers.
PxU8* ptr = reinterpret_cast<PxU8*>(vehTelData) + sizeof(PxVehicleTelemetryData);
vehTelData->mEngineGraph = reinterpret_cast<PxVehicleGraph*>(ptr);
new(vehTelData->mEngineGraph) PxVehicleGraph();
ptr += sizeof(PxVehicleGraph);
vehTelData->mWheelGraphs = reinterpret_cast<PxVehicleGraph*>(ptr);
for(PxU32 i=0;i<numWheels;i++)
{
new(&vehTelData->mWheelGraphs[i]) PxVehicleGraph();
}
ptr += sizeof(PxVehicleGraph)*numWheels;
vehTelData->mSuspforceAppPoints = reinterpret_cast<PxVec3*>(ptr);
ptr += sizeof(PxVec3)*numWheels;
vehTelData->mTireforceAppPoints = reinterpret_cast<PxVec3*>(ptr);
ptr += sizeof(PxVec3)*numWheels;
//Set the number of wheels in each structure that needs it.
vehTelData->mNbActiveWheels=numWheels;
//Finished.
return vehTelData;
}
void PxVehicleTelemetryData::free()
{
PX_FREE(this);
}
void physx::PxVehicleTelemetryData::setup
(const PxF32 graphSizeX, const PxF32 graphSizeY,
const PxF32 engineGraphPosX, const PxF32 engineGraphPosY,
const PxF32* const wheelGraphPosX, const PxF32* const wheelGraphPosY,
const PxVec3& backgroundColor, const PxVec3& lineColorHigh, const PxVec3& lineColorLow)
{
mEngineGraph->setupEngineGraph
(graphSizeX, graphSizeY, engineGraphPosX, engineGraphPosY,
backgroundColor, lineColorHigh, lineColorLow);
const PxU32 numActiveWheels=mNbActiveWheels;
for(PxU32 k=0;k<numActiveWheels;k++)
{
mWheelGraphs[k].setupWheelGraph
(graphSizeX, graphSizeY, wheelGraphPosX[k], wheelGraphPosY[k],
backgroundColor, lineColorHigh, lineColorLow);
mTireforceAppPoints[k]=PxVec3(0,0,0);
mSuspforceAppPoints[k]=PxVec3(0,0,0);
}
}
void physx::PxVehicleTelemetryData::clear()
{
mEngineGraph->clearRecordedChannelData();
const PxU32 numActiveWheels=mNbActiveWheels;
for(PxU32 k=0;k<numActiveWheels;k++)
{
mWheelGraphs[k].clearRecordedChannelData();
mTireforceAppPoints[k]=PxVec3(0,0,0);
mSuspforceAppPoints[k]=PxVec3(0,0,0);
}
}
#endif //PX_DEBUG_VEHICLE_ON
} //physx
|