TORCS  1.3.9
The Open Racing Car Simulator
rttrack.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  rttrack.cpp -- Track utilities functions
3  -------------------
4  created : Sat Aug 14 23:03:22 CEST 1999
5  copyright : (C) 1999-2024 by Eric Espie, Bernhard Wymann
6  email : berniw@bluewin.ch
7 
8 ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
35 #include <portability.h>
36 #include <stdlib.h>
37 #include <math.h>
38 #ifdef WIN32
39 #include <windows.h>
40 #endif
41 #include <tgf.h>
42 #include <car.h>
43 #include <track.h>
44 
45 #include <robottools.h>
46 
57 tdble
59 {
60  return fabs(seg->startWidth + toStart * seg->Kyl);
61 }
62 
63 
79 void
81 {
82  tdble CosA, SinA, r, a;
83  tdble tr, toRight;
84  tTrackSeg *seg = p->seg;
85 
86  // Compute the equivalent toRight for TR_TOMIDDLE and TR_TOLEFT. This way
87  // we can run for all cases the same calculations further below.
88  if (flag == TR_TOMIDDLE || flag == TR_TOLEFT) {
89  tdble width = RtTrackGetWidth(seg, p->toStart);
90 
91  if (flag == TR_TOMIDDLE) {
92  toRight = (width / 2.0) + p->toMiddle;
93  } else { // TR_TOLEFT
94  toRight = width - p->toLeft;
95  }
96  } else {
97  toRight = p->toRight;
98  }
99 
100  switch(seg->type) {
101  case TR_STR:
102  CosA = cos(seg->angle[TR_ZS]);
103  SinA = sin(seg->angle[TR_ZS]);
104 
105  if (seg->type2 == TR_MAIN || seg->type2 == TR_LSIDE || seg->type2 == TR_LBORDER) {
106  tr = toRight;
107  } else if (seg->type2 == TR_RSIDE || seg->type2 == TR_RBORDER) {
108  tr = toRight - seg->Kyl * p->toStart;
109  } else {
110  tr = 0;
111  }
112 
113  *X = seg->vertex[TR_SR].x + p->toStart * CosA - tr * SinA;
114  *Y = seg->vertex[TR_SR].y + p->toStart * SinA + tr * CosA;
115  break;
116 
117  case TR_LFT:
118  case TR_RGT:
119  {
120  tdble sign = (seg->type == TR_LFT) ? 1.0f : -1.0f;
121  a = seg->angle[TR_ZS] + sign * p->toStart;
122 
123  if (seg->type2 == TR_MAIN || seg->type2 == TR_LSIDE || seg->type2 == TR_LBORDER) {
124  r = seg->radiusr - sign * toRight;
125  } else if (seg->type2 == TR_RSIDE || seg->type2 == TR_RBORDER) {
126  r = seg->radiusl + sign * (seg->startWidth + seg->Kyl * p->toStart - toRight);
127  } else {
128  r = 0;
129  }
130 
131  *X = seg->center.x + sign * r * sin(a);
132  *Y = seg->center.y - sign * r * cos(a);
133  break;
134  }
135  }
136 }
137 
155 void
157 {
158  int segnotfound = 1;
159  tdble x, y;
160  tTrackSeg *seg = segment;
161  tdble theta, a2;
162  int depl = 0;
163  tdble curWidth;
164 
165  p->type = type;
166 
167  while (segnotfound) {
168 
169  switch(seg->type) {
170  case TR_STR:
171  /* rotation */
172  tdble sine, cosine;
173  tdble ts;
174 
175  sine = sin(seg->angle[TR_ZS]);
176  cosine = cos(seg->angle[TR_ZS]);
177  x = X - seg->vertex[TR_SR].x;
178  y = Y - seg->vertex[TR_SR].y;
179  ts = x * cosine + y * sine;
180  p->seg = seg;
181  p->toStart = ts;
182  p->toRight = y * cosine - x * sine;
183  if ((ts < 0) && (depl < 1)) {
184  /* get back */
185  seg = seg->prev;
186  depl = -1;
187  } else if ((ts > seg->length) && (depl > -1)) {
188  seg = seg->next;
189  depl = 1;
190  } else {
191  segnotfound = 0;
192  }
193  break;
194 
195  case TR_LFT:
196  /* rectangular to polar */
197  x = X - seg->center.x;
198  y = Y - seg->center.y;
199  a2 = seg->arc / 2.0;
200  theta = atan2(y, x) - (seg->angle[TR_CS] + a2);
201  NORM_PI_PI(theta);
202  p->seg = seg;
203  p->toStart = theta + a2;
204  p->toRight = seg->radiusr - sqrt(x*x + y*y);
205  if ((theta < -a2) && (depl < 1)) {
206  seg = seg->prev;
207  depl = -1;
208  } else if ((theta > a2) && (depl > -1)) {
209  seg = seg->next;
210  depl = 1;
211  } else {
212  segnotfound = 0;
213  }
214  break;
215 
216  case TR_RGT:
217  /* rectangular to polar */
218 
219  x = X - seg->center.x;
220  y = Y - seg->center.y;
221  a2 = seg->arc / 2.0;
222  theta = seg->angle[TR_CS] - a2 - atan2(y, x);
223  NORM_PI_PI(theta);
224  p->seg = seg;
225  p->toStart = theta + a2;
226  p->toRight = sqrt(x*x + y*y) - seg->radiusr;
227  if ((theta < -a2) && (depl < 1)) {
228  seg = seg->prev;
229  depl = -1;
230  } else if ((theta > a2) && (depl > -1)) {
231  seg = seg->next;
232  depl = 1;
233  } else {
234  segnotfound = 0;
235  }
236  break;
237  }
238  }
239 
240  /* The track is of constant width */
241  /* This is subject to change */
242  p->toMiddle = p->toRight - seg->width / 2.0;
243  p->toLeft = seg->width - p->toRight;
244 
245  // Local position relative to the outermost barriers, mostly used for collision detection with barrier
246  if (type == TR_LPOS_TRACK) {
247  int side;
248  for (side = TR_SIDE_RGT; side <= TR_SIDE_LFT; side++) {
249  tdble* toSide = (side == TR_SIDE_RGT) ? (&p->toRight) : (&p->toLeft);
250  tTrackSeg *sseg = seg;
251  while ((sseg = sseg->side[side]) != NULL) {
252  *toSide += RtTrackGetWidth(sseg, p->toStart);
253  }
254  }
255  }
256 
257  // Relative to the segment which the point is located, including border and sides, mostly used for contact physics
258  if (type == TR_LPOS_SEGMENT) {
259  tTrackSeg *sseg = seg;
260  int trSide;
261 
262  // Determine which side to traverse to based on the position
263  if ((p->toRight < 0.0f) && (seg->side[TR_SIDE_RGT] != NULL)) {
264  trSide = TR_SIDE_RGT;
265  } else if ((p->toLeft < 0.0f) && (seg->side[TR_SIDE_LFT] != NULL)) {
266  trSide = TR_SIDE_LFT;
267  } else {
268  // Local position is already within the given segment
269  return;
270  }
271 
272  // Set variables based on the side
273  tdble *toSide = (trSide == TR_SIDE_RGT) ? &p->toRight : &p->toLeft;
274  tdble *toOppositeSide = (trSide == TR_SIDE_RGT) ? &p->toLeft : &p->toRight;
275  tdble sign = (trSide == TR_SIDE_RGT) ? 1.0f : -1.0f;
276  tdble prevWidth = seg->width;
277 
278  while ((*toSide < 0.0f) && (sseg->side[trSide] != NULL)) {
279  sseg = sseg->side[trSide];
280  p->seg = sseg;
281  curWidth = RtTrackGetWidth(sseg, p->toStart);
282  *toOppositeSide -= prevWidth;
283  *toSide += curWidth;
284  p->toMiddle += sign*(prevWidth + curWidth)/2.0f;
285  prevWidth = curWidth;
286  }
287  }
288 }
289 
290 
313 tdble
315 {
316  tdble lg;
317  tdble tr = p->toRight;
318  tTrackSeg *seg = p->seg;
319 
320  if ((tr < 0) && (seg->rside != NULL)) {
321  seg = seg->rside;
322  tr += seg->width;
323 
324  if ((tr < 0) && (seg->rside != NULL)) {
325  seg = seg->rside;
326  tr += RtTrackGetWidth(seg, p->toStart);
327  }
328  } else if ((tr > seg->width) && (seg->lside != NULL)) {
329  tr -= seg->width;
330  seg = seg->lside;
331  if ((tr > seg->width) && (seg->lside != NULL)) {
332  tr -= RtTrackGetWidth(seg, p->toStart);
333  seg = seg->lside;
334  }
335  }
336 
337  switch (seg->type) {
338  case TR_STR:
339  lg = p->toStart;
340  break;
341  default:
342  lg = p->toStart * seg->radius;
343  break;
344  }
345 
346  // Initial height on right side
347  tdble height_right_side = seg->vertex[TR_SR].z + p->toStart * seg->Kzl;
348  // Additional height because of banking angle
349  tdble banking_height = tr * tan(seg->angle[TR_XS] + p->toStart * seg->Kzw);
350  // Base height
351  tdble base_height = height_right_side + banking_height;
352 
353  if (seg->style == TR_CURB) {
354  // The final height = starting height + height difference due
355  // to track angle + height difference due to curb (this seems
356  // to be the way it is implemented in the graphics too: the
357  // curb does not adding an angle to the main track, but a
358  // height in global coordinates).
359 
360  tdble alpha = tr;
361  if (seg->type2 == TR_RBORDER) {
362  alpha = seg->width - tr;
363  }
364 
365  tdble curb_roughness = seg->surface->kRoughness * sin(seg->surface->kRoughWaveLen * lg);
366  return base_height + alpha * (seg->height + curb_roughness) / seg->width;
367  }
368 
369  return base_height +
370  seg->surface->kRoughness * sin(seg->surface->kRoughWaveLen * tr) * sin(seg->surface->kRoughWaveLen * lg);
371 }
372 
373 
384 {
385  if (current->side[tr_side] != NULL) {
386  return current->side[tr_side];
387  }
388 
389  // Because of the above guard the neighbour has now to be on the inside. Switching direction because we
390  // are searching from the inside; we need to traverse the opposite side to find the matching segment.
391  int tr_other_side = (tr_side == TR_SIDE_LFT) ? TR_SIDE_RGT : TR_SIDE_LFT;
392  tTrackSeg *neighbour = main;
393  tTrackSeg *otherSurface = main;
394  while (neighbour->side[tr_other_side] != NULL) {
395  otherSurface = neighbour;
396  if (neighbour->side[tr_other_side] == current) {
397  break;
398  }
399  neighbour = neighbour->side[tr_other_side];
400  }
401 
402  return otherSurface;
403 }
404 
405 
412 tTrackSeg *
414 {
415  tdble tr = p->toRight;
416  tTrackSeg *seg = p->seg;
417 
418  if ((tr < 0) && (seg->rside != NULL)) {
419  seg = seg->rside;
420  tr += seg->width;
421  if ((tr < 0) && (seg->rside != NULL)) {
422  seg = seg->rside;
423  }
424  } else if ((tr > seg->width) && (seg->lside != NULL)) {
425  tr -= seg->width;
426  seg = seg->lside;
427  if ((tr > seg->width) && (seg->lside != NULL)) {
428  seg = seg->lside;
429  }
430  }
431  return seg;
432 }
433 
442 tdble
444 {
445  tTrkLocPos p;
446 
448  return RtTrackHeightL(&p);
449 }
450 
469 void
470 RtTrackSideNormalG(tTrackSeg *seg, tdble X, tdble Y, int side, t3Dd *norm)
471 {
472  tdble lg;
473 
474  switch (seg->type) {
475  case TR_STR:
476  if (side == TR_RGT) {
477  norm->x = seg->rgtSideNormal.x;
478  norm->y = seg->rgtSideNormal.y;
479  } else {
480  norm->x = -seg->rgtSideNormal.x;
481  norm->y = -seg->rgtSideNormal.y;
482  }
483  break;
484  case TR_RGT:
485  case TR_LFT:
486  // For curved segments: same side as curve direction = outward, opposite side = inward
487  if (side == seg->type) {
488  // outward: pos - center
489  norm->x = X - seg->center.x;
490  norm->y = Y - seg->center.y;
491  } else {
492  // inward: center - pos
493  norm->x = seg->center.x - X;
494  norm->y = seg->center.y - Y;
495  }
496 
497  lg = 1.0 / sqrt(norm->x * norm->x + norm->y * norm->y);
498  norm->x *= lg;
499  norm->y *= lg;
500  break;
501  }
502 }
503 
513 tdble
515 {
516  switch (p->seg->type) {
517  case TR_STR:
518  return p->seg->angle[TR_ZS];
519  break;
520  case TR_RGT:
521  return p->seg->angle[TR_ZS] - p->toStart;
522  break;
523  case TR_LFT:
524  return p->seg->angle[TR_ZS] + p->toStart;
525  break;
526  }
527  return 0;
528 }
529 
530 
539 void
541 {
542  tTrkLocPos p1;
543  t3Dd px1, px2, py1, py2;
544  t3Dd v1, v2;
545  tdble lg;
546 
547  // Get to vectors, and calculate normal from the cross product.
548  p1.seg = p->seg;
549 
550  // Points for vector along the track with points px1, px2
551  p1.toStart = 0;
552  p1.toRight = p->toRight;
553  RtTrackLocal2Global(&p1, &px1.x, &px1.y, TR_TORIGHT);
554  px1.z = RtTrackHeightL(&p1);
555 
556  if (p1.seg->type == TR_STR) {
557  p1.toStart = p1.seg->length;
558  } else {
559  p1.toStart = p1.seg->arc;
560  }
561 
562  RtTrackLocal2Global(&p1, &px2.x, &px2.y, TR_TORIGHT);
563  px2.z = RtTrackHeightL(&p1);
564 
565  // Points for vector to the side of the track
566  // Determine if we take the vector on the start or end of the segment, for cases
567  // where start width or end width is 0. Does usually not matter, except on special
568  // cases like test tracks like ole-dirt
569  tdble width;
570  if (p1.seg->endWidth > p1.seg->startWidth) {
571  p1.toStart = p->toStart;
572  width = p1.seg->endWidth;
573  } else {
574  p1.toStart = 0;
575  width = p1.seg->startWidth;
576  }
577 
578  p1.toRight = 0;
579  RtTrackLocal2Global(&p1, &py1.x, &py1.y, TR_TORIGHT);
580  py1.z = RtTrackHeightL(&p1);
581 
582  p1.toRight = width;
583  RtTrackLocal2Global(&p1, &py2.x, &py2.y, TR_TORIGHT);
584  py2.z = RtTrackHeightL(&p1);
585 
586  // Vector along the track with points px1, px2
587  v1.x = px2.x - px1.x;
588  v1.y = px2.y - px1.y;
589  v1.z = px2.z - px1.z;
590 
591  // Vector to the side of the track py1, py2
592  v2.x = py2.x - py1.x;
593  v2.y = py2.y - py1.y;
594  v2.z = py2.z - py1.z;
595 
596  norm->x = v1.y * v2.z - v2.y * v1.z;
597  norm->y = v2.x * v1.z - v1.x * v2.z;
598  norm->z = v1.x * v2.y - v2.x * v1.y;
599  lg = sqrt(norm->x * norm->x + norm->y * norm->y + norm->z * norm->z);
600 
601  if (lg == 0.0) {
602  lg = 1.0;
603  } else {
604  lg = 1.0 / lg;
605  }
606 
607  norm->x *= lg;
608  norm->y *= lg;
609  norm->z *= lg;
610 }
611 
612 
618 tdble
620 {
621  return RtGetDistFromStart2(&(car->_trkPos));
622 }
623 
624 
630 tdble
632 {
633  tTrackSeg *seg;
634  tdble lg;
635 
636  seg = p->seg;
637  lg = seg->lgfromstart;
638 
639  switch (seg->type) {
640  case TR_STR:
641  lg += p->toStart;
642  break;
643  default:
644  lg += p->toStart * seg->radius;
645  break;
646  }
647 
648  return lg;
649 }
650 
651 
661 int
662 RtDistToPit(struct CarElt *car, tTrack *track, tdble *dL, tdble *dW)
663 {
664  tTrkLocPos *pitpos;
665  tTrkLocPos *carpos;
666  tdble pitts;
667  tdble carts;
668 
669  if (car->_pit == NULL) return 1;
670 
671  pitpos = &(car->_pit->pos);
672  carpos = &(car->_trkPos);
673 
674  if (carpos->seg->radius) {
675  carts = carpos->toStart * carpos->seg->radius;
676  } else {
677  carts = carpos->toStart;
678  }
679 
680  if (pitpos->seg->radius) {
681  pitts = pitpos->toStart * pitpos->seg->radius;
682  } else {
683  pitts = pitpos->toStart;
684  }
685 
686  *dL = pitpos->seg->lgfromstart - carpos->seg->lgfromstart + pitts - carts;
687  if (*dL < 0.0f) {
688  *dL += track->length;
689  } else if (*dL > track->length) {
690  *dL -= track->length;
691  }
692 
693  *dW = pitpos->toRight - carpos->toRight;
694 
695  return 0;
696 }
697 
698 
699 static void RtReadCarPitSetupEntry(tCarPitSetupValue* v, const char* path, const char* key, void *hdle, bool minmaxonly)
700 {
701  if (!minmaxonly) {
702  v->value = GfParmGetNum(hdle, path, key, (char*)NULL, 0.0f);
703  }
704  GfParmGetNumBoundaries(hdle, path, key, &v->min, &v->max);
705 }
706 
707 
714 void RtInitCarPitSetup(void *hdle, tCarPitSetup* s, bool minmaxonly)
715 {
718  const int BUFSIZE = 256;
719  char path[BUFSIZE];
720 
721  // Steer
722  RtReadCarPitSetupEntry(&s->steerLock, SECT_STEER, PRM_STEERLOCK, hdle, minmaxonly);
723 
724  int i;
725  for (i=0; i < 4; i++) {
726  // Wheel
727  RtReadCarPitSetupEntry(&s->wheelcamber[i], WheelSect[i], PRM_CAMBER, hdle, minmaxonly);
728  RtReadCarPitSetupEntry(&s->wheeltoe[i], WheelSect[i], PRM_TOE, hdle, minmaxonly);
729  RtReadCarPitSetupEntry(&s->wheelrideheight[i], WheelSect[i], PRM_RIDEHEIGHT, hdle, minmaxonly);
730  RtReadCarPitSetupEntry(&s->wheelcaster[i], WheelSect[i], PRM_CASTER, hdle, minmaxonly);
731 
732  // Suspension
733  RtReadCarPitSetupEntry(&s->suspspring[i], SuspSect[i], PRM_SPR, hdle, minmaxonly);
734  RtReadCarPitSetupEntry(&s->susppackers[i], SuspSect[i], PRM_PACKERS, hdle, minmaxonly);
735  RtReadCarPitSetupEntry(&s->suspslowbump[i], SuspSect[i], PRM_SLOWBUMP, hdle, minmaxonly);
736  RtReadCarPitSetupEntry(&s->suspslowrebound[i], SuspSect[i], PRM_SLOWREBOUND, hdle, minmaxonly);
737  RtReadCarPitSetupEntry(&s->suspfastbump[i], SuspSect[i], PRM_FASTBUMP, hdle, minmaxonly);
738  RtReadCarPitSetupEntry(&s->suspfastrebound[i], SuspSect[i], PRM_FASTREBOUND, hdle, minmaxonly);
741  }
742 
743  // Brake
746 
747  // Anti roll bar
748  static const char *ArbSect[2] = {SECT_FRNTARB, SECT_REARARB};
749  for (i=0; i < 2; i++) {
750  RtReadCarPitSetupEntry(&s->arbspring[i], ArbSect[i], PRM_SPR, hdle, minmaxonly);
751  }
752 
753  // Third element
754  static const char *AxleSect[2] = {SECT_FRNTAXLE, SECT_REARAXLE};
755  for (i=0; i < 2; i++) {
756  RtReadCarPitSetupEntry(&s->thirdspring[i], AxleSect[i], PRM_SPR, hdle, minmaxonly);
757  RtReadCarPitSetupEntry(&s->thirdbump[i], AxleSect[i], PRM_SLOWBUMP, hdle, minmaxonly);
758  RtReadCarPitSetupEntry(&s->thirdrebound[i], AxleSect[i], PRM_SLOWREBOUND, hdle, minmaxonly);
759  RtReadCarPitSetupEntry(&s->thirdX0[i], AxleSect[i], PRM_SUSPCOURSE, hdle, minmaxonly);
760  }
761 
762  // Gears
763  for (i=0; i < 8; i++) {
764  snprintf(path, BUFSIZE, "%s/%s/%d", SECT_GEARBOX, ARR_GEARS, i+1);
765  RtReadCarPitSetupEntry(&s->gearsratio[i], path, PRM_RATIO, hdle, minmaxonly);
766  }
767 
768  // Wings
769  static const char *WingSect[2] = {SECT_FRNTWING, SECT_REARWING};
770  for (i=0; i < 2; i++) {
771  RtReadCarPitSetupEntry(&s->wingangle[i], WingSect[i], PRM_WINGANGLE, hdle, minmaxonly);
772  }
773 
774  // Differentials
775  static const char *DiffSect[3] = {SECT_FRNTDIFFERENTIAL, SECT_REARDIFFERENTIAL, SECT_CENTRALDIFFERENTIAL};
776  for (i=0; i < 3; i++) {
777  RtReadCarPitSetupEntry(&s->diffratio[i], DiffSect[i], PRM_RATIO, hdle, minmaxonly);
778  RtReadCarPitSetupEntry(&s->diffmintqbias[i], DiffSect[i], PRM_MIN_TQ_BIAS, hdle, minmaxonly);
779  RtReadCarPitSetupEntry(&s->diffmaxtqbias[i], DiffSect[i], PRM_MAX_TQ_BIAS, hdle, minmaxonly);
780  RtReadCarPitSetupEntry(&s->diffslipbias[i], DiffSect[i], PRM_MAX_SLIP_BIAS, hdle, minmaxonly);
781  RtReadCarPitSetupEntry(&s->difflockinginputtq[i], DiffSect[i], PRM_LOCKING_TQ, hdle, minmaxonly);
782  RtReadCarPitSetupEntry(&s->difflockinginputbraketq[i], DiffSect[i], PRM_LOCKINGBRAKE_TQ, hdle, minmaxonly);
783 
784  const char* type = GfParmGetStr(hdle, DiffSect[i], PRM_TYPE, VAL_DIFF_NONE);
785  if (strcmp(type, VAL_DIFF_LIMITED_SLIP) == 0) {
787  } else if (strcmp(type, VAL_DIFF_VISCOUS_COUPLER) == 0) {
789  } else if (strcmp(type, VAL_DIFF_SPOOL) == 0) {
791  } else if (strcmp(type, VAL_DIFF_FREE) == 0) {
793  } else {
794  s->diffType[i] = tCarPitSetup::NONE;
795  }
796  }
797 }
798 
799 
801 static const char* CarPitSetupFilenames[6] = { "practice", "qualifying", "race", "backup1", "backup2", "backup3" };
802 
803 
814  rtCarPitSetupType type,
815  int robidx,
816  const char* carname,
817  const char* trackname,
818  char* filename,
819  const int len
820 )
821 {
822  snprintf(filename, len, "%s_%s_%d_%s" , carname, trackname, robidx, CarPitSetupFilenames[type]);
823 }
824 
825 
834 static void RtParmSetNum(void* hdlesetup, const char* path, const char* key, const char* unit, tCarPitSetupValue* v)
835 {
836  // If min == max there is nothing to adjust, so we do not need to write the value.
837  if (fabs(v->min - v->max) >= 0.0001f) {
838  GfParmSetNumEx(hdlesetup, path, key, unit, GfParmSI2Unit(unit, v->value), GfParmSI2Unit(unit, v->min), GfParmSI2Unit(unit, v->max));
839  }
840 }
841 
842 
851  void *hdlecar, // handle to car definition file, for min/max merge
852  tCarPitSetup* s, // the setup data to save
853  const char* filepath, // full path including filename and extension
854  const char* carname
855 )
856 {
857  const int BUFSIZE = 256;
858  char path[BUFSIZE];
859  void* hdlesetup = GfParmReadFile(filepath, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT);
860 
861  // Steer
862  RtParmSetNum(hdlesetup, SECT_STEER, PRM_STEERLOCK, "deg", &s->steerLock);
863 
866 
867  int i;
868  for (i=0; i < 4; i++) {
869  // Wheel
870  RtParmSetNum(hdlesetup, WheelSect[i], PRM_CAMBER, "deg", &s->wheelcamber[i]);
871  RtParmSetNum(hdlesetup, WheelSect[i], PRM_TOE, "deg", &s->wheeltoe[i]);
872  RtParmSetNum(hdlesetup, WheelSect[i], PRM_RIDEHEIGHT, "mm", &s->wheelrideheight[i]);
873  RtParmSetNum(hdlesetup, WheelSect[i], PRM_CASTER, "deg", &s->wheelcaster[i]);
874 
875  // Suspension
876  RtParmSetNum(hdlesetup, SuspSect[i], PRM_SPR, "lbs/in", &s->suspspring[i]);
877  RtParmSetNum(hdlesetup, SuspSect[i], PRM_PACKERS, "mm", &s->susppackers[i]);
878  RtParmSetNum(hdlesetup, SuspSect[i], PRM_SLOWBUMP, "lbs/in/s", &s->suspslowbump[i]);
879  RtParmSetNum(hdlesetup, SuspSect[i], PRM_SLOWREBOUND, "lbs/in/s", &s->suspslowrebound[i]);
880  RtParmSetNum(hdlesetup, SuspSect[i], PRM_FASTBUMP, "lbs/in/s", &s->suspfastbump[i]);
881  RtParmSetNum(hdlesetup, SuspSect[i], PRM_FASTREBOUND, "lbs/in/s", &s->suspfastrebound[i]);
882  RtParmSetNum(hdlesetup, SuspSect[i], PRM_BUMPTHRESHOLD, "cm/s", &s->suspbumpthreshold[i]);
883  RtParmSetNum(hdlesetup, SuspSect[i], PRM_REBOUNDTHRESHOLD, "cm/s", &s->suspreboundthreshold[i]);
884  }
885 
886  // Brake
887  RtParmSetNum(hdlesetup, SECT_BRKSYST, PRM_BRKREP, NULL, &s->brakeRepartition);
888  RtParmSetNum(hdlesetup, SECT_BRKSYST, PRM_BRKPRESS, "kPa", &s->brakePressure);
889 
890  // Anti roll bar
891  static const char *ArbSect[2] = {SECT_FRNTARB, SECT_REARARB};
892  for (i=0; i < 2; i++) {
893  RtParmSetNum(hdlesetup, ArbSect[i], PRM_SPR, "lbs/in", &s->arbspring[i]);
894  }
895 
896  // Third element
897  static const char *AxleSect[2] = {SECT_FRNTAXLE, SECT_REARAXLE};
898  for (i=0; i < 2; i++) {
899  RtParmSetNum(hdlesetup, AxleSect[i], PRM_SPR, "lbs/in", &s->thirdspring[i]);
900  RtParmSetNum(hdlesetup, AxleSect[i], PRM_SLOWBUMP, "lbs/in/s", &s->thirdbump[i]);
901  RtParmSetNum(hdlesetup, AxleSect[i], PRM_SLOWREBOUND, "lbs/in/s", &s->thirdrebound[i]);
902  RtParmSetNum(hdlesetup, AxleSect[i], PRM_SUSPCOURSE, "mm", &s->thirdX0[i]);
903  }
904 
905  // Gears
906  for (i=0; i < 8; i++) {
907  snprintf(path, BUFSIZE, "%s/%s/%d", SECT_GEARBOX, ARR_GEARS, i+1);
908  RtParmSetNum(hdlesetup, path, PRM_RATIO, NULL, &s->gearsratio[i]);
909  }
910 
911  // Wings
912  static const char *WingSect[2] = {SECT_FRNTWING, SECT_REARWING};
913  for (i=0; i < 2; i++) {
914  RtParmSetNum(hdlesetup, WingSect[i], PRM_WINGANGLE, "deg", &s->wingangle[i]);
915  }
916 
917  // Differentials
918  static const char *DiffSect[3] = {SECT_FRNTDIFFERENTIAL, SECT_REARDIFFERENTIAL, SECT_CENTRALDIFFERENTIAL};
920  for (i=0; i < 3; i++) {
921  RtParmSetNum(hdlesetup, DiffSect[i], PRM_RATIO, NULL, &s->diffratio[i]);
922  RtParmSetNum(hdlesetup, DiffSect[i], PRM_MIN_TQ_BIAS, NULL, &s->diffmintqbias[i]);
923  RtParmSetNum(hdlesetup, DiffSect[i], PRM_MAX_TQ_BIAS, NULL, &s->diffmaxtqbias[i]);
924  RtParmSetNum(hdlesetup, DiffSect[i], PRM_MAX_SLIP_BIAS, NULL, &s->diffslipbias[i]);
925  RtParmSetNum(hdlesetup, DiffSect[i], PRM_LOCKING_TQ, "N.m", &s->difflockinginputtq[i]);
926  RtParmSetNum(hdlesetup, DiffSect[i], PRM_LOCKINGBRAKE_TQ, "N.m", &s->difflockinginputbraketq[i]);
927 
928  if (s->diffType[i] != tCarPitSetup::NONE) {
929  GfParmSetStr(hdlesetup, DiffSect[i], PRM_TYPE, DiffType[s->diffType[i]]);
930  }
931  }
932 
933  hdlesetup = GfParmMergeHandles(hdlecar, hdlesetup, GFPARM_MMODE_DST | GFPARM_MMODE_RELDST);
934  GfParmWriteFile(filepath, hdlesetup, carname);
935  GfParmReleaseHandle(hdlesetup);
936 }
937 
938 
953  void *hdlecar,
954  tCarPitSetup* s,
955  rtCarPitSetupType type,
956  const char* modulename,
957  int robidx,
958  const char* trackname,
959  const char* carname
960 )
961 {
962  const int filelen = 256;
963  char filename[filelen];
964  RtGetCarPitSetupFilename(type, robidx, carname, trackname, filename, filelen);
965 
966  const int pathlen = 1024;
967  char path[pathlen];
968 
969  snprintf(path, pathlen, "%sdrivers/%s/setups", GetLocalDir(), modulename);
970  if (GfCreateDir(path) == GF_DIR_CREATED) {
971  snprintf(path, pathlen, "%sdrivers/%s/setups/%s.xml", GetLocalDir(), modulename, filename);
972  RtSaveCarPitSetupFile(hdlecar, s, path, carname);
973  } else {
974  GfError("RtSaveCarPitSetup, could not create %s\n", path);
975  }
976 }
977 
978 
989  rtCarPitSetupType type,
990  const char* modulename,
991  int robidx,
992  const char* trackname,
993  const char* carname
994 )
995 {
996  const int filelen = 256;
997  char filename[filelen];
998  RtGetCarPitSetupFilename(type, robidx, carname, trackname, filename, filelen);
999 
1000  const int pathlen = 1024;
1001  char path[pathlen];
1002 
1003  snprintf(path, pathlen, "%sdrivers/%s/setups/%s.xml", GetLocalDir(), modulename, filename);
1004  FILE* file = fopen(path, "r"); // TODO: maybe "stat" would be enough here
1005  if (file) {
1006  fclose(file);
1007  return true;
1008  }
1009 
1010  return false;
1011 }
1012 
1013 
1022 bool RtLoadCarPitSetupFilename(void* hdlecar, const char* filepath, tCarPitSetup* s, bool minmaxonly)
1023 {
1024  void* hdlesetup = GfParmReadFile(filepath, GFPARM_RMODE_STD);
1025  if (hdlesetup) {
1026  hdlesetup = GfParmMergeHandles(hdlecar, hdlesetup, GFPARM_MMODE_DST | GFPARM_MMODE_RELDST);
1027  RtInitCarPitSetup(hdlesetup, s, minmaxonly);
1028  GfParmReleaseHandle(hdlesetup);
1029  return true;
1030  } else {
1031  return false;
1032  }
1033 }
1034 
1035 
1052  void* hdlecar,
1053  tCarPitSetup* s,
1054  rtCarPitSetupType type,
1055  const char* modulename,
1056  int robidx,
1057  const char* trackname,
1058  const char* carname,
1059  bool minmaxonly
1060 )
1061 {
1062  const int filelen = 256;
1063  char filename[filelen];
1064  RtGetCarPitSetupFilename(type, robidx, carname, trackname, filename, filelen);
1065 
1066  const int pathlen = 1024;
1067  char path[pathlen];
1068 
1069  snprintf(path, pathlen, "%sdrivers/%s/setups/%s.xml", GetLocalDir(), modulename, filename);
1070  return RtLoadCarPitSetupFilename(hdlecar, path, s, minmaxonly);
1071 }
1072 
1073 
1080 void* RtLoadOriginalCarSettings(const char* carname)
1081 {
1082  const int BUFSIZE = 1024;
1083  char buf[BUFSIZE];
1084 
1085  // Fetch car handle
1086  snprintf(buf, BUFSIZE, "%scars/%s/%s.xml", GetDataDir(), carname, carname);
1087  void* carhdle = GfParmReadFile(buf, GFPARM_RMODE_STD);
1088  if (carhdle == 0) {
1089  GfError("carhdle NULL in %s, line %d\n", __FILE__, __LINE__);
1090  return NULL;
1091  }
1092 
1093  // Get category
1094  const char* category = GfParmGetStr(carhdle, SECT_CAR, PRM_CATEGORY, NULL);
1095  if (category == 0) {
1096  GfError("category string NULL in %s, line %d\n", __FILE__, __LINE__);
1097  GfParmReleaseHandle(carhdle);
1098  return NULL;
1099  }
1100 
1101  // Fetch category handle
1102  snprintf(buf, BUFSIZE, "%scategories/%s.xml", GetDataDir(), category);
1103  void* cathdle = GfParmReadFile(buf, GFPARM_RMODE_STD);
1104  if (cathdle == 0) {
1105  GfError("cathdle NULL in %s, line %d\n", __FILE__, __LINE__);
1106  GfParmReleaseHandle(carhdle);
1107  return NULL;
1108  }
1109 
1110  // Compose final result, MergeHandles releases source handles with given parameters
1113 
1114  return carhdle;
1115 }
1116 
1117 
1125 bool RtInitCarPitSetupFromDefault(tCarPitSetup* s, const char* carname)
1126 {
1127  void* carhandle = RtLoadOriginalCarSettings(carname);
1128  if (carhandle == 0) {
1129  GfError("carhandle NULL in %s, line %d\n", __FILE__, __LINE__);
1130  return false;
1131  }
1132 
1133  RtInitCarPitSetup(carhandle, s, false);
1134  GfParmReleaseHandle(carhandle);
1135  return true;
1136 }
1137 
1138 
1150  rtCarPitSetupType type,
1151  const char* modulename,
1152  int robidx,
1153  const char* trackname,
1154  const char* carname
1155 )
1156 {
1157  const int filelen = 256;
1158  char filename[filelen];
1159  RtGetCarPitSetupFilename(type, robidx, carname, trackname, filename, filelen);
1160 
1161  const int pathlen = 1024;
1162  char path[pathlen];
1163 
1164  snprintf(path, pathlen, "%sdrivers/%s/setups/%s.xml", GetLocalDir(), modulename, filename);
1165  return GfParmReadFile(path, GFPARM_RMODE_STD);
1166 }
tdble RtTrackHeightL(tTrkLocPos *p)
Returns the absolute height in meters of the road at the Local position p.
Definition: rttrack.cpp:314
#define GfError
Definition: tgf.h:351
tdble kRoughness
Roughtness in m of the surface (wave height)
Definition: track.h:250
int GfParmSetStr(void *handle, const char *path, const char *key, const char *val)
Set a string parameter in the parameter set handle.
Definition: params.cpp:2477
tdble angle[7]
Definition: track.h:337
tdble Kyl
Definition: track.h:359
#define TR_SR
Start-Right corner.
Definition: track.h:333
#define PRM_CATEGORY
Definition: car.h:511
tdble max
Definition: car.h:377
int type
Geometrical type:
Definition: track.h:280
void RtInitCarPitSetup(void *hdle, tCarPitSetup *s, bool minmaxonly)
Initialize tCarPitSetup from data in parameter set given in handle hdle.
Definition: rttrack.cpp:714
t3Dd center
Center of the curve.
Definition: track.h:324
#define PRM_BRKPRESS
Definition: car.h:574
void * GfParmReadFile(const char *file, int mode)
Read parameter set from file and return handle to parameter set.
Definition: params.cpp:1157
tTrackSeg * RtTrackGetSeg(tTrkLocPos *p)
Get the effective segment of the given position starting from a segment of type TR_MAIN, searching to the sides.
Definition: rttrack.cpp:413
#define PRM_TOE
Definition: car.h:536
tCarPitSetupValue gearsratio[MAX_GEARS - 2]
Definition: car.h:417
tdble toRight
Distance (+ to left, - to right) relative to the right side of segment.
Definition: track.h:432
#define SECT_FRNTAXLE
Definition: car.h:476
#define PRM_TYPE
Definition: car.h:527
tCarPitSetupValue suspslowrebound[4]
Definition: car.h:401
#define TR_LSIDE
Left side segment (outer segment)
Definition: track.h:297
bool RtCarPitSetupExists(rtCarPitSetupType type, const char *modulename, int robidx, const char *trackname, const char *carname)
Checks if a specific car setup is available.
Definition: rttrack.cpp:988
tdble RtTrackHeightG(tTrackSeg *seg, tdble X, tdble Y)
Returns the absolute height in meters of the road at the Global position (segment, X, Y)
Definition: rttrack.cpp:443
#define GFPARM_RMODE_STD
if handle already openned return it
Definition: tgf.h:265
void * GfParmMergeHandles(void *ref, void *tgt, int mode)
Merge two parameter sets into a new one, either containing parameters from ref, tgt or from both sets...
Definition: params.cpp:2962
#define TR_ZS
Rotation angles of the track in rad anti-clockwise: Index in:
Definition: track.h:347
#define TR_STR
Straight.
Definition: track.h:287
tdble width
Width of the segment (if constant width)
Definition: track.h:316
#define PRM_SUSPCOURSE
Definition: car.h:554
bool RtLoadCarPitSetupFilename(void *hdlecar, const char *filepath, tCarPitSetup *s, bool minmaxonly)
Load a custom car setup from a given filename.
Definition: rttrack.cpp:1022
int GfParmSetNumEx(void *handle, const char *path, const char *key, const char *unit, tdble val, tdble min, tdble max)
Set a numerical parameter in the parameter set handle including min and max.
Definition: params.cpp:2629
#define SECT_REARWING
Definition: car.h:486
tCarPitSetupValue thirdX0[2]
Definition: car.h:414
Location on the track in local coordinates.
Definition: track.h:418
#define PRM_LOCKING_TQ
Definition: car.h:620
static const char * SuspSect[4]
Definition: wheel.cpp:23
void RtTrackLocal2Global(tTrkLocPos *p, tdble *X, tdble *Y, int flag)
Calculate global coordinates from a local position relative to the given track segment (segment...
Definition: rttrack.cpp:80
Car structure (tCarElt).
Definition: car.h:455
void RtSaveCarPitSetup(void *hdlecar, tCarPitSetup *s, rtCarPitSetupType type, const char *modulename, int robidx, const char *trackname, const char *carname)
Save a custom car setup for a given robot, car, track and session (race, practice, qualifying, ...) type.
Definition: rttrack.cpp:952
#define SECT_BRKSYST
Definition: car.h:498
char * GetLocalDir(void)
Definition: tgf.cpp:231
tCarPitSetupValue diffmaxtqbias[3]
Definition: car.h:425
void GfParmReleaseHandle(void *parmHandle)
Release given parameter set handle parmHandle.
Definition: params.cpp:1834
#define SECT_FRNTLFTWHEEL
Definition: car.h:479
Robots Tools.
tCarPitSetupValue suspslowbump[4]
Definition: car.h:400
Track structure.
Definition: track.h:502
t3Dd rgtSideNormal
Definition: track.h:360
rtCarPitSetupType
Definition: robottools.h:180
#define PRM_MIN_TQ_BIAS
Definition: car.h:617
int GfCreateDir(char *path)
Create directory for given path recursively, so all missing parent directories are created as well...
Definition: tgf.cpp:309
#define TR_CS
Center start angle.
Definition: track.h:353
#define VAL_DIFF_LIMITED_SLIP
Definition: car.h:628
tdble Kzw
Definition: track.h:357
#define SECT_FRNTWING
Definition: car.h:475
#define SECT_FRNTLFTSUSP
Definition: car.h:481
#define SECT_REARRGTWHEEL
Definition: car.h:489
tCarPitSetupValue brakePressure
Definition: car.h:394
#define PRM_MAX_SLIP_BIAS
Definition: car.h:619
Definition: Basic.h:58
tdble lgfromstart
Length of beginning of segment from starting line.
Definition: track.h:319
tdble endWidth
Width of the end of the segment.
Definition: track.h:318
#define SECT_FRNTRGTSUSP
Definition: car.h:480
int GfParmWriteFile(const char *file, void *parmHandle, const char *name)
Write parameter set into file.
Definition: params.cpp:1610
#define TR_SIDE_LFT
Definition: track.h:403
tdble length
Length in meters of the middle of the track.
Definition: track.h:315
tdble startWidth
Width of the beginning of the segment.
Definition: track.h:317
tdble GfParmSI2Unit(const char *unit, tdble val)
Convert a value from SI to given unit.
Definition: params.cpp:1998
#define SECT_FRNTRGTWHEEL
Definition: car.h:478
#define SECT_REARLFTWHEEL
Definition: car.h:490
tCarPitSetupValue diffratio[3]
Definition: car.h:423
const char * GfParmGetStr(void *parmHandle, const char *path, const char *key, const char *deflt)
Get a string parameter from the parameter set handle.
Definition: params.cpp:2311
#define SECT_REARAXLE
Definition: car.h:487
#define GFPARM_MMODE_RELDST
release tgt after the merge
Definition: tgf.h:316
#define VAL_DIFF_SPOOL
Definition: car.h:626
#define PRM_RIDEHEIGHT
Definition: car.h:535
tCarPitSetupValue brakeRepartition
Definition: car.h:395
void * RtLoadOriginalCarSettings(const char *carname)
Gets a handle to a parameter file containing the original TORCS car setup, that means the car setup m...
Definition: rttrack.cpp:1080
void RtTrackGlobal2Local(tTrackSeg *segment, tdble X, tdble Y, tTrkLocPos *p, int type)
Convert a Global (segment, X, Y) position into a Local one (segment, toRight, toStart)The segment in ...
Definition: rttrack.cpp:156
#define VAL_DIFF_NONE
Definition: car.h:625
static const char * WheelSect[4]
Definition: wheel.cpp:22
tCarPitSetupValue steerLock
Definition: car.h:385
#define PRM_PACKERS
Definition: car.h:556
tCarPitSetupValue suspbumpthreshold[4]
Definition: car.h:404
tCarPitSetupValue arbspring[2]
Definition: car.h:408
tCarPitSetupValue difflockinginputtq[3]
Definition: car.h:427
#define PRM_BUMPTHRESHOLD
Definition: car.h:561
#define TR_RBORDER
Right border segment (inner segment)
Definition: track.h:300
int RtDistToPit(struct CarElt *car, tTrack *track, tdble *dL, tdble *dW)
Get the distance to the pit stop.
Definition: rttrack.cpp:662
void RtTrackSideNormalG(tTrackSeg *seg, tdble X, tdble Y, int side, t3Dd *norm)
Give the normal vector of the border of the track including the sides.
Definition: rttrack.cpp:470
#define VAL_DIFF_VISCOUS_COUPLER
Definition: car.h:629
#define PRM_WINGANGLE
Definition: car.h:583
#define PRM_SLOWBUMP
Definition: car.h:557
#define PRM_CAMBER
Definition: car.h:537
tCarPitSetupValue thirdspring[2]
Definition: car.h:411
#define PRM_FASTREBOUND
Definition: car.h:560
int GfParmGetNumBoundaries(void *handle, const char *path, const char *key, tdble *min, tdble *max)
Get the min and max of a numerical parameter from the parameter set handle.
Definition: params.cpp:3101
static const char * WingSect[2]
Definition: aero.cpp:108
#define TR_LFT
Left curve.
Definition: track.h:286
static void RtParmSetNum(void *hdlesetup, const char *path, const char *key, const char *unit, tCarPitSetupValue *v)
Robottool internal: Set parameter if min != max, save as well min and max values ...
Definition: rttrack.cpp:834
#define TR_RSIDE
Right side segment (outer segment)
Definition: track.h:298
#define PRM_BRKREP
Definition: car.h:573
int main(int argc, char *argv[])
Definition: main.cpp:124
tdble radiusr
Radius in meters of the right side of the track (>0)
Definition: track.h:321
float tdble
Floating point type used in TORCS.
Definition: tgf.h:48
static const char * CarPitSetupFilenames[6]
Array with names for rtCarPitSetupType enumeration.
Definition: rttrack.cpp:801
char * GetDataDir(void)
Definition: tgf.cpp:257
tdble radiusl
Radius in meters of the left side of the track (>0)
Definition: track.h:322
#define TR_CURB
Curb (border only)
Definition: track.h:310
#define SECT_REARARB
Definition: car.h:488
tdble value
Definition: car.h:375
#define SECT_REARRGTSUSP
Definition: car.h:491
struct trackSeg * side[2]
Definition: track.h:407
tCarPitSetupValue susppackers[4]
Definition: car.h:399
tCarPitSetupValue wheelrideheight[4]
Definition: car.h:390
static Point p[4]
Definition: Convex.cpp:54
#define SECT_FRNTDIFFERENTIAL
Definition: car.h:484
The Gaming Framework API.
#define TR_TOLEFT
Definition: track.h:415
tCarPitSetupValue thirdrebound[2]
Definition: car.h:413
Definition: Basic.h:58
tCarPitSetupValue thirdbump[2]
Definition: car.h:412
tdble arc
Arc in rad of the curve (>0)
Definition: track.h:323
#define TR_LBORDER
Left border segment (inner segment)
Definition: track.h:299
#define SECT_REARLFTSUSP
Definition: car.h:492
#define TR_XS
X Start angle.
Definition: track.h:351
tdble radius
Radius in meters of the middle of the track (>0)
Definition: track.h:320
#define PRM_SLOWREBOUND
Definition: car.h:558
tdble y
y coordinate
Definition: tgf.h:117
#define PRM_RATIO
Definition: car.h:600
#define PRM_STEERLOCK
Definition: car.h:568
#define SECT_CENTRALDIFFERENTIAL
Definition: car.h:496
tdble z
z coordinate
Definition: tgf.h:118
#define PRM_MAX_TQ_BIAS
Definition: car.h:618
tCarPitSetupValue suspfastbump[4]
Definition: car.h:402
TDiffType diffType[3]
Definition: car.h:430
t3Dd vertex[4]
Coordinates of the 4 corners of the segment.
Definition: track.h:325
This is the car structure.
tTrackSeg * RtTrackGetSideNeighbourSeg(tTrackSeg *main, tTrackSeg *current, int tr_side)
Get the neighbour segment of the given current segment.
Definition: rttrack.cpp:383
void * RtParmReadSetup(rtCarPitSetupType type, const char *modulename, int robidx, const char *trackname, const char *carname)
Load a custom car setup file for a given robot, car, track and session (race, practice, qualifying, ...) type.
Definition: rttrack.cpp:1149
int type2
Position type:
Definition: track.h:289
tCarPitSetupValue wheelcamber[4]
Definition: car.h:388
void RtGetCarPitSetupFilename(rtCarPitSetupType type, int robidx, const char *carname, const char *trackname, char *filename, const int len)
Compose filename from given strings.
Definition: rttrack.cpp:813
#define PRM_REBOUNDTHRESHOLD
Definition: car.h:562
tCarPitSetupValue wingangle[2]
Definition: car.h:420
#define TR_SIDE_RGT
Definition: track.h:404
tCarPitSetupValue diffmintqbias[3]
Definition: car.h:424
tCarPitSetupValue suspreboundthreshold[4]
Definition: car.h:405
tdble height
Max height for curbs.
Definition: track.h:363
#define SECT_STEER
Definition: car.h:497
tTrackSeg * seg
Track segment.
Definition: track.h:420
#define SECT_CAR
Definition: car.h:473
tdble GfParmGetNum(void *handle, const char *path, const char *key, const char *unit, tdble deflt)
Get a numerical parameter from the parameter set handle.
Definition: params.cpp:2392
tdble RtTrackGetWidth(tTrackSeg *seg, tdble toStart)
Get the track width at the specified point.
Definition: rttrack.cpp:58
struct trackSeg * lside
Definition: track.h:406
Track segment (tTrackSeg) The segments can be straights (type TR_STR): (the track goes from the right...
Definition: track.h:276
tdble RtGetDistFromStart(tCarElt *car)
Get the distance from the start lane.
Definition: rttrack.cpp:619
int track(tModInfo *modInfo)
Definition: trackitf.cpp:85
static Vector y[4]
Definition: Convex.cpp:56
bool RtInitCarPitSetupFromDefault(tCarPitSetup *s, const char *carname)
Initialize the given tCarPitSetup with the original TORCS setup, that means the car setup merged with...
Definition: rttrack.cpp:1125
#define GFPARM_MMODE_RELSRC
release ref after the merge
Definition: tgf.h:315
#define TR_RGT
Right curve.
Definition: track.h:285
tdble toStart
Distance to start of segment (or arc if turn)
Definition: track.h:431
bool RtLoadCarPitSetup(void *hdlecar, tCarPitSetup *s, rtCarPitSetupType type, const char *modulename, int robidx, const char *trackname, const char *carname, bool minmaxonly)
Load a custom car setup for a given robot, car, track and session (race, practice, qualifying, ...) type.
Definition: rttrack.cpp:1051
#define PRM_SPR
Definition: car.h:553
#define PRM_CASTER
Definition: car.h:538
struct trackSeg * prev
Previous segment.
Definition: track.h:398
void RtSaveCarPitSetupFile(void *hdlecar, tCarPitSetup *s, const char *filepath, const char *carname)
Save a custom car setup to a given filename.
Definition: rttrack.cpp:850
tTrackSurface * surface
Segment surface.
Definition: track.h:394
struct trackSeg * next
Next segment.
Definition: track.h:397
#define TR_LPOS_SEGMENT
Relative to the segment which the point is located, including border and sides, mostly used for conta...
Definition: track.h:428
#define TR_TORIGHT
Definition: track.h:413
#define GFPARM_MMODE_DST
use tgt and verify ref parameters
Definition: tgf.h:314
#define SECT_FRNTARB
Definition: car.h:477
static void RtReadCarPitSetupEntry(tCarPitSetupValue *v, const char *path, const char *key, void *hdle, bool minmaxonly)
Definition: rttrack.cpp:699
tCarPitSetupValue suspfastrebound[4]
Definition: car.h:403
#define TR_TOMIDDLE
Definition: track.h:414
static tRmTrackSelect ts
Definition: racemanmenu.cpp:45
#define TR_MAIN
Main track segment (ie road part)
Definition: track.h:296
3D point.
Definition: tgf.h:115
#define SECT_REARDIFFERENTIAL
Definition: car.h:495
tdble min
Definition: car.h:376
#define SECT_GEARBOX
Definition: car.h:503
struct trackSeg * rside
Definition: track.h:406
#define VAL_DIFF_FREE
Definition: car.h:627
#define NORM_PI_PI(x)
Angle normalization between -PI and PI.
Definition: tgf.h:88
tCarPitSetupValue suspspring[4]
Definition: car.h:398
int style
Border and barrier segments style:
Definition: track.h:302
#define ARR_GEARS
Definition: car.h:603
#define PRM_FASTBUMP
Definition: car.h:559
Track Structure and Track Loader Module Definition.
tCarPitSetupValue wheelcaster[4]
Definition: car.h:391
tCarPitSetupValue diffslipbias[3]
Definition: car.h:426
void RtTrackSurfaceNormalL(tTrkLocPos *p, t3Dd *norm)
Used to get the normal vector of the road (pointing upward).
Definition: rttrack.cpp:540
#define TR_LPOS_TRACK
Local position relative to the outermost barriers, mostly used for collision detection with barrier...
Definition: track.h:429
tdble Kzl
Definition: track.h:356
tdble kRoughWaveLen
Wave length in m of the surface.
Definition: track.h:251
#define GFPARM_RMODE_CREAT
Create the file if doesn&#39;t exist.
Definition: tgf.h:267
tdble x
x coordinate
Definition: tgf.h:116
tdble RtTrackSideTgAngleL(tTrkLocPos *p)
Used to get the tangent angle for a track position The angle is given in radian.
Definition: rttrack.cpp:514
tdble RtGetDistFromStart2(tTrkLocPos *p)
Get the distance from the start lane.
Definition: rttrack.cpp:631
#define GF_DIR_CREATED
Definition: tgf.h:623
tCarPitSetupValue wheeltoe[4]
Definition: car.h:389
#define PRM_LOCKINGBRAKE_TQ
Definition: car.h:621
static const char * AxleSect[2]
Definition: axle.cpp:21
#define GFPARM_MMODE_SRC
use ref and modify existing parameters with tgt
Definition: tgf.h:313
tCarPitSetupValue difflockinginputbraketq[3]
Definition: car.h:428
const T sign(const T &x)
Definition: MathFunctions.h:30