diff options
Diffstat (limited to 'indra/newview/llviewerpartsource.cpp')
-rw-r--r-- | indra/newview/llviewerpartsource.cpp | 129 |
1 files changed, 72 insertions, 57 deletions
diff --git a/indra/newview/llviewerpartsource.cpp b/indra/newview/llviewerpartsource.cpp index d81b688abf..4af92e79ff 100644 --- a/indra/newview/llviewerpartsource.cpp +++ b/indra/newview/llviewerpartsource.cpp @@ -2,30 +2,25 @@ * @file llviewerpartsource.cpp * @brief LLViewerPartSource class implementation * - * $LicenseInfo:firstyear=2003&license=viewergpl$ - * - * Copyright (c) 2003-2007, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2003&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlife.com/developers/opensource/gplv2 + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at http://secondlife.com/developers/opensource/flossexception + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -33,11 +28,12 @@ #include "llviewerpartsource.h" #include "llviewercontrol.h" +#include "llrender.h" #include "llagent.h" #include "lldrawable.h" #include "llviewercamera.h" -#include "llviewerimagelist.h" +#include "llviewertexturelist.h" #include "llviewerobject.h" #include "llviewerobjectlist.h" #include "llvoavatar.h" @@ -46,7 +42,8 @@ LLViewerPartSource::LLViewerPartSource(const U32 type) : mType(type), - mOwnerUUID(LLUUID::null) + mOwnerUUID(LLUUID::null), + mPartFlags(0) { mLastUpdateTime = 0.f; mLastPartTime = 0.f; @@ -68,14 +65,14 @@ void LLViewerPartSource::updatePart(LLViewerPart &part, const F32 dt) { } -void LLViewerPartSource::update(const F32 dt) +void LLViewerPartSource::update(const F32 dt) { llerrs << "Creating default part source!" << llendl; } LLUUID LLViewerPartSource::getImageUUID() const { - LLViewerImage* imagep = mImagep; + LLViewerTexture* imagep = mImagep; if(imagep) { return imagep->getID(); @@ -84,7 +81,10 @@ LLUUID LLViewerPartSource::getImageUUID() const } void LLViewerPartSource::setStart() { - mDelay = 99 ; + //cancel delaying to start a new added particle source, because some particle source just emits for a short time. + //however, canceling this might cause overall particle emmitting fluctuate for a while because the new added source jumps to + //the current particle emmitting settings instantly. -->bao + mDelay = 0 ; //99 } LLViewerPartSourceScript::LLViewerPartSourceScript(LLViewerObject *source_objp) : @@ -94,11 +94,9 @@ LLViewerPartSourceScript::LLViewerPartSourceScript(LLViewerObject *source_objp) llassert(source_objp); mSourceObjectp = source_objp; mPosAgent = mSourceObjectp->getPositionAgent(); - LLUUID id; - id.set( gViewerArt.getString("pixiesmall.tga") ); - mImagep = gImageList.getImage(id); - mImagep->bind(); - mImagep->setClamp(TRUE, TRUE); + mImagep = LLViewerTextureManager::getFetchedTextureFromFile("pixiesmall.j2c"); + + mImagep->setAddressMode(LLTexUnit::TAM_CLAMP); } @@ -119,7 +117,7 @@ void LLViewerPartSourceScript::update(const F32 dt) F32 old_update_time = mLastUpdateTime; mLastUpdateTime += dt; - F32 ref_rate_travelspeed = llmin(gWorldPointer->mPartSim.getRefRate(), 1.f); + F32 ref_rate_travelspeed = llmin(LLViewerPartSim::getInstance()->getRefRate(), 1.f); F32 dt_update = mLastUpdateTime - mLastPartTime; @@ -209,7 +207,7 @@ void LLViewerPartSourceScript::update(const F32 dt) mRotation.setQuat(0, 0, 0); } - if (gWorldPointer->mPartSim.aboveParticleLimit()) + if (LLViewerPartSim::getInstance()->aboveParticleLimit()) { // Don't bother doing any more updates if we're above the particle limit, // just give up. @@ -231,7 +229,7 @@ void LLViewerPartSourceScript::update(const F32 dt) (mPartSysData.mPartData.mStartScale[1] + mPartSysData.mPartData.mEndScale[1])/2)); - F32 pixel_meter_ratio = gCamera->getPixelMeterRatio(); + F32 pixel_meter_ratio = LLViewerCamera::getInstance()->getPixelMeterRatio(); // Maximum distance at which spawned particles will be viewable F32 max_dist = max_short_side * pixel_meter_ratio; @@ -246,7 +244,7 @@ void LLViewerPartSourceScript::update(const F32 dt) } // Distance from camera - F32 dist = (mPosAgent - gCamera->getOrigin()).magVec(); + F32 dist = (mPosAgent - LLViewerCamera::getInstance()->getOrigin()).magVec(); // Particle size vs distance vs maxage throttling @@ -263,23 +261,27 @@ void LLViewerPartSourceScript::update(const F32 dt) } if(mDelay) - { + { limited_rate = llmax(limited_rate, 0.01f * mDelay--) ; } S32 i; for (i = 0; i < mPartSysData.mBurstPartCount; i++) { - if (ll_frand() < llmax(1.0f - gWorldPointer->mPartSim.getBurstRate(), limited_rate)) + if (ll_frand() < llmax(1.0f - LLViewerPartSim::getInstance()->getBurstRate(), limited_rate)) { // Limit particle generation continue; } - LLPointer<LLViewerPart> part = new LLViewerPart(); + LLViewerPart* part = new LLViewerPart(); part->init(this, mImagep, NULL); part->mFlags = mPartSysData.mPartData.mFlags; + if (!mSourceObjectp.isNull() && mSourceObjectp->isHUDAttachment()) + { + part->mFlags |= LLPartData::LL_PART_HUD; + } part->mMaxAge = mPartSysData.mPartData.mMaxAge; part->mStartColor = mPartSysData.mPartData.mStartColor; part->mEndColor = mPartSysData.mPartData.mEndColor; @@ -381,7 +383,7 @@ void LLViewerPartSourceScript::update(const F32 dt) mPartSysData.mBurstRadius = 0; } - gWorldPointer->mPartSim.addPart(part); + LLViewerPartSim::getInstance()->addPart(part); } mLastPartTime = mLastUpdateTime; @@ -464,7 +466,26 @@ LLPointer<LLViewerPartSourceScript> LLViewerPartSourceScript::unpackPSS(LLViewer } } -void LLViewerPartSourceScript::setImage(LLViewerImage *imagep) + +/* static */ +LLPointer<LLViewerPartSourceScript> LLViewerPartSourceScript::createPSS(LLViewerObject *source_objp, const LLPartSysData& particle_parameters) +{ + LLMemType mt(LLMemType::MTYPE_PARTICLES); + + LLPointer<LLViewerPartSourceScript> new_pssp = new LLViewerPartSourceScript(source_objp); + + new_pssp->mPartSysData = particle_parameters; + + if (new_pssp->mPartSysData.mTargetUUID.notNull()) + { + LLViewerObject *target_objp = gObjectList.findObject(new_pssp->mPartSysData.mTargetUUID); + new_pssp->setTargetObject(target_objp); + } + return new_pssp; +} + + +void LLViewerPartSourceScript::setImage(LLViewerTexture *imagep) { LLMemType mt(LLMemType::MTYPE_PARTICLES); mImagep = imagep; @@ -524,9 +545,7 @@ void LLViewerPartSourceSpiral::update(const F32 dt) LLMemType mt(LLMemType::MTYPE_PARTICLES); if (!mImagep) { - LLUUID id; - id.set( gViewerArt.getString("pixiesmall.tga") ); - mImagep = gImageList.getImage(id); + mImagep = LLViewerTextureManager::getFetchedTextureFromFile("pixiesmall.j2c"); } const F32 RATE = 0.025f; @@ -540,7 +559,7 @@ void LLViewerPartSourceSpiral::update(const F32 dt) if (dt_update > RATE) { mLastPartTime = mLastUpdateTime; - if (!gWorldPointer->mPartSim.shouldAddPart()) + if (!LLViewerPartSim::getInstance()->shouldAddPart()) { // Particle simulation says we have too many particles, skip all this return; @@ -550,7 +569,7 @@ void LLViewerPartSourceSpiral::update(const F32 dt) { mPosAgent = mSourceObjectp->getRenderPosition(); } - LLPointer<LLViewerPart> part = new LLViewerPart(); + LLViewerPart* part = new LLViewerPart(); part->init(this, mImagep, updatePart); part->mStartColor = mColor; part->mEndColor = mColor; @@ -563,7 +582,7 @@ void LLViewerPartSourceSpiral::update(const F32 dt) part->mScale.mV[1] = 0.25f; part->mParameter = ll_frand(F_TWO_PI); - gWorldPointer->mPartSim.addPart(part); + LLViewerPartSim::getInstance()->addPart(part); } } @@ -687,7 +706,7 @@ void LLViewerPartSourceBeam::update(const F32 dt) if (dt_update > RATE) { mLastPartTime = mLastUpdateTime; - if (!gWorldPointer->mPartSim.shouldAddPart()) + if (!LLViewerPartSim::getInstance()->shouldAddPart()) { // Particle simulation says we have too many particles, skip all this return; @@ -695,12 +714,10 @@ void LLViewerPartSourceBeam::update(const F32 dt) if (!mImagep) { - LLUUID id; - id.set( gViewerArt.getString("pixiesmall.tga") ); - mImagep = gImageList.getImage(id); + mImagep = LLViewerTextureManager::getFetchedTextureFromFile("pixiesmall.j2c"); } - LLPointer<LLViewerPart> part = new LLViewerPart(); + LLViewerPart* part = new LLViewerPart(); part->init(this, mImagep, NULL); part->mFlags = LLPartData::LL_PART_INTERP_COLOR_MASK | @@ -720,7 +737,7 @@ void LLViewerPartSourceBeam::update(const F32 dt) part->mPosAgent = mPosAgent; part->mVelocity = mTargetPosAgent - mPosAgent; - gWorldPointer->mPartSim.addPart(part); + LLViewerPartSim::getInstance()->addPart(part); } } @@ -783,9 +800,7 @@ void LLViewerPartSourceChat::update(const F32 dt) LLMemType mt(LLMemType::MTYPE_PARTICLES); if (!mImagep) { - LLUUID id; - id.set( gViewerArt.getString("pixiesmall.tga") ); - mImagep = gImageList.getImage(id); + mImagep = LLViewerTextureManager::getFetchedTextureFromFile("pixiesmall.j2c"); } @@ -809,7 +824,7 @@ void LLViewerPartSourceChat::update(const F32 dt) if (dt_update > RATE) { mLastPartTime = mLastUpdateTime; - if (!gWorldPointer->mPartSim.shouldAddPart()) + if (!LLViewerPartSim::getInstance()->shouldAddPart()) { // Particle simulation says we have too many particles, skip all this return; @@ -819,7 +834,7 @@ void LLViewerPartSourceChat::update(const F32 dt) { mPosAgent = mSourceObjectp->getRenderPosition(); } - LLPointer<LLViewerPart> part = new LLViewerPart(); + LLViewerPart* part = new LLViewerPart(); part->init(this, mImagep, updatePart); part->mStartColor = mColor; part->mEndColor = mColor; @@ -832,7 +847,7 @@ void LLViewerPartSourceChat::update(const F32 dt) part->mScale.mV[1] = 0.25f; part->mParameter = ll_frand(F_TWO_PI); - gWorldPointer->mPartSim.addPart(part); + LLViewerPartSim::getInstance()->addPart(part); } } |