Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Anim Component] Fix for the normalizeWeights property #4203

Merged
merged 3 commits into from
Apr 20, 2022

Conversation

ellthompson
Copy link
Contributor

@ellthompson ellthompson commented Apr 20, 2022

Previously when setting the normalizeWeights property, the state graph was reset in order to unbind any dirty targets it contained. This PR moves the target unbinding to its own function so that the normalizeWeights setter can call it directly. It also removes the resetStateGraph function which is no longer necessary.

Fixes #4189

I confirm I have read the contributing guidelines and signed the Contributor License Agreement.

@ellthompson ellthompson added bug area: animation Animation related issue labels Apr 20, 2022
@ellthompson ellthompson self-assigned this Apr 20, 2022
// clear all targets from previous binding
this._targets = {};
}

resetStateGraph() {
const assetId = this._stateGraphAsset;
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this tested against the model component when it isn't playing?

this.removeStateGraph();
if (this.stateGraphAsset) {
if (assetId) {
const stateGraph = this.system.app.assets.get(this.stateGraphAsset).resource;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const stateGraph = this.system.app.assets.get(this.stateGraphAsset).resource;
const stateGraph = this.system.app.assets.get(assetId).resource;

Should this be assetId instead?

@@ -475,6 +474,14 @@ class AnimComponent extends Component {
}
}

unbind() {
if (!this._normalizeWeights) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Given the function name unbind, it would imply it would unbind regardless of _normalizeWeights. Do we want the if check here or in the setter of normalizeWeights?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We'd want this check any time unbind is called (currently changing the normalizeWeights property or removing the state graph).

if (this.stateGraphAsset) {
const stateGraph = this.system.app.assets.get(this.stateGraphAsset).resource;
if (assetId) {
const stateGraph = this.system.app.assets.get(assetId).resource;
this.loadStateGraph(stateGraph);
Copy link
Contributor

Choose a reason for hiding this comment

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

_stateGraphAsset is still null after this call. Should we set this prior to the call?

Copy link
Contributor

@yaustar yaustar left a comment

Choose a reason for hiding this comment

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

LGTM

@ellthompson ellthompson merged commit e6d3994 into main Apr 20, 2022
@ellthompson ellthompson deleted the normalize-weights-fix branch April 20, 2022 16:59
slimbuck pushed a commit that referenced this pull request Apr 21, 2022
* fix for the normalizeWeights anim component property
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: animation Animation related issue bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[1.53.0] Setting anim normalizeWeights to true means that the base animation layer cannot be found
2 participants