Beispiel #1
0
        // Prepare shards. Set bounds, set neibs
        public static List <RFShard> GetShards(List <RayfireRigid> rigidList, ConnectivityType connectivity)
        {
            List <RFShard> shardList = new List <RFShard>();

            for (int i = 0; i < rigidList.Count; i++)
            {
                // Get mesh filter
                MeshFilter mf = rigidList[i].GetComponent <MeshFilter>();

                // Child has no mesh
                if (mf == null)
                {
                    continue;
                }

                // Create new shard
                RFShard shard = new RFShard(rigidList[i].transform, i);
                shard.rigid = rigidList[i];

                // Set faces data for connectivity
                if (connectivity == ConnectivityType.ByMesh)
                {
                    shard.tris = RFTriangle.SetTriangles(shard.tm, mf);
                }

                // Collect shard
                shardList.Add(shard);
            }
            return(shardList);
        }
        // Prepare shards. Set bounds, set neibs
        static void SetShardsByRigids(RFCluster cluster, List <RayfireRigid> rigidList, ConnectivityType connectivity)
        {
            for (int i = 0; i < rigidList.Count; i++)
            {
                // Get mesh filter
                MeshFilter mf = rigidList[i].GetComponent <MeshFilter>();

                // Child has no mesh
                if (mf == null)
                {
                    continue;
                }

                // Create new shard
                RFShard shard = new RFShard(rigidList[i].transform, i);
                shard.cluster = cluster;
                shard.rigid   = rigidList[i];
                shard.uny     = rigidList[i].activation.unyielding;
                shard.col     = rigidList[i].physics.meshCollider;

                // Set faces data for connectivity
                if (connectivity == ConnectivityType.ByMesh)
                {
                    RFTriangle.SetTriangles(shard, mf);
                }

                // Collect shard
                cluster.shards.Add(shard);
            }
        }
Beispiel #3
0
        // Prepare shards. Set bounds, set neibs
        public static void SetShardsByTransforms(RFCluster cluster, List <Transform> tmList, ConnectivityType connectivity, bool setRigid = false)
        {
            cluster.shards = new List <RFShard>();
            for (int i = 0; i < tmList.Count; i++)
            {
                // Get mesh filter
                MeshFilter mf = tmList[i].GetComponent <MeshFilter>();

                // Child has no mesh
                if (mf == null)
                {
                    continue;
                }

                // Has no mesh
                if (mf.sharedMesh == null)
                {
                    continue;
                }

                // Create new shard
                RFShard shard = new RFShard(tmList[i], i);
                shard.cluster = cluster;

                // Set faces data for connectivity
                if (connectivity == ConnectivityType.ByMesh || connectivity == ConnectivityType.ByBoundingBoxAndMesh)
                {
                    RFTriangle.SetTriangles(shard, mf);
                }

                // Collect shard
                cluster.shards.Add(shard);
            }

            // Set rigid component
            if (setRigid == true)
            {
                for (int i = 0; i < cluster.shards.Count; i++)
                {
                    cluster.shards[i].rigid = cluster.shards[i].tm.GetComponent <RayfireRigid>();
                }
            }
        }