mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-11 15:58:45 -05:00
Enable Translation classes to signal when settings have changed substantially
RenderableTrail listens to those changes and recomputes the trail if Translation settings have changed Minor GUI improvements Remove try/catch block from SpiceRotation Update Ghoul reference
This commit is contained in:
Submodule ext/ghoul updated: 4301855146...822898275c
@@ -46,7 +46,16 @@ public:
|
||||
|
||||
glm::dvec3 position(double time);
|
||||
|
||||
// Registers a callback that gets called when a significant change has been made that
|
||||
// invalidates potentially stored points, for example in trails
|
||||
void onParameterChange(std::function<void()> callback);
|
||||
|
||||
static openspace::Documentation Documentation();
|
||||
|
||||
protected:
|
||||
void notifyObservers();
|
||||
|
||||
std::function<void()> _onParameterChangeCallback;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -349,7 +349,7 @@ void RenderablePlanet::render(const RenderData& data) {
|
||||
glm::dmat4 rot = glm::rotate(glm::dmat4(1.0), M_PI_2, glm::dvec3(1, 0, 0));
|
||||
glm::dmat4 roty = glm::rotate(glm::dmat4(1.0), M_PI_2, glm::dvec3(0, -1, 0));
|
||||
//glm::dmat4 rotProp = glm::rotate(glm::dmat4(1.0), glm::radians(static_cast<double>(_rotation)), glm::dvec3(0, 1, 0));
|
||||
modelTransform = modelTransform * rot /** roty*/ /** rotProp*/;
|
||||
modelTransform = modelTransform * rot * roty /** rotProp*/;
|
||||
|
||||
glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform;
|
||||
|
||||
|
||||
@@ -143,6 +143,7 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary)
|
||||
_translation = std::unique_ptr<Translation>(Translation::createFromDictionary(
|
||||
dictionary.value<ghoul::Dictionary>(KeyTranslation)
|
||||
));
|
||||
addPropertySubOwner(_translation.get());
|
||||
|
||||
_lineColor = dictionary.value<glm::vec3>(KeyColor);
|
||||
addProperty(_lineColor);
|
||||
|
||||
@@ -131,7 +131,7 @@ openspace::Documentation RenderableTrailOrbit::Documentation() {
|
||||
RenderableTrailOrbit::RenderableTrailOrbit(const ghoul::Dictionary& dictionary)
|
||||
: RenderableTrail(dictionary)
|
||||
, _period("period", "Period in days", 0.0, 0.0, 1e9)
|
||||
, _resolution("resoluion", "Number of Samples along Orbit", 10000, 1, 1e6)
|
||||
, _resolution("resolution", "Number of Samples along Orbit", 10000, 1, 1e6)
|
||||
, _needsFullSweep(true)
|
||||
, _indexBufferDirty(true)
|
||||
{
|
||||
@@ -141,6 +141,10 @@ RenderableTrailOrbit::RenderableTrailOrbit(const ghoul::Dictionary& dictionary)
|
||||
"RenderableTrailOrbit"
|
||||
);
|
||||
|
||||
_translation->onParameterChange([this](){
|
||||
_needsFullSweep = true;
|
||||
});
|
||||
|
||||
// Period is in days
|
||||
using namespace std::chrono;
|
||||
int factor = duration_cast<seconds>(hours(24)).count();
|
||||
@@ -180,12 +184,6 @@ void RenderableTrailOrbit::update(const UpdateData& data) {
|
||||
// 2. Update floating position
|
||||
// 3. Determine which parts of the array to upload and upload the data
|
||||
|
||||
// Early bailout when we don't move in time
|
||||
if (data.timePaused || data.delta == 0.0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 1
|
||||
// Update the trails; the report contains whether any of the other values has been
|
||||
// touched and if so, how many
|
||||
|
||||
@@ -140,6 +140,10 @@ RenderableTrailTrajectory::RenderableTrailTrajectory(const ghoul::Dictionary& di
|
||||
"RenderableTrailTrajectory"
|
||||
);
|
||||
|
||||
_translation->onParameterChange([this]() {
|
||||
_needsFullSweep = true;
|
||||
});
|
||||
|
||||
_startTime = dictionary.value<std::string>(KeyStartTime);
|
||||
_startTime.onChange([this] { _needsFullSweep = true; });
|
||||
addProperty(_startTime);
|
||||
|
||||
@@ -116,17 +116,11 @@ SpiceRotation::SpiceRotation(const ghoul::Dictionary& dictionary)
|
||||
}
|
||||
|
||||
void SpiceRotation::update(const UpdateData& data) {
|
||||
try {
|
||||
_matrix = SpiceManager::ref().positionTransformMatrix(
|
||||
_sourceFrame,
|
||||
_destinationFrame,
|
||||
data.time
|
||||
);
|
||||
}
|
||||
catch (const ghoul::RuntimeError&) {
|
||||
// In case of missing coverage
|
||||
_matrix = glm::dmat3(1);
|
||||
}
|
||||
_matrix = SpiceManager::ref().positionTransformMatrix(
|
||||
_sourceFrame,
|
||||
_destinationFrame,
|
||||
data.time
|
||||
);
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -144,8 +144,18 @@ SpiceTranslation::SpiceTranslation(const ghoul::Dictionary& dictionary)
|
||||
}
|
||||
}
|
||||
|
||||
auto update = [this](){
|
||||
notifyObservers();
|
||||
};
|
||||
|
||||
_target.onChange(update);
|
||||
addProperty(_target);
|
||||
|
||||
_origin.onChange(update);
|
||||
addProperty(_origin);
|
||||
|
||||
_frame.onChange(update);
|
||||
addProperty(_frame);
|
||||
}
|
||||
|
||||
glm::dvec3 SpiceTranslation::position() const {
|
||||
|
||||
@@ -74,6 +74,7 @@ void GuiPropertyComponent::renderPropertyOwner(properties::PropertyOwner* owner)
|
||||
return;
|
||||
}
|
||||
|
||||
int nThisProperty = nVisibleProperties(owner->properties(), _visibility);
|
||||
ImGui::PushID(owner->name().c_str());
|
||||
const auto& subOwners = owner->propertySubOwners();
|
||||
for (properties::PropertyOwner* subOwner : subOwners) {
|
||||
@@ -82,7 +83,7 @@ void GuiPropertyComponent::renderPropertyOwner(properties::PropertyOwner* owner)
|
||||
if (count == 0) {
|
||||
continue;
|
||||
}
|
||||
if (subOwners.size() == 1) {
|
||||
if (subOwners.size() == 1 && (nThisProperty == 0)) {
|
||||
renderPropertyOwner(subOwner);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -97,5 +97,14 @@ glm::dvec3 Translation::position(double time) {
|
||||
return position();
|
||||
}
|
||||
|
||||
void Translation::notifyObservers() {
|
||||
if (_onParameterChangeCallback) {
|
||||
_onParameterChangeCallback();
|
||||
}
|
||||
}
|
||||
|
||||
void Translation::onParameterChange(std::function<void()> callback) {
|
||||
_onParameterChangeCallback = std::move(callback);
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
Reference in New Issue
Block a user