aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llvopartgroup.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llvopartgroup.cpp
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/newview/llvopartgroup.cpp')
-rw-r--r--linden/indra/newview/llvopartgroup.cpp207
1 files changed, 78 insertions, 129 deletions
diff --git a/linden/indra/newview/llvopartgroup.cpp b/linden/indra/newview/llvopartgroup.cpp
index 31ec38e..79255ca 100644
--- a/linden/indra/newview/llvopartgroup.cpp
+++ b/linden/indra/newview/llvopartgroup.cpp
@@ -47,6 +47,7 @@
47#include "llviewerpartsim.h" 47#include "llviewerpartsim.h"
48#include "llviewerregion.h" 48#include "llviewerregion.h"
49#include "pipeline.h" 49#include "pipeline.h"
50#include "llspatialpartition.h"
50 51
51const F32 MAX_PART_LIFETIME = 120.f; 52const F32 MAX_PART_LIFETIME = 120.f;
52 53
@@ -59,7 +60,6 @@ LLVOPartGroup::LLVOPartGroup(const LLUUID &id, const LLPCode pcode, LLViewerRegi
59 setNumTEs(1); 60 setNumTEs(1);
60 setTETexture(0, LLUUID::null); 61 setTETexture(0, LLUUID::null);
61 mbCanSelect = FALSE; // users can't select particle systems 62 mbCanSelect = FALSE; // users can't select particle systems
62 mDebugColor = LLColor4(ll_frand(), ll_frand(), ll_frand(), 1.f);
63} 63}
64 64
65 65
@@ -70,7 +70,7 @@ LLVOPartGroup::~LLVOPartGroup()
70 70
71BOOL LLVOPartGroup::isActive() const 71BOOL LLVOPartGroup::isActive() const
72{ 72{
73 return TRUE; 73 return FALSE;
74} 74}
75 75
76F32 LLVOPartGroup::getBinRadius() 76F32 LLVOPartGroup::getBinRadius()
@@ -80,11 +80,9 @@ F32 LLVOPartGroup::getBinRadius()
80 80
81void LLVOPartGroup::updateSpatialExtents(LLVector3& newMin, LLVector3& newMax) 81void LLVOPartGroup::updateSpatialExtents(LLVector3& newMin, LLVector3& newMax)
82{ 82{
83 LLVector3 pos_agent = getPositionAgent(); 83 const LLVector3& pos_agent = getPositionAgent();
84 mExtents[0] = pos_agent - mScale; 84 newMin = pos_agent - mScale;
85 mExtents[1] = pos_agent + mScale; 85 newMax = pos_agent + mScale;
86 newMin = mExtents[0];
87 newMax = mExtents[1];
88 mDrawable->setPositionGroup(pos_agent); 86 mDrawable->setPositionGroup(pos_agent);
89} 87}
90 88
@@ -139,6 +137,8 @@ BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable)
139{ 137{
140 LLFastTimer ftm(LLFastTimer::FTM_UPDATE_PARTICLES); 138 LLFastTimer ftm(LLFastTimer::FTM_UPDATE_PARTICLES);
141 139
140 dirtySpatialGroup();
141
142 LLVector3 at; 142 LLVector3 at;
143 LLVector3 position_agent; 143 LLVector3 position_agent;
144 LLVector3 camera_agent = gCamera->getOrigin(); 144 LLVector3 camera_agent = gCamera->getOrigin();
@@ -156,7 +156,7 @@ BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable)
156 { 156 {
157 if (group && drawable->getNumFaces()) 157 if (group && drawable->getNumFaces())
158 { 158 {
159 group->dirtyGeom(); 159 group->setState(LLSpatialGroup::GEOM_DIRTY);
160 } 160 }
161 drawable->setNumFaces(0, NULL, getTEImage(0)); 161 drawable->setNumFaces(0, NULL, getTEImage(0));
162 LLPipeline::sCompiles++; 162 LLPipeline::sCompiles++;
@@ -174,7 +174,6 @@ BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable)
174 } 174 }
175 175
176 F32 tot_area = 0; 176 F32 tot_area = 0;
177 BOOL is_particle = isParticle();
178 177
179 F32 max_area = LLViewerPartSim::getMaxPartCount() * MAX_PARTICLE_AREA_SCALE; 178 F32 max_area = LLViewerPartSim::getMaxPartCount() * MAX_PARTICLE_AREA_SCALE;
180 F32 pixel_meter_ratio = gCamera->getPixelMeterRatio(); 179 F32 pixel_meter_ratio = gCamera->getPixelMeterRatio();
@@ -182,7 +181,6 @@ BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable)
182 181
183 S32 count=0; 182 S32 count=0;
184 S32 i; 183 S32 i;
185 F32 max_width = 0.f;
186 mDepth = 0.f; 184 mDepth = 0.f;
187 185
188 for (i = 0; i < num_parts; i++) 186 for (i = 0; i < num_parts; i++)
@@ -199,9 +197,9 @@ BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable)
199 else 197 else
200 inv_camera_dist_squared = 1.f; 198 inv_camera_dist_squared = 1.f;
201 F32 area = part.mScale.mV[0] * part.mScale.mV[1] * inv_camera_dist_squared; 199 F32 area = part.mScale.mV[0] * part.mScale.mV[1] * inv_camera_dist_squared;
202 tot_area += area; 200 tot_area = llmax(tot_area, area);
203 201
204 if (!is_particle && tot_area > max_area) 202 if (tot_area > max_area)
205 { 203 {
206 break; 204 break;
207 } 205 }
@@ -219,21 +217,14 @@ BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable)
219 const F32 NEAR_PART_DIST_SQ = 5.f*5.f; // Only discard particles > 5 m from the camera 217 const F32 NEAR_PART_DIST_SQ = 5.f*5.f; // Only discard particles > 5 m from the camera
220 const F32 MIN_PART_AREA = .005f*.005f; // only less than 5 mm x 5 mm at 1 m from camera 218 const F32 MIN_PART_AREA = .005f*.005f; // only less than 5 mm x 5 mm at 1 m from camera
221 219
222 if (!is_particle) 220 if (camera_dist_squared > NEAR_PART_DIST_SQ && area < MIN_PART_AREA)
223 { 221 {
224 if (camera_dist_squared > NEAR_PART_DIST_SQ && area < MIN_PART_AREA) 222 facep->setSize(0, 0);
225 { 223 continue;
226 facep->setSize(0, 0);
227 continue;
228 }
229
230 facep->setSize(4, 6);
231 }
232 else
233 {
234 facep->setSize(1,1);
235 } 224 }
236 225
226 facep->setSize(4, 6);
227
237 facep->setViewerObject(this); 228 facep->setViewerObject(this);
238 229
239 if (part.mFlags & LLPartData::LL_PART_EMISSIVE_MASK) 230 if (part.mFlags & LLPartData::LL_PART_EMISSIVE_MASK)
@@ -248,18 +239,6 @@ BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable)
248 facep->mCenterLocal = part.mPosAgent; 239 facep->mCenterLocal = part.mPosAgent;
249 facep->setFaceColor(part.mColor); 240 facep->setFaceColor(part.mColor);
250 facep->setTexture(part.mImagep); 241 facep->setTexture(part.mImagep);
251
252 if (i == 0)
253 {
254 mExtents[0] = mExtents[1] = part.mPosAgent;
255 }
256 else
257 {
258 update_min_max(mExtents[0], mExtents[1], part.mPosAgent);
259 }
260
261 max_width = llmax(max_width, part.mScale.mV[0]);
262 max_width = llmax(max_width, part.mScale.mV[1]);
263 242
264 mPixelArea = tot_area * pixel_meter_ratio; 243 mPixelArea = tot_area * pixel_meter_ratio;
265 const F32 area_scale = 10.f; // scale area to increase priority a bit 244 const F32 area_scale = 10.f; // scale area to increase priority a bit
@@ -274,21 +253,9 @@ BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable)
274 continue; 253 continue;
275 } 254 }
276 facep->setTEOffset(i); 255 facep->setTEOffset(i);
277 facep->setSize(0,0); 256 facep->setSize(0, 0);
278 } 257 }
279
280 LLVector3 y = gCamera->mYAxis;
281 LLVector3 z = gCamera->mZAxis;
282 258
283 LLVector3 pad;
284 for (i = 0; i < 3; i++)
285 {
286 pad.mV[i] = llmax(max_width, max_width * (fabsf(y.mV[i]) + fabsf(z.mV[i])));
287 }
288
289 mExtents[0] -= pad;
290 mExtents[1] += pad;
291
292 mDrawable->movePartition(); 259 mDrawable->movePartition();
293 LLPipeline::sCompiles++; 260 LLPipeline::sCompiles++;
294 return TRUE; 261 return TRUE;
@@ -299,7 +266,7 @@ void LLVOPartGroup::getGeometry(S32 idx,
299 LLStrider<LLVector3>& normalsp, 266 LLStrider<LLVector3>& normalsp,
300 LLStrider<LLVector2>& texcoordsp, 267 LLStrider<LLVector2>& texcoordsp,
301 LLStrider<LLColor4U>& colorsp, 268 LLStrider<LLColor4U>& colorsp,
302 LLStrider<U32>& indicesp) 269 LLStrider<U16>& indicesp)
303{ 270{
304 if (idx >= (S32) mViewerPartGroupp->mParticles.size()) 271 if (idx >= (S32) mViewerPartGroupp->mParticles.size())
305 { 272 {
@@ -310,92 +277,72 @@ void LLVOPartGroup::getGeometry(S32 idx,
310 277
311 U32 vert_offset = mDrawable->getFace(idx)->getGeomIndex(); 278 U32 vert_offset = mDrawable->getFace(idx)->getGeomIndex();
312 279
313 if (isParticle()) 280
314 { 281 LLVector3 part_pos_agent(part.mPosAgent);
315 LLVector3 part_pos_agent(part.mPosAgent); 282 LLVector3 camera_agent = gAgent.getCameraPositionAgent();
283 LLVector3 at = part_pos_agent - camera_agent;
284 LLVector3 up, right;
316 285
317 const LLVector3& normal = -gCamera->getXAxis(); 286 right = at % LLVector3(0.f, 0.f, 1.f);
287 right.normVec();
288 up = right % at;
289 up.normVec();
318 290
319 *verticesp++ = part_pos_agent; 291 if (part.mFlags & LLPartData::LL_PART_FOLLOW_VELOCITY_MASK)
320 *normalsp++ = normal;
321 *colorsp++ = part.mColor;
322 *texcoordsp++ = LLVector2(0.5f, 0.5f);
323 *indicesp++ = vert_offset;
324 }
325 else
326 { 292 {
327 LLVector3 part_pos_agent(part.mPosAgent); 293 LLVector3 normvel = part.mVelocity;
328 LLVector3 camera_agent = gAgent.getCameraPositionAgent(); 294 normvel.normVec();
329 LLVector3 at = part_pos_agent - camera_agent; 295 LLVector2 up_fracs;
330 LLVector3 up, right; 296 up_fracs.mV[0] = normvel*right;
331 297 up_fracs.mV[1] = normvel*up;
332 right = at % LLVector3(0.f, 0.f, 1.f); 298 up_fracs.normVec();
333 right.normVec(); 299 LLVector3 new_up;
334 up = right % at; 300 LLVector3 new_right;
301 new_up = up_fracs.mV[0] * right + up_fracs.mV[1]*up;
302 new_right = up_fracs.mV[1] * right - up_fracs.mV[0]*up;
303 up = new_up;
304 right = new_right;
335 up.normVec(); 305 up.normVec();
306 right.normVec();
307 }
336 308
337 if (part.mFlags & LLPartData::LL_PART_FOLLOW_VELOCITY_MASK) 309 right *= 0.5f*part.mScale.mV[0];
338 { 310 up *= 0.5f*part.mScale.mV[1];
339 LLVector3 normvel = part.mVelocity;
340 normvel.normVec();
341 LLVector2 up_fracs;
342 up_fracs.mV[0] = normvel*right;
343 up_fracs.mV[1] = normvel*up;
344 up_fracs.normVec();
345
346 LLVector3 new_up;
347 LLVector3 new_right;
348 new_up = up_fracs.mV[0] * right + up_fracs.mV[1]*up;
349 new_right = up_fracs.mV[1] * right - up_fracs.mV[0]*up;
350 up = new_up;
351 right = new_right;
352 up.normVec();
353 right.normVec();
354 }
355
356 right *= 0.5f*part.mScale.mV[0];
357 up *= 0.5f*part.mScale.mV[1];
358 311
359 const LLVector3& normal = -gCamera->getXAxis(); 312 const LLVector3& normal = -gCamera->getXAxis();
360 313
361 *verticesp++ = part_pos_agent + up - right; 314 *verticesp++ = part_pos_agent + up - right;
362 *verticesp++ = part_pos_agent - up - right; 315 *verticesp++ = part_pos_agent - up - right;
363 *verticesp++ = part_pos_agent + up + right; 316 *verticesp++ = part_pos_agent + up + right;
364 *verticesp++ = part_pos_agent - up + right; 317 *verticesp++ = part_pos_agent - up + right;
365 318
366 *colorsp++ = part.mColor; 319 *colorsp++ = part.mColor;
367 *colorsp++ = part.mColor; 320 *colorsp++ = part.mColor;
368 *colorsp++ = part.mColor; 321 *colorsp++ = part.mColor;
369 *colorsp++ = part.mColor; 322 *colorsp++ = part.mColor;
370 323
371 *texcoordsp++ = LLVector2(0.f, 1.f); 324 *texcoordsp++ = LLVector2(0.f, 1.f);
372 *texcoordsp++ = LLVector2(0.f, 0.f); 325 *texcoordsp++ = LLVector2(0.f, 0.f);
373 *texcoordsp++ = LLVector2(1.f, 1.f); 326 *texcoordsp++ = LLVector2(1.f, 1.f);
374 *texcoordsp++ = LLVector2(1.f, 0.f); 327 *texcoordsp++ = LLVector2(1.f, 0.f);
375 328
376 *normalsp++ = normal; 329 *normalsp++ = normal;
377 *normalsp++ = normal; 330 *normalsp++ = normal;
378 *normalsp++ = normal; 331 *normalsp++ = normal;
379 *normalsp++ = normal; 332 *normalsp++ = normal;
380 333
381 *indicesp++ = vert_offset + 0; 334 *indicesp++ = vert_offset + 0;
382 *indicesp++ = vert_offset + 1; 335 *indicesp++ = vert_offset + 1;
383 *indicesp++ = vert_offset + 2; 336 *indicesp++ = vert_offset + 2;
384 337
385 *indicesp++ = vert_offset + 1; 338 *indicesp++ = vert_offset + 1;
386 *indicesp++ = vert_offset + 3; 339 *indicesp++ = vert_offset + 3;
387 *indicesp++ = vert_offset + 2; 340 *indicesp++ = vert_offset + 2;
388 }
389}
390
391BOOL LLVOPartGroup::isParticle()
392{
393 return FALSE; //gGLManager.mHasPointParameters && mViewerPartGroupp->mUniformParticles;
394} 341}
395 342
396U32 LLVOPartGroup::getPartitionType() const 343U32 LLVOPartGroup::getPartitionType() const
397{ 344{
398 return LLPipeline::PARTITION_PARTICLE; 345 return LLViewerRegion::PARTITION_PARTICLE;
399} 346}
400 347
401LLParticlePartition::LLParticlePartition() 348LLParticlePartition::LLParticlePartition()
@@ -403,7 +350,7 @@ LLParticlePartition::LLParticlePartition()
403{ 350{
404 mRenderPass = LLRenderPass::PASS_ALPHA; 351 mRenderPass = LLRenderPass::PASS_ALPHA;
405 mDrawableType = LLPipeline::RENDER_TYPE_PARTICLES; 352 mDrawableType = LLPipeline::RENDER_TYPE_PARTICLES;
406 mPartitionType = LLPipeline::PARTITION_PARTICLE; 353 mPartitionType = LLViewerRegion::PARTITION_PARTICLE;
407 mBufferUsage = GL_DYNAMIC_DRAW_ARB; 354 mBufferUsage = GL_DYNAMIC_DRAW_ARB;
408 mSlopRatio = 0.f; 355 mSlopRatio = 0.f;
409 mLODPeriod = 1; 356 mLODPeriod = 1;
@@ -459,6 +406,7 @@ void LLParticlePartition::addGeometryCount(LLSpatialGroup* group, U32& vertex_co
459void LLParticlePartition::getGeometry(LLSpatialGroup* group) 406void LLParticlePartition::getGeometry(LLSpatialGroup* group)
460{ 407{
461 LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION); 408 LLMemType mt(LLMemType::MTYPE_SPACE_PARTITION);
409 LLFastTimer ftm(LLFastTimer::FTM_REBUILD_PARTICLE_VB);
462 410
463 std::sort(mFaceList.begin(), mFaceList.end(), LLFace::CompareDistanceGreater()); 411 std::sort(mFaceList.begin(), mFaceList.end(), LLFace::CompareDistanceGreater());
464 412
@@ -469,7 +417,7 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group)
469 417
470 LLVertexBuffer* buffer = group->mVertexBuffer; 418 LLVertexBuffer* buffer = group->mVertexBuffer;
471 419
472 LLStrider<U32> indicesp; 420 LLStrider<U16> indicesp;
473 LLStrider<LLVector3> verticesp; 421 LLStrider<LLVector3> verticesp;
474 LLStrider<LLVector3> normalsp; 422 LLStrider<LLVector3> normalsp;
475 LLStrider<LLVector2> texcoordsp; 423 LLStrider<LLVector2> texcoordsp;
@@ -503,8 +451,8 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group)
503 451
504 if (idx >= 0 && draw_vec[idx]->mEnd == facep->getGeomIndex()-1 && 452 if (idx >= 0 && draw_vec[idx]->mEnd == facep->getGeomIndex()-1 &&
505 draw_vec[idx]->mTexture == facep->getTexture() && 453 draw_vec[idx]->mTexture == facep->getTexture() &&
506 draw_vec[idx]->mEnd - draw_vec[idx]->mStart + facep->getGeomCount() <= (U32) gGLManager.mGLMaxVertexRange && 454 (U16) (draw_vec[idx]->mEnd - draw_vec[idx]->mStart + facep->getGeomCount()) <= (U32) gGLManager.mGLMaxVertexRange &&
507 draw_vec[idx]->mCount + facep->getIndicesCount() <= (U32) gGLManager.mGLMaxIndexRange && 455 //draw_vec[idx]->mCount + facep->getIndicesCount() <= (U32) gGLManager.mGLMaxIndexRange &&
508 draw_vec[idx]->mEnd - draw_vec[idx]->mStart + facep->getGeomCount() < 4096 && 456 draw_vec[idx]->mEnd - draw_vec[idx]->mStart + facep->getGeomCount() < 4096 &&
509 draw_vec[idx]->mFullbright == fullbright) 457 draw_vec[idx]->mFullbright == fullbright)
510 { 458 {
@@ -524,6 +472,7 @@ void LLParticlePartition::getGeometry(LLSpatialGroup* group)
524 } 472 }
525 } 473 }
526 474
475 buffer->setBuffer(0);
527 mFaceList.clear(); 476 mFaceList.clear();
528} 477}
529 478