mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-20 03:19:19 +02:00
point light distance attenuation, partial unification of vbo/dl render paths
This commit is contained in:
54
Segment.cpp
54
Segment.cpp
@@ -42,10 +42,12 @@ TSegment::~TSegment()
|
||||
SafeDeleteArray(fTsBuffer);
|
||||
};
|
||||
|
||||
bool TSegment::Init(vector3 NewPoint1, vector3 NewPoint2, double fNewStep, double fNewRoll1,
|
||||
double fNewRoll2)
|
||||
bool TSegment::Init(vector3 NewPoint1, vector3 NewPoint2, double fNewStep, double fNewRoll1, double fNewRoll2)
|
||||
{ // wersja dla prostego - wyliczanie punktów kontrolnych
|
||||
vector3 dir;
|
||||
|
||||
// NOTE: we're enforcing division also for straight track, to ensure dense enough mesh for per-vertex lighting
|
||||
/*
|
||||
if (fNewRoll1 == fNewRoll2)
|
||||
{ // faktyczny prosty
|
||||
dir = Normalize(NewPoint2 - NewPoint1); // wektor kierunku o długości 1
|
||||
@@ -53,10 +55,13 @@ bool TSegment::Init(vector3 NewPoint1, vector3 NewPoint2, double fNewStep, doubl
|
||||
false);
|
||||
}
|
||||
else
|
||||
*/
|
||||
{ // prosty ze zmienną przechyłką musi być segmentowany jak krzywe
|
||||
dir = (NewPoint2 - NewPoint1) / 3.0; // punkty kontrolne prostego są w 1/3 długości
|
||||
return TSegment::Init(NewPoint1, NewPoint1 + dir, NewPoint2 - dir, NewPoint2, fNewStep,
|
||||
fNewRoll1, fNewRoll2, true);
|
||||
return TSegment::Init(
|
||||
NewPoint1, NewPoint1 + dir,
|
||||
NewPoint2 - dir, NewPoint2,
|
||||
fNewStep, fNewRoll1, fNewRoll2, true);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -120,33 +125,24 @@ bool TSegment::Init(vector3 &NewPoint1, vector3 NewCPointOut, vector3 NewCPointI
|
||||
fStoop = atan2((Point2.y - Point1.y),
|
||||
fLength); // pochylenie toru prostego, żeby nie liczyć wielokrotnie
|
||||
SafeDeleteArray(fTsBuffer);
|
||||
/*
|
||||
if ((bCurve) && (fStep > 0))
|
||||
*/
|
||||
// we're enforcing sub-division of even straight track, to have dense enough mesh for the spotlight to work with
|
||||
if( fStep > 0 )
|
||||
{ // Ra: prosty dostanie podział, jak ma różną przechyłkę na końcach
|
||||
double s = 0;
|
||||
int i = 0;
|
||||
iSegCount = ceil(fLength / fStep); // potrzebne do VBO
|
||||
// fStep=fLength/(double)(iSegCount-1); //wyrównanie podziału
|
||||
fTsBuffer = new double[iSegCount + 1];
|
||||
fTsBuffer[0] = 0; /* TODO : fix fTsBuffer */
|
||||
while (s < fLength)
|
||||
{
|
||||
i++;
|
||||
s += fStep;
|
||||
if (s > fLength)
|
||||
s = fLength;
|
||||
fTsBuffer[i] = GetTFromS(s);
|
||||
|
||||
if( ( bCurve ) && ( fStep > 0 ) ) {
|
||||
if( fStep > 0 ) { // Ra: prosty dostanie podział, jak ma różną przechyłkę na końcach
|
||||
double s = 0;
|
||||
int i = 0;
|
||||
iSegCount = ceil( fLength / fStep ); // potrzebne do VBO
|
||||
// fStep=fLength/(double)(iSegCount-1); //wyrównanie podziału
|
||||
fTsBuffer = new double[ iSegCount + 1 ];
|
||||
fTsBuffer[ 0 ] = 0; /* TODO : fix fTsBuffer */
|
||||
while( s < fLength ) {
|
||||
i++;
|
||||
s += fStep;
|
||||
if( s > fLength )
|
||||
s = fLength;
|
||||
fTsBuffer[ i ] = GetTFromS( s );
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fLength > 500)
|
||||
{ // tor ma pojemność 40 pojazdów, więc nie może być za długi
|
||||
ErrorLog("Bad geometry: Length > 500m at " + Where(Point1));
|
||||
// MessageBox(0,"Length>500","TSegment::Init",MB_OK);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user