Example #1
0
    public bool Intersects(DCollider collider)
    {
        DBox3DCollider bbox = (collider.Type == ColliderType.Box3D) ? (DBox3DCollider)collider : ((DSphereCollider)collider).BoundingBox;
        Vector2F       min  = position;
        Vector2F       max  = position + Vector2F.One * size;

        //if (max.x < bbox.Min.x || min.x > bbox.Max.x) return false;
        //if (max.y < bbox.Min.y || min.y > bbox.Max.y) return false;
        return(true);
    }
Example #2
0
    /// <summary>
    /// Creates a new circle collider with the given position and radius.
    /// </summary>
    /// <param name="position">the center of the circle</param>
    /// <param name="radius">the radius of the circle</param>
    public DSphereCollider(Vector3F position, Fix32 radius, bool isTrigger, bool isDebug)
        : base(ColliderType.Sphere, isTrigger, isDebug)
    {
        this.center = position;
        this.radius = radius;
        Vector3F scale = new Vector3F(radius * (Fix32)2, radius * (Fix32)2, radius * (Fix32)2);
        Vector3F euler = new Vector3F(0, 0, 0);

        boundingBox = new DBox3DCollider(center, scale, euler, isTrigger, isDebug);
    }
Example #3
0
    /// <summary>
    /// Removes the given object from the grid.
    /// </summary>
    /// <param name="obj">the rigid body</param>
    public void Remove(DBody obj)
    {
        DBox3DCollider box = obj.Collider.GetContainer();
        //Coord min = Hash(box.Min);
        //Coord max = Hash(box.Max);
        //if (!IsInsideBounds(min) || !IsInsideBounds(max))
        //    return;

        //for (int i = min.x; i <= max.x; i++) {
        //    for (int j = min.y; j <= max.y; j++) {
        //        Remove(obj, i, j);
        //    }
        //}
    }
Example #4
0
 /// <summary>
 /// Abstract function for intersections with boxes.
 /// </summary>
 /// <param name="other">box3d collider.</param>
 /// <param name="intersection">collision data.</param>
 /// <returns></returns>
 public abstract bool Intersects(DBox3DCollider other, out Manifold intersection);
Example #5
0
 /// <summary>
 /// Checks whether the two boxes collide, generating an intersection containing the collision data.
 /// This function can only compare bounding boxes againsts other bounding boxes.
 /// </summary>
 /// <param name="other">bounding box to check</param>
 /// <param name="intersection">the collision data, <code>null</code> if no collision has been detected.</param>
 /// <returns></returns>
 public override bool Intersects(DBox3DCollider other, out Manifold intersection)
 {
     intersection = null;
     return(false);
 }
Example #6
0
 /// <summary>
 /// Checks whether the given box collider intersects with this circle, calculating
 /// the collision data in that case.
 /// </summary>
 /// <param name="other">box collider to check</param>
 /// <param name="intersection">the collision data, <code>null</code> if no collision has been detected.</param>
 /// <returns>true if the colliders intersect, false otherwise.</returns>
 public override bool Intersects(DBox3DCollider other, out Manifold intersection)
 {
     intersection = null;
     return(other.Intersects(this, out intersection));
 }