llvlmanager.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include "llvlmanager.h"
00035 
00036 #include "indra_constants.h"
00037 #include "bitpack.h"
00038 #include "patch_code.h"
00039 #include "patch_dct.h"
00040 #include "llviewerregion.h"
00041 #include "llframetimer.h"
00042 #include "llagent.h"
00043 #include "llsurface.h"
00044 
00045 LLVLManager gVLManager;
00046 
00047 LLVLManager::~LLVLManager()
00048 {
00049         S32 i;
00050         for (i = 0; i < mPacketData.count(); i++)
00051         {
00052                 delete mPacketData[i];
00053         }
00054         mPacketData.reset();
00055 }
00056 
00057 void LLVLManager::addLayerData(LLVLData *vl_datap, const S32 mesg_size)
00058 {
00059         if (LAND_LAYER_CODE == vl_datap->mType)
00060         {
00061                 mLandBits += mesg_size * 8;
00062         }
00063         else if (WIND_LAYER_CODE == vl_datap->mType)
00064         {
00065                 mWindBits += mesg_size * 8;
00066         }
00067         else if (CLOUD_LAYER_CODE == vl_datap->mType)
00068         {
00069                 mCloudBits += mesg_size * 8;
00070         }
00071         else
00072         {
00073                 llerrs << "Unknown layer type!" << (S32)vl_datap->mType << llendl;
00074         }
00075 
00076         mPacketData.put(vl_datap);
00077 }
00078 
00079 void LLVLManager::unpackData(const S32 num_packets)
00080 {
00081         static LLFrameTimer decode_timer;
00082         
00083         S32 i;
00084         for (i = 0; i < mPacketData.count(); i++)
00085         {
00086                 LLVLData *datap = mPacketData[i];
00087 
00088                 LLBitPack bit_pack(datap->mData, datap->mSize);
00089                 LLGroupHeader goph;
00090 
00091                 decode_patch_group_header(bit_pack, &goph);
00092                 if (LAND_LAYER_CODE == datap->mType)
00093                 {
00094                         datap->mRegionp->getLand().decompressDCTPatch(bit_pack, &goph, FALSE);
00095                 }
00096                 else if (WIND_LAYER_CODE == datap->mType)
00097                 {
00098                         datap->mRegionp->mWind.decompress(bit_pack, &goph);
00099 
00100                 }
00101                 else if (CLOUD_LAYER_CODE == datap->mType)
00102                 {
00103                         datap->mRegionp->mCloudLayer.decompress(bit_pack, &goph);
00104                 }
00105         }
00106 
00107         for (i = 0; i < mPacketData.count(); i++)
00108         {
00109                 delete mPacketData[i];
00110         }
00111         mPacketData.reset();
00112 
00113 }
00114 
00115 void LLVLManager::resetBitCounts()
00116 {
00117         mLandBits = mWindBits = mCloudBits = 0;
00118 }
00119 
00120 S32 LLVLManager::getLandBits() const
00121 {
00122         return mLandBits;
00123 }
00124 
00125 S32 LLVLManager::getWindBits() const
00126 {
00127         return mWindBits;
00128 }
00129 
00130 S32 LLVLManager::getCloudBits() const
00131 {
00132         return mCloudBits;
00133 }
00134 
00135 S32 LLVLManager::getTotalBytes() const
00136 {
00137         return mLandBits + mWindBits + mCloudBits;
00138 }
00139 
00140 void LLVLManager::cleanupData(LLViewerRegion *regionp)
00141 {
00142         S32 cur = 0;
00143         while (cur < mPacketData.count())
00144         {
00145                 if (mPacketData[cur]->mRegionp == regionp)
00146                 {
00147                         delete mPacketData[cur];
00148                         mPacketData.remove(cur);
00149                 }
00150                 else
00151                 {
00152                         cur++;
00153                 }
00154         }
00155 }
00156 
00157 LLVLData::LLVLData(LLViewerRegion *regionp, const S8 type, U8 *data, const S32 size)
00158 {
00159         mType = type;
00160         mData = data;
00161         mRegionp = regionp;
00162         mSize = size;
00163 }
00164 
00165 LLVLData::~LLVLData()
00166 {
00167         delete [] mData;
00168         mData = NULL;
00169         mRegionp = NULL;
00170 }

Generated on Thu Jul 1 06:09:35 2010 for Second Life Viewer by  doxygen 1.4.7