internal static CapsuleGeometryAuthoring BakeToBodySpace( this CapsuleGeometryAuthoring capsule, float4x4 localToWorld, float4x4 shapeToWorld ) { using (var geometry = new NativeArray <CapsuleGeometryAuthoring>(1, Allocator.TempJob) { [0] = capsule }) { var job = new BakeCapsuleJob { Capsule = geometry, localToWorld = localToWorld, shapeToWorld = shapeToWorld }; job.Run(); return(geometry[0]); } }
public void Execute() { var radius = Capsule[0].Radius; var center = Capsule[0].Center; var height = Capsule[0].Height; var orientationEuler = Capsule[0].OrientationEuler; var bakeToShape = GetBakeToShape(localToWorld, shapeToWorld, ref center, ref orientationEuler); var scale = bakeToShape.DecomposeScale(); radius *= math.cmax(scale.xy); height = math.max(0, height * scale.z); Capsule[0] = new CapsuleGeometryAuthoring { OrientationEuler = orientationEuler, Center = center, Height = height, Radius = radius }; }