Reduce copying in animation step.
This commit is contained in:
@@ -51,7 +51,7 @@ ActivityAnimation::ActivityAnimation(
|
||||
|
||||
void ActivityAnimation::draw(float timeScale)
|
||||
{
|
||||
const auto vertexBuffer = animate(startingPos, delta, timeScale);
|
||||
const auto &vertexBuffer = animate(startingPos, delta, timeScale);
|
||||
glPointSize(5);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
@@ -8,7 +8,7 @@ using namespace fmri;
|
||||
|
||||
void ImageInteractionAnimation::draw(float step)
|
||||
{
|
||||
auto vertexBuffer = animate(startingPositions, deltas, step);
|
||||
auto &vertexBuffer = animate(startingPositions, deltas, step);
|
||||
|
||||
drawImageTiles(vertexBuffer.size() / 3, vertexBuffer.data(), textureCoordinates.data(), texture);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ PoolingLayerAnimation::PoolingLayerAnimation(const LayerData &prevData, const La
|
||||
|
||||
void PoolingLayerAnimation::draw(float timeStep)
|
||||
{
|
||||
auto vertexBuffer = animate(startingPositions, deltas, timeStep);
|
||||
auto& vertexBuffer = animate(startingPositions, deltas, timeStep);
|
||||
|
||||
drawImageTiles(vertexBuffer.size() / 3, vertexBuffer.data(), textureCoordinates.data(), original);
|
||||
}
|
||||
|
||||
@@ -16,9 +16,10 @@ std::default_random_engine &fmri::rng()
|
||||
return rng;
|
||||
}
|
||||
|
||||
std::vector<float> fmri::animate(const std::vector<float> &start, const std::vector<float> &delta, float time)
|
||||
const std::vector<float> & fmri::animate(const std::vector<float> &start, const std::vector<float> &delta, float time)
|
||||
{
|
||||
auto vertexBuffer = delta;
|
||||
static std::vector<float> vertexBuffer;
|
||||
vertexBuffer = delta;
|
||||
caffe::caffe_scal(vertexBuffer.size(), time, vertexBuffer.data());
|
||||
caffe::caffe_add(start.size(), vertexBuffer.data(), start.data(), vertexBuffer.data());
|
||||
|
||||
|
||||
@@ -238,5 +238,5 @@ namespace fmri
|
||||
* @param time 0..1 where in the animation are we?
|
||||
* @return Resulting list of floats.
|
||||
*/
|
||||
std::vector<float> animate(const std::vector<float>& start, const std::vector<float>& delta, float time);
|
||||
const std::vector<float> & animate(const std::vector<float> &start, const std::vector<float> &delta, float time);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user