当前位置: 首页>>代码示例>>C++>>正文


C++ Contact::Update方法代码示例

本文整理汇总了C++中Contact::Update方法的典型用法代码示例。如果您正苦于以下问题:C++ Contact::Update方法的具体用法?C++ Contact::Update怎么用?C++ Contact::Update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Contact的用法示例。


在下文中一共展示了Contact::Update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AddContact

void Arbiter::AddContact(const Vector& p1, const Vector& p2, const Vector& normal)
{
	Vector point = 0.5f * (p1 + p2);

	Contact* contact = NULL;
	ContactList::iterator it = contacts.begin();
	ContactList::iterator endIt = contacts.end();
	while (it != endIt)
	{
		if ( ((*it)->point - point).Len3Squared() < 1.0f )
		{
			contact = *it;
			break;
		}
		it++;
	}

	if ( contact == NULL )
	{
		contact = new Contact(b1, b2, p1, p2, normal);
		contacts.push_back(contact);
	}
	else
	{
		contact->point = point;
		contact->Update(p1, p2, normal);
	}
}
开发者ID:DanielNeander,项目名称:my-3d-engine,代码行数:28,代码来源:Arbiter.cpp

示例2: Collide

// This is the top level collision call for the time step. Here
// all the narrow phase collision is processed for the world
// contact list.
void ContactManager::Collide()
{
	// Update awake contacts.
	Contact* c = m_contactList;
	while (c)
	{
		Fixture* fixtureA = c->GetFixtureA();
		Fixture* fixtureB = c->GetFixtureB();
		s32 indexA = c->GetChildIndexA();
		s32 indexB = c->GetChildIndexB();
		Body* bodyA = fixtureA->GetBody();
		Body* bodyB = fixtureB->GetBody();

		// Is this contact flagged for filtering?
		if (c->m_flags & Contact::filterFlag)
		{
			// Should these bodies collide?
			if (bodyB->ShouldCollide(bodyA) == false)
			{
				Contact* cNuke = c;
				c = cNuke->GetNext();
				Destroy(cNuke);
				continue;
			}

			// Check user filtering.
			if (m_contactFilter && m_contactFilter->ShouldCollide(fixtureA, fixtureB) == false)
			{
				Contact* cNuke = c;
				c = cNuke->GetNext();
				Destroy(cNuke);
				continue;
			}

			// Clear the filtering flag.
			c->m_flags &= ~Contact::filterFlag;
		}

		bool activeA = bodyA->IsAwake() && bodyA->m_type != staticBody;
		bool activeB = bodyB->IsAwake() && bodyB->m_type != staticBody;

		// At least one body must be awake and it must be dynamic or kinematic.
		if (activeA == false && activeB == false)
		{
			c = c->GetNext();
			continue;
		}

		s32 proxyIdA = fixtureA->m_proxies[indexA].proxyId;
		s32 proxyIdB = fixtureB->m_proxies[indexB].proxyId;
		bool overlap = m_broadPhase.TestOverlap(proxyIdA, proxyIdB);

		// Here we destroy contacts that cease to overlap in the broad-phase.
		if (overlap == false)
		{
			Contact* cNuke = c;
			c = cNuke->GetNext();
			Destroy(cNuke);
			continue;
		}

		// The contact persists.
		c->Update(m_contactListener);
		c = c->GetNext();
	}
}
开发者ID:BreakEngine,项目名称:Break-0.1,代码行数:69,代码来源:ContactManager.cpp


注:本文中的Contact::Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。