mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 19:52:26 +02:00
add update expiry to VoxelShapeManager
This commit is contained in:
parent
32b07027d3
commit
c21491a034
2 changed files with 8 additions and 3 deletions
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#include "VoxelShapeManager.h"
|
#include "VoxelShapeManager.h"
|
||||||
|
|
||||||
VoxelShapeManager::VoxelShapeManager() : PhysicsEntity(), _lastSimulationTranslation(0.0f) {
|
VoxelShapeManager::VoxelShapeManager() : PhysicsEntity(), _updateExpiry(0), _lastSimulationTranslation(0.0f) {
|
||||||
}
|
}
|
||||||
|
|
||||||
VoxelShapeManager::~VoxelShapeManager() {
|
VoxelShapeManager::~VoxelShapeManager() {
|
||||||
|
@ -57,7 +57,9 @@ void VoxelShapeManager::clearShapes() {
|
||||||
_voxels.clear();
|
_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();
|
PhysicsSimulation* simulation = getSimulation();
|
||||||
if (!simulation) {
|
if (!simulation) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -39,11 +39,14 @@ public:
|
||||||
void buildShapes();
|
void buildShapes();
|
||||||
void clearShapes();
|
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
|
/// \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:
|
private:
|
||||||
|
quint64 _updateExpiry;
|
||||||
glm::vec3 _lastSimulationTranslation;
|
glm::vec3 _lastSimulationTranslation;
|
||||||
VoxelPool _voxels;
|
VoxelPool _voxels;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue