@@ -4860,7 +4860,7 @@ Error GLTFDocument::_serialize_animations(Ref<GLTFState> p_state) {
48604860 t[" sampler" ] = samplers.size ();
48614861 Dictionary s;
48624862 Vector<real_t > times;
4863- const double increment = 1.0 / BAKE_FPS ;
4863+ const double increment = 1.0 / p_state-> get_bake_fps () ;
48644864 {
48654865 double time = 0.0 ;
48664866 bool last = false ;
@@ -5902,7 +5902,8 @@ T GLTFDocument::_interpolate_track(const Vector<real_t> &p_times, const Vector<T
59025902 ERR_FAIL_V (p_values[0 ]);
59035903}
59045904
5905- void GLTFDocument::_import_animation (Ref<GLTFState> p_state, AnimationPlayer *p_animation_player, const GLTFAnimationIndex p_index, const float p_bake_fps, const bool p_trimming, const bool p_remove_immutable_tracks) {
5905+ void GLTFDocument::_import_animation (Ref<GLTFState> p_state, AnimationPlayer *p_animation_player, const GLTFAnimationIndex p_index, const bool p_trimming, const bool p_remove_immutable_tracks) {
5906+ ERR_FAIL_COND (p_state.is_null ());
59065907 Ref<GLTFAnimation> anim = p_state->animations [p_index];
59075908
59085909 String anim_name = anim->get_name ();
@@ -5914,7 +5915,7 @@ void GLTFDocument::_import_animation(Ref<GLTFState> p_state, AnimationPlayer *p_
59145915 Ref<Animation> animation;
59155916 animation.instantiate ();
59165917 animation->set_name (anim_name);
5917- animation->set_step (1.0 / p_bake_fps );
5918+ animation->set_step (1.0 / p_state-> get_bake_fps () );
59185919
59195920 if (anim->get_loop ()) {
59205921 animation->set_loop_mode (Animation::LOOP_LINEAR);
@@ -6081,7 +6082,7 @@ void GLTFDocument::_import_animation(Ref<GLTFState> p_state, AnimationPlayer *p_
60816082 }
60826083 }
60836084
6084- const double increment = 1.0 / p_bake_fps ;
6085+ const double increment = 1.0 / p_state-> get_bake_fps () ;
60856086 double time = anim_start;
60866087
60876088 Vector3 base_pos;
@@ -6158,7 +6159,7 @@ void GLTFDocument::_import_animation(Ref<GLTFState> p_state, AnimationPlayer *p_
61586159 }
61596160 } else {
61606161 // CATMULLROMSPLINE or CUBIC_SPLINE have to be baked, apologies.
6161- const double increment = 1.0 / p_bake_fps ;
6162+ const double increment = 1.0 / p_state-> get_bake_fps () ;
61626163 double time = 0.0 ;
61636164 bool last = false ;
61646165 while (true ) {
@@ -6372,7 +6373,7 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> p_sta
63726373 p_track.scale_track .times .clear ();
63736374 p_track.scale_track .values .clear ();
63746375 // CATMULLROMSPLINE or CUBIC_SPLINE have to be baked, apologies.
6375- const double increment = 1.0 / BAKE_FPS ;
6376+ const double increment = 1.0 / p_state-> get_bake_fps () ;
63766377 double time = 0.0 ;
63776378 bool last = false ;
63786379 while (true ) {
@@ -6407,7 +6408,7 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> p_sta
64076408 p_track.position_track .times .clear ();
64086409 p_track.position_track .values .clear ();
64096410 // CATMULLROMSPLINE or CUBIC_SPLINE have to be baked, apologies.
6410- const double increment = 1.0 / BAKE_FPS ;
6411+ const double increment = 1.0 / p_state-> get_bake_fps () ;
64116412 double time = 0.0 ;
64126413 bool last = false ;
64136414 while (true ) {
@@ -6442,7 +6443,7 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> p_sta
64426443 p_track.rotation_track .times .clear ();
64436444 p_track.rotation_track .values .clear ();
64446445 // CATMULLROMSPLINE or CUBIC_SPLINE have to be baked, apologies.
6445- const double increment = 1.0 / BAKE_FPS ;
6446+ const double increment = 1.0 / p_state-> get_bake_fps () ;
64466447 double time = 0.0 ;
64476448 bool last = false ;
64486449 while (true ) {
@@ -6482,7 +6483,7 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> p_sta
64826483 p_track.position_track .times .clear ();
64836484 p_track.position_track .values .clear ();
64846485 // CATMULLROMSPLINE or CUBIC_SPLINE have to be baked, apologies.
6485- const double increment = 1.0 / BAKE_FPS ;
6486+ const double increment = 1.0 / p_state-> get_bake_fps () ;
64866487 double time = 0.0 ;
64876488 bool last = false ;
64886489 while (true ) {
@@ -6515,7 +6516,7 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> p_sta
65156516 p_track.rotation_track .times .clear ();
65166517 p_track.rotation_track .values .clear ();
65176518 // CATMULLROMSPLINE or CUBIC_SPLINE have to be baked, apologies.
6518- const double increment = 1.0 / BAKE_FPS ;
6519+ const double increment = 1.0 / p_state-> get_bake_fps () ;
65196520 double time = 0.0 ;
65206521 bool last = false ;
65216522 while (true ) {
@@ -6551,7 +6552,7 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> p_sta
65516552 p_track.scale_track .times .clear ();
65526553 p_track.scale_track .values .clear ();
65536554 // CATMULLROMSPLINE or CUBIC_SPLINE have to be baked, apologies.
6554- const double increment = 1.0 / BAKE_FPS ;
6555+ const double increment = 1.0 / p_state-> get_bake_fps () ;
65556556 double time = 0.0 ;
65566557 bool last = false ;
65576558 while (true ) {
@@ -6577,14 +6578,14 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> p_sta
65776578 }
65786579 }
65796580 } else if (track_type == Animation::TYPE_BEZIER) {
6580- const int32_t keys = anim_end * BAKE_FPS ;
6581+ const int32_t keys = anim_end * p_state-> get_bake_fps () ;
65816582 if (path.contains (" :scale" )) {
65826583 if (!p_track.scale_track .times .size ()) {
65836584 p_track.scale_track .interpolation = gltf_interpolation;
65846585 Vector<real_t > new_times;
65856586 new_times.resize (keys);
65866587 for (int32_t key_i = 0 ; key_i < keys; key_i++) {
6587- new_times.write [key_i] = key_i / BAKE_FPS ;
6588+ new_times.write [key_i] = key_i / p_state-> get_bake_fps () ;
65886589 }
65896590 p_track.scale_track .times = new_times;
65906591
@@ -6597,11 +6598,11 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> p_sta
65976598 for (int32_t key_i = 0 ; key_i < keys; key_i++) {
65986599 Vector3 bezier_track = p_track.scale_track .values [key_i];
65996600 if (path.contains (" :scale:x" )) {
6600- bezier_track.x = p_animation->bezier_track_interpolate (p_track_i, key_i / BAKE_FPS );
6601+ bezier_track.x = p_animation->bezier_track_interpolate (p_track_i, key_i / p_state-> get_bake_fps () );
66016602 } else if (path.contains (" :scale:y" )) {
6602- bezier_track.y = p_animation->bezier_track_interpolate (p_track_i, key_i / BAKE_FPS );
6603+ bezier_track.y = p_animation->bezier_track_interpolate (p_track_i, key_i / p_state-> get_bake_fps () );
66036604 } else if (path.contains (" :scale:z" )) {
6604- bezier_track.z = p_animation->bezier_track_interpolate (p_track_i, key_i / BAKE_FPS );
6605+ bezier_track.z = p_animation->bezier_track_interpolate (p_track_i, key_i / p_state-> get_bake_fps () );
66056606 }
66066607 p_track.scale_track .values .write [key_i] = bezier_track;
66076608 }
@@ -6612,7 +6613,7 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> p_sta
66126613 Vector<real_t > new_times;
66136614 new_times.resize (keys);
66146615 for (int32_t key_i = 0 ; key_i < keys; key_i++) {
6615- new_times.write [key_i] = key_i / BAKE_FPS ;
6616+ new_times.write [key_i] = key_i / p_state-> get_bake_fps () ;
66166617 }
66176618 p_track.position_track .times = new_times;
66186619
@@ -6622,11 +6623,11 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> p_sta
66226623 for (int32_t key_i = 0 ; key_i < keys; key_i++) {
66236624 Vector3 bezier_track = p_track.position_track .values [key_i];
66246625 if (path.contains (" :position:x" )) {
6625- bezier_track.x = p_animation->bezier_track_interpolate (p_track_i, key_i / BAKE_FPS );
6626+ bezier_track.x = p_animation->bezier_track_interpolate (p_track_i, key_i / p_state-> get_bake_fps () );
66266627 } else if (path.contains (" :position:y" )) {
6627- bezier_track.y = p_animation->bezier_track_interpolate (p_track_i, key_i / BAKE_FPS );
6628+ bezier_track.y = p_animation->bezier_track_interpolate (p_track_i, key_i / p_state-> get_bake_fps () );
66286629 } else if (path.contains (" :position:z" )) {
6629- bezier_track.z = p_animation->bezier_track_interpolate (p_track_i, key_i / BAKE_FPS );
6630+ bezier_track.z = p_animation->bezier_track_interpolate (p_track_i, key_i / p_state-> get_bake_fps () );
66306631 }
66316632 p_track.position_track .values .write [key_i] = bezier_track;
66326633 }
@@ -6636,7 +6637,7 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> p_sta
66366637 Vector<real_t > new_times;
66376638 new_times.resize (keys);
66386639 for (int32_t key_i = 0 ; key_i < keys; key_i++) {
6639- new_times.write [key_i] = key_i / BAKE_FPS ;
6640+ new_times.write [key_i] = key_i / p_state-> get_bake_fps () ;
66406641 }
66416642 p_track.rotation_track .times = new_times;
66426643
@@ -6645,13 +6646,13 @@ GLTFAnimation::Track GLTFDocument::_convert_animation_track(Ref<GLTFState> p_sta
66456646 for (int32_t key_i = 0 ; key_i < keys; key_i++) {
66466647 Quaternion bezier_track = p_track.rotation_track .values [key_i];
66476648 if (path.contains (" :rotation:x" )) {
6648- bezier_track.x = p_animation->bezier_track_interpolate (p_track_i, key_i / BAKE_FPS );
6649+ bezier_track.x = p_animation->bezier_track_interpolate (p_track_i, key_i / p_state-> get_bake_fps () );
66496650 } else if (path.contains (" :rotation:y" )) {
6650- bezier_track.y = p_animation->bezier_track_interpolate (p_track_i, key_i / BAKE_FPS );
6651+ bezier_track.y = p_animation->bezier_track_interpolate (p_track_i, key_i / p_state-> get_bake_fps () );
66516652 } else if (path.contains (" :rotation:z" )) {
6652- bezier_track.z = p_animation->bezier_track_interpolate (p_track_i, key_i / BAKE_FPS );
6653+ bezier_track.z = p_animation->bezier_track_interpolate (p_track_i, key_i / p_state-> get_bake_fps () );
66536654 } else if (path.contains (" :rotation:w" )) {
6654- bezier_track.w = p_animation->bezier_track_interpolate (p_track_i, key_i / BAKE_FPS );
6655+ bezier_track.w = p_animation->bezier_track_interpolate (p_track_i, key_i / p_state-> get_bake_fps () );
66556656 }
66566657 p_track.rotation_track .values .write [key_i] = bezier_track;
66576658 }
@@ -7305,6 +7306,7 @@ Node *GLTFDocument::generate_scene(Ref<GLTFState> p_state, float p_bake_fps, boo
73057306 ERR_FAIL_NULL_V (state, nullptr );
73067307 ERR_FAIL_INDEX_V (0 , state->root_nodes .size (), nullptr );
73077308 Error err = OK;
7309+ p_state->set_bake_fps (p_bake_fps);
73087310 Node *root = _generate_scene_node_tree (state);
73097311 ERR_FAIL_NULL_V (root, nullptr );
73107312 _process_mesh_instances (state, root);
@@ -7313,7 +7315,7 @@ Node *GLTFDocument::generate_scene(Ref<GLTFState> p_state, float p_bake_fps, boo
73137315 root->add_child (ap, true );
73147316 ap->set_owner (root);
73157317 for (int i = 0 ; i < state->animations .size (); i++) {
7316- _import_animation (state, ap, i, p_bake_fps, p_trimming, p_remove_immutable_tracks);
7318+ _import_animation (state, ap, i, p_trimming, p_remove_immutable_tracks);
73177319 }
73187320 }
73197321 for (KeyValue<GLTFNodeIndex, Node *> E : state->scene_nodes ) {
0 commit comments