Esempio n. 1
0
        internal static void SetBakedCylinderSize(this PhysicsShapeAuthoring shape, float height, float radius, float bevelRadius)
        {
            var cylinder = shape.GetCylinderProperties(out EulerAngles orientation);
            var center   = cylinder.Center;

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

            var newRadius = radius / math.cmax(scale.xy);

            if (math.abs(cylinder.Radius - newRadius) > kMinimumChange)
            {
                cylinder.Radius = newRadius;
            }
            if (math.abs(cylinder.BevelRadius - bevelRadius) > kMinimumChange)
            {
                cylinder.BevelRadius = bevelRadius;
            }


            var newHeight = math.max(0, height / scale.z);

            if (math.abs(cylinder.Height - newHeight) > kMinimumChange)
            {
                cylinder.Height = newHeight;
            }
            shape.SetCylinder(cylinder, orientation);
        }
Esempio n. 2
0
 internal static CylinderGeometry BakeToBodySpace(
     this CylinderGeometry cylinder, float4x4 localToWorld, float4x4 shapeToWorld, EulerAngles orientation
     )
 {
     using (var geometry = new NativeArray <CylinderGeometry>(1, Allocator.TempJob)
     {
         [0] = cylinder
     })
     {
         var job = new BakeCylinderJob
         {
             Cylinder     = geometry,
             localToWorld = localToWorld,
             shapeToWorld = shapeToWorld,
             orientation  = orientation
         };
         job.Run();
         return(geometry[0]);
     }
 }