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


C# BoundingBox.Intersects方法代码示例

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


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

示例1: TestBBoxIntersection

		public void TestBBoxIntersection()
		{
			BoundingBox targetBox = new BoundingBox(0, 0, 0, 20, 20, 20);
			BoundingBox intersectBox = new BoundingBox(-10, -10, -10, 10, 10, 10);
			BoundingBox containBox = new BoundingBox(0, 0, 0, 20, 20, 20);
			BoundingBox disjointBox = new BoundingBox(-30, -30, -30, -10, -10, -10);
			BoundingSphere intersectSphere = new BoundingSphere(new Vector3(0, 0, 0), 15);
			BoundingSphere containSphere = new BoundingSphere(new Vector3(10, 10, 10), 3);
			BoundingSphere disjointSphere = new BoundingSphere(new Vector3(-30, -30, -30), 5);
			BoundingBox intersectBoxExpected = intersectBox;
			BoundingBox containBoxExpected = containBox;
			BoundingBox disjointBoxExpected = disjointBox;
			BoundingSphere intersectSphereExpected = intersectSphere;
			BoundingSphere containSphereExpected = containSphere;
			BoundingSphere disjointSphereExpected = disjointSphere;

			IntersectionType intersectBoxTypeExpected = IntersectionType.Intersects;
			IntersectionType intersectBoxTypeActual;
			intersectBoxTypeActual = targetBox.Intersects(ref intersectBox);

			IntersectionType containBoxTypeExpected = IntersectionType.Contained;
			IntersectionType containBoxTypeActual;
			containBoxTypeActual = targetBox.Intersects(ref containBox);

			IntersectionType disjointBoxTypeExpected = IntersectionType.NoIntersection;
			IntersectionType disjointBoxTypeActual;
			disjointBoxTypeActual = targetBox.Intersects(ref disjointBox);

			IntersectionType intersectSphereTypeExpected = IntersectionType.Intersects;
			IntersectionType intersectSphereTypeActual;
			intersectSphereTypeActual = targetBox.Intersects(ref intersectSphere);

			IntersectionType containSphereTypeExpected = IntersectionType.Contained;
			IntersectionType containSphereTypeActual;
			containSphereTypeActual = targetBox.Intersects(ref containSphere);

			IntersectionType disjointSphereTypeExpected = IntersectionType.NoIntersection;
			IntersectionType disjointSphereTypeActual;
			disjointSphereTypeActual = targetBox.Intersects(ref disjointSphere);

			Assert.AreEqual(intersectBoxExpected, intersectBox);
			Assert.AreEqual(intersectBoxTypeExpected, intersectBoxTypeActual);
			Assert.AreEqual(containBoxExpected, containBox);
			Assert.AreEqual(containBoxTypeExpected, containBoxTypeActual);
			Assert.AreEqual(disjointBoxExpected, disjointBox);
			Assert.AreEqual(disjointBoxTypeExpected, disjointBoxTypeActual);
			Assert.AreEqual(intersectSphereExpected, intersectSphere);
			Assert.AreEqual(intersectSphereTypeExpected, intersectSphereTypeActual);
			Assert.AreEqual(containSphereExpected, containSphere);
			Assert.AreEqual(containSphereTypeExpected, containSphereTypeActual);
			Assert.AreEqual(disjointSphereExpected, disjointSphere);
			Assert.AreEqual(disjointSphereTypeExpected, disjointSphereTypeActual);
		}
开发者ID:pallmall,项目名称:WCell,代码行数:53,代码来源:GraphicsTest.cs

