Removing more dynamic memory allocations

This commit is contained in:
Alexander Bock
2020-08-05 15:45:06 +02:00
parent 2691dae11f
commit c472ac131e
11 changed files with 198 additions and 140 deletions

View File

@@ -609,6 +609,8 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary)
addPropertySubOwner(_debugPropertyOwner);
addPropertySubOwner(_layerManager);
_traversalMemory.reserve(512);
//================================================================
//======== Reads Shadow (Eclipses) Entries in mod file ===========
//================================================================
@@ -1171,19 +1173,18 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&,
std::array<const Chunk*, ChunkBufferSize> local;
int localCount = 0;
auto traversal = [&global, &globalCount, &local, &localCount,
auto traversal = [&global, &globalCount, &local, &localCount, this,
cutoff = _debugProperties.modelSpaceRenderingCutoffLevel](const Chunk& node)
{
ZoneScopedN("traversal")
std::vector<const Chunk*> Q;
Q.reserve(256);
_traversalMemory.clear();
// Loop through nodes in breadths first order
Q.push_back(&node);
while (!Q.empty()) {
const Chunk* n = Q.front();
Q.erase(Q.begin());
_traversalMemory.push_back(&node);
while (!_traversalMemory.empty()) {
const Chunk* n = _traversalMemory.front();
_traversalMemory.erase(_traversalMemory.begin());
if (isLeaf(*n) && n->isVisible) {
if (n->tileIndex.level < cutoff) {
@@ -1199,7 +1200,7 @@ void RenderableGlobe::renderChunks(const RenderData& data, RendererTasks&,
// Add children to queue, if any
if (!isLeaf(*n)) {
for (int i = 0; i < 4; ++i) {
Q.push_back(n->children[i]);
_traversalMemory.push_back(n->children[i]);
}
}
}

View File

@@ -258,6 +258,9 @@ private:
ghoul::ReusableTypedMemoryPool<Chunk, 256> _chunkPool;
std::vector<const Chunk*> _traversalMemory;
Chunk _leftRoot; // Covers all negative longitudes
Chunk _rightRoot; // Covers all positive longitudes

View File

@@ -32,6 +32,7 @@
#include <ghoul/filesystem/file.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/misc/profiling.h>
namespace {
constexpr const char* KeyKernels = "Kernels";
@@ -172,6 +173,8 @@ SpiceTranslation::SpiceTranslation(const ghoul::Dictionary& dictionary)
}
glm::dvec3 SpiceTranslation::position(const UpdateData& data) const {
ZoneScoped
double lightTime = 0.0;
return SpiceManager::ref().targetPosition(
_target,
@@ -180,7 +183,7 @@ glm::dvec3 SpiceTranslation::position(const UpdateData& data) const {
{},
data.time.j2000Seconds(),
lightTime
) * glm::pow(10.0, 3.0);
) * 1000.0;
}
} // namespace openspace