Exemplo n.º 1
0
            unsafe uint GetInputHash(
                PhysicsShapeAuthoring shape,
                NativeList <float3> currentPoints,
                NativeArray <float3> hashedPoints,
                ConvexHullGenerationParameters hashedConvexParameters,
                out ConvexHullGenerationParameters currentConvexProperties
                )
            {
                currentConvexProperties = default;
                switch (shape.ShapeType)
                {
                case ShapeType.ConvexHull:
                    shape.GetBakedConvexProperties(currentPoints, out currentConvexProperties);

                    return(math.hash(
                               new uint3(
                                   (uint)shape.ShapeType,
                                   currentConvexProperties.GetStableHash(hashedConvexParameters),
                                   currentPoints.GetStableHash(hashedPoints)
                                   )
                               ));

                case ShapeType.Mesh:
                    var indices = new NativeList <int>(65535, Allocator.Temp);
                    shape.GetBakedMeshProperties(currentPoints, indices);

                    return(math.hash(
                               new uint3(
                                   (uint)shape.ShapeType,
                                   currentPoints.GetStableHash(hashedPoints),
                                   math.hash(indices.GetUnsafePtr(), UnsafeUtility.SizeOf <int>() * indices.Length)
                                   )
                               ));

                default:
                    return((uint)shape.ShapeType);
                }
            }