Properly initialize animation player when loading a scene.
This commit is contained in:
parent
f07b54e42b
commit
14329e606e
@ -149,7 +149,7 @@ void BLTAnimationGraph::_notification(int p_what) {
|
|||||||
GodotProfileZone("SyncedAnimationGraph::_notification");
|
GodotProfileZone("SyncedAnimationGraph::_notification");
|
||||||
|
|
||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
case Node::NOTIFICATION_READY: {
|
case NOTIFICATION_ENTER_TREE: {
|
||||||
_setup_evaluation_context();
|
_setup_evaluation_context();
|
||||||
_setup_graph();
|
_setup_graph();
|
||||||
|
|
||||||
@ -234,16 +234,9 @@ AnimationMixer::AnimationCallbackModeDiscrete BLTAnimationGraph::get_callback_mo
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BLTAnimationGraph::set_animation_player(const NodePath &p_path) {
|
void BLTAnimationGraph::set_animation_player(const NodePath &p_path) {
|
||||||
animation_player_path = p_path;
|
print_line(vformat("set_animation_player(%s) ", p_path));
|
||||||
if (p_path.is_empty()) {
|
|
||||||
// set_root_node(SceneStringName(path_pp));
|
|
||||||
// while (animation_libraries.size()) {
|
|
||||||
// remove_animation_library(animation_libraries[0].name);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
graph_context.animation_player = Object::cast_to<AnimationPlayer>(get_node_or_null(animation_player_path));
|
|
||||||
|
|
||||||
print_line(vformat("Setting animation player of graph %x to %x", (uintptr_t)(this), (uintptr_t)graph_context.animation_player));
|
animation_player_path = p_path;
|
||||||
|
|
||||||
_setup_evaluation_context();
|
_setup_evaluation_context();
|
||||||
_setup_graph();
|
_setup_graph();
|
||||||
@ -279,14 +272,9 @@ Ref<BLTAnimationNode> BLTAnimationGraph::get_root_animation_node() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BLTAnimationGraph::set_skeleton(const NodePath &p_path) {
|
void BLTAnimationGraph::set_skeleton(const NodePath &p_path) {
|
||||||
|
print_line(vformat("set_skeleton(%s) ", p_path));
|
||||||
|
|
||||||
skeleton_path = p_path;
|
skeleton_path = p_path;
|
||||||
if (p_path.is_empty()) {
|
|
||||||
// set_root_node(SceneStringName(path_pp));
|
|
||||||
// while (animation_libraries.size()) {
|
|
||||||
// remove_animation_library(animation_libraries[0].name);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
graph_context.skeleton_3d = Object::cast_to<Skeleton3D>(get_node_or_null(skeleton_path));
|
|
||||||
|
|
||||||
_setup_evaluation_context();
|
_setup_evaluation_context();
|
||||||
_setup_graph();
|
_setup_graph();
|
||||||
@ -365,11 +353,20 @@ void BLTAnimationGraph::_set_process(bool p_process, bool p_force) {
|
|||||||
processing = p_process;
|
processing = p_process;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BLTAnimationGraph::_setup_animation_player() {
|
||||||
|
if (!is_inside_tree()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
graph_context.animation_player = Object::cast_to<AnimationPlayer>(get_node_or_null(animation_player_path));
|
||||||
|
print_line(vformat("AnimationPlayer of graph %x is now %x", (uintptr_t)(this), (uintptr_t)graph_context.animation_player));
|
||||||
|
}
|
||||||
|
|
||||||
void BLTAnimationGraph::_setup_evaluation_context() {
|
void BLTAnimationGraph::_setup_evaluation_context() {
|
||||||
print_line("_setup_evaluation_context()");
|
print_line("_setup_evaluation_context()");
|
||||||
_cleanup_evaluation_context();
|
_cleanup_evaluation_context();
|
||||||
|
|
||||||
graph_context.animation_player = Object::cast_to<AnimationPlayer>(get_node_or_null(animation_player_path));
|
_setup_animation_player();
|
||||||
graph_context.skeleton_3d = Object::cast_to<Skeleton3D>(get_node_or_null(skeleton_path));
|
graph_context.skeleton_3d = Object::cast_to<Skeleton3D>(get_node_or_null(skeleton_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -76,6 +76,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void _set_process(bool p_process, bool p_force = false);
|
void _set_process(bool p_process, bool p_force = false);
|
||||||
|
|
||||||
|
void _setup_animation_player();
|
||||||
void _setup_evaluation_context();
|
void _setup_evaluation_context();
|
||||||
void _cleanup_evaluation_context();
|
void _cleanup_evaluation_context();
|
||||||
|
|
||||||
|
|||||||
@ -279,6 +279,7 @@ bones/66/position = Vector3(-0.014239848, 6.412128, 0.0079107955)
|
|||||||
active = false
|
active = false
|
||||||
|
|
||||||
[node name="AnimationPlayer2" type="AnimationPlayer" parent="Characters/MixamoAmyWalkRunSynced" unique_id=1255239074]
|
[node name="AnimationPlayer2" type="AnimationPlayer" parent="Characters/MixamoAmyWalkRunSynced" unique_id=1255239074]
|
||||||
|
active = false
|
||||||
libraries/animation_library = ExtResource("3_1bvp3")
|
libraries/animation_library = ExtResource("3_1bvp3")
|
||||||
|
|
||||||
[node name="SyncedAnimationGraph" type="BLTAnimationGraph" parent="Characters/MixamoAmyWalkRunSynced" unique_id=1602406394]
|
[node name="SyncedAnimationGraph" type="BLTAnimationGraph" parent="Characters/MixamoAmyWalkRunSynced" unique_id=1602406394]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user