mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-25 05:28:37 -05:00
Fix for Flare
- Fixed timestep error in Flare - Added option to compile openspace with Flare only
This commit is contained in:
@@ -45,7 +45,7 @@ raycaster_stepsize 0.005
|
||||
raycaster_intensity 1.0
|
||||
|
||||
# Animation speed
|
||||
animator_refresh_interval 0.05
|
||||
animator_refresh_interval 0.5
|
||||
|
||||
# Various paths
|
||||
raycaster_kernel_filename ${KERNELS}/RaycasterTSP.cl
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
#include <ghoul/opencl/clprogram.h>
|
||||
#include <ghoul/opencl/clkernel.h>
|
||||
|
||||
#define FLARE_ONLY
|
||||
|
||||
#include <openspace/flare/flare.h>
|
||||
|
||||
namespace openspace {
|
||||
@@ -81,6 +83,9 @@ private:
|
||||
ghoul::Dictionary* _configurationManager;
|
||||
InteractionHandler* _interactionHandler;
|
||||
RenderEngine* _renderEngine;
|
||||
#ifdef FLARE_ONLY
|
||||
Flare* _flare;
|
||||
#endif
|
||||
// ScriptEngine* _scriptEngine;
|
||||
ghoul::opencl::CLContext _context;
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ public:
|
||||
void keyboard(int key, int action);
|
||||
void mouse(int button, int action);
|
||||
void preSync();
|
||||
void postSyncPreDraw();
|
||||
void postDraw();
|
||||
void encode();
|
||||
void decode();
|
||||
|
||||
@@ -273,12 +273,14 @@ bool OpenSpaceEngine::initialize()
|
||||
|
||||
// initialize the RenderEngine, needs ${SCENEPATH} to be set
|
||||
_renderEngine->initialize();
|
||||
|
||||
sceneGraph->loadScene(sceneDescriptionPath, scenePath);
|
||||
sceneGraph->initialize();
|
||||
|
||||
_renderEngine->setSceneGraph(sceneGraph);
|
||||
|
||||
#ifdef FLARE_ONLY
|
||||
_flare = new Flare();
|
||||
_flare->initialize();
|
||||
#endif
|
||||
|
||||
// Initialize OpenSpace input devices
|
||||
DeviceIdentifier::init();
|
||||
@@ -331,16 +333,26 @@ void OpenSpaceEngine::preSynchronization()
|
||||
_interactionHandler->update(dt);
|
||||
_interactionHandler->lockControls();
|
||||
}
|
||||
#ifdef FLARE_ONLY
|
||||
_flare->preSync();
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::postSynchronizationPreDraw()
|
||||
{
|
||||
_renderEngine->postSynchronizationPreDraw();
|
||||
#ifdef FLARE_ONLY
|
||||
_flare->postSyncPreDraw();
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::render()
|
||||
{
|
||||
#ifdef FLARE_ONLY
|
||||
_flare->render();
|
||||
#else
|
||||
_renderEngine->render();
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::postDraw()
|
||||
@@ -348,6 +360,9 @@ void OpenSpaceEngine::postDraw()
|
||||
if (sgct::Engine::instance()->isMaster()) {
|
||||
_interactionHandler->unlockControls();
|
||||
}
|
||||
#ifdef FLARE_ONLY
|
||||
_flare->postDraw();
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::keyboardCallback(int key, int action)
|
||||
@@ -355,6 +370,9 @@ void OpenSpaceEngine::keyboardCallback(int key, int action)
|
||||
if (sgct::Engine::instance()->isMaster()) {
|
||||
_interactionHandler->keyboardCallback(key, action);
|
||||
}
|
||||
#ifdef FLARE_ONLY
|
||||
_flare->keyboard(key, action);
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::mouseButtonCallback(int key, int action)
|
||||
@@ -362,6 +380,9 @@ void OpenSpaceEngine::mouseButtonCallback(int key, int action)
|
||||
if (sgct::Engine::instance()->isMaster()) {
|
||||
_interactionHandler->mouseButtonCallback(key, action);
|
||||
}
|
||||
#ifdef FLARE_ONLY
|
||||
_flare->mouse(key, action);
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::mousePositionCallback(int x, int y)
|
||||
@@ -384,6 +405,9 @@ void OpenSpaceEngine::encode()
|
||||
|
||||
_synchronizationBuffer.setVal(dataStream);
|
||||
sgct::SharedData::instance()->writeVector(&_synchronizationBuffer);
|
||||
#ifdef FLARE_ONLY
|
||||
_flare->encode();
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenSpaceEngine::decode()
|
||||
@@ -394,6 +418,9 @@ void OpenSpaceEngine::decode()
|
||||
|
||||
// deserialize in the same order as done in serialization
|
||||
_renderEngine->deserialize(dataStream, offset);
|
||||
#ifdef FLARE_ONLY
|
||||
_flare->decode();
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <sgct.h>
|
||||
#include <ghoul/opengl/ghoul_gl.h>
|
||||
#include <ghoul/opengl/framebufferobject.h>
|
||||
#include <fstream>
|
||||
#include <openspace/flare/Raycaster.h>
|
||||
#include <openspace/flare/BrickManager.h>
|
||||
@@ -94,6 +95,7 @@ Raycaster * Raycaster::New(Config *_config) {
|
||||
|
||||
bool Raycaster::Render(float _timestep) {
|
||||
proj_ = sgct::Engine::instance()->getActiveProjectionMatrix();
|
||||
GLuint activeFBO = ghoul::opengl::FramebufferObject::getActiveObject();
|
||||
|
||||
// Clear cache for benchmarking
|
||||
if (config_->ClearCache()) {
|
||||
@@ -270,7 +272,7 @@ bool Raycaster::Render(float _timestep) {
|
||||
|
||||
|
||||
// Render to framebuffer using quad
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, sgct::Engine::instance()->getActiveWindowPtr()->getFBOPtr()->getBufferID());
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, activeFBO);
|
||||
|
||||
glGetError();
|
||||
quadShaderProgram_->activate();
|
||||
|
||||
+10
-2
@@ -34,7 +34,9 @@ Flare::Flare()
|
||||
, _lastMouseY(0)
|
||||
, _oldTime(0.f)
|
||||
, _currentTime(0.f)
|
||||
{}
|
||||
{
|
||||
setBoundingSphere(PowerScaledScalar::CreatePSS(sqrt(3.0f)));
|
||||
}
|
||||
|
||||
Flare::~Flare() {
|
||||
// Clean up like a good citizen
|
||||
@@ -66,7 +68,8 @@ void Flare::update() {
|
||||
|
||||
void Flare::render() {
|
||||
// Sync timestep
|
||||
_animator->SetCurrentTimestep(static_cast<unsigned int>(_timeStep.getVal()));
|
||||
//unsigned int ts = static_cast<unsigned int>(_timeStep.getVal());
|
||||
//LDEBUG("ts: " << ts);
|
||||
// Reload config if flag is set
|
||||
if (_reloadFlag.getVal()) _raycaster->Reload();
|
||||
|
||||
@@ -379,6 +382,7 @@ void Flare::preSync() {
|
||||
_oldTime = _currentTime;
|
||||
_currentTime = static_cast<float>(sgct::Engine::getTime());
|
||||
_elapsedTime.setVal(_currentTime - _oldTime);
|
||||
_timeStep.setVal(_animator->CurrentTimestep());
|
||||
|
||||
// Update automatic model transform
|
||||
if (!_animationPaused.getVal()) {
|
||||
@@ -398,6 +402,10 @@ void Flare::preSync() {
|
||||
}
|
||||
}
|
||||
|
||||
void Flare::postSyncPreDraw() {
|
||||
_animator->SetCurrentTimestep(static_cast<unsigned int>(_timeStep.getVal()));
|
||||
}
|
||||
|
||||
void Flare::postDraw() {
|
||||
// Reset manual timestep
|
||||
_manualTimestep.setVal(0);
|
||||
|
||||
Reference in New Issue
Block a user