예제 #1
0
void LLGestureManager::playGesture(LLMultiGesture* gesture)
{
	if (!gesture) return;

	// Reset gesture to first step
	gesture->mCurrentStep = 0;

	// Add to list of playing
	gesture->mPlaying = TRUE;
	mPlaying.push_back(gesture);

	// And get it going
	stepGesture(gesture);

	notifyObservers();
}
void LLGestureMgr::update()
{
	S32 i;
	for (i = 0; i < (S32)mPlaying.size(); ++i)
	{
		stepGesture(mPlaying[i]);
	}

	// Clear out gestures that are done, by moving all the
	// ones that are still playing to the front.
	std::vector<LLMultiGesture*>::iterator new_end;
	new_end = std::partition(mPlaying.begin(),
							 mPlaying.end(),
							 IsGesturePlaying());

	// Something finished playing
	if (new_end != mPlaying.end())
	{
		// Delete the completed gestures that want deletion
		std::vector<LLMultiGesture*>::iterator it;
		for (it = new_end; it != mPlaying.end(); ++it)
		{
			LLMultiGesture* gesture = *it;

			if (gesture->mDoneCallback)
			{
				gesture->mDoneCallback(gesture);

				// callback might have deleted gesture, can't
				// rely on this pointer any more
				gesture = NULL;
			}
		}

		// And take done gestures out of the playing list
		mPlaying.erase(new_end, mPlaying.end());

		notifyObservers();
	}
}
void LLGestureMgr::playGesture(LLMultiGesture* gesture, bool local)
{
	if (!gesture) return;

	// Reset gesture to first step
	gesture->mCurrentStep = 0;

	// Add to list of playing
	gesture->mPlaying = TRUE;
	gesture->mLocal = local;
	mPlaying.push_back(gesture);

	// Load all needed assets to minimize the delays
	// when gesture is playing.
	for (std::vector<LLGestureStep*>::iterator steps_it = gesture->mSteps.begin();
		 steps_it != gesture->mSteps.end();
		 ++steps_it)
	{
		LLGestureStep* step = *steps_it;
		switch(step->getType())
		{
		case STEP_ANIMATION:
			{
				LLGestureStepAnimation* anim_step = (LLGestureStepAnimation*)step;
				const LLUUID& anim_id = anim_step->mAnimAssetID;

				// Don't request the animation if this step stops it or if it is already in Static VFS
				if (!(anim_id.isNull()
					  || anim_step->mFlags & ANIM_FLAG_STOP
					  || gAssetStorage->hasLocalAsset(anim_id, LLAssetType::AT_ANIMATION)))
				{
					//Singu note: Don't attempt to fetch expressions/emotes.
					const char* emote_name = gAnimLibrary.animStateToString(anim_id);
					if(emote_name && strstr(emote_name,"express_")==emote_name)
					{
						break;
					}

					mLoadingAssets.insert(anim_id);

					LLUUID* id = new LLUUID(gAgentID);
					gAssetStorage->getAssetData(anim_id,
									LLAssetType::AT_ANIMATION,
									onAssetLoadComplete,
									(void *)id,
									TRUE);
				}
				break;
			}
		case STEP_SOUND:
			{
				LLGestureStepSound* sound_step = (LLGestureStepSound*)step;
				const LLUUID& sound_id = sound_step->mSoundAssetID;
				if (!(sound_id.isNull()
					  || gAssetStorage->hasLocalAsset(sound_id, LLAssetType::AT_SOUND)))
				{
					mLoadingAssets.insert(sound_id);

					gAssetStorage->getAssetData(sound_id,
									LLAssetType::AT_SOUND,
									onAssetLoadComplete,
									NULL,
									TRUE);
				}
				break;
			}
		case STEP_CHAT:
		case STEP_WAIT:
		case STEP_EOF:
			{
				break;
			}
		default:
			{
				LL_WARNS() << "Unknown gesture step type: " << step->getType() << LL_ENDL;
			}
		}
	}

	// And get it going
	stepGesture(gesture);

	notifyObservers();
}