bool CActionScope::IsDifferent(const FragmentID aaID, const TagState &fragmentTags, const TagID subContext /*= TAG_ID_INVALID*/) const { if (m_lastFragmentID != aaID) { return true; } else { SFragmentQuery fragQuery(aaID, SFragTagState(m_context.state.GetMask(), fragmentTags)); if (subContext != TAG_ID_INVALID) { const SSubContext subContextDef = m_context.controllerDef.m_subContext[subContext]; fragQuery.tagState.globalTags = m_context.controllerDef.m_tags.GetUnion(fragQuery.tagState.globalTags, m_context.subStates[subContext].GetMask()); fragQuery.tagState.globalTags = m_context.controllerDef.m_tags.GetUnion(fragQuery.tagState.globalTags, subContextDef.additionalTags); } fragQuery.tagState.globalTags = m_context.controllerDef.m_tags.GetUnion(fragQuery.tagState.globalTags, m_additionalTags); fragQuery.requiredTags = m_additionalTags; SFragTagState foundState; const bool foundMatch = (GetDatabase().FindBestMatchingTag(fragQuery, &foundState) > 0); return ((foundMatch != HasFragment()) || (foundMatch && (foundState != m_lastFragSelection.tagState))); } return false; }
bool CFragmentVariationHelper::Reevaluate( const IAnimationDatabase* pDatabase, const bool forceReevaluate ) { CRY_ASSERT( pDatabase ); const bool fragmentIdChanged = ( m_requestedFragmentId != m_currentFragmentId ); const bool tagStateChanged = ( m_requestedTagState != m_currentTagState ); const bool reevaluate = ( m_reachedFragmentEnd || tagStateChanged || fragmentIdChanged || forceReevaluate ); if ( ! reevaluate ) { return false; } SFragTagState matchingTagState; if ( m_requestedFragmentId != FRAGMENT_ID_INVALID ) { SFragmentQuery fragQuery(m_requestedFragmentId, m_requestedTagState); const uint32 optionCount = pDatabase->FindBestMatchingTag( fragQuery, &matchingTagState ); } const bool fragmentTagsChanged = ( matchingTagState != m_selectedTagState ); const bool fragmentChanged = ( fragmentIdChanged || fragmentTagsChanged ); m_currentFragmentId = m_requestedFragmentId; m_selectedTagState = matchingTagState; m_selectedOptionIndex = OPTION_IDX_RANDOM; // TODO: Be smarter about this! m_currentTagState = m_requestedTagState; const bool shouldQueueNewFragment = ( fragmentChanged || m_reachedFragmentEnd || forceReevaluate ); m_reachedFragmentEnd = false; return shouldQueueNewFragment; }
void CInteractiveObjectRegistry::QueryInteractiveActionOptions( const EntityId entityId, const TagID interactionTag, const TagID stateTagId, std::vector<SInteraction> &options) { if (m_pDatabasePlayer) { SFragTagState fragTagState; if ((m_interactFragID != TAG_ID_INVALID) && (interactionTag != TAG_ID_INVALID)) { const CTagDefinition *tagDef = m_pDatabasePlayer->GetFragmentDefs().GetSubTagDefinition(m_interactFragID); const bool hasState = (stateTagId != TAG_ID_INVALID); m_entityToTag[entityId].interactionTagID = interactionTag; m_entityToTag[entityId].stateTagID = stateTagId; SFragTagState fragTagStateMatch; tagDef->Set(fragTagState.fragmentTags, interactionTag, true); if (hasState) { tagDef->Set(fragTagState.fragmentTags, stateTagId, true); } uint32 tagSetIdx; SFragmentQuery fragQuery(m_interactFragID, fragTagState); int32 numOptions = m_pDatabasePlayer->FindBestMatchingTag(fragQuery, &fragTagStateMatch, &tagSetIdx); if (hasState && !tagDef->IsSet(fragTagStateMatch.fragmentTags, stateTagId)) { numOptions = 0; } for (int32 i=0; i<numOptions; i++) { const CFragment *fragment = m_pDatabasePlayer->GetEntry(m_interactFragID, tagSetIdx, i); bool foundLocator = false; const uint32 numProcLayers = fragment->m_procLayers.size(); for (uint32 k=0; (k<numProcLayers) && !foundLocator; k++) { const uint32 numClips = fragment->m_procLayers[k].size(); for (uint32 c=0; (c<numClips) && !foundLocator; c++) { const SProceduralEntry &entry = fragment->m_procLayers[k][c]; if (entry.typeNameHash == m_clipLocatorHash) { const SProceduralClipPosAdjustTargetLocatorParams* const pParams = static_cast<const SProceduralClipPosAdjustTargetLocatorParams*>(entry.pProceduralParams.get()); CRY_ASSERT(pParams); foundLocator = true; SInteraction interaction; interaction.helper = pParams->targetJointName.c_str(); interaction.targetStateTagID = tagDef->Find(pParams->targetStateName.crc); options.push_back(interaction); } } } } } } }
bool CActionScope::IsDifferent(const FragmentID aaID, const TagState &fragmentTags, const TagID subContext /*= TAG_ID_INVALID*/) const { if (m_lastFragmentID != aaID) { return true; } else { uint32 tagSetIdx; if (aaID == m_cachedaaID && fragmentTags == m_cachedFragmentTags && m_context.state.GetMask() == m_cachedContextStateMask) { tagSetIdx = m_cachedTagSetIdx; } else { SFragmentQuery fragQuery(aaID, SFragTagState(m_context.state.GetMask(), fragmentTags)); if (subContext != TAG_ID_INVALID) { const SSubContext subContextDef = m_context.controllerDef.m_subContext[subContext]; fragQuery.tagState.globalTags = m_context.controllerDef.m_tags.GetUnion(fragQuery.tagState.globalTags, m_context.subStates[subContext].GetMask()); fragQuery.tagState.globalTags = m_context.controllerDef.m_tags.GetUnion(fragQuery.tagState.globalTags, subContextDef.additionalTags); } fragQuery.tagState.globalTags = m_context.controllerDef.m_tags.GetUnion(fragQuery.tagState.globalTags, m_additionalTags); fragQuery.requiredTags = m_additionalTags; // the database may not exist in case of full enslavement if (!m_scopeContext.pDatabase) { return false; } GetDatabase().FindBestMatchingTag(fragQuery, NULL, &tagSetIdx); //--- Store cache m_cachedaaID = aaID; m_cachedFragmentTags = fragmentTags; m_cachedContextStateMask = m_context.state.GetMask(); m_cachedTagSetIdx = tagSetIdx; } return tagSetIdx != m_lastFragSelection.tagSetIdx; } return false; }