Skip to content

Commit

Permalink
Merge branch 'release/3.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
naavis committed Mar 23, 2021
2 parents 41658f4 + 84dea39 commit c4eab39
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 32 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 3.2.0 - 2021-03-24

### Changed

- Improved logging and error handling

### Fixed

- Fixed bug where pyramid apex angle was set incorrectly based on crystal edge angle rather than face angle

## 3.1.0 - 2021-02-21

### Changed
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@ On Windows you can find it in `%LOCALAPPDATA%\Temp\haloray\haloray.log` where

On Linux the log file is in `/tmp/haloray/haloray.log`

If the logs do not show any useful information and no error messages pop up,
it is possible the crash happens because of a GPU driver bug. This has
occasionally happened with some Intel GPUs, and there is not much HaloRay
can do about it. It is recommended to update to the latest GPU drivers if
problems like this are encountered.

## Acknowledgments

- [Lauri Kangas](https://github.com/lkangas) for providing tons of reading material and debugging help
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "3.1.0-{build}"
version: "3.2.0-{build}"
branches:
only:
- master
Expand Down
15 changes: 8 additions & 7 deletions src/haloray-core/gui/crystalPreview/previewRenderArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ void PreviewRenderArea::initializeGeometry(QVector3D *vertices, int numVertices)

float deltaAngle = degToRad(60.0f);
QVector2D hexagonCorners[6];
/* The sqrt(3)/2 multiplier makes the default crystal such
that the distance of a vertex from the C axis is 1.0 */
float sizeScaler = sqrt(3.0f) / 2.0f;
for (int face = 0; face < 6; ++face)
{
int previousFace = face == 0 ? 5 : face - 1;
Expand All @@ -132,11 +135,9 @@ void PreviewRenderArea::initializeGeometry(QVector3D *vertices, int numVertices)
float currentAngle = previousAngle + deltaAngle;
float nextAngle = previousAngle + 2.0 * deltaAngle;

/* The sqrt(3)/2 multiplier makes the default crystal such
that the distance of a vertex from the C axis is 1.0 */
float previousDistance = 0.86602540378443864676372317075294 * prismFaceDistances[previousFace];
float currentDistance = 0.86602540378443864676372317075294 * prismFaceDistances[face];
float nextDistance = 0.86602540378443864676372317075294 * prismFaceDistances[nextFace];
float previousDistance = sizeScaler * prismFaceDistances[previousFace];
float currentDistance = sizeScaler * prismFaceDistances[face];
float nextDistance = sizeScaler * prismFaceDistances[nextFace];

QVector2D previousLine = QVector2D(previousDistance, previousAngle);
QVector2D currentLine = QVector2D(currentDistance, currentAngle);
Expand Down Expand Up @@ -185,8 +186,8 @@ void PreviewRenderArea::initializeGeometry(QVector3D *vertices, int numVertices)
}

// Scale pyramid caps
float upperApexMaxHeight = 1.0 / tan(upperApexAngle / 2.0);
float lowerApexMaxHeight = 1.0 / tan(lowerApexAngle / 2.0);
float upperApexMaxHeight = sizeScaler / tan(upperApexAngle / 2.0);
float lowerApexMaxHeight = sizeScaler / tan(lowerApexAngle / 2.0);

float upperApexHeight = upperApexHeightAverage;
float lowerApexHeight = lowerApexHeightAverage;
Expand Down
1 change: 1 addition & 0 deletions src/haloray-core/gui/openGLWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ void OpenGLWidget::resizeGL(int w, int h)

void OpenGLWidget::initializeGL()
{
qInfo("Initializing OpenGL widget");
initializeOpenGLFunctions();

m_textureRenderer = std::make_unique<OpenGL::TextureRenderer>();
Expand Down
1 change: 1 addition & 0 deletions src/haloray-core/haloray-core.pro
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ QT += core gui widgets
CONFIG += c++17 static
win32:CONFIG += windows

DEFINES += QT_MESSAGELOGCONTEXT
DEFINES += QT_DEPRECATED_WARNINGS

GIT_COMMIT_HASH=$$system(git log -1 --format=%h)
Expand Down
20 changes: 12 additions & 8 deletions src/haloray-core/opengl/textureRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,32 @@ namespace OpenGL

std::unique_ptr<QOpenGLShaderProgram> TextureRenderer::initializeTexDrawShaderProgram()
{
qInfo("Initializing texture renderer vertex shader");
auto program = std::make_unique<QOpenGLShaderProgram>();
bool vertexShaderCompilationSucceeded = program->addCacheableShaderFromSourceFile(QOpenGLShader::ShaderTypeBit::Vertex, ":/shaders/renderer.vert");
bool vertexShaderReadSucceeded = program->addCacheableShaderFromSourceFile(QOpenGLShader::ShaderTypeBit::Vertex, ":/shaders/renderer.vert");

if (vertexShaderCompilationSucceeded == false)
if (vertexShaderReadSucceeded == false)
{
qWarning("Texture renderer vertex shader compilation failed");
qWarning("Texture renderer vertex shader read failed");
throw std::runtime_error(program->log().toUtf8());
}
qInfo("Texture renderer vertex shader successfully initialized");

bool fragmentShaderCompilationSucceeded = program->addCacheableShaderFromSourceFile(QOpenGLShader::ShaderTypeBit::Fragment, ":/shaders/renderer.frag");

if (fragmentShaderCompilationSucceeded == false)
qInfo("Initializing texture renderer fragment shader");
bool fragmentShaderReadSucceeded = program->addCacheableShaderFromSourceFile(QOpenGLShader::ShaderTypeBit::Fragment, ":/shaders/renderer.frag");
if (fragmentShaderReadSucceeded == false)
{
qWarning("Texture renderer fragment shader compilation failed");
qWarning("Texture renderer fragment shader read failed");
throw std::runtime_error(program->log().toUtf8());
}
qInfo("Texture renderer fragment shader successfully initialized");

if (program->link() == false)
{
qWarning("Texture renderer shader linking failed");
qWarning("Texture renderer shader compilation and linking failed");
throw std::runtime_error(program->log().toUtf8());
}
qInfo("Texture renderer shader program compilation and linking successful");

return program;
}
Expand Down
17 changes: 10 additions & 7 deletions src/haloray-core/resources/shaders/raytrace.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,11 @@ void initializeCrystal()
{
float deltaAngle = radians(60.0);
vec2 hexagonCorners[6];
/* The sqrt(3)/2 multiplier makes the default crystal such
that the distance of a vertex from the C axis is 1.0.
sqrt(3)/2 equals cos(30deg), which is faster to calculate
on GPU */
float sizeScaler = cos(radians(30.0));
for (int face = 0; face < 6; ++face)
{
int previousFace = face == 0 ? 5 : face - 1;
Expand All @@ -506,11 +511,9 @@ void initializeCrystal()
float currentAngle = previousAngle + deltaAngle;
float nextAngle = previousAngle + 2.0 * deltaAngle;

/* The sqrt(3)/2 multiplier makes the default crystal such
that the distance of a vertex from the C axis is 1.0 */
float previousDistance = 0.86602540378443864676372317075294 * crystalProperties.prismFaceDistances[previousFace];
float currentDistance = 0.86602540378443864676372317075294 * crystalProperties.prismFaceDistances[face];
float nextDistance = 0.86602540378443864676372317075294 * crystalProperties.prismFaceDistances[nextFace];
float previousDistance = sizeScaler * crystalProperties.prismFaceDistances[previousFace];
float currentDistance = sizeScaler * crystalProperties.prismFaceDistances[face];
float nextDistance = sizeScaler * crystalProperties.prismFaceDistances[nextFace];

vec2 previousLine = vec2(previousDistance, previousAngle);
vec2 currentLine = vec2(currentDistance, currentAngle);
Expand Down Expand Up @@ -564,8 +567,8 @@ void initializeCrystal()
}

// Scale pyramid caps
float upperApexMaxHeight = 1.0 / tan(crystalProperties.upperApexAngle / 2.0);
float lowerApexMaxHeight = 1.0 / tan(crystalProperties.lowerApexAngle / 2.0);
float upperApexMaxHeight = sizeScaler / tan(crystalProperties.upperApexAngle / 2.0);
float lowerApexMaxHeight = sizeScaler / tan(crystalProperties.lowerApexAngle / 2.0);

vec2 random = randn();
float upperApexHeight = clamp(crystalProperties.upperApexHeightAverage + crystalProperties.upperApexHeightStd * random.x, 0.0, 1.0);
Expand Down
23 changes: 15 additions & 8 deletions src/haloray-core/simulation/simulationEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,32 +261,39 @@ void SimulationEngine::initialize()

void SimulationEngine::initializeShaders()
{
qInfo("Initializing raytracing shader");
m_simulationShader = std::make_unique<QOpenGLShaderProgram>();
bool raytraceShaderCompilationSucceeded = m_simulationShader->addCacheableShaderFromSourceFile(QOpenGLShader::ShaderTypeBit::Compute, ":/shaders/raytrace.glsl");
if (raytraceShaderCompilationSucceeded == false)
bool raytraceShaderReadSucceeded = m_simulationShader->addCacheableShaderFromSourceFile(QOpenGLShader::ShaderTypeBit::Compute, ":/shaders/raytrace.glsl");
if (raytraceShaderReadSucceeded == false)
{
qWarning("Compiling raytracing shader failed");
qWarning("Reading raytracing shader failed");
throw std::runtime_error(m_simulationShader->log().toUtf8());
}
qInfo("Raytracing shader successfully initialized");

if (m_simulationShader->link() == false)
{
qWarning("Linking raytracing shader failed");
qWarning("Compiling and linking raytracing shader failed");
throw std::runtime_error(m_simulationShader->log().toUtf8());
}
qInfo("Raytracing shader program compilation and linking successful");

qInfo("Initializing sky shader");
m_skyShader = new QOpenGLShaderProgram(this);
bool skyShaderCompilationSucceeded = m_skyShader->addCacheableShaderFromSourceFile(QOpenGLShader::ShaderTypeBit::Compute, ":/shaders/sky.glsl");
if (skyShaderCompilationSucceeded == false)
bool skyShaderReadSucceeded = m_skyShader->addCacheableShaderFromSourceFile(QOpenGLShader::ShaderTypeBit::Compute, ":/shaders/sky.glsl");
if (skyShaderReadSucceeded == false)
{
qWarning("Compiling sky shader failed");
qWarning("Reading sky shader failed");
throw std::runtime_error(m_skyShader->log().toUtf8());
}
qInfo("Sky shader successfully initialized");

if (m_skyShader->link() == false)
{
qWarning("Linking sky shader failed");
qWarning("Compiling and linking sky shader failed");
throw std::runtime_error(m_skyShader->log().toUtf8());
}
qInfo("Sky shader program compilation and linking successful");
}

void SimulationEngine::initializeTextures()
Expand Down
11 changes: 10 additions & 1 deletion src/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,21 @@ int main(int argc, char *argv[])
HaloRay::MainWindow mainWindow;
mainWindow.showMaximized();

return app.exec();
qInfo("Starting event loop");
int returnCode = app.exec();
qInfo("Event loop exited with return code %i", returnCode);
return returnCode;
}
catch (const std::exception &e)
{
QMessageBox::critical(nullptr, QObject::tr("Exception thrown"), QString("An error occurred:\n%1").arg(e.what()));
qFatal("Caught exception: %s", e.what());
return 1;
}
catch (...)
{
QMessageBox::critical(nullptr, QObject::tr("Exception thrown"), QObject::tr("An unknown error occurred"));
qFatal("Caught non-standard exception");
return 2;
}
}
1 change: 1 addition & 0 deletions src/main/main.pro
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ QT += core gui widgets
CONFIG += c++17
win32:CONFIG += windows

DEFINES += QT_MESSAGELOGCONTEXT
DEFINES += QT_DEPRECATED_WARNINGS

GIT_COMMIT_HASH=$$system(git log -1 --format=%h)
Expand Down

0 comments on commit c4eab39

Please sign in to comment.