aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llviewerpartsim.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llviewerpartsim.cpp')
-rw-r--r--linden/indra/newview/llviewerpartsim.cpp52
1 files changed, 47 insertions, 5 deletions
diff --git a/linden/indra/newview/llviewerpartsim.cpp b/linden/indra/newview/llviewerpartsim.cpp
index d27e0df..c303fc5 100644
--- a/linden/indra/newview/llviewerpartsim.cpp
+++ b/linden/indra/newview/llviewerpartsim.cpp
@@ -4,7 +4,7 @@
4 * 4 *
5 * $LicenseInfo:firstyear=2003&license=viewergpl$ 5 * $LicenseInfo:firstyear=2003&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2003-2008, Linden Research, Inc. 7 * Copyright (c) 2003-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
@@ -53,6 +53,7 @@ const F32 PART_SIM_BOX_RAD = 0.5f*F_SQRT3*PART_SIM_BOX_SIDE;
53//static 53//static
54S32 LLViewerPartSim::sMaxParticleCount = 0; 54S32 LLViewerPartSim::sMaxParticleCount = 0;
55S32 LLViewerPartSim::sParticleCount = 0; 55S32 LLViewerPartSim::sParticleCount = 0;
56S32 LLViewerPartSim::sParticleCount2 = 0;
56// This controls how greedy individual particle burst sources are allowed to be, and adapts according to how near the particle-count limit we are. 57// This controls how greedy individual particle burst sources are allowed to be, and adapts according to how near the particle-count limit we are.
57F32 LLViewerPartSim::sParticleAdaptiveRate = 0.0625f; 58F32 LLViewerPartSim::sParticleAdaptiveRate = 0.0625f;
58F32 LLViewerPartSim::sParticleBurstRate = 0.5f; 59F32 LLViewerPartSim::sParticleBurstRate = 0.5f;
@@ -84,12 +85,16 @@ LLViewerPart::LLViewerPart() :
84{ 85{
85 LLMemType mt(LLMemType::MTYPE_PARTICLES); 86 LLMemType mt(LLMemType::MTYPE_PARTICLES);
86 mPartSourcep = NULL; 87 mPartSourcep = NULL;
88
89 ++LLViewerPartSim::sParticleCount2 ;
87} 90}
88 91
89LLViewerPart::~LLViewerPart() 92LLViewerPart::~LLViewerPart()
90{ 93{
91 LLMemType mt(LLMemType::MTYPE_PARTICLES); 94 LLMemType mt(LLMemType::MTYPE_PARTICLES);
92 mPartSourcep = NULL; 95 mPartSourcep = NULL;
96
97 --LLViewerPartSim::sParticleCount2 ;
93} 98}
94 99
95void LLViewerPart::init(LLPointer<LLViewerPartSource> sourcep, LLViewerImage *imagep, LLVPCallback cb) 100void LLViewerPart::init(LLPointer<LLViewerPartSource> sourcep, LLViewerImage *imagep, LLVPCallback cb)
@@ -116,7 +121,8 @@ void LLViewerPart::init(LLPointer<LLViewerPartSource> sourcep, LLViewerImage *im
116// 121//
117 122
118 123
119LLViewerPartGroup::LLViewerPartGroup(const LLVector3 &center_agent, const F32 box_side) 124LLViewerPartGroup::LLViewerPartGroup(const LLVector3 &center_agent, const F32 box_side, bool hud)
125 : mHud(hud)
120{ 126{
121 LLMemType mt(LLMemType::MTYPE_PARTICLES); 127 LLMemType mt(LLMemType::MTYPE_PARTICLES);
122 mVOPartGroupp = NULL; 128 mVOPartGroupp = NULL;
@@ -133,7 +139,14 @@ LLViewerPartGroup::LLViewerPartGroup(const LLVector3 &center_agent, const F32 bo
133 mCenterAgent = center_agent; 139 mCenterAgent = center_agent;
134 mBoxRadius = F_SQRT3*box_side*0.5f; 140 mBoxRadius = F_SQRT3*box_side*0.5f;
135 141
142 if (mHud)
143 {
144 mVOPartGroupp = (LLVOPartGroup *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_HUD_PART_GROUP, getRegion());
145 }
146 else
147 {
136 mVOPartGroupp = (LLVOPartGroup *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_PART_GROUP, getRegion()); 148 mVOPartGroupp = (LLVOPartGroup *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_PART_GROUP, getRegion());
149 }
137 mVOPartGroupp->setViewerPartGroup(this); 150 mVOPartGroupp->setViewerPartGroup(this);
138 mVOPartGroupp->setPositionAgent(getCenterAgent()); 151 mVOPartGroupp->setPositionAgent(getCenterAgent());
139 F32 scale = box_side * 0.5f; 152 F32 scale = box_side * 0.5f;
@@ -223,6 +236,12 @@ BOOL LLViewerPartGroup::posInGroup(const LLVector3 &pos, const F32 desired_size)
223BOOL LLViewerPartGroup::addPart(LLViewerPart* part, F32 desired_size) 236BOOL LLViewerPartGroup::addPart(LLViewerPart* part, F32 desired_size)
224{ 237{
225 LLMemType mt(LLMemType::MTYPE_PARTICLES); 238 LLMemType mt(LLMemType::MTYPE_PARTICLES);
239
240 if (part->mFlags & LLPartData::LL_PART_HUD && !mHud)
241 {
242 return FALSE;
243 }
244
226 BOOL uniform_part = part->mScale.mV[0] == part->mScale.mV[1] && 245 BOOL uniform_part = part->mScale.mV[0] == part->mScale.mV[1] &&
227 !(part->mFlags & LLPartData::LL_PART_FOLLOW_VELOCITY_MASK); 246 !(part->mFlags & LLPartData::LL_PART_FOLLOW_VELOCITY_MASK);
228 247
@@ -249,6 +268,8 @@ void LLViewerPartGroup::updateParticles(const F32 lastdt)
249 268
250 LLVector3 gravity(0.f, 0.f, GRAVITY); 269 LLVector3 gravity(0.f, 0.f, GRAVITY);
251 270
271 LLViewerPartSim::checkParticleCount(mParticles.size());
272
252 LLViewerRegion *regionp = getRegion(); 273 LLViewerRegion *regionp = getRegion();
253 S32 end = (S32) mParticles.size(); 274 S32 end = (S32) mParticles.size();
254 for (S32 i = 0 ; i < (S32)mParticles.size();) 275 for (S32 i = 0 ; i < (S32)mParticles.size();)
@@ -402,6 +423,8 @@ void LLViewerPartGroup::updateParticles(const F32 lastdt)
402 gObjectList.killObject(mVOPartGroupp); 423 gObjectList.killObject(mVOPartGroupp);
403 mVOPartGroupp = NULL; 424 mVOPartGroupp = NULL;
404 } 425 }
426
427 LLViewerPartSim::checkParticleCount() ;
405} 428}
406 429
407 430
@@ -437,6 +460,19 @@ void LLViewerPartGroup::removeParticlesByID(const U32 source_id)
437// 460//
438// 461//
439 462
463//static
464void LLViewerPartSim::checkParticleCount(U32 size)
465{
466 if(LLViewerPartSim::sParticleCount2 != LLViewerPartSim::sParticleCount)
467 {
468 llerrs << "sParticleCount: " << LLViewerPartSim::sParticleCount << " ; sParticleCount2: " << LLViewerPartSim::sParticleCount2 << llendl ;
469 }
470
471 if(size > (U32)LLViewerPartSim::sParticleCount2)
472 {
473 llerrs << "curren particle size: " << LLViewerPartSim::sParticleCount2 << " array size: " << size << llendl ;
474 }
475}
440 476
441LLViewerPartSim::LLViewerPartSim() 477LLViewerPartSim::LLViewerPartSim()
442{ 478{
@@ -495,6 +531,12 @@ void LLViewerPartSim::addPart(LLViewerPart* part)
495 { 531 {
496 put(part); 532 put(part);
497 } 533 }
534 else
535 {
536 //delete the particle if can not add it in
537 delete part ;
538 part = NULL ;
539 }
498} 540}
499 541
500 542
@@ -530,7 +572,7 @@ LLViewerPartGroup *LLViewerPartSim::put(LLViewerPart* part)
530 if(!return_group) 572 if(!return_group)
531 { 573 {
532 llassert_always(part->mPosAgent.isFinite()); 574 llassert_always(part->mPosAgent.isFinite());
533 LLViewerPartGroup *groupp = createViewerPartGroup(part->mPosAgent, desired_size); 575 LLViewerPartGroup *groupp = createViewerPartGroup(part->mPosAgent, desired_size, part->mFlags & LLPartData::LL_PART_HUD);
534 groupp->mUniformParticles = (part->mScale.mV[0] == part->mScale.mV[1] && 576 groupp->mUniformParticles = (part->mScale.mV[0] == part->mScale.mV[1] &&
535 !(part->mFlags & LLPartData::LL_PART_FOLLOW_VELOCITY_MASK)); 577 !(part->mFlags & LLPartData::LL_PART_FOLLOW_VELOCITY_MASK));
536 if (!groupp->addPart(part)) 578 if (!groupp->addPart(part))
@@ -555,12 +597,12 @@ LLViewerPartGroup *LLViewerPartSim::put(LLViewerPart* part)
555 return return_group ; 597 return return_group ;
556} 598}
557 599
558LLViewerPartGroup *LLViewerPartSim::createViewerPartGroup(const LLVector3 &pos_agent, const F32 desired_size) 600LLViewerPartGroup *LLViewerPartSim::createViewerPartGroup(const LLVector3 &pos_agent, const F32 desired_size, bool hud)
559{ 601{
560 LLMemType mt(LLMemType::MTYPE_PARTICLES); 602 LLMemType mt(LLMemType::MTYPE_PARTICLES);
561 //find a box that has a center position divisible by PART_SIM_BOX_SIDE that encompasses 603 //find a box that has a center position divisible by PART_SIM_BOX_SIDE that encompasses
562 //pos_agent 604 //pos_agent
563 LLViewerPartGroup *groupp = new LLViewerPartGroup(pos_agent, desired_size); 605 LLViewerPartGroup *groupp = new LLViewerPartGroup(pos_agent, desired_size, hud);
564 mViewerPartGroups.push_back(groupp); 606 mViewerPartGroups.push_back(groupp);
565 return groupp; 607 return groupp;
566} 608}