llsurfacepatch.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLSURFACEPATCH_H
00033 #define LL_LLSURFACEPATCH_H
00034 
00035 #include "v3math.h"
00036 #include "v3dmath.h"
00037 #include "llmemory.h"
00038 
00039 class LLSurface;
00040 class LLVOSurfacePatch;
00041 class LLVector2;
00042 class LLColor4U;
00043 class LLAgent;
00044 
00045 // A patch shouldn't know about its visibility since that really depends on the 
00046 // camera that is looking (or not looking) at it.  So, anything about a patch
00047 // that is specific to a camera should be in the struct below.
00048 struct LLPatchVisibilityInfo
00049 {
00050         BOOL mbIsVisible;
00051         F32 mDistance;                  // Distance from camera
00052         S32 mRenderLevel;
00053         U32 mRenderStride;
00054 };
00055 
00056 
00057 
00058 class LLSurfacePatch 
00059 {
00060 public:
00061         LLSurfacePatch();
00062         ~LLSurfacePatch();
00063 
00064         void reset(const U32 id);
00065         void connectNeighbor(LLSurfacePatch *neighborp, const U32 direction);
00066         void disconnectNeighbor(LLSurface *surfacep);
00067 
00068         void setNeighborPatch(const U32 direction, LLSurfacePatch *neighborp);
00069         LLSurfacePatch *getNeighborPatch(const U32 direction) const;
00070 
00071         void colorPatch(const U8 r, const U8 g, const U8 b);
00072 
00073         BOOL updateTexture();
00074 
00075         void updateVerticalStats();
00076         void updateCompositionStats();
00077         void updateNormals();
00078 
00079         void updateEastEdge();
00080         void updateNorthEdge();
00081 
00082         void updateCameraDistanceRegion( const LLVector3 &pos_region);
00083         void updateVisibility();
00084 
00085         void dirtyZ(); // Dirty the z values of this patch
00086         void setHasReceivedData();
00087         BOOL getHasReceivedData() const;
00088 
00089         F32 getDistance() const;
00090         F32 getMaxZ() const;
00091         F32 getMinZ() const;
00092         F32 getMeanComposition() const;
00093         F32 getMinComposition() const;
00094         F32 getMaxComposition() const;
00095         const LLVector3 &getCenterRegion() const;
00096         const U64 &getLastUpdateTime() const;
00097         LLSurface *getSurface() const { return mSurfacep; }
00098         LLVector3 getPointAgent(const U32 x, const U32 y) const; // get the point at the offset.
00099         LLVector2 getTexCoords(const U32 x, const U32 y) const;
00100 
00101         void calcNormal(const U32 x, const U32 y, const U32 stride);
00102         const LLVector3 &getNormal(const U32 x, const U32 y) const;
00103 
00104         void eval(const U32 x, const U32 y, const U32 stride,
00105                                 LLVector3 *vertex, LLVector3 *normal, LLVector2 *tex0, LLVector2 *tex1);
00106         
00107         
00108 
00109         LLVector3 getOriginAgent() const;
00110         const LLVector3d &getOriginGlobal() const;
00111         void setOriginGlobal(const LLVector3d &origin_global);
00112         
00113         // connectivity -- each LLPatch points at 5 neighbors (or NULL)
00114         // +---+---+---+
00115         // |   | 2 | 5 |
00116         // +---+---+---+
00117         // | 3 | 0 | 1 |
00118         // +---+---+---+
00119         // | 6 | 4 |   |
00120         // +---+---+---+
00121 
00122 
00123         BOOL getVisible() const;
00124         U32 getRenderStride() const;
00125         S32 getRenderLevel() const;
00126 
00127         void setSurface(LLSurface *surfacep);
00128         void setDataZ(F32 *data_z)                                      { mDataZ = data_z; }
00129         void setDataNorm(LLVector3 *data_norm)          { mDataNorm = data_norm; }
00130         F32 *getDataZ() const                                           { return mDataZ; }
00131 
00132         void dirty();                   // Mark this surface patch as dirty...
00133         void clearDirty()                                                       { mDirty = FALSE; }
00134 
00135         void clearVObj();
00136 
00137 public:
00138         BOOL mHasReceivedData;  // has the patch EVER received height data?
00139         BOOL mSTexUpdate;               // Does the surface texture need to be updated?
00140 
00141 protected:
00142         LLSurfacePatch *mNeighborPatches[8]; // Adjacent patches
00143         BOOL mNormalsInvalid[9];  // Which normals are invalid
00144 
00145         BOOL mDirty;
00146         BOOL mDirtyZStats;
00147         BOOL mHeightsGenerated;
00148 
00149         U32 mDataOffset;
00150         F32 *mDataZ;
00151         LLVector3 *mDataNorm;
00152 
00153         // Pointer to the LLVOSurfacePatch object which is used in the new renderer.
00154         LLPointer<LLVOSurfacePatch> mVObjp;
00155 
00156         // All of the camera-dependent stuff should be in its own structure...
00157         LLPatchVisibilityInfo mVisInfo;
00158 
00159         // pointers to beginnings of patch data fields
00160         LLVector3d mOriginGlobal;
00161         LLVector3 mOriginRegion;
00162 
00163 
00164         // height field stats
00165         LLVector3 mCenterRegion; // Center in region-local coords
00166         F32 mMinZ, mMaxZ, mMeanZ;
00167         F32 mRadius;
00168 
00169         F32 mMinComposition;
00170         F32 mMaxComposition;
00171         F32 mMeanComposition;
00172 
00173         U8 mConnectedEdge;              // This flag is non-zero iff patch is on at least one edge 
00174                                                         // of LLSurface that is "connected" to another LLSurface
00175         U64 mLastUpdateTime;    // Time patch was last updated
00176 
00177         LLSurface *mSurfacep; // Pointer to "parent" surface
00178 };
00179 
00180 
00181 #endif // LL_LLSURFACEPATCH_H

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