Showing the changes to interface/src/VoxelHideShowThread.cpp (1 of 7 files). Show all
Unified · Split
| @@ -0,0 +1,46 @@ | ||
| 1 | +// | |
| 2 | +// VoxelHideShowThread.cpp | |
| 3 | +// interface | |
| 4 | +// | |
| 5 | +// Created by Brad Hefta-Gaub on 12/1/13 | |
| 6 | +// Copyright (c) 2013 High Fidelity, Inc. All rights reserved. | |
| 7 | +// | |
| 8 | +// Threaded or non-threaded interface thread for hiding and showing voxels in the local tree. | |
| 9 | +// | |
| 10 | + | |
| 11 | +#include <QDebug> | |
| 12 | +#include <NodeList.h> | |
| 13 | +#include <PerfStat.h> | |
| 14 | +#include <SharedUtil.h> | |
| 15 | + | |
| 16 | +#include "Menu.h" | |
| 17 | +#include "VoxelHideShowThread.h" | |
| 18 | + | |
| 19 | +VoxelHideShowThread::VoxelHideShowThread(VoxelSystem* theSystem) : | |
| 20 | + _theSystem(theSystem) { | |
| 21 | +} | |
| 22 | + | |
| 23 | +bool VoxelHideShowThread::process() { | |
| 24 | + const uint64_t MSECS_TO_USECS = 1000; | |
| 25 | + const uint64_t SECS_TO_USECS = 1000 * MSECS_TO_USECS; | |
| 26 | + const uint64_t FRAME_RATE = 60; | |
| 27 | + const uint64_t USECS_PER_FRAME = SECS_TO_USECS / FRAME_RATE; // every 60fps | |
| 28 | + | |
| 29 | + uint64_t start = usecTimestampNow(); | |
| 30 | + _theSystem->checkForCulling(); | |
| 31 | + uint64_t end = usecTimestampNow(); | |
| 32 | + uint64_t elapsed = end - start; | |
| 33 | + | |
| 34 | + bool showExtraDebugging = Menu::getInstance()->isOptionChecked(MenuOption::ExtraDebugging); | |
| 35 | + if (showExtraDebugging && elapsed > USECS_PER_FRAME) { | |
| 36 | + printf("VoxelHideShowThread::process()... checkForCulling took %llu\n", elapsed); | |
| 37 | + } | |
| 38 | + | |
| 39 | + if (isStillRunning()) { | |
| 40 | + if (elapsed < USECS_PER_FRAME) { | |
| 41 | + uint64_t sleepFor = USECS_PER_FRAME - elapsed; | |
| 42 | + usleep(sleepFor); | |
| 43 | + } | |
| 44 | + } | |
| 45 | + return isStillRunning(); // keep running till they terminate us | |
| 46 | +} | |