aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llvotextbubble.cpp
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/llvotextbubble.cpp
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 '')
-rw-r--r--linden/indra/newview/llvotextbubble.cpp223
1 files changed, 223 insertions, 0 deletions
diff --git a/linden/indra/newview/llvotextbubble.cpp b/linden/indra/newview/llvotextbubble.cpp
new file mode 100644
index 0000000..96ffe6b
--- /dev/null
+++ b/linden/indra/newview/llvotextbubble.cpp
@@ -0,0 +1,223 @@
1/**
2 * @file llvotextbubble.cpp
3 * @brief Viewer-object text bubble.
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#include "llviewerprecompiledheaders.h"
29
30#include "llvotextbubble.h"
31
32#include "imageids.h"
33#include "llviewercontrol.h"
34#include "llprimitive.h"
35#include "llsphere.h"
36
37#include "llagent.h"
38#include "llbox.h"
39#include "lldrawable.h"
40#include "llface.h"
41#include "llviewerimagelist.h"
42#include "llvolume.h"
43#include "pipeline.h"
44
45LLVOTextBubble::LLVOTextBubble(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp)
46: LLViewerObject(id, pcode, regionp)
47{
48 setScale(LLVector3(1.5f, 1.5f, 0.25f));
49 mbCanSelect = FALSE;
50 mLOD = MIN_LOD;
51 mVolumeChanged = TRUE;
52 setVelocity(LLVector3(0.f, 0.f, 0.75f));
53 LLVolumeParams volume_params;
54 volume_params.setType(LL_PCODE_PROFILE_CIRCLE, LL_PCODE_PATH_LINE);
55 volume_params.setBeginAndEndS(0.f, 1.f);
56 volume_params.setBeginAndEndT(0.f, 1.f);
57 volume_params.setRatio(0.25f, 0.25f);
58 volume_params.setShear(0.f, 0.f);
59 setVolume(volume_params);
60 mColor = LLColor4(1.0f, 0.0f, 0.0f, 1.f);
61 S32 i;
62 for (i = 0; i < getNumTEs(); i++)
63 {
64 setTEColor(i, mColor);
65 setTETexture(i, LLUUID(IMG_DEFAULT));
66 }
67}
68
69
70LLVOTextBubble::~LLVOTextBubble()
71{
72}
73
74
75BOOL LLVOTextBubble::isActive() const
76{
77 return TRUE;
78}
79
80BOOL LLVOTextBubble::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
81{
82 F32 dt = mUpdateTimer.getElapsedTimeF32();
83 // Die after a few seconds.
84 if (dt > 1.5f)
85 {
86 return FALSE;
87 }
88
89 LLViewerObject::idleUpdate(agent, world, time);
90
91 setScale(0.5f * (1.f+dt) * LLVector3(1.5f, 1.5f, 0.5f));
92
93 F32 alpha = 0.35f*dt;
94
95 LLColor4 color = mColor;
96 color.mV[VALPHA] -= alpha;
97 if (color.mV[VALPHA] <= 0.05f)
98 {
99 return FALSE;
100 }
101 S32 i;
102 for (i = 0; i < getNumTEs(); i++)
103 {
104 setTEColor(i, color);
105 }
106
107 return TRUE;
108}
109
110
111void LLVOTextBubble::updateTextures(LLAgent &agent)
112{
113 // Update the image levels of all textures...
114 // First we do some quick checks.
115 U32 i;
116
117 // This doesn't take into account whether the object is in front
118 // or behind...
119
120 LLVector3 position_local = getPositionAgent() - agent.getCameraPositionAgent();
121 F32 dot_product = position_local * agent.getFrameAgent().getAtAxis();
122 F32 cos_angle = dot_product / position_local.magVec();
123
124 if (cos_angle > 1.f)
125 {
126 cos_angle = 1.f;
127 }
128
129 for (i = 0; i < getNumTEs(); i++)
130 {
131 const LLTextureEntry *te = getTE(i);
132 F32 texel_area_ratio = fabs(te->mScaleS * te->mScaleT);
133
134 LLViewerImage *imagep = getTEImage(i);
135 if (imagep)
136 {
137 imagep->addTextureStats(mPixelArea, texel_area_ratio, cos_angle);
138 }
139 }
140}
141
142
143LLDrawable *LLVOTextBubble::createDrawable(LLPipeline *pipeline)
144{
145 pipeline->allocDrawable(this);
146 mDrawable->setLit(FALSE);
147 mDrawable->setRenderType(LLPipeline::RENDER_TYPE_VOLUME);
148 LLDrawPool *poolp;
149 for (U32 i = 0; i < getNumTEs(); i++)
150 {
151 LLViewerImage *imagep;
152 const LLTextureEntry *texture_entry = getTE(i);
153 imagep = gImageList.getImage(texture_entry->getID());
154
155 poolp = gPipeline.getPool(LLDrawPool::POOL_ALPHA);
156 mDrawable->addFace(poolp, imagep);
157 }
158
159 return mDrawable;
160}
161
162
163BOOL LLVOTextBubble::setVolume(const LLVolumeParams &volume_params)
164{
165 if (LLPrimitive::setVolume(volume_params, mLOD))
166 {
167 if (mDrawable)
168 {
169 gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_VOLUME, TRUE);
170 mVolumeChanged = TRUE;
171 }
172 return TRUE;
173 }
174 return FALSE;
175}
176
177
178BOOL LLVOTextBubble::updateLOD()
179{
180 return FALSE;
181}
182
183BOOL LLVOTextBubble::updateGeometry(LLDrawable *drawable)
184{
185 if (!(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_VOLUME)))
186 return TRUE;
187
188 if (mVolumeChanged)
189 {
190 LLVolumeParams volume_params = getVolume()->getParams();
191 setVolume(volume_params);
192
193 LLPipeline::sCompiles++;
194
195 drawable->setNumFaces(getVolume()->getNumFaces(), drawable->getFace(0)->getPool(), getTEImage(0));
196 }
197
198 LLMatrix4 identity4;
199 LLMatrix3 identity3;
200 for (S32 i = 0; i < drawable->getNumFaces(); i++)
201 {
202 LLFace *face = drawable->getFace(i);
203
204 if (i == 0)
205 {
206 face->setSize(0);
207 continue;
208 }
209 if (i == 2)
210 {
211 face->setSize(0);
212 continue;
213 }
214
215 // Need to figure out how to readd logic to determine face dirty vs. entire object dirty.
216 face->setTEOffset(i);
217 face->clearState(LLFace::GLOBAL);
218 face->genVolumeTriangles(*getVolume(), i, identity4, identity3);
219 }
220 mVolumeChanged = FALSE;
221
222 return TRUE;
223}