Example #1
0
        static void ClusterDraw(RayfireConnectivity targ)
        {
            if (targ.showNodes == true || targ.showConnections == true)
            {
                if (targ.cluster != null && targ.cluster.shards.Count > 0)
                {
                    // Reinit connections
                    if (targ.cluster.initialized == false)
                    {
                        RayfireConnectivity.InitShards(targ.rigidList, targ.cluster);
                    }

                    for (int i = 0; i < targ.cluster.shards.Count; i++)
                    {
                        if (targ.cluster.shards[i].tm != null)
                        {
                            // Color
                            if (targ.cluster.shards[i].rigid == null)
                            {
                                Gizmos.color = targ.cluster.shards[i].uny == true ? Color.red : Color.green;
                            }
                            else
                            {
                                Gizmos.color = targ.cluster.shards[i].rigid.activation.unyielding == true ? Color.red : Color.green;
                            }

                            // Nodes
                            if (targ.showNodes == true)
                            {
                                Gizmos.DrawWireSphere(targ.cluster.shards[i].tm.position, targ.cluster.shards[i].sz / 12f);
                            }

                            // Connection
                            if (targ.showConnections == true)
                            {
                                for (int j = 0; j < targ.cluster.shards[i].neibShards.Count; j++)
                                {
                                    if (targ.cluster.shards[i].neibShards[j].tm != null)
                                    {
                                        Gizmos.DrawLine(targ.cluster.shards[i].tm.position, targ.cluster.shards[i].neibShards[j].tm.position);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }