Example #1
0
        public override bool Equals(object obj)
        {
            var query = obj as Query;

            if (query == null)
            {
                return(false);
            }

            if (Constraint1 != null && Constraint2 != null)
            {
                return(Constraint1.Equals(query.Constraint1) &&
                       Constraint2.Equals(query.Constraint2));
            }

            if (Constraint1 == null)
            {
                return(Constraint2.Equals(query.Constraint2));
            }
            if (Constraint2 == null)
            {
                return(Constraint1.Equals(query.Constraint1));
            }

            throw new Exception("Cannot reach here");
        }
        public IConstraint2 Create(
            Ir r,
            Is s,
            It t,
            Iψ ψ,
            IB B)
        {
            IConstraint2 constraint = null;

            try
            {
                constraint = new Constraint2(
                    r,
                    s,
                    t,
                    ψ,
                    B);
            }
            catch (Exception exception)
            {
                this.Log.Error(
                    exception.Message,
                    exception);
            }

            return(constraint);
        }
Example #3
0
    void SatisfyConstraints()
    {
        const int numIterations = 1;

        for (int i = 0; i < numIterations; i++)
        {
            for (int k = 0; k < m_numConstraints; k++)
            {
                // Constraint 1 (Floor)
                for (int v = 0; v < m_numPoints; v++)
                {
                    if (m_points[v].curPos.y < 0.0f)
                    {
                        m_points[v].curPos.y = 0.0f;
                    }
                }

                // Constraint 2 (Links)
                Constraint2 c     = m_constraints[k];
                Vector3     p0    = m_points[c.index0].curPos;
                Vector3     p1    = m_points[c.index1].curPos;
                Vector3     delta = p1 - p0;
                float       len   = delta.magnitude;
//				float diff = (len - c->restLength) / len;
                float diff = (len - c.restLength) / len;
                p0 += delta * softness * diff;
                p1 -= delta * softness * diff;


                if (p0.y > -110)
                {
                    m_points[c.index0].curPos = p0;
                    m_points[c.index1].curPos = p1;
                }

                if (m_points[c.index0].unmovable)
                {
                    m_points[c.index0].curPos = m_points[c.index0].oldPos;
                }
                if (m_points[c.index1].unmovable)
                {
                    m_points[c.index1].curPos = m_points[c.index1].oldPos;
                }
            }
        }
    }
Example #4
0
        public override int GetHashCode()
        {
            if (Constraint1 != null && Constraint2 != null)
            {
                return(Constraint1.GetHashCode() ^ Constraint2.GetHashCode());
            }

            if (Constraint1 == null)
            {
                return(Constraint2.GetHashCode());
            }
            if (Constraint2 == null)
            {
                return(Constraint1.GetHashCode());
            }

            throw new Exception("Cannot reach here");
        }
        public IConstraint2 Create(
            Iw w,
            IBEDS BEDS,
            ITPy y)
        {
            IConstraint2 constraint = null;

            try
            {
                constraint = new Constraint2(
                    w,
                    BEDS,
                    y);
            }
            catch (Exception exception)
            {
                this.Log.Error(
                    exception.Message,
                    exception);
            }

            return(constraint);
        }