コード例 #1
0
        // Token: 0x06000034 RID: 52 RVA: 0x0000291C File Offset: 0x00000B1C
        public ICollection <int> BoxQuery(AxisAlignedBox3 box)
        {
            List <int> list = new List <int>();
            QuantizedAxisAlignedBox3 quantizedAabb = this.Quantize(box);
            int i = 0;

            while (i < this.quantizedAabbTreeNodes.Length)
            {
                bool flag  = this.TestQuantizedBoxOverlap(i, quantizedAabb);
                bool flag2 = this.IsDataNode(i);
                if (flag2 && flag)
                {
                    list.Add(this.GetNodeDataValue(i));
                    i++;
                }
                else if (flag2 || flag)
                {
                    i++;
                }
                else
                {
                    i += this.GetBranchNodeWidth(i);
                }
            }
            return(list);
        }
コード例 #2
0
        /// <summary>
        ///		Intersection test with an <see cref="AxisAlignedBox2"/>.
        /// </summary>
        /// <remarks>
        ///		May return false positives but will never miss an intersection.
        /// </remarks>
        /// <param name="box">Box to test.</param>
        /// <returns>True if interesecting, false otherwise.</returns>
        public bool Intersects(AxisAlignedBox3 box)
        {
            if (box.IsNull)
            {
                return(false);
            }

            if (box.IsInfinite)
            {
                return(true);
            }

            // Get centre of the box
            Vector3 center = box.Center;
            // Get the half-size of the box
            Vector3 halfSize = box.HalfSize;

            // If all points are on outside of any plane, we fail
            Vector3[] points = box.Corners;

            for (int i = 0; i < planes.Count; i++)
            {
                Plane plane = (Plane)planes[i];

                PlaneSide side = plane.GetSide(center, halfSize);
                if (side == outside)
                {
                    // Found a splitting plane therefore return not intersecting
                    return(false);
                }
            }

            // couldn't find a splitting plane, assume intersecting
            return(true);
        }
コード例 #3
0
ファイル: Segment3.cs プロジェクト: minskowl/MY
        /// <summary>Determines where the range clips an axis aligned box</summary>
        /// <param name="box">Box that will be checked for intersection</param>
        /// <returns>The times at which the range enters or leaves the volume</returns>
        public LineContacts FindContacts(AxisAlignedBox3 box)
        {
            throw new NotImplementedException();

            /*
             * return filterContacts(
             * Collisions.Line3Aabb3Collider.FindContacts(
             *  this.Start - box.Center, this.End - this.Start, box.Dimensions / 2.0f
             * )
             * );
             */
        }
