Skip to content

Commit bf31cd6

Browse files
committed
Fixed an issue where curves were not editable after being saved and reloaded.
Code cleanup.
1 parent 5db2ef8 commit bf31cd6

File tree

4 files changed

+30
-43
lines changed

4 files changed

+30
-43
lines changed

Plugins/HoudiniEngineUnity/Editor/UI/HEU_CurveUI.cs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,12 @@ public class HEU_CurveUI : Editor
6262
private const float _sceneUIBorderPadding = 2f;
6363

6464
private const string _curveEditorLabel = "HOUDINI ENGINE CURVE EDITOR";
65-
6665
private const string _infoHeaderLabel = "CURVE EDITOR INFO";
67-
6866
private const string _curveNewPointModeLabel = "New Point Mode";
69-
7067
private const string _infoLabel = "Press F1 to show or hide Info Panel.";
71-
7268
private const string _curveViewHelp =
7369
"You can add and edit curve points similar to the Houdini Curve tool."
7470
+ "\nSelect ADD or EDIT mode or switch to them using Space.";
75-
7671
private const string _curveViewHelp2 =
7772
"You can add and edit curve points similar to the Houdini Curve tool."
7873
+ "\nSelect ADD or EDIT mode or switch to them using F2.";
@@ -96,13 +91,9 @@ public class HEU_CurveUI : Editor
9691
// CACHE ------------------------------------------------------------------------------------------------------
9792

9893
private Camera _currentCamera;
99-
10094
private Texture2D _lineTexture;
101-
10295
private Texture2D _boxTexture;
103-
10496
private Rect _curveEditorUIRect;
105-
10697
private HEU_Curve.Interaction _interactionMode;
10798

