-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
Expose AnimationNode::get_animation_tree()
to GDScript.
#6966
Expose AnimationNode::get_animation_tree()
to GDScript.
#6966
Comments
@TokageItLab thoughts on exposing get animation tree? |
Having a reference from a A similar issue has been raised several times before. See also godotengine/godot#23629 (comment). An These resources have a reference to the Exposing internal variable in the process for gdscript is never happen without a fundamental change in the current If you really want to use it, you can create a class that extends |
BTW, for this use case, you could propose something like a blackboard system (like godotengine/godot#61680 but that PR has many problems so you need to rewrite it from zero) or an alias feature. |
Maybe implement this solution is better, or just add new property Then add and expose this methods to
Instead of get |
I don't recommend setting the path string to the AnimationNode. Instead, I remember that in a previous discussion with @SaracenOne, we talked about the ability to have a Map with a type in the property of the AnimationTree and make the AnimationNode get the value of the AnimationTree's Map. |
You may misunderstand my purpose. The The usage in GDScript may like this.
If this is implemented, user can use cast |
Extending AnimationNode to interrupt the process is clearly not for general users and it is never versatile. |
(Note you can just write |
Of course not for general users, this only for user who need create a complicated AnimationTree. Usually we use single script attach to Currently, we can only control animation logic outside the AnimationTree(except AnimationStateMachine) and must use parameter path to set parameters. If the graph of By extends In other word, this proposal is aim at Improving maintainability of animation system. |
No, rather exposing internal variables means less maintainability. This is because when the processing of internal variables is changed, it provides a breakdown in compatibility for users who utilize them. I recognize that you have a tendency to carelessly expose internal variables, please focus on safe and versatile API proposals that are consistent with actual use cases. |
Not internal variable. The |
You used expression_base as an example. But it needs to be passed to the AnimationNode by the AnimationTree and should not be set arbitrarily by the user to the AnimationNode. By "internal" I mean that "the user should not access". |
A new and independent property named "base_node", only used for this purpose, not participate in any internal logic. Please look close into my comments. |
I already understood. The advance_expression_base_node is a property of the AnimationTree, not the AnimationNode. In order to use it from the AnimationNode you would need to get the AnimationTree from the AnimationNode or expose the internal variables of the AnimationNode, which is not allowed due to the safety issues mentioned above. |
Do you mean that
|
The set/get parameter is done for the AnimationTree, not the AnimationNode. The AnimationNode then internally fetches and processes those values from the AnimationTree (then, the values are never permanently stored in the AnimationNode). The user does not have access to the AnimationNode's internal variables. In other words, you can implement an interface to the AnimationTree, but it is not allowed to access variables inside the AnimationNode that may be updated during the process. |
Like I said before, AnimationTree only hold the reference of If it is not allow |
We can allow base_nodes to be implemented in AnimationTree. However, we do not allow AnimationNode to expose the fetched base_node. The extended AnimationNode is intended to be used to create AnimationNodes for example, mathematical processes such as Add4 and Sub3, or seeking processes such as ChangeFPS, using the |
If the AnimationNode can correctly fetch information from the AnimationTree and process it, then there is no need for the user to fetch the AnimationTree again in the AnimationNode.
For example, in this use case, we would have a Next, prepare an interface like Then, if there are multiple players, simply write code like Footnotes
|
This still doesn't solve the code bloat of control logic (the part of "interface" in your comment). I still believe that my solution is safe for internal process, more flexible for users, less over design for core animation system. In my opinion, it is more elegent that implementing specific control logic in specific AnimationNode, but this is vialot current AnimationNode design principle. Anyway, for this proposal, I will not implement and request to be merged. Waiting for others to express their opinions. |
To implement a user-friendly interface, the code is always a bit cumbersome in the core/editor so that is acceptable. I can assure that exposing the code for internal processes in AnimationNode is outside the current design of AnimationTree, and should not be done for the sake of system stability or future compatibility issues. It may be flexible for you, but it exposes an unsafe variable to the user and imposes an esoteric code implementation on the user. Instead, it is important to implement the elements that are minimally necessary for the actual use case that makes it easier for the common users. |
If you really need to get a pointer to an Also, in that case, it would be necessary to remove This should probably work, but some testing needs to be done to see if it can handle multiple AnimationTrees, NestedAnimationStateMachine, and multi-threading. |
Although this clearify that "this Given the previous discussion, I prefer to hide the "processing tree", only pass the "base_node" ( the new property referenced by |
Although GDVIRTUAL unfortunately ignores const declarations, so users may delete p_tree, but at least it does not directly reference AnimationNode's internal variables. This means that refactoring is needed to ensure tree consistency within _process() first, since the current design may assign trees outside of _process(). I also can't see the point of you wanting to go to the hassle of having a new property called base_node. Once you know which tree to fetch correctly, you can just create a class extending AnimationTree in GDScript and implement whatever variables you want in it. |
I don't know how do you define "the border of danger". If the passed By passing a object which is responsible by user self, user can't access any internal variable and the processing tree, and realize the internal safety. If this is violate animation system design principle, we don't need to argue about this proposal, just discard it. |
I am simply saying that those internal variables should not be accessible from outside of AnimationNode. You should learn the principles of encapsulation, and do pondering why it is undesirable to send the PR "Expose XXX" carelessly, compared to implementing a secure API. The availability of So we first refactor the internal If The core will never update the |
What I want to say is not matter how to encapsulate, how to implemt this proposal elegent, how to make it internal safety, is a maintainability question. You should clearify the fact that, If we not change the current AnimationTree logic and change the ability of AnimaitionNode, not matter how to provide a way to access the parocssing AnimationTree, AnimaitionNode only hold the referenced of specify AnimationTree during If you think provide tree is dangurous, I put forward that provide a independence object which is referenced by the tree. Before we solve follow problems, talking about how to implement internal safety is nonsense.
I have no right to decide on these, my conclusion is that if you allow provide the tree to users, of course, I agree your implementation. |
It is possible to serve the way to retrieve the tree to the user in the way I have described above. There is already a similar implementation called However, since that function currently raises concerns about its ability to support multi-threading, perhaps passing an
A user who is not aware of safety may not be able to distinguish it from exposing an internal variable, but "allowing an external object to access an |
Describe the project you are working on
Creating a complicated AnimationTree.
Describe the problem or limitation you are having in your project
For
AnimationNodeStateMachine
, we can set advance expression for transitions. to avoid setting parameters.For
AnimationNodeBlendTree
, we can only set parameters to control the logic with a long parameter's path.Describe the feature / enhancement and how it helps to overcome the problem or limitation
By exposing
AnimationNode::get_animation_tree()
, we can extendAnimationNode
to control it's parameters by overridingAnimationNode::_process()
, instead of set parameters with a long path, and seperate contol logic to differentAnimationNode
s, avoiding code bloat of a single script.Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Just bind
AnimationNode::get_animation_tree()
in_bind_methods()
.==============================================================
Another solution:
The principle is get the main object which is related to specific animation tree.
Instead of getting animation tree, we can get the main object directly.
What I want to say is rename
AnimationTree
's propertyadvance_expression_base_node
tologic_base_node
orbase_node
, then implementAnimationNode::get_base_node()
to getbase_node
.If this enhancement will not be used often, can it be worked around with a few lines of script?
Obviously it is impossible and unreasonable.
Is there a reason why this should be core and not an add-on in the asset library?
Same as above.
The text was updated successfully, but these errors were encountered: