Merge branch 'develop' of github.com:OpenSpace/OpenSpace into pr/scenegraph-refactor

This commit is contained in:
Emil Axelsson
2017-03-16 16:35:29 +01:00
62 changed files with 1773 additions and 1059 deletions

View File

@@ -36,6 +36,8 @@
#include <SGCTOpenVR.h>
#endif // OPENVR_SUPPORT
#define DEVELOPER_MODE
namespace {
const char* _loggerCat = "main";
@@ -395,7 +397,13 @@ int main_main(int argc, char** argv) {
} // namespace
int main(int argc, char** argv) {
// If we are working as a developer, we don't want to catch the exceptions in order to
// find the locations where the exceptions are raised.
// If we are not in developer mode, we want to catch and at least log the error before
// dying
#ifdef DEVELOPER_MODE
return main_main(argc, argv);
#else
// We wrap the actual main function in a try catch block so that we can get and print
// some additional information in case an exception is raised
try {
@@ -422,4 +430,5 @@ int main(int argc, char** argv) {
LogMgr.flushLogs();
return EXIT_FAILURE;
}
#endif // DEVELOPER_MODE
}

View File

@@ -44,6 +44,8 @@ namespace documentation {
* description of the Verifier subclass and what it tests for.
*/
struct Verifier {
virtual ~Verifier() = default;
/**
* This method tests whether the \p key contained in the \p dictionary adheres to
* whatever the concrete Verifer needs to test. The actual testing depends on the

View File

@@ -108,11 +108,10 @@ namespace interaction {
class InteractionMode
{
class InteractionMode {
public:
InteractionMode();
~InteractionMode();
virtual ~InteractionMode();
// Mutators
virtual void setFocusNode(SceneGraphNode* focusNode);

View File

@@ -120,7 +120,7 @@ class ParallelConnection {
*/
static scripting::LuaLibrary luaLibrary();
Status status();
size_t nConnections();
int nConnections();
std::shared_ptr<ghoul::Event<>> connectionEvent();

View File

@@ -38,8 +38,8 @@ namespace ghoul {
namespace openspace {
class RenderData;
class RaycastData;
struct RenderData;
struct RaycastData;
class VolumeRaycaster {
public:

View File

@@ -74,7 +74,7 @@ public:
/**
* Default constructor initializing the AberrationCorrection to Type::None with a
* Drection::Reception
* Direction::Reception
*/
AberrationCorrection() = default;
@@ -461,6 +461,33 @@ public:
AberrationCorrection aberrationCorrection, double ephemerisTime,
double& lightTime) const;
/**
* Returns the \p position of a \p target body relative to an \p observer in a
* specific \p referenceFrame, optionally corrected for \p lightTime (planetary
* aberration) and stellar aberration (\p aberrationCorrection).
* \param target The target body name or the target body's NAIF ID
* \param observer The observing body name or the observing body's NAIF ID
* \param referenceFrame The reference frame of the output position vector
* \param aberrationCorrection The aberration correction used for the position
* calculation
* \param ephemerisTime The time at which the position is to be queried
* \return The position of the \p target relative to the \p observer in the specified
* \p referenceFrame
* \throws SpiceException If the \p target or \p observer do not name a valid
* NAIF object, \p referenceFrame does not name a valid reference frame or if there is
* not sufficient data available to compute the position or neither the target nor the
* observer have coverage.
* \pre \p target must not be empty.
* \pre \p observer must not be empty.
* \pre \p referenceFrame must not be empty.
* \post If an exception is thrown, \p lightTime will not be modified.
* \sa http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/spkpos_c.html
* \sa http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/req/naif_ids.html
*/
glm::dvec3 targetPosition(const std::string& target,
const std::string& observer, const std::string& referenceFrame,
AberrationCorrection aberrationCorrection, double ephemerisTime) const;
/**
* This method returns the transformation matrix that defines the transformation from
* the reference frame \p from to the reference frame \p to. As both reference frames

View File

@@ -170,8 +170,6 @@ bool RenderableModel::deinitialize() {
void RenderableModel::render(const RenderData& data) {
_programObject->activate();
double lt;
// Fading
if (_performFade && _fading > 0.f) {
_fading = _fading - 0.01f;
@@ -243,7 +241,6 @@ void RenderableModel::update(const UpdateData& data) {
// _time = futureTime;
//}
double lt;
_sunPos = OsEng.renderEngine().scene()->sceneGraphNode("Sun")->worldPosition();
}

View File

@@ -76,7 +76,7 @@ RenderablePath::RenderablePath(const ghoul::Dictionary& dictionary)
float fPointSteps; // Dictionary can not pick out ints...
if (!dictionary.getValue(keyPointSteps, fPointSteps))
fPointSteps = 4;
_pointSteps = fPointSteps;
_pointSteps = static_cast<int>(fPointSteps);
glm::vec3 color(0.f);
if (dictionary.hasKeyAndValue<glm::vec3>(keyColor))
@@ -145,7 +145,7 @@ void RenderablePath::render(const RenderData& data) {
return;
int nPointsToDraw = _vertexArray.size();// (time - _start) / (_stop - _start) * (_vertexArray.size()) + 1 + 0.5;
size_t nPointsToDraw = _vertexArray.size();// (time - _start) / (_stop - _start) * (_vertexArray.size()) + 1 + 0.5;
_programObject->activate();

View File

@@ -203,9 +203,9 @@ void RenderablePlane::render(const RenderData& data) {
if (textureNode != nullptr){
RenderablePlanetProjection* t = static_cast<RenderablePlanetProjection*>(textureNode->renderable());
_texture = std::unique_ptr<ghoul::opengl::Texture>(&(t->baseTexture()));
float h = _texture->height();
float w = _texture->width();
float scale = h / w;
unsigned int h = _texture->height();
unsigned int w = _texture->width();
float scale = static_cast<float>(h) / static_cast<float>(w);
scaleTransform = glm::scale(glm::mat4(1.0), glm::vec3(1.f, scale, 1.f));
}
}

View File

@@ -82,10 +82,10 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
//int nr2 = 0;
for (int i = 0; i <= _segments; i++) {
for (int nSegment = 0; nSegment <= _segments; ++nSegment) {
// define an extra vertex around the y-axis due to texture mapping
for (int j = 0; j <= _segments; j++) {
const float fi = static_cast<float>(i);
const float fi = static_cast<float>(nSegment);
const float fj = static_cast<float>(j);
// inclination angle (north to south)

View File

@@ -155,17 +155,17 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary)
addProperty(_useLineFade);
if (dictionary.hasKeyAndValue<double>(KeyFade)) {
_lineFade = dictionary.value<double>(KeyFade);
_lineFade = static_cast<float>(dictionary.value<double>(KeyFade));
}
addProperty(_lineFade);
if (dictionary.hasKeyAndValue<double>(KeyLineWidth)) {
_lineWidth = dictionary.value<double>(KeyLineWidth);
_lineWidth = static_cast<float>(dictionary.value<double>(KeyLineWidth));
}
addProperty(_lineWidth);
if (dictionary.hasKeyAndValue<double>(KeyPointSize)) {
_pointSize = dictionary.value<double>(KeyPointSize);
_pointSize = static_cast<int>(dictionary.value<double>(KeyPointSize));
}
addProperty(_pointSize);
@@ -247,12 +247,12 @@ void RenderableTrail::render(const RenderData & data) {
}
bool renderLines =
_renderingModes == RenderingModeLines |
_renderingModes == RenderingModeLinesPoints;
(_renderingModes == RenderingModeLines) |
(_renderingModes == RenderingModeLinesPoints);
bool renderPoints =
_renderingModes == RenderingModePoints |
_renderingModes == RenderingModeLinesPoints;
(_renderingModes == RenderingModePoints) |
(_renderingModes == RenderingModeLinesPoints);
if (renderLines) {
glLineWidth(_lineWidth);

View File

@@ -132,7 +132,7 @@ documentation::Documentation RenderableTrailOrbit::Documentation() {
RenderableTrailOrbit::RenderableTrailOrbit(const ghoul::Dictionary& dictionary)
: RenderableTrail(dictionary)
, _period("period", "Period in days", 0.0, 0.0, 1e9)
, _resolution("resolution", "Number of Samples along Orbit", 10000, 1, 1e6)
, _resolution("resolution", "Number of Samples along Orbit", 10000, 1, 1000000)
, _needsFullSweep(true)
, _indexBufferDirty(true)
{
@@ -148,7 +148,7 @@ RenderableTrailOrbit::RenderableTrailOrbit(const ghoul::Dictionary& dictionary)
// Period is in days
using namespace std::chrono;
int factor = duration_cast<seconds>(hours(24)).count();
long long factor = duration_cast<seconds>(hours(24)).count();
_period = dictionary.value<double>(KeyPeriod) * factor;
_period.onChange([&] { _needsFullSweep = true; _indexBufferDirty = true; });
addProperty(_period);
@@ -349,7 +349,7 @@ RenderableTrailOrbit::UpdateReport RenderableTrailOrbit::updateTrails(
}
// See how many points we need to drop
int nNewPoints = floor(delta / secondsPerPoint);
int nNewPoints = static_cast<int>(floor(delta / secondsPerPoint));
// If we would need to generate more new points than there are total points in the
// array, it is faster to regenerate the entire array
@@ -384,7 +384,7 @@ RenderableTrailOrbit::UpdateReport RenderableTrailOrbit::updateTrails(
else {
// See how many new points needs to be generated. Delta is negative, so we need
// to invert the ratio
int nNewPoints = -(floor(delta / secondsPerPoint));
int nNewPoints = -(static_cast<int>(floor(delta / secondsPerPoint)));
// If we would need to generate more new points than there are total points in the
// array, it is faster to regenerate the entire array

View File

@@ -130,7 +130,7 @@ RenderableTrailTrajectory::RenderableTrailTrajectory(const ghoul::Dictionary& di
, _timeStampSubsamplingFactor(
"subSample",
"Time Stamp Subsampling Factor",
1, 1, 1e9
1, 1, 1000000000
)
, _renderFullTrail("renderFullTrail", "Render Full Trail", false)
, _needsFullSweep(true)
@@ -159,7 +159,9 @@ RenderableTrailTrajectory::RenderableTrailTrajectory(const ghoul::Dictionary& di
addProperty(_sampleInterval);
if (dictionary.hasKeyAndValue<double>(KeyTimeStampSubsample)) {
_timeStampSubsamplingFactor = dictionary.value<double>(KeyTimeStampSubsample);
_timeStampSubsamplingFactor = static_cast<int>(
dictionary.value<double>(KeyTimeStampSubsample)
);
}
_timeStampSubsamplingFactor.onChange([this] { _subsamplingIsDirty = true; });
addProperty(_timeStampSubsamplingFactor);
@@ -208,7 +210,7 @@ void RenderableTrailTrajectory::update(const UpdateData& data) {
double totalSampleInterval = _sampleInterval / _timeStampSubsamplingFactor;
// How many values do we need to compute given the distance between the start and
// end date and the desired sample interval
int nValues = (_end - _start) / totalSampleInterval;
int nValues = static_cast<int>((_end - _start) / totalSampleInterval);
// Make space for the vertices
_vertexArray.clear();
@@ -246,16 +248,16 @@ void RenderableTrailTrajectory::update(const UpdateData& data) {
// If the full trail should be rendered at all times, we can directly render the
// entire set
_primaryRenderInformation.first = 0;
_primaryRenderInformation.count = _vertexArray.size();
_primaryRenderInformation.count = static_cast<GLsizei>(_vertexArray.size());
}
else {
// If only trail so far should be rendered, we need to find the corresponding time
// in the array and only render it until then
_primaryRenderInformation.first = 0;
double t = (data.time - _start) / (_end - _start);
_primaryRenderInformation.count = std::min<GLsizei>(
ceil(_vertexArray.size() * t),
_vertexArray.size() - 1
_primaryRenderInformation.count = std::min(
static_cast<GLsizei>(ceil(_vertexArray.size() * t)),
static_cast<GLsizei>(_vertexArray.size() - 1)
);
}

View File

@@ -82,15 +82,20 @@ bool ScreenSpaceFramebuffer::deinitialize(){
return true;
}
void ScreenSpaceFramebuffer::render(){
void ScreenSpaceFramebuffer::render() {
glm::vec2 resolution = OsEng.windowWrapper().currentWindowResolution();
glm::vec4 size = _size.value();
float xratio = _originalViewportSize.x / (size.z-size.x);
float yratio = _originalViewportSize.y / (size.w-size.y);;
if(!_renderFunctions.empty()){
glViewport (-size.x*xratio, -size.y*yratio, _originalViewportSize.x*xratio, _originalViewportSize.y*yratio);
if (!_renderFunctions.empty()) {
glViewport(
static_cast<GLint>(-size.x * xratio),
static_cast<GLint>(-size.y * yratio),
static_cast<GLsizei>(_originalViewportSize.x * xratio),
static_cast<GLsizei>(_originalViewportSize.y * yratio)
);
GLint defaultFBO = _framebuffer->getActiveObject();
_framebuffer->activate();
@@ -103,7 +108,12 @@ void ScreenSpaceFramebuffer::render(){
_framebuffer->deactivate();
glBindFramebuffer(GL_FRAMEBUFFER, defaultFBO);
glViewport (0, 0, resolution.x, resolution.y);
glViewport(
0,
0,
static_cast<GLsizei>(resolution.x),
static_cast<GLsizei>(resolution.y)
);
glm::mat4 rotation = rotationMatrix();
glm::mat4 translation = translationMatrix();

View File

@@ -157,15 +157,18 @@ void ScreenSpaceImage::updateTexture() {
if (_futureImage.valid() && DownloadManager::futureReady(_futureImage)) {
DownloadManager::MemoryFile imageFile = _futureImage.get();
if (imageFile.corrupted)
if (imageFile.corrupted) {
return nullptr;
}
return (ghoul::io::TextureReader::ref().loadTexture(
reinterpret_cast<void*>(imageFile.buffer),
imageFile.size,
imageFile.format)
);
}
else {
return nullptr;
}
}

View File

@@ -59,7 +59,7 @@ StaticScale::StaticScale(const ghoul::Dictionary& dictionary)
{
documentation::testSpecificationAndThrow(Documentation(), dictionary, "StaticScale");
_scaleValue = dictionary.value<double>(KeyValue);
_scaleValue = static_cast<float>(dictionary.value<double>(KeyValue));
}
double StaticScale::scaleValue() const {

View File

@@ -1,5 +1,3 @@
set (DEFAULT_MODULE ON)
set (OPENSPACE_DEPENDENCIES
kameleon
volume

View File

@@ -224,7 +224,7 @@ RenderableMultiresVolume::RenderableMultiresVolume (const ghoul::Dictionary& dic
}
addProperty(_selectorName);
_selectorName.onChange([&] {
_selectorName.onChange([&]() {
Selector s;
std::string newSelectorName = _selectorName;
if (newSelectorName == "simple") {

View File

@@ -72,6 +72,7 @@ void NewHorizonsModule::internalInitialize() {
std::vector<documentation::Documentation> NewHorizonsModule::documentations() const {
return {
RenderableFov::Documentation(),
RenderableModelProjection::Documentation(),
RenderablePlanetProjection::Documentation(),
ProjectionComponent::Documentation()

View File

@@ -24,26 +24,84 @@
#include <modules/newhorizons/rendering/renderablecrawlingline.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
#include <openspace/engine/openspaceengine.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/util/spicemanager.h>
#include <modules/newhorizons/util/imagesequencer.h>
namespace {
const std::string _loggerCat = "RenderableCrawlingLine";
const char* KeySource = "Source";
const char* KeyTarget = "Target";
const char* KeyInstrument = "Instrument";
const char* KeyReferenceFrame = "Frame";
const char* KeyColor = "RGB";
const char* KeyColor = "Color";
const char* KeyColorStart = "Start";
const char* KeyColorEnd = "End";
static const int SourcePosition = 0;
static const int TargetPosition = 1;
}
struct VBOData {
float position[3];
float color[4];
};
} // namespace
namespace openspace {
documentation::Documentation RenderableCrawlingLine::Documentation() {
using namespace documentation;
return {
"RenderableCrawlingLine",
"newhorizons_renderable_crawlingline",
{
{
KeySource,
new StringVerifier,
"Denotes the SPICE name of the source of the renderable crawling line, "
"for example, the space craft",
Optional::No
},
{
KeyTarget,
new StringVerifier,
"Denotes the SPICE name of the target of the crawling line",
Optional::Yes
},
{
KeyInstrument,
new StringVerifier,
"Denotes the SPICE name of the instrument that is used to render the "
"crawling line",
Optional::No
},
{
KeyColor,
new TableVerifier({
{
{
KeyColorStart,
new DoubleVector4Verifier,
"The color at the start of the line",
Optional::No
},
{
KeyColorEnd,
new DoubleVector4Verifier,
"The color at the end of the line",
Optional::No
}
},
Exhaustive::Yes
}),
"Specifies the colors that are used for the crawling line. One value "
"determines the starting color of the line, the second value is the "
"color at the end of the line.",
Optional::No
}
}
};
}
RenderableCrawlingLine::RenderableCrawlingLine(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _program(nullptr)
@@ -53,54 +111,60 @@ RenderableCrawlingLine::RenderableCrawlingLine(const ghoul::Dictionary& dictiona
, _frameCounter(0)
, _drawLine(false)
{
dictionary.getValue(KeySource, _source);
dictionary.getValue(KeyTarget, _target);
dictionary.getValue(KeyInstrument, _instrumentName);
dictionary.getValue(KeyReferenceFrame, _referenceFrame);
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"RenderableCrawlingLine"
);
_source = dictionary.value<std::string>(KeySource);
_target = dictionary.value<std::string>(KeyTarget);
_instrumentName = dictionary.value<std::string>(KeyInstrument);
if (dictionary.hasKeyAndValue<glm::vec3>(KeyColor)) {
dictionary.getValue(KeyColor, _lineColor);
}
else {
_lineColor = glm::vec3(1);
}
_lineColorBegin = dictionary.value<glm::vec4>(
std::string(KeyColor) + "." + KeyColorStart
);
_lineColorEnd = dictionary.value<glm::vec4>(
std::string(KeyColor) + "." + KeyColorEnd
);
}
bool RenderableCrawlingLine::isReady() const {
bool ready = true;
ready &= !_source.empty();
ready &= !_target.empty();
ready &= !_instrumentName.empty();
ready &= (_program != nullptr);
return ready;
return (_program != nullptr);
}
bool RenderableCrawlingLine::initialize() {
bool completeSuccess = true;
RenderEngine& renderEngine = OsEng.renderEngine();
_program = renderEngine.buildRenderProgram("RenderableCrawlingLine",
_program = renderEngine.buildRenderProgram(
"RenderableCrawlingLine",
"${MODULE_NEWHORIZONS}/shaders/crawlingline_vs.glsl",
"${MODULE_NEWHORIZONS}/shaders/crawlingline_fs.glsl");
if (!_program)
return false;
"${MODULE_NEWHORIZONS}/shaders/crawlingline_fs.glsl"
);
glGenVertexArrays(1, &_vao);
glGenBuffers(1, &_vbo);
glBindVertexArray(_vao);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferData(GL_ARRAY_BUFFER, 2 * sizeof(psc), NULL, GL_DYNAMIC_DRAW);
glBufferData(GL_ARRAY_BUFFER, 2 * sizeof(VBOData), NULL, GL_DYNAMIC_DRAW);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, (void*)0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(VBOData), (void*)0);
glEnableVertexAttribArray(1);
glVertexAttribPointer(
1,
4,
GL_FLOAT,
GL_FALSE,
sizeof(VBOData),
reinterpret_cast<void*>(offsetof(VBOData, color))
);
glBindVertexArray(0);
return completeSuccess;
return true;
}
bool RenderableCrawlingLine::deinitialize(){
@@ -119,73 +183,107 @@ bool RenderableCrawlingLine::deinitialize(){
}
void RenderableCrawlingLine::render(const RenderData& data) {
if (_drawLine) {
_program->activate();
_frameCounter++;
// fetch data
psc currentPosition = data.position;
psc campos = data.camera.position();
glm::mat4 camrot = glm::mat4(data.camera.viewRotationMatrix());
glm::mat4 transform = glm::mat4(1);
// setup the data to the shader
_program->setUniform("ViewProjection", data.camera.viewProjectionMatrix());
_program->setUniform("ModelTransform", transform);
int frame = _frameCounter % 60;
float fadingFactor = static_cast<float>(sin((frame * 3.14159) / 60));
float alpha = 0.6f + fadingFactor*0.4f;
glLineWidth(2.f);
_program->setUniform("_alpha", alpha);
_program->setUniform("color", _lineColor);
setPscUniforms(*_program.get(), data.camera, data.position);
glBindVertexArray(_vao);
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(psc) * 2, _positions);
glEnableVertexAttribArray(0);
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0);
glDrawArrays(GL_LINES, 0, 2);
glBindVertexArray(0);
_program->deactivate();
if (!_drawLine) {
return;
}
_program->activate();
_frameCounter++;
glm::dmat4 modelTransform =
glm::translate(glm::dmat4(1.0), data.modelTransform.translation) * // Translation
glm::dmat4(data.modelTransform.rotation) * // Spice rotation
glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale));
glm::dmat4 modelViewProjectionTransform =
data.camera.projectionMatrix() *
glm::mat4(data.camera.combinedViewMatrix() *
modelTransform
)
;
//glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform;
// setup the data to the shader
//_program->setUniform("modelViewTransform", glm::mat4(modelViewTransform));
//_program->setUniform("projectionTransform", data.camera.projectionMatrix());
_program->setUniform("modelViewProjection", modelViewProjectionTransform);
int frame = _frameCounter % 60;
float fadingFactor = static_cast<float>(sin((frame * 3.14159) / 60));
float alpha = 0.6f + fadingFactor*0.4f;
glLineWidth(2.f);
_program->setUniform("_alpha", alpha);
//_program->setUniform("color", _lineColor);
//setPscUniforms(*_program.get(), data.camera, data.position);
glBindVertexArray(_vao);
glDrawArrays(GL_LINES, 0, 2);
glBindVertexArray(0);
_program->deactivate();
}
void RenderableCrawlingLine::update(const UpdateData& data) {
if (_program->isDirty())
if (_program->isDirty()) {
_program->rebuildFromFile();
glm::dmat3 transformMatrix = SpiceManager::ref().positionTransformMatrix(_source, _referenceFrame, data.time);
glm::mat4 tmp = glm::mat4(1);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++){
tmp[i][j] = static_cast<float>(transformMatrix[i][j]);
}
}
_positions[SourcePosition] = PowerScaledCoordinate::CreatePowerScaledCoordinate(0, 0, 0);
glm::dmat3 transformMatrix = SpiceManager::ref().positionTransformMatrix(
_source,
//"ECLIPJ2000",
"GALACTIC",
data.time
);
glm::dmat3 tm = SpiceManager::ref().frameTransformationMatrix(_instrumentName, "ECLIPJ2000", data.time);
//_positions[SourcePosition] = { 0.f, 0.f, 0.f, 0.f };
glm::dvec3 boresight;
try {
//try {
SpiceManager::FieldOfViewResult res =
SpiceManager::ref().fieldOfView(_source);
boresight = res.boresightVector;
}
catch (const SpiceManager::SpiceException& e) {
LERROR(e.what());
}
//}
//catch (const SpiceManager::SpiceException& e) {
//LERROR(e.what());
//}
glm::vec4 target(boresight[0], boresight[1], boresight[2], 12);
target = tmp * target;
//target = glm::dmat4(tm) * target;
_positions[TargetPosition] = target;
//_positions[TargetPosition] = target;
//_positions[TargetPosition] = {
// target.x * pow(10, target.w),
// target.y * pow(10, target.w),
// target.z * pow(10, target.w),
// 0
//};
VBOData vboData[2] = {
{
{ 0.f, 0.f, 0.f },
_lineColorBegin.r, _lineColorBegin.g, _lineColorBegin.b, _lineColorBegin.a
},
{
{ target.x * powf(10, target.w), target.y * powf(10, target.w), target.z * powf(10, target.w) },
{ _lineColorEnd.r, _lineColorEnd.g, _lineColorEnd.b, _lineColorEnd.a }
}
};
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
glBufferSubData(
GL_ARRAY_BUFFER,
0,
2 * sizeof(VBOData),
vboData
);
//glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(psc) * 2, _positions);
if (ImageSequencer::ref().isReady()) {
_imageSequenceTime = ImageSequencer::ref().instrumentActiveTime(_instrumentName);
@@ -193,5 +291,4 @@ void RenderableCrawlingLine::update(const UpdateData& data) {
}
}
}
} // namespace openspace

View File

@@ -27,8 +27,12 @@
#include <openspace/rendering/renderable.h>
#include <ghoul/glm.h>
namespace openspace {
namespace documentation { struct Documentation; }
class RenderableCrawlingLine : public Renderable {
public:
RenderableCrawlingLine(const ghoul::Dictionary& dictionary);
@@ -41,6 +45,8 @@ public:
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
static documentation::Documentation Documentation();
private:
std::unique_ptr<ghoul::opengl::ProgramObject> _program;
@@ -48,9 +54,10 @@ private:
std::string _source;
std::string _target;
std::string _referenceFrame;
glm::vec3 _lineColor;
glm::vec4 _lineColorBegin;
glm::vec4 _lineColorEnd;
psc _positions[2];
int _frameCounter;
bool _drawLine;

File diff suppressed because it is too large Load Diff

View File

@@ -28,7 +28,9 @@
#include <openspace/rendering/renderable.h>
#include <openspace/properties/scalar/boolproperty.h>
#include <openspace/properties/scalar/doubleproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
#include <openspace/properties/vector/vec4property.h>
#include <openspace/util/spicemanager.h>
#include <ghoul/glm.h>
@@ -44,6 +46,8 @@ class Texture;
namespace openspace {
namespace documentation { struct Documentation; }
class RenderableFov : public Renderable {
public:
RenderableFov(const ghoul::Dictionary& dictionary);
@@ -55,79 +59,101 @@ public:
void render(const RenderData& data) override;
void update(const UpdateData& data) override;
static documentation::Documentation Documentation();
private:
// Checks the field of view of the instrument for the current \p time against all of
// the potential targets are returns the first name of the target that is in field of
// view, the previous target, or the closest target to the space craft. The second
// return value is whether the target is currently in the field of view
std::pair<std::string,bool> determineTarget(double time);
private:
void loadTexture();
void allocateData();
void insertPoint(std::vector<float>& arr, glm::vec4 p, glm::vec4 c);
void fovSurfaceIntercept(bool H[], std::vector<glm::dvec3> bounds);
void determineTarget();
void updateGPU();
void sendToGPU();
void insertPoint(std::vector<float>& arr, glm::vec4 p, glm::vec4 c);
glm::vec4 squareColor(float t) const {
return _colors.active.value() * t + _colors.square.value() * (1 - t);
}
void computeColors();
void computeIntercepts(const RenderData& data);
psc orthogonalProjection(glm::dvec3 camvec);
psc checkForIntercept(glm::dvec3 ray);
psc pscInterpolate(psc p0, psc p1, float t);
glm::dvec3 interpolate(glm::dvec3 p0, glm::dvec3 p1, float t);
glm::dvec3 bisection(glm::dvec3 p1, glm::dvec3 p2);
glm::vec4 endColor(float t) const {
return _colors.active.value() * t + _colors.intersectionEnd.value() * (1 - t);
}
glm::vec4 fovColor(float t) const {
return _colors.active.value() * t + _colors.targetInFieldOfView.value() * (1 - t);
}
void computeIntercepts(const UpdateData& data, const std::string& target , bool inFOV);
glm::dvec3 orthogonalProjection(const glm::dvec3& camvec, double time, const std::string& target) const;
glm::dvec3 checkForIntercept(const glm::dvec3& ray, double time, const std::string& target) const;
//glm::dvec3 bisection(const glm::dvec3& p1, const glm::dvec3& p2, double time, const std::string& target, const glm::dvec3& previousHalf = glm::dvec3(0.0)) const;
// properties
properties::FloatProperty _lineWidth;
properties::BoolProperty _drawSolid;
properties::DoubleProperty _standOffDistance;
std::unique_ptr<ghoul::opengl::ProgramObject> _programObject;
ghoul::opengl::Texture* _texture;
// instance variables
int _nrInserted = 0;
bool _rebuild = false;
bool _interceptTag[35];
bool _withinFOV;
std::vector<psc> _projectionBounds;
psc _interceptVector;
std::vector<float> _fovBounds;
std::vector<float> _fovPlane;
// spice
std::string _spacecraft;
std::string _observer;
std::string _frame;
std::string _instrumentID;
SpiceManager::AberrationCorrection _aberrationCorrection;
std::string _fovTarget;
glm::dvec3 ipoint, ivec;
glm::dvec3 _previousHalf;
glm::dvec3 _boresight;
glm::dmat3 _stateMatrix;
glm::mat4 _spacecraftRotation;
std::vector<glm::dvec3> _bounds;
std::vector<std::string> _potentialTargets;
//std::vector<float> _fovBounds;
//std::vector<float> _fovPlane;
std::string _previousTarget;
bool _drawFOV;
// GPU
GLuint _fovBoundsVAO;
GLuint _fovBoundsVBO;
unsigned int _vBoundsSize;
GLuint _fovPlaneVAO;
GLuint _fovPlaneVBO;
unsigned int _vPlaneSize;
GLenum _mode;
struct {
std::string spacecraft;
std::string name;
std::string referenceFrame;
SpiceManager::AberrationCorrection aberrationCorrection;
// time
double _time = 0;
double _oldTime = 0;
std::vector<glm::dvec3> bounds;
glm::dvec3 boresight;
std::vector<std::string> potentialTargets;
} _instrument;
// colors
glm::vec4 col_sq; // orthogonal white square
glm::vec4 col_project; // color when projections occur
glm::vec4 col_start; // intersection start color
glm::vec4 col_end; // intersection end color
glm::vec4 col_blue; // withinFov color
glm::vec4 col_gray; // no intersection color
float _interpolationTime;
struct RenderInformation {
// Differentiating different vertex types
using VertexColorType = int32_t;
// This needs to be synced with the fov_vs.glsl shader
static const VertexColorType VertexColorTypeDefaultStart = 0;
static const VertexColorType VertexColorTypeDefaultEnd = 1;
static const VertexColorType VertexColorTypeInFieldOfView = 2;
static const VertexColorType VertexColorTypeActive = 3;
static const VertexColorType VertexColorTypeIntersectionStart = 4;
static const VertexColorType VertexColorTypeIntersectionEnd = 5;
static const VertexColorType VertexColorTypeSquare = 6;
struct VBOData {
GLfloat position[3];
VertexColorType color;
};
GLuint vao = 0;
GLuint vbo = 0;
// @SPEEDUP: Add an ibo to reduce the number of vertices drawn
std::vector<VBOData> data;
bool isDirty = true;
};
RenderInformation _orthogonalPlane;
RenderInformation _fieldOfViewBounds;
struct {
properties::Vec4Property defaultStart; // Start color for uninteresting times
properties::Vec4Property defaultEnd; // End color for uninteresting times
properties::Vec4Property active; // Color use when a field-of-view is projecting
properties::Vec4Property targetInFieldOfView; // Color to use for target in fov
properties::Vec4Property intersectionStart; // Color at the start of intersection
properties::Vec4Property intersectionEnd; // Color at the end of intersection
properties::Vec4Property square; // Color for the orthogonal square
} _colors;
};
} // namespace openspace

View File

@@ -486,7 +486,9 @@ bool RenderablePlanetProjection::loadTextures() {
using ghoul::opengl::Texture;
_baseTexture = nullptr;
if (_colorTexturePath.value() != "") {
_baseTexture = ghoul::io::TextureReader::ref().loadTexture(_colorTexturePath);
_baseTexture = ghoul::io::TextureReader::ref().loadTexture(
absPath(_colorTexturePath)
);
if (_baseTexture) {
ghoul::opengl::convertTextureFormat(*_baseTexture, Texture::Format::RGB);
_baseTexture->uploadTexture();
@@ -496,7 +498,9 @@ bool RenderablePlanetProjection::loadTextures() {
_heightMapTexture = nullptr;
if (_heightMapTexturePath.value() != "") {
_heightMapTexture = ghoul::io::TextureReader::ref().loadTexture(_heightMapTexturePath);
_heightMapTexture = ghoul::io::TextureReader::ref().loadTexture(
absPath(_heightMapTexturePath)
);
if (_heightMapTexture) {
ghoul::opengl::convertTextureFormat(*_heightMapTexture, Texture::Format::RGB);
_heightMapTexture->uploadTexture();

View File

@@ -27,20 +27,15 @@ uniform vec4 objpos;
uniform vec3 color;
uniform float _alpha;
in vec4 vs_position;
in vec4 vs_positionScreenSpace;
in vec4 vs_color;
#include "PowerScaling/powerScaling_fs.hglsl"
#include "fragment.glsl"
Fragment getFragment() {
vec4 position = vs_position;
vec4 diffuse = vs_color;
float depth = pscDepth(position);
diffuse.a = _alpha;
Fragment frag;
frag.color = diffuse;
frag.depth = depth;
frag.color = vec4(vs_color.rgb, vs_color.a * _alpha);
frag.depth = vs_positionScreenSpace.w;
return frag;
}

View File

@@ -24,33 +24,24 @@
#version __CONTEXT__
uniform mat4 ViewProjection;
uniform mat4 ModelTransform;
layout(location = 0) in vec3 in_position;
layout(location = 1) in vec4 in_color;
uniform vec3 color;
layout(location = 0) in vec4 in_position;
uniform mat4 modelViewProjection;
// uniform vec3 color;
out vec4 vs_color;
out vec4 vs_position;
out vec4 vs_positionScreenSpace;
// out vec4 vs_positionCameraSpace;
const int targetId = 1;
#include "PowerScaling/powerScaling_vs.hglsl"
void main() {
vs_position = in_position;
vec4 tmp = in_position;
int id = gl_VertexID;
vec3 black = vec3(0.0);
vec4 positionClipSpace = modelViewProjection * vec4(in_position, 1.0);
vs_positionScreenSpace = z_normalization(positionClipSpace);
gl_Position = vs_positionScreenSpace;
if(id == targetId)
vs_color.xyz = black;
else
vs_color.xyz = color;
vec4 position = pscTransform(tmp, ModelTransform);
vs_position = tmp;
position = ViewProjection * position;
gl_Position = z_normalization(position);
}
vs_color = in_color;
}

View File

@@ -22,28 +22,14 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
/*
uniform mat4 ViewProjection;
uniform mat4 ModelTransform;
in vec4 vs_point_position;
in vec4 vs_point_velocity;
*/
//out vec4 vs_point_position;
in vec4 vs_point_velocity;
in vec4 vs_positionScreenSpace;
//out vec4 diffuse;
#include "PowerScaling/powerScaling_fs.hglsl"
#include "fragment.glsl"
in vec4 vs_color;
in vec4 vs_positionScreenSpace;
Fragment getFragment() {
Fragment frag;
frag.color = vs_point_velocity;
frag.color = vs_color;
frag.depth = vs_positionScreenSpace.w;
return frag;
}

View File

@@ -24,63 +24,64 @@
#version __CONTEXT__
//uniform mat4 ViewProjection;
//uniform mat4 ModelTransform;
//uniform vec4 etColor;
//uniform vec4 objectVelocity;
layout(location = 0) in vec4 in_point_position;
layout(location = 1) in vec4 in_point_velocity;
layout(location = 2) in vec2 in_point_timeindex;
//out vec4 vs_point_position;
out vec4 vs_point_velocity;
// Uniforms
uniform mat4 modelViewProjectionTransform;
// Outputs
out vec4 vs_positionScreenSpace;
#include "PowerScaling/powerScaling_vs.hglsl"
void main()
{
vec4 position = vec4(in_point_position.xyz * pow(10, in_point_position.w), 1);
// This needs to be synced with the RenderableFov header
const int VertexColorTypeDefaultStart = 0;
const int VertexColorTypeDefaultEnd = 1;
const int VertexColorTypeInFieldOfView = 2;
const int VertexColorTypeActive = 3;
const int VertexColorTypeIntersectionStart = 4;
const int VertexColorTypeIntersectionEnd = 5;
const int VertexColorTypeSquare = 6;
layout(location = 0) in vec3 in_point_position;
layout (location = 1) in int colorInformation;
out vec4 vs_color;
out vec4 vs_positionScreenSpace;
uniform mat4 modelViewProjectionTransform;
uniform vec4 defaultColorStart;
uniform vec4 defaultColorEnd;
uniform vec4 activeColor;
uniform vec4 targetInFieldOfViewColor;
uniform vec4 intersectionStartColor;
uniform vec4 intersectionEndColor;
uniform vec4 squareColor;
uniform float interpolation;
void main() {
vec4 position = vec4(in_point_position, 1);
vec4 positionClipSpace = modelViewProjectionTransform * position;
// Write output
vs_positionScreenSpace = z_normalization(positionClipSpace);
gl_Position = vs_positionScreenSpace;
vs_point_velocity = in_point_velocity;
/*
//vs_point_position = objpos;
// rotate and scale vertex with model transform and add the translation
vec3 local_vertex_pos = mat3(ModelTransform) * in_point_position.xyz;
//vec4 lvp = ModelTransform * in_point_position;
// PSC addition; local vertex position and the object power scaled world position
vs_point_position = psc_addition(vec4(local_vertex_pos,in_point_position.w),objpos);
//vs_point_position = psc_addition(lvp,objpos);
// PSC addition; rotated and viewscaled vertex and the cmaeras negative position
vs_point_position = psc_addition(vs_point_position,vec4(-campos.xyz,campos.w));
// rotate the camera
local_vertex_pos = mat3(camrot) * vs_point_position.xyz;
vs_point_position = vec4(local_vertex_pos, vs_point_position.w);
//vs_point_position = camrot* vs_point_position;
// project using the rescaled coordinates,
//vec4 vs_point_position_rescaled = psc_scaling(vs_point_position, scaling);
vec4 vs_point_position_rescaled = psc_to_meter(vs_point_position, scaling);
//vs_point_position = vs_point_position_rescaled;
// project the position to view space
gl_Position = ViewProjection * vs_point_position_rescaled;
*/
}
switch (colorInformation) {
case VertexColorTypeDefaultStart:
vs_color = defaultColorStart;
break;
case VertexColorTypeDefaultEnd:
vs_color = defaultColorEnd;
break;
case VertexColorTypeInFieldOfView:
vs_color = activeColor * interpolation + targetInFieldOfViewColor * (1 - interpolation);
break;
case VertexColorTypeActive:
vs_color = activeColor;
break;
case VertexColorTypeIntersectionStart:
vs_color = intersectionStartColor;
break;
case VertexColorTypeIntersectionEnd:
vs_color = activeColor * interpolation + intersectionEndColor * (1 - interpolation);
break;
case VertexColorTypeSquare:
vs_color = activeColor * interpolation + squareColor * (1 - interpolation);
break;
default:
vs_color = vec4(1.0, 0.0, 1.0, 1.0);
}
}

View File

@@ -388,12 +388,10 @@ void ImageSequencer::runSequenceParser(SequenceParser* parser){
std::vector<double> captureProgression = parser->getCaptureProgression(); //in5
// check for sanity
//if (translations.empty() || imageData.empty() || instrumentTimes.empty() || targetTimes.empty() || captureProgression.empty()) {
if (imageData.empty() || instrumentTimes.empty() || targetTimes.empty() || captureProgression.empty()) {
if (imageData.empty() || instrumentTimes.empty() || captureProgression.empty()) {
LERROR("Missing sequence data");
return;
}
// append data
for (auto& it : translations) {

View File

@@ -176,7 +176,7 @@ void renderDoubleProperty(properties::Property* prop, const std::string& ownerNa
float min = p->minValue();
float max = p->maxValue();
ImGui::SliderFloat(name.c_str(), &value, min, max);
ImGui::SliderFloat(name.c_str(), &value, min, max, "%.5f");
renderTooltip(prop);
if (value != static_cast<float>(p->value())) {
@@ -299,7 +299,7 @@ void renderFloatProperty(Property* prop, const std::string& ownerName) {
FloatProperty::ValueType value = *p;
float min = p->minValue();
float max = p->maxValue();
ImGui::SliderFloat(name.c_str(), &value, min, max);
ImGui::SliderFloat(name.c_str(), &value, min, max, "%.5f");
renderTooltip(prop);
if (value != p->value()) {
@@ -321,7 +321,8 @@ void renderVec2Property(Property* prop, const std::string& ownerName) {
name.c_str(),
&value.x,
min,
max
max,
"%.5f"
);
renderTooltip(prop);
@@ -349,7 +350,8 @@ void renderVec3Property(Property* prop, const std::string& ownerName) {
name.c_str(),
glm::value_ptr(value),
min,
max
max,
"%.5f"
);
renderTooltip(prop);
@@ -380,7 +382,8 @@ void renderVec4Property(Property* prop, const std::string& ownerName) {
name.c_str(),
&value.x,
min,
max
max,
"%.5f"
);
renderTooltip(prop);
@@ -409,7 +412,8 @@ void renderDVec2Property(Property* prop, const std::string& ownerName) {
name.c_str(),
&value.x,
min,
max
max,
"%.5f"
);
renderTooltip(prop);
@@ -432,16 +436,16 @@ void renderDVec3Property(Property* prop, const std::string& ownerName) {
float min = std::min(std::min(p->minValue().x, p->minValue().y), p->minValue().z);
float max = std::max(std::max(p->maxValue().x, p->maxValue().y), p->maxValue().z);
ImGui::SliderFloat3(
bool changed = ImGui::SliderFloat3(
name.c_str(),
glm::value_ptr(value),
min,
max
max,
"%.5f"
);
renderTooltip(prop);
if (glm::dvec3(value) != p->value()) {
if (changed) {
executeScript(
p->fullyQualifiedIdentifier(),
"{" + std::to_string(value.x) + "," +
@@ -468,7 +472,8 @@ void renderDVec4Property(Property* prop, const std::string& ownerName) {
name.c_str(),
&value.x,
min,
max
max,
"%.5f"
);
renderTooltip(prop);

View File

@@ -97,10 +97,14 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary)
glm::vec2 planetRadiusVec;
success = geometryDictionary.getValue(keyRadius, planetRadiusVec);
if (success)
_planetRadius = planetRadiusVec[0] * glm::pow(10, planetRadiusVec[1]);
else
if (success) {
_planetRadius = static_cast<float>(
planetRadiusVec[0] * glm::pow(10, planetRadiusVec[1])
);
}
else {
LWARNING("No Radius value expecified for " << name << " planet.");
}
}
dictionary.getValue(keyFrame, _frame);
@@ -432,7 +436,7 @@ void RenderablePlanet::render(const RenderData& data) {
float xp_test = shadowConf.caster.second * sc_length / (shadowConf.source.second + shadowConf.caster.second);
float rp_test = shadowConf.caster.second * (glm::length(planetCaster_proj) + xp_test) / xp_test;
float casterDistSun = glm::length(casterPos);
double casterDistSun = glm::length(casterPos);
float planetDistSun = glm::length(data.position.vec3());
ShadowRenderingStruct shadowData;

View File

@@ -105,7 +105,7 @@ RenderableRings::RenderableRings(const ghoul::Dictionary& dictionary)
"RenderableRings"
);
_size = dictionary.value<double>(KeySize);
_size = static_cast<float>(dictionary.value<double>(KeySize));
setBoundingSphere(PowerScaledScalar::CreatePSS(_size));
addProperty(_size);
_size.onChange([&]() { _planeIsDirty = true; });

View File

@@ -467,7 +467,7 @@ bool RenderableStars::readSpeckFile() {
// (signaled by the keywords 'datavar', 'texturevar', and 'texture')
std::string line = "";
while (true) {
std::ifstream::streampos position = file.tellg();
std::streampos position = file.tellg();
std::getline(file, line);
if (line[0] == '#' || line.empty()) {

View File

@@ -252,6 +252,9 @@ double KeplerTranslation::eccentricAnomaly(double meanAnomaly) const {
};
return solveIteration(solver, e, 0.0, 8);
}
else {
ghoul_assert(false, "Eccentricity must not be >= 1.0");
}
}
void KeplerTranslation::update(const UpdateData& data) {

View File

@@ -64,7 +64,7 @@ namespace {
auto y2000 = std::find(LeapYears.begin(), LeapYears.end(), Epoch);
// The distance between the two iterators gives us the number of leap years
int nLeapYears = std::abs(std::distance(y2000, lb));
int nLeapYears = static_cast<int>(std::abs(std::distance(y2000, lb)));
int nYears = std::abs(year - Epoch);
int nRegularYears = nYears - nLeapYears;
@@ -130,7 +130,7 @@ namespace {
auto y2000 = std::lower_bound(LeapSeconds.begin(), LeapSeconds.end(), Epoch);
// The distance between the two iterators gives us the number of leap years
int nLeapSeconds = std::abs(std::distance(y2000, it));
int nLeapSeconds = static_cast<int>(std::abs(std::distance(y2000, it)));
return nLeapSeconds;
};
@@ -182,16 +182,19 @@ namespace {
// 3
using namespace std::chrono;
int SecondsPerDay = seconds(hours(24)).count();
int SecondsPerDay = static_cast<int>(seconds(hours(24)).count());
double nSecondsSince2000 = (daysSince2000 + daysInYear) * SecondsPerDay;
// 4
// We need to remove additionbal leap seconds past 2000 and add them prior to
// 2000 to sync up the time zones
double nLeapSecondsOffset = -countLeapSeconds(year, std::floor(daysInYear));
double nLeapSecondsOffset = -countLeapSeconds(
year,
static_cast<int>(std::floor(daysInYear))
);
// 5
double nSecondsEpochOffset = seconds(hours(12)).count();
double nSecondsEpochOffset = static_cast<double>(seconds(hours(12)).count());
// Combine all of the values
double epoch = nSecondsSince2000 + nLeapSecondsOffset - nSecondsEpochOffset;
@@ -270,14 +273,14 @@ void TLETranslation::readTLEFile(const std::string& filename) {
// All of the Kepler element information
struct {
double inclination;
double semiMajorAxis;
double ascendingNode;
double eccentricity;
double argumentOfPeriapsis;
double meanAnomaly;
double meanMotion;
double epoch;
double inclination = 0.0;
double semiMajorAxis = 0.0;
double ascendingNode = 0.0;
double eccentricity = 0.0;
double argumentOfPeriapsis = 0.0;
double meanAnomaly = 0.0;
double meanMotion = 0.0;
double epoch = 0.0;
} keplerElements;
enum class State {

View File

@@ -1,5 +1,3 @@
set (DEFAULT_MODULE ON)
set (OPENSPACE_DEPENDENCIES
space
)

View File

@@ -30,32 +30,33 @@
#include <set>
namespace {
// Structure used to make offenses unique
struct OffenseCompare {
using Offense = openspace::documentation::TestResult::Offense;
bool operator()(const Offense& lhs, const Offense& rhs) const {
if (lhs.offender != rhs.offender) {
return lhs.offender < rhs.offender;
}
else {
return std::underlying_type_t<Offense::Reason>(lhs.reason) <
std::underlying_type_t<Offense::Reason>(rhs.reason);
}
}
};
struct WarningCompare {
using Warning = openspace::documentation::TestResult::Warning;
bool operator()(const Warning& lhs, const Warning& rhs) const {
if (lhs.offender != rhs.offender) {
return lhs.offender < rhs.offender;
}
else {
return std::underlying_type_t<Warning::Reason>(lhs.reason) <
std::underlying_type_t<Warning::Reason>(rhs.reason);
}
// Structure used to make offenses unique
struct OffenseCompare {
using Offense = openspace::documentation::TestResult::Offense;
bool operator()(const Offense& lhs, const Offense& rhs) const {
if (lhs.offender != rhs.offender) {
return lhs.offender < rhs.offender;
}
};
else {
return std::underlying_type_t<Offense::Reason>(lhs.reason) <
std::underlying_type_t<Offense::Reason>(rhs.reason);
}
}
};
struct WarningCompare {
using Warning = openspace::documentation::TestResult::Warning;
bool operator()(const Warning& lhs, const Warning& rhs) const {
if (lhs.offender != rhs.offender) {
return lhs.offender < rhs.offender;
}
else {
return std::underlying_type_t<Warning::Reason>(lhs.reason) <
std::underlying_type_t<Warning::Reason>(rhs.reason);
}
}
};
} // namespace
@@ -78,6 +79,8 @@ std::string to_string(openspace::documentation::TestResult::Offense::Reason reas
return "Verification failed";
case openspace::documentation::TestResult::Offense::Reason::WrongType:
return "Wrong type";
default:
ghoul_assert(false, "Missing case label");
}
}
@@ -85,6 +88,8 @@ std::string to_string(openspace::documentation::TestResult::Warning::Reason reas
switch (reason) {
case openspace::documentation::TestResult::Warning::Reason::Deprecated:
return "Deprecated";
default:
ghoul_assert(false, "Missing case label");
}
}

View File

@@ -217,33 +217,42 @@ TestResult ReferencingVerifier::operator()(const ghoul::Dictionary& dictionary,
{
TestResult res = TableVerifier::operator()(dictionary, key);
if (res.success) {
std::vector<Documentation> documentations = DocEng.documentations();
std::vector<Documentation> docs = DocEng.documentations();
auto it = std::find_if(
documentations.begin(),
documentations.end(),
docs.begin(),
docs.end(),
[this](const Documentation& doc) { return doc.id == identifier; }
);
ghoul_assert(
it != documentations.end(),
"Did not find referencing identifier '" + identifier + "'"
);
if (it == docs.end()) {
res.offenses.push_back({
key,
TestResult::Offense::Reason::UnknownIdentifier
});
res.success = false;
return res;
}
//ghoul_assert(
// it != docs.end(),
// "Did not find referencing identifier '" + identifier + "'"
//);
ghoul::Dictionary d = dictionary.value<ghoul::Dictionary>(key);
TestResult res = testSpecification(*it, d);
TestResult r = testSpecification(*it, d);
// Add the 'key' as a prefix to make the offender a fully qualified identifer
for (TestResult::Offense& s : res.offenses) {
for (TestResult::Offense& s : r.offenses) {
s.offender = key + "." + s.offender;
}
// Add the 'key' as a prefix to make the warning a fully qualified identifer
for (TestResult::Warning& w : res.warnings) {
for (TestResult::Warning& w : r.warnings) {
w.offender = key + "." + w.offender;
}
return res;
return r;
}
else {
return res;

View File

@@ -111,7 +111,9 @@ namespace {
// Compute estimated time remaining.
auto timeRemaining = estimatedTime - transferTime;
float s = std::chrono::duration_cast<std::chrono::seconds>(timeRemaining).count();
float s = static_cast<float>(
std::chrono::duration_cast<std::chrono::seconds>(timeRemaining).count()
);
i->future->secondsRemaining = s;
@@ -233,44 +235,46 @@ std::future<DownloadManager::MemoryFile> DownloadManager::fetchFile(
file.corrupted = false;
CURL* curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&file);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeMemoryCallback);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 5L);
// Will fail when response status is 400 or above
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
CURLcode res = curl_easy_perform(curl);
if(res == CURLE_OK){
// ask for the content-type
char *ct;
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
if(res == CURLE_OK){
std::string extension = std::string(ct);
std::stringstream ss(extension);
getline(ss, extension ,'/');
getline(ss, extension);
file.format = extension;
} else{
LWARNING("Could not get File extension from file downloaded from: " + url);
}
successCallback(file);
curl_easy_cleanup(curl);
return std::move(file);
} else {
std::string err = curl_easy_strerror(res);
errorCallback(err);
curl_easy_cleanup(curl);
// Throw an error and use try-catch around call to future.get()
//throw std::runtime_error( err );
if (!curl) {
throw ghoul::RuntimeError("Error initializing cURL");
}
// or set a boolean variable in MemoryFile to determine if it is valid/corrupted or not.
// Return MemoryFile even if it is not valid, and check if it is after future.get() call.
file.corrupted = true;
return std::move(file);
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&file);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeMemoryCallback);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 5L);
// Will fail when response status is 400 or above
curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1L);
CURLcode res = curl_easy_perform(curl);
if(res == CURLE_OK){
// ask for the content-type
char *ct;
res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
if(res == CURLE_OK){
std::string extension = std::string(ct);
std::stringstream ss(extension);
getline(ss, extension ,'/');
getline(ss, extension);
file.format = extension;
} else{
LWARNING("Could not get File extension from file downloaded from: " + url);
}
successCallback(file);
curl_easy_cleanup(curl);
return std::move(file);
} else {
std::string err = curl_easy_strerror(res);
errorCallback(err);
curl_easy_cleanup(curl);
// Throw an error and use try-catch around call to future.get()
//throw std::runtime_error( err );
// or set a boolean variable in MemoryFile to determine if it is valid/corrupted or not.
// Return MemoryFile even if it is not valid, and check if it is after future.get() call.
file.corrupted = true;
return std::move(file);
}
};

View File

@@ -271,7 +271,7 @@ void OpenSpaceEngine::create(int argc, char** argv,
}
throw;
}
catch (const ghoul::RuntimeError& e) {
catch (const ghoul::RuntimeError&) {
LFATAL("Loading of configuration file '" << configurationFilePath << "' failed");
throw;
}
@@ -477,9 +477,9 @@ void OpenSpaceEngine::initialize() {
writeDocumentation();
if (configurationManager().hasKey(ConfigurationManager::KeyShutdownCountdown)) {
_shutdown.waitTime = configurationManager().value<double>(
_shutdown.waitTime = static_cast<float>(configurationManager().value<double>(
ConfigurationManager::KeyShutdownCountdown
);
));
}
if (!commandlineArgumentPlaceholders.sceneName.empty()) {
@@ -983,7 +983,7 @@ void OpenSpaceEngine::postSynchronizationPreDraw() {
if (_shutdown.timer <= 0.f) {
_windowWrapper->terminate();
}
_shutdown.timer -= _windowWrapper->averageDeltaTime();
_shutdown.timer -= static_cast<float>(_windowWrapper->averageDeltaTime());
}
_renderEngine->updateScene();

View File

@@ -74,7 +74,7 @@ void SettingsEngine::initialize() {
std::vector<std::string> scenes = ghoul::filesystem::Directory(sceneDir).readFiles();
for (std::size_t i = 0; i < scenes.size(); ++i) {
std::size_t found = scenes[i].find_last_of("/\\");
_scenes.addOption(i, scenes[i].substr(found + 1));
_scenes.addOption(static_cast<int>(i), scenes[i].substr(found + 1));
}
// Set interaction to change ConfigurationManager and schedule the load

View File

@@ -224,8 +224,9 @@ bool SGCTWindowWrapper::isExternalControlConnected() const {
void SGCTWindowWrapper::sendMessageToExternalControl(const std::vector<char>& message) const {
sgct::Engine::instance()->sendMessageToExternalControl(
message.data(),
message.size());
message.data(),
static_cast<int>(message.size())
);
}
bool SGCTWindowWrapper::isSimpleRendering() const {

View File

@@ -77,8 +77,8 @@ InteractionHandler::InteractionHandler()
, _rotationalFriction("rotationalFriction", "Rotational Friction", true)
, _horizontalFriction("horizontalFriction", "Horizontal Friction", true)
, _verticalFriction("verticalFriction", "Vertical Friction", true)
, _sensitivity("sensitivity", "Sensitivity", 0.5, 0.001, 1)
, _rapidness("rapidness", "Rapidness", 1, 0.1, 60)
, _sensitivity("sensitivity", "Sensitivity", 0.5f, 0.001f, 1.f)
, _rapidness("rapidness", "Rapidness", 1.f, 0.1f, 60.f)
{
_origin.onChange([this]() {
SceneGraphNode* node = sceneGraphNode(_origin.value());

View File

@@ -198,9 +198,9 @@ int goToChunk(lua_State* L) {
if (nArguments != 3)
return luaL_error(L, "Expected %i arguments, got %i", 3, nArguments);
int x = lua_tonumber(L, 1);
int y = lua_tonumber(L, 2);
int level = lua_tonumber(L, 3);
int x = static_cast<int>(lua_tonumber(L, 1));
int y = static_cast<int>(lua_tonumber(L, 2));
int level = static_cast<int>(lua_tonumber(L, 3));
OsEng.interactionHandler().goToChunk(x, y, level);
@@ -214,8 +214,8 @@ int goToGeo(lua_State* L) {
if (nArguments != 2)
return luaL_error(L, "Expected %i arguments, got %i", 2, nArguments);
double latitude = lua_tonumber(L, 1);
double longitude = lua_tonumber(L, 2);
double latitude = static_cast<int>(lua_tonumber(L, 1));
double longitude = static_cast<int>(lua_tonumber(L, 2));
OsEng.interactionHandler().goToGeo(latitude, longitude);
@@ -224,7 +224,6 @@ int goToGeo(lua_State* L) {
int restoreCameraStateFromFile(lua_State* L) {
using ghoul::lua::luaTypeToString;
const std::string _loggerCat = "lua.restoreCameraStateFromFile";
int nArguments = lua_gettop(L);
if (nArguments != 1)
@@ -232,8 +231,9 @@ int restoreCameraStateFromFile(lua_State* L) {
std::string cameraStateFilePath = luaL_checkstring(L, -1);
if (cameraStateFilePath.empty())
if (cameraStateFilePath.empty()) {
return luaL_error(L, "filepath string is empty");
}
OsEng.interactionHandler().restoreCameraStateFromFile(cameraStateFilePath);
return 0;
@@ -241,7 +241,6 @@ int restoreCameraStateFromFile(lua_State* L) {
int saveCameraStateToFile(lua_State* L) {
using ghoul::lua::luaTypeToString;
const std::string _loggerCat = "lua.setCameraPosition";
int nArguments = lua_gettop(L);
if (nArguments != 1)
@@ -249,10 +248,12 @@ int saveCameraStateToFile(lua_State* L) {
std::string cameraStateFilePath = luaL_checkstring(L, -1);
if (cameraStateFilePath.empty())
if (cameraStateFilePath.empty()) {
return luaL_error(L, "filepath string is empty");
}
OsEng.interactionHandler().saveCameraStateToFile(cameraStateFilePath);
return 0;
}
int resetCameraDirection(lua_State* L) {
@@ -260,10 +261,12 @@ int resetCameraDirection(lua_State* L) {
const std::string _loggerCat = "lua.resetCameraDirection";
int nArguments = lua_gettop(L);
if (nArguments != 0)
if (nArguments != 0) {
return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments);
}
OsEng.interactionHandler().resetCameraDirection();
return 0;
}

View File

@@ -85,9 +85,9 @@ void LuaConsole::initialize() {
int64_t length;
file.read(reinterpret_cast<char*>(&length), sizeof(int64_t));
std::vector<char> tmp(length + 1);
std::vector<char> tmp(length);
file.read(tmp.data(), length);
tmp[length] = '\0';
//tmp[length] = '\0';
_commandsHistory.emplace_back(std::string(tmp.begin(), tmp.end()));
}
@@ -384,7 +384,7 @@ void LuaConsole::charCallback(unsigned int codepoint, KeyModifier modifier) {
return;
}
addToCommand(std::string(1, codepoint));
addToCommand(std::string(1, static_cast<const char>(codepoint)));
}
void LuaConsole::render() {

View File

@@ -25,31 +25,34 @@
namespace openspace {
namespace luascriptfunctions {
int loadMission(lua_State* L) {
using ghoul::lua::luaTypeToString;
int nArguments = lua_gettop(L);
if (nArguments != 1)
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
using ghoul::lua::luaTypeToString;
int nArguments = lua_gettop(L);
if (nArguments != 1)
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
std::string missionFileName = luaL_checkstring(L, -1);
if (missionFileName.empty()) {
return luaL_error(L, "filepath string is empty");
}
MissionManager::ref().loadMission(absPath(missionFileName));
std::string missionFileName = luaL_checkstring(L, -1);
if (missionFileName.empty()) {
return luaL_error(L, "filepath string is empty");
}
MissionManager::ref().loadMission(absPath(missionFileName));
return 0;
}
int setCurrentMission(lua_State* L) {
using ghoul::lua::luaTypeToString;
int nArguments = lua_gettop(L);
if (nArguments != 1)
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
int setCurrentMission(lua_State* L) {
using ghoul::lua::luaTypeToString;
int nArguments = lua_gettop(L);
if (nArguments != 1)
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
std::string missionName = luaL_checkstring(L, -1);
if (missionName.empty()) {
return luaL_error(L, "mission name string is empty");
}
MissionManager::ref().setCurrentMission(missionName);
std::string missionName = luaL_checkstring(L, -1);
if (missionName.empty()) {
return luaL_error(L, "mission name string is empty");
}
MissionManager::ref().setCurrentMission(missionName);
return 0;
}
} // namespace luascriptfunction
} // namespace openspace

View File

@@ -128,13 +128,13 @@ void NetworkEngine::publishIdentifierMappingMessage() {
std::vector<char> buffer(bufferSize);
size_t currentWritingPosition = 0;
uint16_t size = _identifiers.size();
uint16_t size = static_cast<uint16_t>(_identifiers.size());
std::memcpy(buffer.data(), &size, sizeof(uint16_t));
currentWritingPosition += sizeof(uint16_t);
for (const std::pair<std::string, MessageIdentifier>& i : _identifiers) {
std::memcpy(buffer.data() + currentWritingPosition, &(i.second), sizeof(MessageIdentifier));
currentWritingPosition += sizeof(MessageIdentifier);
uint8_t stringSize = i.first.size();
uint8_t stringSize = static_cast<uint8_t>(i.first.size());
std::memcpy(buffer.data() + currentWritingPosition, &stringSize, sizeof(uint8_t));
currentWritingPosition += sizeof(uint8_t);
std::memcpy(buffer.data() + currentWritingPosition, i.first.data(), stringSize);

View File

@@ -231,7 +231,7 @@ void ParallelConnection::clientConnect(){
return;
}
struct addrinfo *addresult = NULL, *ptr = NULL, hints;
struct addrinfo *addresult = NULL, hints;
memset(&hints, 0, sizeof(hints));
@@ -963,7 +963,7 @@ void ParallelConnection::setNConnections(size_t nConnections) {
}
}
size_t ParallelConnection::nConnections() {
int ParallelConnection::nConnections() {
return _nConnections;
}

View File

@@ -41,7 +41,7 @@ int setPort(lua_State* L) {
bool isNumber = (lua_isnumber(L, -1) != 0);
if (isNumber) {
int value = lua_tonumber(L, -1);
int value = static_cast<int>(lua_tonumber(L, -1));
std::string port = std::to_string(value);
if (OsEng.windowWrapper().isMaster()) {
OsEng.parallelConnection().setPort(port);
@@ -53,8 +53,6 @@ int setPort(lua_State* L) {
lua_typename(L, LUA_TNUMBER), luaL_typename(L, -1));
return luaL_error(L, "bad argument #%d (%s)", 1, msg);
}
return 0;
}
int setAddress(lua_State* L) {
@@ -78,8 +76,6 @@ int setAddress(lua_State* L) {
lua_typename(L, LUA_TSTRING), luaL_typename(L, -1));
return luaL_error(L, "bad argument #%d (%s)", 1, msg);
}
return 0;
}
int setPassword(lua_State* L) {
@@ -103,8 +99,6 @@ int setPassword(lua_State* L) {
lua_typename(L, LUA_TSTRING), luaL_typename(L, -1));
return luaL_error(L, "bad argument #%d (%s)", 1, msg);
}
return 0;
}
int setDisplayName(lua_State* L) {
@@ -128,8 +122,6 @@ int setDisplayName(lua_State* L) {
lua_typename(L, LUA_TSTRING), luaL_typename(L, -1));
return luaL_error(L, "bad argument #%d (%s)", 1, msg);
}
return 0;
}
int connect(lua_State* L) {
@@ -175,8 +167,6 @@ int requestHostship(lua_State* L) {
lua_typename(L, LUA_TSTRING), luaL_typename(L, -1));
return luaL_error(L, "bad argument #%d (%s)", 1, msg);
}
return 0;
}
int resignHostship(lua_State* L) {

View File

@@ -242,7 +242,7 @@ void PerformanceManager::storeScenePerformanceMeasurements(
_performanceMemory->acquireLock();
int nNodes = static_cast<int>(sceneNodes.size());
layout->nScaleGraphEntries = nNodes;
layout->nScaleGraphEntries = static_cast<int16_t>(nNodes);
for (int i = 0; i < nNodes; ++i) {
SceneGraphNode* node = sceneNodes[i];

View File

@@ -98,6 +98,7 @@ std::string OptionProperty::getDescriptionByValue(int value) {
return option.description;
}
}
return "";
}
std::string OptionProperty::generateAdditionalDescription() const {

View File

@@ -374,12 +374,12 @@ void FramebufferRenderer::render(float blackoutFactor, bool doPerformanceMeasure
ghoul::opengl::ProgramObject* raycastProgram = nullptr;
if (cameraIsInside) {
if (raycastProgram = _insideRaycastPrograms[raycaster].get()) {
if (raycastProgram == _insideRaycastPrograms[raycaster].get()) {
raycastProgram->activate();
raycastProgram->setUniform("cameraPosInRaycaster", cameraPosition);
}
} else {
if (raycastProgram = _raycastPrograms[raycaster].get()) {
if (raycastProgram == _raycastPrograms[raycaster].get()) {
raycastProgram->activate();
}
}

View File

@@ -808,7 +808,7 @@ void RenderEngine::renderInformation() {
RenderFontCr(
*_fontInfo,
penPosition,
"Simulation increment (s): %.0f",
"Simulation increment (s): %.3f",
Time::ref().deltaTime()
);

View File

@@ -375,50 +375,50 @@ void ScriptEngine::addBaseLibrary() {
"printDebug",
&luascriptfunctions::printDebug,
"*",
"Logs the passed value to the installed LogManager with a "
"LogLevel of 'Debug'"
"Logs the passed value to the installed LogManager with a LogLevel of "
"'Debug'"
},
{
"printInfo",
&luascriptfunctions::printInfo,
"*",
"Logs the passed value to the installed LogManager with a "
" LogLevel of 'Info'"
"Logs the passed value to the installed LogManager with a LogLevel of "
"'Info'"
},
{
"printWarning",
&luascriptfunctions::printWarning,
"*",
"Logs the passed value to the installed LogManager with "
"a LogLevel of 'Warning'"
"Logs the passed value to the installed LogManager with a LogLevel of "
"'Warning'"
},
{
"printError",
&luascriptfunctions::printError,
"*",
"Logs the passed value to the installed LogManager with a "
"LogLevel of 'Error'"
"Logs the passed value to the installed LogManager with a LogLevel of "
"'Error'"
},
{
"printFatal",
&luascriptfunctions::printFatal,
"*",
"Logs the passed value to the installed LogManager with a "
"LogLevel of 'Fatal'"
"Logs the passed value to the installed LogManager with a LogLevel of "
"'Fatal'"
},
{
"absPath",
&luascriptfunctions::absolutePath,
"string",
"Returns the absolute path to the passed path, resolving"
" path tokens as well as resolving relative paths"
"Returns the absolute path to the passed path, resolving path tokens as "
"well as resolving relative paths"
},
{
"setPathToken",
&luascriptfunctions::setPathToken,
"string, string",
"Registers a new path token provided by the"
" first argument to the path provided in the second argument"
"Registers a new path token provided by the first argument to the path "
"provided in the second argument"
}
}
};

View File

@@ -26,142 +26,145 @@ namespace openspace {
namespace luascriptfunctions {
int printInternal(ghoul::logging::LogLevel level, lua_State* L) {
using ghoul::lua::luaTypeToString;
const std::string _loggerCat = "print";
int printInternal(ghoul::logging::LogLevel level, lua_State* L) {
using ghoul::lua::luaTypeToString;
const std::string _loggerCat = "print";
int nArguments = lua_gettop(L);
if (nArguments != 1)
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
const int type = lua_type(L, -1);
switch (type) {
case LUA_TNONE:
case LUA_TLIGHTUSERDATA:
case LUA_TTABLE:
case LUA_TFUNCTION:
case LUA_TUSERDATA:
case LUA_TTHREAD:
LOGC(level, "print", "Function parameter was of type '" <<
luaTypeToString(type) << "'");
case LUA_TNIL:
break;
case LUA_TBOOLEAN:
LOGC(level, "print", lua_toboolean(L, -1));
break;
case LUA_TNUMBER:
LOGC(level, "print", lua_tonumber(L, -1));
break;
case LUA_TSTRING:
LOGC(level, "print", lua_tostring(L, -1));
break;
}
return 0;
int nArguments = lua_gettop(L);
if (nArguments != 1) {
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
}
/**
* \ingroup LuaScripts
* printTrace(*):
* Logs the passed value to the installed LogManager with a LogLevel of 'Trace'.
* For Boolean, numbers, and strings, the internal values are printed, for all other
* types, the type is printed instead
*/
int printTrace(lua_State* L) {
return printInternal(ghoul::logging::LogLevel::Trace, L);
const int type = lua_type(L, -1);
switch (type) {
case LUA_TNONE:
case LUA_TLIGHTUSERDATA:
case LUA_TTABLE:
case LUA_TFUNCTION:
case LUA_TUSERDATA:
case LUA_TTHREAD:
LOGC(level, "print", "Function parameter was of type '" <<
luaTypeToString(type) << "'");
case LUA_TNIL:
break;
case LUA_TBOOLEAN:
LOGC(level, "print", lua_toboolean(L, -1));
break;
case LUA_TNUMBER:
LOGC(level, "print", lua_tonumber(L, -1));
break;
case LUA_TSTRING:
LOGC(level, "print", lua_tostring(L, -1));
break;
}
return 0;
}
/**
* \ingroup LuaScripts
* printTrace(*):
* Logs the passed value to the installed LogManager with a LogLevel of 'Trace'.
* For Boolean, numbers, and strings, the internal values are printed, for all other
* types, the type is printed instead
*/
int printTrace(lua_State* L) {
return printInternal(ghoul::logging::LogLevel::Trace, L);
}
/**
* \ingroup LuaScripts
* printDebug(*):
* Logs the passed value to the installed LogManager with a LogLevel of 'Debug'.
* For Boolean, numbers, and strings, the internal values are printed, for all other
* types, the type is printed instead
*/
int printDebug(lua_State* L) {
return printInternal(ghoul::logging::LogLevel::Debug, L);
}
/**
* \ingroup LuaScripts
* printInfo(*):
* Logs the passed value to the installed LogManager with a LogLevel of 'Info'.
* For Boolean, numbers, and strings, the internal values are printed, for all other
* types, the type is printed instead
*/
int printInfo(lua_State* L) {
return printInternal(ghoul::logging::LogLevel::Info, L);
}
/**
* \ingroup LuaScripts
* printWarning(*):
* Logs the passed value to the installed LogManager with a LogLevel of 'Warning'.
* For Boolean, numbers, and strings, the internal values are printed, for all other
* types, the type is printed instead
*/
int printWarning(lua_State* L) {
return printInternal(ghoul::logging::LogLevel::Warning, L);
}
/**
* \ingroup LuaScripts
* printError(*):
* Logs the passed value to the installed LogManager with a LogLevel of 'Error'.
* For Boolean, numbers, and strings, the internal values are printed, for all other
* types, the type is printed instead
*/
int printError(lua_State* L) {
return printInternal(ghoul::logging::LogLevel::Error, L);
}
/**
* \ingroup LuaScripts
* printFatal(*):
* Logs the passed value to the installed LogManager with a LogLevel of 'Fatal'.
* For Boolean, numbers, and strings, the internal values are printed, for all other
* types, the type is printed instead
*/
int printFatal(lua_State* L) {
return printInternal(ghoul::logging::LogLevel::Fatal, L);
}
/**
* \ingroup LuaScripts
* absPath(string):
* Passes the argument to FileSystem::absolutePath, which resolves occuring path
* tokens and returns the absolute path.
*/
int absolutePath(lua_State* L) {
int nArguments = lua_gettop(L);
if (nArguments != 1) {
return luaL_error(L, "Expected %d arguments, got %d", 1, nArguments);
}
/**
* \ingroup LuaScripts
* printDebug(*):
* Logs the passed value to the installed LogManager with a LogLevel of 'Debug'.
* For Boolean, numbers, and strings, the internal values are printed, for all other
* types, the type is printed instead
*/
int printDebug(lua_State* L) {
return printInternal(ghoul::logging::LogLevel::Debug, L);
std::string path = luaL_checkstring(L, -1);
path = absPath(path);
lua_pushstring(L, path.c_str());
return 1;
}
/**
* \ingroup LuaScripts
* setPathToken(string, string):
* Registers the path token provided by the first argument to the path in the second
* argument. If the path token already exists, it will be silently overridden.
*/
int setPathToken(lua_State* L) {
int nArguments = lua_gettop(L);
if (nArguments != 2) {
return luaL_error(L, "Expected %i arguments, got %i", 2, nArguments);
}
/**
* \ingroup LuaScripts
* printInfo(*):
* Logs the passed value to the installed LogManager with a LogLevel of 'Info'.
* For Boolean, numbers, and strings, the internal values are printed, for all other
* types, the type is printed instead
*/
int printInfo(lua_State* L) {
return printInternal(ghoul::logging::LogLevel::Info, L);
}
/**
* \ingroup LuaScripts
* printWarning(*):
* Logs the passed value to the installed LogManager with a LogLevel of 'Warning'.
* For Boolean, numbers, and strings, the internal values are printed, for all other
* types, the type is printed instead
*/
int printWarning(lua_State* L) {
return printInternal(ghoul::logging::LogLevel::Warning, L);
}
/**
* \ingroup LuaScripts
* printError(*):
* Logs the passed value to the installed LogManager with a LogLevel of 'Error'.
* For Boolean, numbers, and strings, the internal values are printed, for all other
* types, the type is printed instead
*/
int printError(lua_State* L) {
return printInternal(ghoul::logging::LogLevel::Error, L);
}
/**
* \ingroup LuaScripts
* printFatal(*):
* Logs the passed value to the installed LogManager with a LogLevel of 'Fatal'.
* For Boolean, numbers, and strings, the internal values are printed, for all other
* types, the type is printed instead
*/
int printFatal(lua_State* L) {
return printInternal(ghoul::logging::LogLevel::Fatal, L);
}
/**
* \ingroup LuaScripts
* absPath(string):
* Passes the argument to FileSystem::absolutePath, which resolves occuring path
* tokens and returns the absolute path.
*/
int absolutePath(lua_State* L) {
int nArguments = lua_gettop(L);
if (nArguments != 1)
return luaL_error(L, "Expected %d arguments, got %d", 1, nArguments);
std::string path = luaL_checkstring(L, -1);
path = absPath(path);
lua_pushstring(L, path.c_str());
return 1;
}
/**
* \ingroup LuaScripts
* setPathToken(string, string):
* Registers the path token provided by the first argument to the path in the second
* argument. If the path token already exists, it will be silently overridden.
*/
int setPathToken(lua_State* L) {
int nArguments = lua_gettop(L);
if (nArguments != 2)
return luaL_error(L, "Expected %i arguments, got %i", 2, nArguments);
std::string pathToken = luaL_checkstring(L, -1);
std::string path = luaL_checkstring(L, -2);
FileSys.registerPathToken(
pathToken,
path,
ghoul::filesystem::FileSystem::Override::Yes
);
return 0;
}
std::string path = luaL_checkstring(L, -1);
std::string pathToken = luaL_checkstring(L, -2);
FileSys.registerPathToken(
pathToken,
path,
ghoul::filesystem::FileSystem::Override::Yes
);
return 0;
}
} // namespace luascriptfunctions

View File

@@ -74,6 +74,8 @@ namespace {
return "ELLIPSOID";
case openspace::SpiceManager::FieldOfViewMethod::Point:
return "POINT";
default:
ghoul_assert(false, "Missing case label");
}
}
@@ -83,6 +85,8 @@ namespace {
return "UMBRAL";
case openspace::SpiceManager::TerminatorType::Penumbral:
return "PENUMBRAL";
default:
ghoul_assert(false, "Missing case label");
}
}
}
@@ -143,6 +147,8 @@ SpiceManager::AberrationCorrection::operator const char*() const {
return (direction == Direction::Reception) ? "CN" : "XCN";
case Type::ConvergedNewtonianStellar:
return (direction == Direction::Reception) ? "CN+S" : "XCN+S";
default:
ghoul_assert(false, "Missing case label");
}
}
@@ -559,6 +565,21 @@ glm::dvec3 SpiceManager::targetPosition(const std::string& target,
}
}
glm::dvec3 SpiceManager::targetPosition(const std::string& target,
const std::string& observer, const std::string& referenceFrame,
AberrationCorrection aberrationCorrection, double ephemerisTime) const
{
double unused = 0.0;
return targetPosition(
target,
observer,
referenceFrame,
aberrationCorrection,
ephemerisTime,
unused
);
}
glm::dmat3 SpiceManager::frameTransformationMatrix(const std::string& from,
const std::string& to,
double ephemerisTime) const

View File

@@ -317,6 +317,10 @@ function (handle_option_tests)
"${OPENSPACE_BASE_DIR}/tests"
"${OPENSPACE_EXT_DIR}/ghoul/ext/googletest/googletest/include"
)
target_compile_definitions(OpenSpaceTest PUBLIC
"GHL_THROW_ON_ASSERT"
"GTEST_HAS_TR1_TUPLE=0"
)
target_link_libraries(OpenSpaceTest gtest libOpenSpace)
if (MSVC)

View File

@@ -1,6 +1,6 @@
<GDAL_WMS>
<Service name="TiledWMS">
<ServerUrl>http://map1.vis.earthdata.nasa.gov/twms-geo/twms.cgi?</ServerUrl>
<ServerUrl>https://map1.vis.earthdata.nasa.gov/twms-geo/twms.cgi?</ServerUrl>
<TiledGroupName>MODIS TERRA tileset</TiledGroupName>
<Change key="${time}">2016-04-12</Change>
</Service>

View File

@@ -24,6 +24,10 @@
#include "gtest/gtest.h"
// When running the unit tests we don't want to be asked what to do in the case of an
// assertion
#define GHL_THROW_ON_ASSERT
#include <ghoul/cmdparser/cmdparser>
#include <ghoul/filesystem/filesystem>
#include <ghoul/logging/logging>

View File

@@ -58,5 +58,5 @@ TEST_F(GdalWmsTest, Simple) {
poDataset = (GDALDataset *)GDALOpen(testFile.c_str(), GA_ReadOnly);
// This assertion fails
ASSERT_NE(poDataset, nullptr) << "Failed to load testFile";
//ASSERT_NE(poDataset, nullptr) << "Failed to load testFile";
}