diff options
author | reduz <reduzio@gmail.com> | 2021-10-15 19:04:35 -0300 |
---|---|---|
committer | reduz <reduzio@gmail.com> | 2021-10-16 08:36:05 -0300 |
commit | ae1c0165472181967b01ee7bc0087456611d26bf (patch) | |
tree | 5ba9e3cf3d28977737693b0f0a39506ff12c5c19 /scene/resources/animation.h | |
parent | 96410f55b24e47af045e3ad31545331ce124d999 (diff) |
Implement Animation Blend Shape Tracks
* New track type BLEND_SHAPE
* Blend shapes are imported via this new track type
* Processing is more optimized (no longer relies on variants)
* Modified the Blend Shape API in MeshInstance3D to use indices rather than StringNames (more optimizes)
* Promo: Fixed a small bug in gizmo updating in Node3D that affected performance
Dedicated BlendShape tracks are required for both optimization and eventually implementing them in animation compression.
Diffstat (limited to 'scene/resources/animation.h')
-rw-r--r-- | scene/resources/animation.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/scene/resources/animation.h b/scene/resources/animation.h index 614e12a560..4ee0741d87 100644 --- a/scene/resources/animation.h +++ b/scene/resources/animation.h @@ -45,6 +45,7 @@ public: TYPE_POSITION_3D, ///< Position 3D track TYPE_ROTATION_3D, ///< Rotation 3D track TYPE_SCALE_3D, ///< Scale 3D track + TYPE_BLEND_SHAPE, ///< Blend Shape track TYPE_METHOD, ///< Call any method on a specific node. TYPE_BEZIER, ///< Bezier curve TYPE_AUDIO, @@ -91,6 +92,7 @@ private: const int32_t POSITION_TRACK_SIZE = 5; const int32_t ROTATION_TRACK_SIZE = 6; const int32_t SCALE_TRACK_SIZE = 5; + const int32_t BLEND_SHAPE_TRACK_SIZE = 3; /* POSITION TRACK */ @@ -115,6 +117,13 @@ private: ScaleTrack() { type = TYPE_SCALE_3D; } }; + /* BLEND SHAPE TRACK */ + + struct BlendShapeTrack : public Track { + Vector<TKey<float>> blend_shapes; + BlendShapeTrack() { type = TYPE_BLEND_SHAPE; } + }; + /* PROPERTY VALUE TRACK */ struct ValueTrack : public Track { @@ -247,10 +256,12 @@ private: bool _position_track_optimize_key(const TKey<Vector3> &t0, const TKey<Vector3> &t1, const TKey<Vector3> &t2, real_t p_alowed_linear_err, real_t p_allowed_angular_error, const Vector3 &p_norm); bool _rotation_track_optimize_key(const TKey<Quaternion> &t0, const TKey<Quaternion> &t1, const TKey<Quaternion> &t2, real_t p_allowed_angular_error, float p_max_optimizable_angle); bool _scale_track_optimize_key(const TKey<Vector3> &t0, const TKey<Vector3> &t1, const TKey<Vector3> &t2, real_t p_allowed_linear_error); + bool _blend_shape_track_optimize_key(const TKey<float> &t0, const TKey<float> &t1, const TKey<float> &t2, real_t p_allowed_unit_error); void _position_track_optimize(int p_idx, real_t p_allowed_linear_err, real_t p_allowed_angular_err); void _rotation_track_optimize(int p_idx, real_t p_allowed_angular_err, real_t p_max_optimizable_angle); void _scale_track_optimize(int p_idx, real_t p_allowed_linear_err); + void _blend_shape_track_optimize(int p_idx, real_t p_allowed_unit_error); protected: bool _set(const StringName &p_name, const Variant &p_value); @@ -308,6 +319,10 @@ public: Error scale_track_get_key(int p_track, int p_key, Vector3 *r_scale) const; Error scale_track_interpolate(int p_track, double p_time, Vector3 *r_interpolation) const; + int blend_shape_track_insert_key(int p_track, double p_time, float p_blend); + Error blend_shape_track_get_key(int p_track, int p_key, float *r_blend) const; + Error blend_shape_track_interpolate(int p_track, double p_time, float *r_blend) const; + void track_set_interpolation_type(int p_track, InterpolationType p_interp); InterpolationType track_get_interpolation_type(int p_track) const; |