SabreCSG icon indicating copy to clipboard operation
SabreCSG copied to clipboard

Collision brushes just don't generate collision meshes.

Open sniggyfigbat opened this issue 3 years ago • 9 comments

I've been getting complaints of the clipping on one of my windows not working in a level, and decided to investigate. Not sure what the SabreCSG version is, but it's relatively recent (downloaded within the last couple of months).

I have disabled every other CSG object and brush other than shown.

The brushes: image

The generated geometry: image

As you can see, some of the brushes are being turned into collision meshes correctly, but the ones on the right are just skipped. No errors are thrown. I have tried deleting and remaking the brushes from the ones on the left that work. I know the Rebuild button is working because I've tried deleting the CollisionMesh object and it gets remade.

Bluntly, I'm completely stumped, and really think this may be a bug not user error. And if it's not, it's probably a UX failure if the user has literally no way of telling what the issue is.

sniggyfigbat avatar Oct 13 '21 22:10 sniggyfigbat

Hey Sniggyfigbat,

a quick suggestion, because I remember encountering a similar issue with CSG Models that contain only collision brushes... just add one regular brush. See if that fixes everything after a force rebuild.

Henry00IS avatar Oct 13 '21 22:10 Henry00IS

@Henry00IS Good suggestion, but unfortunately no dice.

image

sniggyfigbat avatar Oct 13 '21 22:10 sniggyfigbat

Hmm. Turning on the experimental 'Optimize Geometry' setting throws the following error:

NullReferenceException: Object reference not set to an instance of an object
Sabresaurus.SabreCSG.Optimizer.CalculateConvexHulls (System.Collections.Generic.List`1[T] polygons) (at Assets/IntruderMM/SabreCSG/Scripts/Core/BuildEngine/Optimizer.cs:253)
Sabresaurus.SabreCSG.BrushCache.OptimizeCollision (Sabresaurus.SabreCSG.BrushCache mainCache) (at Assets/IntruderMM/SabreCSG/Scripts/Core/BuildEngine/BrushCache.cs:554)
Sabresaurus.SabreCSG.CSGFactory.CoreBuild (System.Object state) (at Assets/IntruderMM/SabreCSG/Scripts/Core/BuildEngine/CSGFactory.cs:430)
Sabresaurus.SabreCSG.CSGFactory.Build (System.Collections.Generic.List`1[T] brushes, Sabresaurus.SabreCSG.CSGBuildSettings buildSettings, Sabresaurus.SabreCSG.CSGBuildContext+BuildContext buildContext, UnityEngine.Transform rootTransform, Sabresaurus.SabreCSG.MaterialMeshDictionary materialMeshDictionary, System.Collections.Generic.List`1[T] collisionMeshDictionary, System.Boolean polygonsRemoved, System.Boolean forceRebuild, System.Action`1[T] onProgressChange, System.Action`2[T1,T2] onFinalizeVisualMesh, System.Action`2[T1,T2] onFinalizeCollisionMesh, System.Boolean multithreaded) (at Assets/IntruderMM/SabreCSG/Scripts/Core/BuildEngine/CSGFactory.cs:100)
Sabresaurus.SabreCSG.CSGModelBase.Build (System.Boolean forceRebuild, System.Boolean buildInBackground) (at Assets/IntruderMM/SabreCSG/Scripts/CSGModelBase.cs:234)
Sabresaurus.SabreCSG.CSGModel.Build (System.Boolean forceRebuild, System.Boolean buildInBackground) (at Assets/IntruderMM/SabreCSG/Scripts/CSGModel.cs:234)
Sabresaurus.SabreCSG.Toolbar.OnBottomToolbarGUI (System.Int32 windowID) (at Assets/IntruderMM/SabreCSG/Scripts/UI/Toolbar.cs:570)
UnityEngine.GUILayout+LayoutedWindow.DoWindow (System.Int32 windowID) (at <e958c94af49b432dad15fe9d47da0d11>:0)
UnityEngine.GUI.CallWindowDelegate (UnityEngine.GUI+WindowFunction func, System.Int32 id, System.Int32 instanceID, UnityEngine.GUISkin _skin, System.Int32 forceRect, System.Single width, System.Single height, UnityEngine.GUIStyle style) (at <e958c94af49b432dad15fe9d47da0d11>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

Dunno' if that's in any way relevant.

sniggyfigbat avatar Oct 13 '21 22:10 sniggyfigbat

I can reproduce the issue. Adding a regular brush at the end tends to fix one of them, that's what I remembered. Clearly something is horribly broken.

Henry00IS avatar Oct 13 '21 22:10 Henry00IS

Aha, progress:

image

Adding meshes with visual geometry forces generation of the missing colliders if (and only if) they intersect the missing colliders.

sniggyfigbat avatar Oct 13 '21 22:10 sniggyfigbat

Notes:

  • Adding entirely new brushes using the Draw tool, and setting them to collision-only, still results in them being skipped.
  • Changing the order of the brushes inside their parent object has no effect. Neither does shifting them up one layer of the hierarchy. Neither did forming them into a CSG group.

sniggyfigbat avatar Oct 13 '21 22:10 sniggyfigbat

Shitty workaround: Put all collision brushes in a dedicated CSG object, set them all as visible, Force Rebuild, and them manually delete the created MaterialMesh object.

sniggyfigbat avatar Oct 13 '21 22:10 sniggyfigbat

Out of interest, did this problem ever get fixed?

sniggyfigbat avatar Mar 05 '22 15:03 sniggyfigbat

Out of interest, did this problem ever get fixed?

nope, have the exact same issue currently

MrXonte avatar Jul 03 '22 11:07 MrXonte