コード例 #4
0
        // Token: 0x06000030 RID: 48 RVA: 0x000027E0 File Offset: 0x000009E0
        internal bool CollidePlanes(ICollection <Plane3> clippingPlanes)
        {
            AxisAlignedBox3 axisAlignedBox = new AxisAlignedBox3(this.Center - this.Extent, this.Center + this.Extent);

            using (IEnumerator <Plane3> enumerator = clippingPlanes.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    if (enumerator.Current.SideClassification(axisAlignedBox) == PlaneSideClassification.Front)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
コード例 #5
0
ファイル: Sphere.cs プロジェクト: xposure/zSprite_Old
 /// <summary>
 ///		Returns whether or not this sphere interects a box.
 /// </summary>
 /// <param name="box"></param>
 /// <returns>True if the box intersects, false otherwise.</returns>
 public bool Intersects(AxisAlignedBox3 box)
 {
     return(Utility.Intersects(this, box));
 }
コード例 #6
0
ファイル: Segment3.cs プロジェクト: minskowl/MY
        /// <summary>Determines where the range clips an axis aligned box</summary>
        /// <param name="box">Box that will be checked for intersection</param>
        /// <returns>The times at which the range enters or leaves the volume</returns>
        /// <remarks>
        ///   Taken from the article "Simple Intersection Tests for Games" on
        ///   Gamasutra by Gomez et al.
        /// </remarks>
        public bool Intersects(AxisAlignedBox3 box)
        {
            Vector3 lineDirection  = (End - Start);
            float   lineHalfLength = lineDirection.Length();

            lineDirection  /= lineHalfLength;
            lineHalfLength /= 2.0f;

            // ALGORITHM: Use the separating axis theorem to see if the line segment and
            //            the box overlap. A line segment is a degenerate OBB.

            Vector3 distance = box.Center - (Start + End) / 2.0f;
            float   r;

            // Do any of the principal axes form a separating axis?
            Vector3 scaledDimensions = new Vector3(
                box.Dimensions.X * lineHalfLength * Math.Abs(lineDirection.X),
                box.Dimensions.Y * lineHalfLength * Math.Abs(lineDirection.Y),
                box.Dimensions.Z * lineHalfLength * Math.Abs(lineDirection.Z)
                );

            if (Math.Abs(distance.X) > scaledDimensions.X)
            {
                return(false);
            }

            if (Math.Abs(distance.Y) > scaledDimensions.Y)
            {
                return(false);
            }

            if (Math.Abs(distance.Z) > scaledDimensions.Z)
            {
                return(false);
            }

            // NOTE: Since the separating axis is perpendicular to the line in these
            //       last four cases, the line does not contribute to the projection.

            //l.cross(x-axis)?

            r =
                box.Dimensions.Y * Math.Abs(lineDirection.Z) +
                box.Dimensions.Z * Math.Abs(lineDirection.Y);

            if (Math.Abs(distance.Y * lineDirection.Z - distance.Z * lineDirection.Y) > r)
            {
                return(false);
            }

            //l.cross(y-axis)?

            r =
                box.Dimensions.X * Math.Abs(lineDirection.Z) +
                box.Dimensions.Z * Math.Abs(lineDirection.X);

            if (Math.Abs(distance.Z * lineDirection.X - distance.X * lineDirection.Z) > r)
            {
                return(false);
            }

            //l.cross(z-axis)?

            r =
                box.Dimensions.X * Math.Abs(lineDirection.Y) +
                box.Dimensions.Y * Math.Abs(lineDirection.X);

            if (Math.Abs(distance.X * lineDirection.Y - distance.Y * lineDirection.X) > r)
            {
                return(false);
            }

            return(true);
        }
コード例 #7
0
 /// <summary>
 ///    Tests whether this ray intersects the given box.
 /// </summary>
 /// <param name="box"></param>
 /// <returns>
 ///		Struct containing info on whether there was a hit, and the distance from the
 ///		origin of this ray where the intersect happened.
 ///	</returns>
 public IntersectResult Intersects(AxisAlignedBox3 box)
 {
     return(Utility.Intersects(this, box));
 }
コード例 #8
0
ファイル: Ray3.cs プロジェクト: minskowl/MY
 /// <summary>Determines where the range clips an axis aligned box</summary>
 /// <param name="box">Box that will be checked for intersection</param>
 /// <returns>The times at which the range enters or leaves the volume</returns>
 public LineContacts FindContacts(AxisAlignedBox3 box)
 {
     return(Collisions.Ray3Aabb3Collider.FindContacts(
                Origin - box.Center, Direction, box.Extents
                ));
 }
コード例 #9
0
 /// <summary>Determines where the range clips an axis aligned box</summary>
 /// <param name="box">Box that will be checked for intersection</param>
 /// <returns>The times at which the range enters or leaves the volume</returns>
 public LineContacts FindContacts(AxisAlignedBox3 box)
 {
     return(Collisions.Line3Aabb3Collider.FindContacts(
                Offset - box.Center, Direction, box.Dimensions / 2.0f
                ));
 }
コード例 #10
0
        public object Deserialize(JsonValue _jv)
        {
            if (_jv.Type == JsonTypes.Null)
            {
                return(null);
            }

            var ja   = (JsonArray)_jv;
            var data = new AxisAlignedBox3[ja.Count];

            for (var i = 0; i < data.Length; i++)
            {
                var jv = ja[i];
                if (jv.Type == JsonTypes.Object)
                {
                    var jo  = (JsonObject)jv;
                    var min = jo["min"];
                    var max = jo["max"];

                    if (min.Type == JsonTypes.Object && max.Type == JsonTypes.Object)
                    {
                        var jmin = (JsonObject)min;
                        var jmax = (JsonObject)max;

                        var vmin = new Vector3();
                        var vmax = new Vector3();

                        var jminx = jmin["x"];
                        var jminy = jmin["y"];
                        var jminz = jmin["z"];
                        if (jminx.Type == JsonTypes.Number)
                        {
                            vmin.X = (float)jminx;
                        }

                        if (jminy.Type == JsonTypes.Number)
                        {
                            vmin.Y = (float)jminy;
                        }

                        if (jminz.Type == JsonTypes.Number)
                        {
                            vmin.Z = (float)jminz;
                        }

                        var jmaxx = jmax["x"];
                        var jmaxy = jmax["y"];
                        var jmaxz = jmax["z"];
                        if (jmaxx.Type == JsonTypes.Number)
                        {
                            vmax.X = (float)jmaxx;
                        }

                        if (jmaxy.Type == JsonTypes.Number)
                        {
                            vmax.Y = (float)jmaxy;
                        }

                        if (jmaxz.Type == JsonTypes.Number)
                        {
                            vmax.Z = (float)jmaxz;
                        }

                        data[i].SetExtents(vmin, vmax);
                    }
                }
            }
            return(data);
        }