Skip to content

Fixed bugs in PostNormalizedVectorDrawer#44

Merged
runestubbe merged 1 commit into
masterfrom
property-drawer-fixes
Nov 26, 2018
Merged

Fixed bugs in PostNormalizedVectorDrawer#44
runestubbe merged 1 commit into
masterfrom
property-drawer-fixes

Conversation

@amechtley
Copy link
Copy Markdown
Contributor

  • Fixed exception when drawing control without having called GetPropertyHeight first
  • Apply normalization twice to fix possible precision error (fixes issue where value might be normalized with magnitude slightly less than 1)
  • Fixed bug where stale post-normalized values were applied to property when it was edited from another context (fixes issue where systems could not modify an entity's rotation while it was inspected)
  • Assorted cleanup

- Fixed exception when drawing control without having called GetPropertyHeight first
- Apply normalization twice to fix possible precision error (fixes issue where value might be normalized with magnitude slightly less than 1)
- Fixed bug where stale post-normalized values were applied to property when it was edited from another context (fixes issue where systems could not modify an entity's rotation while it was inspected)
- Assorted cleanup
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var guiData = m_GUIDataPerPropertyPath[property.propertyPath];
var guiData = GetGUIData(property);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call ensures drawing the property works if GetPropertyHeight() has not been called yet

if (string.IsNullOrEmpty(label.tooltip))
label.tooltip = Content.tooltip;

guiData.RebuildIfDirty();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method was added to solve the problem of serialized data getting updated from a different context, and then being overwritten by the pre-normalized data cached by the drawer

sp.serializedObject.ApplyModifiedProperties();
for (var i = 0; i < m_NumElements; ++i)
postNormalizedValue[i] = target.Key.FindPropertyRelative(m_ElementPaths[i]).doubleValue;
postNormalizedValue = normalize(normalize(postNormalizedValue));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double normalization fixes a problem where data were sometimes normalized with values slightly less than 1

@runestubbe runestubbe merged commit ae52f04 into master Nov 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants