simuv4: check both horizontal and vertical distances for different walls
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@8853 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: f3e15bfc14ef95a0830b04819ad6e0769b5fe793 Former-commit-id: 5a26d1147a9a5d023750384161bcec286e0936b4
This commit is contained in:
parent
3fb45ee8dc
commit
c69895b78e
1 changed files with 17 additions and 13 deletions
|
@ -546,13 +546,11 @@ void SimCollideRemoveCar(tCar *car, int nbcars)
|
|||
// TODO: Dynamic implementation.
|
||||
static DtShapeRef fixedobjects[100];
|
||||
// Id to the next free slot in fixedobjects.
|
||||
static unsigned int fixedid;
|
||||
static size_t fixedid;
|
||||
|
||||
void SimCarCollideShutdown(int nbcars)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < nbcars; i++)
|
||||
for (int i = 0; i < nbcars; i++)
|
||||
{
|
||||
// Check if car has not been removed already (wrecked).
|
||||
if (SimCarTable[i].shape != NULL)
|
||||
|
@ -562,8 +560,7 @@ void SimCarCollideShutdown(int nbcars)
|
|||
}
|
||||
}
|
||||
|
||||
unsigned int j;
|
||||
for (j = 0; j < fixedid; j++)
|
||||
for (size_t j = 0; j < fixedid; j++)
|
||||
{
|
||||
dtClearObjectResponse(&fixedobjects[j]);
|
||||
dtDeleteObject(&fixedobjects[j]);
|
||||
|
@ -610,6 +607,15 @@ static tTrackSeg *getFirstWallStart(tTrackSeg *start, int side)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static tdble distance(const t3Dd &p1, const t3Dd &p2)
|
||||
{
|
||||
tdble dx = p1.x - p2.x;
|
||||
tdble dy = p1.y - p2.y;
|
||||
tdble dz = p1.z - p2.z;
|
||||
|
||||
return sqrt(dx * dx + dy * dy + dz * dz);
|
||||
}
|
||||
|
||||
// Create the left walls, start must point to a segment with a wall on the left and a leading
|
||||
// non wall segment.
|
||||
// FIXME: Does not work for a closed ring "by design".
|
||||
|
@ -640,8 +646,8 @@ void buildWalls(tTrackSeg *start, int side) {
|
|||
|
||||
// Close the start with a ploygon?
|
||||
if (p == NULL || p->style != TR_WALL ||
|
||||
(fabs(p->vertex[TR_EL].x - svl.x) > weps) ||
|
||||
(fabs(p->vertex[TR_ER].x - svr.x) > weps) ||
|
||||
(distance(p->vertex[TR_EL], svl) > weps) ||
|
||||
(distance(p->vertex[TR_ER], svr) > weps) ||
|
||||
(fabs(h - p->height) > weps) ||
|
||||
fixedid == 0)
|
||||
{
|
||||
|
@ -706,8 +712,8 @@ void buildWalls(tTrackSeg *start, int side) {
|
|||
|
||||
// Close the end with a ploygon?
|
||||
if (n == NULL || n->style != TR_WALL ||
|
||||
(fabs(n->vertex[TR_SL].x - evl.x) > weps) ||
|
||||
(fabs(n->vertex[TR_SR].x - evr.x) > weps) ||
|
||||
(distance(n->vertex[TR_SL], evl) > weps) ||
|
||||
(distance(n->vertex[TR_SR], evr) > weps) ||
|
||||
(fabs(h - n->height) > weps))
|
||||
{
|
||||
if (close == true)
|
||||
|
@ -727,7 +733,6 @@ void buildWalls(tTrackSeg *start, int side) {
|
|||
GfError("Shape not open %s, line %d\n", __FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
current = current->next;
|
||||
|
@ -772,8 +777,7 @@ SimCarCollideInit(tTrack *track)
|
|||
buildWalls(firstleft, TR_SIDE_LFT);
|
||||
buildWalls(firstright, TR_SIDE_RGT);
|
||||
|
||||
unsigned int i;
|
||||
for (i = 0; i < fixedid; i++) {
|
||||
for (size_t i = 0; i < fixedid; i++) {
|
||||
dtCreateObject(&fixedobjects[i], fixedobjects[i]);
|
||||
dtSetObjectResponse(&fixedobjects[i], SimCarWallCollideResponse, DT_SMART_RESPONSE, &fixedobjects[i]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue