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


C++ AABB::GetMin方法代码示例

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


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

示例1: CHR

RESULT
DebugRenderer::Quad( const AABB& bounds, Color color, float fOpacity )
{
    RESULT rval = S_OK;

    // Draw screen-aligned 2D rectangular outline for the AABB.
    // TODO: have solid mode using a quad.
    
    WORLD_POSITION corner1;
    WORLD_POSITION corner2;
    WORLD_POSITION corner3;
    WORLD_POSITION corner4;

    corner1.x = bounds.GetMin().x;  corner1.y = bounds.GetMin().y;              corner1.z = 0.0f;
    corner2.x = bounds.GetMin().x;  corner2.y = corner1.y + bounds.GetHeight(); corner2.z = 0.0f;
    corner3.x = bounds.GetMax().x;  corner3.y = bounds.GetMax().y;              corner3.z = 0.0f;
    corner4.x = bounds.GetMax().x;  corner4.y = corner3.y - bounds.GetHeight(); corner4.z = 0.0f;

    CHR( Line(corner1, vec3(0,  1, 0),  Color::Green(), fOpacity, bounds.GetHeight(), 5.0f) );
    CHR( Line(corner2, vec3(1,  0, 0),  Color::Green(), fOpacity, bounds.GetWidth(),  5.0f) );
    CHR( Line(corner3, vec3(0, -1, 0),  Color::Green(), fOpacity, bounds.GetHeight(), 5.0f) );
    CHR( Line(corner4, vec3(-1, 0, 0),  Color::Green(), fOpacity, bounds.GetWidth(),  5.0f) );
    
//    CHR( Point( bounds.GetCenter(), Color::Black(), 1.0f ) );
    
Exit:
    return rval;
}
开发者ID:kabinud,项目名称:HappyGame,代码行数:28,代码来源:DebugRenderer.cpp

示例2: IsInside

bool AABB::IsInside(const AABB& box) const
{
	if(box.GetMin(0)>GetMin(0))	return false;
	if(box.GetMin(1)>GetMin(1))	return false;
	if(box.GetMin(2)>GetMin(2))	return false;
	if(box.GetMax(0)<GetMax(0))	return false;
	if(box.GetMax(1)<GetMax(1))	return false;
	if(box.GetMax(2)<GetMax(2))	return false;
	return true;
}
开发者ID:DougHamil,项目名称:WIT,代码行数:10,代码来源:IceAABB.cpp

示例3: Intersects

bool Intersects(const AABB& aabb, const Capsule& cap)
{
  float r = cap.m_radius;
  AABB ab(
    aabb.GetMin(0) - r, aabb.GetMax(0) + r,
    aabb.GetMin(1) - r, aabb.GetMax(1) + r,
    aabb.GetMin(2) - r, aabb.GetMax(2) + r);

  return Clip(cap.m_lineseg, ab, nullptr);
}
开发者ID:jason-amju,项目名称:amjulib,代码行数:10,代码来源:IntAABBCapsule.cpp

示例4: Intersects

       //----------------------------------------------------------------
       /// AABB vs Ray
       //----------------------------------------------------------------
       bool Intersects(const AABB& inAABB, const Ray& inRay, f32 &outfT1, f32 &outfT2)
       {
           //Using the slab intersection method we check for intersection
           //against the 3 planes (slabs). If the ray fails itersection with any
           //slab then it does not intersect the box
           f32 t2 = std::numeric_limits<f32>::infinity();
           f32 t1 = -t2;
           
           Vector3 vRayOrigin = inRay.vOrigin;
           Vector3 vRayDir = inRay.vDirection * inRay.fLength;
           
           Vector3 vAABBMin = inAABB.GetMin();
           Vector3 vAABBMax = inAABB.GetMax();
           
           //----X Slab 
           if(!RaySlabIntersect(vRayOrigin.x, vRayDir.x, vAABBMin.x, vAABBMax.x, t1, t2)) return false;
           
           //----Y Slab 
           if(!RaySlabIntersect(vRayOrigin.y, vRayDir.y, vAABBMin.y, vAABBMax.y, t1, t2)) return false;
           
           //----Z Slab 
           if(!RaySlabIntersect(vRayOrigin.z, vRayDir.z, vAABBMin.z, vAABBMax.z, t1, t2)) return false;
 
           //We haven't failed intersection against any slab therefore we must have hit
           //t1 and t2 will give us our entry and exit point on the parametric ray
           outfT1 = t1;
           outfT2 = t2;
           
           return true; 
       }
