llviewerparcelmgr.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLVIEWERPARCELMGR_H
00033 #define LL_LLVIEWERPARCELMGR_H
00034 
00035 #include "v3dmath.h"
00036 #include "lldarray.h"
00037 #include "llframetimer.h"
00038 #include "llmemory.h"
00039 #include "llparcelselection.h"
00040 #include "llui.h"
00041 
00042 class LLUUID;
00043 class LLMessageSystem;
00044 class LLParcel;
00045 class LLViewerImage;
00046 class LLViewerRegion;
00047 
00048 // Constants for sendLandOwner
00049 //const U32 NO_NEIGHBOR_JOIN = 0x0;
00050 //const U32 ALL_NEIGHBOR_JOIN = U32(  NORTH_MASK 
00051 //                                                        | SOUTH_MASK 
00052 //                                                        | EAST_MASK 
00053 //                                                        | WEST_MASK);
00054 
00055 const F32 PARCEL_POST_HEIGHT = 0.666f;
00056 //const F32 PARCEL_POST_HEIGHT = 20.f;
00057 
00058 // Specify the type of land transfer taking place
00059 //enum ELandTransferType
00060 //{
00061 //      LTT_RELEASE_LAND = 0x1,
00062 //      LTT_CLAIM_LAND = 0x2,
00063 //      LTT_BUY_LAND = 0x4,
00064 //      LTT_DEED_LAND = 0x8,
00065 //      LTT_FOR_GROUP = 0x16
00066 //};
00067 
00068 // Base class for people who want to "observe" changes in the viewer
00069 // parcel selection.
00070 class LLParcelObserver
00071 {
00072 public:
00073         virtual ~LLParcelObserver() {};
00074         virtual void changed() = 0;
00075 };
00076 
00077 class LLViewerParcelMgr : public LLSingleton<LLViewerParcelMgr>
00078 {
00079 
00080 public:
00081         LLViewerParcelMgr();
00082         ~LLViewerParcelMgr();
00083 
00084         static void cleanupGlobals();
00085 
00086         BOOL    selectionEmpty() const;
00087         F32             getSelectionWidth() const       { return F32(mEastNorth.mdV[VX] - mWestSouth.mdV[VX]); }
00088         F32             getSelectionHeight() const      { return F32(mEastNorth.mdV[VY] - mWestSouth.mdV[VY]); }
00089         BOOL    getSelection(LLVector3d &min, LLVector3d &max) { min = mWestSouth; max = mEastNorth; return !selectionEmpty();}
00090         LLViewerRegion* getSelectionRegion();
00091         F32             getDwelling() const { return mSelectedDwell;}
00092 
00093         void    getDisplayInfo(S32* area, S32* claim, S32* rent, BOOL* for_sale, F32* dwell);
00094 
00095         // Returns selected area
00096         S32 getSelectedArea() const;
00097 
00098         void resetSegments(U8* segments);
00099 
00100         // write a rectangle's worth of line segments into the highlight array
00101         void writeHighlightSegments(F32 west, F32 south, F32 east, F32 north);
00102 
00103         // Write highlight segments from a packed bitmap of the appropriate
00104         // parcel.
00105         void writeSegmentsFromBitmap(U8* bitmap, U8* segments);
00106 
00107         void writeAgentParcelFromBitmap(U8* bitmap);
00108 
00109         // Select the collision parcel
00110         void selectCollisionParcel();
00111 
00112         // Select the parcel at a specific point
00113         LLSafeHandle<LLParcelSelection> selectParcelAt(const LLVector3d& pos_global);
00114 
00115         // Take the current rectangle select, and select the parcel contained
00116         // within it.
00117         LLParcelSelectionHandle selectParcelInRectangle();
00118 
00119         // Select a piece of land
00120         LLParcelSelectionHandle selectLand(const LLVector3d &corner1, const LLVector3d &corner2, 
00121                                            BOOL snap_to_parcel);
00122 
00123         // Clear the selection, and stop drawing the highlight.
00124         void    deselectLand();
00125         void    deselectUnused();
00126 
00127         void addObserver(LLParcelObserver* observer);
00128         void removeObserver(LLParcelObserver* observer);
00129         void notifyObservers();
00130 
00131         void setSelectionVisible(BOOL visible) { mRenderSelection = visible; }
00132 
00133         BOOL    isOwnedAt(const LLVector3d& pos_global) const;
00134         BOOL    isOwnedSelfAt(const LLVector3d& pos_global) const;
00135         BOOL    isOwnedOtherAt(const LLVector3d& pos_global) const;
00136         BOOL    isSoundLocal(const LLVector3d &pos_global) const;
00137 
00138         BOOL    canHearSound(const LLVector3d &pos_global) const;
00139 
00140         // Returns a reference counted pointer to current parcel selection.  
00141         // Selection does not change to reflect new selections made by user
00142         // Use this when implementing a task UI that refers to a specific
00143         // selection.
00144         LLParcelSelectionHandle getParcelSelection() const;
00145 
00146         // Returns a reference counted pointer to current parcel selection.
00147         // Pointer tracks whatever the user has currently selected.
00148         // Use this when implementing an inspector UI.
00149         // http://en.wikipedia.org/wiki/Inspector_window
00150         LLParcelSelectionHandle getFloatingParcelSelection() const;
00151 
00152         //LLParcel *getParcelSelection() const;
00153         LLParcel *getAgentParcel() const;
00154 
00155         BOOL    inAgentParcel(const LLVector3d &pos_global) const;
00156 
00157         // Returns a pointer only when it has valid data.
00158         LLParcel*       getHoverParcel() const;
00159 
00160         LLParcel*       getCollisionParcel() const;
00161 
00162         BOOL    agentCanTakeDamage() const;
00163         BOOL    agentCanFly() const;
00164         F32             agentDrawDistance() const;
00165         BOOL    agentCanBuild() const;
00166 
00167         F32             getHoverParcelWidth() const             
00168                                 { return F32(mHoverEastNorth.mdV[VX] - mHoverWestSouth.mdV[VX]); }
00169 
00170         F32             getHoverParcelHeight() const
00171                                 { return F32(mHoverEastNorth.mdV[VY] - mHoverWestSouth.mdV[VY]); }
00172 
00173         // UTILITIES
00174         void    render();
00175         void    renderParcelCollision();
00176 
00177         void    renderRect(     const LLVector3d &west_south_bottom, 
00178                                                 const LLVector3d &east_north_top );
00179         void    renderOneSegment(F32 x1, F32 y1, F32 x2, F32 y2, F32 height, U8 direction, LLViewerRegion* regionp);
00180         void    renderHighlightSegments(const U8* segments, LLViewerRegion* regionp);
00181         void    renderCollisionSegments(U8* segments, BOOL use_pass, LLViewerRegion* regionp);
00182 
00183         void    sendParcelGodForceOwner(const LLUUID& owner_id);
00184 
00185         // make the selected parcel a content parcel. 
00186         void sendParcelGodForceToContent();
00187 
00188         // Pack information about this parcel and send it to the region
00189         // containing the southwest corner of the selection.
00190         // If want_reply_to_update, simulator will send back a ParcelProperties
00191         // message.
00192         void    sendParcelPropertiesUpdate(LLParcel* parcel, bool use_agent_region = false);
00193 
00194         // Takes an Access List flag, like AL_ACCESS or AL_BAN
00195         void    sendParcelAccessListUpdate(U32 which);
00196 
00197         // Takes an Access List flag, like AL_ACCESS or AL_BAN
00198         void    sendParcelAccessListRequest(U32 flags);
00199 
00200         // Dwell is not part of the usual parcel update information because the
00201         // simulator doesn't actually know the per-parcel dwell.  Ack!  We have
00202         // to get it out of the database.
00203         void    sendParcelDwellRequest();
00204 
00205         // If the point is outside the current hover parcel, request more data
00206         void    requestHoverParcelProperties(const LLVector3d& pos_global);
00207 
00208         bool    canAgentBuyParcel(LLParcel*, bool forGroup) const;
00209         
00210 //      void    startClaimLand(BOOL is_for_group = FALSE);
00211         void    startBuyLand(BOOL is_for_group = FALSE);
00212         void    startSellLand();
00213         void    startReleaseLand();
00214         void    startDivideLand();
00215         void    startJoinLand();
00216         void    startDeedLandToGroup();
00217         void reclaimParcel();
00218 
00219         void    buyPass();
00220 
00221         // Buying Land
00222         
00223         class ParcelBuyInfo;
00224         ParcelBuyInfo* setupParcelBuy(const LLUUID& agent_id,
00225                                                                   const LLUUID& session_id,                                              
00226                                                                   const LLUUID& group_id,
00227                                                                   BOOL is_group_owned,
00228                                                                   BOOL is_claim,
00229                                                                   BOOL remove_contribution);
00230                 // callers responsibility to call deleteParcelBuy() on return value
00231         void sendParcelBuy(ParcelBuyInfo*);
00232         void deleteParcelBuy(ParcelBuyInfo*&);
00233                                            
00234         void sendParcelDeed(const LLUUID& group_id);
00235 
00236         // Send the ParcelRelease message
00237         void sendParcelRelease();
00238 
00239         // accessors for mAgentParcel
00240         const LLString& getAgentParcelName() const;
00241 
00242         // Create a landmark at the "appropriate" location for the
00243         // currently selected parcel.
00244         // *NOTE: Taken out 2005-03-21. Phoenix.
00245         //void makeLandmarkAtSelection();
00246 
00247         static void processParcelOverlay(LLMessageSystem *msg, void **user_data);
00248         static void processParcelProperties(LLMessageSystem *msg, void **user_data);
00249         static void processParcelAccessListReply(LLMessageSystem *msg, void **user);
00250         static void processParcelDwellReply(LLMessageSystem *msg, void **user);
00251 
00252         void dump();
00253 
00254         // Whether or not the collision border around the parcel is there because
00255         // the agent is banned or not in the allowed group
00256         BOOL isCollisionBanned();
00257 
00258         static BOOL isParcelOwnedByAgent(const LLParcel* parcelp, U64 group_proxy_power);
00259         static BOOL isParcelModifiableByAgent(const LLParcel* parcelp, U64 group_proxy_power);
00260 
00261 private:
00262         static void releaseAlertCB(S32 option, void *data);
00263 
00264         // If the user is claiming land and the current selection 
00265         // borders a piece of land the user already owns, ask if he
00266         // wants to join this land to the other piece.
00267         //void  askJoinIfNecessary(ELandTransferType land_transfer_type);
00268         //static void joinAlertCB(S32 option, void* data);
00269 
00270         //void buyAskMoney(ELandTransferType land_transfer_type);
00271 
00272         // move land from current owner to it's group.
00273         void deedLandToGroup();
00274 
00275         static void claimAlertCB(S32 option, void* data);
00276         static void buyAlertCB(S32 option, void* data);
00277         static void deedAlertCB(S32 option, void*);
00278 
00279         static void callbackDivideLand(S32 option, void* data);
00280         static void callbackJoinLand(S32 option, void* data);
00281 
00282         //void  finishClaim(BOOL user_to_user_sale, U32 join);
00283         LLViewerImage* getBlockedImage() const;
00284         LLViewerImage* getPassImage() const;
00285 
00286 private:
00287         BOOL                                            mSelected;
00288 
00289         LLParcel*                                       mCurrentParcel;                 // selected parcel info
00290         LLParcelSelectionHandle         mCurrentParcelSelection;
00291         LLParcelSelectionHandle         mFloatingParcelSelection;
00292         S32                                                     mRequestResult;         // result of last parcel request
00293         LLVector3d                                      mWestSouth;
00294         LLVector3d                                      mEastNorth;
00295         F32                                                     mSelectedDwell;
00296 
00297         LLParcel                                        *mAgentParcel;          // info for parcel agent is in
00298         S32                                                     mAgentParcelSequenceID; // incrementing counter to suppress out of order updates
00299 
00300         LLParcel*                                       mHoverParcel;
00301         S32                                                     mHoverRequestResult;
00302         LLVector3d                                      mHoverWestSouth;
00303         LLVector3d                                      mHoverEastNorth;
00304 
00305         LLDynamicArray<LLParcelObserver*> mObservers;
00306 
00307         // Array of pieces of parcel edges to potentially draw
00308         // Has (parcels_per_edge + 1) * (parcels_per_edge + 1) elements so
00309         // we can represent edges of the grid.
00310         // WEST_MASK = draw west edge
00311         // SOUTH_MASK = draw south edge
00312         S32                                                     mParcelsPerEdge;
00313         U8*                                                     mHighlightSegments;
00314         U8*                                                     mAgentParcelOverlay;
00315 
00316         // Raw data buffer for unpacking parcel overlay chunks
00317         // Size = parcels_per_edge * parcels_per_edge / parcel_overlay_chunks
00318         static U8*                                      sPackedOverlay;
00319 
00320         // Watch for pending collisions with a parcel you can't access.
00321         // If it's coming, draw the parcel's boundaries.
00322         LLParcel*                                       mCollisionParcel;
00323         U8*                                                     mCollisionSegments;
00324         BOOL                                            mRenderCollision; 
00325         BOOL                                            mRenderSelection;
00326         S32                                                     mCollisionBanned;     
00327         LLFrameTimer                            mCollisionTimer;
00328         LLImageGL*                                      mBlockedImage;
00329         LLImageGL*                                      mPassImage;
00330 
00331         // Media
00332         S32                                             mMediaParcelId;
00333         U64                                             mMediaRegionId;
00334 };
00335 
00336 
00337 void sanitize_corners(const LLVector3d &corner1, const LLVector3d &corner2,
00338                                                 LLVector3d &west_south_bottom, LLVector3d &east_north_top);
00339 
00340 #endif

Generated on Fri May 16 08:34:16 2008 for SecondLife by  doxygen 1.5.5