public bool Intersects(UprightBoxNode box)
 {
     return PrimitiveNode.Intersects(box, this);
 }
示例#2
0
        protected static bool Intersects(UprightBoxNode a, UprightCylinderNode b)
        {
            Vector3 baseTransformed = a.ReferenceNode.ConvertWorldToLocalPosition(
                b.ReferenceNode.ConvertLocalToWorldPosition(b.BaseCenterPosition)
            );
            // Check if the two objects intersect the same horizontal (xz) plane
            // Simplification:
            // |a.yCenter - b.yCenter| > max(a.height / 2, b.height / 2)
            // |(a.min.y + a.max.y) / 2 - (b.base.y + b.base.y + b.height) / 2| > max((a.max.y - a.min.y) / 2, b.height / 2)
            // |(a.min.y + a.max.y) - (b.base.y * 2 + b.height)| / 2 > max((a.max.y - a.min.y), b.height) / 2
            if (System.Math.Abs(a.Min.y + a.Max.y - (b.BaseCenterPosition.y * 2 + b.Height)) > System.Math.Max(a.Max.y - a.Min.y, b.Height))
                return false;

            // Check if the two objects intersect when projected onto a horizontal (xz) plane
            Vector2 closest = baseTransformed.ToVectorXZ().Clamp(a.Min.ToVectorXZ(), a.Max.ToVectorXZ());
            return closest.SquaredDistance(baseTransformed.ToVectorXZ()) < b.Radius.Squared();
        }
示例#3
0
 public void AddBuildingCollisionMesh(UprightBoxNode box)
 {
     Buildings.Add(box);
 }