mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-23 04:30:09 -05:00
Pull merge before committing nullptr access guard in globebrowsing
This commit is contained in:
@@ -85,6 +85,12 @@ namespace {
|
||||
"of the Sun."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo DisableFaceCullingInfo = {
|
||||
"DisableFaceCulling",
|
||||
"Disable Face Culling",
|
||||
"Disable OpenGL automatic face culling optimization."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo ModelTransformInfo = {
|
||||
"ModelTransform",
|
||||
"Model Transform",
|
||||
@@ -92,6 +98,12 @@ namespace {
|
||||
"all other transformations are applied."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo RotationVecInfo = {
|
||||
"RotationVector",
|
||||
"Rotation Vector",
|
||||
"Rotation Vector using degrees"
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo LightSourcesInfo = {
|
||||
"LightSources",
|
||||
"Light Sources",
|
||||
@@ -143,12 +155,24 @@ documentation::Documentation RenderableModel::Documentation() {
|
||||
Optional::Yes,
|
||||
ShadingInfo.description
|
||||
},
|
||||
{
|
||||
DisableFaceCullingInfo.identifier,
|
||||
new BoolVerifier,
|
||||
Optional::Yes,
|
||||
DisableFaceCullingInfo.description
|
||||
},
|
||||
{
|
||||
ModelTransformInfo.identifier,
|
||||
new DoubleMatrix3Verifier,
|
||||
Optional::Yes,
|
||||
ModelTransformInfo.description
|
||||
},
|
||||
{
|
||||
RotationVecInfo.identifier,
|
||||
new DoubleVector3Verifier,
|
||||
Optional::Yes,
|
||||
RotationVecInfo.description
|
||||
},
|
||||
{
|
||||
LightSourcesInfo.identifier,
|
||||
new TableVerifier({
|
||||
@@ -172,7 +196,9 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
|
||||
, _diffuseIntensity(DiffuseIntensityInfo, 1.f, 0.f, 1.f)
|
||||
, _specularIntensity(SpecularIntensityInfo, 1.f, 0.f, 1.f)
|
||||
, _performShading(ShadingInfo, true)
|
||||
, _modelTransform(ModelTransformInfo, glm::mat3(1.f))
|
||||
, _disableFaceCulling(DisableFaceCullingInfo, false)
|
||||
, _modelTransform(ModelTransformInfo, glm::dmat3(1.0), glm::dmat3(-1.0), glm::dmat3(1.0))
|
||||
, _rotationVec(RotationVecInfo, glm::dvec3(0), glm::dvec3(0), glm::dvec3(360))
|
||||
, _lightSourcePropertyOwner({ "LightSources", "Light Sources" })
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
@@ -214,6 +240,10 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
|
||||
_performShading = dictionary.value<bool>(ShadingInfo.identifier);
|
||||
}
|
||||
|
||||
if (dictionary.hasKey(DisableFaceCullingInfo.identifier)) {
|
||||
_disableFaceCulling = dictionary.value<bool>(DisableFaceCullingInfo.identifier);
|
||||
}
|
||||
|
||||
if (dictionary.hasKey(LightSourcesInfo.identifier)) {
|
||||
const ghoul::Dictionary& lsDictionary =
|
||||
dictionary.value<ghoul::Dictionary>(LightSourcesInfo.identifier);
|
||||
@@ -238,6 +268,17 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
|
||||
addProperty(_diffuseIntensity);
|
||||
addProperty(_specularIntensity);
|
||||
addProperty(_performShading);
|
||||
addProperty(_disableFaceCulling);
|
||||
addProperty(_modelTransform);
|
||||
addProperty(_rotationVec);
|
||||
|
||||
_rotationVec.onChange([this]() {
|
||||
glm::vec3 degreeVector = _rotationVec;
|
||||
glm::vec3 radianVector = glm::vec3(glm::radians(degreeVector.x),
|
||||
glm::radians(degreeVector.y), glm::radians(degreeVector.z));
|
||||
_modelTransform = glm::mat4_cast(
|
||||
glm::quat(radianVector));
|
||||
});
|
||||
}
|
||||
|
||||
bool RenderableModel::isReady() const {
|
||||
@@ -361,8 +402,16 @@ void RenderableModel::render(const RenderData& data, RendererTasks&) {
|
||||
_texture->bind();
|
||||
_program->setUniform(_uniformCache.texture, unit);
|
||||
|
||||
if (_disableFaceCulling) {
|
||||
glDisable(GL_CULL_FACE);
|
||||
}
|
||||
|
||||
_geometry->render();
|
||||
|
||||
if (_disableFaceCulling) {
|
||||
glEnable(GL_CULL_FACE);
|
||||
}
|
||||
|
||||
_program->deactivate();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,10 @@
|
||||
#include <openspace/properties/scalar/floatproperty.h>
|
||||
#include <ghoul/opengl/uniformcache.h>
|
||||
#include <memory>
|
||||
#include <openspace/properties/matrix/dmat4property.h>
|
||||
#include <openspace/properties/vector/vec3property.h>
|
||||
|
||||
|
||||
|
||||
namespace ghoul::opengl {
|
||||
class ProgramObject;
|
||||
@@ -73,11 +77,14 @@ private:
|
||||
properties::StringProperty _colorTexturePath;
|
||||
|
||||
properties::FloatProperty _ambientIntensity;
|
||||
|
||||
properties::FloatProperty _diffuseIntensity;
|
||||
properties::FloatProperty _specularIntensity;
|
||||
|
||||
properties::BoolProperty _performShading;
|
||||
properties::Mat3Property _modelTransform;
|
||||
properties::BoolProperty _disableFaceCulling;
|
||||
properties::DMat4Property _modelTransform;
|
||||
properties::Vec3Property _rotationVec;
|
||||
|
||||
ghoul::opengl::ProgramObject* _program = nullptr;
|
||||
UniformCache(opacity, nLightSources, lightDirectionsViewSpace, lightIntensities,
|
||||
|
||||
@@ -46,6 +46,12 @@ namespace {
|
||||
"This value specifies the destination frame that is used for the coordinate "
|
||||
"transformation. This has to be a valid SPICE name."
|
||||
};
|
||||
|
||||
constexpr openspace::properties::Property::PropertyInfo TimeFrameInfo = {
|
||||
"TimeFrame",
|
||||
"Time Frame",
|
||||
"The time frame in which the spice kernels are valid."
|
||||
};
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
@@ -80,7 +86,13 @@ documentation::Documentation SpiceRotation::Documentation() {
|
||||
"A single kernel or list of kernels that this SpiceTranslation depends "
|
||||
"on. All provided kernels will be loaded before any other operation is "
|
||||
"performed."
|
||||
}
|
||||
},
|
||||
{
|
||||
TimeFrameInfo.identifier,
|
||||
new ReferencingVerifier("core_time_frame"),
|
||||
Optional::Yes,
|
||||
TimeFrameInfo.description
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -113,6 +125,16 @@ SpiceRotation::SpiceRotation(const ghoul::Dictionary& dictionary)
|
||||
}
|
||||
}
|
||||
|
||||
if (dictionary.hasKey(TimeFrameInfo.identifier)) {
|
||||
ghoul::Dictionary timeFrameDictionary;
|
||||
dictionary.getValue(TimeFrameInfo.identifier, timeFrameDictionary);
|
||||
_timeFrame = TimeFrame::createFromDictionary(timeFrameDictionary);
|
||||
if (_timeFrame == nullptr) {
|
||||
throw ghoul::RuntimeError("Invalid dictionary for TimeFrame.");
|
||||
}
|
||||
addPropertySubOwner(_timeFrame.get());
|
||||
}
|
||||
|
||||
addProperty(_sourceFrame);
|
||||
addProperty(_destinationFrame);
|
||||
|
||||
@@ -121,6 +143,9 @@ SpiceRotation::SpiceRotation(const ghoul::Dictionary& dictionary)
|
||||
}
|
||||
|
||||
glm::dmat3 SpiceRotation::matrix(const UpdateData& data) const {
|
||||
if (_timeFrame && !_timeFrame->isActive(data.time)) {
|
||||
return glm::dmat3(1.0);
|
||||
}
|
||||
return SpiceManager::ref().positionTransformMatrix(
|
||||
_sourceFrame,
|
||||
_destinationFrame,
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <openspace/scene/rotation.h>
|
||||
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/scene/timeframe.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
@@ -45,6 +46,7 @@ public:
|
||||
private:
|
||||
properties::StringProperty _sourceFrame;
|
||||
properties::StringProperty _destinationFrame;
|
||||
std::unique_ptr<TimeFrame> _timeFrame;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
Reference in New Issue
Block a user