Improve performance of animation layers.
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
|
#include <caffe/util/math_functions.hpp>
|
||||||
#include "Range.hpp"
|
#include "Range.hpp"
|
||||||
#include "ActivityAnimation.hpp"
|
#include "ActivityAnimation.hpp"
|
||||||
|
|
||||||
@@ -38,10 +39,9 @@ ActivityAnimation::ActivityAnimation(const vector<pair<DType, pair<size_t, size_
|
|||||||
void ActivityAnimation::draw(float timeScale)
|
void ActivityAnimation::draw(float timeScale)
|
||||||
{
|
{
|
||||||
std::unique_ptr<float[]> vertexBuffer(new float[bufferLength]);
|
std::unique_ptr<float[]> vertexBuffer(new float[bufferLength]);
|
||||||
|
caffe::caffe_copy(bufferLength, delta.data(), vertexBuffer.get());
|
||||||
for (auto i : Range(bufferLength)) {
|
caffe::caffe_scal(bufferLength, timeScale, vertexBuffer.get());
|
||||||
vertexBuffer[i] = startingPos[i] + timeScale * delta[i];
|
caffe::caffe_add(bufferLength, startingPos.data(), vertexBuffer.get(), vertexBuffer.get());
|
||||||
}
|
|
||||||
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
glEnableClientState(GL_COLOR_ARRAY);
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
|
|||||||
Reference in New Issue
Block a user