Skip to content

Commit

Permalink
[animGraph] Added resetSmoothedValues to AnimGraphInstance
Browse files Browse the repository at this point in the history
  • Loading branch information
EspeuteClement committed Jan 31, 2025
1 parent efd8045 commit aa08fef
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hide/view/animgraph/BlendSpace2DEditor.hx
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ class BlendSpace2DEditor extends hide.view.FileView {
}
}
}

updatePreviewAxis();
animPreview.resetSmoothedValues();
}
}

Expand Down
11 changes: 11 additions & 0 deletions hrt/animgraph/AnimGraphInstance.hx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ class AnimGraphInstance extends h3d.anim.Animation {
}
}

/**
Force nodes in the graph that smooth their input over time to match the
current value of their parameters
**/
public function resetSmoothedValues() {
tickRec(rootNode, 0.0);
map(rootNode, (node) -> {
node.resetSmoothedValues();
});
}

override function clone(?target: h3d.anim.Animation) : h3d.anim.Animation {
#if editor
if (editorSkipClone) {
Expand Down
8 changes: 8 additions & 0 deletions hrt/animgraph/Node.hx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ implements hide.view.GraphInterface.IGraphNode

}

/**
Called on the node when AnimGraphInstance.resetSmoothedValues is called
Should reset all the smoothed parameters to their input value OR default values
**/
public function resetSmoothedValues() : Void {

}


// Serialization api

Expand Down
7 changes: 7 additions & 0 deletions hrt/animgraph/nodes/BlendSpace2D.hx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ class BlendSpace2D extends AnimNode {
return {x: eydt * (j0 + j1 * dt) + c, v: eydt *(v - j1*half_damping*dt)};
}

override function resetSmoothedValues() {
realX = bsX;
realY = bsY;
vX = 0.0;
vY = 0.0;
}


override function getBones(ctx: hrt.animgraph.nodes.AnimNode.GetBoneContext):Map<String, Int> {
var boneMap : Map<String, Int> = [];
Expand Down

0 comments on commit aa08fef

Please sign in to comment.