Skip to content

Commit

Permalink
doc: Fix formatting of curve docs and reformulate array docs a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
heinezen committed Jan 19, 2025
1 parent 156d009 commit ad747a6
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions doc/code/curves.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Curves are an integral part of openage's event-based game simulation.
2. [Container](#container)
1. [Queue](#queue)
2. [Unordered Map](#unordered-map)
3. [Array](#array)


## Motivation
Expand Down Expand Up @@ -256,33 +257,38 @@ 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.

Array curve containers store a fixed number of `n` elements where `n` is determined at compile-time.
They are the curve equivalent to the `std::array` C++ containers. In comparison to `std::array` each
element in the array curve container is tracked individually over time. Hence, each index is associated
with its own `KeyframeContainer` whose keyframes can be updated independent from other indices.
When a value is added to the `Array` curve at a given index, a new keyframe is added to the respective
`KeyframeContainer` stored at that index.

**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`|
| Method | Description |
| ------------------ | ------------------------------------------------------------------------ |
| `get(t, i)` | Get value of element at index `i` at time <= `t` |
| `get(t)` | Get array of values at time <= `t` |
| `size()` | Get the number of elements in the array |
| `frame(t, i)` | Get the previous keyframe (time and value) at index `i` before or at `t` |
| `next_frame(t, i)` | Get the next keyframe (time and value) at index `i` after `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`|
| 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` |

0 comments on commit ad747a6

Please sign in to comment.