aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llface.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llface.h194
1 files changed, 110 insertions, 84 deletions
diff --git a/linden/indra/newview/llface.h b/linden/indra/newview/llface.h
index cb3b705..b265b3a 100644
--- a/linden/indra/newview/llface.h
+++ b/linden/indra/newview/llface.h
@@ -38,18 +38,19 @@
38#include "llquaternion.h" 38#include "llquaternion.h"
39#include "xform.h" 39#include "xform.h"
40#include "lldarrayptr.h" 40#include "lldarrayptr.h"
41#include "llvertexbuffer.h"
42#include "llviewerimage.h"
41#include "llpagemem.h" 43#include "llpagemem.h"
42#include "llstat.h" 44#include "llstat.h"
43#include "lldrawable.h" 45#include "lldrawable.h"
44 46
45#define ENABLE_FACE_LINKING 1 // Causes problems with snapshot rendering 47class LLFacePool;
46
47class LLDrawPool;
48class LLVolume; 48class LLVolume;
49class LLViewerImage; 49class LLViewerImage;
50class LLTextureEntry; 50class LLTextureEntry;
51class LLVertexProgram; 51class LLVertexProgram;
52class LLViewerImage; 52class LLViewerImage;
53class LLGeometryManager;
53 54
54class LLFace 55class LLFace
55{ 56{
@@ -57,26 +58,12 @@ public:
57 58
58 enum EMasks 59 enum EMasks
59 { 60 {
60 SHARED_GEOM = 0x0001, 61 LIGHT = 0x0001,
61 LIGHT = 0x0002, 62 GLOBAL = 0x0002,
62 REBUILD = 0x0004, 63 FULLBRIGHT = 0x0004,
63 GLOBAL = 0x0008, 64 HUD_RENDER = 0x0008,
64 VISIBLE = 0x0010, 65 USE_FACE_COLOR = 0x0010,
65 BACKLIST = 0x0020, 66 TEXTURE_ANIM = 0x0020,
66 INTERP = 0x0040,
67 FULLBRIGHT = 0x0080,
68 HUD_RENDER = 0x0100,
69 USE_FACE_COLOR = 0x0200,
70
71 POINT_SPRITE = 0x10000,
72 BOARD_SPRITE = 0x20000,
73 FIXED_SPRITE = 0x40000,
74 DEPTH_SPRITE = 0x80000
75 };
76
77 enum EDirty
78 {
79 DIRTY = -2
80 }; 67 };
81 68
82 static void initClass(); 69 static void initClass();
@@ -93,54 +80,64 @@ public:
93 const S32 getGeomIndex() const { return mGeomIndex; } // index into draw pool 80 const S32 getGeomIndex() const { return mGeomIndex; } // index into draw pool
94 const U32 getGeomStart() const { return mGeomIndex; } // index into draw pool 81 const U32 getGeomStart() const { return mGeomIndex; } // index into draw pool
95 LLViewerImage* getTexture() const { return mTexture; } 82 LLViewerImage* getTexture() const { return mTexture; }
83 void setTexture(LLViewerImage* tex) { mTexture = tex; }
96 LLXformMatrix* getXform() const { return mXform; } 84 LLXformMatrix* getXform() const { return mXform; }
97 BOOL hasGeometry() const { return mGeomCount > 0; } 85 BOOL hasGeometry() const { return mGeomCount > 0; }
98 LLVector3 getPositionAgent() const; 86 LLVector3 getPositionAgent() const;
99 void setPrimType(U32 primType) { mPrimType = primType; } 87
100 const U32 getPrimType() const { return mPrimType; }
101
102 U32 getState() const { return mState; } 88 U32 getState() const { return mState; }
103 void setState(U32 state) { mState |= state; } 89 void setState(U32 state) { mState |= state; }
104 void clearState(U32 state) { mState &= ~state; } 90 void clearState(U32 state) { mState &= ~state; }
105 BOOL isState(U32 state) const { return ((mState & state) != 0); } 91 BOOL isState(U32 state) const { return ((mState & state) != 0) ? TRUE : FALSE; }
106 92 void setVirtualSize(F32 size) { mVSize = size; }
93 void setPixelArea(F32 area) { mPixelArea = area; }
94 F32 getVirtualSize() const { return mVSize; }
95 F32 getPixelArea() const { return mPixelArea; }
107 void bindTexture(S32 stage = 0) const { LLViewerImage::bindTexture(mTexture, stage); } 96 void bindTexture(S32 stage = 0) const { LLViewerImage::bindTexture(mTexture, stage); }
108 97
109 void enableLights() const; 98 void enableLights() const;
110 void renderSetColor() const; 99 void renderSetColor() const;
111 S32 renderElements(const U32 *index_array) const; 100 S32 renderElements(const U32 *index_array) const;
112 S32 renderIndexed (const U32 *index_array) const; 101 S32 renderIndexed ();
102 S32 renderIndexed (U32 mask);
113 S32 pushVertices(const U32* index_array) const; 103 S32 pushVertices(const U32* index_array) const;
114 104
115 void setWorldMatrix(const LLMatrix4& mat); 105 void setWorldMatrix(const LLMatrix4& mat);
116 const LLTextureEntry* getTextureEntry() const { return mVObjp->getTE(mTEOffset); } 106 const LLTextureEntry* getTextureEntry() const { return mVObjp->getTE(mTEOffset); }
117 107
118 LLDrawPool* getPool() const { return mDrawPoolp; } 108 LLFacePool* getPool() const { return mDrawPoolp; }
119 S32 getStride() const { return mDrawPoolp->getStride(); } 109 U32 getPoolType() const { return mPoolType; }
120 const U32* getRawIndices() const { return &mDrawPoolp->mIndices[mIndicesIndex]; }
121 LLDrawable* getDrawable() const { return mDrawablep; } 110 LLDrawable* getDrawable() const { return mDrawablep; }
122 LLViewerObject* getViewerObject() const { return mVObjp; } 111 LLViewerObject* getViewerObject() const { return mVObjp; }
123 112 S32 getLOD() const { return mVObjp.notNull() ? mVObjp->getLOD() : 0; }
124 void clearDirty() { mGeneration = mDrawPoolp->mGeneration; }; 113 LLVertexBuffer* getVertexBuffer() const { return mVertexBuffer; }
125 114 void setPoolType(U32 type) { mPoolType = type; }
126 S32 backup(); 115 S32 getTEOffset() { return mTEOffset; }
127 void restore();
128 116
129 void setViewerObject(LLViewerObject* object); 117 void setViewerObject(LLViewerObject* object);
130 void setPool(LLDrawPool *pool, LLViewerImage *texturep); 118 void setPool(LLFacePool *pool, LLViewerImage *texturep);
119
131 void setDrawable(LLDrawable *drawable); 120 void setDrawable(LLDrawable *drawable);
132 void setTEOffset(const S32 te_offset); 121 void setTEOffset(const S32 te_offset);
133 S32 getTEOffset() { return mTEOffset; } 122
134 123
135 void setFaceColor(const LLColor4& color); // override material color 124 void setFaceColor(const LLColor4& color); // override material color
136 void unsetFaceColor(); // switch back to material color 125 void unsetFaceColor(); // switch back to material color
137 const LLColor4& getFaceColor() const { return mFaceColor; } 126 const LLColor4& getFaceColor() const { return mFaceColor; }
138 const LLColor4& getRenderColor() const; 127 const LLColor4& getRenderColor() const;
139 128
140 void unReserve(); // Set Removed from pool 129 //for volumes
141 130 S32 getGeometryVolume(const LLVolume& volume,
142 BOOL reserveIfNeeded(); // Reserves data if dirty. 131 S32 f,
143 132 LLStrider<LLVector3>& vertices,
133 LLStrider<LLVector3>& normals,
134 LLStrider<LLVector2>& texcoords,
135 LLStrider<LLVector2>& texcoords2,
136 LLStrider<LLColor4U>& colors,
137 LLStrider<U32>& indices,
138 const LLMatrix4& mat_vert, const LLMatrix3& mat_normal,
139 U32& index_offset);
140
144 // For avatar 141 // For avatar
145 S32 getGeometryAvatar( 142 S32 getGeometryAvatar(
146 LLStrider<LLVector3> &vertices, 143 LLStrider<LLVector3> &vertices,
@@ -156,69 +153,51 @@ public:
156 LLStrider<LLColor4U> &colors, 153 LLStrider<LLColor4U> &colors,
157 LLStrider<LLVector2> &texCoords0, 154 LLStrider<LLVector2> &texCoords0,
158 LLStrider<LLVector2> &texCoords1, 155 LLStrider<LLVector2> &texCoords1,
159 U32* &indices); 156 LLStrider<U32> &indices);
160 157
161 // For volumes, etc. 158 // For volumes, etc.
162 S32 getGeometry(LLStrider<LLVector3> &vertices, 159 S32 getGeometry(LLStrider<LLVector3> &vertices,
163 LLStrider<LLVector3> &normals, 160 LLStrider<LLVector3> &normals,
164 LLStrider<LLVector2> &texCoords, 161 LLStrider<LLVector2> &texCoords,
165 U32* &indices); 162 LLStrider<U32> &indices);
166 163
167 S32 getGeometryColors(LLStrider<LLVector3> &vertices, 164 S32 getGeometryColors(LLStrider<LLVector3> &vertices,
168 LLStrider<LLVector3> &normals, 165 LLStrider<LLVector3> &normals,
169 LLStrider<LLVector2> &texCoords, 166 LLStrider<LLVector2> &texCoords,
170 LLStrider<LLColor4U> &colors, 167 LLStrider<LLColor4U> &colors,
171 U32* &indices); 168 LLStrider<U32> &indices);
172 169
173 S32 getGeometryMultiTexture(LLStrider<LLVector3> &vertices, 170 S32 getVertices(LLStrider<LLVector3> &vertices);
174 LLStrider<LLVector3> &normals, 171 S32 getColors(LLStrider<LLColor4U> &colors);
175 LLStrider<LLVector3> &binormals, 172 S32 getIndices(LLStrider<U32> &indices);
176 LLStrider<LLVector2> &texCoords0,
177 LLStrider<LLVector2> &texCoords1,
178 U32* &indices);
179
180
181 S32 getVertices (LLStrider<LLVector3> &vertices);
182 S32 getColors (LLStrider<LLColor4U> &colors);
183 S32 getIndices (U32* &indices);
184 173
185 void setSize(const S32 numVertices, const S32 num_indices = 0); 174 void setSize(const S32 numVertices, const S32 num_indices = 0);
186 BOOL getDirty() const { return (mGeneration != mDrawPoolp->mGeneration); } 175
187 176 BOOL genVolumeBBoxes(const LLVolume &volume, S32 f,
188 BOOL genVolumeTriangles(const LLVolume &volume, S32 f,
189 const LLMatrix4& mat, const LLMatrix3& inv_trans_mat, BOOL global_volume = FALSE);
190 BOOL genVolumeTriangles(const LLVolume &volume, S32 fstart, S32 fend,
191 const LLMatrix4& mat, const LLMatrix3& inv_trans_mat, BOOL global_volume = FALSE); 177 const LLMatrix4& mat, const LLMatrix3& inv_trans_mat, BOOL global_volume = FALSE);
192 BOOL genLighting(const LLVolume* volume, const LLDrawable* drawablep, S32 fstart, S32 fend, 178
193 const LLMatrix4& mat_vert, const LLMatrix3& mat_normal, BOOL do_lighting);
194
195 BOOL genShadows(const LLVolume* volume, const LLDrawable* drawablep, S32 fstart, S32 fend,
196 const LLMatrix4& mat_vert, const LLMatrix3& mat_normal, BOOL use_shadow_factor);
197
198 void init(LLDrawable* drawablep, LLViewerObject* objp); 179 void init(LLDrawable* drawablep, LLViewerObject* objp);
199 void destroy(); 180 void destroy();
200 void update(); 181 void update();
201 182
202 void updateCenterAgent(); // Update center when xform has changed. 183 void updateCenterAgent(); // Update center when xform has changed.
203 void renderSelectedUV(const S32 offset = 0, const S32 count = 0); 184 void renderSelectedUV(const S32 offset = 0, const S32 count = 0);
204 185
205 void renderForSelect() const; 186 void renderForSelect(U32 data_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD);
206 void renderSelected(LLImageGL *image, const LLColor4 &color, const S32 offset = 0, const S32 count = 0); 187 void renderSelected(LLImageGL *image, const LLColor4 &color, const S32 offset = 0, const S32 count = 0);
207 188
208 F32 getKey() const { return mDistance; } 189 F32 getKey() const { return mDistance; }
209 190
210 S32 getGeneration() const { return mGeneration; }
211 S32 getReferenceIndex() const { return mReferenceIndex; } 191 S32 getReferenceIndex() const { return mReferenceIndex; }
212 void setReferenceIndex(const S32 index) { mReferenceIndex = index; } 192 void setReferenceIndex(const S32 index) { mReferenceIndex = index; }
213 193
214 BOOL verify(const U32* indices_array = NULL) const; 194 BOOL verify(const U32* indices_array = NULL) const;
215 void printDebugInfo() const; 195 void printDebugInfo() const;
216 196
217 void link(LLFace* facep); 197 void setGeomIndex(S32 idx) { mGeomIndex = idx; }
198 void setIndicesIndex(S32 idx) { mIndicesIndex = idx; }
218 199
219protected: 200protected:
220 S32 allocBackupMem(); // Allocate backup memory based on the draw pool information.
221 void setDirty();
222 201
223public: 202public:
224 LLVector3 mCenterLocal; 203 LLVector3 mCenterLocal;
@@ -227,30 +206,40 @@ public:
227 LLVector2 mTexExtents[2]; 206 LLVector2 mTexExtents[2];
228 F32 mDistance; 207 F32 mDistance;
229 F32 mAlphaFade; 208 F32 mAlphaFade;
230 LLFace* mNextFace; 209 LLPointer<LLVertexBuffer> mVertexBuffer;
231 BOOL mSkipRender; 210 LLPointer<LLVertexBuffer> mLastVertexBuffer;
232 211 F32 mLastUpdateTime;
212 LLMatrix4 mTextureMatrix;
213
233protected: 214protected:
234 S32 mGeneration; 215 friend class LLGeometryManager;
216 friend class LLVolumeGeometryManager;
217
235 U32 mState; 218 U32 mState;
236 LLDrawPool* mDrawPoolp; 219 LLFacePool* mDrawPoolp;
237 S32 mGeomIndex; // index into draw pool 220 U32 mPoolType;
238 LLColor4 mFaceColor; // overrides material color if state |= USE_FACE_COLOR 221 LLColor4 mFaceColor; // overrides material color if state |= USE_FACE_COLOR
239 222
240 U32 mPrimType;
241 S32 mGeomCount; // vertex count for this face 223 S32 mGeomCount; // vertex count for this face
224 S32 mGeomIndex; // index into draw pool
242 U32 mIndicesCount; 225 U32 mIndicesCount;
243 S32 mIndicesIndex; // index into draw pool for indices (yeah, I know!) 226 S32 mIndicesIndex; // index into draw pool for indices (yeah, I know!)
244 LLXformMatrix* mXform;
245 LLPointer<LLViewerImage> mTexture;
246 227
247 U8 *mBackupMem; 228 //previous rebuild's geometry info
229 S32 mLastGeomCount;
230 S32 mLastGeomIndex;
231 U32 mLastIndicesCount;
232 S32 mLastIndicesIndex;
248 233
234 LLXformMatrix* mXform;
235 LLPointer<LLViewerImage> mTexture;
249 LLPointer<LLDrawable> mDrawablep; 236 LLPointer<LLDrawable> mDrawablep;
250 LLPointer<LLViewerObject> mVObjp; 237 LLPointer<LLViewerObject> mVObjp;
251 S32 mTEOffset; 238 S32 mTEOffset;
252 239
253 S32 mReferenceIndex; 240 S32 mReferenceIndex;
241 F32 mVSize;
242 F32 mPixelArea;
254 243
255protected: 244protected:
256 static BOOL sSafeRenderSelect; 245 static BOOL sSafeRenderSelect;
@@ -264,6 +253,43 @@ public:
264 } 253 }
265 }; 254 };
266 255
256 struct CompareTexture
257 {
258 bool operator()(const LLFace* const& lhs, const LLFace* const& rhs)
259 {
260 return lhs->getTexture() < rhs->getTexture();
261 }
262 };
263
264 struct CompareTextureAndGeomCount
265 {
266 bool operator()(const LLFace* const& lhs, const LLFace* const& rhs)
267 {
268 return lhs->getTexture() == rhs->getTexture() ?
269 lhs->getGeomCount() < rhs->getGeomCount() :
270 lhs->getTexture() > rhs->getTexture();
271 }
272 };
273
274 struct CompareTextureAndLOD
275 {
276 bool operator()(const LLFace* const& lhs, const LLFace* const& rhs)
277 {
278 return lhs->getTexture() == rhs->getTexture() ?
279 lhs->getLOD() < rhs->getLOD() :
280 lhs->getTexture() < rhs->getTexture();
281 }
282 };
283
284 struct CompareTextureAndTime
285 {
286 bool operator()(const LLFace* const& lhs, const LLFace* const& rhs)
287 {
288 return lhs->getTexture() == rhs->getTexture() ?
289 lhs->mLastUpdateTime < rhs->mLastUpdateTime :
290 lhs->getTexture() < rhs->getTexture();
291 }
292 };
267}; 293};
268 294
269#endif // LL_LLFACE_H 295#endif // LL_LLFACE_H