llenvironment.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. /**
  2. * @file llenvironment.h
  3. * @brief Extended environment manager class declaration.
  4. *
  5. * $LicenseInfo:firstyear=2018&license=viewergpl$
  6. *
  7. * Copyright (c) 2002-2019, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_ENVIRONMENT_H
  33. #define LL_ENVIRONMENT_H
  34. #include <array>
  35. #include "llglslshader.h"
  36. #include "llsd.h"
  37. #include "llsettingsdaycycle.h"
  38. #include "llsettingssky.h"
  39. #include "llsettingswater.h"
  40. class LLAtmosModelSettings;
  41. class LLParcel;
  42. class LLViewerCamera;
  43. // Defined to 0 since we do not use EE fixed sky settings (which would not
  44. // allow to set the time in the local environment editor, since they do not
  45. // include a day cycle at all), but instead the genuine Windlight Default day
  46. // cycle.
  47. #define LL_USE_FIXED_SKY_SETTINGS_FOR_DEFAULT_TIME 0
  48. class LLEnvironment
  49. {
  50. protected:
  51. LOG_CLASS(LLEnvironment);
  52. public:
  53. LLEnvironment();
  54. // These methods are called in llappviewer.cpp only
  55. void initClass();
  56. void cleanupClass();
  57. class EnvironmentInfo
  58. {
  59. public:
  60. EnvironmentInfo();
  61. typedef std::shared_ptr<EnvironmentInfo> ptr_t;
  62. typedef std::array<std::string, 5> namelist_t;
  63. static ptr_t extract(LLSD);
  64. static ptr_t extractLegacy(LLSD);
  65. public:
  66. LLUUID mRegionId;
  67. LLUUID mAssetId;
  68. S32 mEnvVersion;
  69. S32 mParcelId;
  70. S64 mDayLength;
  71. S64 mDayOffset;
  72. size_t mDayHash;
  73. LLSettingsDay::ptr_t mDayCycle;
  74. std::array<F32, 4> mAltitudes;
  75. std::string mDayCycleName;
  76. namelist_t mNameList;
  77. bool mIsDefault;
  78. bool mIsLegacy;
  79. };
  80. typedef EnvironmentInfo::ptr_t envinfo_ptr_t;
  81. enum EEnvSelection
  82. {
  83. ENV_EDIT = 0,
  84. ENV_LOCAL,
  85. ENV_PUSH,
  86. ENV_PARCEL,
  87. ENV_REGION,
  88. ENV_DEFAULT,
  89. ENV_END,
  90. ENV_CURRENT = -1,
  91. ENV_NONE = -2
  92. };
  93. // Using an enum here instead of static const or constexpr variables makes
  94. // it easier should we add more values later. HB
  95. enum EETransition
  96. {
  97. TRANSITION_INSTANT = 0,
  98. TRANSITION_FAST = 1,
  99. TRANSITION_DEFAULT = 5,
  100. TRANSITION_SLOW = 10,
  101. TRANSITION_ALTITUDE = 5
  102. };
  103. typedef boost::signals2::connection connection_t;
  104. typedef boost::signals2::signal<void(EEnvSelection, S32)> env_changed_signal_t;
  105. typedef env_changed_signal_t::slot_type env_changed_fn;
  106. typedef std::pair<LLSettingsSky::ptr_t, LLSettingsWater::ptr_t> fixed_env_t;
  107. typedef boost::function<void(S32, envinfo_ptr_t)> env_apply_fn;
  108. typedef std::array<F32, 4> altitude_list_t;
  109. typedef std::vector<F32> altitudes_vect_t;
  110. LL_INLINE bool canEdit() const { return true; }
  111. static bool canAgentUpdateParcelEnvironment(LLParcel* parcel = NULL);
  112. static bool canAgentUpdateRegionEnvironment();
  113. static void setSunrise();
  114. static void setMidday();
  115. static void setMiddayPBR();
  116. static void setSunset();
  117. static void setMidnight();
  118. static void setRegion();
  119. void setFixedTimeOfDay(F32 position, EEnvSelection env = ENV_LOCAL,
  120. S32 env_version = NO_VERSION);
  121. void setLocalEnvFromDefaultWindlightDay(F32 position = -1.f);
  122. LL_INLINE LLSettingsDay::ptr_t getCurrentDay() const
  123. {
  124. return mCurrentEnvironment->getDayCycle();
  125. }
  126. const LLSettingsSky::ptr_t& getCurrentSky() const;
  127. const LLSettingsWater::ptr_t& getCurrentWater() const;
  128. void update();
  129. void setSelectedEnvironment(EEnvSelection env,
  130. F64 transition = (F64)TRANSITION_DEFAULT,
  131. bool forced = false);
  132. LL_INLINE EEnvSelection getSelectedEnvironment() const
  133. {
  134. return mSelectedEnvironment;
  135. }
  136. // Apply current settings to given shader
  137. void updateShaderUniforms(LLGLSLShader* shaderp);
  138. // Apply current sky settings to given shader
  139. void updateShaderSkyUniforms(LLGLSLShader* shaderp);
  140. // Prepare settings to be applied to shaders (call whenever settings are
  141. // updated)
  142. void updateSettingsUniforms();
  143. // Flags uniforms for shaders using environment settings as dirty. HB
  144. void dirtyUniforms();
  145. static void updateGLVariablesForSettings(LLShaderUniforms* uniforms,
  146. const LLSettingsBase::ptr_t& setting);
  147. bool hasEnvironment(EEnvSelection env);
  148. void setCurrentEnvironmentSelection(EEnvSelection env);
  149. void setEnvironment(EEnvSelection env, const LLSettingsDay::ptr_t& dayp,
  150. S32 daylength, S32 dayoffset,
  151. S32 env_version = NO_VERSION);
  152. void setEnvironment(EEnvSelection env, fixed_env_t fixed,
  153. S32 env_version = NO_VERSION);
  154. void setEnvironment(EEnvSelection env, const LLSettingsBase::ptr_t& fixed,
  155. S32 env_version = NO_VERSION);
  156. LL_INLINE void setEnvironment(EEnvSelection env,
  157. const LLSettingsSky::ptr_t& skyp,
  158. S32 env_version = NO_VERSION)
  159. {
  160. setEnvironment(env, fixed_env_t(skyp, LLSettingsWater::ptr_t()),
  161. env_version);
  162. }
  163. LL_INLINE void setEnvironment(EEnvSelection env,
  164. const LLSettingsWater::ptr_t& waterp,
  165. S32 env_version = NO_VERSION)
  166. {
  167. setEnvironment(env, fixed_env_t(LLSettingsSky::ptr_t(), waterp),
  168. env_version);
  169. }
  170. LL_INLINE void setEnvironment(EEnvSelection env,
  171. const LLSettingsSky::ptr_t& fixeds,
  172. const LLSettingsWater::ptr_t& fixedw,
  173. S32 env_version = NO_VERSION)
  174. {
  175. setEnvironment(env, fixed_env_t(fixeds, fixedw), env_version);
  176. }
  177. void setEnvironment(EEnvSelection env, const LLUUID& asset_id,
  178. S32 transition = TRANSITION_DEFAULT);
  179. void setSharedEnvironment();
  180. void clearEnvironment(EEnvSelection env);
  181. LLSettingsDay::ptr_t getEnvironmentDay(EEnvSelection env);
  182. S32 getEnvironmentDayLength(EEnvSelection env);
  183. S32 getEnvironmentDayOffset(EEnvSelection env);
  184. fixed_env_t getEnvironmentFixed(EEnvSelection env, bool resolve = false);
  185. LL_INLINE LLSettingsSky::ptr_t getEnvironmentFixedSky(EEnvSelection env,
  186. bool resolve = false)
  187. {
  188. return getEnvironmentFixed(env, resolve).first;
  189. }
  190. LL_INLINE LLSettingsWater::ptr_t getEnvironmentFixedWater(EEnvSelection env,
  191. bool resolve = false)
  192. {
  193. return getEnvironmentFixed(env, resolve).second;
  194. }
  195. void updateEnvironment(F64 transition = (F64)TRANSITION_DEFAULT,
  196. bool forced = false);
  197. LL_INLINE LLVector2 getCloudScrollDelta() const { return mCloudScrollDelta; }
  198. LL_INLINE void pauseCloudScroll() { mCloudScrollPaused = true; }
  199. LL_INLINE void resumeCloudScroll() { mCloudScrollPaused = false; }
  200. LL_INLINE bool isCloudScrollPaused() const { return mCloudScrollPaused; }
  201. F32 getCamHeight() const;
  202. bool getIsSunUp() const;
  203. bool getIsMoonUp() const;
  204. LL_INLINE static void addBeaconsUser() { ++sBeaconsUsers; }
  205. static void delBeaconsUser();
  206. // Returns either sun or moon direction (depending on which is up and
  207. // stronger). Light direction in +x right, +z up, +y at internal coord sys.
  208. LLVector3 getLightDirection() const;
  209. LLVector3 getSunDirection() const;
  210. LLVector3 getMoonDirection() const;
  211. // These methods return light direction converted to CFR coord system
  212. LL_INLINE LLVector4 getLightDirectionCFR() const
  213. {
  214. return toCFR(getLightDirection());
  215. }
  216. LL_INLINE LLVector4 getSunDirectionCFR() const
  217. {
  218. return toCFR(getSunDirection());
  219. }
  220. LL_INLINE LLVector4 getMoonDirectionCFR() const
  221. {
  222. return toCFR(getMoonDirection());
  223. }
  224. // Returns light direction converted to OGL coord system and clamped above
  225. // -0.1f in Y to avoid render artifacts in sky shaders.
  226. LLVector4 getClampedLightNorm() const;
  227. LLVector4 getClampedSunNorm() const;
  228. LLVector4 getClampedMoonNorm() const;
  229. // Returns light direction converted to OGL coord system and rotated by
  230. // last cam yaw needed by water rendering shaders
  231. LLVector4 getRotatedLightNorm() const;
  232. static LLSettingsWater::ptr_t createWaterFromLegacyPreset(const std::string& filename,
  233. LLSD& messages);
  234. static LLSettingsSky::ptr_t createSkyFromLegacyPreset(const std::string& filename,
  235. LLSD& messages);
  236. static LLSettingsDay::ptr_t createDayCycleFromLegacyPreset(const std::string& filename,
  237. LLSD& messages);
  238. // Constructs a new day cycle based on the environment, replacing either
  239. // the water or the sky tracks.
  240. LLSettingsDay::ptr_t createDayCycleFromEnvironment(EEnvSelection env,
  241. LLSettingsBase::ptr_t settings);
  242. LL_INLINE F32 getProgress() const
  243. {
  244. return mCurrentEnvironment ? mCurrentEnvironment->getProgress() : -1.f;
  245. }
  246. LL_INLINE F32 getRegionProgress() const
  247. {
  248. return mEnvironments[ENV_REGION] ?
  249. mEnvironments[ENV_REGION]->getProgress() : -1.f;
  250. }
  251. // Only used on legacy regions, to better sync the viewer with other
  252. // agents
  253. void adjustRegionOffset(F32 adjust);
  254. LL_INLINE connection_t setEnvironmentChanged(env_changed_fn cb)
  255. {
  256. return mSignalEnvChanged.connect(cb);
  257. }
  258. void updateRegion(const LLUUID& asset_id, const std::string& display_name,
  259. S32 track_num, S32 day_length, S32 day_offset, U32 flags,
  260. altitudes_vect_t altitudes = altitudes_vect_t(),
  261. env_apply_fn cb = env_apply_fn());
  262. void updateRegion(const LLSettingsDay::ptr_t& dayp, S32 day_length,
  263. S32 day_offset,
  264. altitudes_vect_t altitudes = altitudes_vect_t(),
  265. env_apply_fn cb = env_apply_fn());
  266. void updateRegion(const LLSettingsSky::ptr_t& skyp, S32 day_length,
  267. S32 day_offset,
  268. altitudes_vect_t altitudes = altitudes_vect_t(),
  269. env_apply_fn cb = env_apply_fn());
  270. void updateRegion(const LLSettingsWater::ptr_t& waterp, S32 day_length,
  271. S32 day_offset,
  272. altitudes_vect_t altitudes = altitudes_vect_t(),
  273. env_apply_fn cb = env_apply_fn());
  274. void resetRegion(env_apply_fn cb = env_apply_fn());
  275. void requestParcel(S32 parcel_id, env_apply_fn cb = env_apply_fn());
  276. void updateParcel(S32 parcel_id, const LLUUID& asset_id,
  277. const std::string& display_name, S32 track_num,
  278. S32 day_length, S32 day_offset, U32 flags,
  279. altitudes_vect_t altitudes = altitudes_vect_t(),
  280. env_apply_fn cb = env_apply_fn());
  281. void updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t& dayp,
  282. S32 track_num, S32 day_length, S32 day_offset,
  283. altitudes_vect_t altitudes = altitudes_vect_t(),
  284. env_apply_fn cb = env_apply_fn());
  285. void updateParcel(S32 parcel_id, const LLSettingsDay::ptr_t& dayp,
  286. S32 day_length, S32 day_offset,
  287. altitudes_vect_t altitudes = altitudes_vect_t(),
  288. env_apply_fn cb = env_apply_fn());
  289. void updateParcel(S32 parcel_id, const LLSettingsSky::ptr_t& skyp,
  290. S32 day_length, S32 day_offset,
  291. altitudes_vect_t altitudes = altitudes_vect_t(),
  292. env_apply_fn cb = env_apply_fn());
  293. void updateParcel(S32 parcel_id, const LLSettingsWater::ptr_t& waterp,
  294. S32 day_length, S32 day_offset,
  295. altitudes_vect_t altitudes = altitudes_vect_t(),
  296. env_apply_fn cb = env_apply_fn());
  297. void resetParcel(S32 parcel_id, env_apply_fn cb = env_apply_fn());
  298. void selectAgentEnvironment();
  299. static void requestRegion(env_apply_fn cb = env_apply_fn());
  300. S32 calculateSkyTrackForAltitude(F64 altitude);
  301. LL_INLINE const altitude_list_t& getRegionAltitudes() const
  302. {
  303. return mTrackAltitudes;
  304. }
  305. void handleEnvironmentPush(LLSD& message);
  306. class DayInstance : public std::enable_shared_from_this<DayInstance>
  307. {
  308. public:
  309. DayInstance(EEnvSelection env);
  310. virtual ~DayInstance() {}
  311. enum EInstanceType
  312. {
  313. TYPE_INVALID,
  314. TYPE_FIXED,
  315. TYPE_CYCLED
  316. };
  317. typedef std::shared_ptr<DayInstance> ptr_t;
  318. virtual ptr_t clone() const;
  319. virtual bool applyTimeDelta(F64 delta);
  320. virtual void setDay(const LLSettingsDay::ptr_t& dayp, S32 daylength,
  321. S32 dayoffset);
  322. virtual bool setSky(const LLSettingsSky::ptr_t& skyp);
  323. virtual void setWater(const LLSettingsWater::ptr_t& waterp);
  324. void initialize();
  325. bool isInitialized();
  326. void clear();
  327. void setSkyTrack(S32 trackno);
  328. const LL_INLINE LLSettingsDay::ptr_t& getDayCycle() const
  329. {
  330. return mDayCycle;
  331. }
  332. const LL_INLINE LLSettingsSky::ptr_t& getSky() const
  333. {
  334. return mSky;
  335. }
  336. const LL_INLINE LLSettingsWater::ptr_t& getWater() const
  337. {
  338. return mWater;
  339. }
  340. LL_INLINE S32 getDayLength() const { return mDayLength; }
  341. LL_INLINE S32 getDayOffset() const { return mDayOffset; }
  342. LL_INLINE S32 getSkyTrack() const { return mSkyTrack; }
  343. LL_INLINE void setDayOffset(F64 offset)
  344. {
  345. mDayOffset = offset;
  346. animate();
  347. }
  348. virtual void animate();
  349. void setBlenders(const LLSettingsBlender::ptr_t& skyblend,
  350. const LLSettingsBlender::ptr_t& waterblend);
  351. LL_INLINE EEnvSelection getEnvironmentSelection() const
  352. {
  353. return mEnv;
  354. }
  355. LL_INLINE void setEnvironmentSelection(EEnvSelection env)
  356. {
  357. mEnv = env;
  358. }
  359. F32 getProgress() const;
  360. LL_INLINE void setFlags(U32 flag) { mAnimateFlags |= flag; }
  361. LL_INLINE void clearFlags(U32 flag) { mAnimateFlags &= ~flag; }
  362. protected:
  363. F32 secondsToKeyframe(S32 seconds);
  364. public:
  365. static constexpr U32 NO_ANIMATE_SKY = 1;
  366. static constexpr U32 NO_ANIMATE_WATER = 2;
  367. protected:
  368. S32 mSkyTrack;
  369. S32 mDayLength;
  370. S32 mDayOffset;
  371. S32 mLastTrackAltitude;
  372. U32 mAnimateFlags;
  373. LLSettingsDay::ptr_t mDayCycle;
  374. LLSettingsSky::ptr_t mSky;
  375. LLSettingsWater::ptr_t mWater;
  376. LLSettingsBlender::ptr_t mBlenderSky;
  377. LLSettingsBlender::ptr_t mBlenderWater;
  378. EEnvSelection mEnv;
  379. EInstanceType mType;
  380. bool mInitialized;
  381. };
  382. class DayTransition : public DayInstance
  383. {
  384. public:
  385. DayTransition(const LLSettingsSky::ptr_t& skystart,
  386. const LLSettingsWater::ptr_t& waterstart,
  387. DayInstance::ptr_t& end, S32 time);
  388. ~DayTransition() override {}
  389. bool applyTimeDelta(F64 delta) override;
  390. void animate() override;
  391. protected:
  392. LLSettingsSky::ptr_t mStartSky;
  393. LLSettingsWater::ptr_t mStartWater;
  394. DayInstance::ptr_t mNextInstance;
  395. S32 mTransitionTime;
  396. };
  397. DayInstance::ptr_t getSelectedEnvironmentInstance();
  398. DayInstance::ptr_t getSharedEnvironmentInstance();
  399. private:
  400. LL_INLINE static LLVector4 toCFR(const LLVector3& vec)
  401. {
  402. return LLVector4(vec.mV[1], vec.mV[0], vec.mV[2], 0.f);
  403. }
  404. LL_INLINE static LLVector4 toLightNorm(const LLVector3& vec)
  405. {
  406. return LLVector4(vec.mV[1], vec.mV[2], vec.mV[0], 0.f);
  407. }
  408. typedef std::array<DayInstance::ptr_t, ENV_END> InstanceArray_t;
  409. DayInstance::ptr_t getEnvironmentInstance(EEnvSelection env,
  410. bool create = false);
  411. void updateCloudScroll();
  412. void onRegionChange();
  413. void onParcelChange();
  414. struct UpdateInfo
  415. {
  416. typedef std::shared_ptr<UpdateInfo> ptr_t;
  417. UpdateInfo(LLSettingsDay::ptr_t pday, S32 day_length, S32 day_offset,
  418. altitudes_vect_t altitudes)
  419. : mDayp(pday),
  420. mSettingsAsset(),
  421. mDayLength(day_length),
  422. mDayOffset(day_offset),
  423. mAltitudes(altitudes),
  424. mFlags(0)
  425. {
  426. if (mDayp)
  427. {
  428. mDayName = mDayp->getName();
  429. }
  430. }
  431. UpdateInfo(const LLUUID& settings_asset, const std::string& name,
  432. S32 day_length, S32 day_offset, altitudes_vect_t altitudes,
  433. U32 flags)
  434. : mSettingsAsset(settings_asset),
  435. mDayLength(day_length),
  436. mDayOffset(day_offset),
  437. mAltitudes(altitudes),
  438. mDayName(name),
  439. mFlags(flags)
  440. {
  441. }
  442. LLUUID mSettingsAsset;
  443. S32 mDayLength;
  444. S32 mDayOffset;
  445. U32 mFlags;
  446. LLSettingsDay::ptr_t mDayp;
  447. altitudes_vect_t mAltitudes;
  448. std::string mDayName;
  449. };
  450. void coroRequestEnvironment(S32 parcel_id, env_apply_fn apply);
  451. void coroUpdateEnvironment(S32 parcel_id, S32 track_no,
  452. UpdateInfo::ptr_t updates, env_apply_fn apply);
  453. void coroResetEnvironment(S32 parcel_id, S32 track_no, env_apply_fn apply);
  454. void recordEnvironment(S32 parcel_id, envinfo_ptr_t environment,
  455. F64 transition);
  456. void onAgentPositionHasChanged(const LLVector3& localpos);
  457. void onSetEnvAssetLoaded(EEnvSelection env, S32 transition,
  458. const LLUUID& asset_id,
  459. LLSettingsBase::ptr_t settings, S32 status);
  460. void onUpdateParcelAssetLoaded(const LLUUID& asset_id,
  461. LLSettingsBase::ptr_t settings, S32 status,
  462. S32 parcel_id, S32 day_length,
  463. S32 day_offset, altitudes_vect_t altitudes);
  464. void handleEnvironmentPushClear(const LLUUID& experience_id, LLSD& message,
  465. F32 transition);
  466. void handleEnvironmentPushFull(const LLUUID& experience_id, LLSD& message,
  467. F32 transition);
  468. void handleEnvironmentPushPartial(const LLUUID& experience_id,
  469. LLSD& message, F32 transition);
  470. void clearExperienceEnvironment(const LLUUID& experience_id,
  471. F64 transition_time);
  472. void setExperienceEnvironment(const LLUUID& experience_id,
  473. const LLUUID& asset_id, F32 transition_time);
  474. void setExperienceEnvironment(const LLUUID& experience_id,
  475. LLSD environment, F32 transition_time);
  476. void onSetExperienceEnvAssetLoaded(const LLUUID& experience_id,
  477. LLSettingsBase::ptr_t setting,
  478. F32 transition_time, S32 status);
  479. bool listenExperiencePump(const LLSD& message);
  480. public:
  481. #if LL_USE_FIXED_SKY_SETTINGS_FOR_DEFAULT_TIME
  482. static const LLUUID KNOWN_SKY_SUNRISE;
  483. static const LLUUID KNOWN_SKY_MIDDAY;
  484. static const LLUUID KNOWN_SKY_LEGACY_MIDDAY;
  485. static const LLUUID KNOWN_SKY_PBR_MIDDAY;
  486. static const LLUUID KNOWN_SKY_SUNSET;
  487. static const LLUUID KNOWN_SKY_MIDNIGHT;
  488. #endif
  489. static constexpr S32 NO_TRACK = -1;
  490. // For viewer sided change, like ENV_LOCAL. -3 since -1 and -2 are taken by
  491. // parcel initial server/viewer version
  492. static constexpr S32 NO_VERSION = -3;
  493. // For cleanups
  494. static constexpr S32 VERSION_CLEANUP = -4;
  495. static constexpr F32 SUN_DELTA_YAW = F_PI;
  496. private:
  497. F32 mLastCamYaw;
  498. S32 mCurrentTrack;
  499. altitude_list_t mTrackAltitudes;
  500. InstanceArray_t mEnvironments;
  501. EEnvSelection mSelectedEnvironment;
  502. DayInstance::ptr_t mCurrentEnvironment;
  503. LLSettingsSky::ptr_t mSelectedSky;
  504. LLSettingsWater::ptr_t mSelectedWater;
  505. LLSettingsDay::ptr_t mSelectedDay;
  506. env_changed_signal_t mSignalEnvChanged;
  507. connection_t mRegionChangedConnection;
  508. connection_t mParcelChangedConnection;
  509. connection_t mPositionChangedConnection;
  510. LLSD mSkyOverrides;
  511. LLSD mWaterOverrides;
  512. // Cached uniform values from LLSD values
  513. LLShaderUniforms mWaterUniforms[LLGLSLShader::SG_COUNT];
  514. LLShaderUniforms mSkyUniforms[LLGLSLShader::SG_COUNT];
  515. // Cumulative cloud delta
  516. LLVector2 mCloudScrollDelta;
  517. bool mCloudScrollPaused;
  518. bool mInstanceValid;
  519. static S32 sBeaconsUsers;
  520. };
  521. class LLTrackBlenderLoopingManual : public LLSettingsBlender
  522. {
  523. public:
  524. typedef std::shared_ptr<LLTrackBlenderLoopingManual> ptr_t;
  525. LLTrackBlenderLoopingManual(const LLSettingsBase::ptr_t& target,
  526. const LLSettingsDay::ptr_t& day, S32 trackno);
  527. F64 setPosition(F32 position);
  528. void switchTrack(S32 trackno, F32 position) override;
  529. LL_INLINE S32 getTrack() const { return mTrackNo; }
  530. protected:
  531. LLSettingsDay::track_bound_t getBoundingEntries(F64 position);
  532. F64 getSpanLength(const LLSettingsDay::track_bound_t& bounds) const;
  533. private:
  534. LLSettingsDay::ptr_t mDay;
  535. LLSettingsDay::cycle_track_it_t mEndMarker;
  536. F64 mPosition;
  537. S32 mTrackNo;
  538. };
  539. extern LLEnvironment gEnvironment;
  540. #endif // LL_ENVIRONMENT_H