aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llvoclouds.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:50 -0500
committerJacek Antonelli2008-08-15 23:44:50 -0500
commit89fe5dab825a62a0e3fd8d248cbc91c65eb2a426 (patch)
treebcff14b7888d04a2fec799c59369f6095224bd08 /linden/indra/newview/llvoclouds.cpp
parentSecond Life viewer sources 1.13.3.2 (diff)
downloadmeta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.zip
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.gz
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.bz2
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.xz
Second Life viewer sources 1.14.0.0
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llvoclouds.cpp177
1 files changed, 126 insertions, 51 deletions
diff --git a/linden/indra/newview/llvoclouds.cpp b/linden/indra/newview/llvoclouds.cpp
index a4e424a..7d1d958 100644
--- a/linden/indra/newview/llvoclouds.cpp
+++ b/linden/indra/newview/llvoclouds.cpp
@@ -29,6 +29,8 @@
29 29
30#include "llvoclouds.h" 30#include "llvoclouds.h"
31 31
32#include "lldrawpoolalpha.h"
33
32#include "llviewercontrol.h" 34#include "llviewercontrol.h"
33 35
34#include "llagent.h" // to get camera position 36#include "llagent.h" // to get camera position
@@ -46,7 +48,7 @@
46#include "viewer.h" 48#include "viewer.h"
47 49
48LLVOClouds::LLVOClouds(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) 50LLVOClouds::LLVOClouds(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp)
49: LLViewerObject(id, LL_VO_CLOUDS, regionp) 51: LLAlphaObject(id, LL_VO_CLOUDS, regionp)
50{ 52{
51 mCloudGroupp = NULL; 53 mCloudGroupp = NULL;
52 mbCanSelect = FALSE; 54 mbCanSelect = FALSE;
@@ -99,77 +101,132 @@ LLDrawable* LLVOClouds::createDrawable(LLPipeline *pipeline)
99 mDrawable->setLit(FALSE); 101 mDrawable->setLit(FALSE);
100 mDrawable->setRenderType(LLPipeline::RENDER_TYPE_CLOUDS); 102 mDrawable->setRenderType(LLPipeline::RENDER_TYPE_CLOUDS);
101 103
102 LLDrawPool *pool = gPipeline.getPool(LLDrawPool::POOL_CLOUDS);
103
104 mDrawable->setNumFaces(1, pool, getTEImage(0));
105
106 return mDrawable; 104 return mDrawable;
107} 105}
108 106
109BOOL LLVOClouds::updateGeometry(LLDrawable *drawable) 107BOOL LLVOClouds::updateGeometry(LLDrawable *drawable)
110{ 108{
109 LLFastTimer ftm(LLFastTimer::FTM_UPDATE_CLOUDS);
111 if (!(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS))) 110 if (!(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS)))
112 return TRUE; 111 return TRUE;
113 112
114 LLVector3 at;
115 LLVector3 up;
116 LLVector3 right;
117 LLVector3 normal(0.f,0.f,-1.f);
118 LLVector3 position_agent;
119 //LLVector3 v[4];
120 LLFace *facep; 113 LLFace *facep;
121 const LLVector3 region_pos_agent = mRegionp->getOriginAgent(); 114
122 const LLVector3 camera_agent = gAgent.getCameraPositionAgent();
123 LLVector3 center_offset = getPositionRegion();
124 LLVector2 uvs[4];
125
126 uvs[0].setVec(0.f, 1.f);
127 uvs[1].setVec(0.f, 0.f);
128 uvs[2].setVec(1.f, 1.f);
129 uvs[3].setVec(1.f, 0.f);
130
131 LLVector3 vtx[4];
132
133 S32 num_faces = mCloudGroupp->getNumPuffs(); 115 S32 num_faces = mCloudGroupp->getNumPuffs();
134 116
135 drawable->setNumFacesFast(num_faces, gPipeline.getPool(LLDrawPool::POOL_CLOUDS), getTEImage(0)); 117 if (num_faces > drawable->getNumFaces())
118 {
119 drawable->setNumFacesFast(num_faces, NULL, getTEImage(0));
120 }
121
122 mDepth = (getPositionAgent()-gCamera->getOrigin())*gCamera->getAtAxis();
136 123
137 S32 face_indx = 0; 124 S32 face_indx = 0;
138 for ( ; face_indx < num_faces; face_indx++) 125 for ( ; face_indx < num_faces; face_indx++)
139 { 126 {
140 facep = drawable->getFace(face_indx); 127 facep = drawable->getFace(face_indx);
141 128 if (isParticle())
142 LLStrider<LLVector3> verticesp, normalsp;
143 LLStrider<LLVector2> texCoordsp;
144 U32 *indicesp;
145 S32 index_offset;
146
147 facep->setPrimType(LLTriangles);
148 facep->setSize(4, 6);
149 index_offset = facep->getGeometry(verticesp,normalsp,texCoordsp, indicesp);
150 if (-1 == index_offset)
151 { 129 {
152 return TRUE; 130 facep->setSize(1,1);
153 } 131 }
154 132 else
133 {
134 facep->setSize(4, 6);
135 }
136 facep->setTEOffset(face_indx);
137 facep->setTexture(getTEImage(0));
155 const LLCloudPuff &puff = mCloudGroupp->getPuff(face_indx); 138 const LLCloudPuff &puff = mCloudGroupp->getPuff(face_indx);
156 const LLVector3 puff_pos_agent = gAgent.getPosAgentFromGlobal(puff.getPositionGlobal()); 139 const LLVector3 puff_pos_agent = gAgent.getPosAgentFromGlobal(puff.getPositionGlobal());
157 facep->mCenterAgent = puff_pos_agent; 140 facep->mCenterLocal = puff_pos_agent;
141 }
142 for ( ; face_indx < drawable->getNumFaces(); face_indx++)
143 {
144 facep = drawable->getFace(face_indx);
145 facep->setTEOffset(face_indx);
146 facep->setSize(0,0);
147 }
148
149 drawable->movePartition();
150
151 return TRUE;
152}
153
154BOOL LLVOClouds::isParticle()
155{
156 return FALSE; // gGLManager.mHasPointParameters;
157}
158
159F32 LLVOClouds::getPartSize(S32 idx)
160{
161 return (CLOUD_PUFF_HEIGHT+CLOUD_PUFF_WIDTH)*0.5f;
162}
163
164void LLVOClouds::getGeometry(S32 te,
165 LLStrider<LLVector3>& verticesp,
166 LLStrider<LLVector3>& normalsp,
167 LLStrider<LLVector2>& texcoordsp,
168 LLStrider<LLColor4U>& colorsp,
169 LLStrider<U32>& indicesp)
170{
158 171
159 LLVector3 from_camera_vec = gCamera->getAtAxis();//puff_pos_agent - camera_agent; 172 if (te >= mCloudGroupp->getNumPuffs())
160 at = from_camera_vec; 173 {
174 return;
175 }
176
177 LLDrawable* drawable = mDrawable;
178 LLFace *facep = drawable->getFace(te);
179
180 if (!facep->hasGeometry())
181 {
182 return;
183 }
184
185 LLVector3 normal(0.f,0.f,-1.f);
186
187 const LLCloudPuff &puff = mCloudGroupp->getPuff(te);
188 S32 index_offset = facep->getGeomIndex();
189 LLColor4U color(255, 255, 255, (U8) (puff.getAlpha()*255));
190 facep->setFaceColor(LLColor4(color));
191
192
193 if (isParticle())
194 {
195 *verticesp++ = facep->mCenterLocal;
196 *texcoordsp++ = LLVector2(0.5f, 0.5f);
197 *colorsp++ = color;
198 *normalsp++ = normal;
199 *indicesp++ = facep->getGeomIndex();
200 }
201 else
202 {
203 LLVector3 up;
204 LLVector3 right;
205 LLVector3 at;
206
207 const LLVector3& puff_pos_agent = facep->mCenterLocal;
208 LLVector2 uvs[4];
209
210 uvs[0].setVec(0.f, 1.f);
211 uvs[1].setVec(0.f, 0.f);
212 uvs[2].setVec(1.f, 1.f);
213 uvs[3].setVec(1.f, 0.f);
214
215 LLVector3 vtx[4];
216
217 at = gCamera->getAtAxis();
161 right = at % LLVector3(0.f, 0.f, 1.f); 218 right = at % LLVector3(0.f, 0.f, 1.f);
162 right.normVec(); 219 right.normVec();
163 up = right % at; 220 up = right % at;
164 up.normVec(); 221 up.normVec();
165 right *= 0.5f*CLOUD_PUFF_WIDTH; 222 right *= 0.5f*CLOUD_PUFF_WIDTH;
166 up *= 0.5f*CLOUD_PUFF_HEIGHT;; 223 up *= 0.5f*CLOUD_PUFF_HEIGHT;;
167
168 facep->mCenterAgent = puff_pos_agent;
169
170 LLColor4 color(1.f, 1.f, 1.f, puff.getAlpha());
171 facep->setFaceColor(color);
172 224
225 *colorsp++ = color;
226 *colorsp++ = color;
227 *colorsp++ = color;
228 *colorsp++ = color;
229
173 vtx[0] = puff_pos_agent - right + up; 230 vtx[0] = puff_pos_agent - right + up;
174 vtx[1] = puff_pos_agent - right - up; 231 vtx[1] = puff_pos_agent - right - up;
175 vtx[2] = puff_pos_agent + right + up; 232 vtx[2] = puff_pos_agent + right + up;
@@ -180,10 +237,10 @@ BOOL LLVOClouds::updateGeometry(LLDrawable *drawable)
180 *verticesp++ = vtx[2]; 237 *verticesp++ = vtx[2];
181 *verticesp++ = vtx[3]; 238 *verticesp++ = vtx[3];
182 239
183 *texCoordsp++ = uvs[0]; 240 *texcoordsp++ = uvs[0];
184 *texCoordsp++ = uvs[1]; 241 *texcoordsp++ = uvs[1];
185 *texCoordsp++ = uvs[2]; 242 *texcoordsp++ = uvs[2];
186 *texCoordsp++ = uvs[3]; 243 *texcoordsp++ = uvs[3];
187 244
188 *normalsp++ = normal; 245 *normalsp++ = normal;
189 *normalsp++ = normal; 246 *normalsp++ = normal;
@@ -198,10 +255,28 @@ BOOL LLVOClouds::updateGeometry(LLDrawable *drawable)
198 *indicesp++ = index_offset + 3; 255 *indicesp++ = index_offset + 3;
199 *indicesp++ = index_offset + 2; 256 *indicesp++ = index_offset + 2;
200 } 257 }
201 for ( ; face_indx < drawable->getNumFaces(); face_indx++) 258}
259
260U32 LLVOClouds::getPartitionType() const
261{
262 return LLPipeline::PARTITION_CLOUD;
263}
264
265// virtual
266void LLVOClouds::updateDrawable(BOOL force_damped)
267{
268 // Force an immediate rebuild on any update
269 if (mDrawable.notNull())
202 { 270 {
203 drawable->getFace(face_indx)->setSize(0,0); 271 mDrawable->updateXform(TRUE);
272 gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_ALL, TRUE);
204 } 273 }
274 clearChanged(SHIFTED);
275}
205 276
206 return TRUE; 277LLCloudPartition::LLCloudPartition()
278{
279 mDrawableType = LLPipeline::RENDER_TYPE_CLOUDS;
280 mPartitionType = LLPipeline::PARTITION_CLOUD;
207} 281}
282