int32 b2BroadPhase::CreateProxy(const b2AABB& aabb, void* userData)
{
	int32 proxyId = m_tree.CreateProxy(aabb, userData);
	++m_proxyCount;
	BufferMove(proxyId);
	return proxyId;
}
示例#2
0
void b2BroadPhase::MoveProxy(int32 proxyId, const b2AABB& aabb,
		const b2Vec2& displacement) {
	bool buffer = m_tree.MoveProxy(proxyId, aabb, displacement);
	if (buffer) {
		BufferMove(proxyId);
	}
}
示例#3
0
u32 b3BroadPhase::CreateProxy(const b3AABB3& aabb, void* userData) 
{
	// Later, if the node aabb has changed then it should be reinserted into the tree.
	// However, this can be expansive due to the hierarchy reconstruction.
	// Therefore, the original AABB is extended and inserted into the tree,
	// so we can check later if the new (original) AABB is inside the old (fat) AABB.
	b3AABB3 fatAABB = aabb;
	fatAABB.Extend(B3_AABB_EXTENSION);	
	u32 proxyId = m_tree.InsertNode(fatAABB, userData);
	BufferMove(proxyId);
	return proxyId;
}
示例#4
0
bool b3BroadPhase::MoveProxy(u32 proxyId, const b3AABB3& aabb, const b3Vec3& displacement)
{
	if (m_tree.GetAABB(proxyId).Contains(aabb))
	{
		// Do nothing if the new AABB is contained in the old AABB.
		return false;
	}

	// Update the tree with a fat and motion predicted AABB.
	const b3Vec3 kExtension(B3_AABB_EXTENSION, B3_AABB_EXTENSION, B3_AABB_EXTENSION);

	// Extend the new (original) AABB.
	b3AABB3 fatAABB;
	fatAABB.m_lower = aabb.m_lower - kExtension;
	fatAABB.m_upper = aabb.m_upper + kExtension;

	if (displacement.x < 0.0f)
	{
		fatAABB.m_lower.x += B3_AABB_MULTIPLIER * displacement.x;
	}
	else
	{
		fatAABB.m_upper.x += B3_AABB_MULTIPLIER * displacement.x;
	}

	if (displacement.y < 0.0f)
	{
		fatAABB.m_lower.y += B3_AABB_MULTIPLIER * displacement.y;
	}
	else
	{
		fatAABB.m_upper.y += B3_AABB_MULTIPLIER * displacement.y;
	}

	if (displacement.z < 0.0f)
	{
		fatAABB.m_lower.z += B3_AABB_MULTIPLIER * displacement.z;
	}
	else
	{
		fatAABB.m_upper.z += B3_AABB_MULTIPLIER * displacement.z;
	}

	// Update proxy with the extented AABB.
	m_tree.UpdateNode(proxyId, fatAABB);
	
	// Buffer the moved proxy.
	BufferMove(proxyId);
	
	// Notify the proxy has moved.
	return true;
}
void b2BroadPhase::TouchProxy(int32 proxyId)
{
	BufferMove(proxyId);
}
示例#6
0
void b3BroadPhase::UpdateProxy(i32 proxyId, const b3AABB& aabb) {
	if (m_dynamicAabbTree.UpdateNode(proxyId, aabb)) {
		// If the proxy AABB changed significantly then the proxy has moved.
		BufferMove(proxyId);
	}
}