开发者ID:DNSMorgan,项目名称:ChilliSource,代码行数:33,代码来源:ShapeIntersection.cpp

示例5: GetAABB

	AABB Node::GetAABB()
	{
		AABB box;
		for (int i = 0; i < child_array_->Size(); i++)
		{
			Node * node = (Node*)child_array_->At(i);
			AABB tbox = node->GetAABB();
			vec3 v = tbox.GetMax();
			box.Add(v.x, v.y, v.z);
			v = tbox.GetMin();
			box.Add(v.x, v.y, v.z);
		}
		vec3 v = aabb_.GetMax();
		box.Add(v.x, v.y, v.z);
		v = aabb_.GetMin();
		box.Add(v.x,v.y, v.z);

		mat4 t = this->GetTransform();
		if (parents_)
		{
			t = parents_->GetTransform() * t;
		}
		box.SetToTransformedBox(t);
		return box;
	}
开发者ID:JunC74,项目名称:PYX,代码行数:25,代码来源:Node.cpp

示例6: UnCollide

void UnCollide(GameObject* go, const Vec3f& oldPos, const AABB& aabb)
{
  /* 
  Move back so not interpenetrating:
  Boxes now intersect in all axes. Moving away by penetration depth in any
  axis will resolve the intersection. To choose which axis, use the previous
  position. E.g. if previously not intersecting in X, move away in X axis.
  */

  // Intersecton region
  AABB ir = aabb.Intersection(go->GetAABB());
  Vec3f goPos = go->GetPos();

  AABB oldBox = go->GetAABB();
  Vec3f move = oldPos - goPos;
  oldBox.Translate(move);
  // Oldbox should NOT be intersecting in one or more axes

  Vec3f penDist(
    ir.GetMax(0) - ir.GetMin(0), 
    ir.GetMax(1) - ir.GetMin(1),
    ir.GetMax(2) - ir.GetMin(2));
  penDist *= 1.01f; // move away a bit more to be sure of clearing the collision

  if (oldBox.GetMax(0) < aabb.GetMin(0))
  {
    // Old box to left of box, so move away to the left
    goPos.x -= penDist.x; 
  }
  else if (oldBox.GetMin(0) > aabb.GetMax(0))
  {
    goPos.x += penDist.x;
  }
  /*
  else if (oldBox.GetMax(1) < aabb.GetMin(1))
  {
    goPos.y -= penDist.y;
  }
  else if (oldBox.GetMin(1) > aabb.GetMax(1))
  {
    goPos.y += penDist.y;
  }
  */
  else if (oldBox.GetMax(2) < aabb.GetMin(2))
  {
    goPos.z -= penDist.z;
  }
  else if (oldBox.GetMin(2) > aabb.GetMax(2))
  {
    goPos.z += penDist.z;
  }

  go->SetPos(goPos);
}
开发者ID:jason-amju,项目名称:amjulib,代码行数:54,代码来源:UnCollide.cpp

示例7: Query

