Example #1
0
        internal static void SetBakedBoxSize(this PhysicsShapeAuthoring shape, float3 size, float bevelRadius)
        {
            var box      = shape.GetBoxProperties(out var orientation);
            var center   = box.Center;
            var prevSize = math.abs(box.Size);

            size = math.abs(size);

            var bakeToShape = BakeBoxJob.GetBakeToShape(shape, center, orientation);
            var scale       = bakeToShape.DecomposeScale();

            size /= scale;

            if (math.abs(size[0] - prevSize[0]) < kMinimumChange)
            {
                size[0] = prevSize[0];
            }
            if (math.abs(size[1] - prevSize[1]) < kMinimumChange)
            {
                size[1] = prevSize[1];
            }
            if (math.abs(size[2] - prevSize[2]) < kMinimumChange)
            {
                size[2] = prevSize[2];
            }

            box.BevelRadius = bevelRadius;
            box.Size        = size;

            shape.SetBox(box, orientation);
        }
Example #2
0
 internal static BoxGeometry BakeToBodySpace(
     this BoxGeometry box, float4x4 localToWorld, float4x4 shapeToWorld, EulerAngles orientation
     )
 {
     using (var geometry = new NativeArray <BoxGeometry>(1, Allocator.TempJob)
     {
         [0] = box
     })
     {
         var job = new BakeBoxJob
         {
             Box          = geometry,
             localToWorld = localToWorld,
             shapeToWorld = shapeToWorld,
             orientation  = orientation
         };
         job.Run();
         return(geometry[0]);
     }
 }