示例2: IntersectsAABB

		/// <summary>
		/// Tests the WorldAABB of an entity for intersection with a capsule
		/// </summary>
		/// <param name="cap">Capsule to test for intersection</param>
		/// <param name="entity">WorldAABB will be tested against capsule</param>
		/// <param name="distance">Distance at which path intersects AABB</param>
		/// <returns>true if there is an intersection (including boundary)</returns>
		public static bool IntersectsAABB(this Capsule cap, IMyEntity entity, out float distance)
		{
			BoundingBox AABB = (BoundingBox)entity.WorldAABB;
			Vector3 Radius = new Vector3(cap.Radius, cap.Radius, cap.Radius);
			AABB = new BoundingBox(AABB.Min - Radius, AABB.Max + Radius);
			//myLogger.debugLog("Testing AABB: " + AABB.Min + ", " + AABB.Max + " against line: " + cap.P0 + ", " + cap.P1, "IntersectsAABB()");
			return (AABB.Intersects(cap.get_Line(), out distance));
		}
开发者ID:deimosx6,项目名称:Autopilot,代码行数:15,代码来源:CapsuleExtensions.cs

示例3: GetIntersectingNodes

 // Methods
 public bool GetIntersectingNodes(ref BoundingBox bbox, ref List<OCTreeNode> nodes)
 {
     if (bbox.Intersects(Bounds))
     {
         if (Indices != null)
         {
             nodes.Add(this);
         }
         if (Children != null)
         {
             for (var i = 0; i < Children.Length; i++)
             {
                 Children[i].GetIntersectingNodes(ref bbox, ref nodes);
             }
         }
     }
     return (nodes.Count > 0);
 }
开发者ID:KroneckerX,项目名称:WCell,代码行数:19,代码来源:OCTreeNode.cs

示例4: TestIntersect

 public void TestIntersect()
 {
     //Test disjoint
     BoundingBox b1 = new BoundingBox(0, 0, 10, 10);
     BoundingBox b2 = new BoundingBox(20, 20, 30, 30);
     Assert.IsFalse(b1.Intersects(b2), "Bounding box intersect test 1a failed");
     Assert.IsFalse(b2.Intersects(b1), "Bounding box intersect test 1a failed");
     b1 = new BoundingBox(0, 0, 10, 10);
     b2 = new BoundingBox(0, 20, 10, 30);
     Assert.IsFalse(b1.Intersects(b2), "Bounding box intersect test 1b failed");
     Assert.IsFalse(b2.Intersects(b1), "Bounding box intersect test 1b failed");
     b1 = new BoundingBox(0, 0, 10, 10);
     b2 = new BoundingBox(20, 0, 30, 10);
     Assert.IsFalse(b1.Intersects(b2), "Bounding box intersect test 1c failed");
     Assert.IsFalse(b2.Intersects(b1), "Bounding box intersect test 1c failed");
     //Test intersects
     b1 = new BoundingBox(0, 0, 10, 10);
     b2 = new BoundingBox(5, 5, 15, 15);
     Assert.IsTrue(b1.Intersects(b2), "Bounding box intersect test 2 failed");
     Assert.IsTrue(b2.Intersects(b1), "Bounding box intersect test 2 failed");
     //Test overlaps
     b1 = new BoundingBox(0, 0, 10, 10);
     b2 = new BoundingBox(-5, -5, 15, 15);
     Assert.IsTrue(b1.Intersects(b2), "Bounding box intersect test 3 failed");
     Assert.IsTrue(b2.Intersects(b1), "Bounding box intersect test 3 failed");
     //Test touches
     b1 = new BoundingBox(0, 0, 10, 10);
     b2 = new BoundingBox(10, 0, 20, 10);
     Assert.IsTrue(b1.Intersects(b2), "Bounding box intersect test 4a failed");
     Assert.IsTrue(b2.Intersects(b1), "Bounding box intersect test 4a failed");
     //Test touches 2
     b1 = new BoundingBox(0, 0, 10, 10);
     b2 = new BoundingBox(10, 10, 20, 20);
     Assert.IsTrue(b1.Intersects(b2), "Bounding box intersect test 4b failed");
     Assert.IsTrue(b2.Intersects(b1), "Bounding box intersect test 4b failed");
     //Test equal
     b1 = new BoundingBox(0, 0, 10, 10);
     b2 = new BoundingBox(0, 0, 10, 10);
     Assert.IsTrue(b1.Intersects(b2), "Bounding box intersect test 5 failed");
     Assert.IsTrue(b2.Intersects(b1), "Bounding box intersect test 5 failed");
 }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:41,代码来源:BoundingBoxTests.cs

