aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llvopartgroup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llvopartgroup.cpp')
-rw-r--r--linden/indra/newview/llvopartgroup.cpp65
1 files changed, 49 insertions, 16 deletions
diff --git a/linden/indra/newview/llvopartgroup.cpp b/linden/indra/newview/llvopartgroup.cpp
index 11d7341..a91b59f 100644
--- a/linden/indra/newview/llvopartgroup.cpp
+++ b/linden/indra/newview/llvopartgroup.cpp
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2001&license=viewergpl$ 5 * $LicenseInfo:firstyear=2001&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2001-2008, Linden Research, Inc. 7 * Copyright (c) 2001-2009, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -95,7 +95,7 @@ void LLVOPartGroup::setPixelAreaAndAngle(LLAgent &agent)
95{ 95{
96 // mPixelArea is calculated during render 96 // mPixelArea is calculated during render
97 F32 mid_scale = getMidScale(); 97 F32 mid_scale = getMidScale();
98 F32 range = (getRenderPosition()-LLViewerCamera::getInstance()->getOrigin()).magVec(); 98 F32 range = (getRenderPosition()-LLViewerCamera::getInstance()->getOrigin()).length();
99 99
100 if (range < 0.001f || isHUDAttachment()) // range == zero 100 if (range < 0.001f || isHUDAttachment()) // range == zero
101 { 101 {
@@ -133,15 +133,16 @@ F32 LLVOPartGroup::getPartSize(S32 idx)
133 return 0.f; 133 return 0.f;
134} 134}
135 135
136LLVector3 LLVOPartGroup::getCameraPosition() const
137{
138 return gAgent.getCameraPositionAgent();
139}
140
136BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable) 141BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable)
137{ 142{
138 LLFastTimer ftm(LLFastTimer::FTM_UPDATE_PARTICLES); 143 LLFastTimer ftm(LLFastTimer::FTM_UPDATE_PARTICLES);
139 144
140 dirtySpatialGroup(); 145 dirtySpatialGroup();
141
142 LLVector3 at;
143 LLVector3 position_agent;
144 LLVector3 camera_agent = LLViewerCamera::getInstance()->getOrigin();
145 146
146 S32 num_parts = mViewerPartGroupp->getCount(); 147 S32 num_parts = mViewerPartGroupp->getCount();
147 LLFace *facep; 148 LLFace *facep;
@@ -179,6 +180,8 @@ BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable)
179 F32 pixel_meter_ratio = LLViewerCamera::getInstance()->getPixelMeterRatio(); 180 F32 pixel_meter_ratio = LLViewerCamera::getInstance()->getPixelMeterRatio();
180 pixel_meter_ratio *= pixel_meter_ratio; 181 pixel_meter_ratio *= pixel_meter_ratio;
181 182
183 LLViewerPartSim::checkParticleCount(mViewerPartGroupp->mParticles.size()) ;
184
182 S32 count=0; 185 S32 count=0;
183 mDepth = 0.f; 186 mDepth = 0.f;
184 S32 i = 0 ; 187 S32 i = 0 ;
@@ -187,9 +190,9 @@ BOOL LLVOPartGroup::updateGeometry(LLDrawable *drawable)
187 const LLViewerPart *part = mViewerPartGroupp->mParticles[i]; 190 const LLViewerPart *part = mViewerPartGroupp->mParticles[i];
188 191
189 LLVector3 part_pos_agent(part->mPosAgent); 192 LLVector3 part_pos_agent(part->mPosAgent);
190 at = part_pos_agent - camera_agent; 193 LLVector3 at(part_pos_agent - LLViewerCamera::getInstance()->getOrigin());
191 194
192 F32 camera_dist_squared = at.magVecSquared(); 195 F32 camera_dist_squared = at.lengthSquared();
193 F32 inv_camera_dist_squared; 196 F32 inv_camera_dist_squared;
194 if (camera_dist_squared > 1.f) 197 if (camera_dist_squared > 1.f)
195 inv_camera_dist_squared = 1.f / camera_dist_squared; 198 inv_camera_dist_squared = 1.f / camera_dist_squared;
@@ -278,36 +281,38 @@ void LLVOPartGroup::getGeometry(S32 idx,
278 281
279 282
280 LLVector3 part_pos_agent(part.mPosAgent); 283 LLVector3 part_pos_agent(part.mPosAgent);
281 LLVector3 camera_agent = gAgent.getCameraPositionAgent(); 284 LLVector3 camera_agent = getCameraPosition();
282 LLVector3 at = part_pos_agent - camera_agent; 285 LLVector3 at = part_pos_agent - camera_agent;
283 LLVector3 up, right; 286 LLVector3 up;
287 LLVector3 right;
284 288
285 right = at % LLVector3(0.f, 0.f, 1.f); 289 right = at % LLVector3(0.f, 0.f, 1.f);
286 right.normVec(); 290 right.normalize();
287 up = right % at; 291 up = right % at;
288 up.normVec(); 292 up.normalize();
289 293
290 if (part.mFlags & LLPartData::LL_PART_FOLLOW_VELOCITY_MASK) 294 if (part.mFlags & LLPartData::LL_PART_FOLLOW_VELOCITY_MASK)
291 { 295 {
292 LLVector3 normvel = part.mVelocity; 296 LLVector3 normvel = part.mVelocity;
293 normvel.normVec(); 297 normvel.normalize();
294 LLVector2 up_fracs; 298 LLVector2 up_fracs;
295 up_fracs.mV[0] = normvel*right; 299 up_fracs.mV[0] = normvel*right;
296 up_fracs.mV[1] = normvel*up; 300 up_fracs.mV[1] = normvel*up;
297 up_fracs.normVec(); 301 up_fracs.normalize();
298 LLVector3 new_up; 302 LLVector3 new_up;
299 LLVector3 new_right; 303 LLVector3 new_right;
300 new_up = up_fracs.mV[0] * right + up_fracs.mV[1]*up; 304 new_up = up_fracs.mV[0] * right + up_fracs.mV[1]*up;
301 new_right = up_fracs.mV[1] * right - up_fracs.mV[0]*up; 305 new_right = up_fracs.mV[1] * right - up_fracs.mV[0]*up;
302 up = new_up; 306 up = new_up;
303 right = new_right; 307 right = new_right;
304 up.normVec(); 308 up.normalize();
305 right.normVec(); 309 right.normalize();
306 } 310 }
307 311
308 right *= 0.5f*part.mScale.mV[0]; 312 right *= 0.5f*part.mScale.mV[0];
309 up *= 0.5f*part.mScale.mV[1]; 313 up *= 0.5f*part.mScale.mV[1];
310 314
315
311 const LLVector3& normal = -LLViewerCamera::getInstance()->getXAxis(); 316 const LLVector3& normal = -LLViewerCamera::getInstance()->getXAxis();
312 317
313 *verticesp++ = part_pos_agent + up - right; 318 *verticesp++ = part_pos_agent + up - right;
@@ -355,6 +360,13 @@ LLParticlePartition::LLParticlePartition()
355 mLODPeriod = 1; 360 mLODPeriod = 1;
356} 361}
357 362
363LLHUDParticlePartition::LLHUDParticlePartition() :
364 LLParticlePartition()
365{
366 mDrawableType = LLPipeline::RENDER_TYPE_HUD;
367 mPartitionType = LLViewerRegion::PARTITION_HUD_PARTICLE;
368}
369
358void LLParticlePartition::addGeometryCount(LLSpatialGroup* group, U32& vertex_count, U32& index_count) 370void LLParticlePartition::addGeometryCount(LLSpatialGroup* group, U32& vertex_count, U32& index_count)
359{ 371{
360 group->mBufferUsage = mBufferUsage; 372 group->mBufferUsage = mBufferUsage;
@@ -480,3 +492,24 @@ F32 LLParticlePartition::calcPixelArea(LLSpatialGroup* group, LLCamera& camera)
480 return 1024.f; 492 return 1024.f;
481} 493}
482 494
495U32 LLVOHUDPartGroup::getPartitionType() const
496{
497 // Commenting out and returning PARTITION_NONE because DEV-16909
498 // (SVC-2396: Particles not handled properly as hud) didn't work completely
499 // so this disables HUD particles until they can be fixed properly. -MG
500 //return LLViewerRegion::PARTITION_HUD_PARTICLE;
501 return LLViewerRegion::PARTITION_NONE;
502}
503
504LLDrawable* LLVOHUDPartGroup::createDrawable(LLPipeline *pipeline)
505{
506 pipeline->allocDrawable(this);
507 mDrawable->setLit(FALSE);
508 mDrawable->setRenderType(LLPipeline::RENDER_TYPE_HUD);
509 return mDrawable;
510}
511
512LLVector3 LLVOHUDPartGroup::getCameraPosition() const
513{
514 return LLVector3(-1,0,0);
515}