Skip to content

Commit

Permalink
curve: Align name of 'sync' for curve and keyframe container.
Browse files Browse the repository at this point in the history
  • Loading branch information
heinezen committed Jul 29, 2023
1 parent d4f78bb commit 75ad418
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
7 changes: 3 additions & 4 deletions doc/code/curves.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,9 @@ for specific curve types.

**Copy**

| Method | Description |
| ---------------------- | ----------------------------------------------------------------------------------------- |
| `sync(Curve, t)` | copy keyframes from `Curve`, starting at time `t`; delete all keyframes after time `t` |
| `sync_after(Curve, t)` | copy keyframes from `Curve`, starting after time `t`; delete all keyframes after time `t` |
| Method | Description |
| ---------------- | -------------------------------------------------------------------------------------- |
| `sync(Curve, t)` | copy keyframes from `Curve`, starting at time `t`; delete all keyframes after time `t` |


#### Discrete
Expand Down
4 changes: 2 additions & 2 deletions libopenage/curve/base_curve.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ template <typename T>
void BaseCurve<T>::sync(const BaseCurve<T> &other,
const time::time_t &start) {
// Copy keyframes between containers for t >= start
this->last_element = this->container.sync_after(other.container, start);
this->last_element = this->container.sync(other.container, start);

// Check if this->get() returns the same value as other->get() for t = start
// If not, insert a new keyframe at start
Expand All @@ -302,7 +302,7 @@ void BaseCurve<T>::sync(const BaseCurve<O> &other,
const std::function<T(const O &)> &converter,
const time::time_t &start) {
// Copy keyframes between containers for t >= start
this->last_element = this->container.sync_after(other.get_container(), converter, start);
this->last_element = this->container.sync(other.get_container(), converter, start);

// Check if this->get() returns the same value as other->get() for t = start
// If not, insert a new keyframe at start
Expand Down
20 changes: 10 additions & 10 deletions libopenage/curve/keyframe_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ class KeyframeContainer {
* Using the default value replaces ALL keyframes of \p this with
* the keyframes of \p other.
*/
iterator sync_after(const KeyframeContainer<T> &other,
const time::time_t &start = std::numeric_limits<time::time_t>::min());
iterator sync(const KeyframeContainer<T> &other,
const time::time_t &start = std::numeric_limits<time::time_t>::min());

/**
* Copy keyframes from another container (with a different element type) to this container.
Expand All @@ -296,9 +296,9 @@ class KeyframeContainer {
* the keyframes of \p other.
*/
template <typename O>
iterator sync_after(const KeyframeContainer<O> &other,
const std::function<T(const O &)> &converter,
const time::time_t &start = std::numeric_limits<time::time_t>::min());
iterator sync(const KeyframeContainer<O> &other,
const std::function<T(const O &)> &converter,
const time::time_t &start = std::numeric_limits<time::time_t>::min());

/**
* Debugging method to be used from gdb to understand bugs better.
Expand Down Expand Up @@ -512,8 +512,8 @@ KeyframeContainer<T>::erase(KeyframeContainer<T>::iterator e) {

template <typename T>
typename KeyframeContainer<T>::iterator
KeyframeContainer<T>::sync_after(const KeyframeContainer<T> &other,
const time::time_t &start) {
KeyframeContainer<T>::sync(const KeyframeContainer<T> &other,
const time::time_t &start) {
// Delete elements after start time
iterator at = this->last_before(start, this->end());
at = this->erase_after(at);
Expand All @@ -536,9 +536,9 @@ KeyframeContainer<T>::sync_after(const KeyframeContainer<T> &other,
template <typename T>
template <typename O>
typename KeyframeContainer<T>::iterator
KeyframeContainer<T>::sync_after(const KeyframeContainer<O> &other,
const std::function<T(const O &)> &converter,
const time::time_t &start) {
KeyframeContainer<T>::sync(const KeyframeContainer<O> &other,
const std::function<T(const O &)> &converter,
const time::time_t &start) {
// Delete elements after start time
iterator at = this->last_before(start, this->end());
at = this->erase_after(at);
Expand Down
2 changes: 1 addition & 1 deletion libopenage/curve/tests/curve_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ void curve_types() {
// TODO: test c.insert_overwrite and c.insert_after

KeyframeContainer<int> c2;
c2.sync_after(c, 1);
c2.sync(c, 1);
// now c2 should be [-inf: 0, 1: 15, 2: 20, 3: 25]
TESTEQUALS(c2.last(0)->value, 0);
TESTEQUALS(c2.last(1)->value, 15);
Expand Down

0 comments on commit 75ad418

Please sign in to comment.