_Use_decl_annotations_
void BIH::Query(const AABB& test, uint32_t nodeIndex, uint32_t* numTriangles)
{
    Node& node = _nodes[nodeIndex];
    if (node.Axis == 3)
    {
        // Leaf
        *numTriangles += node.NumTriangles;
    }
    else
    {
        if (*(&test.GetMin().x + node.Axis) < node.Max)
        {
            Query(test, nodeIndex + 1, numTriangles);
        }

        if (*(&test.GetMax().x + node.Axis) > node.Min)
        {
            Query(test, node.MaxNode, numTriangles);
        }
    }
}
开发者ID:rezanour,项目名称:randomoldstuff,代码行数:22,代码来源:bih.cpp

示例8: AppendVisibleIndices

_Use_decl_annotations_
void BIH::AppendVisibleIndices(const AABB& test, uint32_t nodeIndex, uint32_t* indices, uint32_t maxIndices, uint32_t* numIndices, uint32_t* materials, uint32_t maxMaterials, uint32_t* numMaterials)
{
    if (*numIndices + 3 > maxIndices)
    {
        // No more room
        return;
    }

    Node& node = _nodes[nodeIndex];
    if (node.Axis == 3)
    {
        // Leaf
        Triangle* t = &_triangles[node.StartTriangle];
        for (uint32_t i = 0; (i < node.NumTriangles) && (*numIndices + 3 <= maxIndices); ++i, ++t)
        {
            indices[*numIndices] = t->i0;   ++(*numIndices);
            indices[*numIndices] = t->i1;   ++(*numIndices);
            indices[*numIndices] = t->i2;   ++(*numIndices);
            materials[*numMaterials] = t->MaterialId;   ++(*numMaterials);
        }
    }
    else
    {
        // Inner node
        if (*(&test.GetMin().x + node.Axis) < node.Max)
        {
            AppendVisibleIndices(test, nodeIndex + 1, indices, maxIndices, numIndices, materials, maxMaterials, numMaterials);
        }

        if (*(&test.GetMax().x + node.Axis) > node.Min)
        {
            AppendVisibleIndices(test, node.MaxNode, indices, maxIndices, numIndices, materials, maxMaterials, numMaterials);
        }
    }
}
开发者ID:rezanour,项目名称:randomoldstuff,代码行数:36,代码来源:bih.cpp

