Skip to content

Commit 80c0747

Browse files
Cupiiifreezy
authored andcommitted
CBD2 - reduced number of keypoints in generation of elast./falloff curve, disabled friction if curve is used, populated clear button for friction
1 parent 77b94ad commit 80c0747

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

VisualPinball.Unity/VisualPinball.Unity.Editor/VPT/PhysicsMaterialInspector.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ public override void OnInspectorGUI()
9292
if (GUILayout.Button("Generate from Elasticity & Falloff", GUILayout.Width(220)))
9393
{
9494
ElasticityOverVelocity.animationCurveValue.keys.Initialize();
95-
Keyframe[] keyframes = new Keyframe[64];
95+
Keyframe[] keyframes = new Keyframe[8];
9696
for (int i = 0; i < keyframes.Length; i++)
9797
{
98-
keyframes[i] = new Keyframe(i, Elasticity.floatValue / (1.0f + ElasticityFalloff.floatValue * i / 18.53f));
98+
keyframes[i] = new Keyframe(i*8, Elasticity.floatValue / (1.0f + ElasticityFalloff.floatValue * i*8 / 18.53f));
9999
}
100100
var tempcurve = new AnimationCurve(keyframes);
101101
for (int i = 0; i < keyframes.Length; i++)
@@ -163,13 +163,17 @@ public override void OnInspectorGUI()
163163
EditorGUI.indentLevel--;
164164
EditorGUI.indentLevel++;
165165
GUILayout.Label("Friction");
166+
GUI.enabled = (FrictionOverVelocity.animationCurveValue.keys.Length == 0);
166167
EditorGUILayout.PropertyField(Friction, true);
168+
GUI.enabled = true;
167169
EditorGUILayout.PropertyField(FrictionOverVelocity, new GUIContent("Friction / Velocity"), true);
168170
GUILayout.BeginHorizontal();
169171
GUILayout.FlexibleSpace();
170172
if (GUILayout.Button("Clear (don't use)", GUILayout.Width(220)))
171173
{
172-
174+
FrictionOverVelocity.animationCurveValue.keys.Initialize();
175+
FrictionOverVelocity.animationCurveValue = new AnimationCurve();
176+
FrictionOverVelocity.serializedObject.ApplyModifiedProperties();
173177
}
174178
GUILayout.EndHorizontal();
175179
/*

0 commit comments

Comments
 (0)