Merge branch 'develop' of openspace.itn.liu.se:/openspace into develop

Conflicts:
	src/rendering/renderablecrawlingline.cpp
	src/rendering/renderengine.cpp
This commit is contained in:
Anton Arbring
2015-05-12 23:29:14 -04:00
27 changed files with 201 additions and 159 deletions

View File

@@ -133,9 +133,6 @@ void MainWindow::readTcpData() {
QByteArray data = _socket->readAll();
//QString debug(data);
//qDebug() << debug;
if (QString(data) == "Connected to SGCT!\r\n")
return;
if (QString(data) == "OK\r\n")
@@ -148,6 +145,19 @@ void MainWindow::readTcpData() {
} messageType;
std::memcpy(messageType.data.data(), messageTypeData.data(), sizeof(uint16_t));
switch (messageType.value) {
case MessageTypeStatus:
break;
case MessageTypePlayBookHongKang:
qDebug() << "Hong Kang Playbook received";
break;
case MessageTypePlayBookLabel:
qDebug() << "Label Playbook received";
break;
default:
qDebug() << "Unknown message of type '" << messageType.value << "'";
}
switch (messageType.value) {
case MessageTypeStatus:
{
@@ -163,12 +173,19 @@ void MainWindow::readTcpData() {
size_t beginning = 0;
uint32_t size = readFromBuffer<uint32_t>(data.mid(2).data(), beginning);
//qDebug() << "Begin reading data";
while (_socket->waitForReadyRead() && data.size() < int(size)) {
//qDebug() << ".";
data = data.append(_socket->readAll());
//data = data.append(_socket->read(int(size) - data.size()));
QThread::msleep(50);
}
//qDebug() << "Finished reading data. Handling playbook";
handlePlaybook(data.mid(2));
//qDebug() << "Finished handling playbook";
if (messageType.value == MessageTypePlayBookHongKang)
_hasHongKangTimeline = true;
if (messageType.value == MessageTypePlayBookLabel)
@@ -181,7 +198,7 @@ void MainWindow::readTcpData() {
break;
}
default:
qDebug() << "Unknown message of type '" << messageType.value << "'";
qDebug() << QString(data);
}
}
@@ -275,12 +292,20 @@ void MainWindow::handlePlaybook(QByteArray data) {
}
void MainWindow::sendScript(QString script) {
if (_socket)
if (_socket) {
_socket->write(("0" + script + "\r\n").toLatin1());
//QByteArray data = (QString("0") + script).toLocal8Bit();
//qDebug() << data;
//_socket->write(data);
//QThread::msleep(25);
}
//_socket->write(("0" + script + "\r\n").toLatin1());
//_socket->write(("0" + script + "\0").toLatin1());
}
void MainWindow::onSocketConnected() {
_socket->write(QString("1\r\n").toLatin1());
//_socket->write(QString("1").toLatin1());
}

View File

@@ -65,7 +65,7 @@ private:
std::vector<Message> _initialConnectionMessages;
bool _shouldPublishStatusMessage;
MessageIdentifier _statusMessageIdentifier;
MessageIdentifier _identifierMappingIdentifier;

View File

@@ -86,7 +86,7 @@ private:
std::vector<TrailVBOLayout> _vertexArray;
float _increment;
float _oldTime = 0;
double _oldTime = 0.0;
float _time;
float _distanceFade;
};

View File

@@ -103,7 +103,7 @@ public:
// This is temporary until a proper screenspace solution is found ---abock
struct {
glm::vec2 _position;
float _size;
unsigned int _size;
int _node;
} _onScreenInformation;

View File

@@ -721,7 +721,7 @@ void OpenSpaceEngine::externalControlCallback(const char* receivedChars,
if (size == 0)
return;
_networkEngine->handleMessage(std::string(receivedChars));
_networkEngine->handleMessage(std::string(receivedChars, size));
}
void OpenSpaceEngine::enableBarrier() {

View File

@@ -51,7 +51,7 @@ void GuiOriginComponent::render() {
nodeNames += n->name() + '\0';
int position = it - nodes.begin();
int position = static_cast<int>(std::distance(it, nodes.begin()));
bool result = ImGui::Combo("Origin", &position, nodeNames.c_str());

View File

@@ -433,10 +433,10 @@ void GuiPropertyComponent::render() {
ImGui::SliderFloat2("Position", &value.x, -1.f, 1.f);
pos = value;
float& size = OsEng.renderEngine()->_onScreenInformation._size;
float fValue = size;
ImGui::SliderFloat("Size", &fValue, 0.f, 36.f);
size = fValue;
unsigned int& size = OsEng.renderEngine()->_onScreenInformation._size;
int sizeValue = static_cast<int>(size);
ImGui::SliderInt("Size", &sizeValue, 0, 36);
size = static_cast<unsigned int>(sizeValue);
int& node = OsEng.renderEngine()->_onScreenInformation._node;
int iValue = node;

View File

@@ -38,9 +38,8 @@ namespace openspace {
namespace gui {
void GuiTimeComponent::render() {
float deltaTime = Time::ref().deltaTime();
float deltaTime = static_cast<float>(Time::ref().deltaTime());
bool changed = ImGui::SliderFloat("Delta Time", &deltaTime, -100.f, 100.f);
if (changed)
OsEng.scriptEngine()->queueScript("openspace.time.setDeltaTime(" + std::to_string(deltaTime) + ")");

View File

@@ -308,7 +308,7 @@ int setInteractionSensitivity(lua_State* L) {
if (nArguments != 1)
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
double sensitivity = luaL_checknumber(L, -1);
float sensitivity = static_cast<float>(luaL_checknumber(L, -1));
OsEng.interactionHandler()->setInteractionSensitivity(sensitivity);
return 0;
}
@@ -334,7 +334,7 @@ int setInvertRoll(lua_State* L) {
if (nArguments != 1)
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
bool invert = lua_toboolean(L, -1);
bool invert = lua_toboolean(L, -1) == 1;
OsEng.interactionHandler()->setInvertRoll(invert);
return 0;
}
@@ -360,7 +360,7 @@ int setInvertRotation(lua_State* L) {
if (nArguments != 1)
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
bool invert = lua_toboolean(L, -1);
bool invert = lua_toboolean(L, -1) == 1;
OsEng.interactionHandler()->setInvertRotation(invert);
return 0;
}

View File

@@ -28,6 +28,8 @@
#include <openspace/engine/openspaceengine.h>
#include <array>
#include <chrono>
#include <thread>
#include "sgct.h"
@@ -45,6 +47,7 @@ namespace openspace {
NetworkEngine::NetworkEngine()
: _lastAssignedIdentifier(-1) // -1 is okay as we assign one identifier in this ctor
, _shouldPublishStatusMessage(true)
{
static_assert(
sizeof(MessageIdentifier) == 2,
@@ -78,7 +81,7 @@ bool NetworkEngine::handleMessage(const std::string& message) {
}
void NetworkEngine::publishStatusMessage() {
if (!sgct::Engine::instance()->isExternalControlConnected())
if (!_shouldPublishStatusMessage || !sgct::Engine::instance()->isExternalControlConnected())
return;
// Protocol:
// 8 bytes: time as a ET double
@@ -93,7 +96,7 @@ void NetworkEngine::publishStatusMessage() {
double delta = Time::ref().deltaTime();
messageSize += sizeof(time);
messageSize += timeString.length();
messageSize += static_cast<uint16_t>(timeString.length());
messageSize += sizeof(delta);
ghoul_assert(messageSize == 40, "Message size is not correct");
@@ -104,7 +107,7 @@ void NetworkEngine::publishStatusMessage() {
std::memmove(buffer.data() + currentLocation, &time, sizeof(time));
currentLocation += sizeof(time);
std::memmove(buffer.data() + currentLocation, timeString.c_str(), timeString.length());
currentLocation += timeString.length();
currentLocation += static_cast<unsigned int>(timeString.length());
std::memmove(buffer.data() + currentLocation, &delta, sizeof(delta));
publishMessage(_statusMessageIdentifier, std::move(buffer));
@@ -171,13 +174,18 @@ void NetworkEngine::sendMessages() {
// Prepending the message identifier to the front
m.body.insert(m.body.begin(), identifier.data.begin(), identifier.data.end());
sgct::Engine::instance()->sendMessageToExternalControl(m.body.data(), m.body.size());
sgct::Engine::instance()->sendMessageToExternalControl(
m.body.data(),
static_cast<int>(m.body.size())
);
}
_messagesToSend.clear();
}
void NetworkEngine::sendInitialInformation() {
static const int SleepTime = 100;
_shouldPublishStatusMessage = false;
for (const Message& m : _initialConnectionMessages) {
union {
MessageIdentifier value;
@@ -187,8 +195,15 @@ void NetworkEngine::sendInitialInformation() {
std::vector<char> payload = m.body;
payload.insert(payload.begin(), identifier.data.begin(), identifier.data.end());
sgct::Engine::instance()->sendMessageToExternalControl(payload.data(), payload.size());
sgct::Engine::instance()->sendMessageToExternalControl(
payload.data(),
static_cast<int>(payload.size())
);
std::this_thread::sleep_for(std::chrono::milliseconds(SleepTime));
}
_shouldPublishStatusMessage = true;
}
void NetworkEngine::setInitialConnectionMessage(MessageIdentifier identifier, std::vector<char> message) {

View File

@@ -91,7 +91,7 @@ ModelGeometry::~ModelGeometry() {
void ModelGeometry::render() {
glBindVertexArray(_vaoID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _ibo);
glDrawElements(_mode, _indices.size(), GL_UNSIGNED_INT, 0);
glDrawElements(_mode, static_cast<GLsizei>(_indices.size()), GL_UNSIGNED_INT, 0);
glBindVertexArray(0);
}

View File

@@ -43,6 +43,9 @@
#include <sgct.h>
#include "imgui.h"
#define _USE_MATH_DEFINES
#include <math.h>
namespace {
const std::string _loggerCat = "RenderableModel";
const std::string keySource = "Rotation.Source";
@@ -172,9 +175,9 @@ void RenderableModel::render(const RenderData& data) {
bool targetPositionCoverage = openspace::SpiceManager::ref().hasSpkCoverage(_target, time);
if (!targetPositionCoverage){
int frame = ImGui::GetFrameCount() % 180;
float fadingFactor = sin((frame * pi_c()) / 180);
_alpha = 0.5f + fadingFactor*0.5f;
//_texture = "";
float fadingFactor = static_cast<float>(sin((frame * M_PI) / 180));
_alpha = 0.5f + fadingFactor * 0.5f;
}
else
_alpha = 1.0f;
@@ -222,17 +225,14 @@ void RenderableModel::update(const UpdateData& data) {
double remaining = openspace::ImageSequencer2::ref().getNextCaptureTime() - data.time;
double interval = openspace::ImageSequencer2::ref().getIntervalLength();
double t = 1.f - remaining / openspace::ImageSequencer2::ref().getIntervalLength();
if (interval > 60){
if (t < 0.8){
_fading = t;
}
else if (t >= 0.95f){
if (interval > 60) {
if (t < 0.8)
_fading = static_cast<float>(t);
else if (t >= 0.95)
_fading = _fading - 0.5f;
}
}
else{
_fading = 0.0f;
}
else
_fading = 0.f;
_time = futureTime;
}

View File

@@ -66,8 +66,8 @@ bool WavefrontGeometry::loadModel(const std::string& filename) {
LWARNING("Loading models with more than one shape is currently untested");
}
int totalSizeIndex = 0;
int totalSizeVertex = 0;
size_t totalSizeIndex = 0;
size_t totalSizeVertex = 0;
for (int i = 0; i < shapes.size(); ++i) {
totalSizeIndex += shapes[i].mesh.indices.size();
totalSizeVertex += shapes[i].mesh.positions.size();
@@ -86,9 +86,9 @@ bool WavefrontGeometry::loadModel(const std::string& filename) {
// We add all shapes of the model into the same vertex array, one after the other
// The _shapeCounts array stores for each shape, how many vertices that shape has
int currentPosition = 0;
size_t currentPosition = 0;
int currentIndices = 0;
int p = 0;
size_t p = 0;
for (int i = 0; i < shapes.size(); ++i) {
for (int j = 0; j < shapes[i].mesh.positions.size() / 3; ++j) {
_vertices[j + currentPosition].location[0] = shapes[i].mesh.positions[3 * j + 0];

View File

@@ -303,7 +303,7 @@ void RenderablePlanetProjection::imageProjectGPU(){
glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ZERO, GL_ZERO);
glViewport(0, 0, _texture->width(), _texture->height());
glViewport(0, 0, static_cast<GLsizei>(_texture->width()), static_cast<GLsizei>(_texture->height()));
_fboProgramObject->activate();
ghoul::opengl::TextureUnit unitFbo;
@@ -440,8 +440,6 @@ void RenderablePlanetProjection::render(const RenderData& data){
_camScaling = data.camera.scaling();
_up = data.camera.lookUpVector();
double startTime, endTime;
#ifdef GPU_PROJ
if (_capture && _performProjection)
project();

View File

@@ -55,56 +55,57 @@ namespace {
const std::string keyInstrumentMethod = "Instrument.Method";
const std::string keyInstrumentAberration = "Instrument.Aberration";
const std::string keyPotentialTargets = "PotentialTargets";
}
//#define DEBUG
namespace openspace{
// colors, move later
glm::vec4 col_sq;
glm::vec4 c_project;
glm::vec4 col_end;
glm::vec4 blue;
glm::vec4 col_gray;
glm::vec4 col_start;
RenderableFov::RenderableFov(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _lineWidth("lineWidth", "Line Width", 1.f, 1.f, 20.f)
, _programObject(nullptr)
, _texture(nullptr)
, _drawSolid("solidDraw", "Draw as Quads", false)
, _mode(GL_LINES){
bool success = dictionary.getValue(keyBody, _spacecraft);
ghoul_assert(success, "");
success = dictionary.getValue(keyFrame, _frame);
ghoul_assert(success, "");
success = dictionary.getValue(keyInstrument, _instrumentID);
ghoul_assert(success, "");
success = dictionary.getValue(keyInstrumentMethod, _method);
ghoul_assert(success, "");
success = dictionary.getValue(keyInstrumentAberration, _aberrationCorrection);
ghoul_assert(success, "");
ghoul::Dictionary potentialTargets;
success = dictionary.getValue(keyPotentialTargets, potentialTargets);
ghoul_assert(success, "");
_potentialTargets.resize(potentialTargets.size());
for (int i = 0; i < potentialTargets.size(); ++i) {
std::string target;
potentialTargets.getValue(std::to_string(i + 1), target);
_potentialTargets[i] = target;
}
addProperty(_lineWidth);
addProperty(_drawSolid);
// colors, move later
glm::vec4 col_sq;
glm::vec4 c_project;
glm::vec4 col_end;
glm::vec4 blue;
glm::vec4 col_gray;
glm::vec4 col_start;
}
void RenderableFov::allocateData(){
namespace openspace {
RenderableFov::RenderableFov(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _lineWidth("lineWidth", "Line Width", 1.f, 1.f, 20.f)
, _programObject(nullptr)
, _texture(nullptr)
, _drawSolid("solidDraw", "Draw as Quads", false)
, _mode(GL_LINES)
{
bool success = dictionary.getValue(keyBody, _spacecraft);
ghoul_assert(success, "");
success = dictionary.getValue(keyFrame, _frame);
ghoul_assert(success, "");
success = dictionary.getValue(keyInstrument, _instrumentID);
ghoul_assert(success, "");
success = dictionary.getValue(keyInstrumentMethod, _method);
ghoul_assert(success, "");
success = dictionary.getValue(keyInstrumentAberration, _aberrationCorrection);
ghoul_assert(success, "");
ghoul::Dictionary potentialTargets;
success = dictionary.getValue(keyPotentialTargets, potentialTargets);
ghoul_assert(success, "");
_potentialTargets.resize(potentialTargets.size());
for (int i = 0; i < potentialTargets.size(); ++i) {
std::string target;
potentialTargets.getValue(std::to_string(i + 1), target);
_potentialTargets[i] = target;
}
addProperty(_lineWidth);
addProperty(_drawSolid);
}
void RenderableFov::allocateData() {
int points = 20;
_stride[0] = points;
_isize[0] = points;
@@ -120,14 +121,14 @@ void RenderableFov::allocateData(){
}
_stride[0] = 8;
_vsize[0] = _varray1.size();
_vsize[0] = static_cast<unsigned int>(_varray1.size());
_vtotal[0] = static_cast<int>(_vsize[0] / _stride[0]);
// allocate second vbo data
int cornerPoints = 12;
_isize[1] = cornerPoints;
_iarray1[1] = new int[_isize[1]];
for (int i = 0; i < _isize[1]; i++){
for (unsigned int i = 0; i < _isize[1]; i++){
_iarray1[1][i] = i;
}
_varray2.resize(40);
@@ -136,12 +137,11 @@ void RenderableFov::allocateData(){
_isteps = 10;
}
RenderableFov::~RenderableFov(){
RenderableFov::~RenderableFov() {
deinitialize();
}
bool RenderableFov::initialize(){
bool RenderableFov::initialize() {
bool completeSuccess = true;
if (_programObject == nullptr)
completeSuccess &= OsEng.ref().configurationManager()->getValue("FovProgram", _programObject);
@@ -153,7 +153,7 @@ bool RenderableFov::initialize(){
return completeSuccess;
}
bool RenderableFov::deinitialize(){
bool RenderableFov::deinitialize() {
return true;
}
@@ -161,7 +161,7 @@ bool RenderableFov::isReady() const {
return _programObject != nullptr;
}
void RenderableFov::sendToGPU(){
void RenderableFov::sendToGPU() {
// Initialize and upload to graphics card
glGenVertexArrays(1, &_vaoID[0]);
glGenBuffers(1, &_vboID[0]);
@@ -204,7 +204,7 @@ void RenderableFov::sendToGPU(){
}
// various helper methods
void RenderableFov::insertPoint(std::vector<float>& arr, psc p, glm::vec4 c){
void RenderableFov::insertPoint(std::vector<float>& arr, psc p, glm::vec4 c) {
for (int i = 0; i < 4; i++){
arr.push_back(p[i]);
}
@@ -214,13 +214,14 @@ void RenderableFov::insertPoint(std::vector<float>& arr, psc p, glm::vec4 c){
_nrInserted++;
}
glm::dvec3 RenderableFov::interpolate(glm::dvec3 p0, glm::dvec3 p1, float t){
glm::dvec3 RenderableFov::interpolate(glm::dvec3 p0, glm::dvec3 p1, float t) {
assert(t >= 0 && t <= 1);
float t2 = (1.f - t);
return glm::dvec3(p0.x*t2 + p1.x*t, p0.y*t2 + p1.y*t, p0.z*t2 + p1.z*t);
}
// This method is the current bottleneck.
psc RenderableFov::checkForIntercept(glm::dvec3 ray){
psc RenderableFov::checkForIntercept(glm::dvec3 ray) {
double targetEt;
bool intercepted = false;
openspace::SpiceManager::ref().getSurfaceIntercept(_fovTarget, _spacecraft, _instrumentID,
@@ -232,7 +233,7 @@ psc RenderableFov::checkForIntercept(glm::dvec3 ray){
return _interceptVector;
}
// Orthogonal projection next to planets surface, can also be optimized.
psc RenderableFov::orthogonalProjection(glm::dvec3 vecFov){
psc RenderableFov::orthogonalProjection(glm::dvec3 vecFov) {
glm::dvec3 vecToTarget;
double lt;
SpiceManager::ref().getTargetPosition(_fovTarget, _spacecraft, _frame, _aberrationCorrection, _time, vecToTarget, lt);
@@ -245,7 +246,7 @@ psc RenderableFov::orthogonalProjection(glm::dvec3 vecFov){
return projection;
}
// Bisection method, simple recurtion
glm::dvec3 RenderableFov::bisection(glm::dvec3 p1, glm::dvec3 p2, double tolerance){
glm::dvec3 RenderableFov::bisection(glm::dvec3 p1, glm::dvec3 p2, double tolerance) {
//check if point is on surface
double targetEt;
glm::dvec3 half = interpolate(p1, p2, 0.5f);
@@ -281,11 +282,10 @@ glm::dvec3 RenderableFov::bisection(glm::dvec3 p1, glm::dvec3 p2, double toleran
targets surface, each consecutive point is queried for a surface intercept and
thereby moved to the hull.
*/
void RenderableFov::fovProjection(bool H[], std::vector<glm::dvec3> bounds){
void RenderableFov::fovProjection(bool H[], std::vector<glm::dvec3> bounds) {
_nrInserted = 0;
_varray2.clear();// empty the array
double t;
double tolerance = 0.0000001; // very low tolerance factor
glm::dvec3 mid;
@@ -306,7 +306,7 @@ void RenderableFov::fovProjection(bool H[], std::vector<glm::dvec3> bounds){
// find outer most point for interpolation
mid = bisection(current, next, tolerance);
for (int j = 1; j <= _isteps; j++){
t = ((double)j / _isteps);
float t = (static_cast<float>(j) / _isteps);
interpolated = interpolate(current, mid, t);
_interceptVector = (j < _isteps) ? checkForIntercept(interpolated) : orthogonalProjection(interpolated);
insertPoint(_varray2, _interceptVector, col_sq);
@@ -315,7 +315,7 @@ void RenderableFov::fovProjection(bool H[], std::vector<glm::dvec3> bounds){
if (H[i] == false && H[i + 1] == true){ // current point is non-interceptive, next is
mid = bisection(next, current, tolerance);
for (int j = 1; j <= _isteps; j++){
t = ((double)j / _isteps);
float t = (static_cast<float>(j) / _isteps);
interpolated = interpolate(mid, next, t);
_interceptVector = (j > 1) ? checkForIntercept(interpolated) : orthogonalProjection(interpolated);
insertPoint(_varray2, _interceptVector, col_sq);
@@ -323,7 +323,7 @@ void RenderableFov::fovProjection(bool H[], std::vector<glm::dvec3> bounds){
}
if (H[i] == true && H[i + 1] == true){ // both points intercept
for (int j = 0; j <= _isteps; j++){
t = ((double)j / _isteps);
float t = (static_cast<float>(j) / _isteps);
interpolated = interpolate(current, next, t);
_interceptVector = checkForIntercept(interpolated);
insertPoint(_varray2, _interceptVector, col_sq);
@@ -339,15 +339,15 @@ void RenderableFov::fovProjection(bool H[], std::vector<glm::dvec3> bounds){
//update size etc;
_vtotal[1] = _nrInserted;
_isize[1] = _nrInserted;
_vsize[1] = _varray2.size();
_vsize[1] = static_cast<unsigned int>(_varray2.size());
_iarray1[1] = new int[_isize[1]];
for (int i = 0; i < _isize[1]; i++)
for (unsigned int i = 0; i < _isize[1]; i++)
_iarray1[1][i] = i;
}
}
void RenderableFov::updateData(){
void RenderableFov::updateData() {
glBindBuffer(GL_ARRAY_BUFFER, _vboID[0]);
glBufferSubData(GL_ARRAY_BUFFER, 0, _vsize[0] * sizeof(GLfloat), &_varray1[0]);
@@ -372,13 +372,15 @@ void RenderableFov::updateData(){
glBindVertexArray(0);
}
}
void RenderableFov::computeColors(){
void RenderableFov::computeColors() {
double t2 = openspace::ImageSequencer2::ref().getNextCaptureTime();
double diff = (t2 - _time);
double t = 0.0;
if (diff <= 7.0) t = 1.f - diff / 7.0;
float t = 0.0;
if (diff <= 7.0)
t = static_cast<float>(1.0 - (diff / 7.0));
if (diff < 0) t = 0.0;
if (diff < 0.0)
t = 0.f;
// i need to add an *.h file with colortables....
c_project = glm::vec4(0.0, 1.0, 0.00,1);
col_end = glm::vec4(1.00, 0.29, 0.00, 1);
@@ -404,7 +406,7 @@ void RenderableFov::computeColors(){
col_end.w = 0.5;
}
void RenderableFov::render(const RenderData& data){
void RenderableFov::render(const RenderData& data) {
assert(_programObject);
_programObject->activate();
// fetch data
@@ -413,7 +415,7 @@ void RenderableFov::render(const RenderData& data){
glm::mat4 spacecraftRot = glm::mat4(1);
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
spacecraftRot[i][j] = _stateMatrix[i][j];
spacecraftRot[i][j] = static_cast<float>(_stateMatrix[i][j]);
}
}
bool drawFOV = false;
@@ -441,7 +443,7 @@ void RenderableFov::render(const RenderData& data){
LERROR("Could not locate instrument");
return;
}
float size = 4 * sizeof(float);
const unsigned int size = 4 * sizeof(float);
int indx = 0;
_fovTarget = _potentialTargets[0]; //default
@@ -564,10 +566,9 @@ void RenderableFov::render(const RenderData& data){
_programObject->deactivate();
}
void RenderableFov::update(const UpdateData& data){
double lightTime;
void RenderableFov::update(const UpdateData& data) {
_time = data.time;
openspace::SpiceManager::ref().getPositionTransformMatrix(_instrumentID, _frame, data.time, _stateMatrix);
}
}
} // namespace openspace

View File

@@ -159,7 +159,7 @@ void RenderablePath::render(const RenderData& data) {
if (_drawLine) {
glLineWidth(_lineWidth);
glBindVertexArray(_vaoID);
glDrawArrays(GL_LINE_STRIP, 0, _vertexArray.size());
glDrawArrays(GL_LINE_STRIP, 0, static_cast<GLsizei>(_vertexArray.size()));
glBindVertexArray(0);
glLineWidth(1.f);
}
@@ -178,7 +178,7 @@ void RenderablePath::render(const RenderData& data) {
//glPointParameterfv(GL_POINT_FADE_THRESHOLD_SIZE, fadeThreshold);
glBindVertexArray(_vaoID);
glDrawArrays(GL_POINTS, 0, _vertexArray.size());
glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(_vertexArray.size()));
glBindVertexArray(0);
_programObject->deactivate();

View File

@@ -41,16 +41,14 @@ namespace openspace {
const PowerScaledScalar radius = PowerScaledScalar(1.f, 20.f);
RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _gridProgram(nullptr)
, _vaoID(0)
, _vBufferID(0)
, _iBufferID(0)
, _mode(GL_LINES)
: Renderable(dictionary)
, _gridProgram(nullptr)
, _vaoID(0)
, _vBufferID(0)
, _iBufferID(0)
, _mode(GL_LINES)
{
_gridMatrix = glm::mat4(1);
glm::vec2 s;
dictionary.getValue(constants::renderablesphericalgrid::gridType , _gridType);
dictionary.getValue(constants::renderablesphericalgrid::gridColor , _gridColor);
@@ -59,13 +57,12 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
staticGrid = dictionary.getValue(constants::renderablesphericalgrid::gridPatentsRotiation, _parentsRotation);
}
dictionary.getValue(constants::renderablesphericalgrid::gridSegments, s);
dictionary.getValue(constants::renderablesphericalgrid::gridSegments, _segments);
/*glm::vec2 radius;
dictionary.getValue(constants::renderablesphericalgrid::gridRadius, radius);
*/
_segments = s[0];
_isize = int(6 * _segments * _segments);
_vsize = int((_segments + 1) * (_segments + 1));
@@ -199,7 +196,7 @@ void RenderableSphericalGrid::render(const RenderData& data){
glm::mat4 transform;
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
transform[i][j] = _parentMatrix[i][j];
transform[i][j] = static_cast<float>(_parentMatrix[i][j]);
}
}

View File

@@ -169,7 +169,7 @@ void RenderableTrail::render(const RenderData& data) {
glLineWidth(_lineWidth);
glBindVertexArray(_vaoID);
glDrawArrays(GL_LINE_STRIP, 0, _vertexArray.size());
glDrawArrays(GL_LINE_STRIP, 0, static_cast<GLsizei>(_vertexArray.size()));
glBindVertexArray(0);
glLineWidth(1.f);
@@ -177,7 +177,7 @@ void RenderableTrail::render(const RenderData& data) {
if (_showTimestamps){
glPointSize(5.f);
glBindVertexArray(_vaoID);
glDrawArrays(GL_POINTS, 0, _vertexArray.size());
glDrawArrays(GL_POINTS, 0, static_cast<GLsizei>(_vertexArray.size()));
glBindVertexArray(0);
}
@@ -214,7 +214,7 @@ void RenderableTrail::update(const UpdateData& data) {
// As soon as the time difference between the current time and the last time is bigger
// than the fixed distance, we need to create a new fixed point
double deltaTime = abs(data.time - _oldTime);
int nValues = floor(deltaTime / _increment);
int nValues = static_cast<int>(floor(deltaTime / _increment));
// Update the floating current time
if (start > data.time)

View File

@@ -339,9 +339,9 @@ ghoul::opengl::Texture* RenderableVolume::loadTransferFunction(const std::string
if (tokenSize > 0) {
std::string key = tokens.at(0);
if(key == "width" && tokenSize == 2) {
width = stringToNumber<int>(tokens.at(1),widthValidator);
width = static_cast<int>(stringToNumber<size_t>(tokens.at(1), widthValidator));
} else if(key == "lower" && tokenSize == 2) {
lower = stringToNumber<float>(tokens.at(1),upperLowerValidator);
lower = stringToNumber<float>(tokens.at(1), upperLowerValidator);
} else if(key == "upper" && tokenSize == 2) {
upper = stringToNumber<float>(tokens.at(1),upperLowerValidator);
} else if(key == "mappingkey" && tokenSize == 6) {

View File

@@ -233,7 +233,7 @@ namespace openspace {
{
_onScreenInformation = {
glm::vec2(0.f),
12.f,
12,
-1
};
}
@@ -503,7 +503,7 @@ namespace openspace {
int thisId = sgct_core::ClusterManager::instance()->getThisNodeId();
if (thisId == _onScreenInformation._node) {
const int font_size_mono = _onScreenInformation._size;
const unsigned int font_size_mono = _onScreenInformation._size;
int x1, xSize, y1, ySize;
const sgct_text::Font* font = sgct_text::FontManager::instance()->getFont(constants::fonts::keyMono, font_size_mono);
sgct::Engine::instance()->getActiveWindowPtr()->getCurrentViewportPixelCoords(x1, y1, xSize, ySize);
@@ -557,9 +557,10 @@ namespace openspace {
if (openspace::ImageSequencer2::ref().isReady()) {
double remaining = openspace::ImageSequencer2::ref().getNextCaptureTime() - currentTime;
double t = 1.f - remaining / openspace::ImageSequencer2::ref().getIntervalLength();
double t = 1.0 - remaining / openspace::ImageSequencer2::ref().getIntervalLength();
std::string progress = "|";
int g = ((t)* 24) + 1;
int g = static_cast<int>((t* 24) + 1);
for (int i = 0; i < g; i++)
progress.append("-");
progress.append(">");
@@ -584,7 +585,7 @@ namespace openspace {
std::pair<double, std::string> currentTarget = ImageSequencer2::ref().getCurrentTarget();
if (currentTarget.first > 0.0) {
int timeleft = nextTarget.first - currentTime;
int timeleft = static_cast<int>(nextTarget.first - currentTime);
int hour = timeleft / 3600;
int second = timeleft % 3600;
@@ -606,9 +607,9 @@ namespace openspace {
std::pair<double, std::vector<std::string>> incidentTargets = ImageSequencer2::ref().getIncidentTargetList(2);
std::string space;
glm::vec4 color;
int isize = incidentTargets.second.size();
for (int p = 0; p < isize; p++){
double t = (double)(p + 1) / (double)(isize + 1);
size_t isize = incidentTargets.second.size();
for (size_t p = 0; p < isize; p++){
double t = static_cast<double>(p + 1) / static_cast<double>(isize + 1);
t = (p > isize / 2) ? 1 - t : t;
t += 0.3;
color = (p == isize / 2) ? targetColor : glm::vec4(t, t, t, 1);

View File

@@ -110,7 +110,6 @@ void HongKangParser::create(){
std::string line = "";
double shutter = 0.01;
double startTime, stopTime;
std::string previousTarget;
@@ -182,7 +181,7 @@ void HongKangParser::create(){
std::string endNominal = scanner->getStopCommand();
// store current position in file
int len = file.tellg();
std::streampos len = file.tellg();
std::string linePeek;
bool foundstop = false;
while (!file.eof() && !foundstop){
@@ -290,9 +289,11 @@ bool HongKangParser::augmentWithSpice(Image& image,
std::vector<std::string> potentialTargets){
image.target = "VOID";
// we have (?) to cast to int, unfortunately
// Why? --abock
int exposureTime = image.stopTime - image.startTime;
if (exposureTime == 0) exposureTime = 1;
double et;
if (exposureTime == 0)
exposureTime = 1;
for (int i = 0; i < potentialTargets.size(); i++){
bool success = false;
bool _withinFOV = false;

View File

@@ -89,9 +89,10 @@ std::pair<double, std::string> ImageSequencer2::getNextTarget(){
findEqualToThis.first = _currentTime;
auto it = std::lower_bound(_targetTimes.begin(), _targetTimes.end(), findEqualToThis, compareTime);
if (it != _targetTimes.end() && it != _targetTimes.begin()){
if (it != _targetTimes.end() && it != _targetTimes.begin())
return (*it);
}
else
return std::make_pair(0.0, "");
}
std::pair<double, std::string> ImageSequencer2::getCurrentTarget(){

View File

@@ -131,6 +131,10 @@ void LabelParser::create(){
std::string lblName = "";
ghoul::filesystem::Directory sequenceDir(_fileName, true);
if (!FileSys.directoryExists(sequenceDir)) {
LERROR("Could not load Label Directory '" << sequenceDir.path() << "'");
return;
}
std::vector<std::string> sequencePaths = sequenceDir.read(true, false); // check inputs
for (auto path : sequencePaths){
//std::cout << path << std::endl;

View File

@@ -65,7 +65,7 @@ void writeToBuffer<std::string>(std::vector<char>& buffer, size_t& currentWriteL
if ((currentWriteLocation + sizeof(uint8_t) + value.size()) > buffer.size())
buffer.resize(2 * buffer.size());
uint8_t length = value.size();
uint8_t length = static_cast<uint8_t>(value.size());
std::memcpy(buffer.data() + currentWriteLocation, &length, sizeof(uint8_t));
currentWriteLocation += sizeof(uint8_t);
@@ -123,7 +123,7 @@ void SequenceParser::sendPlaybookInformation(const std::string& name) {
uint32_t allImages = 0;
for (auto target : _subsetMap)
allImages += target.second._subset.size();
allImages += static_cast<uint32_t>(target.second._subset.size());
writeToBuffer(buffer, currentWriteLocation, allImages);
for (auto target : _subsetMap){
@@ -158,7 +158,7 @@ void SequenceParser::sendPlaybookInformation(const std::string& name) {
uint32_t value;
std::array<char, sizeof(uint32_t)> data;
} sizeBuffer;
sizeBuffer.value = currentWriteLocation;
sizeBuffer.value = static_cast<uint32_t>(currentWriteLocation);
buffer.insert(buffer.begin(), sizeBuffer.data.begin(), sizeBuffer.data.end());
currentWriteLocation += sizeof(uint32_t);

View File

@@ -100,7 +100,7 @@ int time_setPause(lua_State* L) {
if (nArguments != 1)
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
bool pause = lua_toboolean(L, -1);
bool pause = lua_toboolean(L, -1) == 1;
openspace::Time::ref().setPause(pause);
return 0;
}