Improve performance of animation layers.

This commit is contained in:
2018-02-23 15:51:45 +01:00
parent 99cf0740fe
commit a8857faa24

View File

@@ -2,6 +2,7 @@
#include <cstring>
#include <random>
#include <GL/gl.h>
#include <caffe/util/math_functions.hpp>
#include "Range.hpp"
#include "ActivityAnimation.hpp"
@@ -38,10 +39,9 @@ ActivityAnimation::ActivityAnimation(const vector<pair<DType, pair<size_t, size_
void ActivityAnimation::draw(float timeScale)
{
std::unique_ptr<float[]> vertexBuffer(new float[bufferLength]);
for (auto i : Range(bufferLength)) {
vertexBuffer[i] = startingPos[i] + timeScale * delta[i];
}
caffe::caffe_copy(bufferLength, delta.data(), vertexBuffer.get());
caffe::caffe_scal(bufferLength, timeScale, vertexBuffer.get());
caffe::caffe_add(bufferLength, startingPos.data(), vertexBuffer.get(), vertexBuffer.get());
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);