15 #include "motive/engine.h"
22 void GatherFloats(MotiveIndex index, MotiveDimension dimensions,
float* out,
23 F value_from_data_fn)
const {
24 for (MotiveDimension i = 0; i < dimensions; ++i) {
25 const MotiveIndex data_idx = index + i;
26 const T& d = Data(data_idx);
27 out[i] = value_from_data_fn(d, values_[data_idx]);
35 virtual const float* Values(MotiveIndex index)
const {
36 return &values_[index];
39 virtual void Velocities(MotiveIndex index, MotiveDimension dimensions,
41 GatherFloats(index, dimensions, out, [](
const T& d,
float value) {
42 return SimpleVelocity(d, value);
46 virtual void TargetValues(MotiveIndex index, MotiveDimension dimensions,
48 GatherFloats(index, dimensions, out, [](
const T& d,
float value) {
49 return SimpleTargetValue(d, value);
53 virtual void TargetVelocities(MotiveIndex index, MotiveDimension dimensions,
55 GatherFloats(index, dimensions, out, [](
const T& d,
float value) {
56 return SimpleTargetVelocity(d, value);
60 virtual void Differences(MotiveIndex index, MotiveDimension dimensions,
62 GatherFloats(index, dimensions, out, [](
const T& d,
float value) {
63 return SimpleDifference(d, value);
67 virtual MotiveTime TargetTime(MotiveIndex index,
68 MotiveDimension dimensions)
const {
69 MotiveTime greatest = std::numeric_limits<MotiveTime>::min();
70 for (MotiveDimension i = 0; i < dimensions; ++i) {
71 const T& d = Data(index + i);
72 greatest = std::max(greatest, SimpleTargetTime(d));
79 MotiveDimension dimensions,
82 for (MotiveDimension i = 0; i < dimensions; ++i) {
83 const MotiveIndex processor_index = i + index;
84 Data(processor_index) = T(simple_init, i);
89 virtual void RemoveIndices(MotiveIndex index, MotiveDimension dimensions) {
90 for (MotiveIndex i = index; i < index + dimensions; ++i) {
96 virtual void MoveIndices(MotiveIndex old_index, MotiveIndex new_index,
97 MotiveDimension dimensions) {
98 MotiveIndex old_i = old_index;
99 MotiveIndex new_i = new_index;
100 for (MotiveDimension i = 0; i < dimensions; ++i, ++new_i, ++old_i) {
101 data_[new_i] = data_[old_i];
102 values_[new_i] = values_[old_i];
107 data_.resize(num_indices);
108 values_.resize(num_indices);
111 const T& Data(MotiveIndex index)
const {
116 T& Data(MotiveIndex index) {
121 std::vector<T> data_;
122 std::vector<float> values_;
Interface for motivator types that drive a single float value.
Definition: processor.h:264
virtual void InitializeIndices(const MotivatorInit &init, MotiveIndex index, MotiveDimension dimensions, MotiveEngine *)
Definition: simple_processor_template.h:78
bool ValidIndex(MotiveIndex index) const
Base class of Init classes for MotiveProcessors that derive from SimpleProcessorTemplate.
Definition: init.h:81
Hold and update all animation data.
Definition: engine.h:36
Definition: simple_processor_template.h:20
const float * start_values
Definition: init.h:97
virtual void SetNumIndices(MotiveIndex num_indices)
Definition: simple_processor_template.h:106
virtual void RemoveIndices(MotiveIndex index, MotiveDimension dimensions)
Definition: simple_processor_template.h:89
virtual void MoveIndices(MotiveIndex old_index, MotiveIndex new_index, MotiveDimension dimensions)
Definition: simple_processor_template.h:96