Example #1
0
        // Set up main cluster and set shards
        RFCluster SetupMainCluster(ConnectivityType connect)
        {
            // Create Base cluster
            RFCluster cluster = RFCluster.SetCluster(transform, connect);

            clusterId = 0;

            // Collect all shards
            allShards.Clear();
            allShards.AddRange(cluster.shards);

            // TODO set bound

            return(cluster);
        }
Example #2
0
        // Create one cluster which includes only children meshes, not children of children meshes.
        static bool ClusterizeConnected(RayfireRigid scr)
        {
            // Setup cluster and shard if first time. Do not if copied from parent
            if (scr.clusterDemolition.cluster == null || scr.clusterDemolition.cluster.id == 0)
            {
                // Set cluster
                scr.clusterDemolition.cluster    = RFCluster.SetCluster(scr.transForm, scr.clusterDemolition.connectivity);
                scr.clusterDemolition.cluster.id = 1;

                // Set shard neibs
                RFShard.SetShardNeibs(scr.clusterDemolition.cluster.shards, scr.clusterDemolition.connectivity);
            }

            // Get all children meshes
            List <MeshFilter> childMeshes = new List <MeshFilter>();

            for (int i = 0; i < scr.transForm.childCount; i++)
            {
                MeshFilter mf = scr.transForm.GetChild(i).GetComponent <MeshFilter>();
                if (mf != null)
                {
                    childMeshes.Add(mf);
                }
            }

            // No meshes in children
            if (childMeshes.Count == 0)
            {
                return(false);
            }

            // float t1 = Time.realtimeSinceStartup;

            // Create mesh colliders for every input mesh and collect
            RFPhysic.SetClusterColliders(scr, childMeshes.ToArray());

            // TODO connectivity check to find solo shards and make sure they are not connected

            return(true);
        }