forked from speed-dreams/speed-dreams-code
Bug fix: InitScene
If width of border decreased, avoid missing surfaces git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@563 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 477b149d220eb7139f2f1f3f9c3d89cde3ce40f0 Former-commit-id: 33c886027db20a9013a7754bdb2eaa3be5213e51
This commit is contained in:
parent
5a164c9c33
commit
a1ae25043d
2 changed files with 43 additions and 7 deletions
|
@ -2221,11 +2221,11 @@ GenerateTerrain(tTrack *track, void *TrackHandle, char *outfile, FILE *AllFd, in
|
|||
FILE *curFd = NULL;
|
||||
|
||||
TrackStep = GfParmGetNum(TrackHandle, TRK_SECT_TERRAIN, TRK_ATT_TSTEP, NULL, 10.0);
|
||||
GfOut("Track step: %.2f ", TrackStep);
|
||||
GfOut("Track step: %.2f\n", TrackStep);
|
||||
Margin = GfParmGetNum(TrackHandle, TRK_SECT_TERRAIN, TRK_ATT_BMARGIN, NULL, 100.0);
|
||||
GridStep = GfParmGetNum(TrackHandle, TRK_SECT_TERRAIN, TRK_ATT_BSTEP, NULL, 10.0);
|
||||
ExtHeight = GfParmGetNum(TrackHandle, TRK_SECT_TERRAIN, TRK_ATT_BHEIGHT, NULL, 0.0);
|
||||
GfOut("Border margin: %.2f step: %.2f height: %.2f", Margin, GridStep, ExtHeight);
|
||||
GfOut("Border margin: %.2f step: %.2f height: %.2f\n", Margin, GridStep, ExtHeight);
|
||||
|
||||
GroupSize = GfParmGetNum(TrackHandle, TRK_SECT_TERRAIN, TRK_ATT_GRPSZ, NULL, 100.0);
|
||||
XGroupOffset = track->min.x - Margin;
|
||||
|
|
|
@ -78,6 +78,15 @@ static unsigned int *trackindices;
|
|||
|
||||
static tdble TrackStep;
|
||||
|
||||
#ifndef sqr
|
||||
#define sqr(x) ((x)*(x))
|
||||
#endif
|
||||
|
||||
tdble Distance(tdble x0, tdble y0, tdble z0, tdble x1, tdble y1, tdble z1)
|
||||
{
|
||||
return sqrt((x0-x1)*(x0-x1)+(y0-y1)*(y0-y1)+(z0-z1)*(z0-z1));
|
||||
}
|
||||
|
||||
static void
|
||||
initPits(tTrack *theTrack, void *TrackHandle, tTrackPitInfo *pits)
|
||||
{
|
||||
|
@ -184,12 +193,18 @@ initPits(tTrack *theTrack, void *TrackHandle, tTrackPitInfo *pits)
|
|||
}
|
||||
}
|
||||
|
||||
/** Bug fix:
|
||||
If width of border decreased, additional vertices are needed to avoid missing surfaces
|
||||
Implementation:
|
||||
Compares old end vertices and new start vertices, set startNeeded if one is different
|
||||
**/
|
||||
int
|
||||
InitScene(tTrack *Track, void *TrackHandle, int bump)
|
||||
{
|
||||
|
||||
int i, j;
|
||||
tTrackSeg *seg;
|
||||
tTrackSeg *lastSeg;
|
||||
tTrackSeg *mseg;
|
||||
int nbvert;
|
||||
tdble width, wi2;
|
||||
|
@ -229,6 +244,7 @@ InitScene(tTrack *Track, void *TrackHandle, int bump)
|
|||
int hasBorder;
|
||||
tDispElt *theCurDispElt = NULL;
|
||||
char sname[256];
|
||||
float dmax = 0;
|
||||
|
||||
#define LG_STEP_MAX 50.0
|
||||
|
||||
|
@ -983,6 +999,15 @@ InitScene(tTrack *Track, void *TrackHandle, int bump)
|
|||
hasBorder = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!startNeeded)
|
||||
{
|
||||
tdble d0 = Distance(lastSeg->vertex[TR_EL].x, lastSeg->vertex[TR_EL].y, lastSeg->vertex[TR_EL].z, seg->vertex[TR_SL].x, seg->vertex[TR_SL].y, seg->vertex[TR_SL].z);
|
||||
tdble d1 = Distance(lastSeg->vertex[TR_ER].x, lastSeg->vertex[TR_ER].y, lastSeg->vertex[TR_ER].z, seg->vertex[TR_SR].x, seg->vertex[TR_SR].y, seg->vertex[TR_SR].z);
|
||||
if ((d0 > 0.01) || (d1 > 0.01))
|
||||
startNeeded = 1;
|
||||
}
|
||||
|
||||
CHECKDISPLIST(seg->surface->material, "tkRS", i, mseg->lgfromstart);
|
||||
if (!curTexLink) {
|
||||
curTexSeg = 0;
|
||||
|
@ -1002,8 +1027,8 @@ InitScene(tTrack *Track, void *TrackHandle, int bump)
|
|||
SETPOINT(texLen, 0, seg->vertex[TR_SL].x, seg->vertex[TR_SL].y, seg->vertex[TR_SL].z);
|
||||
SETPOINT(texLen, texMaxT, seg->vertex[TR_SR].x, seg->vertex[TR_SR].y, seg->vertex[TR_SR].z);
|
||||
}
|
||||
|
||||
switch (seg->type) {
|
||||
|
||||
switch (seg->type) {
|
||||
case TR_STR:
|
||||
ts = LMAX;
|
||||
texStep = LMAX / curTexSize;
|
||||
|
@ -1099,6 +1124,7 @@ InitScene(tTrack *Track, void *TrackHandle, int bump)
|
|||
|
||||
startNeeded = 0;
|
||||
runninglentgh += seg->length;
|
||||
lastSeg = seg;
|
||||
} else {
|
||||
startNeeded = 1;
|
||||
}
|
||||
|
@ -1501,7 +1527,16 @@ InitScene(tTrack *Track, void *TrackHandle, int bump)
|
|||
hasBorder = 0;
|
||||
}
|
||||
}
|
||||
CHECKDISPLIST(seg->surface->material, "tkLS", i, mseg->lgfromstart);
|
||||
|
||||
if (!startNeeded)
|
||||
{
|
||||
tdble d0 = Distance(lastSeg->vertex[TR_EL].x, lastSeg->vertex[TR_EL].y, lastSeg->vertex[TR_EL].z, seg->vertex[TR_SL].x, seg->vertex[TR_SL].y, seg->vertex[TR_SL].z);
|
||||
tdble d1 = Distance(lastSeg->vertex[TR_ER].x, lastSeg->vertex[TR_ER].y, lastSeg->vertex[TR_ER].z, seg->vertex[TR_SR].x, seg->vertex[TR_SR].y, seg->vertex[TR_SR].z);
|
||||
if ((d0 > 0.01) || (d1 > 0.01))
|
||||
startNeeded = 1;
|
||||
}
|
||||
|
||||
CHECKDISPLIST(seg->surface->material, "tkLS", i, mseg->lgfromstart);
|
||||
if (!curTexLink) {
|
||||
curTexSeg = 0;
|
||||
} else {
|
||||
|
@ -1519,8 +1554,8 @@ InitScene(tTrack *Track, void *TrackHandle, int bump)
|
|||
SETPOINT(texLen, texMaxT, seg->vertex[TR_SL].x, seg->vertex[TR_SL].y, seg->vertex[TR_SL].z);
|
||||
SETPOINT(texLen, 0, seg->vertex[TR_SR].x, seg->vertex[TR_SR].y, seg->vertex[TR_SR].z);
|
||||
}
|
||||
|
||||
switch (seg->type) {
|
||||
|
||||
switch (seg->type) {
|
||||
case TR_STR:
|
||||
ts = LMAX;
|
||||
texStep = LMAX / curTexSize;
|
||||
|
@ -1616,6 +1651,7 @@ InitScene(tTrack *Track, void *TrackHandle, int bump)
|
|||
|
||||
startNeeded = 0;
|
||||
runninglentgh += seg->length;
|
||||
lastSeg = seg;
|
||||
} else {
|
||||
startNeeded = 1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue