aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lldrawable.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/lldrawable.h
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/lldrawable.h')
-rw-r--r--linden/indra/newview/lldrawable.h330
1 files changed, 330 insertions, 0 deletions
diff --git a/linden/indra/newview/lldrawable.h b/linden/indra/newview/lldrawable.h
new file mode 100644
index 0000000..062427e
--- /dev/null
+++ b/linden/indra/newview/lldrawable.h
@@ -0,0 +1,330 @@
1/**
2 * @file lldrawable.h
3 * @brief LLDrawable class definition
4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#ifndef LL_DRAWABLE_H
29#define LL_DRAWABLE_H
30
31#include <vector>
32#include <map>
33
34#include "v2math.h"
35#include "v3math.h"
36#include "v4math.h"
37#include "m4math.h"
38#include "v4coloru.h"
39#include "llquaternion.h"
40#include "xform.h"
41#include "llprimitive.h"
42#include "llviewerimage.h"
43#include "lldarray.h"
44#include "llstat.h"
45#include "llviewerobject.h"
46#include "llrect.h"
47
48class LLDrawPool;
49class LLDrawable;
50class LLFace;
51class LLSpatialGroup;
52class LLSpatialBridge;
53class LLSpatialPartition;
54class LLVOVolume;
55
56extern F32 gFrameTimeSeconds;
57
58// Can have multiple silhouettes for each object
59const U32 SILHOUETTE_HIGHLIGHT = 0;
60
61
62// All data for new renderer goes into this class.
63class LLDrawable : public LLRefCount
64{
65public:
66 static void initClass();
67
68 LLDrawable() { init(); }
69 MEM_TYPE_NEW(LLMemType::MTYPE_DRAWABLE);
70
71 void markDead(); // Mark this drawable as dead
72 BOOL isDead() const { return isState(DEAD); }
73 BOOL isNew() const { return !isState(BUILT); }
74
75 BOOL isLight() const;
76
77 BOOL isVisible() const { return (mVisible == sCurVisible); }
78 virtual void setVisible(LLCamera& camera_in, std::vector<LLDrawable*>* results = NULL, BOOL for_select = FALSE);
79
80
81 const LLViewerRegion* getRegion() const { return mVObjp->getRegion(); }
82 const LLTextureEntry* getTextureEntry(U8 which) const { return mVObjp->getTE(which); }
83 LLViewerObject* getVObj() { return mVObjp; }
84 const LLViewerObject* getVObj() const { return mVObjp; }
85 LLVOVolume* getVOVolume() const; // cast mVObjp tp LLVOVolume if OK
86
87 const LLMatrix4& getWorldMatrix() const { return mXform.getWorldMatrix(); }
88 const LLMatrix4& getRenderMatrix() const { return isRoot() ? getWorldMatrix() : getParent()->getWorldMatrix(); }
89 const void setPosition(LLVector3 v) const { }
90 const LLVector3& getPosition() const { return mXform.getPosition(); }
91 const LLVector3& getWorldPosition() const { return mXform.getPositionW(); }
92 const LLVector3 getPositionAgent() const;
93 const LLVector3d& getPositionGroup() const { return mPositionGroup; }
94 const LLVector3& getScale() const { return mCurrentScale; }
95 const LLQuaternion& getWorldRotation() const { return mXform.getWorldRotation(); }
96 const LLQuaternion& getRotation() const { return mXform.getRotation(); }
97 const F32 getIntensity() const { return llmin(mXform.getScale().mV[0], 4.f); }
98 const S32 getLOD() const { return mVObjp ? mVObjp->getLOD() : 1; }
99 const F64 getBinRadius() const { return mBinRadius; }
100 void getMinMax(LLVector3& min,LLVector3& max) const { mXform.getMinMax(min,max); }
101 LLXformMatrix* getXform() { return &mXform; }
102
103 const U32 getState() const { return mState; }
104 const BOOL isState (U32 bits) const { return ((mState & bits) != 0); }
105 void setState (U32 bits) { mState |= bits; }
106 void clearState(U32 bits) { mState &= ~bits; }
107
108 BOOL isAvatar() const { return mVObjp.notNull() && mVObjp->isAvatar(); }
109 BOOL isRoot() const { return !mParent || mParent->isAvatar(); }
110 BOOL isSpatialRoot() const { return !mParent || mParent->isAvatar(); }
111 virtual BOOL isSpatialBridge() const { return FALSE; }
112 virtual LLSpatialPartition* asPartition() { return NULL; }
113 LLDrawable* getParent() const { return mParent; }
114 LLDrawable* getChild(U32 index) { return mVObjp->mChildList[index]->mDrawable; }
115 U32 getChildCount() { return mVObjp ? mVObjp->mChildList.size() : 0; }
116
117 // must set parent through LLViewerObject:: ()
118 //BOOL setParent(LLDrawable *parent);
119
120 inline LLFace* getFace(const S32 i) const;
121 inline S32 getNumFaces() const;
122
123 //void removeFace(const S32 i); // SJB: Avoid using this, it's slow
124 LLFace* addFace(LLDrawPool *poolp, LLViewerImage *texturep, const BOOL shared_geom = FALSE);
125 void deleteFaces(S32 offset, S32 count);
126 void setNumFaces(const S32 numFaces, LLDrawPool *poolp, LLViewerImage *texturep);
127 void setNumFacesFast(const S32 numFaces, LLDrawPool *poolp, LLViewerImage *texturep);
128 void mergeFaces(LLDrawable* src);
129
130 void init();
131 void destroy();
132
133 void update();
134 F32 updateXform(BOOL undamped);
135
136 virtual void makeActive();
137 virtual void makeStatic();
138
139 BOOL isActive() const { return isState(ACTIVE); }
140 BOOL isStatic() const { return !isActive(); }
141 virtual BOOL updateMove();
142 virtual void movePartition();
143
144 void updateTexture();
145 void updateMaterial();
146 virtual void updateDistance(LLCamera& camera);
147 BOOL updateGeometry(BOOL priority);
148 BOOL updateLighting(BOOL priority);
149 void updateLightSet();
150
151 F32 getSunShadowFactor() const { return mSunShadowFactor; }
152 void setSunShadowFactor(F32 factor) { mSunShadowFactor = factor; }
153 void applyLightsAsPoint(LLColor4& result);
154 void updateSpecialHoverCursor(BOOL enabled);
155
156 virtual void shiftPos(const LLVector3 &shift_vector);
157
158 S32 getGeneration() const { return mGeneration; }
159
160 BOOL getLit() const { return isState(UNLIT) ? FALSE : TRUE; }
161 void setLit(BOOL lit) { lit ? clearState(UNLIT) : setState(UNLIT); }
162
163 void clearLightSet();
164 virtual void cleanupReferences();
165
166 void setRadius(const F32 radius);
167 F32 getRadius() const { return mRadius; }
168 F32 getVisibilityRadius() const;
169
170 void updateUVMinMax(); // Updates the cache of sun space bounding box.
171
172 const LLVector3& getBounds(LLVector3& min, LLVector3& max) const;
173 virtual void updateSpatialExtents();
174 virtual void updateBinRadius();
175 const LLVector3* getSpatialExtents() const;
176 void setSpatialExtents(LLVector3 min, LLVector3 max);
177 void setPositionGroup(const LLVector3d& pos);
178 void setPositionGroup(const LLVector3& pos) { setPositionGroup(LLVector3d(pos)); }
179
180 void setRenderType(S32 type) { mRenderType = type; }
181 BOOL isRenderType(S32 type) { return mRenderType == type; }
182 S32 getRenderType() { return mRenderType; }
183
184 // Debugging methods
185 S32 findReferences(LLDrawable *drawablep); // Not const because of @#$! iterators...
186
187 void setSpatialGroup(LLSpatialGroup *groupp, const S32 offset);
188 LLSpatialGroup *getSpatialGroup() const { return mSpatialGroupp; }
189 LLSpatialPartition* getSpatialPartition();
190
191 // Statics
192 static void incrementVisible();
193 static void cleanupDeadDrawables();
194
195protected:
196 virtual ~LLDrawable() { destroy(); }
197 void moveUpdatePipeline(BOOL moved);
198 BOOL updateMoveDamped();
199 BOOL updateMoveUndamped();
200
201public:
202 friend class LLPipeline;
203 friend class LLDrawPool;
204 friend class LLSpatialBridge;
205
206 typedef std::set<LLPointer<LLDrawable> > drawable_set_t;
207 typedef std::vector<LLPointer<LLDrawable> > drawable_vector_t;
208 typedef std::list<LLPointer<LLDrawable> > drawable_list_t;
209
210 struct CompareDistanceGreater
211 {
212 bool operator()(const LLDrawable* const& lhs, const LLDrawable* const& rhs)
213 {
214 return lhs->mDistanceWRTCamera < rhs->mDistanceWRTCamera; // farthest = last
215 }
216 };
217
218 struct CompareDistanceGreaterVisibleFirst
219 {
220 bool operator()(const LLDrawable* const& lhs, const LLDrawable* const& rhs)
221 {
222 if (lhs->isVisible() && !rhs->isVisible())
223 {
224 return TRUE; //visible things come first
225 }
226 else if (!lhs->isVisible() && rhs->isVisible())
227 {
228 return FALSE; //rhs is visible, comes first
229 }
230
231 return lhs->mDistanceWRTCamera < rhs->mDistanceWRTCamera; // farthest = last
232 }
233 };
234
235 typedef enum e_drawable_flags
236 {
237// TEXTURE = 0x00000001,
238 IN_REBUILD_Q1 = 0x00000002,
239 IN_REBUILD_Q2 = 0x00000004,
240 IN_LIGHT_Q = 0x00000008,
241 EARLY_MOVE = 0x00000010,
242 MOVE_UNDAMPED = 0x00000020,
243 ON_MOVE_LIST = 0x00000040,
244 USE_BACKLIGHT = 0x00000080,
245 UV = 0x00000100,
246 UNLIT = 0x00000200,
247 LIGHT = 0x00000400,
248 LIGHTING_BUILT = 0x00000800,
249 REBUILD_VOLUME = 0x00001000,
250 REBUILD_TCOORD = 0x00002000,
251 REBUILD_GEOMETRY= REBUILD_VOLUME|REBUILD_TCOORD,
252 REBUILD_LIGHTING= 0x00008000,
253 REBUILD_ALL = REBUILD_GEOMETRY|REBUILD_LIGHTING,
254 ON_SHIFT_LIST = 0x00100000,
255// NO_INTERP_COLOR = 0x00200000,
256 BLOCKER = 0x00400000,
257 ACTIVE = 0x00800000,
258 DEAD = 0x01000000,
259 INVISIBLE = 0x02000000, // stay invisible until flag is cleared
260 NEARBY_LIGHT = 0x04000000, // In gPipeline.mNearbyLightSet
261 BUILT = 0x08000000,
262 FORCE_INVISIBLE = 0x10000000, // stay invis until CLEAR_INVISIBLE is set (set of orphaned)
263 CLEAR_INVISIBLE = 0x20000000, // clear FORCE_INVISIBLE next draw frame
264 REBUILD_SHADOW = 0x40000000
265 } EDrawableFlags;
266
267 LLXformMatrix mXform;
268
269 // vis data
270 LLPointer<LLDrawable> mParent;
271
272 F32 mDistanceWRTCamera;
273
274 LLRectf mUVRect;
275 F32 mUVZ;
276
277 drawable_set_t mLightSet;
278 drawable_set_t mBlockSet;
279
280 LLVector3 mSavePos;
281 S32 mQuietCount;
282
283 static S32 getCurrentFrame() { return sCurVisible; }
284
285 void setSpatialBridge(LLSpatialBridge* bridge) { mSpatialBridge = (LLDrawable*) bridge; }
286 LLSpatialBridge* getSpatialBridge() { return (LLSpatialBridge*) (LLDrawable*) mSpatialBridge; }
287
288protected:
289 typedef std::vector<LLFace*> face_list_t;
290
291 U32 mState;
292 S32 mRenderType;
293 LLPointer<LLViewerObject> mVObjp;
294 face_list_t mFaces;
295 LLSpatialGroup* mSpatialGroupp;
296 LLPointer<LLDrawable> mSpatialBridge;
297 S32 mSpatialGroupOffset;
298
299 U32 mVisible;
300 F32 mRadius;
301 LLVector3 mExtents[2];
302 LLVector3d mPositionGroup;
303 F64 mBinRadius;
304 S32 mGeneration;
305
306 F32 mSunShadowFactor;
307
308 LLVector3 mCurrentScale;
309
310 static U32 sCurVisible; // Counter for what value of mVisible means currently visible
311 static F32 sCurPixelAngle; //current pixels per radian
312
313 static U32 sNumZombieDrawables;
314 static LLDynamicArrayPtr<LLPointer<LLDrawable> > sDeadList;
315};
316
317
318inline LLFace* LLDrawable::getFace(const S32 i) const
319{
320 llassert((U32)i < mFaces.size());
321 return mFaces[i];
322}
323
324
325inline S32 LLDrawable::getNumFaces()const
326{
327 return (S32)mFaces.size();
328}
329
330#endif