Base orbit update on actual previous values instead of time jump concept. Fix OpenGL invalid value bug caused by negative buffer size. (#346)

This commit is contained in:
Emil Axelsson
2017-07-01 19:31:12 +02:00
committed by Alexander Bock
parent 46179922b7
commit 4318a2b709
2 changed files with 9 additions and 8 deletions

View File

@@ -138,6 +138,7 @@ RenderableTrailOrbit::RenderableTrailOrbit(const ghoul::Dictionary& dictionary)
, _resolution("resolution", "Number of Samples along Orbit", 10000, 1, 1000000)
, _needsFullSweep(true)
, _indexBufferDirty(true)
, _previousTime(0)
{
documentation::testSpecificationAndThrow(
Documentation(),
@@ -284,7 +285,7 @@ void RenderableTrailOrbit::update(const UpdateData& data) {
// The current index
int i = _primaryRenderInformation.first;
// Number of values
int n = report.nUpdated + 1; // +1 for the floating position
int n = std::abs(report.nUpdated) + 1; // +1 for the floating position
// Total size of the array
int s = _primaryRenderInformation.count;
@@ -309,23 +310,21 @@ void RenderableTrailOrbit::update(const UpdateData& data) {
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
glBindVertexArray(0);
_previousTime = data.time.j2000Seconds();
}
RenderableTrailOrbit::UpdateReport RenderableTrailOrbit::updateTrails(
const UpdateData& data)
{
// If we are doing a time jump, it is in general faster to recalculate everything
// than to only update parts of the array
if (data.time.timeJumped()) {
_needsFullSweep = true;
}
if (_needsFullSweep) {
fullSweep(data.time.j2000Seconds());
return { true, UpdateReport::All } ;
}
const double Epsilon = 1e-7;
// When time stands still (at the iron hill), we don't need to perform any work
if (data.time.deltaTime() == 0.0) {
if (std::abs(data.time.j2000Seconds() - _previousTime) < Epsilon) {
return { false, 0 };
}
@@ -339,7 +338,7 @@ RenderableTrailOrbit::UpdateReport RenderableTrailOrbit::updateTrails(
//
// This might become a bigger issue if we are starting to look at very short time
// intervals
const double Epsilon = 1e-7;
if (std::abs(delta) < Epsilon) {
return { false, 0 };
}