internal void OnGuiInternal()
        {
            if (m_PreviewTexture == null)
            {
                return;
            }

            EditorGUILayout.LabelField(m_HeaderLabel, EditorStyles.whiteLargeLabel);

            var newDeadZone =
                Mathf.Clamp(EditorGUILayout.FloatField("dead zone", m_RatingConfig.deadZone), 0f, 0.98f);

            var newCenter = Mathf.Clamp01(EditorGUILayout.FloatField("center", m_RatingConfig.center));

            if (newDeadZone != m_PreviousDeadZone || newCenter != m_PreviousCenter)
            {
                m_RatingConfig           = new RatingConfiguration(newDeadZone, newCenter);
                m_Condition.ratingConfig = m_RatingConfig;
                DrawTexture();
            }

            var rect = EditorGUILayout.GetControlRect(false, m_TextureSize.y, GUILayout.Width(m_TextureSize.x));

            EditorGUI.DrawPreviewTexture(rect, m_PreviewTexture);

            if (rect.Contains(Event.current.mousePosition))
            {
                EditorGUIUtils.MouseLabel(GetMouseLabel());
            }

            m_PreviousDeadZone = m_RatingConfig.deadZone;
            m_PreviousCenter   = m_RatingConfig.center;
        }
        static float Rate(ElevationRelation relation, RatingConfiguration config, float elevation)
        {
            var pose = new Pose(new Vector3(0, elevation, 0), Quaternion.identity);

            relation.ratingConfig = config;
            return(relation.RateDataMatch(ref pose, ref s_IdentityPose));
        }
Ejemplo n.º 3
0
        static float Rate(DistanceRelation relation, RatingConfiguration config, float distance)
        {
            relation.ratingConfig = config;
            var pose = new Pose(PointAtDistance(distance), Quaternion.identity);

            return(relation.RateDataMatch(ref pose, ref s_IdentityPose));
        }
        [TestCase(0.2f, 1.2f, -1f)]      // diff of 2.2, totally ideal
        public void MinAndMaxBounded_NonZeroComparison_PerfectMatches(float center,
                                                                      float child1Elevation, float child2Elevation)
        {
            var config = new RatingConfiguration(0.25f, center);
            var rating = Rate(m_DoubleBoundedCondition, config, child1Elevation, child2Elevation);

            Assert.AreEqual(1f, rating);
        }
        public void MinAndMaxBounded_CenterPointNotInMiddle_RatingApproachesMinimumWhenAlmostFailing(float deadZone, float center)
        {
            var         config           = new RatingConfiguration(deadZone, center);
            const float deltaFromFailure = 0.002f;

            AssertApproachesMin(Rate(m_DoubleBoundedCondition, config, k_MinElevation + deltaFromFailure));
            AssertApproachesMin(Rate(m_DoubleBoundedCondition, config, k_MaxElevation - deltaFromFailure));
        }
Ejemplo n.º 6
0
        public void DeadZoneIsClampedInConstructor()
        {
            var config = new RatingConfiguration(1.1f);

            Assert.AreEqual(config.deadZone, RatingConfiguration.MaxDeadZone);
            config = new RatingConfiguration(-0.1f);
            Assert.AreEqual(config.deadZone, 0f);
        }
Ejemplo n.º 7
0
        public void CenterIsClampedInConstructor()
        {
            var config = new RatingConfiguration(0f, 0f);

            Assert.AreEqual(RatingConfiguration.MinimumCenter, config.center);
            config = new RatingConfiguration(0f, 1f);
            Assert.AreEqual(RatingConfiguration.MaximumCenter, config.center);
        }
        static float Rate(ElevationRelation relation, RatingConfiguration config,
                          float child1Elevation, float child2Elevation)
        {
            var pose1 = new Pose(new Vector3(0, child1Elevation, 0), Quaternion.identity);
            var pose2 = new Pose(new Vector3(0, child2Elevation, 0), Quaternion.identity);

            relation.ratingConfig = config;
            return(relation.RateDataMatch(ref pose1, ref pose2));
        }
Ejemplo n.º 9
0
        public string GetRatingTagString(BooruSiteType type, RatingConfiguration ratingConfiguration)
        {
            //ToDo maybe configure rating tag value in configuration file
            switch (ratingConfiguration.GetEnabledRatingTagCount())
            {
            case 1:
            {
                if (ratingConfiguration.Safe)
                {
                    return("rating%3Asafe");
                }
                if (ratingConfiguration.Explicit)
                {
                    if (type == BooruSiteType.SafeBooru)
                    {
                        return(String.Empty);
                    }
                    if (type == BooruSiteType.Gelbooru)
                    {
                        return("rating%3Aexplicit");
                    }
                    return("rating%3Ae");
                }
                return("rating%3Aquestionable");
            }

            case 2:
            {
                if (!ratingConfiguration.Safe)
                {
                    return("-rating%3Asafe");
                }
                if (!ratingConfiguration.Explicit)
                {
                    return("-rating%3Ae");
                }
                return("-rating%3Aquestionable");
            }

            default: return(String.Empty);
            }
        }
Ejemplo n.º 10
0
        [TestCase(0.5f, 0.5f, 2.749f)]      // almost at edge of top of dead zone
        public void MinAndMaxBounded_CenterPointInMiddle_PerfectMatches(float deadZone, float center, float distance)
        {
            var config = new RatingConfiguration(deadZone, center);

            Assert.AreEqual(1f, Rate(m_DoubleBoundedCondition, config, distance));
        }