示例5: TouchesAny

        /// <summary> Determines whether any of the blocks that intersect the
        /// given bounding box satisfy the given condition. </summary>
        public bool TouchesAny( BoundingBox bounds, Predicate<byte> condition )
        {
            Vector3I bbMin = Vector3I.Floor( bounds.Min );
            Vector3I bbMax = Vector3I.Floor( bounds.Max );

            // Order loops so that we minimise cache misses
            for( int y = bbMin.Y; y <= bbMax.Y; y++ )
                for( int z = bbMin.Z; z <= bbMax.Z; z++ )
                    for( int x = bbMin.X; x <= bbMax.X; x++ )
            {
                if( !game.World.IsValidPos( x, y, z ) ) continue;
                byte block = game.World.GetBlock( x, y, z );
                Vector3 min = new Vector3( x, y, z ) + info.MinBB[block];
                Vector3 max = new Vector3( x, y, z ) + info.MaxBB[block];

                BoundingBox blockBB = new BoundingBox( min, max );
                if( !blockBB.Intersects( bounds ) ) continue;
                if( condition( block ) ) return true;
            }
            return false;
        }
开发者ID:Chameleonherman,项目名称:ClassicalSharp,代码行数:23,代码来源:Entity.Bounds.cs

示例6: GetTrianglesIntersectingSphere

        public void GetTrianglesIntersectingSphere(ref BoundingSphereD sphere, Vector3? referenceNormalVector, float? maxAngle, List<MyTriangle_Vertex_Normals> retTriangles, int maxNeighbourTriangles)
        {
            var aabb = BoundingBox.CreateInvalid();
            BoundingSphere sphereF = (BoundingSphere)sphere;
            aabb.Include(ref sphereF);
            AABB gi_aabb = new AABB(aabb.Min.ToBullet(), aabb.Max.ToBullet());
            m_overlappedTriangles.Clear();
            if (m_bvh.BoxQuery(ref gi_aabb, m_overlappedTriangles))
            {
                // temporary variable for storing tirngle boundingbox info
                BoundingBox triangleBoundingBox = new BoundingBox();

                for (int i = 0; i < m_overlappedTriangles.Count; i++)
                {
                    var triangleIndex = m_overlappedTriangles[i];

                    //  If we reached end of the buffer of neighbour triangles, we stop adding new ones. This is better behavior than throwing exception because of array overflow.
                    if (retTriangles.Count == maxNeighbourTriangles) return;

                    m_model.GetTriangleBoundingBox(triangleIndex, ref triangleBoundingBox);

                    //  First test intersection of triangleVertexes's bounding box with bounding sphere. And only if they overlap or intersect, do further intersection tests.
                    if (triangleBoundingBox.Intersects(ref sphere))
                    {
                        //if (m_triangleIndices[value] != ignoreTriangleWithIndex)
                        {
                            //  See that we swaped vertex indices!!
                            MyTriangle_Vertices triangle;
                            MyTriangle_Normals triangleNormals;
                            //MyTriangle_Normals triangleTangents;

                            MyTriangleVertexIndices triangleIndices = m_model.Triangles[triangleIndex];
                            m_model.GetVertex(triangleIndices.I0, triangleIndices.I2, triangleIndices.I1, out triangle.Vertex0, out triangle.Vertex1, out triangle.Vertex2);

                            /*
                            triangle.Vertex0 = m_model.GetVertex(triangleIndices.I0);
                            triangle.Vertex1 = m_model.GetVertex(triangleIndices.I2);
                            triangle.Vertex2 = m_model.GetVertex(triangleIndices.I1);
                              */

                            triangleNormals.Normal0 = m_model.GetVertexNormal(triangleIndices.I0);
                            triangleNormals.Normal1 = m_model.GetVertexNormal(triangleIndices.I2);
                            triangleNormals.Normal2 = m_model.GetVertexNormal(triangleIndices.I1);

                            PlaneD trianglePlane = new PlaneD(triangle.Vertex0, triangle.Vertex1, triangle.Vertex2);

                            if (MyUtils.GetSphereTriangleIntersection(ref sphere, ref trianglePlane, ref triangle) != null)
                            {
                                Vector3 triangleNormal = MyUtils.GetNormalVectorFromTriangle(ref triangle);

                                if ((referenceNormalVector.HasValue == false) || (maxAngle.HasValue == false) ||
                                    ((MyUtils.GetAngleBetweenVectors(referenceNormalVector.Value, triangleNormal) <= maxAngle)))
                                {
                                    MyTriangle_Vertex_Normals retTriangle;
                                    retTriangle.Vertices = triangle;
                                    retTriangle.Normals = triangleNormals;

                                    retTriangles.Add(retTriangle);
                                }
                            }
                        }
                    }
                }
            }
        }
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:65,代码来源:MyQuantizedBvhAdapter.cs

