add update expiry to VoxelShapeManager

This commit is contained in:
Andrew Meadows 2014-09-12 17:38:20 -07:00
parent 32b07027d3
commit c21491a034
2 changed files with 8 additions and 3 deletions

View file

@ -17,7 +17,7 @@
#include "VoxelShapeManager.h"
VoxelShapeManager::VoxelShapeManager() : PhysicsEntity(), _lastSimulationTranslation(0.0f) {
VoxelShapeManager::VoxelShapeManager() : PhysicsEntity(), _updateExpiry(0), _lastSimulationTranslation(0.0f) {
}
VoxelShapeManager::~VoxelShapeManager() {
@ -57,7 +57,9 @@ void VoxelShapeManager::clearShapes() {
_voxels.clear();
}
void VoxelShapeManager::updateVoxels(CubeList& cubes) {
void VoxelShapeManager::updateVoxels(const quint64& now, CubeList& cubes) {
const quint64 VOXEL_UPDATE_PERIOD = 100000; // usec
_updateExpiry = now + VOXEL_UPDATE_PERIOD;
PhysicsSimulation* simulation = getSimulation();
if (!simulation) {
return;

View file

@ -39,11 +39,14 @@ public:
void buildShapes();
void clearShapes();
bool needsUpdate(const quint64& now) const { return _updateExpiry < now; }
/// \param cubes list of AACubes representing all of the voxels that should be in this VoxelShapeManager
void updateVoxels(CubeList& cubes);
void updateVoxels(const quint64& now, CubeList& cubes);
private:
quint64 _updateExpiry;
glm::vec3 _lastSimulationTranslation;
VoxelPool _voxels;
};