summaryrefslogtreecommitdiff
path: root/indra/newview/llspatialpartition.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llspatialpartition.h')
-rw-r--r--indra/newview/llspatialpartition.h172
1 files changed, 115 insertions, 57 deletions
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index 8aec5c8377..1a25f3f85d 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -2,31 +2,25 @@
* @file llspatialpartition.h
* @brief LLSpatialGroup header file including definitions for supporting functions
*
- * $LicenseInfo:firstyear=2003&license=viewergpl$
- *
- * Copyright (c) 2003-2009, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2003&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * Copyright (C) 2010, Linden Research, Inc.
*
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
*
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -44,6 +38,7 @@
#include "llcubemap.h"
#include "lldrawpool.h"
#include "llface.h"
+#include "llviewercamera.h"
#include <queue>
@@ -53,6 +48,8 @@
class LLSpatialPartition;
class LLSpatialBridge;
class LLSpatialGroup;
+class LLTextureAtlas;
+class LLTextureAtlasSlot;
S32 AABBSphereIntersect(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &rad);
S32 AABBSphereIntersectR2(const LLVector3& min, const LLVector3& max, const LLVector3 &origin, const F32 &radius_squared);
@@ -67,12 +64,12 @@ protected:
public:
LLDrawInfo(U16 start, U16 end, U32 count, U32 offset,
- LLViewerImage* image, LLVertexBuffer* buffer,
+ LLViewerTexture* image, LLVertexBuffer* buffer,
BOOL fullbright = FALSE, U8 bump = 0, BOOL particle = FALSE, F32 part_size = 0);
LLPointer<LLVertexBuffer> mVertexBuffer;
- LLPointer<LLViewerImage> mTexture;
+ LLPointer<LLViewerTexture> mTexture;
LLColor4U mGlowColor;
S32 mDebugColor;
const LLMatrix4* mTextureMatrix;
@@ -90,6 +87,7 @@ public:
LLFace* mFace; //associated face
F32 mDistance;
LLVector3 mExtents[2];
+ U32 mDrawMode;
struct CompareTexture
{
@@ -154,17 +152,17 @@ public:
class LLSpatialGroup : public LLOctreeListener<LLDrawable>
{
friend class LLSpatialPartition;
+ friend class LLOctreeStateCheck;
public:
static U32 sNodeCount;
static BOOL sNoDelete; //deletion of spatial groups and draw info not allowed if TRUE
typedef std::vector<LLPointer<LLSpatialGroup> > sg_vector_t;
- typedef std::set<LLPointer<LLSpatialGroup> > sg_set_t;
typedef std::vector<LLPointer<LLSpatialBridge> > bridge_list_t;
typedef std::vector<LLPointer<LLDrawInfo> > drawmap_elem_t;
typedef std::map<U32, drawmap_elem_t > draw_map_t;
typedef std::vector<LLPointer<LLVertexBuffer> > buffer_list_t;
- typedef std::map<LLPointer<LLViewerImage>, buffer_list_t> buffer_texture_map_t;
+ typedef std::map<LLPointer<LLViewerTexture>, buffer_list_t> buffer_texture_map_t;
typedef std::map<U32, buffer_texture_map_t> buffer_map_t;
typedef LLOctreeListener<LLDrawable> BaseType;
@@ -184,6 +182,14 @@ public:
}
};
+ struct CompareUpdateUrgency
+ {
+ bool operator()(const LLPointer<LLSpatialGroup> lhs, const LLPointer<LLSpatialGroup> rhs)
+ {
+ return lhs->getUpdateUrgency() > rhs->getUpdateUrgency();
+ }
+ };
+
struct CompareDepthGreater
{
bool operator()(const LLSpatialGroup* const& lhs, const LLSpatialGroup* const& rhs)
@@ -194,35 +200,44 @@ public:
typedef enum
{
- OCCLUDED = 0x00000001,
- IN_QUEUE = 0x00000002,
- QUERY_PENDING = 0x00000004,
- ACTIVE_OCCLUSION = 0x00000008,
- DISCARD_QUERY = 0x00000010,
- DEAD = 0x00000020,
- EARLY_FAIL = 0x00000040,
- DIRTY = 0x00000080,
- OBJECT_DIRTY = 0x00000100,
- GEOM_DIRTY = 0x00000200,
- ALPHA_DIRTY = 0x00000800,
- SKIP_FRUSTUM_CHECK = 0x00001000,
- IN_IMAGE_QUEUE = 0x00002000,
- IMAGE_DIRTY = 0x00004000,
- OCCLUSION_DIRTY = 0x00008000,
- MESH_DIRTY = 0x00010000,
+ OCCLUDED = 0x00010000,
+ QUERY_PENDING = 0x00020000,
+ ACTIVE_OCCLUSION = 0x00040000,
+ DISCARD_QUERY = 0x00080000,
+ EARLY_FAIL = 0x00100000,
+ } eOcclusionState;
+
+ typedef enum
+ {
+ DEAD = 0x00000001,
+ DIRTY = 0x00000002,
+ OBJECT_DIRTY = 0x00000004,
+ GEOM_DIRTY = 0x00000008,
+ ALPHA_DIRTY = 0x00000010,
+ SKIP_FRUSTUM_CHECK = 0x00000020,
+ IN_IMAGE_QUEUE = 0x00000040,
+ IMAGE_DIRTY = 0x00000080,
+ OCCLUSION_DIRTY = 0x00000100,
+ MESH_DIRTY = 0x00000200,
+ NEW_DRAWINFO = 0x00000400,
+ IN_BUILD_Q1 = 0x00000800,
+ IN_BUILD_Q2 = 0x00001000,
+ STATE_MASK = 0x0000FFFF,
} eSpatialState;
typedef enum
{
STATE_MODE_SINGLE = 0, //set one node
STATE_MODE_BRANCH, //set entire branch
- STATE_MODE_DIFF //set entire branch as long as current state is different
+ STATE_MODE_DIFF, //set entire branch as long as current state is different
+ STATE_MODE_ALL_CAMERAS, //used for occlusion state, set state for all cameras
} eSetStateMode;
LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part);
BOOL isDead() { return isState(DEAD); }
- BOOL isState(U32 state) const { return mState & state ? TRUE : FALSE; }
+ BOOL isState(U32 state) const;
+ BOOL isOcclusionState(U32 state) const { return mOcclusionState[LLViewerCamera::sCurCameraID] & state ? TRUE : FALSE; }
U32 getState() { return mState; }
void setState(U32 state);
void clearState(U32 state);
@@ -233,14 +248,19 @@ public:
void validateDrawMap();
void setState(U32 state, S32 mode);
+ void clearState(U32 state, S32 mode);
+
+ void setOcclusionState(U32 state, S32 mode = STATE_MODE_SINGLE);
+ void clearOcclusionState(U32 state, S32 mode = STATE_MODE_SINGLE);
LLSpatialGroup* getParent();
- void clearState(U32 state, S32 mode);
+
BOOL addObject(LLDrawable *drawablep, BOOL add_all = FALSE, BOOL from_octree = FALSE);
BOOL removeObject(LLDrawable *drawablep, BOOL from_octree = FALSE);
BOOL updateInGroup(LLDrawable *drawablep, BOOL immediate = FALSE); // Update position if it's in the group
BOOL isVisible() const;
+ BOOL isRecentlyVisible() const;
void setVisible();
void shift(const LLVector3 &offset);
BOOL boundObjects(BOOL empty, LLVector3& newMin, LLVector3& newMax);
@@ -253,6 +273,7 @@ public:
void updateDistance(LLCamera& camera);
BOOL needsUpdate();
+ F32 getUpdateUrgency() const;
BOOL changeLOD();
void rebuildGeom();
void rebuildMesh();
@@ -262,6 +283,8 @@ public:
element_list& getData() { return mOctreeNode->getData(); }
U32 getElementCount() const { return mOctreeNode->getElementCount(); }
+ void drawObjectBox(LLColor4 col);
+
//LISTENER FUNCTIONS
virtual void handleInsertion(const TreeNode* node, LLDrawable* face);
virtual void handleRemoval(const TreeNode* node, LLDrawable* face);
@@ -270,10 +293,41 @@ public:
virtual void handleChildAddition(const OctreeNode* parent, OctreeNode* child);
virtual void handleChildRemoval(const OctreeNode* parent, const OctreeNode* child);
+//-------------------
+//for atlas use
+//-------------------
+ //atlas
+ void setCurUpdatingTime(U32 t) {mCurUpdatingTime = t ;}
+ U32 getCurUpdatingTime() const { return mCurUpdatingTime ;}
+
+ void setCurUpdatingSlot(LLTextureAtlasSlot* slotp) ;
+ LLTextureAtlasSlot* getCurUpdatingSlot(LLViewerTexture* imagep, S8 recursive_level = 3) ;
+
+ void setCurUpdatingTexture(LLViewerTexture* tex){ mCurUpdatingTexture = tex ;}
+ LLViewerTexture* getCurUpdatingTexture() const { return mCurUpdatingTexture ;}
+
+ BOOL hasAtlas(LLTextureAtlas* atlasp) ;
+ LLTextureAtlas* getAtlas(S8 ncomponents, S8 to_be_reserved, S8 recursive_level = 3) ;
+ void addAtlas(LLTextureAtlas* atlasp, S8 recursive_level = 3) ;
+ void removeAtlas(LLTextureAtlas* atlasp, BOOL remove_group = TRUE, S8 recursive_level = 3) ;
+ void clearAtlasList() ;
+private:
+ U32 mCurUpdatingTime ;
+ //do not make the below two to use LLPointer
+ //because mCurUpdatingTime invalidates them automatically.
+ LLTextureAtlasSlot* mCurUpdatingSlotp ;
+ LLViewerTexture* mCurUpdatingTexture ;
+
+ std::vector< std::list<LLTextureAtlas*> > mAtlasList ;
+//-------------------
+//end for atlas use
+//-------------------
+
protected:
virtual ~LLSpatialGroup();
U32 mState;
+ U32 mOcclusionState[LLViewerCamera::NUM_CAMERAS];
S32 mLODHash;
static S32 sLODSeed;
@@ -284,20 +338,20 @@ public:
F32 mBuilt;
OctreeNode* mOctreeNode;
LLSpatialPartition* mSpatialPartition;
- LLVector3 mBounds[2];
- LLVector3 mExtents[2];
+ LLVector3 mBounds[2]; // bounding box (center, size) of this node and all its children (tight fit to objects)
+ LLVector3 mExtents[2]; // extents (min, max) of this node and all its children
- LLVector3 mObjectExtents[2];
- LLVector3 mObjectBounds[2];
+ LLVector3 mObjectExtents[2]; // extents (min, max) of objects in this node
+ LLVector3 mObjectBounds[2]; // bounding box (center, size) of objects in this node
LLPointer<LLVertexBuffer> mVertexBuffer;
F32* mOcclusionVerts;
- GLuint mOcclusionQuery;
+ GLuint mOcclusionQuery[LLViewerCamera::NUM_CAMERAS];
U32 mBufferUsage;
draw_map_t mDrawMap;
- S32 mVisible;
+ S32 mVisible[LLViewerCamera::NUM_CAMERAS];
F32 mDistance;
F32 mDepth;
F32 mLastUpdateDistance;
@@ -326,9 +380,7 @@ public:
class LLSpatialPartition: public LLGeometryManager
{
public:
- static BOOL sFreezeState; //if true, no spatialgroup state updates will be made
-
- LLSpatialPartition(U32 data_mask, U32 mBufferUsage = GL_STATIC_DRAW_ARB);
+ LLSpatialPartition(U32 data_mask, BOOL render_by_group, U32 mBufferUsage);
virtual ~LLSpatialPartition();
LLSpatialGroup *put(LLDrawable *drawablep, BOOL was_visible = FALSE);
@@ -374,7 +426,7 @@ public:
BOOL mOcclusionEnabled; // if TRUE, occlusion culling is performed
BOOL mInfiniteFarClip; // if TRUE, frustum culling ignores far clip plane
U32 mBufferUsage;
- BOOL mRenderByGroup;
+ const BOOL mRenderByGroup;
U32 mLODSeed;
U32 mLODPeriod; //number of frames between LOD updates for a given spatial group (staggered by mLODSeed)
U32 mVertexDataMask;
@@ -393,7 +445,7 @@ protected:
public:
typedef std::vector<LLPointer<LLSpatialBridge> > bridge_vector_t;
- LLSpatialBridge(LLDrawable* root, U32 data_mask);
+ LLSpatialBridge(LLDrawable* root, BOOL render_by_group, U32 data_mask);
virtual BOOL isSpatialBridge() const { return TRUE; }
@@ -474,12 +526,19 @@ private:
U32 mRenderMapSize[LLRenderPass::NUM_RENDER_TYPES];
sg_list_t mVisibleGroups;
+ sg_list_t::iterator mVisibleGroupsEnd;
sg_list_t mAlphaGroups;
+ sg_list_t::iterator mAlphaGroupsEnd;
sg_list_t mOcclusionGroups;
+ sg_list_t::iterator mOcclusionGroupsEnd;
sg_list_t mDrawableGroups;
+ sg_list_t::iterator mDrawableGroupsEnd;
drawable_list_t mVisibleList;
+ drawable_list_t::iterator mVisibleListEnd;
bridge_list_t mVisibleBridge;
+ bridge_list_t::iterator mVisibleBridgeEnd;
drawinfo_list_t mRenderMap[LLRenderPass::NUM_RENDER_TYPES];
+ drawinfo_list_t::iterator mRenderMapEnd[LLRenderPass::NUM_RENDER_TYPES];
};
@@ -546,14 +605,13 @@ public:
//class for wrangling geometry out of volumes (implemented in LLVOVolume.cpp)
class LLVolumeGeometryManager: public LLGeometryManager
{
-public:
+ public:
virtual ~LLVolumeGeometryManager() { }
virtual void rebuildGeom(LLSpatialGroup* group);
virtual void rebuildMesh(LLSpatialGroup* group);
virtual void getGeometry(LLSpatialGroup* group);
void genDrawInfo(LLSpatialGroup* group, U32 mask, std::vector<LLFace*>& faces, BOOL distance_sort = FALSE);
void registerFace(LLSpatialGroup* group, LLFace* facep, U32 type);
-
};
//spatial partition that uses volume geometry manager (implemented in LLVOVolume.cpp)