コード例 #1
0
ファイル: Polygon2.cpp プロジェクト: Britefury/gsculpt
bool Polygon2::containsAllOf(const Polygon2 &polygon) const
{
	// If any vertex of @polygon is outside the boundary of @this, then
	// @polygon is not wholly inside @this
	for (int polyI = 0; polyI < polygon.size(); polyI++)
	{
		if ( !contains( polygon[polyI] ) )
		{
			return false;
		}
	}

	// If any edge of @polygon intersects @this, then
	// @polygon is not wholly contained within @this
	int edgeIPrev = polygon.size() - 1;
	for (int edgeI = 0; edgeI < polygon.size(); edgeI++)
	{
		Segment2 edge( polygon[edgeIPrev], polygon[edgeI] );

		if ( checkEdgeIntersection( edge ) )
		{
			return false;
		}

		edgeIPrev = edgeI;
	}

	return true;
}
コード例 #2
0
ファイル: Polygon2.cpp プロジェクト: Britefury/gsculpt
bool Polygon2::containsAllOf(const Segment2 &seg) const
{
	//if the end points of @seg are contained within @this
	if ( contains( seg.a )  &&  contains( seg.b ) )
	{
		//if none of the edges of @this intersect @seg
		if ( !checkEdgeIntersection( seg ) )
		{
			//@seg is wholly contained by @this
			return true;
		}
	}

	return false;
}
コード例 #3
0
ファイル: Polygon2.cpp プロジェクト: Britefury/gsculpt
bool Polygon2::containsPartOf(const Segment2 &seg) const
{
	//if either end point of @seg is contained by @this, then @segs is partially
	//inside @this
	if ( contains( seg.a )  ||  contains( seg.b ) )
	{
		return true;
	}

	//if @seg intersects any of the edges of @this, then @seg is partially
	//inside @this
	if ( checkEdgeIntersection( seg ) )
	{
		return true;
	}

	return false;
}
コード例 #4
0
ファイル: Polygon2.cpp プロジェクト: Britefury/gsculpt
bool Polygon2::containsPartOf(const Polygon2 &polygon) const
{
	// If any vertex of @polygon is inside the boundary of @this, then
	// @polygon is partially inside @this
	for (int polyI = 0; polyI < polygon.size(); polyI++)
	{
		if ( contains( polygon[polyI] ) )
		{
			return true;
		}
	}

	// If any vertex of @this is inside the boundary of @polygon, then
	// @polygon is partially inside @this
	for (int vertexI = 0; vertexI < vertices.size(); vertexI++)
	{
		if ( polygon.contains( vertices[vertexI] ) )
		{
			return true;
		}
	}

	// If any edge of @polygon intersects @this, then
	// @polygon is partially inside @this
	int edgeIPrev = polygon.size() - 1;
	for (int edgeI = 0; edgeI < polygon.size(); edgeI++)
	{
		Segment2 edge( polygon[edgeIPrev], polygon[edgeI] );

		if ( checkEdgeIntersection( edge ) )
		{
			return true;
		}

		edgeIPrev = edgeI;
	}

	// No intersection at all
	return false;
}
コード例 #5
0
ファイル: BoxContact.cpp プロジェクト: mrzzzrm/Deliberation2
bool CollideBox3D::execute()
{
    /**
     * Determine intersectionIndex
     */
    if (checkFaceNormalDepth(m_a.box, m_b.box, 0))
    {
        return false;
    }

    if (checkFaceNormalDepth(m_b.box, m_a.box, 3))
    {
        return false;
    }

    {
        uint index = 6;
        for (uint a0 = 0; a0 < 3; a0++)
        {
            for (uint a1 = 0; a1 < 3; a1++)
            {
                if (checkEdgeDepth(m_a.box.axis(a0), m_b.box.axis(a1), index))
                {
                    return false;
                }
                index++;
            }
        }
    }

    /**
     *
     */
    m_a.inverseOrientation = glm::transpose(m_a.box.orientationMatrix());
    m_b.inverseOrientation = glm::transpose(m_b.box.orientationMatrix());

    /**
     *
     */
    if (m_intersectionIndex < 6)
    {
        if (m_intersectionIndex < 3)
        {
            m_refCenterToInCenter = m_b.box.p() - m_a.box.p();
            checkFaceIntersection(m_a, m_b, m_a.box.axis(m_intersectionIndex), false);
        }
        else
        {
            m_refCenterToInCenter = m_a.box.p() - m_b.box.p();
            checkFaceIntersection(m_b, m_a, m_b.box.axis(m_intersectionIndex - 3), true);
        }
    }
    else
    {
        m_refCenterToInCenter = m_b.box.p() - m_a.box.p();

        auto edgeIntersectionIndex = m_intersectionIndex - 6;
        auto e0 = edgeIntersectionIndex / 3;
        auto e1 = edgeIntersectionIndex % 3;

        checkEdgeIntersection(e0, e1);
    }

    return true;
}