示例#1
0
/*
 * MoveWindowToFront - bring a window forward
 */
void MoveWindowToFront( window_id wn )
{
    if( !TestOverlap( wn ) ) {
        return;
    }
    MoveWindowToFrontDammit( wn, TRUE );

} /* MoveWindowToFront */
void MyContactSolver::solvePositionConstrain(MyContact* contact)
{
    for (int i = 0; i < m_positionIter; i ++)
    {
        if (TestOverlap(contact))
        {
            contact->getBodyA()->update();
            contact->getBodyB()->update();
        }
    }
}
示例#3
0
void TestToken::TestAll()
{
  cout << "- test Text" << endl;
  TestText();
  cout << "- test Time" << endl;
  TestTime();
  cout << "- test Overlap" << endl;
  TestOverlap();
  cout << "- test Equals" << endl;
  TestEquals();
  cout << "- test IsEquivalentTo" << endl;
  TestIsEquivalentTo();
  //cout << "- test PrecNextGraph" << endl;
  //TestPrecNextGraph();     
}
示例#4
0
/*-------------------------------------------------------
	nClass번째 클래스에 속하는 박스에 대해 overlap 테스트해서 축소하는 함수

	pBox(입력) : 박스
	nClass(입력) : 클래스 번호(0부터 시작), pBox가 속한 클래스
-------------------------------------------------------*/
void CFMMNN::TestBox(MINMAX* pBox, int nClass)
{
	register MINMAX* p1 = pBox;

	for(register int i = 0; i < m_nClass; i ++)
	{
		if(i == nClass)
			continue;

		for(register int j = 0; j < m_nBox[i]; j ++)
		{
			register MINMAX* p2 = &m_pBox[i][j];
			register int nDir, nCase;
			if(TestOverlap(p1, p2, nDir, nCase))
				Contract(p1, p2, nDir, nCase);
		}
	}
}
示例#5
0
// sorting a min edge downwards can only ever *add* overlaps
void AxisSweep3::SortMinDown(int axis, unsigned short edge, bool updateOverlaps)
{
	Edge* pEdge = m_pEdges[axis] + edge;
	Edge* pPrev = pEdge - 1;
	Handle* pHandleEdge = GetHandle(pEdge->m_handle);

	while (pEdge->m_pos < pPrev->m_pos)
	{
		Handle* pHandlePrev = GetHandle(pPrev->m_handle);

		if (pPrev->IsMax())
		{
			// if previous edge is a maximum check the bounds and add an overlap if necessary
			if (updateOverlaps && TestOverlap(axis,pHandleEdge, pHandlePrev))
			{
				AddOverlappingPair(pHandleEdge,pHandlePrev);

				//AddOverlap(pEdge->m_handle, pPrev->m_handle);

			}

			// update edge reference in other handle
			pHandlePrev->m_maxEdges[axis]++;
		}
		else
			pHandlePrev->m_minEdges[axis]++;

		pHandleEdge->m_minEdges[axis]--;

		// swap the edges
		Edge swap = *pEdge;
		*pEdge = *pPrev;
		*pPrev = swap;

		// decrement
		pEdge--;
		pPrev--;
	}
}
示例#6
0
// sorting a max edge upwards can only ever *add* overlaps
void AxisSweep3::SortMaxUp(int axis, unsigned short edge, bool updateOverlaps)
{
	Edge* pEdge = m_pEdges[axis] + edge;
	Edge* pNext = pEdge + 1;
	Handle* pHandleEdge = GetHandle(pEdge->m_handle);

	while (pEdge->m_pos > pNext->m_pos)
	{
		Handle* pHandleNext = GetHandle(pNext->m_handle);

		if (!pNext->IsMax())
		{
			// if next edge is a minimum check the bounds and add an overlap if necessary
			if (updateOverlaps && TestOverlap(axis, pHandleEdge, pHandleNext))
			{
				Handle* handle0 = GetHandle(pEdge->m_handle);
				Handle* handle1 = GetHandle(pNext->m_handle);
				AddOverlappingPair(handle0,handle1);
			}

			// update edge reference in other handle
			pHandleNext->m_minEdges[axis]--;
		}
		else
			pHandleNext->m_maxEdges[axis]--;

		pHandleEdge->m_maxEdges[axis]++;

		// swap the edges
		Edge swap = *pEdge;
		*pEdge = *pNext;
		*pNext = swap;

		// increment
		pEdge++;
		pNext++;
	}
}
示例#7
0
// Update the contact manifold and touching status.
// Note: do not assume the fixture AABBs are overlapping or are valid.
void Contact::Update(ContactListener* listener)
{
    Manifold oldManifold = m_manifold;

    // Re-enable this contact.
    m_flags |= e_enabledFlag;

    bool touching = false;
    bool wasTouching = (m_flags & e_touchingFlag) == e_touchingFlag;

    bool sensorA = m_fixtureA->IsSensor();
    bool sensorB = m_fixtureB->IsSensor();
    bool sensor = sensorA || sensorB;

    Body* bodyA = m_fixtureA->GetBody();
    Body* bodyB = m_fixtureB->GetBody();
    const Transform& xfA = bodyA->GetTransform();
    const Transform& xfB = bodyB->GetTransform();

    // Is this contact a sensor?
    if (sensor)
    {
        const Shape* shapeA = m_fixtureA->GetShape();
        const Shape* shapeB = m_fixtureB->GetShape();
        touching = TestOverlap(shapeA, m_indexA, shapeB, m_indexB, xfA, xfB);

        // Sensors don't generate manifolds.
        m_manifold.pointCount = 0;
    }
    else
    {
        Evaluate(&m_manifold, xfA, xfB);
        touching = m_manifold.pointCount > 0;

        // Match old contact ids to new contact ids and copy the
        // stored impulses to warm start the solver.
        for (int32 i = 0; i < m_manifold.pointCount; ++i)
        {
            ManifoldPoint* mp2 = m_manifold.points + i;
            mp2->normalImpulse = 0.0f;
            mp2->tangentImpulse = 0.0f;
            ContactID id2 = mp2->id;

            for (int32 j = 0; j < oldManifold.pointCount; ++j)
            {
                ManifoldPoint* mp1 = oldManifold.points + j;

                if (mp1->id.key == id2.key)
                {
                    mp2->normalImpulse = mp1->normalImpulse;
                    mp2->tangentImpulse = mp1->tangentImpulse;
                    break;
                }
            }
        }

        if (touching != wasTouching)
        {
            bodyA->SetAwake(true);
            bodyB->SetAwake(true);
        }
    }

    if (touching)
    {
        m_flags |= e_touchingFlag;
    }
    else
    {
        m_flags &= ~e_touchingFlag;
    }

    if (wasTouching == false && touching == true && listener)
    {
        listener->BeginContact(this);
    }

    if (wasTouching == true && touching == false && listener)
    {
        listener->EndContact(this);
    }

    if (sensor == false && touching && listener)
    {
        listener->PreSolve(this, &oldManifold);
    }
}