static void ProcessPrimitive(List <ReducerTask> reducerTasks, MeshCache meshCache, SAMeshCollider meshCollider) { if (reducerTasks == null || meshCache == null || meshCollider == null) { Debug.LogError(""); return; } SplitMesh splitMesh = meshCollider.splitMesh; if (splitMesh == null) { Debug.LogError(""); return; } SAMeshColliderEditorCommon.MarkManualProcessingToParent(meshCollider); if (meshCollider.splitPolygonNormalEnabled) { SAMeshColliderEditorCommon.MakeSplitMeshTriangles(meshCache, splitMesh); SplitPolygon(reducerTasks, meshCache, meshCollider, meshCollider); } else { SAMeshColliderEditorCommon.MakeSplitMeshTriangles(meshCache, splitMesh); SAMeshColliderEditorCommon.RegistReducerTask(reducerTasks, meshCollider); } }
static void ProcessPrimitive( List <ReducerTask> reducerTasks, MeshCache meshCache, SAMeshColliderBuilder meshColliderBuilder, GameObject parentGameObject, SplitMesh parentSplitMesh) { if (reducerTasks == null || meshCache == null || meshColliderBuilder == null || parentGameObject == null || parentSplitMesh == null) { Debug.LogError(""); return; } SplitMesh[] resplitMeshes = SAMeshColliderEditorCommon.MakeSplitMeshesByPrimitive(meshCache, parentSplitMesh); if (resplitMeshes == null || resplitMeshes.Length == 0) { return; } SAMeshCollider[] existingMeshColliders = SAMeshColliderEditorCommon.GetChildSAMeshColliders(parentGameObject); for (int i = 0; i < resplitMeshes.Length; ++i) { SplitMesh resplitMesh = resplitMeshes[i]; SAMeshCollider existingMeshCollider = SAMeshColliderEditorCommon.FindSAMeshCollider(existingMeshColliders, resplitMesh); if (existingMeshCollider != null && existingMeshCollider.modified) { continue; // Not overwrite modified SAMeshCollider. } string resplitMeshColliderName = SAMeshColliderEditorCommon.GetSAMeshColliderName_Primitive(i); SAMeshCollider resplitMeshCollider = null; if (existingMeshCollider != null) { resplitMeshCollider = existingMeshCollider; SAMeshColliderEditorCommon.SetupSAMeshCollider( meshColliderBuilder, resplitMeshCollider, resplitMeshColliderName); resplitMesh = resplitMeshCollider.splitMesh; } else { resplitMeshCollider = SAMeshColliderEditorCommon.CreateSAMeshCollider( meshColliderBuilder, parentGameObject, resplitMeshColliderName, resplitMesh, SplitMode.Primitive); } if (resplitMeshCollider.splitPolygonNormalEnabled) { SAMeshColliderEditorCommon.MakeSplitMeshTriangles(meshCache, resplitMesh); ProcessPolygon(reducerTasks, meshCache, meshColliderBuilder, resplitMeshCollider.gameObject, resplitMeshCollider.splitMesh); } else { SAMeshColliderEditorCommon.MakeSplitMeshTriangles(meshCache, resplitMesh); SAMeshColliderEditorCommon.RegistReducerTask(reducerTasks, resplitMeshCollider); } } }
static void ProcessRoot( List <ReducerTask> reducerTasks, MeshCache meshCache, SAMeshColliderBuilder meshColliderBuilder, GameObject parentGameObject) { if (reducerTasks == null || meshCache == null || meshColliderBuilder == null || parentGameObject == null) { Debug.LogError(""); return; } SplitMesh resplitMesh = SAMeshColliderEditorCommon.MakeRootSplitMesh(meshCache); if (resplitMesh == null) { return; } if (meshColliderBuilder.splitMaterialEnabled) { ProcessMaterial(reducerTasks, meshCache, meshColliderBuilder, parentGameObject); } else if (meshColliderBuilder.splitPrimitiveEnabled) { ProcessPrimitive(reducerTasks, meshCache, meshColliderBuilder, parentGameObject, resplitMesh); } else if (meshColliderBuilder.splitPolygonNormalEnabled) { SAMeshColliderEditorCommon.MakeSplitMeshTriangles(meshCache, resplitMesh); ProcessPolygon(reducerTasks, meshCache, meshColliderBuilder, parentGameObject, resplitMesh); } else { SAMeshCollider[] existingMeshColliders = SAMeshColliderEditorCommon.GetChildSAMeshColliders(parentGameObject); SAMeshCollider existingMeshCollider = SAMeshColliderEditorCommon.FindSAMeshCollider(existingMeshColliders, resplitMesh); if (existingMeshCollider != null && existingMeshCollider.modified) { return; // Not overwrite modified SAMeshCollider. } string resplitMeshColliderName = SAMeshColliderEditorCommon.GetSAMeshColliderName_Root(parentGameObject); SAMeshCollider resplitMeshCollider = null; if (existingMeshCollider != null) { resplitMeshCollider = existingMeshCollider; SAMeshColliderEditorCommon.SetupSAMeshCollider( meshColliderBuilder, resplitMeshCollider, resplitMeshColliderName); resplitMesh = resplitMeshCollider.splitMesh; } else { resplitMeshCollider = SAMeshColliderEditorCommon.CreateSAMeshCollider( meshColliderBuilder, parentGameObject, resplitMeshColliderName, resplitMesh, SplitMode.None); } SAMeshColliderEditorCommon.MakeSplitMeshTriangles(meshCache, resplitMesh); SAMeshColliderEditorCommon.RegistReducerTask(reducerTasks, resplitMeshCollider); } }
static void SplitMaterial(List <ReducerTask> reducerTasks, MeshCache meshCache, SAMeshCollider parentMeshCollider, SAMeshCollider rootMeshCollider) { if (reducerTasks == null || meshCache == null || parentMeshCollider == null || rootMeshCollider == null) { Debug.LogError(""); return; } SplitMesh parentSplitMesh = parentMeshCollider.splitMesh; if (parentSplitMesh == null) { Debug.LogError(""); return; } SAMeshColliderEditorCommon.CleanupSelfSAMeshCollider(parentMeshCollider); SAMeshCollider[] existingMeshColliders = SAMeshColliderEditorCommon.GetChildSAMeshColliders(parentMeshCollider.gameObject); SplitMesh[] resplitMeshes = SAMeshColliderEditorCommon.MakeSplitMeshesByMaterial(meshCache); if (resplitMeshes == null || resplitMeshes.Length == 0) { return; } Material[] materials = meshCache.materials; for (int i = 0; i < resplitMeshes.Length; ++i) { SplitMesh resplitMesh = resplitMeshes[i]; SAMeshCollider existingMeshCollider = SAMeshColliderEditorCommon.FindSAMeshCollider(existingMeshColliders, resplitMesh); if (existingMeshCollider != null && existingMeshCollider.modified) { continue; } string resplitMeshColliderName = SAMeshColliderEditorCommon.GetSAMeshColliderName_Material(materials, i); SAMeshCollider resplitMeshCollider = null; if (existingMeshCollider != null) { resplitMeshCollider = existingMeshCollider; SAMeshColliderEditorCommon.SetupSAMeshCollider( parentMeshCollider, resplitMeshCollider, resplitMeshColliderName); resplitMesh = resplitMeshCollider.splitMesh; } else { resplitMeshCollider = SAMeshColliderEditorCommon.CreateSAMeshCollider( parentMeshCollider, resplitMeshColliderName, resplitMesh, SplitMode.Primitive); } if (resplitMeshCollider.splitPrimitiveEnabled) { SplitPrimitive(reducerTasks, meshCache, resplitMeshCollider, rootMeshCollider); } else if (resplitMeshCollider.splitPolygonNormalEnabled) { SAMeshColliderEditorCommon.MakeSplitMeshTriangles(meshCache, resplitMesh); SplitPolygon(reducerTasks, meshCache, resplitMeshCollider, rootMeshCollider); } else { SAMeshColliderEditorCommon.MakeSplitMeshTriangles(meshCache, resplitMesh); SAMeshColliderEditorCommon.RegistReducerTask(reducerTasks, resplitMeshCollider); } } }