Closed hunterhunted closed 2 years ago
MeshUtility.Optimize re-orders the sharedmesh indices, but something internal doesn't update for later raycasts.
Here's where it gets optimized: https://github.com/LogicalError/realtime-CSG-for-unity/blob/2b6143fbbdfaca79a2a57ae1fcd2aadfbe3f5416/RealtimeCSG/Assets/Plugins/RealtimeCSG/Editor/Scripts/Control/Managers/MeshInstanceManager.Build.cs#L120
I noticed a similar issue was solved here: https://github.com/LogicalError/realtime-CSG-for-unity/blob/2b6143fbbdfaca79a2a57ae1fcd2aadfbe3f5416/RealtimeCSG/Assets/Plugins/RealtimeCSG/Editor/Scripts/Control/Managers/MeshInstanceManager.cs#L1401
Using the same workaround, my raycasts during playmode in the editor are getting the correct triangleIndex on optimized meshes from RCSG again:
if (child.SharedMesh && !UsesLightmapUVs(model)) { MeshUtility.Optimize(child.SharedMesh); #if UNITY_EDITOR var currentMeshCollider = child.gameObject.GetComponent<MeshCollider>(); if (currentMeshCollider && currentMeshCollider.enabled) { currentMeshCollider.enabled = false; currentMeshCollider.enabled = true; } #endif }
Thanks, fixed in 1.562! I'll close this ticket when it's available from the asset store
MeshUtility.Optimize re-orders the sharedmesh indices, but something internal doesn't update for later raycasts.
Here's where it gets optimized: https://github.com/LogicalError/realtime-CSG-for-unity/blob/2b6143fbbdfaca79a2a57ae1fcd2aadfbe3f5416/RealtimeCSG/Assets/Plugins/RealtimeCSG/Editor/Scripts/Control/Managers/MeshInstanceManager.Build.cs#L120
I noticed a similar issue was solved here: https://github.com/LogicalError/realtime-CSG-for-unity/blob/2b6143fbbdfaca79a2a57ae1fcd2aadfbe3f5416/RealtimeCSG/Assets/Plugins/RealtimeCSG/Editor/Scripts/Control/Managers/MeshInstanceManager.cs#L1401
Using the same workaround, my raycasts during playmode in the editor are getting the correct triangleIndex on optimized meshes from RCSG again: