From 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Fri, 15 Aug 2008 23:44:46 -0500 Subject: Second Life viewer sources 1.13.2.12 --- linden/indra/newview/llface.h | 269 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 269 insertions(+) create mode 100644 linden/indra/newview/llface.h (limited to 'linden/indra/newview/llface.h') 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 @@ +/** + * @file llface.h + * @brief LLFace class definition + * + * Copyright (c) 2001-2007, Linden Research, Inc. + * + * 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://secondlife.com/developers/opensource/gplv2 + * + * 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://secondlife.com/developers/opensource/flossexception + * + * 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. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + */ + +#ifndef LL_LLFACE_H +#define LL_LLFACE_H + +#include "llstrider.h" + +#include "v2math.h" +#include "v3math.h" +#include "v4math.h" +#include "m4math.h" +#include "v4coloru.h" +#include "llquaternion.h" +#include "xform.h" +#include "lldarrayptr.h" +#include "llpagemem.h" +#include "llstat.h" +#include "lldrawable.h" + +#define ENABLE_FACE_LINKING 1 // Causes problems with snapshot rendering + +class LLDrawPool; +class LLVolume; +class LLViewerImage; +class LLTextureEntry; +class LLVertexProgram; +class LLViewerImage; + +class LLFace +{ +public: + + enum EMasks + { + SHARED_GEOM = 0x0001, + LIGHT = 0x0002, + REBUILD = 0x0004, + GLOBAL = 0x0008, + VISIBLE = 0x0010, + BACKLIST = 0x0020, + INTERP = 0x0040, + FULLBRIGHT = 0x0080, + HUD_RENDER = 0x0100, + USE_FACE_COLOR = 0x0200, + + POINT_SPRITE = 0x10000, + BOARD_SPRITE = 0x20000, + FIXED_SPRITE = 0x40000, + DEPTH_SPRITE = 0x80000 + }; + + enum EDirty + { + DIRTY = -2 + }; + + static void initClass(); + +public: + LLFace(LLDrawable* drawablep, LLViewerObject* objp) { init(drawablep, objp); } + ~LLFace() { destroy(); } + + const LLMatrix4& getWorldMatrix() const { return mVObjp->getWorldMatrix(mXform); } + const LLMatrix4& getRenderMatrix() const; + const U32 getIndicesCount() const { return mIndicesCount; }; + const S32 getIndicesStart() const { return mIndicesIndex; }; + const S32 getGeomCount() const { return mGeomCount; } // vertex count for this face + const S32 getGeomIndex() const { return mGeomIndex; } // index into draw pool + const U32 getGeomStart() const { return mGeomIndex; } // index into draw pool + LLViewerImage* getTexture() const { return mTexture; } + LLXformMatrix* getXform() const { return mXform; } + BOOL hasGeometry() const { return mGeomCount > 0; } + LLVector3 getPositionAgent() const; + void setPrimType(U32 primType) { mPrimType = primType; } + const U32 getPrimType() const { return mPrimType; } + + U32 getState() const { return mState; } + void setState(U32 state) { mState |= state; } + void clearState(U32 state) { mState &= ~state; } + BOOL isState(U32 state) const { return ((mState & state) != 0); } + + void bindTexture(S32 stage = 0) const { LLViewerImage::bindTexture(mTexture, stage); } + + void enableLights() const; + void renderSetColor() const; + S32 renderElements(const U32 *index_array) const; + S32 renderIndexed (const U32 *index_array) const; + S32 pushVertices(const U32* index_array) const; + + void setWorldMatrix(const LLMatrix4& mat); + const LLTextureEntry* getTextureEntry() const { return mVObjp->getTE(mTEOffset); } + + LLDrawPool* getPool() const { return mDrawPoolp; } + S32 getStride() const { return mDrawPoolp->getStride(); } + const U32* getRawIndices() const { return &mDrawPoolp->mIndices[mIndicesIndex]; } + LLDrawable* getDrawable() const { return mDrawablep; } + LLViewerObject* getViewerObject() const { return mVObjp; } + + void clearDirty() { mGeneration = mDrawPoolp->mGeneration; }; + + S32 backup(); + void restore(); + + void setViewerObject(LLViewerObject* object); + void setPool(LLDrawPool *pool, LLViewerImage *texturep); + void setDrawable(LLDrawable *drawable); + void setTEOffset(const S32 te_offset); + S32 getTEOffset() { return mTEOffset; } + + void setFaceColor(const LLColor4& color); // override material color + void unsetFaceColor(); // switch back to material color + const LLColor4& getFaceColor() const { return mFaceColor; } + const LLColor4& getRenderColor() const; + + void unReserve(); // Set Removed from pool + + BOOL reserveIfNeeded(); // Reserves data if dirty. + + // For avatar + S32 getGeometryAvatar( + LLStrider &vertices, + LLStrider &normals, + LLStrider &binormals, + LLStrider &texCoords, + LLStrider &vertex_weights, + LLStrider &clothing_weights); + + // For terrain + S32 getGeometryTerrain(LLStrider &vertices, + LLStrider &normals, + LLStrider &colors, + LLStrider &texCoords0, + LLStrider &texCoords1, + U32* &indices); + + // For volumes, etc. + S32 getGeometry(LLStrider &vertices, + LLStrider &normals, + LLStrider &texCoords, + U32* &indices); + + S32 getGeometryColors(LLStrider &vertices, + LLStrider &normals, + LLStrider &texCoords, + LLStrider &colors, + U32* &indices); + + S32 getGeometryMultiTexture(LLStrider &vertices, + LLStrider &normals, + LLStrider &binormals, + LLStrider &texCoords0, + LLStrider &texCoords1, + U32* &indices); + + + S32 getVertices (LLStrider &vertices); + S32 getColors (LLStrider &colors); + S32 getIndices (U32* &indices); + + void setSize(const S32 numVertices, const S32 num_indices = 0); + BOOL getDirty() const { return (mGeneration != mDrawPoolp->mGeneration); } + + BOOL genVolumeTriangles(const LLVolume &volume, S32 f, + const LLMatrix4& mat, const LLMatrix3& inv_trans_mat, BOOL global_volume = FALSE); + BOOL genVolumeTriangles(const LLVolume &volume, S32 fstart, S32 fend, + const LLMatrix4& mat, const LLMatrix3& inv_trans_mat, BOOL global_volume = FALSE); + BOOL genLighting(const LLVolume* volume, const LLDrawable* drawablep, S32 fstart, S32 fend, + const LLMatrix4& mat_vert, const LLMatrix3& mat_normal, BOOL do_lighting); + + BOOL genShadows(const LLVolume* volume, const LLDrawable* drawablep, S32 fstart, S32 fend, + const LLMatrix4& mat_vert, const LLMatrix3& mat_normal, BOOL use_shadow_factor); + + void init(LLDrawable* drawablep, LLViewerObject* objp); + void destroy(); + void update(); + + void updateCenterAgent(); // Update center when xform has changed. + void renderSelectedUV(const S32 offset = 0, const S32 count = 0); + + void renderForSelect() const; + void renderSelected(LLImageGL *image, const LLColor4 &color, const S32 offset = 0, const S32 count = 0); + + F32 getKey() const { return mDistance; } + + S32 getGeneration() const { return mGeneration; } + S32 getReferenceIndex() const { return mReferenceIndex; } + void setReferenceIndex(const S32 index) { mReferenceIndex = index; } + + BOOL verify(const U32* indices_array = NULL) const; + void printDebugInfo() const; + + void link(LLFace* facep); + +protected: + S32 allocBackupMem(); // Allocate backup memory based on the draw pool information. + void setDirty(); + +public: + LLVector3 mCenterLocal; + LLVector3 mCenterAgent; + LLVector3 mExtents[2]; + LLVector2 mTexExtents[2]; + F32 mDistance; + F32 mAlphaFade; + LLFace* mNextFace; + BOOL mSkipRender; + +protected: + S32 mGeneration; + U32 mState; + LLDrawPool* mDrawPoolp; + S32 mGeomIndex; // index into draw pool + LLColor4 mFaceColor; // overrides material color if state |= USE_FACE_COLOR + + U32 mPrimType; + S32 mGeomCount; // vertex count for this face + U32 mIndicesCount; + S32 mIndicesIndex; // index into draw pool for indices (yeah, I know!) + LLXformMatrix* mXform; + LLPointer mTexture; + + U8 *mBackupMem; + + LLPointer mDrawablep; + LLPointer mVObjp; + S32 mTEOffset; + + S32 mReferenceIndex; + +protected: + static BOOL sSafeRenderSelect; + +public: + struct CompareDistanceGreater + { + bool operator()(const LLFace* const& lhs, const LLFace* const& rhs) + { + return lhs->mDistance > rhs->mDistance; // farthest = first + } + }; + +}; + +#endif // LL_LLFACE_H -- cgit v1.1