void LLMotionController::pauseAllSyncedCharacters(std::vector<LLAnimPauseRequest>& avatar_pause_handles) { // Run over all motions. for (motion_list_t::iterator iter = mActiveMotions.begin(); iter != mActiveMotions.end(); ++iter) { LLMotion* motionp = *iter; AISyncServer* server = motionp->server(); if (server && !server->never_synced() && motionp->isActive()) // Skip motions that aren't synchronized at all or that are not active. { // Run over all clients of the found servers. AISyncServer::client_list_t const& clients = server->getClients(); for (AISyncServer::client_list_t::const_iterator client = clients.begin(); client != clients.end(); ++client) { LLMotion* motion = dynamic_cast<LLMotion*>(client->mClientPtr); if (!motion) { continue; } LLMotionController* controller = motion->getController(); if (controller == this) { continue; } controller->requestPause(avatar_pause_handles); } } } }
//<singu> //----------------------------------------------------------------------------- // toggle_hidden() //----------------------------------------------------------------------------- void LLMotionController::toggle_hidden(void) { mHaveVisibleSyncedMotions = mHidden; // Default is false if we just became invisible (otherwise this value isn't used). mHidden = !mHidden; synceventset_t const visible = mHidden ? 0 : 4; // Run over all motions. for (motion_list_t::iterator iter = mActiveMotions.begin(); iter != mActiveMotions.end(); ++iter) { LLMotion* motionp = *iter; AISyncServer* server = motionp->server(); if (server && !server->never_synced() && motionp->isActive()) // Skip motions that aren't synchronized at all or that are not active. { bool visible_before = server->events_with_at_least_one_client_ready() & 4; server->ready(4, visible, motionp); // Mark that now we are visible or no longer visible. bool visible_after = server->events_with_at_least_one_client_ready() & 4; if (visible_after) // Are there any synchronized motions (left) that ARE visible? { mHaveVisibleSyncedMotions = true; } if (visible_before != visible_after) { // The group as a whole now might need to change whether or not it is animated. AISyncServer::client_list_t const& clients = server->getClients(); for (AISyncServer::client_list_t::const_iterator client = clients.begin(); client != clients.end(); ++client) { LLMotion* motion = dynamic_cast<LLMotion*>(client->mClientPtr); if (!motion) { continue; } LLMotionController* controller = motion->getController(); if (controller == this) { continue; } if (visible_after) { // Us becoming visible means that all synchronized avatars need to be animated again too. controller->setHaveVisibleSyncedMotions(); } else { // Us becoming hidden means that all synchronized avatars might stop animating. controller->refresh_hidden(); // It is extremely unlikely, but harmless, to call this twice on the same controller. } } } } } }
//----------------------------------------------------------------------------- // startMotion() //----------------------------------------------------------------------------- BOOL LLMotionController::startMotion(const LLUUID &id, F32 start_offset) { // do we have an instance of this motion for this character? LLMotion *motion = findMotion(id); // motion that is stopping will be allowed to stop but // replaced by a new instance of that motion if (motion && !mPaused && motion->canDeprecate() && motion->isActive() // singu: do not deprecate motions that are not active. && motion->getFadeWeight() > 0.01f // not LOD-ed out && (motion->isBlending() || motion->getStopTime() != 0.f)) { deprecateMotionInstance(motion); // force creation of new instance motion = NULL; } // create new motion instance if (!motion) { motion = createMotion(id); } if (!motion) { return FALSE; } //if the motion is already active and allows deprecation, then let it keep playing else if (motion->canDeprecate() && isMotionActive(motion)) { return TRUE; } // llinfos << "Starting motion " << name << llendl; //<singu> F32 start_time = mAnimTime - start_offset; if (!mDisableSyncing) { start_time = motion->syncActivationTime(start_time); } ++mDisableSyncing; //</singu> BOOL res = activateMotionInstance(motion, start_time); //<singu> --mDisableSyncing; //</singu> return res; }
void LLMotionController::refresh_hidden(void) { mHaveVisibleSyncedMotions = !mHidden; // Run over all motions. for (motion_list_t::iterator iter = mActiveMotions.begin(); iter != mActiveMotions.end(); ++iter) { LLMotion* motionp = *iter; AISyncServer* server = motionp->server(); if (server && !server->never_synced() && motionp->isActive()) // Skip motions that aren't synchronized at all or that are not active. { bool visible_after = server->events_with_at_least_one_client_ready() & 4; if (visible_after) // Are there any synchronized motions (left) that ARE visible? { mHaveVisibleSyncedMotions = true; } } } }