@@ -60,9 +60,12 @@ static const S32 ONE_LESS_THAN_NEIGHBOR = -1;
6060const S32 ABOVE_WATERLINE_ALPHA = 32 ; // The alpha of water when the land elevation is above the waterline.
6161
6262class LLViewerRegion ;
63- class LLSurfacePatch ;
6463class LLBitPack ;
6564class LLGroupHeader ;
65+ class LLSurfacePatch ;
66+
67+ typedef std::shared_ptr<LLSurfacePatch> surface_patch_ref;
68+ typedef std::weak_ptr<LLSurfacePatch> surface_patch_weak_ref;
6669
6770class LLSurface
6871{
@@ -111,9 +114,9 @@ class LLSurface
111114 F32 resolveHeightGlobal (const LLVector3d &position_global) const ;
112115 LLVector3 resolveNormalGlobal (const LLVector3d& v) const ; // Returns normal to surface
113116
114- LLSurfacePatch * resolvePatchRegion (const F32 x, const F32 y) const ;
115- LLSurfacePatch * resolvePatchRegion (const LLVector3 &position_region) const ;
116- LLSurfacePatch * resolvePatchGlobal (const LLVector3d &position_global) const ;
117+ const surface_patch_ref& resolvePatchRegion (const F32 x, const F32 y) const ;
118+ const surface_patch_ref& resolvePatchRegion (const LLVector3 &position_region) const ;
119+ const surface_patch_ref& resolvePatchGlobal (const LLVector3d &position_global) const ;
117120
118121 // Update methods (called during idle, normally)
119122 BOOL idleUpdate (F32 max_update_time);
@@ -136,7 +139,7 @@ class LLSurface
136139
137140 void dirtyAllPatches (); // Use this to dirty all patches when changing terrain parameters
138141
139- void dirtySurfacePatch (LLSurfacePatch * patchp);
142+ void dirtySurfacePatch (const surface_patch_ref& patchp);
140143 LLVOWater *getWaterObj () { return mWaterObjp ; }
141144
142145 static void setTextureSize (const S32 texture_size);
@@ -155,8 +158,6 @@ class LLSurface
155158 F32 mOOGridsPerEdge ; // Inverse of grids per edge
156159
157160 S32 mPatchesPerEdge ; // Number of patches on one side of a region
158- S32 mNumberOfPatches ; // Total number of patches
159-
160161
161162 // Each surface points at 8 neighbors (or NULL)
162163 // +---+---+---+
@@ -191,19 +192,19 @@ class LLSurface
191192
192193 // F32 updateTexture(LLSurfacePatch *ppatch);
193194
194- LLSurfacePatch * getPatch (const S32 x, const S32 y) const ;
195+ const surface_patch_ref& getPatch (const S32 x, const S32 y) const ;
195196
196197protected:
197198 LLVector3d mOriginGlobal ; // In absolute frame
198- LLSurfacePatch * mPatchList ; // Array of all patches
199+ std::vector< surface_patch_ref > mPatchList ; // Array of all patches
199200
200201 // Array of grid data, mGridsPerEdge * mGridsPerEdge
201202 F32 *mSurfaceZ ;
202203
203204 // Array of grid normals, mGridsPerEdge * mGridsPerEdge
204205 LLVector3 *mNorm ;
205206
206- std::set<LLSurfacePatch * > mDirtyPatchList ;
207+ std::vector< std::pair< U32 , surface_patch_weak_ref > > mDirtyPatchList ;
207208
208209
209210 // The textures should never be directly initialized - use the setter methods!
0 commit comments