Пример #1
0
        private static CollisionMeshData CreateDataOptionallyReduce(Mesh mesh,
                                                                    CollisionMeshOptions options,
                                                                    Utils.MeshMerger merger)
        {
            var reductionEnabled = options != null && options.ReductionEnabled;
            var orgNumVertices   = merger.Vertices.Count;

            if (reductionEnabled)
            {
                merger.Reduce(options.ReductionRatio, options.ReductionAggressiveness);
            }

            if (merger.Vertices.Count == 0)
            {
                if (reductionEnabled && orgNumVertices > 0)
                {
                    UnityEngine.Debug.LogWarning($"Vertex Reduction reduced a collision mesh from {orgNumVertices} vertices to zero. " +
                                                 "Ignoring collision mesh.", mesh);
                }
                else
                {
                    UnityEngine.Debug.LogWarning($"Mesh \"{mesh.name}\" doesn't contain any vertices for the collision mesh. " +
                                                 "Ignoring collision mesh.", mesh);
                }
                return(null);
            }

            var meshData = new CollisionMeshData();

            meshData.Apply(merger.Vertices, merger.Indices);

            return(meshData);
        }
Пример #2
0
 private static CollisionMeshData CreateDataOptionallyReduce(Mesh mesh,
                                                             CollisionMeshOptions options,
                                                             Utils.MeshMerger merger,
                                                             agxCollide.Convex convex)
 {
     merger.Vertices = convex.getMeshData().getVertices();
     merger.Indices  = convex.getMeshData().getIndices();
     return(CreateDataOptionallyReduce(mesh, options, merger));
 }