diff --git a/src/libs/robottools/robottools.h b/src/libs/robottools/robottools.h index fa4b25b3e..40b69216e 100644 --- a/src/libs/robottools/robottools.h +++ b/src/libs/robottools/robottools.h @@ -86,7 +86,7 @@ ROBOTTOOLS_API tdble RtTrackGetWidth(tTrackSeg *seg, tdble toStart); * and a length in meters for straights. * */ -ROBOTTOOLS_API void RtTrackLocal2Global(tTrkLocPos *p, tdble *X, tdble *Y, int flag); +ROBOTTOOLS_API void RtTrackLocal2Global(const tTrkLocPos *p, tdble *X, tdble *Y, int flag); /* * Convert a Global (segment, X, Y) position into a Local one (segment, toRight, toStart) diff --git a/src/libs/robottools/rttrack.cpp b/src/libs/robottools/rttrack.cpp index 3c6508383..201d598fb 100644 --- a/src/libs/robottools/rttrack.cpp +++ b/src/libs/robottools/rttrack.cpp @@ -67,7 +67,7 @@ tdble RtTrackGetWidth(tTrackSeg *seg, tdble toStart) - TR_TORIGHT the toRight field is used - TR_TOLEFT the toLeft field is used */ -void RtTrackLocal2Global(tTrkLocPos *p, tdble *X, tdble *Y, int flag) +void RtTrackLocal2Global(const tTrkLocPos *p, tdble *X, tdble *Y, int flag) { tdble r, a; tdble tr; diff --git a/src/modules/graphic/osggraph/Render/OsgRender.cpp b/src/modules/graphic/osggraph/Render/OsgRender.cpp index 21489ac2b..6fd535301 100644 --- a/src/modules/graphic/osggraph/Render/OsgRender.cpp +++ b/src/modules/graphic/osggraph/Render/OsgRender.cpp @@ -89,7 +89,7 @@ SDRender::SDRender(void) : APlanetsData(NULL), thesky(NULL), scenery(NULL), - SDTrack(NULL) + track(NULL) { BaseSkyColor = osg::Vec3f( 0.31f, 0.43f, 0.69f ); BaseFogColor = osg::Vec3f( 0.84f, 0.84f, 1.0f ); @@ -136,8 +136,6 @@ SDRender::~SDRender(void) } delete thesky; - - SDTrack = NULL; } /** @@ -146,10 +144,8 @@ SDRender::~SDRender(void) * * @return 0 if OK, -1 if something failed */ -void SDRender::Init(tTrack *track) +void SDRender::Init(const tTrack *track) { - SDTrack = track; - std::string datapath = GfDataDir(); //datapath +="/"; thesky = new SDSky; @@ -279,8 +275,8 @@ void SDRender::Init(tTrack *track) GfLogDebug(" Planets : %d\n", NPlanets); - const int timeOfDay = (int)SDTrack->local.timeofday; - //SDRain = (unsigned int)SDTrack->local.rain; + const int timeOfDay = track->local.timeofday; + //SDRain = (unsigned int)track->local.rain; const double domeSizeRatio = SDSkyDomeDistance / 80000.0; GfLogDebug(" domeSizeRation : %f\n", domeSizeRatio); @@ -289,7 +285,7 @@ void SDRender::Init(tTrack *track) SDSkyDomeDistance, 2000 * domeSizeRatio, SDSkyDomeDistance, NPlanets, APlanetsData, NStars, AStarsData ); GfLogDebug("Build SKY\n"); - GLfloat sunAscension = SDTrack->local.sunascension; + GLfloat sunAscension = track->local.sunascension; SDSunDeclination = (float)(15 * (double)timeOfDay / 3600 - 90.0); thesky->setSD( DEG2RAD(SDSunDeclination)); @@ -304,7 +300,7 @@ void SDRender::Init(tTrack *track) else SDMoonDeclination = (rand() % 270); - const float moonAscension = SDTrack->local.sunascension; + const float moonAscension = track->local.sunascension; thesky->setMD( DEG2RAD(SDMoonDeclination) ); thesky->setMRA( DEG2RAD(moonAscension) ); @@ -319,7 +315,7 @@ void SDRender::Init(tTrack *track) //double r_WrldZ = SDScenery::getWorldZ(); osg::Vec3d viewPos(r_WrldX / 2, r_WrldY/ 2, 0.0 ); - weather(); + weather(track); thesky->set_visibility( SDVisibility ); // Visibility in meters thesky->reposition( viewPos, 0, 0); @@ -327,7 +323,7 @@ void SDRender::Init(tTrack *track) moon_angle = (float)thesky->getMA(); thesky->repaint(SkyColor, FogColor, CloudsColor, sol_angle, moon_angle, NPlanets, APlanetsData, NStars, AStarsData); - UpdateLight(); + UpdateLight(track); osg::ref_ptr vdsm = new osgShadow::ShadowMap; m_Root = new osg::Group; @@ -448,6 +444,7 @@ void SDRender::Init(tTrack *track) stateSet2->setMode(GL_LIGHTING, osg::StateAttribute::ON); stateSet2->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON); //stateSet2->setMode(GL_FOG, osg::StateAttribute::ON); + this->track = track; }//SDRender::Init void SDRender::ShadowedScene() @@ -536,13 +533,13 @@ void SDRender::addCars(osg::Node* cars, osg::Node* carLights) optimizer.optimize(m_Root.get()); } -void SDRender::UpdateLight( void ) +void SDRender::UpdateLight(const tTrack *track) { sol_angle = (float)thesky->getSA(); moon_angle = (float)thesky->getMA(); sky_brightness = (float)(1.0 + cos(sol_angle)) / 2.0f; - if (SDTrack->local.rain > 0) + if (track->local.rain > 0) { BaseFogColor = osg::Vec3f(0.42f, 0.44f, 0.50f); sky_brightness = (float)pow(sky_brightness, 0.5f); @@ -700,11 +697,11 @@ void SDRender::UpdateSky(double currentTime, double accelTime, double X, double if ( SDSkyDomeDistance ) { // Ensure the sun and moon positions are reset - const int timeOfDay = (int)SDTrack->local.timeofday; - GLfloat sunAscension = SDTrack->local.sunascension; + const int timeOfDay = (int)track->local.timeofday; + GLfloat sunAscension = track->local.sunascension; SDSunDeclination = (float)(15 * (double)timeOfDay / 3600 - 90.0); - const float moonAscension = SDTrack->local.sunascension; + const float moonAscension = track->local.sunascension; //SDMoonDeclination = grUpdateMoonPos(timeOfDay); thesky->setSD( DEG2RAD(SDSunDeclination)); @@ -759,7 +756,7 @@ void SDRender::UpdateSky(double currentTime, double accelTime, double X, double } // 3) Update scene color and light - UpdateLight(); + UpdateLight(track); sunLight->getLight()->setAmbient(SceneAmbiant); sunLight->getLight()->setDiffuse(SceneDiffuse); @@ -785,7 +782,7 @@ void SDRender::UpdateSky(double currentTime, double accelTime, double X, double }//grUpdateSky -void SDRender::weather(void) +void SDRender::weather(const tTrack *track) { std::string datapath = GfDataDir(); double domeSizeRatio = SDSkyDomeDistance / 80000.0; @@ -795,22 +792,22 @@ void SDRender::weather(void) (unsigned)(GfParmGetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_CLOUDLAYER, 0, 0) + 0.5); GfLogDebug("Graphic options : Number of cloud layers : %u\n", SDNbCloudLayers); - GfLogDebug("Graphic cloud alt 1 = %.3f\n", SDTrack->local.cloud_altitude); - GfLogDebug("Graphic cloud alt 2 = %.3f\n", SDTrack->local.cloud_altitude2); - GfLogDebug("Graphic cloud alt 3 = %.3f\n", SDTrack->local.cloud_altitude3); + GfLogDebug("Graphic cloud alt 1 = %.3f\n", track->local.cloud_altitude); + GfLogDebug("Graphic cloud alt 2 = %.3f\n", track->local.cloud_altitude2); + GfLogDebug("Graphic cloud alt 3 = %.3f\n", track->local.cloud_altitude3); - cloudsTextureIndex = SDTrack->local.clouds; - cloudsTextureIndex2 = SDTrack->local.clouds2; - cloudsTextureIndex3 = SDTrack->local.clouds3; + cloudsTextureIndex = track->local.clouds; + cloudsTextureIndex2 = track->local.clouds2; + cloudsTextureIndex3 = track->local.clouds3; - switch (SDTrack->local.rain) + switch (track->local.rain) { case TR_RAIN_NONE: - SDVisibility = SDTrack->local.visibility; + SDVisibility = track->local.visibility; SDRain = 0; break; case TR_RAIN_LITTLE: - SDVisibility = SDTrack->local.visibility; + SDVisibility = track->local.visibility; SDRain = 1; break; case TR_RAIN_MEDIUM: @@ -823,8 +820,8 @@ void SDRender::weather(void) break; default: GfLogDebug("Unsupported rain strength value %d (assuming none)", - SDTrack->local.rain); - SDVisibility = SDTrack->local.visibility; + track->local.rain); + SDVisibility = track->local.visibility; break; }//switch Rain @@ -832,9 +829,9 @@ void SDRender::weather(void) { SDCloudLayer *layer = new SDCloudLayer(datapath); layer->setCoverage(layer->SD_CLOUD_OVERCAST); - layer->setSpeed(SDTrack->local.windspeed); - layer->setDirection(SDTrack->local.winddir); - layer->setElevation_m(SDTrack->local.cloud_altitude); + layer->setSpeed(track->local.windspeed); + layer->setDirection(track->local.winddir); + layer->setElevation_m(track->local.cloud_altitude); layer->setThickness_m(100 / domeSizeRatio); layer->setTransition_m(100 / domeSizeRatio); layer->setSpan_m(SDSkyDomeDistance); @@ -875,9 +872,9 @@ void SDRender::weather(void) break; } - layer->setSpeed(SDTrack->local.windspeed); - layer->setDirection(SDTrack->local.winddir); - layer->setElevation_m(SDTrack->local.cloud_altitude); + layer->setSpeed(track->local.windspeed); + layer->setDirection(track->local.winddir); + layer->setElevation_m(track->local.cloud_altitude); layer->setThickness_m(100 / domeSizeRatio); layer->setTransition_m(100 / domeSizeRatio); layer->setSpan_m(SDSkyDomeDistance); @@ -919,9 +916,9 @@ void SDRender::weather(void) break; } - layer2->setSpeed(SDTrack->local.windspeed / 2); - layer2->setDirection(SDTrack->local.winddir); - layer2->setElevation_m(SDTrack->local.cloud_altitude2); + layer2->setSpeed(track->local.windspeed / 2); + layer2->setDirection(track->local.winddir); + layer2->setElevation_m(track->local.cloud_altitude2); layer2->setThickness_m(100 / domeSizeRatio); layer2->setTransition_m(100 / domeSizeRatio); layer2->setSpan_m(SDSkyDomeDistance); @@ -959,9 +956,9 @@ void SDRender::weather(void) break; } - layer->setSpeed(SDTrack->local.windspeed); - layer->setDirection(SDTrack->local.winddir); - layer->setElevation_m(SDTrack->local.cloud_altitude); + layer->setSpeed(track->local.windspeed); + layer->setDirection(track->local.winddir); + layer->setElevation_m(track->local.cloud_altitude); layer->setThickness_m(100 / domeSizeRatio); layer->setTransition_m(100 / domeSizeRatio); layer->setSpan_m(SDSkyDomeDistance); @@ -1002,9 +999,9 @@ void SDRender::weather(void) break; } - layer->setSpeed(SDTrack->local.windspeed); - layer->setDirection(SDTrack->local.winddir); - layer->setElevation_m(SDTrack->local.cloud_altitude); + layer->setSpeed(track->local.windspeed); + layer->setDirection(track->local.winddir); + layer->setElevation_m(track->local.cloud_altitude); layer->setThickness_m(100 / domeSizeRatio); layer->setTransition_m(100 / domeSizeRatio); layer->setSpan_m(SDSkyDomeDistance); @@ -1051,8 +1048,8 @@ void SDRender::weather(void) } layer3->setSpeed(0); - layer3->setDirection(SDTrack->local.winddir); - layer3->setElevation_m(SDTrack->local.cloud_altitude3); + layer3->setDirection(track->local.winddir); + layer3->setElevation_m(track->local.cloud_altitude3); layer3->setThickness_m(100 / domeSizeRatio); layer3->setTransition_m(100 / domeSizeRatio); layer3->setSpan_m(SDSkyDomeDistance); @@ -1090,9 +1087,9 @@ void SDRender::weather(void) break; } - layer2->setSpeed(SDTrack->local.windspeed / 2); - layer2->setDirection(SDTrack->local.winddir); - layer2->setElevation_m(SDTrack->local.cloud_altitude2); + layer2->setSpeed(track->local.windspeed / 2); + layer2->setDirection(track->local.winddir); + layer2->setElevation_m(track->local.cloud_altitude2); layer2->setThickness_m(100 / domeSizeRatio); layer2->setTransition_m(100 / domeSizeRatio); layer2->setSpan_m(SDSkyDomeDistance); @@ -1130,9 +1127,9 @@ void SDRender::weather(void) break; } - layer->setSpeed(SDTrack->local.windspeed); - layer->setDirection(SDTrack->local.winddir); - layer->setElevation_m(SDTrack->local.cloud_altitude); + layer->setSpeed(track->local.windspeed); + layer->setDirection(track->local.winddir); + layer->setElevation_m(track->local.cloud_altitude); layer->setThickness_m(100 / domeSizeRatio); layer->setTransition_m(100 / domeSizeRatio); layer->setSpan_m(SDSkyDomeDistance); @@ -1173,9 +1170,9 @@ void SDRender::weather(void) break; } - layer2->setSpeed(SDTrack->local.windspeed /2); - layer2->setDirection(SDTrack->local.winddir); - layer2->setElevation_m(SDTrack->local.cloud_altitude2); + layer2->setSpeed(track->local.windspeed /2); + layer2->setDirection(track->local.winddir); + layer2->setElevation_m(track->local.cloud_altitude2); layer2->setThickness_m(100 / domeSizeRatio); layer2->setTransition_m(100 / domeSizeRatio); layer2->setSpan_m(SDSkyDomeDistance); @@ -1213,9 +1210,9 @@ void SDRender::weather(void) break; } - layer->setSpeed(SDTrack->local.windspeed); - layer->setDirection(SDTrack->local.winddir); - layer->setElevation_m(SDTrack->local.cloud_altitude); + layer->setSpeed(track->local.windspeed); + layer->setDirection(track->local.winddir); + layer->setElevation_m(track->local.cloud_altitude); layer->setThickness_m(100 / domeSizeRatio); layer->setTransition_m(100 / domeSizeRatio); layer->setSpan_m(SDSkyDomeDistance); @@ -1255,9 +1252,9 @@ void SDRender::weather(void) break; } - layer->setSpeed(SDTrack->local.windspeed); - layer->setDirection(SDTrack->local.winddir); - layer->setElevation_m(SDTrack->local.cloud_altitude); + layer->setSpeed(track->local.windspeed); + layer->setDirection(track->local.winddir); + layer->setElevation_m(track->local.cloud_altitude); layer->setThickness_m(100 / domeSizeRatio); layer->setTransition_m(100 / domeSizeRatio); layer->setSpan_m(SDSkyDomeDistance); diff --git a/src/modules/graphic/osggraph/Render/OsgRender.h b/src/modules/graphic/osggraph/Render/OsgRender.h index dc10a673d..8c64f0063 100644 --- a/src/modules/graphic/osggraph/Render/OsgRender.h +++ b/src/modules/graphic/osggraph/Render/OsgRender.h @@ -98,22 +98,22 @@ private: SDSky *thesky; SDScenery *scenery; - tTrack *SDTrack; + const tTrack *track; public: SDRender(void); ~SDRender(void); - void Init(tTrack *track); + void Init(const tTrack *track); osg::ref_ptr< osg::StateSet> setFogState(); osg::Vec4f getSceneColor(void); void UpdateTime(tSituation *s); - void UpdateLight(void); + void UpdateLight(const tTrack *track); void addCars(osg::Node* cars, osg::Node* carLights); void UpdateFogColor(double angle); void UpdateSky(double currentTime, double accelTime, double X, double Y); void ShadowedScene(void); - void weather(void); + void weather(const tTrack *track); inline SDSky * getSky() { return thesky; } inline int getShader() const { return carsShader; } diff --git a/src/modules/graphic/osggraph/Scenery/OsgPit.cpp b/src/modules/graphic/osggraph/Scenery/OsgPit.cpp index c40a6ce4e..4c4309fde 100644 --- a/src/modules/graphic/osggraph/Scenery/OsgPit.cpp +++ b/src/modules/graphic/osggraph/Scenery/OsgPit.cpp @@ -35,11 +35,11 @@ SDPit::~SDPit(void) { } -void SDPit::build(tTrack *track) +void SDPit::build(const tTrack *track) { GfLogDebug("Build pits ... \n"); - tTrackPitInfo *pits = &track->pits; + const tTrackPitInfo *pits = &track->pits; if (pits->pitindicator > 0) GfLogTrace("Pit Indicator ... YES ...\n"); @@ -56,7 +56,7 @@ void SDPit::build(tTrack *track) GfLogTrace("Creating track side pit buildings (%d slots) ...\n", pits->nMaxPits); for (int i = 0; i < pits->nMaxPits; i++) { - tTrackOwnPit *act_pit = &pits->driversPits[i]; + const tTrackOwnPit *act_pit = &pits->driversPits[i]; osgLoader loader; diff --git a/src/modules/graphic/osggraph/Scenery/OsgScenery.cpp b/src/modules/graphic/osggraph/Scenery/OsgScenery.cpp index f542c808c..2cd14ca1b 100644 --- a/src/modules/graphic/osggraph/Scenery/OsgScenery.cpp +++ b/src/modules/graphic/osggraph/Scenery/OsgScenery.cpp @@ -69,7 +69,7 @@ SDScenery::~SDScenery(void) } } -void SDScenery::LoadScene(tTrack *track) +void SDScenery::LoadScene(const tTrack *track) { void *hndl = grTrackHandle; const char *acname; diff --git a/src/modules/graphic/osggraph/Scenery/OsgScenery.h b/src/modules/graphic/osggraph/Scenery/OsgScenery.h index b84481270..a29d83a23 100644 --- a/src/modules/graphic/osggraph/Scenery/OsgScenery.h +++ b/src/modules/graphic/osggraph/Scenery/OsgScenery.h @@ -69,7 +69,7 @@ public: // Destructor ~SDPit(void); - void build(tTrack *track); + void build(const tTrack *track); osg::ref_ptr getPit() const { return pit_root; } }; @@ -89,7 +89,7 @@ public: // Destructor ~SDTrackLights(void); - void build(tTrack *track); + void build(const tTrack *track); void update(double currentTime, double totTime, int raceType); osg::ref_ptr getTrackLight() { return _osgtracklight.get(); } @@ -135,7 +135,7 @@ public: /* Destructor */ ~SDScenery(void); - void LoadScene(tTrack *track); + void LoadScene(const tTrack *track); void ShutdownScene(void); void reposition(double X, double Y, double Z); void update_tracklights(double currentTime, double totTime, int raceType); diff --git a/src/modules/graphic/osggraph/Scenery/OsgTrackLight.cpp b/src/modules/graphic/osggraph/Scenery/OsgTrackLight.cpp index c6119bcde..ed3510147 100644 --- a/src/modules/graphic/osggraph/Scenery/OsgTrackLight.cpp +++ b/src/modules/graphic/osggraph/Scenery/OsgTrackLight.cpp @@ -285,7 +285,7 @@ SDTrackLights::~SDTrackLights(void) if (internal) delete internal; } -void SDTrackLights::build(tTrack *track) +void SDTrackLights::build(const tTrack *track) { if (internal) delete internal;