summaryrefslogtreecommitdiff
path: root/indra/newview/llspatialpartition.h
diff options
context:
space:
mode:
authorRichard Linden <none@none>2013-03-22 00:44:59 -0700
committerRichard Linden <none@none>2013-03-22 00:44:59 -0700
commit68f9f656cd22332e46959a90347e38f79c19a66c (patch)
tree531d87287b69f500c5901f785e60483555b415f9 /indra/newview/llspatialpartition.h
parente87000ba0750e55d9d6b55feccc4124f5d2b4b74 (diff)
parent368dd542bec7c31e14673b83d3342c35717d2920 (diff)
merge with viewer-release
Diffstat (limited to 'indra/newview/llspatialpartition.h')
-rw-r--r--indra/newview/llspatialpartition.h129
1 files changed, 39 insertions, 90 deletions
diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h
index b1706d9d35..b592e73403 100644
--- a/indra/newview/llspatialpartition.h
+++ b/indra/newview/llspatialpartition.h
@@ -45,22 +45,21 @@
#define SG_STATE_INHERIT_MASK (OCCLUDED)
#define SG_INITIAL_STATE_MASK (DIRTY | GEOM_DIRTY)
+class LLViewerOctreePartition;
class LLSpatialPartition;
class LLSpatialBridge;
class LLSpatialGroup;
class LLTextureAtlas;
class LLTextureAtlasSlot;
+class LLViewerRegion;
-S32 AABBSphereIntersect(const LLVector4a& min, const LLVector4a& max, const LLVector3 &origin, const F32 &rad);
-S32 AABBSphereIntersectR2(const LLVector4a& min, const LLVector4a& max, const LLVector3 &origin, const F32 &radius_squared);
-
-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);
void pushVerts(LLFace* face, U32 mask);
// get index buffer for binary encoded axis vertex buffer given a box at center being viewed by given camera
U32 get_box_fan_indices(LLCamera* camera, const LLVector4a& center);
U8* get_box_fan_indices_ptr(LLCamera* camera, const LLVector4a& center);
+GLuint get_new_occlusion_query_object_name();
+void release_occlusion_query_object_name(GLuint name);
class LLDrawInfo : public LLRefCount
{
@@ -192,13 +191,13 @@ public:
};
LL_ALIGN_PREFIX(16)
-class LLSpatialGroup : public LLOctreeListener<LLDrawable>
+class LLSpatialGroup : public LLviewerOctreeGroup
{
friend class LLSpatialPartition;
friend class LLOctreeStateCheck;
public:
- LLSpatialGroup(const LLSpatialGroup& rhs)
+ LLSpatialGroup(const LLSpatialGroup& rhs) : LLviewerOctreeGroup(rhs)
{
*this = rhs;
}
@@ -231,15 +230,6 @@ public:
typedef std::map<LLFace*, buffer_list_t> buffer_texture_map_t;
typedef std::map<U32, buffer_texture_map_t> buffer_map_t;
- typedef LLOctreeListener<LLDrawable> BaseType;
- typedef LLOctreeListener<LLDrawable> OctreeListener;
- typedef LLTreeNode<LLDrawable> TreeNode;
- typedef LLOctreeNode<LLDrawable> OctreeNode;
- typedef LLOctreeRoot<LLDrawable> OctreeRoot;
- typedef LLOctreeTraveler<LLDrawable> OctreeTraveler;
- typedef LLOctreeNode<LLDrawable>::element_iter element_iter;
- typedef LLOctreeNode<LLDrawable>::element_list element_list;
-
struct CompareDistanceGreater
{
bool operator()(const LLSpatialGroup* const& lhs, const LLSpatialGroup* const& rhs)
@@ -275,18 +265,15 @@ public:
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,
- MESH_DIRTY = 0x00000100,
- NEW_DRAWINFO = 0x00000200,
- IN_BUILD_Q1 = 0x00000400,
- IN_BUILD_Q2 = 0x00000800,
+ DEAD = LLviewerOctreeGroup::INVALID_STATE,
+ GEOM_DIRTY = (DEAD << 1),
+ ALPHA_DIRTY = (GEOM_DIRTY << 1),
+ IN_IMAGE_QUEUE = (ALPHA_DIRTY << 1),
+ IMAGE_DIRTY = (IN_IMAGE_QUEUE << 1),
+ MESH_DIRTY = (IMAGE_DIRTY << 1),
+ NEW_DRAWINFO = (MESH_DIRTY << 1),
+ IN_BUILD_Q1 = (NEW_DRAWINFO << 1),
+ IN_BUILD_Q2 = (IN_BUILD_Q1 << 1),
STATE_MASK = 0x0000FFFF,
} eSpatialState;
@@ -301,12 +288,8 @@ public:
LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part);
BOOL isHUDGroup() ;
- BOOL isDead() { return isState(DEAD); }
- BOOL isState(U32 state) const;
+ BOOL isDead() { return hasState(DEAD); }
BOOL isOcclusionState(U32 state) const { return mOcclusionState[LLViewerCamera::sCurCameraID] & state ? TRUE : FALSE; }
- U32 getState() { return mState; }
- void setState(U32 state);
- void clearState(U32 state);
void clearDrawMap();
void validate();
@@ -315,23 +298,18 @@ public:
void setState(U32 state, S32 mode);
void clearState(U32 state, S32 mode);
+ void clearState(U32 state) {mState &= ~state;}
void setOcclusionState(U32 state, S32 mode = STATE_MODE_SINGLE);
void clearOcclusionState(U32 state, S32 mode = STATE_MODE_SINGLE);
LLSpatialGroup* getParent();
-
- BOOL addObject(LLDrawable *drawablep, BOOL add_all = FALSE, BOOL from_octree = FALSE);
+ BOOL addObject(LLDrawable *drawablep);
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 LLVector4a &offset);
- BOOL boundObjects(BOOL empty, LLVector4a& newMin, LLVector4a& newMax);
- void unbound();
- BOOL rebound();
void checkOcclusion(); //read back last occlusion query (if any)
void doOcclusion(LLCamera* camera); //issue occlusion query
void destroyGL(bool keep_occlusion = false);
@@ -343,27 +321,17 @@ public:
void rebuildGeom();
void rebuildMesh();
+ void setState(U32 state) {mState |= state;}
void dirtyGeom() { setState(GEOM_DIRTY); }
void dirtyMesh() { setState(MESH_DIRTY); }
- //octree wrappers to make code more readable
- element_list& getData() { return mOctreeNode->getData(); }
- element_iter getDataBegin() { return mOctreeNode->getDataBegin(); }
- element_iter getDataEnd() { return mOctreeNode->getDataEnd(); }
- bool hasElement(LLDrawable* drawablep) { return std::find(mOctreeNode->getDataBegin(), mOctreeNode->getDataEnd(), drawablep) != mOctreeNode->getDataEnd(); }
-
- U32 getElementCount() const { return mOctreeNode->getElementCount(); }
- bool isEmpty() const { return mOctreeNode->isEmpty(); }
-
void drawObjectBox(LLColor4 col);
//LISTENER FUNCTIONS
- virtual void handleInsertion(const TreeNode* node, LLDrawable* face);
- virtual void handleRemoval(const TreeNode* node, LLDrawable* face);
+ virtual void handleInsertion(const TreeNode* node, LLViewerOctreeEntry* face);
+ virtual void handleRemoval(const TreeNode* node, LLViewerOctreeEntry* face);
virtual void handleDestruction(const TreeNode* node);
- virtual void handleStateChange(const TreeNode* node);
virtual void handleChildAddition(const OctreeNode* parent, OctreeNode* child);
- virtual void handleChildRemoval(const OctreeNode* parent, const OctreeNode* child);
//-------------------
//for atlas use
@@ -386,21 +354,6 @@ public:
public:
- typedef enum
- {
- BOUNDS = 0,
- EXTENTS = 2,
- OBJECT_BOUNDS = 4,
- OBJECT_EXTENTS = 6,
- VIEW_ANGLE = 8,
- LAST_VIEW_ANGLE = 9,
- V4_COUNT = 10
- } eV4Index;
-
- LL_ALIGN_16(LLVector4a mBounds[2]); // bounding box (center, size) of this node and all its children (tight fit to objects)
- LL_ALIGN_16(LLVector4a mExtents[2]); // extents (min, max) of this node and all its children
- LL_ALIGN_16(LLVector4a mObjectExtents[2]); // extents (min, max) of objects in this node
- LL_ALIGN_16(LLVector4a mObjectBounds[2]); // bounding box (center, size) of objects in this node
LL_ALIGN_16(LLVector4a mViewAngle);
LL_ALIGN_16(LLVector4a mLastUpdateViewAngle);
@@ -421,7 +374,6 @@ private:
protected:
virtual ~LLSpatialGroup();
- U32 mState;
U32 mOcclusionState[LLViewerCamera::NUM_CAMERAS];
U32 mOcclusionIssued[LLViewerCamera::NUM_CAMERAS];
@@ -436,7 +388,6 @@ public:
F32 mSurfaceArea; //used by volumes to track estimated surface area of geometry in this node
F32 mBuilt;
- OctreeNode* mOctreeNode;
LLSpatialPartition* mSpatialPartition;
LLPointer<LLVertexBuffer> mVertexBuffer;
@@ -445,7 +396,6 @@ public:
U32 mBufferUsage;
draw_map_t mDrawMap;
- S32 mVisible[LLViewerCamera::NUM_CAMERAS];
F32 mDistance;
F32 mDepth;
F32 mLastUpdateDistance;
@@ -468,10 +418,10 @@ public:
virtual LLVertexBuffer* createVertexBuffer(U32 type_mask, U32 usage);
};
-class LLSpatialPartition: public LLGeometryManager
+class LLSpatialPartition: public LLViewerOctreePartition, public LLGeometryManager
{
public:
- LLSpatialPartition(U32 data_mask, BOOL render_by_group, U32 mBufferUsage);
+ LLSpatialPartition(U32 data_mask, BOOL render_by_group, U32 mBufferUsage, LLViewerRegion* regionp);
virtual ~LLSpatialPartition();
LLSpatialGroup *put(LLDrawable *drawablep, BOOL was_visible = FALSE);
@@ -498,7 +448,8 @@ public:
virtual void rebuildMesh(LLSpatialGroup* group);
BOOL visibleObjectsInFrustum(LLCamera& camera);
- S32 cull(LLCamera &camera, std::vector<LLDrawable *>* results = NULL, BOOL for_select = FALSE); // Cull on arbitrary frustum
+ /*virtual*/ S32 cull(LLCamera &camera); // Cull on arbitrary frustum
+ S32 cull(LLCamera &camera, std::vector<LLDrawable *>* results, BOOL for_select); // Cull on arbitrary frustum
BOOL isVisible(const LLVector3& v);
bool isHUDPartition() ;
@@ -515,21 +466,19 @@ public:
BOOL getVisibleExtents(LLCamera& camera, LLVector3& visMin, LLVector3& visMax);
public:
- LLSpatialGroup::OctreeNode* mOctree;
LLSpatialBridge* mBridge; // NULL for non-LLSpatialBridge instances, otherwise, mBridge == this
// use a pointer instead of making "isBridge" and "asBridge" virtual so it's safe
// to call asBridge() from the destructor
BOOL mOcclusionEnabled; // if TRUE, occlusion culling is performed
BOOL mInfiniteFarClip; // if TRUE, frustum culling ignores far clip plane
U32 mBufferUsage;
+ U32 mDrawableType;
const BOOL mRenderByGroup;
U32 mLODSeed;
U32 mLODPeriod; //number of frames between LOD updates for a given spatial group (staggered by mLODSeed)
U32 mVertexDataMask;
F32 mSlopRatio; //percentage distance must change before drawables receive LOD update (default is 0.25);
BOOL mDepthMask; //if TRUE, objects in this partition will be written to depth during alpha rendering
- U32 mDrawableType;
- U32 mPartitionType;
};
// class for creating bridges between spatial partitions
@@ -541,7 +490,7 @@ protected:
public:
typedef std::vector<LLPointer<LLSpatialBridge> > bridge_vector_t;
- LLSpatialBridge(LLDrawable* root, BOOL render_by_group, U32 data_mask);
+ LLSpatialBridge(LLDrawable* root, BOOL render_by_group, U32 data_mask, LLViewerRegion* regionp);
void destroyTree();
@@ -663,7 +612,7 @@ private:
class LLWaterPartition : public LLSpatialPartition
{
public:
- LLWaterPartition();
+ LLWaterPartition(LLViewerRegion* regionp);
virtual void getGeometry(LLSpatialGroup* group) { }
virtual void addGeometryCount(LLSpatialGroup* group, U32 &vertex_count, U32& index_count) { }
};
@@ -672,14 +621,14 @@ public:
class LLVoidWaterPartition : public LLWaterPartition
{
public:
- LLVoidWaterPartition();
+ LLVoidWaterPartition(LLViewerRegion* regionp);
};
//spatial partition for terrain (impelmented in LLVOSurfacePatch.cpp)
class LLTerrainPartition : public LLSpatialPartition
{
public:
- LLTerrainPartition();
+ LLTerrainPartition(LLViewerRegion* regionp);
virtual void getGeometry(LLSpatialGroup* group);
virtual LLVertexBuffer* createVertexBuffer(U32 type_mask, U32 usage);
};
@@ -688,7 +637,7 @@ public:
class LLTreePartition : public LLSpatialPartition
{
public:
- LLTreePartition();
+ LLTreePartition(LLViewerRegion* regionp);
virtual void getGeometry(LLSpatialGroup* group) { }
virtual void addGeometryCount(LLSpatialGroup* group, U32 &vertex_count, U32& index_count) { }
@@ -698,7 +647,7 @@ public:
class LLParticlePartition : public LLSpatialPartition
{
public:
- LLParticlePartition();
+ LLParticlePartition(LLViewerRegion* regionp);
virtual void rebuildGeom(LLSpatialGroup* group);
virtual void getGeometry(LLSpatialGroup* group);
virtual void addGeometryCount(LLSpatialGroup* group, U32 &vertex_count, U32& index_count);
@@ -710,14 +659,14 @@ protected:
class LLHUDParticlePartition : public LLParticlePartition
{
public:
- LLHUDParticlePartition();
+ LLHUDParticlePartition(LLViewerRegion* regionp);
};
//spatial partition for grass (implemented in LLVOGrass.cpp)
class LLGrassPartition : public LLSpatialPartition
{
public:
- LLGrassPartition();
+ LLGrassPartition(LLViewerRegion* regionp);
virtual void getGeometry(LLSpatialGroup* group);
virtual void addGeometryCount(LLSpatialGroup* group, U32 &vertex_count, U32& index_count);
protected:
@@ -747,7 +696,7 @@ class LLVolumeGeometryManager: public LLGeometryManager
class LLVolumePartition : public LLSpatialPartition, public LLVolumeGeometryManager
{
public:
- LLVolumePartition();
+ LLVolumePartition(LLViewerRegion* regionp);
virtual void rebuildGeom(LLSpatialGroup* group) { LLVolumeGeometryManager::rebuildGeom(group); }
virtual void getGeometry(LLSpatialGroup* group) { LLVolumeGeometryManager::getGeometry(group); }
virtual void rebuildMesh(LLSpatialGroup* group) { LLVolumeGeometryManager::rebuildMesh(group); }
@@ -758,7 +707,7 @@ public:
class LLVolumeBridge : public LLSpatialBridge, public LLVolumeGeometryManager
{
public:
- LLVolumeBridge(LLDrawable* drawable);
+ LLVolumeBridge(LLDrawable* drawable, LLViewerRegion* regionp);
virtual void rebuildGeom(LLSpatialGroup* group) { LLVolumeGeometryManager::rebuildGeom(group); }
virtual void getGeometry(LLSpatialGroup* group) { LLVolumeGeometryManager::getGeometry(group); }
virtual void rebuildMesh(LLSpatialGroup* group) { LLVolumeGeometryManager::rebuildMesh(group); }
@@ -768,7 +717,7 @@ public:
class LLHUDBridge : public LLVolumeBridge
{
public:
- LLHUDBridge(LLDrawable* drawablep);
+ LLHUDBridge(LLDrawable* drawablep, LLViewerRegion* regionp);
virtual void shiftPos(const LLVector4a& vec);
virtual F32 calcPixelArea(LLSpatialGroup* group, LLCamera& camera);
};
@@ -777,7 +726,7 @@ public:
class LLBridgePartition : public LLSpatialPartition
{
public:
- LLBridgePartition();
+ LLBridgePartition(LLViewerRegion* regionp);
virtual void getGeometry(LLSpatialGroup* group) { }
virtual void addGeometryCount(LLSpatialGroup* group, U32 &vertex_count, U32& index_count) { }
};
@@ -785,7 +734,7 @@ public:
class LLHUDPartition : public LLBridgePartition
{
public:
- LLHUDPartition();
+ LLHUDPartition(LLViewerRegion* regionp);
virtual void shift(const LLVector4a &offset);
};