diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llface.h | |
parent | README.txt (diff) | |
download | meta-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/llface.h')
-rw-r--r-- | linden/indra/newview/llface.h | 269 |
1 files changed, 269 insertions, 0 deletions
diff --git a/linden/indra/newview/llface.h b/linden/indra/newview/llface.h new file mode 100644 index 0000000..cb3b705 --- /dev/null +++ b/linden/indra/newview/llface.h | |||
@@ -0,0 +1,269 @@ | |||
1 | /** | ||
2 | * @file llface.h | ||
3 | * @brief LLFace class definition | ||
4 | * | ||
5 | * Copyright (c) 2001-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_LLFACE_H | ||
29 | #define LL_LLFACE_H | ||
30 | |||
31 | #include "llstrider.h" | ||
32 | |||
33 | #include "v2math.h" | ||
34 | #include "v3math.h" | ||
35 | #include "v4math.h" | ||
36 | #include "m4math.h" | ||
37 | #include "v4coloru.h" | ||
38 | #include "llquaternion.h" | ||
39 | #include "xform.h" | ||
40 | #include "lldarrayptr.h" | ||
41 | #include "llpagemem.h" | ||
42 | #include "llstat.h" | ||
43 | #include "lldrawable.h" | ||
44 | |||
45 | #define ENABLE_FACE_LINKING 1 // Causes problems with snapshot rendering | ||
46 | |||
47 | class LLDrawPool; | ||
48 | class LLVolume; | ||
49 | class LLViewerImage; | ||
50 | class LLTextureEntry; | ||
51 | class LLVertexProgram; | ||
52 | class LLViewerImage; | ||
53 | |||
54 | class LLFace | ||
55 | { | ||
56 | public: | ||
57 | |||
58 | enum EMasks | ||
59 | { | ||
60 | SHARED_GEOM = 0x0001, | ||
61 | LIGHT = 0x0002, | ||
62 | REBUILD = 0x0004, | ||
63 | GLOBAL = 0x0008, | ||
64 | VISIBLE = 0x0010, | ||
65 | BACKLIST = 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 | }; | ||
81 | |||
82 | static void initClass(); | ||
83 | |||
84 | public: | ||
85 | LLFace(LLDrawable* drawablep, LLViewerObject* objp) { init(drawablep, objp); } | ||
86 | ~LLFace() { destroy(); } | ||
87 | |||
88 | const LLMatrix4& getWorldMatrix() const { return mVObjp->getWorldMatrix(mXform); } | ||
89 | const LLMatrix4& getRenderMatrix() const; | ||
90 | const U32 getIndicesCount() const { return mIndicesCount; }; | ||
91 | const S32 getIndicesStart() const { return mIndicesIndex; }; | ||
92 | const S32 getGeomCount() const { return mGeomCount; } // vertex count for this face | ||
93 | const S32 getGeomIndex() const { return mGeomIndex; } // index into draw pool | ||
94 | const U32 getGeomStart() const { return mGeomIndex; } // index into draw pool | ||
95 | LLViewerImage* getTexture() const { return mTexture; } | ||
96 | LLXformMatrix* getXform() const { return mXform; } | ||
97 | BOOL hasGeometry() const { return mGeomCount > 0; } | ||
98 | LLVector3 getPositionAgent() const; | ||
99 | void setPrimType(U32 primType) { mPrimType = primType; } | ||
100 | const U32 getPrimType() const { return mPrimType; } | ||
101 | |||
102 | U32 getState() const { return mState; } | ||
103 | void setState(U32 state) { mState |= state; } | ||
104 | void clearState(U32 state) { mState &= ~state; } | ||
105 | BOOL isState(U32 state) const { return ((mState & state) != 0); } | ||
106 | |||
107 | void bindTexture(S32 stage = 0) const { LLViewerImage::bindTexture(mTexture, stage); } | ||
108 | |||
109 | void enableLights() const; | ||
110 | void renderSetColor() const; | ||
111 | S32 renderElements(const U32 *index_array) const; | ||
112 | S32 renderIndexed (const U32 *index_array) const; | ||
113 | S32 pushVertices(const U32* index_array) const; | ||
114 | |||
115 | void setWorldMatrix(const LLMatrix4& mat); | ||
116 | const LLTextureEntry* getTextureEntry() const { return mVObjp->getTE(mTEOffset); } | ||
117 | |||
118 | LLDrawPool* getPool() const { return mDrawPoolp; } | ||
119 | S32 getStride() const { return mDrawPoolp->getStride(); } | ||
120 | const U32* getRawIndices() const { return &mDrawPoolp->mIndices[mIndicesIndex]; } | ||
121 | LLDrawable* getDrawable() const { return mDrawablep; } | ||
122 | LLViewerObject* getViewerObject() const { return mVObjp; } | ||
123 | |||
124 | void clearDirty() { mGeneration = mDrawPoolp->mGeneration; }; | ||
125 | |||
126 | S32 backup(); | ||
127 | void restore(); | ||
128 | |||
129 | void setViewerObject(LLViewerObject* object); | ||
130 | void setPool(LLDrawPool *pool, LLViewerImage *texturep); | ||
131 | void setDrawable(LLDrawable *drawable); | ||
132 | void setTEOffset(const S32 te_offset); | ||
133 | S32 getTEOffset() { return mTEOffset; } | ||
134 | |||
135 | void setFaceColor(const LLColor4& color); // override material color | ||
136 | void unsetFaceColor(); // switch back to material color | ||
137 | const LLColor4& getFaceColor() const { return mFaceColor; } | ||
138 | const LLColor4& getRenderColor() const; | ||
139 | |||
140 | void unReserve(); // Set Removed from pool | ||
141 | |||
142 | BOOL reserveIfNeeded(); // Reserves data if dirty. | ||
143 | |||
144 | // For avatar | ||
145 | S32 getGeometryAvatar( | ||
146 | LLStrider<LLVector3> &vertices, | ||
147 | LLStrider<LLVector3> &normals, | ||
148 | LLStrider<LLVector3> &binormals, | ||
149 | LLStrider<LLVector2> &texCoords, | ||
150 | LLStrider<F32> &vertex_weights, | ||
151 | LLStrider<LLVector4> &clothing_weights); | ||
152 | |||
153 | // For terrain | ||
154 | S32 getGeometryTerrain(LLStrider<LLVector3> &vertices, | ||
155 | LLStrider<LLVector3> &normals, | ||
156 | LLStrider<LLColor4U> &colors, | ||
157 | LLStrider<LLVector2> &texCoords0, | ||
158 | LLStrider<LLVector2> &texCoords1, | ||
159 | U32* &indices); | ||
160 | |||
161 | // For volumes, etc. | ||
162 | S32 getGeometry(LLStrider<LLVector3> &vertices, | ||
163 | LLStrider<LLVector3> &normals, | ||
164 | LLStrider<LLVector2> &texCoords, | ||
165 | U32* &indices); | ||
166 | |||
167 | S32 getGeometryColors(LLStrider<LLVector3> &vertices, | ||
168 | LLStrider<LLVector3> &normals, | ||
169 | LLStrider<LLVector2> &texCoords, | ||
170 | LLStrider<LLColor4U> &colors, | ||
171 | U32* &indices); | ||
172 | |||
173 | S32 getGeometryMultiTexture(LLStrider<LLVector3> &vertices, | ||
174 | LLStrider<LLVector3> &normals, | ||
175 | LLStrider<LLVector3> &binormals, | ||
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 | |||
185 | void setSize(const S32 numVertices, const S32 num_indices = 0); | ||
186 | BOOL getDirty() const { return (mGeneration != mDrawPoolp->mGeneration); } | ||
187 | |||
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); | ||
192 | BOOL genLighting(const LLVolume* volume, const LLDrawable* drawablep, S32 fstart, S32 fend, | ||
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); | ||
199 | void destroy(); | ||
200 | void update(); | ||
201 | |||
202 | void updateCenterAgent(); // Update center when xform has changed. | ||
203 | void renderSelectedUV(const S32 offset = 0, const S32 count = 0); | ||
204 | |||
205 | void renderForSelect() const; | ||
206 | void renderSelected(LLImageGL *image, const LLColor4 &color, const S32 offset = 0, const S32 count = 0); | ||
207 | |||
208 | F32 getKey() const { return mDistance; } | ||
209 | |||
210 | S32 getGeneration() const { return mGeneration; } | ||
211 | S32 getReferenceIndex() const { return mReferenceIndex; } | ||
212 | void setReferenceIndex(const S32 index) { mReferenceIndex = index; } | ||
213 | |||
214 | BOOL verify(const U32* indices_array = NULL) const; | ||
215 | void printDebugInfo() const; | ||
216 | |||
217 | void link(LLFace* facep); | ||
218 | |||
219 | protected: | ||
220 | S32 allocBackupMem(); // Allocate backup memory based on the draw pool information. | ||
221 | void setDirty(); | ||
222 | |||
223 | public: | ||
224 | LLVector3 mCenterLocal; | ||
225 | LLVector3 mCenterAgent; | ||
226 | LLVector3 mExtents[2]; | ||
227 | LLVector2 mTexExtents[2]; | ||
228 | F32 mDistance; | ||
229 | F32 mAlphaFade; | ||
230 | LLFace* mNextFace; | ||
231 | BOOL mSkipRender; | ||
232 | |||
233 | protected: | ||
234 | S32 mGeneration; | ||
235 | U32 mState; | ||
236 | LLDrawPool* mDrawPoolp; | ||
237 | S32 mGeomIndex; // index into draw pool | ||
238 | LLColor4 mFaceColor; // overrides material color if state |= USE_FACE_COLOR | ||
239 | |||
240 | U32 mPrimType; | ||
241 | S32 mGeomCount; // vertex count for this face | ||
242 | U32 mIndicesCount; | ||
243 | S32 mIndicesIndex; // index into draw pool for indices (yeah, I know!) | ||
244 | LLXformMatrix* mXform; | ||
245 | LLPointer<LLViewerImage> mTexture; | ||
246 | |||
247 | U8 *mBackupMem; | ||
248 | |||
249 | LLPointer<LLDrawable> mDrawablep; | ||
250 | LLPointer<LLViewerObject> mVObjp; | ||
251 | S32 mTEOffset; | ||
252 | |||
253 | S32 mReferenceIndex; | ||
254 | |||
255 | protected: | ||
256 | static BOOL sSafeRenderSelect; | ||
257 | |||
258 | public: | ||
259 | struct CompareDistanceGreater | ||
260 | { | ||
261 | bool operator()(const LLFace* const& lhs, const LLFace* const& rhs) | ||
262 | { | ||
263 | return lhs->mDistance > rhs->mDistance; // farthest = first | ||
264 | } | ||
265 | }; | ||
266 | |||
267 | }; | ||
268 | |||
269 | #endif // LL_LLFACE_H | ||