llviewerobjectlist.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLVIEWEROBJECTLIST_H
00033 #define LL_LLVIEWEROBJECTLIST_H
00034 
00035 #include <map>
00036 #include <set>
00037 
00038 // common includes
00039 #include "llstat.h"
00040 #include "lldarrayptr.h"
00041 #include "llstring.h"
00042 
00043 // project includes
00044 #include "llviewerobject.h"
00045 
00046 class LLNetMap;
00047 class LLDebugBeacon;
00048 
00049 const U32 CLOSE_BIN_SIZE = 10;
00050 const U32 NUM_BINS = 16;
00051 
00052 // GL name = position in object list + GL_NAME_INDEX_OFFSET so that
00053 // we can have special numbers like zero.
00054 const U32 GL_NAME_LAND = 0;
00055 const U32 GL_NAME_PARCEL_WALL = 1;
00056 
00057 const U32 GL_NAME_INDEX_OFFSET = 10;
00058 
00059 class LLViewerObjectList
00060 {
00061 public:
00062         LLViewerObjectList();
00063         ~LLViewerObjectList();
00064 
00065         void destroy();
00066 
00067         // For internal use only.  Does NOT take a local id, takes an index into
00068         // an internal dynamic array.
00069         inline LLViewerObject *getObject(const S32 index);
00070         
00071         inline LLViewerObject *findObject(const LLUUID &id);
00072         LLViewerObject *createObjectViewer(const LLPCode pcode, LLViewerRegion *regionp); // Create a viewer-side object
00073         LLViewerObject *createObject(const LLPCode pcode, LLViewerRegion *regionp,
00074                                                                  const LLUUID &uuid, const U32 local_id, const LLHost &sender);
00075 
00076         LLViewerObject *replaceObject(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp); // TomY: hack to switch VO instances on the fly
00077         
00078         BOOL killObject(LLViewerObject *objectp);
00079         void killObjects(LLViewerRegion *regionp); // Kill all objects owned by a particular region.
00080         void killAllObjects();
00081         void removeDrawable(LLDrawable* drawablep);
00082 
00083         void cleanDeadObjects(const BOOL use_timer = TRUE);     // Clean up the dead object list.
00084 
00085         // Simulator and viewer side object updates...
00086         void processUpdateCore(LLViewerObject* objectp, void** data, U32 block, const EObjectUpdateType update_type, LLDataPacker* dpp, BOOL justCreated);
00087         void processObjectUpdate(LLMessageSystem *mesgsys, void **user_data, EObjectUpdateType update_type, bool cached=false, bool compressed=false);
00088         void processCompressedObjectUpdate(LLMessageSystem *mesgsys, void **user_data, EObjectUpdateType update_type);
00089         void processCachedObjectUpdate(LLMessageSystem *mesgsys, void **user_data, EObjectUpdateType update_type);
00090         void updateApparentAngles(LLAgent &agent);
00091         void update(LLAgent &agent, LLWorld &world);
00092 
00093         void shiftObjects(const LLVector3 &offset);
00094 
00095         void renderObjectsForMap(LLNetMap &netmap);
00096         void renderObjectBounds(const LLVector3 &center);
00097 
00098         void addDebugBeacon(const LLVector3 &pos_agent, const LLString &string,
00099                                                 const LLColor4 &color=LLColor4(1.f, 0.f, 0.f, 0.5f),
00100                                                 const LLColor4 &text_color=LLColor4(1.f, 1.f, 1.f, 1.f),
00101                                                 S32 line_width = 1);
00102         void renderObjectBeacons();
00103         void resetObjectBeacons();
00104 
00105         void dirtyAllObjectInventory();
00106 
00107         void updateActive(LLViewerObject *objectp);
00108         void updateAvatarVisibility();
00109 
00110         // Selection related stuff
00111         U32 renderObjectsForSelect(LLCamera &camera, BOOL pick_parcel_wall = FALSE, BOOL keep_pick_list = FALSE);
00112         LLViewerObject *getSelectedObject(const U32 object_id);
00113 
00114         inline S32 getNumObjects() { return mObjects.count(); }
00115 
00116         void addToMap(LLViewerObject *objectp);
00117         void removeFromMap(LLViewerObject *objectp);
00118 
00119         void clearDebugText();
00120 
00122         //
00123         // Only accessed by markDead in LLViewerObject
00124         void cleanupReferences(LLViewerObject *objectp);
00125 
00126         S32 findReferences(LLDrawable *drawablep) const; // Find references to drawable in all objects, and return value.
00127 
00128         S32 getOrphanParentCount() const { return mOrphanParents.count(); }
00129         S32 getOrphanCount() const { return mNumOrphans; }
00130         void orphanize(LLViewerObject *childp, U32 parent_id, U32 ip, U32 port);
00131         void findOrphans(LLViewerObject* objectp, U32 ip, U32 port);
00132 
00133 public:
00134         // Class for keeping track of orphaned objects
00135         class OrphanInfo
00136         {
00137         public:
00138                 OrphanInfo();
00139                 OrphanInfo(const U64 parent_info, const LLUUID child_info);
00140                 bool operator==(const OrphanInfo &rhs) const;
00141                 bool operator!=(const OrphanInfo &rhs) const;
00142                 U64 mParentInfo;
00143                 LLUUID mChildInfo;
00144         };
00145 
00146 
00147         U32     mCurBin; // Current bin we're working on...
00148 
00150         //
00151         // Statistics data
00152         //
00153         //
00154         LLStat mNumObjectsStat;
00155         LLStat mNumActiveObjectsStat;
00156         LLStat mNumNewObjectsStat;
00157         LLStat mNumSizeCulledStat;
00158         LLStat mNumVisCulledStat;
00159 
00160         S32 mNumNewObjects;
00161 
00162         S32 mNumSizeCulled;
00163         S32 mNumVisCulled;
00164 
00165         // if we paused in the last frame
00166         // used to discount stats from this frame
00167         BOOL mWasPaused;
00168 
00169         static void getUUIDFromLocal(LLUUID &id,
00170                                                                 const U32 local_id,
00171                                                                 const U32 ip,
00172                                                                 const U32 port);
00173         static void setUUIDAndLocal(const LLUUID &id,
00174                                                                 const U32 local_id,
00175                                                                 const U32 ip,
00176                                                                 const U32 port); // Requires knowledge of message system info!
00177 
00178         static BOOL removeFromLocalIDTable(const LLViewerObject &object);
00179         // Used ONLY by the orphaned object code.
00180         static U64 getIndex(const U32 local_id, const U32 ip, const U32 port);
00181 
00182         S32 mNumUnknownUpdates;
00183         S32 mNumDeadObjectUpdates;
00184         S32 mNumUnknownKills;
00185         S32 mNumDeadObjects;
00186 protected:
00187         LLDynamicArray<U64>     mOrphanParents; // LocalID/ip,port of orphaned objects
00188         LLDynamicArray<OrphanInfo> mOrphanChildren;     // UUID's of orphaned objects
00189         S32 mNumOrphans;
00190 
00191         LLDynamicArrayPtr<LLPointer<LLViewerObject>, 256> mObjects;
00192         std::set<LLPointer<LLViewerObject> > mActiveObjects;
00193 
00194         LLDynamicArrayPtr<LLPointer<LLViewerObject> > mMapObjects;
00195 
00196         typedef std::map<LLUUID, LLPointer<LLViewerObject> > vo_map;
00197         vo_map mDeadObjects;    // Need to keep multiple entries per UUID
00198 
00199         std::map<LLUUID, LLPointer<LLViewerObject> > mUUIDObjectMap;
00200 
00201         LLDynamicArray<LLDebugBeacon> mDebugBeacons;
00202 
00203         S32 mCurLazyUpdateIndex;
00204 
00205         static U32 sSimulatorMachineIndex;
00206         static LLMap<U64, U32> sIPAndPortToIndex;
00207 
00208         static std::map<U64, LLUUID> sIndexAndLocalIDToUUID;
00209 
00210         std::set<LLViewerObject *> mSelectPickList;
00211 
00212         friend class LLViewerObject;
00213 };
00214 
00215 
00216 class LLDebugBeacon
00217 {
00218 public:
00219         ~LLDebugBeacon()
00220         {
00221                 if (mHUDObject.notNull())
00222                 {
00223                         mHUDObject->markDead();
00224                 }
00225         }
00226 
00227         LLVector3 mPositionAgent;
00228         LLString mString;
00229         LLColor4 mColor;
00230         LLColor4 mTextColor;
00231         S32 mLineWidth;
00232         LLPointer<LLHUDObject> mHUDObject;
00233 };
00234 
00235 
00236 
00237 // Global object list
00238 extern LLViewerObjectList gObjectList;
00239 
00240 // Inlines
00241 inline LLViewerObject *LLViewerObjectList::findObject(const LLUUID &id)
00242 {
00243         std::map<LLUUID, LLPointer<LLViewerObject> >::iterator iter = mUUIDObjectMap.find(id);
00244         if(iter != mUUIDObjectMap.end())
00245         {
00246                 return iter->second;
00247         }
00248         else
00249         {
00250                 return NULL;
00251         }
00252 }
00253 
00254 inline LLViewerObject *LLViewerObjectList::getObject(const S32 index)
00255 {
00256         LLViewerObject *objectp;
00257         objectp = mObjects[index];
00258         if (objectp->isDead())
00259         {
00260                 //llwarns << "Dead object " << objectp->mID << " in getObject" << llendl;
00261                 return NULL;
00262         }
00263         return objectp;
00264 }
00265 
00266 inline void LLViewerObjectList::addToMap(LLViewerObject *objectp)
00267 {
00268         mMapObjects.put(objectp);
00269 }
00270 
00271 inline void LLViewerObjectList::removeFromMap(LLViewerObject *objectp)
00272 {
00273         mMapObjects.removeObj(objectp);
00274 }
00275 
00276 
00277 #endif // LL_VIEWER_OBJECT_LIST_H

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