From 5210f1f65c407c90e26c510a7d2719dac6707b1e Mon Sep 17 00:00:00 2001 From: torcs-ng Date: Sun, 16 Oct 2022 22:49:19 +0000 Subject: [PATCH] - update shadow's driver git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@8594 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: adfcde3b58cbb5fe2b5a6376efd7e0d6dcfd7a08 Former-commit-id: 40706a294f413e4c207c98fecb5abbf5011de830 --- src/drivers/shadow/src/Driver.cpp | 6 +++++- src/drivers/shadow/src/Driver.h | 2 ++ src/drivers/shadow/src/PitPath.cpp | 29 ++++++++++++++++++++++++++--- src/drivers/shadow/src/PitPath.h | 5 +++-- 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/drivers/shadow/src/Driver.cpp b/src/drivers/shadow/src/Driver.cpp index 0a66fce2..2c6b4793 100644 --- a/src/drivers/shadow/src/Driver.cpp +++ b/src/drivers/shadow/src/Driver.cpp @@ -67,6 +67,7 @@ using namespace std; #define PRV_STAY_TOGETHER "stay together" #define PRV_PIT_ENTRY_OFFS "pit entry offset" #define PRV_PIT_EXIT_OFFS "pit exit offset" +#define PRV_PIT_LAT_OFFS "pit lat offset" #define PRV_PIT_DAMAGE_WARN "pit damage warn limit" #define PRV_PIT_DAMAGE_DANGER "pit damage danger limit" #define PRV_PIT_TIRE_WARN "pit tire warn limit" @@ -492,6 +493,7 @@ void Driver::InitTrack( m_priv[p].STEER_K_DEC = SafeParmGetNum(hCarParm, sect.c_str(), PRV_STEER_K_DEC, 0, m_priv[p].STEER_K_DEC); m_priv[p].PIT_ENTRY_OFFSET = SafeParmGetNum(hCarParm, sect.c_str(), PRV_PIT_ENTRY_OFFS, 0, m_priv[p].PIT_ENTRY_OFFSET); m_priv[p].PIT_EXIT_OFFSET = SafeParmGetNum(hCarParm, sect.c_str(), PRV_PIT_EXIT_OFFS, 0, m_priv[p].PIT_EXIT_OFFSET); + m_priv[p].PIT_LAT_OFFSET = SafeParmGetNum(hCarParm, sect.c_str(), PRV_PIT_LAT_OFFS, 0, m_priv[p].PIT_LAT_OFFSET); m_priv[p].PIT_DAMAGE_WARN = (int)SafeParmGetNum(hCarParm, sect.c_str(), PRV_PIT_DAMAGE_WARN, 0, (float)m_priv[p].PIT_DAMAGE_WARN); m_priv[p].PIT_TIRE_WARN = SafeParmGetNum(hCarParm, sect.c_str(), PRV_PIT_TIRE_WARN, 0, 0.3); m_priv[p].PIT_DAMAGE_DANGER = (int)SafeParmGetNum(hCarParm, sect.c_str(), PRV_PIT_DAMAGE_DANGER, 0, (float)m_priv[p].PIT_DAMAGE_DANGER); @@ -741,7 +743,9 @@ void Driver::NewRace( int index, tCarElt* pCar, tSituation* pS ) CarModel pitCm(m_cm[p]); pitCm.BRAKE_MU_SCALE = 0.8; m_pitPath[p][i].MakePath( pCar->race.pit, &m_path[p], pitCm, i == 1, - m_priv[p].PIT_ENTRY_OFFSET, m_priv[p].PIT_EXIT_OFFSET ); + m_priv[p].PIT_ENTRY_OFFSET, + m_priv[p].PIT_EXIT_OFFSET, + m_priv[p].PIT_LAT_OFFSET); } } diff --git a/src/drivers/shadow/src/Driver.h b/src/drivers/shadow/src/Driver.h index be62dc29..0ce4f559 100644 --- a/src/drivers/shadow/src/Driver.h +++ b/src/drivers/shadow/src/Driver.h @@ -383,6 +383,7 @@ private: double AVOID_WIDTH; // in m. double PIT_ENTRY_OFFSET; // dist in m. double PIT_EXIT_OFFSET; // dist in m. + double PIT_LAT_OFFSET; int PIT_DAMAGE_WARN; // fix damage if no extra pit stops required. int PIT_DAMAGE_DANGER; // fix damage even if extra pit stops required. double PIT_TIRE_WARN; @@ -421,6 +422,7 @@ private: AVOID_WIDTH = 0.5; // in m. PIT_ENTRY_OFFSET = 0; // dist in m. PIT_EXIT_OFFSET = 0; // dist in m. + PIT_LAT_OFFSET = 0; PIT_DAMAGE_WARN = 5000; // fix damage if no extra pit stops required. PIT_DAMAGE_DANGER = 7000; // fix damage even if extra pit stops required. SKID_FACTOR = 0.0; diff --git a/src/drivers/shadow/src/PitPath.cpp b/src/drivers/shadow/src/PitPath.cpp index a8c51e13..e1a2bbdd 100644 --- a/src/drivers/shadow/src/PitPath.cpp +++ b/src/drivers/shadow/src/PitPath.cpp @@ -28,6 +28,11 @@ #include +// The "SHADOW" logger instance. +extern GfLogger* PLogSHADOW; +#define LogSHADOW (*PLogSHADOW) + + ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// @@ -80,7 +85,8 @@ void PitPath::MakePath( const CarModel& cm, int pitType, double entryOffset, - double exitOffset ) + double exitOffset, + double latoffset) { operator=( *pBasePath ); @@ -109,6 +115,11 @@ void PitPath::MakePath( m_pitEndPos = x[5]; m_pitExitPos = x[6]; + LogSHADOW.info("Pit Entry Position = %.2f\n", m_pitEntryPos); + LogSHADOW.info("Pit Start position = %.2f\n", m_pitStartPos); + LogSHADOW.info("Pit End position = %.2f\n", m_pitEndPos); + LogSHADOW.info("Pit Exit position = %.2f\n", m_pitExitPos); + // Normalizing spline segments to >= 0.0. {for( int i = 0; i < NPOINTS; i++ ) { @@ -131,21 +142,32 @@ void PitPath::MakePath( if( x[5] < x[4] ) x[5] = x[4]; + LogSHADOW.info("Pit Entry Position2 = %.2f\n", m_pitEntryPos); + LogSHADOW.info("Pit Start position2 = %.2f\n", m_pitStartPos); + LogSHADOW.info("Pit End position2 = %.2f\n", m_pitEndPos); + LogSHADOW.info("Pit Exit position2 = %.2f\n", m_pitExitPos); + // splice entry/exit of pit path into the base path provided. PtInfo pi; pBasePath->GetPtInfo(m_pitEntryPos, pi); y[0] = pi.offs; s[0] = -tan(pi.oang - m_pTrack->CalcForwardAngle(m_pitEntryPos)); + pBasePath->GetPtInfo(m_pitExitPos, pi); y[6] = pi.offs; s[6] = -tan(pi.oang - m_pTrack->CalcForwardAngle(m_pitExitPos)); double sign = (pPitInfo->side == TR_LFT) ? -1.0 : 1.0; - {for( int i = 1; i < NPOINTS - 1; i++ ) + {for( int i = 0; i < NPOINTS - 1; i++ ) { - y[i] = fabs(pPitInfo->driversPits->pos.toMiddle) - pPitInfo->width; + if (i == 0) + y[i] = fabs(pPitInfo->driversPits->pos.toMiddle) - (pPitInfo->width - latoffset); + else + y[i] = fabs(pPitInfo->driversPits->pos.toMiddle) - (pPitInfo->width - 0.5); + y[i] *= sign; + LogSHADOW.info("y[i] = %.2f\n", y[i]); }} if( pitType == Strategy::PT_NORMAL ) @@ -159,6 +181,7 @@ void PitPath::MakePath( {for( int i = 0; i < NPOINTS; i++ ) { LocalToGlobalXY( x[i], y[i], s[i], &gp[i], &gv[i] ); + LogSHADOW.info(" x[%d] = %.2f - y[%d] = %.2f - s[%d] = %.2f\n", i, x[i], i, y[i], i, s[i]); }} ParametricCubicSpline pspline(NPOINTS, gp, gv); diff --git a/src/drivers/shadow/src/PitPath.h b/src/drivers/shadow/src/PitPath.h index 46ff5e58..45a28875 100644 --- a/src/drivers/shadow/src/PitPath.h +++ b/src/drivers/shadow/src/PitPath.h @@ -38,8 +38,9 @@ public: PitPath& operator=( const PitPath& other ); virtual PitPath& operator=( const Path& other ); - void MakePath( const tTrackOwnPit* pPit, Path* pBasePath, const CarModel& cm, - int pitType, double entryOffset = 0, double exitOffset = 0 ); + void MakePath(const tTrackOwnPit* pPit, Path* pBasePath, const CarModel& cm, + int pitType, double entryOffset = 0, + double exitOffset = 0 , double latoffset = 0); // CPath overrides. // virtual bool ContainsPos( double trackPos ) const;