Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions applications/mesh-viewer/mesh-viewer-widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <applications/qt/ColorWidget.h>
#include <applications/scene-display/animation-events.h>

#include "regen/animation/bones.h"

using namespace std;

// Resizes Framebuffer texture when the window size changed
Expand Down Expand Up @@ -388,6 +390,7 @@ static ref_ptr<Camera> createUserCamera(const Vec2i &viewport) {
cam->setPosition(0, Vec3f(0.0f, 0.0f, -3.0f));
cam->setDirection(0, Vec3f(0.0f, 0.0f, 1.0f));
cam->setPerspective(aspect, 45.0f, 0.1f, 100.0f);
cam->updateBuffers();
cam->updateCamera();
cam->updateShaderData(0.0f);
return cam;
Expand Down Expand Up @@ -492,12 +495,15 @@ void MeshViewerWidget::gl_loadScene() {
sceneRoot_->state()->joinStates(blit);
GL_ERROR_LOG();

app_->initializeScene();

// resize fbo with window
app_->connect(Scene::RESIZE_EVENT, ref_ptr<FBOResizer>::alloc(fboState));
// Update frustum when window size changes
app_->connect(Scene::RESIZE_EVENT,
ref_ptr<ProjectionUpdater>::alloc(userCamera_, app_->screen()));

AnimationManager::get().resetTime();
AnimationManager::get().resume();
REGEN_INFO("Scene Loaded.");
createCameraController();
Expand Down
2 changes: 1 addition & 1 deletion applications/scene-display/examples/character.xml
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@
</view>
</node>

<!-- apply anti-aliasing effect -->
<!-- apply antialiasing effect -->
<node import="FXAA">
<fbo id="g-buffer" draw-buffers="0"/>
<texture name="inputTexture" fbo="g-buffer" attachment="1"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
<define key="RAY_CASTING_MODE" value="FIRST_MAXIMUM"/>
<define key="SWITCH_VOLUME_Y" value="FALSE"/>
<cull mode="front"/>
<input type="float" name="rayStep" value="0.01"/>
<input type="float" name="rayStep" value="0.002" min="0.001" max="0.5" step="0.001" />
<input type="float" name="densityThreshold" value="0.175"/>
<input type="float" name="densityScale" value="1.0"/>
<input type="vec3" name="halfVolumeSize" value="0.8, 0.8, 0.8"/>
Expand Down Expand Up @@ -147,7 +147,7 @@
<input name="InputData" ssbo="ComputeInput"/>
<input name="OutputData" ssbo="ComputeOutput"/>

<input type="float" name="rayStep" value="0.01"/>
<input type="float" name="rayStep" value="0.002" min="0.001" max="0.5" step="0.001"/>
<input type="float" name="densityThreshold" value="0.175"/>
<input type="float" name="densityScale" value="1.0"/>
<input type="vec3" name="halfVolumeSize" value="0.8, 0.8, 0.8"/>
Expand Down
4 changes: 3 additions & 1 deletion applications/scene-display/examples/transparency.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@
</node>
</node>
<!-- Finally blit the new refraction texture to attachment 0. -->
<!-- TODO: blit could be avoided through ping-pong rendering. -->
<!-- This is done such that in the render loop we can keep the texture bound
with attachment 0 for sampling. An alternative would be to use ping-pong
buffers and switch the bindings each frame. -->
<node id="Blit-Refraction">
<fbo id="platform-refraction" draw-buffers="0"/>
<stencil test="0"/>
Expand Down
11 changes: 10 additions & 1 deletion applications/scene-display/scene-display-widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ SceneDisplayWidget::SceneDisplayWidget(QtApplication *app)
// load window width/height from Qt settings
int width = settings_.value("width", 1280).toInt();
int height = settings_.value("height", 960).toInt();
// Make sure we do not have too small window
if (width < 400) { width = 400; }
if (height < 300) { height = 300; }
// Make sure dimensions are divisible by 2
if (width % 2 != 0) { width += 1; }
if (height % 2 != 0) { height += 1; }
REGEN_INFO("Initial window size: " << width << "x" << height);

ui_.setupUi(this);
Expand Down Expand Up @@ -1102,9 +1108,12 @@ void SceneDisplayWidget::loadSceneGraphicsThread(const string &sceneFile) {
animations_.emplace_back(timeWidgetAnimation_);
loadAnim_ = ref_ptr<Animation>();
lightStates_ = sceneParser.getResources()->getLights();

// Make sure all staging operations are done before resuming animations.
StagingSystem::instance().rotateBuffers();

AnimationManager::get().setSpatialIndices(spatialIndexList_);
AnimationManager::get().resetTime();

AnimationManager::get().resume();
REGEN_INFO("XML Scene Loaded.");
}
Expand Down
6 changes: 3 additions & 3 deletions regen/av/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ void AudioListener::set3f(const ALenum &p, const Vec3f &v) {
}

Vec3f AudioListener::get3f(const ALenum &p) {
Vec3f v;
Vec3f v = Vec3f::zero();
alGetListenerf(p, &v.x);
return v;
}
Expand All @@ -196,7 +196,7 @@ void AudioListener::set6f(const ALenum &p, const Vec6f &v) {
}

Vec6f AudioListener::get6f(const ALenum &p) {
Vec6f v;
auto v = Vec6f{ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f };
alGetListenerf(p, &v.x0);
return v;
}
Expand Down Expand Up @@ -281,7 +281,7 @@ void AudioSource::set3f(const ALenum &p, const Vec3f &v) const {
}

Vec3f AudioSource::get3f(const ALenum &p) const {
Vec3f v;
Vec3f v = Vec3f::zero();
alGetSourcef(id_, p, &v.x);
return v;
}
Expand Down
11 changes: 4 additions & 7 deletions regen/av/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
#ifndef AUDIO_SOURCE_H_
#define AUDIO_SOURCE_H_

#include <regen/config.h>

extern "C" {
#include <libavcodec/version.h>
#include <libavcodec/avcodec.h>
Expand Down Expand Up @@ -121,6 +119,10 @@ namespace regen {

~AudioSource() override;

AudioSource(const AudioSource &) = delete;

AudioSource &operator=(const AudioSource &) = delete;

/**
* The audio source ID.
*/
Expand Down Expand Up @@ -218,11 +220,6 @@ namespace regen {
#endif

void doClearQueue();

private:
AudioSource(const AudioSource &);

AudioSource &operator=(const AudioSource &);
};
} // namespace

Expand Down
12 changes: 9 additions & 3 deletions regen/av/demuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,20 @@ static void avLogCallback(void *, int level, const char *msg, va_list args) {
int count = vsprintf(buffer, msg, args);
buffer[count - 1] = '\0';
switch (level) {
case AV_LOG_ERROR: REGEN_ERROR(buffer);
case AV_LOG_ERROR:
REGEN_ERROR(buffer);
break;
case AV_LOG_INFO: REGEN_INFO(buffer);
case AV_LOG_INFO:
REGEN_INFO(buffer);
break;
case AV_LOG_DEBUG:
//REGEN_DEBUG(buffer);
break;
case AV_LOG_WARNING: REGEN_WARN(buffer);
case AV_LOG_WARNING:
REGEN_WARN(buffer);
break;
default:
REGEN_DEBUG(buffer);
break;
}
}
Expand Down
11 changes: 2 additions & 9 deletions regen/av/demuxer.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ namespace regen {
*/
bool hasInput() const;

/**
* Total number of seconds elapsed in the stream.
*/
float elapsedSeconds() const;

/**
* Total number of seconds of currently loaded stream.
*/
Expand Down Expand Up @@ -131,10 +126,8 @@ namespace regen {
bool pauseFlag_;
bool repeatStream_;

int videoStreamIndex_;
int audioStreamIndex_;

//float elapsedSeconds_;
int videoStreamIndex_ = -1;
int audioStreamIndex_ = -1;

struct SeekPosition {
bool isRequired;
Expand Down
8 changes: 6 additions & 2 deletions regen/av/video-recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,12 @@ void VideoRecorder::initialize() {
if (formatCtx_->oformat->flags & AVFMT_GLOBALHEADER) {
codecCtx_->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
}
if (avcodec_open2(codecCtx_, codec, nullptr) < 0) {
throw std::runtime_error("Could not open codec");
int status = avcodec_open2(codecCtx_, codec, nullptr);
if (status < 0) {
// print error message
char err_buf[AV_ERROR_MAX_STRING_SIZE] = {};
av_make_error_string(err_buf, AV_ERROR_MAX_STRING_SIZE, status);
throw std::runtime_error(REGEN_STRING("Could not open codec: " << err_buf << " (" << status << ")"));
}

stream_ = avformat_new_stream(formatCtx_, codec);
Expand Down
2 changes: 1 addition & 1 deletion regen/behavior/world/body-part.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ std::istream &regen::operator>>(std::istream &in, BodyPart &v) {
else if (val == "LEG") v = BodyPart::LEG;
else {
REGEN_WARN("Unknown BodyPart value: " << val);
val = "NO_BODY_PART";
v = BodyPart::HEAD;
}
return in;
}
2 changes: 1 addition & 1 deletion regen/camera/camera-anchor.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace regen {

protected:
ref_ptr<ModelTransformation> transform_;
Vec3f offset_;
Vec3f offset_ = Vec3f::zero();
Mode mode_;
};
}
Expand Down
3 changes: 2 additions & 1 deletion regen/camera/reflection-camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ ReflectionCamera::ReflectionCamera(
transform_ = modelMat.value().in;
if (transform_.get() != nullptr) {
transformStamp_ = transform_->stampOfReadData() - 1;
const Mat4f &M = transform_->mapClientData<Mat4f>(BUFFER_GPU_READ).r[0];
auto mapped = transform_->mapClientData<Mat4f>(BUFFER_GPU_READ);
const Mat4f &M = mapped.r[0];
posWorld_ = M.mul_t31(posWorld_);
norWorld_ = M.mul_t30(norWorld_);
norWorld_.normalize();
Expand Down
2 changes: 1 addition & 1 deletion regen/compute/quadric.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace regen {
*/
class quadric {
public:
float a[10] = {0}; // 10 unique components of the symmetric 4x4 matrix
float a[10] = {}; // 10 unique components of the symmetric 4x4 matrix

quadric() = default;

Expand Down
1 change: 0 additions & 1 deletion regen/compute/quaternion.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ namespace regen {
// adjust signs (if necessary)
Quaternion end = pEnd;
if (cosom < 0.0f) {
cosom = -cosom;
end.x = -end.x; // Reverse all signs
end.y = -end.y;
end.z = -end.z;
Expand Down
2 changes: 1 addition & 1 deletion regen/compute/radix-sort-cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace regen {
std::vector<IndexType> tmp_indices_;
std::vector<uint32_t> histogram_;
alignas(32) KeyType tmpBins_[KEYS_PER_SIMD_PASS] = {0};
alignas(32) int32_t tmpKeys32[8] = {0};
alignas(32) int32_t tmpKeys32[8] = {};

/**
* @brief Constructor
Expand Down
1 change: 1 addition & 0 deletions regen/config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ namespace regen {
};
#endif // REGEN_CONFIG_H_

#include <regen/utility/logging.h>
#include <regen/gl/gl-util.h>
8 changes: 1 addition & 7 deletions regen/gl/gl-object.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef REGEN_GL_OBJECT_H_
#define REGEN_GL_OBJECT_H_

#include <regen/config.h>
#include <regen/gl/render-state.h>
#include <regen/utility/ref-ptr.h>

Expand Down Expand Up @@ -56,12 +55,7 @@ namespace regen {

GLObject(const GLObject &other);

virtual ~GLObject();

/**
* Releases and allocates resources again.
*/
void resetGL();
~GLObject() override;

/**
* Switch to the next allocated buffer.
Expand Down
2 changes: 2 additions & 0 deletions regen/gl/gl-param.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "gl-param.h"

#include "regen/compute/vector.h"

namespace regen {
template<> bool glParam<bool>(GLenum param) {
auto &store = GLParameterStore<bool>::instance();
Expand Down
2 changes: 0 additions & 2 deletions regen/gl/gl-param.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include <GL/glew.h>
#include <map>

#include <regen/compute/vector.h>

namespace regen {
// introduce a template function to get the value of a GL parameter
template<typename T> T glParam(GLenum param);
Expand Down
11 changes: 0 additions & 11 deletions regen/gl/gl-util.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
/*
* gl-util.h
*
* Created on: 20.03.2011
* Author: daniel
*/

#ifndef __GL_UTIL__
#define __GL_UTIL__

#include <sstream>

#include <GL/glew.h>
#include <regen/utility/strings.h>
#include <regen/utility/logging.h>
#include <regen/config.h>

namespace regen {
/**
Expand Down
8 changes: 6 additions & 2 deletions regen/gl/gpu-fence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ bool GPUFence::wait(bool allowFrameDropping) {
}
// poll the fence status
GLenum status = glClientWaitSync(fence_, GL_SYNC_FLUSH_COMMANDS_BIT, 0);
if (status == GL_WAIT_FAILED) {
GL_ERROR_LOG();
return false;
}

if (allowFrameDropping) {
if (status == GL_TIMEOUT_EXPIRED) {
setStalledFrame(true);
Expand All @@ -74,8 +79,7 @@ bool GPUFence::wait(bool allowFrameDropping) {
// Note: we use a wait timeout here to avoid wasting too much time in the loop.
setStalledFrame(status == GL_TIMEOUT_EXPIRED);
while (status == GL_TIMEOUT_EXPIRED) {
status = glClientWaitSync(fence_,
GL_SYNC_FLUSH_COMMANDS_BIT, WAIT_TIMEOUT);
status = glClientWaitSync(fence_, 0, WAIT_TIMEOUT);
}
}

Expand Down
4 changes: 3 additions & 1 deletion regen/gl/render-state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "render-state.h"

#include "regen/utility/logging.h"

using namespace regen;

#ifndef GL_DEBUG_OUTPUT
Expand Down Expand Up @@ -446,7 +448,7 @@ GLenum RenderState::toggleToID(Toggle t) {
return GL_NONE;
}
return GL_NONE;
};
}

namespace regen {
std::ostream &operator<<(std::ostream &out, const RenderState::Toggle &mode) {
Expand Down
2 changes: 1 addition & 1 deletion regen/gl/states/atomic-states.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ namespace regen {
*/
class ClearState : public ServerSideState {
public:
ClearState(const ref_ptr<FBO> &fbo)
explicit ClearState(const ref_ptr<FBO> &fbo)
: ServerSideState(), fbo_(fbo) {}

void addClearBit(GLbitfield clearBit) {
Expand Down
2 changes: 0 additions & 2 deletions regen/memory/aligned-allocator.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#ifndef REGEN_ALIGNED_ALLOCATOR_H_
#define REGEN_ALIGNED_ALLOCATOR_H_

#include <memory>
#include <cstdlib>
#include <cstddef>
#include <stdexcept>

namespace regen {
/**
Expand Down
Loading
Loading