Adding static Settings to Renderable (#2578)

* Add settings to Renderable to control whether the renderbin is updated based on Opacity
* Remove duplicate RenderBin specification for RenderableSphere
* Remove unnecessary RenderBin specifications of Lagrange points
* Don't automatically update the renderbin for RenderableLabel and RenderablePlane
* Remove extra `setRenderBinFromOpacity` from RenderableSpheres
* Move information about whether a renderable should be updated when disabled
* Some cleanup of Renderable class
* Don't update the renderbin automatically if the user specified the renderbin manually
This commit is contained in:
Alexander Bock
2023-04-10 20:49:01 +02:00
committed by GitHub
parent bebac26a7f
commit 9022aad479
33 changed files with 72 additions and 76 deletions
@@ -92,7 +92,6 @@ RenderableBoxGrid::RenderableBoxGrid(const ghoul::Dictionary& dictionary)
const Parameters p = codegen::bake<Parameters>(dictionary);
addProperty(_opacity);
registerUpdateRenderBinFromOpacity();
_color = p.color.value_or(_color);
_color.setViewOption(properties::Property::ViewOptions::Color);
@@ -135,7 +135,6 @@ RenderableGrid::RenderableGrid(const ghoul::Dictionary& dictionary)
const Parameters p = codegen::bake<Parameters>(dictionary);
addProperty(_opacity);
registerUpdateRenderBinFromOpacity();
_color = p.color.value_or(_color);
_color.setViewOption(properties::Property::ViewOptions::Color);
@@ -117,7 +117,6 @@ RenderableRadialGrid::RenderableRadialGrid(const ghoul::Dictionary& dictionary)
const Parameters p = codegen::bake<Parameters>(dictionary);
addProperty(_opacity);
registerUpdateRenderBinFromOpacity();
_color = p.color.value_or(_color);
_color.setViewOption(properties::Property::ViewOptions::Color);
@@ -94,7 +94,6 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
const Parameters p = codegen::bake<Parameters>(dictionary);
addProperty(_opacity);
registerUpdateRenderBinFromOpacity();
_color = p.color.value_or(_color);
_color.setViewOption(properties::Property::ViewOptions::Color);
+2 -3
View File
@@ -238,7 +238,7 @@ documentation::Documentation RenderableLabel::Documentation() {
}
RenderableLabel::RenderableLabel(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
: Renderable(dictionary, { .automaticallyUpdateRenderBin = false })
, _blendMode(BlendModeInfo, properties::OptionProperty::DisplayType::Dropdown)
, _color(ColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f))
, _fontSize(FontSizeInfo, 50.f, 1.f, 100.f)
@@ -260,11 +260,10 @@ RenderableLabel::RenderableLabel(const ghoul::Dictionary& dictionary)
const Parameters p = codegen::bake<Parameters>(dictionary);
addProperty(_opacity);
registerUpdateRenderBinFromOpacity();
_blendMode.addOptions({
{ BlendMode::Normal, "Normal" },
{ BlendMode::Additive, "Additive"}
{ BlendMode::Additive, "Additive" }
});
_blendMode.onChange([&]() {
switch (_blendMode) {
+1 -2
View File
@@ -293,7 +293,6 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
const Parameters p = codegen::bake<Parameters>(dictionary);
addProperty(_opacity);
registerUpdateRenderBinFromOpacity();
if (p.forceRenderInvisible.has_value()) {
_forceRenderInvisible = *p.forceRenderInvisible;
@@ -690,7 +689,7 @@ void RenderableModel::update(const UpdateData& data) {
glm::compMax(data.modelTransform.scale)
);
// Set Interaction sphere size to be 10% of the bounding sphere
setInteractionSphere(_boundingSphere * 0.1);
setInteractionSphere(boundingSphere() * 0.1);
if (_geometry->hasAnimation() && !_animationStart.empty()) {
double relativeTime;
@@ -181,7 +181,7 @@ RenderableNodeLine::RenderableNodeLine(const ghoul::Dictionary& dictionary)
"Trying to use relative offsets for start node '{}' that has no "
"bounding sphere. This will result in no offset. Use direct "
"values by setting UseRelativeOffsets to false",
_parent->identifier(), _start
parent()->identifier(), _start
));
}
});
@@ -199,7 +199,7 @@ RenderableNodeLine::RenderableNodeLine(const ghoul::Dictionary& dictionary)
"Trying to use relative offsets for end node '{}' that has no "
"bounding sphere. This will result in no offset. Use direct "
"values by setting UseRelativeOffsets to false",
_parent->identifier(), _end
parent()->identifier(), _end
));
}
});
@@ -212,7 +212,7 @@ RenderableNodeLine::RenderableNodeLine(const ghoul::Dictionary& dictionary)
if (!startNode) {
LERROR(fmt::format(
"Error when recomputing node line offsets for scene graph node '{}'. "
"Could not find start node '{}'", _parent->identifier(), _start.value()
"Could not find start node '{}'", parent()->identifier(), _start.value()
));
return;
}
@@ -220,7 +220,7 @@ RenderableNodeLine::RenderableNodeLine(const ghoul::Dictionary& dictionary)
if (!endNode) {
LERROR(fmt::format(
"Error when recomputing node line offsets for scene graph node '{}'. "
"Could not find end node '{}'", _parent->identifier(), _end.value()
"Could not find end node '{}'", parent()->identifier(), _end.value()
));
return;
}
@@ -229,8 +229,10 @@ RenderableNodeLine::RenderableNodeLine(const ghoul::Dictionary& dictionary)
// Recompute previous offsets to relative values
double startBs = startNode->boundingSphere();
double endBs = endNode->boundingSphere();
_startOffset = startBs > 0.0 ? _startOffset / startBs : 0.0;
_endOffset = endBs > 0.0 ? _endOffset / startBs : 0.0;
_startOffset =
static_cast<float>(startBs > 0.0 ? _startOffset / startBs : 0.0);
_endOffset =
static_cast<float>(endBs > 0.0 ? _endOffset / startBs : 0.0);
}
else {
// Recompute relative values to meters
+1 -2
View File
@@ -113,7 +113,7 @@ documentation::Documentation RenderablePlane::Documentation() {
}
RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
: Renderable(dictionary, { .automaticallyUpdateRenderBin = false })
, _blendMode(BlendModeInfo, properties::OptionProperty::DisplayType::Dropdown)
, _billboard(BillboardInfo, false)
, _mirrorBackside(MirrorBacksideInfo, false)
@@ -123,7 +123,6 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
Parameters p = codegen::bake<Parameters>(dictionary);
addProperty(_opacity);
registerUpdateRenderBinFromOpacity();
_size = p.size;
_billboard = p.billboard.value_or(_billboard);
@@ -162,7 +162,6 @@ RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary)
const Parameters p = codegen::bake<Parameters>(dictionary);
addProperty(_opacity);
registerUpdateRenderBinFromOpacity();
_size = p.size;
_segments = p.segments;
@@ -208,7 +207,6 @@ RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary)
addProperty(_disableFadeInDistance);
setBoundingSphere(_size);
setRenderBinFromOpacity();
}
bool RenderableSphere::isReady() const {
@@ -164,7 +164,6 @@ RenderableTimeVaryingSphere::RenderableTimeVaryingSphere(
const Parameters p = codegen::bake<Parameters>(dictionary);
addProperty(_opacity);
registerUpdateRenderBinFromOpacity();
_size = p.size;
_segments = p.segments;
@@ -208,7 +207,6 @@ RenderableTimeVaryingSphere::RenderableTimeVaryingSphere(
}
setBoundingSphere(_size);
setRenderBinFromOpacity();
}
bool RenderableTimeVaryingSphere::isReady() const {
+1 -1
View File
@@ -433,7 +433,7 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) {
);
const double distance = glm::distance(trailPosWorld, data.camera.eyePositionVec3());
if (distance > _boundingSphere * DISTANCE_CULLING_RADII) {
if (distance > boundingSphere() * DISTANCE_CULLING_RADII) {
return;
}