llvlmanager.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /**
  2. * @file llvlmanager.cpp
  3. * @brief LLVLManager class implementation
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewergpl$
  6. *
  7. * Copyright (c) 2002-2009, 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. #include "llviewerprecompiledheaders.h"
  33. #include "llvlmanager.h"
  34. #include "llbitpack.h"
  35. #include "llpatch_code.h"
  36. #include "llagent.h"
  37. #include "llsurface.h"
  38. #include "llviewerregion.h"
  39. LLVLManager gVLManager;
  40. LLVLManager::LLVLManager()
  41. : mLandBits(0),
  42. mWindBits(0),
  43. mCloudBits(0)
  44. {
  45. }
  46. LLVLManager::~LLVLManager()
  47. {
  48. for (S32 i = 0, count = mPacketData.size(); i < count; ++i)
  49. {
  50. delete mPacketData[i];
  51. }
  52. mPacketData.clear();
  53. }
  54. void LLVLManager::addLayerData(LLVLData* vl_datap, S32 mesg_size)
  55. {
  56. S8 type = vl_datap->mType;
  57. if (type == LAND_LAYER_CODE || type == AURORA_LAND_LAYER_CODE)
  58. {
  59. mLandBits += mesg_size * 8;
  60. }
  61. else if (type == WIND_LAYER_CODE || type == AURORA_WIND_LAYER_CODE)
  62. {
  63. mWindBits += mesg_size * 8;
  64. }
  65. else if (type == CLOUD_LAYER_CODE || type == AURORA_CLOUD_LAYER_CODE)
  66. {
  67. mCloudBits += mesg_size * 8;
  68. }
  69. else if (type != WATER_LAYER_CODE && type != AURORA_WATER_LAYER_CODE)
  70. {
  71. llwarns_once << "Unknown layer type: " << type << " (" << (S32)type
  72. << ")" << llendl;
  73. }
  74. mPacketData.push_back(vl_datap);
  75. }
  76. void LLVLManager::unpackData(S32 num_packets)
  77. {
  78. S32 count = mPacketData.size();
  79. for (S32 i = 0; i < count; ++i)
  80. {
  81. LLVLData* datap = mPacketData[i];
  82. if (!datap) continue; // Paranoia
  83. LLBitPack bit_pack(datap->mData, datap->mSize);
  84. LLGroupHeader goph;
  85. decode_patch_group_header(bit_pack, &goph);
  86. S8 type = datap->mType;
  87. if (type == LAND_LAYER_CODE)
  88. {
  89. datap->mRegionp->getLand().decompressDCTPatch(bit_pack, &goph,
  90. false);
  91. }
  92. else if (type == AURORA_LAND_LAYER_CODE)
  93. {
  94. datap->mRegionp->getLand().decompressDCTPatch(bit_pack, &goph,
  95. true);
  96. }
  97. else if (type == WIND_LAYER_CODE || type == AURORA_WIND_LAYER_CODE)
  98. {
  99. datap->mRegionp->mWind.decompress(bit_pack, &goph);
  100. }
  101. else if (type == CLOUD_LAYER_CODE || type == AURORA_CLOUD_LAYER_CODE)
  102. {
  103. datap->mRegionp->mCloudLayer.decompress(bit_pack, &goph);
  104. }
  105. }
  106. for (S32 i = 0; i < count; ++i)
  107. {
  108. delete mPacketData[i];
  109. }
  110. mPacketData.clear();
  111. }
  112. void LLVLManager::cleanupData(LLViewerRegion* regionp)
  113. {
  114. size_t cur = 0;
  115. while (cur < mPacketData.size())
  116. {
  117. if (mPacketData[cur]->mRegionp == regionp)
  118. {
  119. delete mPacketData[cur];
  120. mPacketData.erase(mPacketData.begin() + cur);
  121. }
  122. else
  123. {
  124. ++cur;
  125. }
  126. }
  127. }