mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-25 05:48:59 -05:00
Removing more dynamic memory allocations
This commit is contained in:
+1
-1
Submodule ext/ghoul updated: 0905695975...0e5d87dc6e
@@ -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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1463,24 +1463,20 @@ void RenderEngine::renderScreenLog() {
|
||||
white
|
||||
);
|
||||
|
||||
glm::vec4 color = glm::vec4(0.f);
|
||||
switch (e->level) {
|
||||
const glm::vec4 color = [alpha, white](ScreenLog::LogLevel level) {
|
||||
switch (level) {
|
||||
case ghoul::logging::LogLevel::Debug:
|
||||
color = glm::vec4(0.f, 1.f, 0.f, alpha);
|
||||
break;
|
||||
return glm::vec4(0.f, 1.f, 0.f, alpha);
|
||||
case ghoul::logging::LogLevel::Warning:
|
||||
color = glm::vec4(1.f, 1.f, 0.f, alpha);
|
||||
break;
|
||||
return glm::vec4(1.f, 1.f, 0.f, alpha);
|
||||
case ghoul::logging::LogLevel::Error:
|
||||
color = glm::vec4(1.f, 0.f, 0.f, alpha);
|
||||
break;
|
||||
return glm::vec4(1.f, 0.f, 0.f, alpha);
|
||||
case ghoul::logging::LogLevel::Fatal:
|
||||
color = glm::vec4(0.3f, 0.3f, 0.85f, alpha);
|
||||
break;
|
||||
return glm::vec4(0.3f, 0.3f, 0.85f, alpha);
|
||||
default:
|
||||
color = white;
|
||||
break;
|
||||
}
|
||||
return white;
|
||||
}
|
||||
}(e->level);
|
||||
|
||||
RenderFont(
|
||||
*_fontLog,
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <openspace/util/updatestructures.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <ghoul/misc/profiling.h>
|
||||
#include <ghoul/misc/templatefactory.h>
|
||||
|
||||
namespace {
|
||||
@@ -95,6 +96,8 @@ const glm::dmat3& Rotation::matrix() const {
|
||||
}
|
||||
|
||||
void Rotation::update(const UpdateData& data) {
|
||||
ZoneScoped
|
||||
|
||||
if (!_needsUpdate && (data.time.j2000Seconds() == _cachedTime)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <openspace/util/updatestructures.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <ghoul/misc/profiling.h>
|
||||
#include <ghoul/misc/templatefactory.h>
|
||||
|
||||
namespace {
|
||||
@@ -90,6 +91,8 @@ glm::dvec3 Scale::scaleValue() const {
|
||||
}
|
||||
|
||||
void Scale::update(const UpdateData& data) {
|
||||
ZoneScoped
|
||||
|
||||
if (!_needsUpdate && data.time.j2000Seconds() == _cachedTime) {
|
||||
return;
|
||||
}
|
||||
|
||||
+2
-6
@@ -303,11 +303,11 @@ void Scene::update(const UpdateData& data) {
|
||||
ZoneScoped
|
||||
|
||||
std::vector<SceneGraphNode*> initializedNodes = _initializer->takeInitializedNodes();
|
||||
|
||||
for (SceneGraphNode* node : initializedNodes) {
|
||||
try {
|
||||
node->initializeGL();
|
||||
} catch (const ghoul::RuntimeError& e) {
|
||||
}
|
||||
catch (const ghoul::RuntimeError& e) {
|
||||
LERRORC(e.component, e.message);
|
||||
}
|
||||
}
|
||||
@@ -316,9 +316,7 @@ void Scene::update(const UpdateData& data) {
|
||||
}
|
||||
for (SceneGraphNode* node : _topologicallySortedNodes) {
|
||||
try {
|
||||
LTRACE("Scene::update(begin '" + node->identifier() + "')");
|
||||
node->update(data);
|
||||
LTRACE("Scene::update(end '" + node->identifier() + "')");
|
||||
}
|
||||
catch (const ghoul::RuntimeError& e) {
|
||||
LERRORC(e.component, e.what());
|
||||
@@ -335,9 +333,7 @@ void Scene::render(const RenderData& data, RendererTasks& tasks) {
|
||||
|
||||
for (SceneGraphNode* node : _topologicallySortedNodes) {
|
||||
try {
|
||||
LTRACE("Scene::render(begin '" + node->identifier() + "')");
|
||||
node->render(data, tasks);
|
||||
LTRACE("Scene::render(end '" + node->identifier() + "')");
|
||||
}
|
||||
catch (const ghoul::RuntimeError& e) {
|
||||
LERRORC(e.component, e.what());
|
||||
|
||||
@@ -545,11 +545,9 @@ void SceneGraphNode::render(const RenderData& data, RendererTasks& tasks) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool visible = _renderable &&
|
||||
_renderable->isVisible() &&
|
||||
_renderable->isReady() &&
|
||||
_renderable->isEnabled() &&
|
||||
_renderable->matchesRenderBinMask(data.renderBinMask);
|
||||
const bool visible = _renderable && _renderable->isVisible() &&
|
||||
_renderable->isReady() && _renderable->isEnabled() &&
|
||||
_renderable->matchesRenderBinMask(data.renderBinMask);
|
||||
|
||||
if (!visible) {
|
||||
return;
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
#include <openspace/util/factorymanager.h>
|
||||
#include <openspace/util/memorymanager.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
#include <ghoul/misc/profiling.h>
|
||||
#include <ghoul/misc/templatefactory.h>
|
||||
|
||||
namespace {
|
||||
@@ -84,6 +84,8 @@ bool Translation::initialize() {
|
||||
}
|
||||
|
||||
void Translation::update(const UpdateData& data) {
|
||||
ZoneScoped
|
||||
|
||||
if (!_needsUpdate && data.time.j2000Seconds() == _cachedTime) {
|
||||
return;
|
||||
}
|
||||
|
||||
+158
-105
@@ -30,6 +30,7 @@
|
||||
#include <ghoul/filesystem/file.h>
|
||||
#include <ghoul/filesystem/filesystem.h>
|
||||
#include <ghoul/misc/assert.h>
|
||||
#include <ghoul/misc/profiling.h>
|
||||
#include <algorithm>
|
||||
#include "SpiceUsr.h"
|
||||
#include "SpiceZpr.h"
|
||||
@@ -45,23 +46,12 @@ namespace {
|
||||
// This method checks if one of the previous SPICE methods has failed. If it has, an
|
||||
// exception with the SPICE error message is thrown
|
||||
// If an error occurred, true is returned, otherwise, false
|
||||
bool throwOnSpiceError(const std::string& errorMessage) {
|
||||
SpiceBoolean failed = failed_c();
|
||||
void throwSpiceError(const std::string& errorMessage) {
|
||||
if (openspace::SpiceManager::ref().exceptionHandling()) {
|
||||
if (failed) {
|
||||
char buffer[SpiceErrorBufferSize];
|
||||
getmsg_c("LONG", SpiceErrorBufferSize, buffer);
|
||||
reset_c();
|
||||
throw openspace::SpiceManager::SpiceException(
|
||||
errorMessage + ": " + buffer
|
||||
);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return failed;
|
||||
char buffer[SpiceErrorBufferSize];
|
||||
getmsg_c("LONG", SpiceErrorBufferSize, buffer);
|
||||
reset_c();
|
||||
throw openspace::SpiceManager::SpiceException(errorMessage + ": " + buffer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +72,7 @@ namespace {
|
||||
default: throw ghoul::MissingCaseException();
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
#include "spicemanager_lua.inl"
|
||||
|
||||
@@ -250,7 +240,9 @@ SpiceManager::KernelHandle SpiceManager::loadKernel(std::string filePath) {
|
||||
// Reset the current directory to the previous one
|
||||
FileSys.setCurrentDirectory(currentDirectory);
|
||||
|
||||
throwOnSpiceError("Kernel loading");
|
||||
if (failed_c()) {
|
||||
throwSpiceError("Kernel loading");
|
||||
}
|
||||
|
||||
std::string fileExtension = ghoul::filesystem::File(
|
||||
path,
|
||||
@@ -332,6 +324,8 @@ void SpiceManager::unloadKernel(std::string filePath) {
|
||||
}
|
||||
|
||||
bool SpiceManager::hasSpkCoverage(const std::string& target, double et) const {
|
||||
ZoneScoped
|
||||
|
||||
ghoul_assert(!target.empty(), "Empty target");
|
||||
|
||||
const int id = naifId(target);
|
||||
@@ -426,7 +420,11 @@ void getValueInternal(const std::string& body, const std::string& value, int siz
|
||||
SpiceInt n;
|
||||
bodvrd_c(body.c_str(), value.c_str(), size, &n, v);
|
||||
|
||||
throwOnSpiceError(fmt::format("Error getting value '{}' for body '{}'", value, body));
|
||||
if (failed_c()) {
|
||||
throwSpiceError(
|
||||
fmt::format("Error getting value '{}' for body '{}'", value, body)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void SpiceManager::getValue(const std::string& body, const std::string& value,
|
||||
@@ -467,9 +465,11 @@ double SpiceManager::spacecraftClockToET(const std::string& craft, double craftT
|
||||
int craftId = naifId(craft);
|
||||
double et;
|
||||
sct2e_c(craftId, craftTicks, &et);
|
||||
throwOnSpiceError(fmt::format(
|
||||
"Error transforming spacecraft clock of '{}' at time {}", craft, craftTicks
|
||||
));
|
||||
if (failed_c()) {
|
||||
throwSpiceError(fmt::format(
|
||||
"Error transforming spacecraft clock of '{}' at time {}", craft, craftTicks
|
||||
));
|
||||
}
|
||||
return et;
|
||||
}
|
||||
|
||||
@@ -478,7 +478,9 @@ double SpiceManager::ephemerisTimeFromDate(const std::string& timeString) const
|
||||
|
||||
double et;
|
||||
str2et_c(timeString.c_str(), &et);
|
||||
throwOnSpiceError(fmt::format("Error converting date '{}'", timeString));
|
||||
if (failed_c()) {
|
||||
throwSpiceError(fmt::format("Error converting date '{}'", timeString));
|
||||
}
|
||||
return et;
|
||||
}
|
||||
|
||||
@@ -490,11 +492,13 @@ std::string SpiceManager::dateFromEphemerisTime(double ephemerisTime,
|
||||
constexpr const int BufferSize = 256;
|
||||
SpiceChar buffer[BufferSize];
|
||||
timout_c(ephemerisTime, formatString.c_str(), BufferSize - 1, buffer);
|
||||
throwOnSpiceError(
|
||||
fmt::format("Error converting ephemeris time '{}' to date with format '{}'",
|
||||
ephemerisTime, formatString
|
||||
)
|
||||
);
|
||||
if (failed_c()) {
|
||||
throwSpiceError(
|
||||
fmt::format("Error converting ephemeris time '{}' to date with format '{}'",
|
||||
ephemerisTime, formatString
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return std::string(buffer);
|
||||
}
|
||||
@@ -505,6 +509,8 @@ glm::dvec3 SpiceManager::targetPosition(const std::string& target,
|
||||
AberrationCorrection aberrationCorrection,
|
||||
double ephemerisTime, double& lightTime) const
|
||||
{
|
||||
ZoneScoped
|
||||
|
||||
ghoul_assert(!target.empty(), "Target is not empty");
|
||||
ghoul_assert(!observer.empty(), "Observer is not empty");
|
||||
ghoul_assert(!referenceFrame.empty(), "Reference frame is not empty");
|
||||
@@ -535,10 +541,12 @@ glm::dvec3 SpiceManager::targetPosition(const std::string& target,
|
||||
glm::value_ptr(position),
|
||||
&lightTime
|
||||
);
|
||||
throwOnSpiceError(fmt::format(
|
||||
"Error getting position from '{}' to '{}' in reference frame '{}' at time {}",
|
||||
target, observer, referenceFrame, ephemerisTime
|
||||
));
|
||||
if (failed_c()) {
|
||||
throwSpiceError(fmt::format(
|
||||
"Error getting position from '{}' to '{}' in frame '{}' at time {}",
|
||||
target, observer, referenceFrame, ephemerisTime
|
||||
));
|
||||
}
|
||||
return position;
|
||||
}
|
||||
else if (targetHasCoverage) {
|
||||
@@ -598,11 +606,13 @@ glm::dmat3 SpiceManager::frameTransformationMatrix(const std::string& from,
|
||||
reinterpret_cast<double(*)[3]>(glm::value_ptr(transform))
|
||||
);
|
||||
|
||||
throwOnSpiceError(
|
||||
fmt::format("Error converting from frame '{}' to frame '{}' at time '{}'",
|
||||
from, to, ephemerisTime
|
||||
)
|
||||
);
|
||||
if (failed_c()) {
|
||||
throwSpiceError(
|
||||
fmt::format("Error converting from frame '{}' to frame '{}' at time '{}'",
|
||||
from, to, ephemerisTime
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// The rox-major, column-major order are switched in GLM and SPICE, so we have to
|
||||
// transpose the matrix before we can return it
|
||||
@@ -645,11 +655,13 @@ SpiceManager::SurfaceInterceptResult SpiceManager::surfaceIntercept(
|
||||
);
|
||||
result.interceptFound = (found == SPICETRUE);
|
||||
|
||||
throwOnSpiceError(fmt::format(
|
||||
"Error retrieving surface intercept on target '{}' viewed from observer '{}' in "
|
||||
"reference frame '{}' at time '{}'",
|
||||
target, observer, referenceFrame, ephemerisTime
|
||||
));
|
||||
if (failed_c()) {
|
||||
throwSpiceError(fmt::format(
|
||||
"Error retrieving surface intercept on target '{}' viewed from observer '{}' "
|
||||
"in reference frame '{}' at time '{}'",
|
||||
target, observer, referenceFrame, ephemerisTime
|
||||
));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -679,10 +691,12 @@ bool SpiceManager::isTargetInFieldOfView(const std::string& target,
|
||||
&visible
|
||||
);
|
||||
|
||||
throwOnSpiceError(fmt::format(
|
||||
"Checking if target '{}' is in view of instrument '{}' failed",
|
||||
target, instrument
|
||||
));
|
||||
if (failed_c()) {
|
||||
throwSpiceError(fmt::format(
|
||||
"Checking if target '{}' is in view of instrument '{}' failed",
|
||||
target, instrument
|
||||
));
|
||||
}
|
||||
|
||||
return visible == SPICETRUE;
|
||||
}
|
||||
@@ -712,11 +726,13 @@ SpiceManager::TargetStateResult SpiceManager::targetState(const std::string& tar
|
||||
&result.lightTime
|
||||
);
|
||||
|
||||
throwOnSpiceError(fmt::format(
|
||||
"Error retrieving state of target '{}' viewed from observer '{}' in reference "
|
||||
"frame '{}' at time '{}'",
|
||||
target, observer, referenceFrame, ephemerisTime
|
||||
));
|
||||
if (failed_c()) {
|
||||
throwSpiceError(fmt::format(
|
||||
"Error retrieving state of target '{}' viewed from observer '{}' in "
|
||||
"reference frame '{}' at time '{}'",
|
||||
target, observer, referenceFrame, ephemerisTime
|
||||
));
|
||||
}
|
||||
|
||||
memmove(glm::value_ptr(result.position), buffer, sizeof(double) * 3);
|
||||
memmove(glm::value_ptr(result.velocity), buffer + 3, sizeof(double) * 3);
|
||||
@@ -738,11 +754,13 @@ SpiceManager::TransformMatrix SpiceManager::stateTransformMatrix(
|
||||
ephemerisTime,
|
||||
reinterpret_cast<double(*)[6]>(m.data())
|
||||
);
|
||||
throwOnSpiceError(fmt::format(
|
||||
"Error retrieved state transform matrix from frame '{}' to frame '{}' at time "
|
||||
"'{}'",
|
||||
sourceFrame, destinationFrame, ephemerisTime
|
||||
));
|
||||
if (failed_c()) {
|
||||
throwSpiceError(fmt::format(
|
||||
"Error retrieved state transform matrix from frame '{}' to frame '{}' at "
|
||||
"time '{}'",
|
||||
sourceFrame, destinationFrame, ephemerisTime
|
||||
));
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
@@ -761,7 +779,9 @@ glm::dmat3 SpiceManager::positionTransformMatrix(const std::string& sourceFrame,
|
||||
reinterpret_cast<double(*)[3]>(glm::value_ptr(result))
|
||||
);
|
||||
|
||||
throwOnSpiceError("");
|
||||
if (failed_c()) {
|
||||
throwSpiceError("");
|
||||
}
|
||||
SpiceBoolean success = !(failed_c());
|
||||
reset_c();
|
||||
if (!success) {
|
||||
@@ -792,11 +812,13 @@ glm::dmat3 SpiceManager::positionTransformMatrix(const std::string& sourceFrame,
|
||||
ephemerisTimeTo,
|
||||
reinterpret_cast<double(*)[3]>(glm::value_ptr(result))
|
||||
);
|
||||
throwOnSpiceError(fmt::format(
|
||||
"Error retrieving position transform matrix from '{}' at time '{}' to frame '{}' "
|
||||
"at time '{}'",
|
||||
sourceFrame, ephemerisTimeFrom, destinationFrame, ephemerisTimeTo
|
||||
));
|
||||
if (failed_c()) {
|
||||
throwSpiceError(fmt::format(
|
||||
"Error retrieving position transform matrix from '{}' at time '{}' to frame "
|
||||
"'{}' at time '{}'",
|
||||
sourceFrame, ephemerisTimeFrom, destinationFrame, ephemerisTimeTo
|
||||
));
|
||||
}
|
||||
return glm::transpose(result);
|
||||
}
|
||||
|
||||
@@ -828,10 +850,10 @@ SpiceManager::FieldOfViewResult SpiceManager::fieldOfView(int instrument) const
|
||||
boundsArr // the bounds
|
||||
);
|
||||
|
||||
bool failed = throwOnSpiceError(fmt::format(
|
||||
"Error getting field-of-view parameters for instrument '{}'", instrument
|
||||
));
|
||||
if (failed) {
|
||||
if (failed_c()) {
|
||||
throwSpiceError(fmt::format(
|
||||
"Error getting field-of-view parameters for instrument '{}'", instrument
|
||||
));
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -887,11 +909,13 @@ SpiceManager::TerminatorEllipseResult SpiceManager::terminatorEllipse(
|
||||
glm::value_ptr(res.observerPosition),
|
||||
reinterpret_cast<double(*)[3]>(res.terminatorPoints.data())
|
||||
);
|
||||
throwOnSpiceError(fmt::format(
|
||||
"Error getting terminator ellipse for target '{}' from observer '{}' in frame "
|
||||
"'{}' with light source '{}' at time '{}'",
|
||||
target, observer, frame, lightSource, ephemerisTime
|
||||
));
|
||||
if (failed_c()) {
|
||||
throwSpiceError(fmt::format(
|
||||
"Error getting terminator ellipse for target '{}' from observer '{}' in "
|
||||
"frame '{}' with light source '{}' at time '{}'",
|
||||
target, observer, frame, lightSource, ephemerisTime
|
||||
));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -914,7 +938,9 @@ void SpiceManager::findCkCoverage(const std::string& path) {
|
||||
SPICEDOUBLE_CELL(cover, WinSiz);
|
||||
|
||||
ckobj_c(path.c_str(), &ids);
|
||||
throwOnSpiceError("Error finding Ck Coverage");
|
||||
if (failed_c()) {
|
||||
throwSpiceError("Error finding Ck Coverage");
|
||||
}
|
||||
|
||||
for (SpiceInt i = 0; i < card_c(&ids); ++i) {
|
||||
const SpiceInt frame = SPICE_CELL_ELEM_I(&ids, i); // NOLINT
|
||||
@@ -927,7 +953,9 @@ void SpiceManager::findCkCoverage(const std::string& path) {
|
||||
|
||||
scard_c(0, &cover);
|
||||
ckcov_c(path.c_str(), frame, SPICEFALSE, "SEGMENT", 0.0, "TDB", &cover);
|
||||
throwOnSpiceError("Error finding Ck Coverage");
|
||||
if (failed_c()) {
|
||||
throwSpiceError("Error finding Ck Coverage");
|
||||
}
|
||||
|
||||
// Get the number of intervals in the coverage window.
|
||||
const SpiceInt numberOfIntervals = wncard_c(&cover);
|
||||
@@ -936,7 +964,9 @@ void SpiceManager::findCkCoverage(const std::string& path) {
|
||||
// Get the endpoints of the jth interval.
|
||||
SpiceDouble b, e;
|
||||
wnfetd_c(&cover, j, &b, &e);
|
||||
throwOnSpiceError("Error finding Ck Coverage");
|
||||
if (failed_c()) {
|
||||
throwSpiceError("Error finding Ck Coverage");
|
||||
}
|
||||
|
||||
_ckCoverageTimes[frame].insert(e);
|
||||
_ckCoverageTimes[frame].insert(b);
|
||||
@@ -964,7 +994,9 @@ void SpiceManager::findSpkCoverage(const std::string& path) {
|
||||
SPICEDOUBLE_CELL(cover, WinSiz);
|
||||
|
||||
spkobj_c(path.c_str(), &ids);
|
||||
throwOnSpiceError("Error finding Spk ID for coverage");
|
||||
if (failed_c()) {
|
||||
throwSpiceError("Error finding Spk ID for coverage");
|
||||
}
|
||||
|
||||
for (SpiceInt i = 0; i < card_c(&ids); ++i) {
|
||||
const SpiceInt obj = SPICE_CELL_ELEM_I(&ids, i); // NOLINT
|
||||
@@ -977,7 +1009,9 @@ void SpiceManager::findSpkCoverage(const std::string& path) {
|
||||
|
||||
scard_c(0, &cover);
|
||||
spkcov_c(path.c_str(), obj, &cover);
|
||||
throwOnSpiceError("Error finding Spk coverage");
|
||||
if (failed_c()) {
|
||||
throwSpiceError("Error finding Spk coverage");
|
||||
}
|
||||
|
||||
// Get the number of intervals in the coverage window.
|
||||
const SpiceInt numberOfIntervals = wncard_c(&cover);
|
||||
@@ -986,7 +1020,9 @@ void SpiceManager::findSpkCoverage(const std::string& path) {
|
||||
//Get the endpoints of the jth interval.
|
||||
SpiceDouble b, e;
|
||||
wnfetd_c(&cover, j, &b, &e);
|
||||
throwOnSpiceError("Error finding Spk coverage");
|
||||
if (failed_c()) {
|
||||
throwSpiceError("Error finding Spk coverage");
|
||||
}
|
||||
|
||||
// insert all into coverage time set, the windows could be merged @AA
|
||||
_spkCoverageTimes[obj].insert(e);
|
||||
@@ -1003,6 +1039,8 @@ glm::dvec3 SpiceManager::getEstimatedPosition(const std::string& target,
|
||||
double ephemerisTime,
|
||||
double& lightTime) const
|
||||
{
|
||||
ZoneScoped
|
||||
|
||||
ghoul_assert(!target.empty(), "Target must not be empty");
|
||||
ghoul_assert(!observer.empty(), "Observer must not be empty");
|
||||
ghoul_assert(!referenceFrame.empty(), "Reference frame must not be empty");
|
||||
@@ -1039,10 +1077,13 @@ glm::dvec3 SpiceManager::getEstimatedPosition(const std::string& target,
|
||||
glm::value_ptr(pos),
|
||||
&lightTime
|
||||
);
|
||||
throwOnSpiceError(fmt::format(
|
||||
"Error estimating position for target '{}' with observer '{}' in frame '{}'",
|
||||
target, observer, referenceFrame
|
||||
));
|
||||
if (failed_c()) {
|
||||
throwSpiceError(fmt::format(
|
||||
"Error estimating position for '{}' with observer '{}' in frame '{}'",
|
||||
target, observer, referenceFrame
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
else if (coveredTimes.upper_bound(ephemerisTime) == coveredTimes.end()) {
|
||||
// coverage earlier, fetch last position
|
||||
@@ -1055,10 +1096,12 @@ glm::dvec3 SpiceManager::getEstimatedPosition(const std::string& target,
|
||||
glm::value_ptr(pos),
|
||||
&lightTime
|
||||
);
|
||||
throwOnSpiceError(fmt::format(
|
||||
"Error estimating position for target '{}' with observer '{}' in frame '{}'",
|
||||
target, observer, referenceFrame
|
||||
));
|
||||
if (failed_c()) {
|
||||
throwSpiceError(fmt::format(
|
||||
"Error estimating position for '{}' with observer '{}' in frame '{}'",
|
||||
target, observer, referenceFrame
|
||||
));
|
||||
}
|
||||
}
|
||||
else {
|
||||
// coverage both earlier and later, interpolate these positions
|
||||
@@ -1088,10 +1131,12 @@ glm::dvec3 SpiceManager::getEstimatedPosition(const std::string& target,
|
||||
<Later
|
||||
);
|
||||
|
||||
throwOnSpiceError(fmt::format(
|
||||
"Error estimating position for target '{}' with observer '{}' in frame '{}'",
|
||||
target, observer, referenceFrame
|
||||
));
|
||||
if (failed_c()) {
|
||||
throwSpiceError(fmt::format(
|
||||
"Error estimating position for '{}' with observer '{}' in frame '{}'",
|
||||
target, observer, referenceFrame
|
||||
));
|
||||
}
|
||||
|
||||
// linear interpolation
|
||||
const double t = (ephemerisTime - timeEarlier) / (timeLater - timeEarlier);
|
||||
@@ -1132,10 +1177,12 @@ glm::dmat3 SpiceManager::getEstimatedTransformMatrix(const std::string& fromFram
|
||||
*(coveredTimes.begin()),
|
||||
reinterpret_cast<double(*)[3]>(glm::value_ptr(result))
|
||||
);
|
||||
throwOnSpiceError(fmt::format(
|
||||
"Error estimating transform matrix from frame '{}' to from '{}' at time '{}'",
|
||||
fromFrame, toFrame, time
|
||||
));
|
||||
if (failed_c()) {
|
||||
throwSpiceError(fmt::format(
|
||||
"Error estimating transform matrix from '{}' to from '{}' at time '{}'",
|
||||
fromFrame, toFrame, time
|
||||
));
|
||||
}
|
||||
}
|
||||
else if (coveredTimes.upper_bound(time) == coveredTimes.end()) {
|
||||
// coverage earlier, fetch last transform
|
||||
@@ -1145,10 +1192,12 @@ glm::dmat3 SpiceManager::getEstimatedTransformMatrix(const std::string& fromFram
|
||||
*(coveredTimes.rbegin()),
|
||||
reinterpret_cast<double(*)[3]>(glm::value_ptr(result))
|
||||
);
|
||||
throwOnSpiceError(fmt::format(
|
||||
"Error estimating transform matrix from frame '{}' to from '{}' at time '{}'",
|
||||
fromFrame, toFrame, time
|
||||
));
|
||||
if (failed_c()) {
|
||||
throwSpiceError(fmt::format(
|
||||
"Error estimating transform matrix from frame '{}' to '{}' at time '{}'",
|
||||
fromFrame, toFrame, time
|
||||
));
|
||||
}
|
||||
}
|
||||
else {
|
||||
// coverage both earlier and later, interpolate these transformations
|
||||
@@ -1162,10 +1211,12 @@ glm::dmat3 SpiceManager::getEstimatedTransformMatrix(const std::string& fromFram
|
||||
earlier,
|
||||
reinterpret_cast<double(*)[3]>(glm::value_ptr(earlierTransform))
|
||||
);
|
||||
throwOnSpiceError(fmt::format(
|
||||
"Error estimating transform matrix from frame '{}' to from '{}' at time '{}'",
|
||||
fromFrame, toFrame, time
|
||||
));
|
||||
if (failed_c()) {
|
||||
throwSpiceError(fmt::format(
|
||||
"Error estimating transform matrix from frame '{}' to '{}' at time '{}'",
|
||||
fromFrame, toFrame, time
|
||||
));
|
||||
}
|
||||
|
||||
glm::dmat3 laterTransform = glm::dmat3(1.0);
|
||||
pxform_c(
|
||||
@@ -1174,10 +1225,12 @@ glm::dmat3 SpiceManager::getEstimatedTransformMatrix(const std::string& fromFram
|
||||
later,
|
||||
reinterpret_cast<double(*)[3]>(glm::value_ptr(laterTransform))
|
||||
);
|
||||
throwOnSpiceError(fmt::format(
|
||||
"Error estimating transform matrix from frame '{}' to from '{}' at time '{}'",
|
||||
fromFrame, toFrame, time
|
||||
));
|
||||
if (failed_c()) {
|
||||
throwSpiceError(fmt::format(
|
||||
"Error estimating transform matrix from frame '{}' to '{}' at time '{}'",
|
||||
fromFrame, toFrame, time
|
||||
));
|
||||
}
|
||||
|
||||
const double t = (time - earlier) / (later - earlier);
|
||||
result = earlierTransform * (1.0 - t) + laterTransform * t;
|
||||
|
||||
Reference in New Issue
Block a user