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
00049
00050
00051
00052
00053
00054
00055 const F32 PARCEL_POST_HEIGHT = 0.666f;
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
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
00096 S32 getSelectedArea() const;
00097
00098 void resetSegments(U8* segments);
00099
00100
00101 void writeHighlightSegments(F32 west, F32 south, F32 east, F32 north);
00102
00103
00104
00105 void writeSegmentsFromBitmap(U8* bitmap, U8* segments);
00106
00107 void writeAgentParcelFromBitmap(U8* bitmap);
00108
00109
00110 void selectCollisionParcel();
00111
00112
00113 LLSafeHandle<LLParcelSelection> selectParcelAt(const LLVector3d& pos_global);
00114
00115
00116
00117 LLParcelSelectionHandle selectParcelInRectangle();
00118
00119
00120 LLParcelSelectionHandle selectLand(const LLVector3d &corner1, const LLVector3d &corner2,
00121 BOOL snap_to_parcel);
00122
00123
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
00141
00142
00143
00144 LLParcelSelectionHandle getParcelSelection() const;
00145
00146
00147
00148
00149
00150 LLParcelSelectionHandle getFloatingParcelSelection() const;
00151
00152
00153 LLParcel *getAgentParcel() const;
00154
00155 BOOL inAgentParcel(const LLVector3d &pos_global) const;
00156
00157
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
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
00186 void sendParcelGodForceToContent();
00187
00188
00189
00190
00191
00192 void sendParcelPropertiesUpdate(LLParcel* parcel, bool use_agent_region = false);
00193
00194
00195 void sendParcelAccessListUpdate(U32 which);
00196
00197
00198 void sendParcelAccessListRequest(U32 flags);
00199
00200
00201
00202
00203 void sendParcelDwellRequest();
00204
00205
00206 void requestHoverParcelProperties(const LLVector3d& pos_global);
00207
00208 bool canAgentBuyParcel(LLParcel*, bool forGroup) const;
00209
00210
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
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
00231 void sendParcelBuy(ParcelBuyInfo*);
00232 void deleteParcelBuy(ParcelBuyInfo*&);
00233
00234 void sendParcelDeed(const LLUUID& group_id);
00235
00236
00237 void sendParcelRelease();
00238
00239
00240 const LLString& getAgentParcelName() const;
00241
00242
00243
00244
00245
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
00255
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
00265
00266
00267
00268
00269
00270
00271
00272
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
00283 LLViewerImage* getBlockedImage() const;
00284 LLViewerImage* getPassImage() const;
00285
00286 private:
00287 BOOL mSelected;
00288
00289 LLParcel* mCurrentParcel;
00290 LLParcelSelectionHandle mCurrentParcelSelection;
00291 LLParcelSelectionHandle mFloatingParcelSelection;
00292 S32 mRequestResult;
00293 LLVector3d mWestSouth;
00294 LLVector3d mEastNorth;
00295 F32 mSelectedDwell;
00296
00297 LLParcel *mAgentParcel;
00298 S32 mAgentParcelSequenceID;
00299
00300 LLParcel* mHoverParcel;
00301 S32 mHoverRequestResult;
00302 LLVector3d mHoverWestSouth;
00303 LLVector3d mHoverEastNorth;
00304
00305 LLDynamicArray<LLParcelObserver*> mObservers;
00306
00307
00308
00309
00310
00311
00312 S32 mParcelsPerEdge;
00313 U8* mHighlightSegments;
00314 U8* mAgentParcelOverlay;
00315
00316
00317
00318 static U8* sPackedOverlay;
00319
00320
00321
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
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