示例9: Intersects

		bool Ray::Intersects(AABB& box)
		{
			switch (m_classification)
			{
			case RayType::MMM:
				if ((m_origin.x < box.GetMin().x) || (m_origin.y < box.GetMin().y) || (m_origin.z < box.GetMin().z)
					|| (m_jbyi * box.GetMin().x - box.GetMax().y + m_cxy > 0)
					|| (m_ibyj * box.GetMin().y - box.GetMax().x + m_cyx > 0)
					|| (m_jbyk * box.GetMin().z - box.GetMax().y + m_czy > 0)
					|| (m_kbyj * box.GetMin().y - box.GetMax().z + m_cyz > 0)
					|| (m_kbyi * box.GetMin().x - box.GetMax().z + m_cxz > 0)
					|| (m_ibyk * box.GetMin().z - box.GetMax().x + m_czx > 0))
					return false;
				return true;
			case RayType::MMP:
				if ((m_origin.x < box.GetMin().x) || (m_origin.y < box.GetMin().y) || (m_origin.z > box.GetMax().z)
					|| (m_jbyi * box.GetMin().x - box.GetMax().y + m_cxy > 0)
					|| (m_ibyj * box.GetMin().y - box.GetMax().x + m_cyx > 0)
					|| (m_jbyk * box.GetMax().z - box.GetMax().y + m_czy > 0)
					|| (m_kbyj * box.GetMin().y - box.GetMin().z + m_cyz < 0)
					|| (m_kbyi * box.GetMin().x - box.GetMin().z + m_cxz < 0)
					|| (m_ibyk * box.GetMax().z - box.GetMax().x + m_czx > 0))
					return false;
				return true;
			case RayType::MPM:
				if ((m_origin.x < box.GetMin().x) || (m_origin.y > box.GetMax().y) || (m_origin.z < box.GetMin().z)
					|| (m_jbyi * box.GetMin().x - box.GetMin().y + m_cxy < 0)
					|| (m_ibyj * box.GetMax().y - box.GetMax().x + m_cyx > 0)
					|| (m_jbyk * box.GetMin().z - box.GetMin().y + m_czy < 0)
					|| (m_kbyj * box.GetMax().y - box.GetMax().z + m_cyz > 0)
					|| (m_kbyi * box.GetMin().x - box.GetMax().z + m_cxz > 0)
					|| (m_ibyk * box.GetMin().z - box.GetMax().x + m_czx > 0))
					return false;
				return true;
			case RayType::MPP:
				if ((m_origin.x < box.GetMin().x) || (m_origin.y > box.GetMax().y) || (m_origin.z > box.GetMax().z)
					|| (m_jbyi * box.GetMin().x - box.GetMin().y + m_cxy < 0)
					|| (m_ibyj * box.GetMax().y - box.GetMax().x + m_cyx > 0)
					|| (m_jbyk * box.GetMax().z - box.GetMin().y + m_czy < 0)
					|| (m_kbyj * box.GetMax().y - box.GetMin().z + m_cyz < 0)
					|| (m_kbyi * box.GetMin().x - box.GetMin().z + m_cxz < 0)
					|| (m_ibyk * box.GetMax().z - box.GetMax().x + m_czx > 0))
					return false;
				return true;
			case RayType::PMM:
				if ((m_origin.x > box.GetMax().x) || (m_origin.y < box.GetMin().y) || (m_origin.z < box.GetMin().z)
					|| (m_jbyi * box.GetMax().x - box.GetMax().y + m_cxy > 0)
					|| (m_ibyj * box.GetMin().y - box.GetMin().x + m_cyx < 0)
					|| (m_jbyk * box.GetMin().z - box.GetMax().y + m_czy > 0)
					|| (m_kbyj * box.GetMin().y - box.GetMax().z + m_cyz > 0)
					|| (m_kbyi * box.GetMax().x - box.GetMax().z + m_cxz > 0)
					|| (m_ibyk * box.GetMin().z - box.GetMin().x + m_czx < 0))
					return false;
				return true;
			case RayType::PMP:
				if ((m_origin.x > box.GetMax().x) || (m_origin.y < box.GetMin().y) || (m_origin.z > box.GetMax().z)
					|| (m_jbyi * box.GetMax().x - box.GetMax().y + m_cxy > 0)
					|| (m_ibyj * box.GetMin().y - box.GetMin().x + m_cyx < 0)
					|| (m_jbyk * box.GetMax().z - box.GetMax().y + m_czy > 0)
					|| (m_kbyj * box.GetMin().y - box.GetMin().z + m_cyz < 0)
					|| (m_kbyi * box.GetMax().x - box.GetMin().z + m_cxz < 0)
					|| (m_ibyk * box.GetMax().z - box.GetMin().x + m_czx < 0))
					return false;
				return true;
			case RayType::PPM:
				if ((m_origin.x > box.GetMax().x) || (m_origin.y > box.GetMax().y) || (m_origin.z < box.GetMin().z)
					|| (m_jbyi * box.GetMax().x - box.GetMin().y + m_cxy < 0)
					|| (m_ibyj * box.GetMax().y - box.GetMin().x + m_cyx < 0)
					|| (m_jbyk * box.GetMin().z - box.GetMin().y + m_czy < 0)
					|| (m_kbyj * box.GetMax().y - box.GetMax().z + m_cyz > 0)
					|| (m_kbyi * box.GetMax().x - box.GetMax().z + m_cxz > 0)
					|| (m_ibyk * box.GetMin().z - box.GetMin().x + m_czx < 0))
					return false;
				return true;
			case RayType::PPP:
				if ((m_origin.x > box.GetMax().x) || (m_origin.y > box.GetMax().y) || (m_origin.z > box.GetMax().z)
					|| (m_jbyi * box.GetMax().x - box.GetMin().y + m_cxy < 0)
					|| (m_ibyj * box.GetMax().y - box.GetMin().x + m_cyx < 0)
					|| (m_jbyk * box.GetMax().z - box.GetMin().y + m_czy < 0)
					|| (m_kbyj * box.GetMax().y - box.GetMin().z + m_cyz < 0)
					|| (m_kbyi * box.GetMax().x - box.GetMin().z + m_cxz < 0)
					|| (m_ibyk * box.GetMax().z - box.GetMin().x + m_czx < 0))
					return false;
				return true;
			case RayType::OMM:
				if ((m_origin.x < box.GetMin().x) || (m_origin.x > box.GetMax().x)
					|| (m_origin.y < box.GetMin().y) || (m_origin.z < box.GetMin().z)
					|| (m_jbyk * box.GetMin().z - box.GetMax().y + m_czy > 0)
					|| (m_kbyj * box.GetMin().y - box.GetMax().z + m_cyz > 0))
					return false;
				return true;
			case RayType::OMP:
				if ((m_origin.x < box.GetMin().x) || (m_origin.x > box.GetMax().x)
					|| (m_origin.y < box.GetMin().y) || (m_origin.z > box.GetMax().z)
					|| (m_jbyk * box.GetMax().z - box.GetMax().y + m_czy > 0)
					|| (m_kbyj * box.GetMin().y - box.GetMin().z + m_cyz < 0))
					return false;
				return true;
			case RayType::OPM:
				if ((m_origin.x < box.GetMin().x) || (m_origin.x > box.GetMax().x)
//.........这里部分代码省略.........
开发者ID:fesoliveira014,项目名称:cubeproject,代码行数:101,代码来源:Ray.cpp

示例10: SetHitbox

void Object::SetHitbox(AABB hitbox)
{
	this->hitbox.Set(hitbox.GetMin(), hitbox.GetMax());
}
开发者ID:plsee,项目名称:SP2-Back-Up,代码行数:4,代码来源:Object.cpp

示例11: LoadBIN


//.........这里部分代码省略.........
			IndexedTriangle* F = IS->GetFaces();
			for(udword j=0;j<NbFaces;j++)
			{
				F[j].mRef[0] = BinFile.LoadDword();
				F[j].mRef[1] = BinFile.LoadDword();
				F[j].mRef[2] = BinFile.LoadDword();
			}

/*			if(tesselation)
			{
				for(udword j=0;j<tesselation;j++)
				{
					if(ts==TESS_BUTTERFLY)
					{
						ButterflyScheme BS;
						IS->Subdivide(BS);
					}
					else if(ts==TESS_POLYHEDRAL)
					{
						PolyhedralScheme PS;
						IS->Subdivide(PS);
					}
				}
			}*/
			if(tesselation)
				Tesselate(IS, tesselation, ts);

			if(gUseMeshCleaner)
			{
				MeshCleaner Cleaner(IS->GetNbVerts(), IS->GetVerts(), IS->GetNbFaces(), IS->GetFaces()->mRef);
				IS->Init(Cleaner.mNbTris, Cleaner.mNbVerts, Cleaner.mVerts, (const IndexedTriangle*)Cleaner.mIndices);
			}

			TotalNbTris += IS->GetNbFaces();
			TotalNbVerts += IS->GetNbVerts();

//			SaveBIN("c:\\TessBunny.bin", *IS);
		}
	}
	else
	{
		IndexedSurface* IS = test.CreateManagedSurface();

		for(udword i=0;i<NbMeshes;i++)
		{
			const udword Collidable = BinFile.LoadDword();
			const udword Renderable = BinFile.LoadDword();

			const udword NbVerts = BinFile.LoadDword();
			const udword NbFaces = BinFile.LoadDword();

			IndexedSurface LocalIS;
			bool Status = LocalIS.Init(NbFaces, NbVerts);
			ASSERT(Status);

			Point* Verts = LocalIS.GetVerts();
			for(udword j=0;j<NbVerts;j++)
			{
				Verts[j].x = BinFile.LoadFloat();
				Verts[j].y = BinFile.LoadFloat();
				Verts[j].z = BinFile.LoadFloat();
				if(scale)
					Verts[j] *= *scale;
				GlobalBounds.Extend(Verts[j]);
			}

			IndexedTriangle* F = LocalIS.GetFaces();
			for(udword j=0;j<NbFaces;j++)
			{
				F[j].mRef[0] = BinFile.LoadDword();
				F[j].mRef[1] = BinFile.LoadDword();
				F[j].mRef[2] = BinFile.LoadDword();
			}

			IS->Merge(&LocalIS);
		}

/*		if(tesselation)
		{
			for(udword j=0;j<tesselation;j++)
			{
				ButterflyScheme BS;
				IS->Subdivide(BS);
			}
		}*/
		if(tesselation)
			Tesselate(IS, tesselation, ts);

		TotalNbTris = IS->GetNbFaces();
		TotalNbVerts = IS->GetNbVerts();
	}

	test.SetGlobalBounds(GlobalBounds);

	const udword GrandTotal = sizeof(Point)*TotalNbVerts + sizeof(IndexedTriangle)*TotalNbTris;
	printf("LoadBIN: loaded %d tris and %d verts, for a total of %d Kb.\n", TotalNbTris, TotalNbVerts, GrandTotal/1024);
	printf("LoadBIN: min bounds: %f | %f | %f\n", GlobalBounds.GetMin(0), GlobalBounds.GetMin(1), GlobalBounds.GetMin(2));
	printf("LoadBIN: max bounds: %f | %f | %f\n", GlobalBounds.GetMax(0), GlobalBounds.GetMax(1), GlobalBounds.GetMax(2));
	return true;
}
开发者ID:DevO2012,项目名称:PEEL,代码行数:101,代码来源:Loader_Bin.cpp

