internal static void FillQueryResultInternal(int dataId, Conditions conditions, CachedTraitCollection traits, QueryMatchID matchId, QueryResult result) { traits.TryGetType(out List <Dictionary <int, System.Int32> > intCollections); conditions.TryGetType(out ICondition <System.Int32>[] intConditions); FillQueryResult <System.Int32>(dataId, intConditions, intCollections, result); traits.TryGetType(out List <Dictionary <int, System.Single> > floatCollections); conditions.TryGetType(out ICondition <System.Single>[] floatConditions); FillQueryResult <System.Single>(dataId, floatConditions, floatCollections, result); traits.TryGetType(out List <Dictionary <int, System.String> > stringCollections); conditions.TryGetType(out ICondition <System.String>[] stringConditions); FillQueryResult <System.String>(dataId, stringConditions, stringCollections, result); traits.TryGetType(out List <Dictionary <int, UnityEngine.Pose> > poseCollections); conditions.TryGetType(out ICondition <UnityEngine.Pose>[] poseConditions); FillQueryResult <UnityEngine.Pose>(dataId, poseConditions, poseCollections, result); traits.TryGetType(out List <Dictionary <int, UnityEngine.Vector2> > vector2Collections); conditions.TryGetType(out ICondition <UnityEngine.Vector2>[] vector2Conditions); FillQueryResult <UnityEngine.Vector2>(dataId, vector2Conditions, vector2Collections, result); }
internal static bool RateConditionType(ICondition <UnityEngine.Pose>[] typeConditions, CachedTraitCollection traitCollections, List <Dictionary <int, float> > ratings) { if (typeConditions.Length == 0) { return(true); } if (!traitCollections.TryGetType(out List <Dictionary <int, UnityEngine.Pose> > traits)) { return(false); } return(RateConditionMatches(typeConditions, traits, ratings)); }
internal static bool RateConditionMatches(ProxyConditions conditions, CachedTraitCollection traitCache, ConditionRatingsData resultData) { if (conditions.Count <= 0) { return(false); } conditions.TryGetType(out ISemanticTagCondition[] semanticTagConditions); traitCache.TryGetType(out List <Dictionary <int, bool> > semanticTagTraits); var semanticTagsMatched = RateSemanticTagConditionMatches(semanticTagConditions, semanticTagTraits, resultData[typeof(bool)], resultData.MatchRuleIndexes); return(semanticTagsMatched && RateConditionMatchesInternal(conditions, traitCache, resultData)); }
internal bool DataIdPassesAll(ProxyConditions conditions, CachedTraitCollection traitCache, int dataId) { conditions.TryGetType(out ISemanticTagCondition[] semanticTagConditions); traitCache.TryGetType(out List <Dictionary <int, bool> > semanticTagTraits); for (var i = 0; i < semanticTagConditions.Length; i++) { var tagCondition = semanticTagConditions[i]; var tagTraitCollection = semanticTagTraits[i]; if (!tagTraitCollection.TryGetValue(dataId, out var traitValue)) { switch (tagCondition.matchRule) { case SemanticTagMatchRule.Exclude: continue; case SemanticTagMatchRule.Match: return(false); } } var rating = tagCondition.RateDataMatch(ref traitValue); switch (tagCondition.matchRule) { case SemanticTagMatchRule.Exclude: if (rating > 0f) { return(false); } break; case SemanticTagMatchRule.Match: if (rating <= 0f) { return(false); } break; } } return(DataPassesAllConditionsInternal(traitCache, dataId)); }
internal void FillQueryResult(int dataId, ProxyConditions conditions, CachedTraitCollection traits, ProxyTraitRequirements requirements, QueryMatchID matchId, QueryResult result) { result.queryMatchId = matchId; result.SetDataId(dataId); FillRequiredTraitsAction(dataId, requirements, result); FillQueryResultInternal(dataId, conditions, traits, matchId, result); conditions.TryGetType(out ICondition <Pose>[] poseConditions); traits.TryGetType(out List <Dictionary <int, Pose> > poseCollections); for (var i = 0; i < poseConditions.Length; i++) { var poseCollection = poseCollections[i]; var nonOffsetValue = poseCollection[dataId]; var poseValue = applyOffsetToPose(nonOffsetValue); var refiner = poseConditions[i] as IPoseRefiner; if (refiner != null) { poseValue = refiner.RefinePose(poseValue, true); } result.SetTrait(poseConditions[i].traitName, poseValue); } if (!conditions.TryGetType(out ISemanticTagCondition[] semanticTagConditions)) { return; } // tags can take a shortcut with query filling - they're really just a test for presence or absence, // so if that test has already been passed, we can just assign a bool representing the result foreach (var condition in semanticTagConditions) { var isExcluding = condition.matchRule == SemanticTagMatchRule.Exclude; result.SetTrait(condition.traitName, !isExcluding); } }