public void Intersects(ref BoundingSphere sphere, out PlaneIntersectionType result) { float num = (float)(sphere.Center.X * (double)Normal.X + sphere.Center.Y * (double)Normal.Y + sphere.Center.Z * (double)Normal.Z) + D; if (num > (double)sphere.Radius) { result = PlaneIntersectionType.Front; } else if (num < -(double)sphere.Radius) { result = PlaneIntersectionType.Back; } else { result = PlaneIntersectionType.Intersecting; } }
/// <summary> /// Returns the raw number of triangles actually checked for collision /// (all triangles in all nodes that are reached) /// </summary> /// <param name="b"></param> /// <param name="result"></param> public void checkedFaces(BoundingSphere b, LinkedList <Face> result) { LinkedList <BspNode> toProcess = new LinkedList <BspNode>(); toProcess.AddLast(mRoot); while (toProcess.Count > 0) { BspNode curNode = toProcess.First.Value; toProcess.RemoveFirst(); if (curNode.separatingPlane.Normal.X == 0.0f && curNode.separatingPlane.Normal.Y == 0.0f && curNode.separatingPlane.Normal.Z == 0.0f && curNode.separatingPlane.D == 0.0f) { foreach (Face f in curNode.faces) { result.AddLast(f); } } else { PlaneIntersectionType side = curNode.separatingPlane.Intersects(b); if (side == PlaneIntersectionType.Back) { toProcess.AddLast(curNode.neg); } else if (side == PlaneIntersectionType.Front) { toProcess.AddLast(curNode.pos); } else { toProcess.AddLast(curNode.pos); toProcess.AddLast(curNode.neg); } } } }
public void Intersects(ref BoundingSphere sphere, out PlaneIntersectionType result) { var sphereCenter = sphere.Center; var NdotC = sphereCenter.X * Normal.X + sphereCenter.Y * Normal.Y + sphereCenter.Z * Normal.Z; var distance = NdotC + Distance; if (distance > sphere.Radius) { result = PlaneIntersectionType.Front; return; } if (distance < -sphere.Radius) { result = PlaneIntersectionType.Back; return; } result = PlaneIntersectionType.Intersecting; }
public void Intersects(ref Plane plane, out PlaneIntersectionType result) { var distance = default(float); // TODO: we might want to inline this for performance reasons Vector3.Dot(ref plane.Normal, ref this.Center, out distance); distance += plane.D; if (distance > this.Radius) { result = PlaneIntersectionType.Front; } else if (distance < -this.Radius) { result = PlaneIntersectionType.Back; } else { result = PlaneIntersectionType.Intersecting; } }
public void Intersects(ref Plane plane, out PlaneIntersectionType result) { float result1 = 0.0f; Vector3.Dot(ref plane.Normal, ref this.Center, out result1); float num = result1 + plane.D; if ((double)num > (double)this.Radius) { result = PlaneIntersectionType.Front; } else if ((double)num < -(double)this.Radius) { result = PlaneIntersectionType.Back; } else { result = PlaneIntersectionType.Intersecting; } }
void ChangePlane() { TetMesh mesh = GlobalData.Instance.TetMesh; foreach (var tet in mesh.Tetras) { PlaneIntersectionType intersect = TetMeshUtil.Intersect(this.plane, tet); if (intersect == PlaneIntersectionType.Front || (intersecting && intersect == PlaneIntersectionType.Intersecting)) { tet.Flag = 1; } else { tet.Flag = 0; } } mesh.ComputeSelectedNormal(); GlobalData.Instance.OnChanged(EventArgs.Empty); }
/// <summary> /// Computes all triangles colliding with the given bounding sphere /// </summary> /// <param name="b">Bounding sphere to be checked for collision</param> /// <param name="collidingFaces">Colliding faces are added to this list (may contain duplicates!)</param> /// <param name="collisionPoints">For each colliding face, the exact collision points is added to this list</param> public void collisions(BoundingSphere b, LinkedList <Face> collidingFaces, LinkedList <Vector3> collisionPoints) { LinkedList <BspNode> toProcess = new LinkedList <BspNode>(); toProcess.AddLast(mRoot); while (toProcess.Count > 0) { BspNode curNode = toProcess.First.Value; toProcess.RemoveFirst(); // have we reached a leaf? check all triangles in leaf for collisions if (curNode.separatingPlane.Normal.X == 0.0f && curNode.separatingPlane.Normal.Y == 0.0f && curNode.separatingPlane.Normal.Z == 0.0f && curNode.separatingPlane.D == 0.0f) { nodeCollisions(b, curNode, collidingFaces, collisionPoints); } else { // propagate bounding sphere down the tree PlaneIntersectionType side = curNode.separatingPlane.Intersects(b); if (side == PlaneIntersectionType.Back) { toProcess.AddLast(curNode.neg); } else if (side == PlaneIntersectionType.Front) { toProcess.AddLast(curNode.pos); } else { toProcess.AddLast(curNode.pos); toProcess.AddLast(curNode.neg); } } } }
public void Contains(ref BoundingSphere sphere, out ContainmentType result) { bool flag = false; for (int index = 0; index < 6; ++index) { PlaneIntersectionType result1 = PlaneIntersectionType.Front; sphere.Intersects(ref this.planes[index], out result1); switch (result1) { case PlaneIntersectionType.Front: result = ContainmentType.Disjoint; return; case PlaneIntersectionType.Intersecting: flag = true; break; } } result = flag ? ContainmentType.Intersects : ContainmentType.Contains; }
/// <summary> /// Gets a value indicating whether this <see cref="BoundingSphere"/> intersects the specified plane. /// </summary> /// <param name="plane">A <see cref="Plane"/> which represents the plane to evaluate.</param> /// <param name="result"><see langword="true"/> if this sphere intersects the evaluated plane; otherwise, <see langword="false"/>.</param> public void Intersects(ref Plane plane, out PlaneIntersectionType result) { Vector3.Dot(ref plane.Normal, ref Center, out Single distance); distance += plane.D; if (distance > Radius) { result = PlaneIntersectionType.Front; } else { if (distance < -this.Radius) { result = PlaneIntersectionType.Back; } else { result = PlaneIntersectionType.Intersecting; } } }
/// <summary> /// Containment test between this <see cref="BoundingFrustum"/> and specified <see cref="BoundingBox"/>. /// </summary> /// <param name="box">A <see cref="BoundingBox"/> for testing.</param> /// <param name="result">Result of testing for containment between this <see cref="BoundingFrustum"/> and specified <see cref="BoundingBox"/> as an output parameter.</param> public void Contains(ref BoundingBox box, out ContainmentType result) { bool intersects = false; for (int i = 0; i < PlaneCount; i += 1) { PlaneIntersectionType planeIntersectionType = default(PlaneIntersectionType); box.Intersects(ref this.planes[i], out planeIntersectionType); switch (planeIntersectionType) { case PlaneIntersectionType.Front: result = ContainmentType.Disjoint; return; case PlaneIntersectionType.Intersecting: intersects = true; break; } } result = intersects ? ContainmentType.Intersects : ContainmentType.Contains; }
public void Intersects(ref Plane plane, out PlaneIntersectionType result) { float distance; Vector3.Dot(ref plane.Normal, ref Center, out distance); distance += plane.D; if (distance > Radius) { result = PlaneIntersectionType.Front; return; } if (distance < -Radius) { result = PlaneIntersectionType.Back; return; } result = PlaneIntersectionType.Intersecting; }
/// <summary> /// Tests if the plane intersects with this bounding volume, and if not /// which side the volume is on relative to the plane. /// </summary> /// <param name="plane">Plane to test</param> /// <param name="result">Result, the plane intersection type</param> public override void Intersects(ref Plane plane, out PlaneIntersectionType result) { Vector3 normal = plane.Normal; float radius = System.Math.Abs(m_extents.X * normal.X) + System.Math.Abs(m_extents.Y * normal.Y) + System.Math.Abs(m_extents.Z * normal.Z); float dist; Plane.DotCoordinate(ref plane, ref m_center, out dist); if (dist < -radius) { result = PlaneIntersectionType.Back; } else if (dist > radius) { result = PlaneIntersectionType.Front; } else { result = PlaneIntersectionType.Intersects; } }
/// <summary> /// Containment test between this <see cref="BoundingFrustum"/> and specified <see cref="BoundingSphere"/>. /// </summary> /// <param name="sphere">A <see cref="BoundingSphere"/> for testing.</param> /// <param name="result">Result of testing for containment between this <see cref="BoundingFrustum"/> and specified <see cref="BoundingSphere"/> as an output parameter.</param> public void Contains(ref BoundingSphere sphere, out ContainmentType result) { bool intersects = false; for (int i = 0; i < PlaneCount; i += 1) { PlaneIntersectionType planeIntersectionType = default(PlaneIntersectionType); // TODO: We might want to inline this for performance reasons. sphere.Intersects(ref this.planes[i], out planeIntersectionType); switch (planeIntersectionType) { case PlaneIntersectionType.Front: result = ContainmentType.Disjoint; return; case PlaneIntersectionType.Intersecting: intersects = true; break; } } result = intersects ? ContainmentType.Intersects : ContainmentType.Contains; }
/// <summary> /// Checks whether the current BoundingFrustumD intersects a Plane. /// </summary> /// <param name="plane">The Plane to check for intersection with.</param><param name="result">[OutAttribute] An enumeration indicating whether the BoundingFrustumD intersects the Plane.</param> public void Intersects(ref PlaneD plane, out PlaneIntersectionType result) { int num = 0; for (int index = 0; index < 8; ++index) { double result1; Vector3D.Dot(ref this.cornerArray[index], ref plane.Normal, out result1); if ((double)result1 + (double)plane.D > 0.0) { num |= 1; } else { num |= 2; } if (num == 3) { result = PlaneIntersectionType.Intersecting; return; } } result = num == 1 ? PlaneIntersectionType.Front : PlaneIntersectionType.Back; }
public void Intersects(ref PlaneD plane, out PlaneIntersectionType result) { Vector3D vectord; Vector3D vectord2; vectord.X = (plane.Normal.X >= 0.0) ? this.Min.X : this.Max.X; vectord.Y = (plane.Normal.Y >= 0.0) ? this.Min.Y : this.Max.Y; vectord.Z = (plane.Normal.Z >= 0.0) ? this.Min.Z : this.Max.Z; vectord2.X = (plane.Normal.X >= 0.0) ? this.Max.X : this.Min.X; vectord2.Y = (plane.Normal.Y >= 0.0) ? this.Max.Y : this.Min.Y; vectord2.Z = (plane.Normal.Z >= 0.0) ? this.Max.Z : this.Min.Z; if (((((plane.Normal.X * vectord.X) + (plane.Normal.Y * vectord.Y)) + (plane.Normal.Z * vectord.Z)) + plane.D) > 0.0) { result = PlaneIntersectionType.Front; } else if (((((plane.Normal.X * vectord2.X) + (plane.Normal.Y * vectord2.Y)) + (plane.Normal.Z * vectord2.Z)) + plane.D) < 0.0) { result = PlaneIntersectionType.Back; } else { result = PlaneIntersectionType.Intersecting; } }
public void Intersects(ref Plane plane, out PlaneIntersectionType result) { int num = 0; for (int i = 0; i < 8; i++) { float num3; Vector3.Dot(ref this.cornerArray[i], ref plane.Normal, out num3); if ((num3 + plane.D) > 0f) { num |= 1; } else { num |= 2; } if (num == 3) { result = PlaneIntersectionType.Intersecting; return; } } result = (num == 1) ? PlaneIntersectionType.Front : PlaneIntersectionType.Back; }
public void Intersects(ref BoundingBoxD box, out PlaneIntersectionType result) { Vector3D vectord; Vector3D vectord2; vectord.X = (this.Normal.X >= 0.0) ? box.Min.X : box.Max.X; vectord.Y = (this.Normal.Y >= 0.0) ? box.Min.Y : box.Max.Y; vectord.Z = (this.Normal.Z >= 0.0) ? box.Min.Z : box.Max.Z; vectord2.X = (this.Normal.X >= 0.0) ? box.Max.X : box.Min.X; vectord2.Y = (this.Normal.Y >= 0.0) ? box.Max.Y : box.Min.Y; vectord2.Z = (this.Normal.Z >= 0.0) ? box.Max.Z : box.Min.Z; if (((((this.Normal.X * vectord.X) + (this.Normal.Y * vectord.Y)) + (this.Normal.Z * vectord.Z)) + this.D) > 0.0) { result = PlaneIntersectionType.Front; } else if (((((this.Normal.X * vectord2.X) + (this.Normal.Y * vectord2.Y)) + (this.Normal.Z * vectord2.Z)) + this.D) < 0.0) { result = PlaneIntersectionType.Back; } else { result = PlaneIntersectionType.Intersecting; } }
public void Intersects(ref BoundingBox box, out PlaneIntersectionType result) { box.Intersects(ref this, out result); }
public static void Intersects(this Plane plane, ref BoundingSphere sphere, out PlaneIntersectionType result) { sphere.Intersects(ref plane, out result); }
public static void Intersects(this Plane plane, ref BoundingBox box, out PlaneIntersectionType result) { box.Intersects(ref plane, out result); }
public void Intersects(ref BoundingBox box, out PlaneIntersectionType result) { result = Intersects(box); }
/// <summary> /// Checks intersection with a plane /// </summary> /// <param name="plane">Plane to test against</param> /// <param name="result">Result relationship between the aabb and the plane</param> public void Intersects(ref Plane plane, out PlaneIntersectionType result) { Vector3 absPlane; Vector3Extension.Abs(ref plane.Normal, out absPlane); float e, s; Vector3.Dot(ref HalfSize, ref absPlane, out e); Vector3.Dot(ref Center, ref plane.Normal, out s); s += plane.D; if (s - e > 0) { result = PlaneIntersectionType.Back; return; } if (s + e < 0) { result = PlaneIntersectionType.Front; return; } result = PlaneIntersectionType.Intersecting; }
public void Intersects(ref Plane plane, out PlaneIntersectionType result) { // See http://zach.in.tu-clausthal.de/teaching/cg_literatur/lighthouse3d_view_frustum_culling/index.html Vector3 positiveVertex; Vector3 negativeVertex; if (plane.Normal.X >= 0) { positiveVertex.X = Max.X; negativeVertex.X = Min.X; } else { positiveVertex.X = Min.X; negativeVertex.X = Max.X; } if (plane.Normal.Y >= 0) { positiveVertex.Y = Max.Y; negativeVertex.Y = Min.Y; } else { positiveVertex.Y = Min.Y; negativeVertex.Y = Max.Y; } if (plane.Normal.Z >= 0) { positiveVertex.Z = Max.Z; negativeVertex.Z = Min.Z; } else { positiveVertex.Z = Min.Z; negativeVertex.Z = Max.Z; } // Inline Vector3.Dot(plane.Normal, negativeVertex) + plane.D; float distance = ( plane.Normal.X * negativeVertex.X + plane.Normal.Y * negativeVertex.Y + plane.Normal.Z * negativeVertex.Z + plane.D ); if (distance > 0) { result = PlaneIntersectionType.Front; return; } // Inline Vector3.Dot(plane.Normal, positiveVertex) + plane.D; distance = ( plane.Normal.X * positiveVertex.X + plane.Normal.Y * positiveVertex.Y + plane.Normal.Z * positiveVertex.Z + plane.D ); if (distance < 0) { result = PlaneIntersectionType.Back; return; } result = PlaneIntersectionType.Intersecting; }
public void Intersects(ref Plane plane, out PlaneIntersectionType result) { result = Intersects(plane); }
/// <summary> /// Checks whether the current BoundingBox intersects a Plane. /// </summary> /// <param name="plane">The Plane to check for intersection with.</param> /// <param name="result">[OutAttribute] An enumeration indicating whether the BoundingBox intersects the Plane.</param> public void Intersects(ref Plane plane, out PlaneIntersectionType result) { // See http://zach.in.tu-clausthal.de/teaching/cg_literatur/lighthouse3d_view_frustum_culling/index.html Vector3 positiveVertex; Vector3 negativeVertex; if (plane.Normal.X >= 0) { positiveVertex.X = Max.X; negativeVertex.X = Min.X; } else { positiveVertex.X = Min.X; negativeVertex.X = Max.X; } if (plane.Normal.Y >= 0) { positiveVertex.Y = Max.Y; negativeVertex.Y = Min.Y; } else { positiveVertex.Y = Min.Y; negativeVertex.Y = Max.Y; } if (plane.Normal.Z >= 0) { positiveVertex.Z = Max.Z; negativeVertex.Z = Min.Z; } else { positiveVertex.Z = Min.Z; negativeVertex.Z = Max.Z; } // Inline Vector3.Dot(plane.Normal, negativeVertex) + plane.D; var distance = plane.Normal.X * negativeVertex.X + plane.Normal.Y * negativeVertex.Y + plane.Normal.Z * negativeVertex.Z + plane.D; if (distance > 0) { result = PlaneIntersectionType.Front; return; } // Inline Vector3.Dot(plane.Normal, positiveVertex) + plane.D; distance = plane.Normal.X * positiveVertex.X + plane.Normal.Y * positiveVertex.Y + plane.Normal.Z * positiveVertex.Z + plane.D; if (distance < 0) { result = PlaneIntersectionType.Back; return; } result = PlaneIntersectionType.Intersecting; }
public void Intersects(ref BoundingSphere sphere, out PlaneIntersectionType result) { result = Intersects(sphere); }
public static void Intersects(ref Plane plane, ref BoundingFrustum boundingFrustum, out PlaneIntersectionType result) => Intersects(ref boundingFrustum, ref plane, out result);
public static void Intersects(ref Plane plane, ref BoundingSphere boundingSphere, out PlaneIntersectionType result) { var distance = Vector3.Dot(plane.Normal, boundingSphere.Center); distance += plane.D; if (distance > boundingSphere.Radius) { result = PlaneIntersectionType.Front; } else if (distance < boundingSphere.Radius) { result = PlaneIntersectionType.Back; } else { result = PlaneIntersectionType.Intersecting; } }
public static void Intersects(ref Plane plane, ref BoundingBox boundingBox, out PlaneIntersectionType result) { Vector3 positiveVertex; Vector3 negativeVertex; // X if (plane.Normal.X >= 0) { positiveVertex.X = boundingBox.Max.X; negativeVertex.X = boundingBox.Min.X; } else { positiveVertex.X = boundingBox.Min.X; negativeVertex.X = boundingBox.Max.X; } // Y if (plane.Normal.Y >= 0) { positiveVertex.Y = boundingBox.Max.Y; negativeVertex.Y = boundingBox.Min.Y; } else { positiveVertex.Y = boundingBox.Min.Y; negativeVertex.Y = boundingBox.Max.Y; } // Z if (plane.Normal.Z >= 0) { positiveVertex.Z = boundingBox.Max.Z; negativeVertex.Z = boundingBox.Min.Z; } else { positiveVertex.Z = boundingBox.Min.Z; negativeVertex.Z = boundingBox.Max.Z; } var distance = Vector3.Dot(plane.Normal, negativeVertex) + plane.D; if (distance > 0) { result = PlaneIntersectionType.Front; } else { distance = Vector3.Dot(plane.Normal, positiveVertex) + plane.D; result = (distance < 0) ? PlaneIntersectionType.Back : PlaneIntersectionType.Intersecting; } }
/// <summary> /// Checks whether the current BoundingFrustum intersects the specified Plane. /// </summary> /// <param name="plane">The plane.</param> /// <param name="result">Plane intersection type.</param> public void Intersects(ref Plane plane, out PlaneIntersectionType result) { result = PlaneIntersectsPoints(ref plane, GetCorners()); }
/// <summary> /// Gets a value indicating whether this <see cref="Plane"/> intersects the specified frustum. /// </summary> /// <param name="frustum">A <see cref="BoundingFrustum"/> which represents the frustum to evaluate.</param> /// <param name="result">A <see cref="PlaneIntersectionType"/> value which describes the relationship between this plane and the evaluated frustum.</param> public void Intersects(BoundingFrustum frustum, out PlaneIntersectionType result) { Contract.Require(frustum, nameof(frustum)); result = frustum.Intersects(this); }
public static void Intersects(ref BoundingFrustum boundingFrustum, ref Plane plane, out PlaneIntersectionType result) { var corners = boundingFrustum.GetCorners(); result = plane.Intersects(corners[0]); for (int i = 1; i < corners.Length; i++) if (plane.Intersects(corners[i]) != result) result = PlaneIntersectionType.Intersecting; }
/// <summary> /// Checks whether the current BoundingSphere intersects a Plane. /// </summary> /// <param name="plane">The Plane to check for intersection with.</param><param name="result">[OutAttribute] An enumeration indicating whether the BoundingSphere intersects the Plane.</param> public void Intersects(ref Plane plane, out PlaneIntersectionType result) { float distance = Vector3.Dot(plane.Normal, Center) + plane.D; if (distance > Radius) result = PlaneIntersectionType.Front; else if (distance < -Radius) result = PlaneIntersectionType.Back; else result = PlaneIntersectionType.Intersecting; }
public void Intersects(ref Plane plane, out PlaneIntersectionType result) { throw new NotImplementedException(); }
public override void Intersects(ref Plane plane, out PlaneIntersectionType result) { throw new System.NotImplementedException(); }
public void Intersects(ref BoundingSphere sphere, out PlaneIntersectionType result) { sphere.Intersects(ref this, out result); }
public void Intersects(ref Plane plane, out PlaneIntersectionType result) { plane.Intersects(ref this, out result); }