void LLHUDEffectBeam::unpackData(LLMessageSystem *mesgsys, S32 blocknum) { llerrs << "Got beam!" << llendl; BOOL use_target_object; LLVector3d new_target; U8 packed_data[41]; LLHUDEffect::unpackData(mesgsys, blocknum); LLUUID source_id; LLUUID target_id; S32 size = mesgsys->getSizeFast(_PREHASH_Effect, blocknum, _PREHASH_TypeData); if (size != 41) { llwarns << "Beam effect with bad size " << size << llendl; return; } mesgsys->getBinaryDataFast(_PREHASH_Effect, _PREHASH_TypeData, packed_data, 41, blocknum); htonmemcpy(source_id.mData, packed_data, MVT_LLUUID, 16); LLViewerObject *objp = gObjectList.findObject(source_id); if (objp) { setSourceObject(objp); } use_target_object = packed_data[16]; if (use_target_object) { htonmemcpy(target_id.mData, &packed_data[17], MVT_LLUUID, 16); LLViewerObject *objp = gObjectList.findObject(target_id); if (objp) { setTargetObject(objp); } } else { htonmemcpy(new_target.mdV, &(packed_data[17]), MVT_LLVector3d, 24); setTargetPos(new_target); } // We've received an update for the effect, update the various timeouts // and fade animations. mKillTime = mTimer.getElapsedTimeF32() + mDuration; F32 fade_length; fade_length = llmin(0.5f, mDuration); mFadeInterp.setStartTime(mKillTime - fade_length); mFadeInterp.setEndTime(mKillTime); mFadeInterp.setStartVal(1.f); mFadeInterp.setEndVal(0.f); }
HidingStateChanger::HidingStateChanger(QObject* target, const QByteArray property, QObject* parent) : ItemVisibilityController(parent) { connect(this, SIGNAL(propertiesAssigned(bool)), this, SLOT(slotPropertiesAssigned(bool))); setTargetObject(target); setPropertyName(property); // here, we assume to start with a visible item setVisible(true); }
PHISlideAnimation::PHISlideAnimation(PHIBaseItem *item, qreal orgHeight, bool upDir ) : QPropertyAnimation( item ), _item( item ), _orgHeight( orgHeight ), _upDir( upDir ) { setTargetObject( item ); setPropertyName( "_height" ); connect( this, &QPropertyAnimation::finished, this, &PHISlideAnimation::slotFinished ); connect( this, &QPropertyAnimation::stateChanged, this, &PHISlideAnimation::slotStateChanged ); if ( _upDir ) { setStartValue( _orgHeight ); setEndValue( 0 ); } else { setStartValue( 0 ); setEndValue( _orgHeight ); } }
int QPropertyAnimation::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QVariantAnimation::qt_metacall(_c, _id, _a); if (_id < 0) return _id; #ifndef QT_NO_PROPERTIES if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QByteArray*>(_v) = propertyName(); break; case 1: *reinterpret_cast< QObject**>(_v) = targetObject(); break; } _id -= 2; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setPropertyName(*reinterpret_cast< QByteArray*>(_v)); break; case 1: setTargetObject(*reinterpret_cast< QObject**>(_v)); break; } _id -= 2; } else if (_c == QMetaObject::ResetProperty) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 2; } #endif // QT_NO_PROPERTIES return _id; }
void LLHUDEffectSpiral::unpackData(LLMessageSystem *mesgsys, S32 blocknum) { const size_t EFFECT_SIZE = 56; U8 packed_data[EFFECT_SIZE]; LLHUDEffect::unpackData(mesgsys, blocknum); LLUUID object_id, target_object_id; S32 size = mesgsys->getSizeFast(_PREHASH_Effect, blocknum, _PREHASH_TypeData); if (size != EFFECT_SIZE) { llwarns << "Spiral effect with bad size " << size << llendl; return; } mesgsys->getBinaryDataFast(_PREHASH_Effect, _PREHASH_TypeData, packed_data, EFFECT_SIZE, blocknum, EFFECT_SIZE); htonmemcpy(object_id.mData, packed_data, MVT_LLUUID, 16); htonmemcpy(target_object_id.mData, packed_data + 16, MVT_LLUUID, 16); htonmemcpy(mPositionGlobal.mdV, packed_data + 32, MVT_LLVector3d, 24); LLViewerObject *objp = NULL; if (object_id.isNull()) { setSourceObject(NULL); } else { LLViewerObject *objp = gObjectList.findObject(object_id); if (objp) { setSourceObject(objp); } else { // We don't have this object, kill this effect markDead(); return; } } if (target_object_id.isNull()) { setTargetObject(NULL); } else { objp = gObjectList.findObject(target_object_id); if (objp) { setTargetObject(objp); } else { // We don't have this object, kill this effect markDead(); return; } } triggerLocal(); }
void LLViewerPartSourceScript::update(const F32 dt) { if( mIsSuspended ) return; LLMemType mt(LLMemType::MTYPE_PARTICLES); F32 old_update_time = mLastUpdateTime; mLastUpdateTime += dt; F32 ref_rate_travelspeed = llmin(LLViewerPartSim::getInstance()->getRefRate(), 1.f); F32 dt_update = mLastUpdateTime - mLastPartTime; // Update this for objects which have the follow flag set... if (!mSourceObjectp.isNull()) { if (mSourceObjectp->isDead()) { mSourceObjectp = NULL; } else if (mSourceObjectp->mDrawable.notNull()) { mPosAgent = mSourceObjectp->getRenderPosition(); } } if (mTargetObjectp.isNull() && mPartSysData.mTargetUUID.notNull()) { // // Hmm, missing object, let's see if we can find it... // LLViewerObject *target_objp = gObjectList.findObject(mPartSysData.mTargetUUID); setTargetObject(target_objp); } if (!mTargetObjectp.isNull()) { if (mTargetObjectp->isDead()) { mTargetObjectp = NULL; } else if (mTargetObjectp->mDrawable.notNull()) { mTargetPosAgent = mTargetObjectp->getRenderPosition(); } } if (!mTargetObjectp) { mTargetPosAgent = mPosAgent; } if (mPartSysData.mMaxAge && ((mPartSysData.mStartAge + mLastUpdateTime + dt_update) > mPartSysData.mMaxAge)) { // Kill particle source because it has outlived its max age... setDead(); return; } if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_PARTICLES)) { if (mSourceObjectp.notNull()) { std::ostringstream ostr; ostr << mPartSysData; mSourceObjectp->setDebugText(ostr.str()); } } BOOL first_run = FALSE; if (old_update_time <= 0.f) { first_run = TRUE; } F32 max_time = llmax(1.f, 10.f*mPartSysData.mBurstRate); dt_update = llmin(max_time, dt_update); while ((dt_update > mPartSysData.mBurstRate) || first_run) { first_run = FALSE; // Update the rotation of the particle source by the angular velocity // First check to see if there is still an angular velocity. F32 angular_velocity_mag = mPartSysData.mAngularVelocity.magVec(); if (angular_velocity_mag != 0.0f) { F32 av_angle = dt * angular_velocity_mag; LLQuaternion dquat(av_angle, mPartSysData.mAngularVelocity); mRotation *= dquat; } else { // No angular velocity. Reset our rotation. mRotation.setQuat(0, 0, 0); } if (LLViewerPartSim::getInstance()->aboveParticleLimit()) { // Don't bother doing any more updates if we're above the particle limit, // just give up. mLastPartTime = mLastUpdateTime; break; } // find the greatest length that the shortest side of a system // particle is expected to have F32 max_short_side = llmax( llmax(llmin(mPartSysData.mPartData.mStartScale[0], mPartSysData.mPartData.mStartScale[1]), llmin(mPartSysData.mPartData.mEndScale[0], mPartSysData.mPartData.mEndScale[1])), llmin((mPartSysData.mPartData.mStartScale[0] + mPartSysData.mPartData.mEndScale[0])/2, (mPartSysData.mPartData.mStartScale[1] + mPartSysData.mPartData.mEndScale[1])/2)); 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; if (max_dist < 0.25f) { // < 1 pixel wide at a distance of >=25cm. Particles // this tiny are useless and mostly spawned by buggy // sources mLastPartTime = mLastUpdateTime; break; } // Distance from camera F32 dist = (mPosAgent - LLViewerCamera::getInstance()->getOrigin()).magVec(); // Particle size vs distance vs maxage throttling F32 limited_rate=0.f; if (dist - max_dist > 0.f) { if((dist - max_dist) * ref_rate_travelspeed > mPartSysData.mPartData.mMaxAge - 0.2f ) { // You need to travel faster than 1 divided by reference rate m/s directly towards these particles to see them at least 0.2s mLastPartTime = mLastUpdateTime; break; } limited_rate = ((dist - max_dist) * ref_rate_travelspeed) / mPartSysData.mPartData.mMaxAge; } 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 - LLViewerPartSim::getInstance()->getBurstRate(), limited_rate)) { // Limit particle generation continue; } 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; part->mColor = part->mStartColor; part->mStartScale = mPartSysData.mPartData.mStartScale; part->mEndScale = mPartSysData.mPartData.mEndScale; part->mScale = part->mStartScale; part->mAccel = mPartSysData.mPartAccel; if (mPartSysData.mPattern & LLPartSysData::LL_PART_SRC_PATTERN_DROP) { part->mPosAgent = mPosAgent; part->mVelocity.setVec(0.f, 0.f, 0.f); } else if (mPartSysData.mPattern & LLPartSysData::LL_PART_SRC_PATTERN_EXPLODE) { part->mPosAgent = mPosAgent; LLVector3 part_dir_vector; F32 mvs; do { part_dir_vector.mV[VX] = ll_frand(2.f) - 1.f; part_dir_vector.mV[VY] = ll_frand(2.f) - 1.f; part_dir_vector.mV[VZ] = ll_frand(2.f) - 1.f; mvs = part_dir_vector.magVecSquared(); } while ((mvs > 1.f) || (mvs < 0.01f)); part_dir_vector.normVec(); part->mPosAgent += mPartSysData.mBurstRadius*part_dir_vector; part->mVelocity = part_dir_vector; F32 speed = mPartSysData.mBurstSpeedMin + ll_frand(mPartSysData.mBurstSpeedMax - mPartSysData.mBurstSpeedMin); part->mVelocity *= speed; } else if (mPartSysData.mPattern & LLPartSysData::LL_PART_SRC_PATTERN_ANGLE || mPartSysData.mPattern & LLPartSysData::LL_PART_SRC_PATTERN_ANGLE_CONE) { part->mPosAgent = mPosAgent; // original implemenetation for part_dir_vector was just: LLVector3 part_dir_vector(0.0, 0.0, 1.0); // params from the script... // outer = outer cone angle // inner = inner cone angle // between outer and inner there will be particles F32 innerAngle = mPartSysData.mInnerAngle; F32 outerAngle = mPartSysData.mOuterAngle; // generate a random angle within the given space... F32 angle = innerAngle + ll_frand(outerAngle - innerAngle); // split which side it will go on randomly... if (ll_frand() < 0.5) { angle = -angle; } // Both patterns rotate around the x-axis first: part_dir_vector.rotVec(angle, 1.0, 0.0, 0.0); // If this is a cone pattern, rotate again to create the cone. if (mPartSysData.mPattern & LLPartSysData::LL_PART_SRC_PATTERN_ANGLE_CONE) { part_dir_vector.rotVec(ll_frand(4*F_PI), 0.0, 0.0, 1.0); } // Only apply this rotation if using the deprecated angles. if (! (mPartSysData.mFlags & LLPartSysData::LL_PART_USE_NEW_ANGLE)) { // Deprecated... part_dir_vector.rotVec(outerAngle, 1.0, 0.0, 0.0); } if (mSourceObjectp) { part_dir_vector = part_dir_vector * mSourceObjectp->getRenderRotation(); } part_dir_vector = part_dir_vector * mRotation; part->mPosAgent += mPartSysData.mBurstRadius*part_dir_vector; part->mVelocity = part_dir_vector; F32 speed = mPartSysData.mBurstSpeedMin + ll_frand(mPartSysData.mBurstSpeedMax - mPartSysData.mBurstSpeedMin); part->mVelocity *= speed; } else { part->mPosAgent = mPosAgent; part->mVelocity.setVec(0.f, 0.f, 0.f); //llwarns << "Unknown source pattern " << (S32)mPartSysData.mPattern << llendl; } if (part->mFlags & LLPartData::LL_PART_FOLLOW_SRC_MASK || // SVC-193, VWR-717 part->mFlags & LLPartData::LL_PART_TARGET_LINEAR_MASK) { mPartSysData.mBurstRadius = 0; } LLViewerPartSim::getInstance()->addPart(part); } mLastPartTime = mLastUpdateTime; dt_update -= mPartSysData.mBurstRate; } }
/*! Construct a QtPropertyAnimation object. \a parent is passed to QObject's constructor. The animation changes the property \a propertyName on \a target. The default duration is 250ms. \sa targetObject, propertyName */ QtPropertyAnimation::QtPropertyAnimation(QObject *target, const QByteArray &propertyName, QObject *parent) : QtVariantAnimation(*new QtPropertyAnimationPrivate, parent) { setTargetObject(target); setPropertyName(propertyName); }
void MonsterFlock::targetTo(PlayerShape* p) { setTargetObject(p->getFlockPos()); }