Fixed several minor memory race bugs
This commit is contained in:
parent
97b9992aa4
commit
192aa7604e
6 changed files with 18 additions and 10 deletions
2
Makefile
2
Makefile
|
@ -64,7 +64,7 @@ package:build
|
||||||
cp $(BUILDPATH)/basics/libpaysages_basics.so* paysages3d-linux/lib/
|
cp $(BUILDPATH)/basics/libpaysages_basics.so* paysages3d-linux/lib/
|
||||||
cp $(BUILDPATH)/definition/libpaysages_definition.so* paysages3d-linux/lib/
|
cp $(BUILDPATH)/definition/libpaysages_definition.so* paysages3d-linux/lib/
|
||||||
cp $(BUILDPATH)/render/software/libpaysages_render_software.so* paysages3d-linux/lib/
|
cp $(BUILDPATH)/render/software/libpaysages_render_software.so* paysages3d-linux/lib/
|
||||||
cp $(BUILDPATH)/render/preview/libpaysages_render_software.so* paysages3d-linux/lib/
|
cp $(BUILDPATH)/render/preview/libpaysages_render_preview.so* paysages3d-linux/lib/
|
||||||
cp $(BUILDPATH)/render/opengl/libpaysages_render_opengl.so* paysages3d-linux/lib/
|
cp $(BUILDPATH)/render/opengl/libpaysages_render_opengl.so* paysages3d-linux/lib/
|
||||||
cp $(BUILDPATH)/interface/desktop/paysages-gui paysages3d-linux/lib/
|
cp $(BUILDPATH)/interface/desktop/paysages-gui paysages3d-linux/lib/
|
||||||
chmod +x paysages3d-linux/lib/paysages-gui
|
chmod +x paysages3d-linux/lib/paysages-gui
|
||||||
|
|
|
@ -46,6 +46,7 @@ static inline double _getDistanceToBorder(BaseCloudsModel* model, Vector3 positi
|
||||||
static int _findSegments(BaseCloudsModel* model, SoftwareRenderer* renderer, Vector3 start, Vector3 direction, double, int max_segments, double max_inside_length, double max_total_length, double* inside_length, double* total_length, CloudSegment* out_segments)
|
static int _findSegments(BaseCloudsModel* model, SoftwareRenderer* renderer, Vector3 start, Vector3 direction, double, int max_segments, double max_inside_length, double max_total_length, double* inside_length, double* total_length, CloudSegment* out_segments)
|
||||||
{
|
{
|
||||||
CloudLayerDefinition* layer = model->getLayer();
|
CloudLayerDefinition* layer = model->getLayer();
|
||||||
|
double ymin, ymax;
|
||||||
int inside, segment_count;
|
int inside, segment_count;
|
||||||
double current_total_length, current_inside_length;
|
double current_total_length, current_inside_length;
|
||||||
double step_length, segment_length, remaining_length;
|
double step_length, segment_length, remaining_length;
|
||||||
|
@ -58,6 +59,8 @@ static int _findSegments(BaseCloudsModel* model, SoftwareRenderer* renderer, Vec
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model->getAltitudeRange(&ymin, &ymax);
|
||||||
|
|
||||||
render_precision = 15.2 - 1.5 * (double)renderer->render_quality;
|
render_precision = 15.2 - 1.5 * (double)renderer->render_quality;
|
||||||
render_precision = render_precision * layer->scaling / 50.0;
|
render_precision = render_precision * layer->scaling / 50.0;
|
||||||
if (render_precision > max_total_length / 10.0)
|
if (render_precision > max_total_length / 10.0)
|
||||||
|
@ -75,7 +78,7 @@ static int _findSegments(BaseCloudsModel* model, SoftwareRenderer* renderer, Vec
|
||||||
segment_length = 0.0;
|
segment_length = 0.0;
|
||||||
walker = start;
|
walker = start;
|
||||||
noise_distance = _getDistanceToBorder(model, start) * render_precision;
|
noise_distance = _getDistanceToBorder(model, start) * render_precision;
|
||||||
inside = (noise_distance > 0.0) ? 1 : 0;
|
inside = 0;
|
||||||
step = direction.scale(render_precision);
|
step = direction.scale(render_precision);
|
||||||
|
|
||||||
do
|
do
|
||||||
|
@ -132,7 +135,7 @@ static int _findSegments(BaseCloudsModel* model, SoftwareRenderer* renderer, Vec
|
||||||
step = direction.scale((noise_distance > -render_precision) ? render_precision : -noise_distance);
|
step = direction.scale((noise_distance > -render_precision) ? render_precision : -noise_distance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (inside || (walker.y >= layer->altitude - 0.001 && walker.y <= (layer->altitude + layer->scaling) + 0.001 && current_total_length < max_total_length && current_inside_length < max_inside_length));
|
} while (inside || (walker.y >= ymin - 0.001 && walker.y <= ymax + 0.001 && current_total_length < max_total_length && current_inside_length < max_inside_length));
|
||||||
|
|
||||||
*total_length = current_total_length;
|
*total_length = current_total_length;
|
||||||
*inside_length = current_inside_length;
|
*inside_length = current_inside_length;
|
||||||
|
@ -169,8 +172,8 @@ Color CloudBasicLayerRenderer::getColor(BaseCloudsModel *model, const Vector3 &e
|
||||||
SurfaceMaterial material;
|
SurfaceMaterial material;
|
||||||
material.base = colorToHSL(Color(0.7, 0.7, 0.7));
|
material.base = colorToHSL(Color(0.7, 0.7, 0.7));
|
||||||
material.hardness = 0.25;
|
material.hardness = 0.25;
|
||||||
material.reflection = 0.3;
|
material.reflection = 0.0;
|
||||||
material.shininess = 0.8;
|
material.shininess = 0.0;
|
||||||
materialValidate(&material);
|
materialValidate(&material);
|
||||||
|
|
||||||
col = parent->applyLightingToSurface(segments[i].start, parent->getAtmosphereRenderer()->getSunDirection(), material);
|
col = parent->applyLightingToSurface(segments[i].start, parent->getAtmosphereRenderer()->getSunDirection(), material);
|
||||||
|
|
|
@ -90,6 +90,7 @@ BaseCloudLayerRenderer* CloudsRenderer::getLayerRenderer(unsigned int layer)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
qWarning("Asked for unknown layer renderer %d", layer);
|
||||||
return fake_renderer;
|
return fake_renderer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,6 +103,7 @@ BaseCloudsModel* CloudsRenderer::getLayerModel(unsigned int layer)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
qWarning("Asked for unknown layer renderer %d", layer);
|
||||||
return fake_model;
|
return fake_model;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,7 +151,7 @@ bool CloudsRenderer::alterLight(LightComponent* light, const Vector3 &eye, const
|
||||||
BaseCloudLayerRenderer* layer_renderer = getLayerRenderer(i);
|
BaseCloudLayerRenderer* layer_renderer = getLayerRenderer(i);
|
||||||
BaseCloudsModel* layer_model = getLayerModel(i);
|
BaseCloudsModel* layer_model = getLayerModel(i);
|
||||||
|
|
||||||
altered = altered || layer_renderer->alterLight(layer_model, light, eye, location);
|
altered = layer_renderer->alterLight(layer_model, light, eye, location) || altered;
|
||||||
}
|
}
|
||||||
|
|
||||||
return altered;
|
return altered;
|
||||||
|
|
|
@ -208,7 +208,7 @@ static int _parallelJobCallback(ParallelQueue*, int, void* data, int stopping)
|
||||||
info->rasterizer->tessellateChunk(&info->chunk, info->chunk.detail_hint);
|
info->rasterizer->tessellateChunk(&info->chunk, info->chunk.detail_hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(data);
|
delete info;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ static int _parallelJobCallback(ParallelQueue*, int, void* data, int stopping)
|
||||||
_renderQuad(info->renderer, info->cx - info->radius_ext, info->cz + info->radius_int - info->chunk_size * info->i, info->chunk_size);
|
_renderQuad(info->renderer, info->cx - info->radius_ext, info->cz + info->radius_int - info->chunk_size * info->i, info->chunk_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(data);
|
delete info;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include "System.h"
|
#include "System.h"
|
||||||
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
static int core_count = -1;
|
static int core_count = -1;
|
||||||
|
|
||||||
|
@ -9,12 +8,16 @@ int System::getCoreCount()
|
||||||
{
|
{
|
||||||
if (core_count < 0)
|
if (core_count < 0)
|
||||||
{
|
{
|
||||||
|
#ifdef NDEBUG
|
||||||
core_count = QThread::idealThreadCount();
|
core_count = QThread::idealThreadCount();
|
||||||
if (core_count <= 0)
|
if (core_count <= 0)
|
||||||
{
|
{
|
||||||
qWarning() << "Can't find number of CPU cores, using only 1";
|
qWarning("Can't find number of CPU cores, using only 1");
|
||||||
core_count = 1;
|
core_count = 1;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
core_count = 1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return core_count;
|
return core_count;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue