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


C++ AABB3::IsPointInside方法代码示例

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


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

示例1: AddContactPoint

static void AddContactPoint( TCFixedVector< CJL_CollPointInfo, MAX_CONTACTS_PER_BOX_PAIR >& vecCollPointInfo,
 							 Vector3& rvNormal,
							 Scalar fPenetrationDepth,
							 CJL_Shape_Box& rBox0,
							 CJL_Shape_Box& rBox1,
							 CJL_CollisionFunctor& rColFunctor )
/*
static void AddContactPoint( Vector3& rvNormal, Scalar fPenetrationDepth,
												CJL_Shape_Box& rBox0,
												CJL_Shape_Box& rBox1,
												CJL_CollisionFunctor& rColFunctor )*/
{
	CJL_ContactInfo contact;

	contact.pBody0 = &rBox0;
	contact.pBody1 = &rBox1;

	// same normal and penetration depths are applied to contact points
	contact.vNormal = rvNormal;
	contact.fPenetrationDepth = fPenetrationDepth;

	///// check box edges against box
	float fFraction = 1.0f;
	Vector3 vEnd = Vector3(0,0,0);

	BSPTreeForBox bsp_tree;

	// transform edges to the local space of the box
	bool b0, b1;
	Vector3 vWorldStart, vWorldGoal, vLocalStart, vLocalGoal;
	Vector3 vHalfLength;
	Matrix34 actor_world_pose;
	Matrix34 box_local_pose;
	AABB3 aabb;
	int i, j;
	CJL_Shape_Box *pBox[2];
	pBox[0] = &rBox0;
	pBox[1] = &rBox1;

	TCFixedVector< Vector3, MAX_CONTACTS_PER_BOX_PAIR > vecPts;

	for( i=0; i<2; i++ )
	{
		// check the edges of box[(i+1)%2] against box[i] (swap boxes and do this for each other)

		vHalfLength = pBox[i]->GetSideLength() * 0.5f;
///		bsptree.SetAABB( vHalfLength );
		aabb.vMin = -vHalfLength;
		aabb.vMax =  vHalfLength;

		Vector3 vSideLength = pBox[i]->GetSideLength();
		bsp_tree.SetSize( vSideLength.x, vSideLength.y, vSideLength.z );


		for( j=0; j<12; j+=2 )
		{
			pBox[(i+1)%2]->GetWorldEdge( j, vWorldStart, vWorldGoal );

			// transform from world space to 'pBox[i]' space
			pBox[i]->GetWorldPose().InvTransform( vLocalStart, vWorldStart );
			pBox[i]->GetWorldPose().InvTransform( vLocalGoal,  vWorldGoal );

			b0 = aabb.IsPointInside( vLocalStart );
			b1 = aabb.IsPointInside( vLocalGoal );

			if( b0 && b1 )
				continue;	// the entire line segment is inside the box[i]

			if( !b0 )
			{
				fFraction = 1.0f;
				bsp_tree.ClipTrace( vEnd, fFraction, vLocalStart, vLocalGoal, 0 );
				if( fFraction < 1.0f )
				{
					// found collision
					if( fFraction < SCALAR_TINY )
					{
						fFraction = 0;
						vEnd = vLocalStart;
					}
					else if( 1 - SCALAR_TINY < fFraction )
					{
						fFraction = 1.0f;
						vEnd = vLocalGoal;
					}
					// transform contact point from the local space of pBox[i] to the world space
					pBox[i]->GetWorldPose().Transform( contact.vContactPoint, vEnd );
					
					// transform contact normal (orientation only)
//					contact.vNormal = pBox[i]->GetWorldOrient() * tr.plane.normal;
//					contact.fPenetrationDepth = fPenetrationDepth;

					if( vecPts.size() < MAX_CONTACTS_PER_BOX_PAIR )
						vecPts.push_back( contact.vContactPoint );
				}
			}
			if( !b1 )
			{
				fFraction = 1.0f;
				bsp_tree.ClipTrace( vEnd, fFraction, vLocalGoal, vLocalStart, 0 );
//.........这里部分代码省略.........
开发者ID:HermanHGF,项目名称:amorphous,代码行数:101,代码来源:JL_CollisionDetect_Box_Box.cpp


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