Skip to content

Commit 34f6ea4

Browse files
committed
Rework LLSurface[Patch]. Abuse weak_ptr for now. Rewrote connectNeighbor. LLSurfacePatch no longer calls parent LLSurface with this poiter, instead parent surface just handles return value and controls its own behavior [Requred for weak_ptr/shared_ptr change.
1 parent d8c4db1 commit 34f6ea4

10 files changed

Lines changed: 375 additions & 571 deletions

indra/newview/llsurface.cpp

Lines changed: 181 additions & 406 deletions
Large diffs are not rendered by default.

indra/newview/llsurface.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,12 @@ static const S32 ONE_LESS_THAN_NEIGHBOR = -1;
6060
const S32 ABOVE_WATERLINE_ALPHA = 32; // The alpha of water when the land elevation is above the waterline.
6161

6262
class LLViewerRegion;
63-
class LLSurfacePatch;
6463
class LLBitPack;
6564
class 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

6770
class 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

196197
protected:
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

Comments
 (0)