コード例 #1
0
ファイル: b2Body.cpp プロジェクト: abaradulkin/dava.framework
void b2Body::SetType(b2BodyType type)
{
	if (m_type == type)
	{
		return;
	}

	m_type = type;

	ResetMassData();

	if (m_type == b2_staticBody)
	{
		m_linearVelocity.SetZero();
		m_angularVelocity = 0.0f;
		m_sweep.a0 = m_sweep.a;
		m_sweep.c0 = m_sweep.c;
		SynchronizeFixtures();
	}

	SetAwake(true);

	m_force.SetZero();
	m_torque = 0.0f;

	// Since the body type changed, we need to flag contacts for filtering.
	for (b2Fixture* f = m_fixtureList; f; f = f->m_next)
	{
		f->Refilter();
	}
}
コード例 #2
0
ファイル: b2Body.cpp プロジェクト: leosurwiki/protectcarrot
void b2Body::SetType(b2BodyType type)
{
    b2Assert(m_world->IsLocked() == false);
    if (m_world->IsLocked() == true)
    {
        return;
    }

    if (m_type == type)
    {
        return;
    }

    m_type = type;

    ResetMassData();

    if (m_type == b2_staticBody)
    {
        m_linearVelocity.SetZero();
        m_angularVelocity = 0.0f;
        m_sweep.a0 = m_sweep.a;
        m_sweep.c0 = m_sweep.c;
        SynchronizeFixtures();
    }

    SetAwake(true);

    m_force.SetZero();
    m_torque = 0.0f;

    // Delete the attached contacts.
    b2ContactEdge* ce = m_contactList;
    while (ce)
    {
        b2ContactEdge* ce0 = ce;
        ce = ce->next;
        m_world->m_contactManager.Destroy(ce0->contact);
    }
    m_contactList = NULL;

    // Touch the proxies so that new contacts will be created (when appropriate)
    b2BroadPhase* broadPhase = &m_world->m_contactManager.m_broadPhase;
    for (b2Fixture* f = m_fixtureList; f; f = f->m_next)
    {
        int32 proxyCount = f->m_proxyCount;
        for (int32 i = 0; i < proxyCount; ++i)
        {
            broadPhase->TouchProxy(f->m_proxies[i].proxyId);
        }
    }
}