示例12: ProcessTriangles

_Use_decl_annotations_
uint32_t BIH::ProcessTriangles(CompileTriangle** triangles, uint32_t count, const AABB& bounds)
{
    assert(*triangles != nullptr);
    assert(count > 0);

    if (count < 4)
    {
        // Make a leaf
        Node node;
        node.Axis = 3;

        node.StartTriangle = (uint32_t)_triangles.size();
        CompileTriangle* t = *triangles;
        while (t != nullptr)
        {
            CompileTriangle* next = t->Next;
            _triangles.push_back(Triangle(t));
            delete t;
            t = next;
        }
        *triangles = nullptr;

        node.NumTriangles = (uint32_t)_triangles.size() - node.StartTriangle;

        _nodes.push_back(node);
        return (uint32_t)_nodes.size() - 1;
    }
    else
    {
        // Split

        // Choose longest axis as initial candidate, but we may end up
        // trying all three if we can't find a good one
        uint8_t axis = 0;
        float xLength = bounds.GetMax().x - bounds.GetMin().x;
        float yLength = bounds.GetMax().y - bounds.GetMin().y;
        float zLength = bounds.GetMax().z - bounds.GetMin().z;
        if (yLength > xLength)
        {
            axis = 1;
            if (zLength > yLength)
            {
                axis = 2;
            }
        }
        else if (zLength > xLength)
        {
            axis = 2;
        }

        uint8_t startAxis = axis;

        CompileTriangle* t;
        uint32_t minCount;
        uint32_t maxCount;

        // Loop and test each axis. Doesn't actually modify lists yet, just counting
        for (;;)
        {
            t = *triangles;

            float totalAlongAxis = 0;
            while (t != nullptr)
            {
                totalAlongAxis += *(&t->Centroid.x + axis);
                t = t->Next;
            }

            float averageAlongAxis = totalAlongAxis / (float)count;

            t = *triangles;
            minCount = 0;
            maxCount = 0;

            while (t != nullptr)
            {
                float v = *(&t->Centroid.x + axis);
                if (v < averageAlongAxis)
                {
                    ++minCount;
                }
                else
                {
                    ++maxCount;
                }

                t = t->Next;
            }

            if (minCount == 0 || maxCount == 0)
            {
                // try the next axis if this one wasn't any good
                axis = (axis + 1) % 3;
                if (axis == startAxis)
                {
                    // bail, no good
                    break;
                }
            }
//.........这里部分代码省略.........
开发者ID:rezanour,项目名称:randomoldstuff,代码行数:101,代码来源:bih.cpp

示例13: PreventIntersection

// Move moving object away from stationary object so they do not intersect.
// Relies on knowing the old (non-intersecting) position of the moving object.
void PreventIntersection(
  GameObject* moving, const GameObject* stationary, const Vec3f& oldPos)
{
std::cout << "Moving apart: moving: " << Describe(moving) << " stnry: " << Describe(stationary) << ": ";

  /* 
  Move back so not interpenetrating:
  Boxes now intersect in all axes. Moving away by penetration depth in any
  axis will resolve the intersection. To choose which axis, use the previous
  position. E.g. if previously not intersecting in X, move away in X axis.
  */

  // Intersecton region
  AABB ir = stationary->GetAABB().Intersection(moving->GetAABB());
  Vec3f goPos = moving->GetPos();

  // Create AABB in old position
  AABB oldBox = moving->GetAABB();
  Vec3f move = oldPos - goPos;
  oldBox.Translate(move);
  // Oldbox should not be intersecting in one or more axes

  const AABB& stationaryBox = stationary->GetAABB();

  // Penetration depth in each axis
  Vec3f penDist(
    ir.GetMax(0) - ir.GetMin(0), 
    ir.GetMax(1) - ir.GetMin(1),
    ir.GetMax(2) - ir.GetMin(2));
  penDist *= 1.01f; // move away a bit more to be sure of clearing the collision

std::cout << "Pen depths: " << Describe(penDist) << ": ";

  //Vec3f vel = moving->GetVel();

  if (oldBox.GetMax(0) < stationaryBox.GetMin(0))
  {
    // Old box to left of stationary object, so move away to the left
//    Assert(penDist.x > 0);
    goPos.x -= penDist.x; 

std::cout << "x -= " << penDist.x;
  }
  else if (oldBox.GetMin(0) > stationaryBox.GetMax(0))
  {
//    Assert(penDist.x > 0);
    goPos.x += penDist.x;

std::cout << "x += " << penDist.x;
  }
  if (oldBox.GetMax(1) < stationaryBox.GetMin(1))
  {
//    Assert(penDist.y > 0);
    goPos.y -= penDist.y;
std::cout << "y -= " << penDist.y;
  }
  else if (oldBox.GetMin(1) > stationaryBox.GetMax(1))
  {
//    Assert(penDist.y > 0);
    goPos.y += penDist.y;
std::cout << "y += " << penDist.y;
  }
  if (oldBox.GetMax(2) < stationaryBox.GetMin(2))
  {
//    Assert(penDist.z > 0);
    goPos.z -= penDist.z;
std::cout << "z -= " << penDist.z;
  }
  else if (oldBox.GetMin(2) > stationaryBox.GetMax(2))
  {
//    Assert(penDist.z > 0);
    goPos.z += penDist.z;
std::cout << "z += " << penDist.z;
  }

std::cout << "\n";

  moving->SetPos(goPos);


//  moving->RecalcAABB();
  // Test that AABBs are no longer intersecting
//  if (stationary->GetAABB().Intersects(moving->GetAABB()))
//  {
//    AABB ir = stationary->GetAABB().Intersection(moving->GetAABB());
//  }
}
开发者ID:jason-amju,项目名称:amju-ww,代码行数:89,代码来源:PreventIntersection.cpp


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