示例7: IntersectTreeRecursive

        /// <summary>
        /// Recursive function that traverses the tree and looks for intersections with a boundingbox
        /// </summary>
        /// <param name="box">Boundingbox to intersect with</param>
        /// <param name="node">Node to search from</param>
        /// <param name="list">List of found intersections</param>
        private void IntersectTreeRecursive(BoundingBox box, QuadTree node, ref Collection<uint> list)
        {
            if (node.IsLeaf) //Leaf has been reached
            {
                foreach (BoxObjects boxObject in node._objList)
                {
                    if(box.Intersects(boxObject.box))
                        list.Add(boxObject.ID);

                }
                /*
                for (int i = 0; i < node._objList.Count; i++)
                {
                    list.Add(node._objList[i].ID);
                }
                */
            }
            else
            {
                if (node.Box.Intersects(box))
                {
                    IntersectTreeRecursive(box, node.Child0, ref list);
                    IntersectTreeRecursive(box, node.Child1, ref list);
                }
            }
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:32,代码来源:SpatialIndexing.cs

示例8: CheckNeighborMountPointsForCompound

		public static bool CheckNeighborMountPointsForCompound(
			Vector3 currentMin, Vector3 currentMax, MyCubeBlockDefinition.MountPoint thisMountPoint, ref Vector3I thisMountPointTransformedNormal, MyCubeBlockDefinition thisDefinition,
			Vector3I neighborPosition, MyCubeBlockDefinition neighborDefinition, MyCubeBlockDefinition.MountPoint[] neighborMountPoints, MyBlockOrientation neighborOrientation,
			List<MyCubeBlockDefinition.MountPoint> otherMountPoints)
        {
			if (!thisMountPoint.Enabled)
				return false;

            var currentBox = new BoundingBox(currentMin - neighborPosition, currentMax - neighborPosition);

			TransformMountPoints(otherMountPoints, neighborDefinition, neighborMountPoints, ref neighborOrientation);

            foreach (var otherMountPoint in otherMountPoints)
            {
                // Skip mount points which exclude themselves (are not allowed to touch).
                if ((((thisMountPoint.ExclusionMask & otherMountPoint.PropertiesMask) != 0 ||
                      (thisMountPoint.PropertiesMask & otherMountPoint.ExclusionMask) != 0) &&
					thisDefinition.Id != neighborDefinition.Id) || !otherMountPoint.Enabled)
                    continue;

                // Check normals on compound side with the same direction (we are in the same block)
                if (MyFakes.ENABLE_TEST_BLOCK_CONNECTIVITY_CHECK && (thisMountPointTransformedNormal - otherMountPoint.Normal != Vector3I.Zero))
                    continue;

                var otherBox = new BoundingBox(Vector3.Min(otherMountPoint.Start, otherMountPoint.End), Vector3.Max(otherMountPoint.Start, otherMountPoint.End));
                if (currentBox.Intersects(otherBox))
                    return true;
            }

            return false;
        }
开发者ID:ales-vilchytski,项目名称:SpaceEngineers,代码行数:31,代码来源:MyCubeGrid.Static.cs

示例9: CheckMinionCollision

        /// <summary>
        /// Checks minion collisions
        /// </summary>
        /// <param name="from">Start position</param>
        /// <param name="to">End position</param>
        /// <param name="width">Rectangle scale</param>
        /// <param name="delay">Spell delay</param>
        /// <param name="missileSpeed">Spell missile speed</param>
        /// <param name="isArc">Checks collision for arc spell</param>
        /// <returns>true if collision found</returns>
        public static bool CheckMinionCollision(Vector2 from, Vector2 to, float width, float delay, float missileSpeed = 0, bool isArc = false)
        {
            var spellBBox = new BoundingBox(from.To3D(), to.To3D());
            if (isArc)
            {
                var spellHitBox = ClipperWrapper.MakePaths(new SPrediction.Geometry.Polygon(
                                ClipperWrapper.DefineArc(from - new Vector2(875 / 2f, 20), to, (float)Math.PI * (to.Distance(from) / 875f), 410, 200 * (to.Distance(from) / 875f)),
                                ClipperWrapper.DefineArc(from - new Vector2(875 / 2f, 20), to, (float)Math.PI * (to.Distance(from) / 875f), 410, 320 * (to.Distance(from) / 875f))));

                return MinionManager.GetMinions(from.Distance(to) + 100, MinionTypes.All, MinionTeam.NotAlly, MinionOrderTypes.None).AsParallel().Any(p => ClipperWrapper.IsIntersects(ClipperWrapper.MakePaths(ClipperWrapper.DefineCircle(Prediction.GetFastUnitPosition(p, delay, missileSpeed), p.BoundingRadius)), spellHitBox));
            }

            return MinionManager.GetMinions(from.Distance(to) + 100, MinionTypes.All, MinionTeam.NotAlly, MinionOrderTypes.None).AsParallel().Any(p => spellBBox.Intersects(new BoundingSphere(Prediction.GetFastUnitPosition(p, delay, missileSpeed).To3D(), p.BoundingRadius)));
        }
开发者ID:Ryzeros,项目名称:L-,代码行数:24,代码来源:Collision.cs

示例10: GetIntersectionWithSphere

 public override bool GetIntersectionWithSphere(ref BoundingSphere sphere)
 {
     if (Type == MyDummyPointType.Box)
     {
         BoundingBox boundingBox = new BoundingBox(WorldMatrix.Translation - Size, WorldMatrix.Translation + Size);
         return boundingBox.Intersects(sphere);
     }
     else if (Type == MyDummyPointType.Sphere)
     {
         BoundingSphere boundingSphere = new BoundingSphere(WorldMatrix.Translation, Radius);
         return boundingSphere.Intersects(sphere);
     }
     
     return false;
 }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:15,代码来源:MyDummyPoint.cs

示例11: LowestModifier

        float LowestModifier( BoundingBox bounds, bool checkSolid )
        {
            Vector3I bbMin = Vector3I.Floor( bounds.Min );
            Vector3I bbMax = Vector3I.Floor( bounds.Max );
            float modifier = inf;

            for( int y = bbMin.Y; y <= bbMax.Y; y++ )
                for( int z = bbMin.Z; z <= bbMax.Z; z++ )
                    for( int x = bbMin.X; x <= bbMax.X; x++ )
            {
                byte block = game.World.SafeGetBlock( x, y, z );
                if( block == 0 ) continue;
                CollideType type = info.Collide[block];
                if( type == CollideType.Solid && !checkSolid )
                    continue;

                Vector3 min = new Vector3( x, y, z ) + info.MinBB[block];
                Vector3 max = new Vector3( x, y, z ) + info.MaxBB[block];
                BoundingBox blockBB = new BoundingBox( min, max );
                if( !blockBB.Intersects( bounds ) ) continue;

                modifier = Math.Min( modifier, info.SpeedMultiplier[block] );
                if( block >= BlockInfo.CpeBlocksCount && type == CollideType.SwimThrough )
                    useLiquidGravity = true;
            }
            return modifier;
        }
开发者ID:Chameleonherman,项目名称:ClassicalSharp,代码行数:27,代码来源:PhysicsComponent.cs

示例12: GetIntersectionWithSphere

        public override bool GetIntersectionWithSphere(ref BoundingSphere sphere)
        {
            if (EntityDetectorType == MyEntityDetectorType.Box)
            {
                BoundingBox boundingBox = new BoundingBox(WorldMatrix.Translation - m_extent, WorldMatrix.Translation + m_extent);
                return boundingBox.Intersects(sphere);
            }
            else if (EntityDetectorType == MyEntityDetectorType.Sphere)
            {
                BoundingSphere boundingSphere = new BoundingSphere(WorldMatrix.Translation, m_radius);
                return boundingSphere.Intersects(sphere);
            }

            return false;
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:15,代码来源:MyEntityDetector.cs

示例13: FindReachableBlocks

        void FindReachableBlocks( ref int count, out BoundingBox entityBB, 
            out BoundingBox entityExtentBB)
        {
            Vector3 vel = entity.Velocity;
            entityBB = entity.CollisionBounds;

            // Exact maximum extent the entity can reach, and the equivalent map coordinates.
            entityExtentBB = new BoundingBox(
                vel.X < 0 ? entityBB.Min.X + vel.X : entityBB.Min.X,
                vel.Y < 0 ? entityBB.Min.Y + vel.Y : entityBB.Min.Y,
                vel.Z < 0 ? entityBB.Min.Z + vel.Z : entityBB.Min.Z,
                vel.X > 0 ? entityBB.Max.X + vel.X : entityBB.Max.X,
                vel.Y > 0 ? entityBB.Max.Y + vel.Y : entityBB.Max.Y,
                vel.Z > 0 ? entityBB.Max.Z + vel.Z : entityBB.Max.Z
            );
            Vector3I min = Vector3I.Floor( entityExtentBB.Min );
            Vector3I max = Vector3I.Floor( entityExtentBB.Max );

            int elements = (max.X + 1 - min.X) * (max.Y + 1 - min.Y) * (max.Z + 1 - min.Z);
            if( elements > stateCache.Length ) {
                stateCache = new State[elements];
            }

            BoundingBox blockBB = default( BoundingBox );
            // Order loops so that we minimise cache misses
            for( int y = min.Y; y <= max.Y; y++ )
                for( int z = min.Z; z <= max.Z; z++ )
                    for( int x = min.X; x <= max.X; x++ )
            {
                byte blockId = GetPhysicsBlockId( x, y, z );
                if( !GetBoundingBox( blockId, x, y, z, ref blockBB ) ) continue;
                if( !entityExtentBB.Intersects( blockBB ) ) continue; // necessary for non whole blocks. (slabs)

                float tx = 0, ty = 0, tz = 0;
                CalcTime( ref vel, ref entityBB, ref blockBB, out tx, out ty, out tz );
                if( tx > 1 || ty > 1 || tz > 1 ) continue;
                float tSquared = tx * tx + ty * ty + tz * tz;
                stateCache[count++] = new State( x, y, z, blockId, tSquared );
            }
        }
开发者ID:Chameleonherman,项目名称:ClassicalSharp,代码行数:40,代码来源:CollisionsComponent.cs

示例14: CollideWithReachableBlocks

        void CollideWithReachableBlocks( int count, ref Vector3 size,
            ref BoundingBox entityBB, ref BoundingBox entityExtentBB)
        {
            bool wasOn = entity.onGround;
            entity.onGround = false;
            if( count > 0 )
                QuickSort( stateCache, 0, count - 1 );
            hitXMin = false; hitYMin = false; hitZMin = false;
            hitXMax = false; hitYMax = false; hitZMax = false;
            BoundingBox blockBB = default(BoundingBox);

            for( int i = 0; i < count; i++ ) {
                State state = stateCache[i];
                Vector3 blockPos = new Vector3( state.X >> 3, state.Y >> 3, state.Z >> 3 );
                int block = (state.X & 0x7) | (state.Y & 0x7) << 3 | (state.Z & 0x7) << 6;
                blockBB.Min = blockPos + info.MinBB[block];
                blockBB.Max = blockPos + info.MaxBB[block];
                if( !entityExtentBB.Intersects( blockBB ) ) continue;

                float tx = 0, ty = 0, tz = 0;
                CalcTime( ref entity.Velocity, ref entityBB, ref blockBB, out tx, out ty, out tz );
                if( tx > 1 || ty > 1 || tz > 1 )
                    Utils.LogDebug( "t > 1 in physics calculation.. this shouldn't have happened." );
                BoundingBox finalBB = entityBB.Offset( entity.Velocity * new Vector3( tx, ty, tz ) );

                // if we have hit the bottom of a block, we need to change the axis we test first.
                if( !hitYMin ) {
                    if( finalBB.Min.Y + Adjustment >= blockBB.Max.Y )
                        ClipYMax( ref blockBB, ref entityBB, ref entityExtentBB, ref size );
                    else if( finalBB.Max.Y - Adjustment <= blockBB.Min.Y )
                        ClipYMin( ref blockBB, ref entityBB, ref entityExtentBB, ref size );
                    else if( finalBB.Min.X + Adjustment >= blockBB.Max.X )
                        ClipXMax( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
                    else if( finalBB.Max.X - Adjustment <= blockBB.Min.X )
                        ClipXMin( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
                    else if( finalBB.Min.Z + Adjustment >= blockBB.Max.Z )
                        ClipZMax( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
                    else if( finalBB.Max.Z - Adjustment <= blockBB.Min.Z )
                        ClipZMin( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
                    continue;
                }

                // if flying or falling, test the horizontal axes first.
                if( finalBB.Min.X + Adjustment >= blockBB.Max.X )
                    ClipXMax( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
                else if( finalBB.Max.X - Adjustment <= blockBB.Min.X )
                    ClipXMin( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
                else if( finalBB.Min.Z + Adjustment >= blockBB.Max.Z )
                    ClipZMax( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
                else if( finalBB.Max.Z - Adjustment <= blockBB.Min.Z )
                    ClipZMin( ref blockBB, ref entityBB, wasOn, finalBB, ref entityExtentBB, ref size );
                else if( finalBB.Min.Y + Adjustment >= blockBB.Max.Y )
                    ClipYMax( ref blockBB, ref entityBB, ref entityExtentBB, ref size );
                else if( finalBB.Max.Y - Adjustment <= blockBB.Min.Y )
                    ClipYMin( ref blockBB, ref entityBB, ref entityExtentBB, ref size );
            }
        }
开发者ID:Chameleonherman,项目名称:ClassicalSharp,代码行数:57,代码来源:CollisionsComponent.cs

示例15: CanSlideThrough

        bool CanSlideThrough( ref BoundingBox adjFinalBB )
        {
            Vector3I bbMin = Vector3I.Floor( adjFinalBB.Min );
            Vector3I bbMax = Vector3I.Floor( adjFinalBB.Max );

            for( int y = bbMin.Y; y <= bbMax.Y; y++ )
                for( int z = bbMin.Z; z <= bbMax.Z; z++ )
                    for( int x = bbMin.X; x <= bbMax.X; x++ )
            {
                byte block = GetPhysicsBlockId( x, y, z );
                Vector3 min = new Vector3( x, y, z ) + info.MinBB[block];
                Vector3 max = new Vector3( x, y, z ) + info.MaxBB[block];

                BoundingBox blockBB = new BoundingBox( min, max );
                if( !blockBB.Intersects( adjFinalBB ) )
                    continue;
                if( info.Collide[GetPhysicsBlockId( x, y, z )] == CollideType.Solid )
                    return false;
            }
            return true;
        }
开发者ID:Chameleonherman,项目名称:ClassicalSharp,代码行数:21,代码来源:CollisionsComponent.cs


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