10899
// Map of selected points for each curve
@@ -894,17 +885,10 @@ private void UpdateEditMode(HEU_HoudiniAsset asset, int controlID, EventType eve
894885
// For multi-point selection, calculates bounds and centre point
895886
Bounds bounds = new Bounds();
896887
int numSelectedPoints = 0;
897-
898888
bool bInteractionOcurred = false;
899-
900889
bool isDraggingPoints = false;
901890
bool wasDraggingPoints = false;
902891

903-
bool cookWhileDragging = false;
904-
905-
bool disableCurveScaleRot = false;
906-
907-
908892
// Draw the curve points
909893
EditModeDrawCurvePoints(currentEvent, eventType, ref numSelectedPoints, ref bounds,
910894
ref bInteractionOcurred);
@@ -916,7 +900,7 @@ private void UpdateEditMode(HEU_HoudiniAsset asset, int controlID, EventType eve
916900
// Drag selected points
917901
Vector3 handleCenter = bounds.center;
918902
isDraggingPoints = (EditorGUIUtility.hotControl != 0);
919-
disableCurveScaleRot = asset.CurveDisableScaleRotation;
903+
bool disableCurveScaleRot = asset.CurveDisableScaleRotation;
920904

921905

922906
// Use rotation for every handle type
@@ -933,8 +917,6 @@ private void UpdateEditMode(HEU_HoudiniAsset asset, int controlID, EventType eve
933917
if (selectedPoints.Count > 0)
934918
{
935919
SerializedObject serializedCurve = GetOrCreateSerializedCurve(curvePoints.Key);
936-
SerializedProperty curveNodesProperty = serializedCurve.FindProperty("_curveNodeData");
937-
938920
HEU_Curve curve = serializedCurve.targetObject as HEU_Curve;
939921
handleRotation = Quaternion.Euler(curve.CurveNodeData[selectedPoints[0]].rotation);
940922
handleScale = curve.CurveNodeData[selectedPoints[0]].scale;
@@ -1093,7 +1075,7 @@ private void UpdateEditMode(HEU_HoudiniAsset asset, int controlID, EventType eve
10931075
HEU_Curve.CurveEditState editState = (HEU_Curve.CurveEditState)stateProperty.intValue;
10941076

10951077
// On mouse release, transition editing curve to generation state
1096-
if (!isDraggingPoints || (isDraggingPoints && cookWhileDragging))
1078+
if (!isDraggingPoints)
10971079
{
10981080
if (editState == HEU_Curve.CurveEditState.EDITING)
10991081
{

Plugins/HoudiniEngineUnity/Scripts/Asset/HEU_Curve.cs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ namespace HoudiniEngineUnity
5555
public class CurveNodeData : IEquivable<CurveNodeData>
5656
{
5757
[SerializeField] public Vector3 position = Vector3.zero;
58-
5958
[SerializeField] public Vector3 rotation = Vector3.zero;
60-
6159
[SerializeField] public Vector3 scale = Vector3.one;
6260

6361
// The index of the curve that this node belongs to
@@ -211,23 +209,16 @@ public GameObject TargetGameObject
211209

212210
// DATA -------------------------------------------------------------------------------------------------------
213211

214-
[SerializeField] private HAPI_NodeId _geoID;
215-
216-
217-
[SerializeField] private HAPI_NodeId _partID;
212+
[System.NonSerialized] private HAPI_NodeId _geoID = HEU_Defines.HEU_INVALID_NODE_ID;
213+
[System.NonSerialized] private HAPI_NodeId _partID;
218214

219215

220216
[SerializeField] private List<CurveNodeData> _curveNodeData = new List<CurveNodeData>();
221217

222218

223219
[SerializeField] private Vector3[] _vertices;
224-
225220
[SerializeField] private bool _isEditable;
226-
227-
228221
[SerializeField] private HEU_Parameters _parameters;
229-
230-
231222
[SerializeField] private bool _bUploadParameterPreset;
232223

233224
internal void SetUploadParameterPreset(bool bValue)
@@ -236,10 +227,7 @@ internal void SetUploadParameterPreset(bool bValue)
236227
}
237228

238229
[SerializeField] private string _curveName;
239-
240-
241230
[SerializeField] private GameObject _targetGameObject;
242-
243231
[SerializeField] private bool _isGeoCurve;
244232

245233

@@ -282,9 +270,7 @@ internal enum CurveDrawCollision
282270
// Variables dealing with part curves
283271

284272
[SerializeField] private bool _bIsPartCurve = true;
285-
286273
[SerializeField] private bool _cachedCurveInfoValid = false;
287-
288274
[SerializeField] private int[] _cachedCurveCounts = null;
289275

290276

@@ -326,6 +312,16 @@ public void Recook()
326312
}
327313
}
328314

315+
public void Rebuild()
316+
{
317+
SetEditState(CurveEditState.INVALID);
318+
319+
if (_parentAsset != null)
320+
{
321+
_parentAsset.RequestReload();
322+
}
323+
}
324+
329325
/// <inheritdoc />
330326
public bool IsEditable()
331327
{

Plugins/HoudiniEngineUnity/Scripts/Asset/HEU_HoudiniAsset.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ internal HEU_AssetType AssetTypeInternal
454454

455455
[SerializeField] private string _assetHelp;
456456

457-
[SerializeField] private HAPI_NodeId _assetID = HEU_Defines.HEU_INVALID_NODE_ID;
457+
[System.NonSerialized] private HAPI_NodeId _assetID = HEU_Defines.HEU_INVALID_NODE_ID;
458458

459459
[SerializeField] private string _assetPath;
460460

@@ -1921,6 +1921,16 @@ private void Awake()
19211921
HEU_Logger.LogWarning("Undoing a deleted HDA may also remove its parameter undo stack.");
19221922
RequestReload(false);
19231923
}
1924+
1925+
// If there are curves they need to be cooked.
1926+
if (Curves != null)
1927+
{
1928+
foreach (var curve in Curves)
1929+
{
1930+
curve.Rebuild();
1931+
}
1932+
}
1933+
19241934
#endif
19251935
}
19261936

@@ -2782,7 +2792,7 @@ private bool InternalStartRecook(bool bCheckParamsChanged,
27822792
}
27832793
}
27842794

2785-
if (!bCookingSessionSync)
2795+
if (!bCookingSessionSync || true)
27862796
{
27872797
// Only upload the following if we are not cooking as a result of SessionSync
27882798
// i.e. Houdini already cook so no need to upload our own
@@ -2798,11 +2808,12 @@ private bool InternalStartRecook(bool bCheckParamsChanged,
27982808
}
27992809
else
28002810
{
2801-
// Otherwise curves should upload their parameters
2802-
UploadCurvesParameters(session, bCheckParamsChanged);
28032811
}
28042812
}
28052813

2814+
// Otherwise curves should upload their parameters
2815+
UploadCurvesParameters(session, bCheckParamsChanged);
2816+
28062817
// Upload attributes. For edit nodes, this will be a cumulative update. So if the source geo has
28072818
// changed earlier in the graph, it will most likely be ignored here since the edit node has its own
28082819
// version of the geo with custom attributes. The only way to resolve it would be to blow away the custom

Plugins/HoudiniEngineUnity/Scripts/Parameters/HEU_Parameters.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,12 @@ public List<HEU_ParameterModifier> ParameterModifiers
8383

8484
// DATA ------------------------------------------------------------------------------------------------------
8585

86-
[SerializeField] private HAPI_NodeId _nodeID;
86+
[System.NonSerialized] private HAPI_NodeId _nodeID = HEU_Defines.HEU_INVALID_NODE_ID;
8787

8888
[SerializeField] internal string _uiLabel = "ASSET PARAMETERS";
8989

9090
[SerializeField] private int[] _paramInts;
91-
9291
[SerializeField] private float[] _paramFloats;
93-
9492
[SerializeField] private string[] _paramStrings;
9593

9694
[SerializeField] private HAPI_ParmChoiceInfo[] _paramChoices;

0 commit comments

Comments
 (0)