History

only allow VBO re-transfer every 5 seconds for test

Stephen Birarda committed 13 years ago

Commit 793ac841 parent ebe11152 files · +11 −5Browse files

Showing the changes to interface/src/VoxelSystem.cpp (1 of 2 files). Show all

Unified · Split

interface/src/VoxelSystem.cpp+10−5
@@ -40,6 +40,8 @@ VoxelSystem::VoxelSystem() { · 39 unmodified lines
4040 voxelsRendered = 0;
4141 tree = new VoxelTree();
4242 pthread_mutex_init(&bufferWriteLock, NULL);
43+ lastBufferCopy.tv_sec = 0;
44+ lastBufferCopy.tv_usec = 0;
4345 }
4446
4547 VoxelSystem::~VoxelSystem() {
@@ -185,11 +187,11 @@ VoxelSystem* VoxelSystem::clone() const { · 139 unmodified lines
185187
186188 void VoxelSystem::init() {
187189 // prep the data structures for incoming voxel data
188− writeVerticesArray = new GLfloat[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];
189− readVerticesArray = new GLfloat[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];
190+ writeVerticesEndPointer = writeVerticesArray = new GLfloat[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];
191+ readVerticesEndPointer = readVerticesArray = new GLfloat[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];
190192 writeColorsArray = new GLubyte[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];
191193 readColorsArray = new GLubyte[VERTEX_POINTS_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];
192−
194+
193195 GLuint *indicesArray = new GLuint[INDICES_PER_VOXEL * MAX_VOXELS_PER_SYSTEM];
194196
195197 // populate the indicesArray
@@ -231,8 +233,9 @@ void VoxelSystem::render() { · 35 unmodified lines
231233
232234 glPushMatrix();
233235
234−
235− if (readVerticesEndPointer != readVerticesArray) {
236+ double timeSinceLastDraw = usecTimestampNow() - usecTimestamp(&lastBufferCopy);
237+ if (readVerticesEndPointer != readVerticesArray && timeSinceLastDraw >= 5000 * 1000) {
238+ printf("The time since the last draw was %f\n", timeSinceLastDraw);
236239 // try to lock on the buffer write
237240 // just avoid pulling new data if it is currently being written
238241 if (pthread_mutex_trylock(&bufferWriteLock) == 0) {
@@ -249,6 +252,8 @@ void VoxelSystem::render() { · 10 unmodified lines
249252
250253 pthread_mutex_unlock(&bufferWriteLock);
251254 }
255+
256+ gettimeofday(&lastBufferCopy, NULL);
252257 }
253258
254259 // tell OpenGL where to find vertex and color information