Annotation of /trunk/indra/newview/llhudeffecttrail.cpp
Parent Directory
|
Revision Log
Revision 137 - (view) (download)
| 1 : | mjm | 135 | /** |
| 2 : | * @file llhudeffecttrail.cpp | ||
| 3 : | * @brief LLHUDEffectSpiral class implementation | ||
| 4 : | * | ||
| 5 : | * $LicenseInfo:firstyear=2002&license=viewergpl$ | ||
| 6 : | * | ||
| 7 : | mjm | 137 | * Copyright (c) 2002-2010, Linden Research, Inc. |
| 8 : | mjm | 135 | * |
| 9 : | * Second Life Viewer Source Code | ||
| 10 : | * The source code in this file ("Source Code") is provided by Linden Lab | ||
| 11 : | * to you under the terms of the GNU General Public License, version 2.0 | ||
| 12 : | * ("GPL"), unless you have obtained a separate licensing agreement | ||
| 13 : | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
| 14 : | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
| 15 : | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
| 16 : | * | ||
| 17 : | * There are special exceptions to the terms and conditions of the GPL as | ||
| 18 : | * it is applied to this Source Code. View the full text of the exception | ||
| 19 : | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
| 20 : | * online at | ||
| 21 : | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
| 22 : | * | ||
| 23 : | * By copying, modifying or distributing this software, you acknowledge | ||
| 24 : | * that you have read and understood your obligations described above, | ||
| 25 : | * and agree to abide by those obligations. | ||
| 26 : | * | ||
| 27 : | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
| 28 : | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
| 29 : | * COMPLETENESS OR PERFORMANCE. | ||
| 30 : | * $/LicenseInfo$ | ||
| 31 : | */ | ||
| 32 : | |||
| 33 : | #include "llviewerprecompiledheaders.h" | ||
| 34 : | |||
| 35 : | #include "llhudeffecttrail.h" | ||
| 36 : | |||
| 37 : | #include "llviewercontrol.h" | ||
| 38 : | #include "llimagegl.h" | ||
| 39 : | #include "message.h" | ||
| 40 : | |||
| 41 : | #include "llagent.h" | ||
| 42 : | #include "llbox.h" | ||
| 43 : | #include "lldrawable.h" | ||
| 44 : | #include "llhudrender.h" | ||
| 45 : | #include "llviewerimagelist.h" | ||
| 46 : | #include "llviewerobjectlist.h" | ||
| 47 : | #include "llviewerpartsim.h" | ||
| 48 : | #include "llviewerpartsource.h" | ||
| 49 : | #include "llvoavatar.h" | ||
| 50 : | #include "llworld.h" | ||
| 51 : | |||
| 52 : | |||
| 53 : | const F32 PARTICLE_SPACING = 0.01f; | ||
| 54 : | const F32 MAX_SIZE = 0.025f; | ||
| 55 : | const F32 START_POS_MAG = 1.f; | ||
| 56 : | const F32 END_POS_MAG = 1.2f; | ||
| 57 : | |||
| 58 : | |||
| 59 : | LLHUDEffectSpiral::LLHUDEffectSpiral(const U8 type) : LLHUDEffect(type), mbInit(FALSE) | ||
| 60 : | { | ||
| 61 : | mKillTime = 10.f; | ||
| 62 : | mVMag = 1.f; | ||
| 63 : | mVOffset = 0.f; | ||
| 64 : | mInitialRadius = 1.f; | ||
| 65 : | mFinalRadius = 1.f; | ||
| 66 : | mSpinRate = 10.f; | ||
| 67 : | mFlickerRate = 50.f; | ||
| 68 : | mScaleBase = 0.1f; | ||
| 69 : | mScaleVar = 0.f; | ||
| 70 : | |||
| 71 : | mFadeInterp.setStartTime(0.f); | ||
| 72 : | mFadeInterp.setEndTime(mKillTime); | ||
| 73 : | mFadeInterp.setStartVal(1.f); | ||
| 74 : | mFadeInterp.setEndVal(1.f); | ||
| 75 : | } | ||
| 76 : | |||
| 77 : | LLHUDEffectSpiral::~LLHUDEffectSpiral() | ||
| 78 : | { | ||
| 79 : | } | ||
| 80 : | |||
| 81 : | void LLHUDEffectSpiral::markDead() | ||
| 82 : | { | ||
| 83 : | if (mPartSourcep) | ||
| 84 : | { | ||
| 85 : | mPartSourcep->setDead(); | ||
| 86 : | mPartSourcep = NULL; | ||
| 87 : | } | ||
| 88 : | LLHUDEffect::markDead(); | ||
| 89 : | } | ||
| 90 : | |||
| 91 : | void LLHUDEffectSpiral::packData(LLMessageSystem *mesgsys) | ||
| 92 : | { | ||
| 93 : | if (!mSourceObject) | ||
| 94 : | { | ||
| 95 : | //llwarns << "Missing object in trail pack!" << llendl; | ||
| 96 : | } | ||
| 97 : | LLHUDEffect::packData(mesgsys); | ||
| 98 : | |||
| 99 : | U8 packed_data[56]; | ||
| 100 : | memset(packed_data, 0, 56); | ||
| 101 : | |||
| 102 : | if (mSourceObject) | ||
| 103 : | { | ||
| 104 : | htonmemcpy(packed_data, mSourceObject->mID.mData, MVT_LLUUID, 16); | ||
| 105 : | } | ||
| 106 : | if (mTargetObject) | ||
| 107 : | { | ||
| 108 : | htonmemcpy(packed_data + 16, mTargetObject->mID.mData, MVT_LLUUID, 16); | ||
| 109 : | } | ||
| 110 : | if (!mPositionGlobal.isExactlyZero()) | ||
| 111 : | { | ||
| 112 : | htonmemcpy(packed_data + 32, mPositionGlobal.mdV, MVT_LLVector3d, 24); | ||
| 113 : | } | ||
| 114 : | mesgsys->addBinaryDataFast(_PREHASH_TypeData, packed_data, 56); | ||
| 115 : | } | ||
| 116 : | |||
| 117 : | void LLHUDEffectSpiral::unpackData(LLMessageSystem *mesgsys, S32 blocknum) | ||
| 118 : | { | ||
| 119 : | const size_t EFFECT_SIZE = 56; | ||
| 120 : | U8 packed_data[EFFECT_SIZE]; | ||
| 121 : | |||
| 122 : | LLHUDEffect::unpackData(mesgsys, blocknum); | ||
| 123 : | LLUUID object_id, target_object_id; | ||
| 124 : | S32 size = mesgsys->getSizeFast(_PREHASH_Effect, blocknum, _PREHASH_TypeData); | ||
| 125 : | if (size != EFFECT_SIZE) | ||
| 126 : | { | ||
| 127 : | llwarns << "Spiral effect with bad size " << size << llendl; | ||
| 128 : | return; | ||
| 129 : | } | ||
| 130 : | mesgsys->getBinaryDataFast(_PREHASH_Effect, _PREHASH_TypeData, | ||
| 131 : | packed_data, EFFECT_SIZE, blocknum, EFFECT_SIZE); | ||
| 132 : | |||
| 133 : | htonmemcpy(object_id.mData, packed_data, MVT_LLUUID, 16); | ||
| 134 : | htonmemcpy(target_object_id.mData, packed_data + 16, MVT_LLUUID, 16); | ||
| 135 : | htonmemcpy(mPositionGlobal.mdV, packed_data + 32, MVT_LLVector3d, 24); | ||
| 136 : | |||
| 137 : | LLViewerObject *objp = NULL; | ||
| 138 : | |||
| 139 : | if (object_id.isNull()) | ||
| 140 : | { | ||
| 141 : | setSourceObject(NULL); | ||
| 142 : | } | ||
| 143 : | else | ||
| 144 : | { | ||
| 145 : | LLViewerObject *objp = gObjectList.findObject(object_id); | ||
| 146 : | if (objp) | ||
| 147 : | { | ||
| 148 : | setSourceObject(objp); | ||
| 149 : | } | ||
| 150 : | else | ||
| 151 : | { | ||
| 152 : | // We don't have this object, kill this effect | ||
| 153 : | markDead(); | ||
| 154 : | return; | ||
| 155 : | } | ||
| 156 : | } | ||
| 157 : | |||
| 158 : | if (target_object_id.isNull()) | ||
| 159 : | { | ||
| 160 : | setTargetObject(NULL); | ||
| 161 : | } | ||
| 162 : | else | ||
| 163 : | { | ||
| 164 : | objp = gObjectList.findObject(target_object_id); | ||
| 165 : | if (objp) | ||
| 166 : | { | ||
| 167 : | setTargetObject(objp); | ||
| 168 : | } | ||
| 169 : | else | ||
| 170 : | { | ||
| 171 : | // We don't have this object, kill this effect | ||
| 172 : | markDead(); | ||
| 173 : | return; | ||
| 174 : | } | ||
| 175 : | } | ||
| 176 : | |||
| 177 : | triggerLocal(); | ||
| 178 : | } | ||
| 179 : | |||
| 180 : | void LLHUDEffectSpiral::triggerLocal() | ||
| 181 : | { | ||
| 182 : | mKillTime = mTimer.getElapsedTimeF32() + mDuration; | ||
| 183 : | |||
| 184 : | BOOL show_beam = gSavedSettings.getBOOL("ShowSelectionBeam"); | ||
| 185 : | |||
| 186 : | LLColor4 color; | ||
| 187 : | color.setVec(mColor); | ||
| 188 : | |||
| 189 : | if (!mPartSourcep) | ||
| 190 : | { | ||
| 191 : | if (!mTargetObject.isNull() && !mSourceObject.isNull()) | ||
| 192 : | { | ||
| 193 : | if (show_beam) | ||
| 194 : | { | ||
| 195 : | LLPointer<LLViewerPartSourceBeam> psb = new LLViewerPartSourceBeam; | ||
| 196 : | psb->setColor(color); | ||
| 197 : | psb->setSourceObject(mSourceObject); | ||
| 198 : | psb->setTargetObject(mTargetObject); | ||
| 199 : | psb->setOwnerUUID(gAgent.getID()); | ||
| 200 : | LLViewerPartSim::getInstance()->addPartSource(psb); | ||
| 201 : | mPartSourcep = psb; | ||
| 202 : | } | ||
| 203 : | } | ||
| 204 : | else | ||
| 205 : | { | ||
| 206 : | if (!mSourceObject.isNull() && !mPositionGlobal.isExactlyZero()) | ||
| 207 : | { | ||
| 208 : | if (show_beam) | ||
| 209 : | { | ||
| 210 : | LLPointer<LLViewerPartSourceBeam> psb = new LLViewerPartSourceBeam; | ||
| 211 : | psb->setSourceObject(mSourceObject); | ||
| 212 : | psb->setTargetObject(NULL); | ||
| 213 : | psb->setColor(color); | ||
| 214 : | psb->mLKGTargetPosGlobal = mPositionGlobal; | ||
| 215 : | psb->setOwnerUUID(gAgent.getID()); | ||
| 216 : | LLViewerPartSim::getInstance()->addPartSource(psb); | ||
| 217 : | mPartSourcep = psb; | ||
| 218 : | } | ||
| 219 : | } | ||
| 220 : | else | ||
| 221 : | { | ||
| 222 : | LLVector3 pos; | ||
| 223 : | if (mSourceObject) | ||
| 224 : | { | ||
| 225 : | pos = mSourceObject->getPositionAgent(); | ||
| 226 : | } | ||
| 227 : | else | ||
| 228 : | { | ||
| 229 : | pos = gAgent.getPosAgentFromGlobal(mPositionGlobal); | ||
| 230 : | } | ||
| 231 : | LLPointer<LLViewerPartSourceSpiral> pss = new LLViewerPartSourceSpiral(pos); | ||
| 232 : | if (!mSourceObject.isNull()) | ||
| 233 : | { | ||
| 234 : | pss->setSourceObject(mSourceObject); | ||
| 235 : | } | ||
| 236 : | pss->setColor(color); | ||
| 237 : | pss->setOwnerUUID(gAgent.getID()); | ||
| 238 : | LLViewerPartSim::getInstance()->addPartSource(pss); | ||
| 239 : | mPartSourcep = pss; | ||
| 240 : | } | ||
| 241 : | } | ||
| 242 : | } | ||
| 243 : | else | ||
| 244 : | { | ||
| 245 : | LLPointer<LLViewerPartSource>& ps = mPartSourcep; | ||
| 246 : | if (mPartSourcep->getType() == LLViewerPartSource::LL_PART_SOURCE_BEAM) | ||
| 247 : | { | ||
| 248 : | LLViewerPartSourceBeam *psb = (LLViewerPartSourceBeam *)ps.get(); | ||
| 249 : | psb->setSourceObject(mSourceObject); | ||
| 250 : | psb->setTargetObject(mTargetObject); | ||
| 251 : | psb->setColor(color); | ||
| 252 : | if (mTargetObject.isNull()) | ||
| 253 : | { | ||
| 254 : | psb->mLKGTargetPosGlobal = mPositionGlobal; | ||
| 255 : | } | ||
| 256 : | } | ||
| 257 : | else | ||
| 258 : | { | ||
| 259 : | LLViewerPartSourceSpiral *pss = (LLViewerPartSourceSpiral *)ps.get(); | ||
| 260 : | pss->setSourceObject(mSourceObject); | ||
| 261 : | } | ||
| 262 : | } | ||
| 263 : | |||
| 264 : | mbInit = TRUE; | ||
| 265 : | } | ||
| 266 : | |||
| 267 : | void LLHUDEffectSpiral::setTargetObject(LLViewerObject *objp) | ||
| 268 : | { | ||
| 269 : | if (objp == mTargetObject) | ||
| 270 : | { | ||
| 271 : | return; | ||
| 272 : | } | ||
| 273 : | |||
| 274 : | mTargetObject = objp; | ||
| 275 : | } | ||
| 276 : | |||
| 277 : | void LLHUDEffectSpiral::render() | ||
| 278 : | { | ||
| 279 : | F32 time = mTimer.getElapsedTimeF32(); | ||
| 280 : | |||
| 281 : | if ((!mSourceObject.isNull() && mSourceObject->isDead()) || | ||
| 282 : | (!mTargetObject.isNull() && mTargetObject->isDead()) || | ||
| 283 : | mKillTime < time || | ||
| 284 : | (!mPartSourcep.isNull() && !gSavedSettings.getBOOL("ShowSelectionBeam")) ) | ||
| 285 : | { | ||
| 286 : | markDead(); | ||
| 287 : | return; | ||
| 288 : | } | ||
| 289 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

