Esempio n. 1
0
        public AABB EncapsulatingAABB(TransformComponent transform)
        {
            AABB result = AABB.Empty();

            switch (Shape)
            {
            case RyneCollisionShape.CollisionShapeAABB:
                result = ExtractAABB(transform);
                break;

            case RyneCollisionShape.CollisionShapeSphere:
                Sphere sphere = ExtractSphere(transform);
                result.Min = new Float4(sphere.Position - new Float3(sphere.Radius), 0.0f);
                result.Max = new Float4(sphere.Position + new Float3(sphere.Radius), 0.0f);
                break;

            case RyneCollisionShape.CollisionShapeCube:
                Cube cube = ExtractCube(transform);
                foreach (var vertex in cube.GetVertices())
                {
                    result.Min = RyneMath.Min(result.Min, new Float4(vertex));
                    result.Max = RyneMath.Max(result.Max, new Float4(vertex));
                }
                break;

            default:
                Logger.Error("EncapsulatingAABB for unsupported shape");
                break;
            }

            return(result);
        }
Esempio n. 2
0
 public void Expand(Float4 position)
 {
     Max = RyneMath.Max(Max, position);
     Min = RyneMath.Min(Min, position);
 }
Esempio n. 3
0
 public void Expand(AABB bounds)
 {
     Max = RyneMath.Max(Max, bounds.Max);
     Min = RyneMath.Min(Min, bounds.Min);
 }