-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Array curve #1724
base: master
Are you sure you want to change the base?
Array curve #1724
Conversation
libopenage/curve/array.h
Outdated
// std::array<Keyframe<T>, size> get_all(const time::time_t& t, const size_t hint) const; | ||
|
||
|
||
size_t size() const; |
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.
You can make this method constexpr
since it returns Size
which is known at compile time.
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.
Maybe you can even make it consteval
but I think that doesn't work on class methods.
libopenage/curve/CMakeLists.txt
Outdated
@@ -12,6 +12,7 @@ add_sources(libopenage | |||
queue.cpp | |||
queue_filter_iterator.cpp | |||
segmented.cpp | |||
array.cpp |
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.
the list of files should be sorted alphabetically
libopenage/curve/array.cpp
Outdated
@@ -0,0 +1,10 @@ | |||
// Copyright 2017-2024 the openage authors. See copying.md for legal info. |
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.
The copyright year format is {created}-{last changed}
. Since you created the file in 2024, it should be 2024-2024
libopenage/curve/array.h
Outdated
@@ -0,0 +1,159 @@ | |||
// Copyright 2017-2024 the openage authors. See copying.md for legal info. |
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.
// Copyright 2017-2024 the openage authors. See copying.md for legal info. | |
// Copyright 2024-2024 the openage authors. See copying.md for legal info. | |
libopenage/curve/array.h
Outdated
|
||
size_t size() const; | ||
|
||
const Keyframe<T> &frame(const time::time_t &t, const size_t index) const; |
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.
You should never expose Keyframe references directly. The reasoning here is that a Keyframe may be dumped to file or deleted for optimization purposes over time. Therefore, you should return a pair instead, like in
openage/libopenage/curve/base_curve.h
Line 64 in 2b902a9
virtual std::pair<time::time_t, const T> frame(const time::time_t &time) const; |
libopenage/curve/array.h
Outdated
const Keyframe<T> &frame(const time::time_t &t, const size_t index) const; | ||
|
||
|
||
const Keyframe<T> &next_frame(const time::time_t &t, const size_t index) const; |
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.
same here
libopenage/curve/array.h
Outdated
|
||
private: | ||
container_t container; | ||
mutable size_t last_hit_index = 0; |
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.
What is this member supposed to do?
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.
it acts as a hint, for KeyframeContainer operations.
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.
But what is the hit index intended to be used for? From what I can see, it's an index into a KeyframeContainer, but there are Size
KeyframeContainers in the array.
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.
array of hints?
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.
Hmm okay I think I understand now what this is used for. An array of hints (one for each container) would work better, yes.
libopenage/curve/array.h
Outdated
for (int i = 0; i < Size; i++) { | ||
this->container[i].sync(other, start); | ||
} |
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.
If you are iterating through all element, you should use a range-based for-loop.
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.
There was a mistake, here
I forgot to Index other
as well.
3ea0f4a
to
4c2b2f3
Compare
is there any chance array curve should be an array of base curves instead of an array of key frame containers? |
4c2b2f3
to
0b01820
Compare
The base curves would have a bunch of duplicate info that we would want to avoid, e.g. they would all have shared pointer to the event loop, their own IDs, and ID strings. Basically, the curve array container should only have this information once. |
libopenage/curve/array.h
Outdated
namespace curve { | ||
|
||
template <typename T, size_t Size> | ||
class Array { |
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.
the class should inherit from event::EventEntity
like all curve types.
Then the IDs wouldn't be unique which would be a problem for the event system. Since all curves are event entities, duplicating the information would either lead to all contained curves being updated or worse, only one curve being tracked by the event loop. It would also be a waste of space, since we have to store a bunch of redundant data which is what we want to avoid with a dedicated Array class. Also, |
0b01820
to
1d653cd
Compare
79e5549
to
f68ec30
Compare
f68ec30
to
0e637b0
Compare
solves #1678