aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llviewerpartsource.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llviewerpartsource.cpp')
-rw-r--r--linden/indra/newview/llviewerpartsource.cpp65
1 files changed, 62 insertions, 3 deletions
diff --git a/linden/indra/newview/llviewerpartsource.cpp b/linden/indra/newview/llviewerpartsource.cpp
index 6c93e75..f54495a 100644
--- a/linden/indra/newview/llviewerpartsource.cpp
+++ b/linden/indra/newview/llviewerpartsource.cpp
@@ -36,6 +36,7 @@
36 36
37#include "llagent.h" 37#include "llagent.h"
38#include "lldrawable.h" 38#include "lldrawable.h"
39#include "llviewercamera.h"
39#include "llviewerimagelist.h" 40#include "llviewerimagelist.h"
40#include "llviewerobject.h" 41#include "llviewerobject.h"
41#include "llviewerobjectlist.h" 42#include "llviewerobjectlist.h"
@@ -53,6 +54,8 @@ LLViewerPartSource::LLViewerPartSource(const U32 type) :
53 mIsSuspended = FALSE; 54 mIsSuspended = FALSE;
54 static U32 id_seed = 0; 55 static U32 id_seed = 0;
55 mID = ++id_seed; 56 mID = ++id_seed;
57
58 mDelay = 0 ;
56} 59}
57 60
58void LLViewerPartSource::setDead() 61void LLViewerPartSource::setDead()
@@ -79,6 +82,10 @@ LLUUID LLViewerPartSource::getImageUUID() const
79 } 82 }
80 return LLUUID::null; 83 return LLUUID::null;
81} 84}
85void LLViewerPartSource::setStart()
86{
87 mDelay = 99 ;
88}
82 89
83LLViewerPartSourceScript::LLViewerPartSourceScript(LLViewerObject *source_objp) : 90LLViewerPartSourceScript::LLViewerPartSourceScript(LLViewerObject *source_objp) :
84 LLViewerPartSource(LL_PART_SOURCE_SCRIPT) 91 LLViewerPartSource(LL_PART_SOURCE_SCRIPT)
@@ -111,6 +118,8 @@ void LLViewerPartSourceScript::update(const F32 dt)
111 LLMemType mt(LLMemType::MTYPE_PARTICLES); 118 LLMemType mt(LLMemType::MTYPE_PARTICLES);
112 F32 old_update_time = mLastUpdateTime; 119 F32 old_update_time = mLastUpdateTime;
113 mLastUpdateTime += dt; 120 mLastUpdateTime += dt;
121
122 F32 ref_rate_travelspeed = llmin(gWorldPointer->mPartSim.getRefRate(), 1.f);
114 123
115 F32 dt_update = mLastUpdateTime - mLastPartTime; 124 F32 dt_update = mLastUpdateTime - mLastPartTime;
116 125
@@ -199,21 +208,71 @@ void LLViewerPartSourceScript::update(const F32 dt)
199 // No angular velocity. Reset our rotation. 208 // No angular velocity. Reset our rotation.
200 mRotation.setQuat(0, 0, 0); 209 mRotation.setQuat(0, 0, 0);
201 } 210 }
202 211
203 if (gWorldPointer->mPartSim.aboveParticleLimit()) 212 if (gWorldPointer->mPartSim.aboveParticleLimit())
204 { 213 {
205 // Don't bother doing any more updates if we're above the particle limit, 214 // Don't bother doing any more updates if we're above the particle limit,
206 // just give up. 215 // just give up.
207 mLastPartTime = mLastUpdateTime; 216 mLastPartTime = mLastUpdateTime;
217 break;
218
219 }
220
221 // find the greatest length that the shortest side of a system
222 // particle is expected to have
223 F32 max_short_side =
224 llmax(
225 llmax(llmin(mPartSysData.mPartData.mStartScale[0],
226 mPartSysData.mPartData.mStartScale[1]),
227 llmin(mPartSysData.mPartData.mEndScale[0],
228 mPartSysData.mPartData.mEndScale[1])),
229 llmin((mPartSysData.mPartData.mStartScale[0]
230 + mPartSysData.mPartData.mEndScale[0])/2,
231 (mPartSysData.mPartData.mStartScale[1]
232 + mPartSysData.mPartData.mEndScale[1])/2));
233
234 F32 pixel_meter_ratio = gCamera->getPixelMeterRatio();
235
236 // Maximum distance at which spawned particles will be viewable
237 F32 max_dist = max_short_side * pixel_meter_ratio;
238
239 if (max_dist < 0.25f)
240 {
241 // < 1 pixel wide at a distance of >=25cm. Particles
242 // this tiny are useless and mostly spawned by buggy
243 // sources
244 mLastPartTime = mLastUpdateTime;
208 break; 245 break;
209 } 246 }
210 247
248 // Distance from camera
249 F32 dist = (mPosAgent - gCamera->getOrigin()).magVec();
250
251 // Particle size vs distance vs maxage throttling
252
253 F32 limited_rate=0.f;
254 if (dist - max_dist > 0.f)
255 {
256 if((dist - max_dist) * ref_rate_travelspeed > mPartSysData.mPartData.mMaxAge - 0.2f )
257 {
258 // You need to travel faster than 1 divided by reference rate m/s directly towards these particles to see them at least 0.2s
259 mLastPartTime = mLastUpdateTime;
260 break;
261 }
262 limited_rate = ((dist - max_dist) * ref_rate_travelspeed) / mPartSysData.mPartData.mMaxAge;
263 }
264
265 if(mDelay)
266 {
267 limited_rate = llmax(limited_rate, 0.01f * mDelay--) ;
268 }
269
211 S32 i; 270 S32 i;
212 for (i = 0; i < mPartSysData.mBurstPartCount; i++) 271 for (i = 0; i < mPartSysData.mBurstPartCount; i++)
213 { 272 {
214 if (!gWorldPointer->mPartSim.shouldAddPart()) 273 if (ll_frand() < llmax(1.0f - gWorldPointer->mPartSim.getBurstRate(), limited_rate))
215 { 274 {
216 // Particle simulation says we have too many particles, skip all this 275 // Limit particle generation
217 continue; 276 continue;
218 } 277 }
219 278