コード例 #1
0
void	btBoxBoxDetector::getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* /*debugDraw*/,bool /*swapResults*/)
{
	
	const btTransform& transformA = input.m_transformA;
	const btTransform& transformB = input.m_transformB;
	
	int skip = 0;
	dContactGeom *contact = 0;

	dMatrix3 R1;
	dMatrix3 R2;

	for (int j=0;j<3;j++)
	{
		R1[0+4*j] = transformA.getBasis()[j].x();
		R2[0+4*j] = transformB.getBasis()[j].x();

		R1[1+4*j] = transformA.getBasis()[j].y();
		R2[1+4*j] = transformB.getBasis()[j].y();


		R1[2+4*j] = transformA.getBasis()[j].z();
		R2[2+4*j] = transformB.getBasis()[j].z();

	}

	

	btVector3 normal;
	btScalar depth;
	int return_code;
	int maxc = 4;


	dBoxBox2 (transformA.getOrigin(), 
	R1,
	2.f*m_box1->getHalfExtentsWithMargin(),
	transformB.getOrigin(),
	R2, 
	2.f*m_box2->getHalfExtentsWithMargin(),
	normal, &depth, &return_code,
	maxc, contact, skip,
	output
	);

}
コード例 #2
0
ファイル: BoxToBox.cpp プロジェクト: lcs2/carpg
bool OrientedBoxToOrientedBox(const Obbox& obox1, const Obbox& obox2, Vec3* _contact)
{
	int skip = 0;
	dContactGeom *contact = 0;

	dMatrix3 R1;
	dMatrix3 R2;

	for(int j = 0; j < 3; j++)
	{
		R1[0 + 4 * j] = obox1.rot(j, 0);
		R2[0 + 4 * j] = obox2.rot(j, 0);

		R1[1 + 4 * j] = obox1.rot(j, 1);
		R2[1 + 4 * j] = obox2.rot(j, 1);

		R1[2 + 4 * j] = obox1.rot(j, 2);
		R2[2 + 4 * j] = obox2.rot(j, 2);
	}

	Vec3 normal;
	float depth;
	int return_code;
	int maxc = 4;
	Result output;

	dBoxBox2(
		obox1.pos, R1, obox1.size,
		obox2.pos, R2, obox2.size,
		normal, &depth, &return_code,
		maxc, contact, skip,
		output
	);

	if(output.HasContact())
	{
		if(_contact)
			*_contact = output.GetContact();
		return true;
	}

	return false;
}
コード例 #3
0
ファイル: collision.c プロジェクト: mewbak/vu
// boxBoxClosestPoints wraps dBoxBox2 so that it can be called from the vu engine.
void boxBoxClosestPoints(BoxBoxInput *in, BoxBoxResults *out)
{
	dBoxBox2(in->orgA, in->rotA, in->lenA, in->orgB, in->rotB, in->lenB, out);
}