static void SplitPolygon(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.MakeSplitMeshesByPolygon(meshCache, parentSplitMesh, rootMeshCollider.splitPolygonNormalAngle); if (resplitMeshes == null || resplitMeshes.Length == 0) { return; } 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_Polygon(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.Polygon); } SAMeshColliderEditorCommon.SalvageMeshByPolygon(resplitMesh); SAMeshColliderEditorCommon.RegistReducerTask(reducerTasks, resplitMeshCollider); } }
static void Cleanup(SAMeshCollider meshCollider) { if (meshCollider == null) { Debug.LogError(""); return; } SAMeshColliderEditorCommon.CleanupChildSAMeshColliders( meshCollider.gameObject, meshCollider.cleanupModified); SAMeshColliderEditorCommon.CleanupSelfSAMeshCollider(meshCollider); SAMeshColliderEditorCommon.MarkManualProcessingToParent(meshCollider); }
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); } } }