void ClusterSetupUI() { GUILayout.BeginHorizontal(); if (GUILayout.Button("Setup Cluster", GUILayout.Height(25))) { if (Application.isPlaying == false) { foreach (var targ in targets) { if (targ as RayfireRigid != null) { RFPhysic.DestroyColliders(targ as RayfireRigid); (targ as RayfireRigid).clusterDemolition.cluster = new RFCluster(); (targ as RayfireRigid).clusterDemolition.clsCount = 1; (targ as RayfireRigid).clusterDemolition.minorClusters = null; (targ as RayfireRigid).SetComponentsBasic(); (targ as RayfireRigid).SetParticleComponents(); if (RFDemolitionCluster.Clusterize(targ as RayfireRigid) == false) { Debug.Log("RayFire Rigid: " + (targ as RayfireRigid).name + " has no children with mesh."); } SetDirty(targ as RayfireRigid); } } } } if (GUILayout.Button("Reset Cluster", GUILayout.Height(25))) { if (Application.isPlaying == false) { foreach (var targ in targets) { if (targ as RayfireRigid != null) { RFPhysic.DestroyColliders(targ as RayfireRigid); (targ as RayfireRigid).clusterDemolition.cluster = new RFCluster(); (targ as RayfireRigid).clusterDemolition.clsCount = 1; (targ as RayfireRigid).clusterDemolition.minorClusters = null; SetDirty(targ as RayfireRigid); } } } } EditorGUILayout.EndHorizontal(); }
// Clusterize void Clusterize() { // TODO skip if minor nested cluster if (objectType == ObjectType.NestedCluster) { if (clusterDemolition.cluster.id > 1) { return; } } // Fail check if (RFDemolitionCluster.Clusterize(this) == true) { return; } // Fail physics.exclude = true; Debug.Log("RayFire Rigid: " + name + " has no children with mesh. Object Excluded from simulation.", gameObject); }
// Define components void SetComponentsPhysics() { // Excluded from simulation if (physics.exclude == true) { return; } // Physics components physics.rigidBody = GetComponent <Rigidbody>(); physics.meshCollider = GetComponent <Collider>(); // Mesh Set collider if (objectType == ObjectType.Mesh) { RFPhysic.SetMeshCollider(this); } // Cluster check TODO EXPOSE IN UI !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! if (objectType == ObjectType.NestedCluster || objectType == ObjectType.ConnectedCluster) { // No children mesh for clustering bool clusteringState = RFDemolitionCluster.Clusterize(this); if (clusteringState == false) { physics.exclude = true; Debug.Log("RayFire Rigid: " + name + " has no children with mesh. Object Excluded from simulation.", gameObject); return; } } // Rigid body if (simulationType != SimType.Static && physics.rigidBody == null) { physics.rigidBody = gameObject.AddComponent <Rigidbody>(); physics.rigidBody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic; } }