From 6e26d3d16493c164211ac7e5b5e95ed0bd838ba2 Mon Sep 17 00:00:00 2001 From: Filip Henningsson Date: Tue, 14 Nov 2023 15:57:03 +0100 Subject: [PATCH 1/2] Fixed constraint controllers not handling multiple controllers of same type --- Editor/AGXUnityEditor/Tools/ConstraintTool.cs | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/Editor/AGXUnityEditor/Tools/ConstraintTool.cs b/Editor/AGXUnityEditor/Tools/ConstraintTool.cs index d5d7f80a..5794815d 100644 --- a/Editor/AGXUnityEditor/Tools/ConstraintTool.cs +++ b/Editor/AGXUnityEditor/Tools/ConstraintTool.cs @@ -193,35 +193,47 @@ in constraintsParser GUI.MakeLabel( "Controllers", true ) ) ) { using ( InspectorGUI.IndentScope.Single ) { foreach ( var refController in ecControllers ) { + // Skip Cone Limit friction controllers + if ( refController.NativeName.StartsWith( "CL" ) ) + continue; + var controllerType = refController.GetControllerType(); var controllerTypeTag = controllerType.ToString()[ 0 ].ToString(); var controllerName = ConstraintUtils.FindName( refController ); if ( controllerName.EndsWith( " Controller" ) ) controllerName = controllerName.Remove( controllerName.LastIndexOf( " Controller" ) ); + string nativeTag = GetNativeNameTag(refController.NativeName); var controllerLabel = GUI.MakeLabel( ( controllerType == Constraint.ControllerType.Rotational ? GUI.Symbols.CircleArrowAcw.ToString() + " " : - GUI.Symbols.ArrowRight.ToString() + " " ) + controllerName, true ); - if ( !InspectorGUI.Foldout( selected( controllerTypeTag + controllerName ), + GUI.Symbols.ArrowRight.ToString() + " " ) + + controllerName + + nativeTag, + true ); + if ( !InspectorGUI.Foldout( selected( controllerTypeTag + controllerName + refController.NativeName ), controllerLabel ) ) { continue; } - var controllers = ( from constraint - in constraints - from controller - in constraint.GetElementaryConstraintControllers() - where controller.GetType() == refController.GetType() && - controller.GetControllerType() == refController.GetControllerType() - select controller ).ToArray(); using ( InspectorGUI.IndentScope.Single ) { - InspectorEditor.DrawMembersGUI( controllers ); - InspectorEditor.DrawMembersGUI( controllers, controller => ( controller as ElementaryConstraint ).RowData[ 0 ] ); + InspectorEditor.DrawMembersGUI( new Object[] { refController } ); + InspectorEditor.DrawMembersGUI( new Object[] { refController }, controller => ( controller as ElementaryConstraint ).RowData[ 0 ] ); } } } } } + private static string GetNativeNameTag( string nativeName ) + { + if ( nativeName[ 0 ] == 'F' ) { + string dimLabel = nativeName[1].ToString(); + if ( RowLabels.Contains( dimLabel ) ) + return " " + GUI.AddColorTag( dimLabel, RowColors[ Array.IndexOf( RowLabels, dimLabel ) ] ); + } + + return ""; + } + private bool ConstraintTypeGUI( Constraint[] constraints, bool differentTypes ) { var anyUnknownType = constraints.Any( c => c.Type == ConstraintType.Unknown ); From da25927b3fb5fe05391ca33da793c9f8de619241 Mon Sep 17 00:00:00 2001 From: Filip Henningsson Date: Wed, 15 Nov 2023 11:08:42 +0100 Subject: [PATCH 2/2] Fixed multi-edit for constraint controllers --- Editor/AGXUnityEditor/Tools/ConstraintTool.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Editor/AGXUnityEditor/Tools/ConstraintTool.cs b/Editor/AGXUnityEditor/Tools/ConstraintTool.cs index 5794815d..4aa7eed8 100644 --- a/Editor/AGXUnityEditor/Tools/ConstraintTool.cs +++ b/Editor/AGXUnityEditor/Tools/ConstraintTool.cs @@ -213,10 +213,15 @@ in constraintsParser controllerLabel ) ) { continue; } - + var controllers = ( from constraint + in constraints + from controller + in constraint.GetElementaryConstraintControllers() + where controller.NativeName == refController.NativeName + select controller ).ToArray(); using ( InspectorGUI.IndentScope.Single ) { - InspectorEditor.DrawMembersGUI( new Object[] { refController } ); - InspectorEditor.DrawMembersGUI( new Object[] { refController }, controller => ( controller as ElementaryConstraint ).RowData[ 0 ] ); + InspectorEditor.DrawMembersGUI( controllers ); + InspectorEditor.DrawMembersGUI( controllers, controller => ( controller as ElementaryConstraint ).RowData[ 0 ] ); } } }