Skip to content
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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
35 changes: 34 additions & 1 deletion doc/code/curves.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ e.g. angles between 0 and 360 degrees.
### Container

Container curves are intended for storing changes to collections and containers.
The currently supported containers are `Queue` and `UnorderedMap`.
The currently supported containers are `Queue`, `UnorderedMap` and `Array`.

The most important distinction between regular C++ containers and curve containers
is that curve containers track the *lifespan* of each element, i.e. their insertion time,
Expand Down Expand Up @@ -253,3 +253,36 @@ Unordered map curve containers store key-value pairs while additionally keeping
track of element insertion time. Requests for a key `k` at time `t` will return the value
of `k` at that time. The unordered map can also be iterated over for a specific time `t` which
allows access to all key-value pairs that were in the map at time `t`.


#### Array
Array curve containers are the equivalent to the `std::array` C++ containers. Unlike other curve containers,
each element of the underlying std::array is a `keyframecontainer` and when a value is added to the `Array curve`
at a given index they are added to the respective `keyframecontainer` at that index as a keyframe.

**Read**

Read operations retrieve values for a specific point in time.

| Method | Description |
| ----------------- | --------------------------------------- ---------------------------------|
| `get(t, i)` | Get value of index `i` at time <= `t` |
| `get(t)` | Get array of keyframes at time <= `t` |
| `size()` | Get size of the array |
| `frame(t, i)` | Get the time and value of the keyframe at index `i` with time <= `t` |
| `next_frame(t, i)`| Get the time and value of the first keyframe at index `i` with time > `t`|

**Modify**

Modify operations insert values for a specific point in time.

| Method | Description |
| ------------------------- | ------------------------------------------------------------------------------------------|
| `set_insert(t, i, value)` | Insert a new keyframe(`t`, `value`) at index `i` |
| `set_last(t, i, value)` | Insert a new keyframe(`t`, `value`) at index `i`; delete all keyframes after time `t` |
| `set_replace(t, i, value)`| Insert a new keyframe(`t`, `value`) at index `i`; remove all other keyframes with time `t`|

**Copy**
| Method | Description |
| ---------------- | ------------------------------------------------------------------------------------------------ |
| `sync(Curve, t)` | Replace all keyframes from self after time `t` with keyframes from source `Curve` after time `t` |
1 change: 1 addition & 0 deletions libopenage/curve/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
add_sources(libopenage
array.cpp
base_curve.cpp
continuous.cpp
discrete.cpp
Expand Down
10 changes: 10 additions & 0 deletions libopenage/curve/array.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright 2024-2024 the openage authors. See copying.md for legal info.


#include "array.h"

namespace openage::curve {

// This file is intended to be empty

} // openage::curve
Loading
Loading