-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[Impeller Scene] Change how property resolution works to fix Animation blending; add mutation log to nodes; enable backface culling; add vertex color contribution back to meshes #38766
Changes from 1 commit
12f436f
507d39e
5f75ed8
da70260
f430cb5
84fc9ee
55bb771
ffc3666
ae9e48d
942635b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,9 @@ | |
|
||
#pragma once | ||
|
||
#include <map> | ||
#include <memory> | ||
#include <optional> | ||
#include <unordered_map> | ||
#include <vector> | ||
|
||
#include "flutter/fml/hash_combine.h" | ||
|
@@ -29,9 +29,11 @@ class AnimationPlayer final { | |
AnimationPlayer(AnimationPlayer&&); | ||
AnimationPlayer& operator=(AnimationPlayer&&); | ||
|
||
AnimationClip& AddAnimation(std::shared_ptr<Animation> animation, | ||
AnimationClip* AddAnimation(const std::shared_ptr<Animation>& animation, | ||
Node* bind_target); | ||
|
||
AnimationClip* GetClip(const std::string& name); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing const correctness here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
|
||
/// @brief Advanced all clips and updates animated properties in the scene. | ||
void Update(); | ||
|
||
|
@@ -41,7 +43,7 @@ class AnimationPlayer final { | |
private: | ||
std::unordered_map<Node*, Matrix> default_target_transforms_; | ||
|
||
std::vector<AnimationClip> clips_; | ||
std::map<std::string, AnimationClip> clips_; | ||
|
||
std::optional<TimePoint> previous_time_; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
#pragma once | ||
|
||
#include <memory> | ||
#include <mutex> | ||
#include <optional> | ||
#include <vector> | ||
|
||
|
@@ -25,6 +26,39 @@ namespace scene { | |
|
||
class Node final { | ||
public: | ||
class MutationLog { | ||
public: | ||
struct SetTransformEntry { | ||
Matrix transform; | ||
}; | ||
|
||
struct SetAnimationStateEntry { | ||
std::string animation_name; | ||
bool playing; | ||
float weight; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
float time_scale; | ||
}; | ||
|
||
struct SeekAnimationEntry { | ||
std::string animation_name; | ||
float time; | ||
}; | ||
|
||
using Entry = std:: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps this just calls for inheritance instead of variants? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm on the fence, but I think that's where it will end up. Will do this in a later patch. |
||
variant<SetTransformEntry, SetAnimationStateEntry, SeekAnimationEntry>; | ||
|
||
void Append(const Entry& entry); | ||
|
||
private: | ||
std::optional<std::vector<Entry>> Flush(); | ||
|
||
bool dirty_ = false; | ||
std::vector<Entry> entries_; | ||
std::mutex write_mutex_; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
|
||
friend Node; | ||
}; | ||
|
||
static std::shared_ptr<Node> MakeFromFlatbuffer( | ||
const fml::Mapping& ipscene_mapping, | ||
Allocator& allocator); | ||
|
@@ -44,7 +78,7 @@ class Node final { | |
bool exclude_animation_players = false) const; | ||
|
||
std::shared_ptr<Animation> FindAnimationByName(const std::string& name) const; | ||
AnimationClip& AddAnimation(const std::shared_ptr<Animation>& animation); | ||
AnimationClip* AddAnimation(const std::shared_ptr<Animation>& animation); | ||
|
||
void SetLocalTransform(Matrix transform); | ||
Matrix GetLocalTransform() const; | ||
|
@@ -63,7 +97,9 @@ class Node final { | |
|
||
bool Render(SceneEncoder& encoder, | ||
Allocator& allocator, | ||
const Matrix& parent_transform) const; | ||
const Matrix& parent_transform); | ||
|
||
void AddMutation(const MutationLog::Entry& entry); | ||
|
||
private: | ||
void UnpackFromFlatbuffer( | ||
|
@@ -72,6 +108,8 @@ class Node final { | |
const std::vector<std::shared_ptr<Texture>>& textures, | ||
Allocator& allocator); | ||
|
||
mutable MutationLog mutation_log_; | ||
|
||
Matrix local_transform_; | ||
|
||
std::string name_; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::map
sinsert
orinsert_or_assign
returns an iterator to element already. So you don't need to insert and then in turn find the inserted element.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.