Add documentation to RenderablePlaneProjection, remove unused parameters

This commit is contained in:
Alexander Bock
2022-02-11 11:01:37 +01:00
parent e51e887f1f
commit 53d34c8dfe
2 changed files with 18 additions and 27 deletions

View File

@@ -45,13 +45,19 @@ namespace {
constexpr const char* _loggerCat = "RenderablePlaneProjection";
constexpr const char* GalacticFrame = "GALACTIC";
// @TODO (emmbr 2022-01-20) Add documentation
struct [[codegen::Dictionary(RenderablePlaneProjection)]] Parameters {
std::optional<std::string> spacecraft;
std::optional<std::string> instrument;
std::optional<bool> moving;
std::optional<std::string> name;
// The SPICE name of the spacecraft from which the projection is performed
std::string spacecraft;
// The SPICE name of the instrument that is used to project the image onto this
// RenderablePlaneProjection
std::string instrument;
// The SPICE name of the default target that is imaged by this planet
std::optional<std::string> defaultTarget;
// The image that is used on this plane before any image is loaded from the
// ImageSequencerr
std::optional<std::string> texture;
};
#include "renderableplaneprojection_codegen.cpp"
@@ -60,17 +66,15 @@ namespace {
namespace openspace {
documentation::Documentation RenderablePlaneProjection::Documentation() {
return codegen::doc<Parameters>("spacecraftinstruments_renderableorbitdisc");
return codegen::doc<Parameters>("spacecraftinstruments_renderableplaneprojection");
}
RenderablePlaneProjection::RenderablePlaneProjection(const ghoul::Dictionary& dict)
: Renderable(dict)
{
const Parameters p = codegen::bake<Parameters>(dict);
_spacecraft = p.spacecraft.value_or(_spacecraft);
_instrument = p.instrument.value_or(_instrument);
_moving = p.moving.value_or(_moving);
_name = p.name.value_or(_name);
_spacecraft = p.spacecraft;
_instrument = p.instrument;
_defaultTarget = p.defaultTarget.value_or(_defaultTarget);
if (p.texture.has_value()) {
@@ -118,7 +122,7 @@ void RenderablePlaneProjection::render(const RenderData& data, RendererTasks&) {
_instrument
);
if (!_hasImage || (_moving && !active)) {
if (!_hasImage) {
return;
}
@@ -161,7 +165,7 @@ void RenderablePlaneProjection::update(const UpdateData& data) {
const double timePast = std::abs(img.timeRange.start - _previousTime);
if (_moving || _planeIsDirty) {
if (_planeIsDirty) {
updatePlane(img, time);
}
else if (timePast > std::numeric_limits<double>::epsilon()) {
@@ -245,9 +249,7 @@ void RenderablePlaneProjection::updatePlane(const Image& img, double currentTime
) * bounds[j];
glm::dvec3 cornerPosition = glm::proj(vecToTarget, bounds[j]);
if (!_moving) {
cornerPosition -= vecToTarget;
}
cornerPosition -= vecToTarget;
cornerPosition = SpiceManager::ref().frameTransformationMatrix(
GalacticFrame,
_target.frame,
@@ -258,15 +260,6 @@ void RenderablePlaneProjection::updatePlane(const Image& img, double currentTime
projection[j] = glm::vec3(cornerPosition * 1000.0);
}
if (!_moving) {
Scene* scene = global::renderEngine->scene();
SceneGraphNode* thisNode = scene->sceneGraphNode(_name);
SceneGraphNode* newParent = scene->sceneGraphNode(_target.node);
if (thisNode && newParent) {
thisNode->setParent(*newParent);
}
}
const GLfloat vertex_data[] = {
// square of two triangles drawn within fov in target coordinates
// x y z w s t
@@ -299,7 +292,7 @@ void RenderablePlaneProjection::updatePlane(const Image& img, double currentTime
reinterpret_cast<void*>(sizeof(GLfloat) * 4)
);
if (!_moving && !img.path.empty()) {
if (!img.path.empty()) {
_texturePath = img.path;
loadTexture();
}

View File

@@ -86,8 +86,6 @@ private:
std::string frame;
std::string node;
} _target;
std::string _name = "ImagePlane";
bool _moving = false;
bool _hasImage = false;
};