build 180628. ai power use logic tweaks, minor bug fixes

This commit is contained in:
tmj-fstate
2018-06-28 17:48:05 +02:00
parent 30e31cdfd0
commit 5dfbd5b0f7
6 changed files with 52 additions and 44 deletions

View File

@@ -53,11 +53,6 @@ TSegment::TSegment(TTrack *owner) :
pOwner( owner )
{}
TSegment::~TSegment()
{
SafeDeleteArray(fTsBuffer);
}
bool TSegment::Init(Math3D::vector3 NewPoint1, Math3D::vector3 NewPoint2, double fNewStep, double fNewRoll1, double fNewRoll2)
{ // wersja dla prostego - wyliczanie punktów kontrolnych
Math3D::vector3 dir;
@@ -157,8 +152,7 @@ bool TSegment::Init( Math3D::vector3 &NewPoint1, Math3D::vector3 NewCPointOut, M
*/
fStep = fLength / iSegCount; // update step to equalize size of individual pieces
SafeDeleteArray( fTsBuffer );
fTsBuffer = new double[ iSegCount + 1 ];
fTsBuffer.resize( iSegCount + 1 );
fTsBuffer[ 0 ] = 0.0;
for( int i = 1; i < iSegCount; ++i ) {
fTsBuffer[ i ] = GetTFromS( i * fStep );
@@ -230,7 +224,7 @@ double TSegment::GetTFromS(double const s) const
do {
double fDifference = RombergIntegral(0, fTime) - s;
if( ( fDifference > 0 ? fDifference : -fDifference ) < fTolerance ) {
if( std::abs( fDifference ) < fTolerance ) {
return fTime;
}
@@ -403,7 +397,7 @@ bool TSegment::RenderLoft( gfx::vertex_array &Output, Math3D::vector3 const &Ori
// podany jest przekrój końcowy
// podsypka toru jest robiona za pomocą 6 punktów, szyna 12, drogi i rzeki na 3+2+3
if( !fTsBuffer )
if( fTsBuffer.empty() )
return false; // prowizoryczne zabezpieczenie przed wysypem - ustalić faktyczną przyczynę
glm::vec3 pos1, pos2, dir, parallel1, parallel2, pt, norm;