paysages : Small improvements.

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@474 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-12-08 14:12:02 +00:00 committed by ThunderK
parent 2756c41188
commit de719c62dd
5 changed files with 67 additions and 40 deletions

View file

@ -19,7 +19,7 @@ public:
PreviewSkyEast(QWidget* parent):
BasePreview(parent)
{
_renderer = rendererCreate();
_renderer = atmosphereCreatePreviewRenderer();
configScaling(0.5, 5.0, 0.5, 2.5);
}
@ -42,7 +42,7 @@ public:
PreviewSkyWest(QWidget* parent):
BasePreview(parent)
{
_renderer = rendererCreate();
_renderer = atmosphereCreatePreviewRenderer();
configScaling(0.5, 5.0, 0.5, 2.5);
}

View file

@ -2,6 +2,7 @@
#include "../renderer.h"
#include "../lighting.h"
#include "../terrain.h"
/*
* Atmosphere previews.
@ -15,8 +16,8 @@ typedef struct
#define MOUNTS_COUNT 11
static Mount MOUNTS[MOUNTS_COUNT] = {
{{2.0, 0.0, -4.0}, 4.0},
{{-1.0, 0.0, -6.0}, 4.0},
{{2.0, 0.0, -6.0}, 4.0},
{{-1.5, 0.0, -8.0}, 4.0},
{{3.0, 0.0, -10.0}, 6.0},
{{-8.0, 0.0, -15.0}, 6.0},
{{10.0, 0.0, -20.0}, 6.0},
@ -28,7 +29,7 @@ static Mount MOUNTS[MOUNTS_COUNT] = {
{{30.0, 0.0, -100.0}, 10.0},
};
static SurfaceMaterial MOUNT_MATERIAL = {{0.0, 0.0, 0.0, 1.0}, 0.0, 0.0};
static SurfaceMaterial MOUNT_MATERIAL = {{0.4, 0.4, 0.4, 1.0}, 0.0, 0.0};
static inline int _rayIntersectsTriangle(Vector3 p, Vector3 d, Vector3 v0, Vector3 v1, Vector3 v2, Vector3* hit)
{
@ -135,10 +136,8 @@ Color atmosphereGetPreview(Renderer* renderer, double x, double y, double headin
normal = m4Transform(rotation, normal);
hit = m4Transform(rotation, hit);
/* TODO Refactor lighting module for this to work */
renderer->getLightStatus(renderer, &light, hit);
color = renderer->applyLightStatus(renderer, &light, hit, normal, MOUNT_MATERIAL);
color = COLOR_BLACK;
return renderer->atmosphere->applyAerialPerspective(renderer, hit, color);
}
@ -149,3 +148,31 @@ Color atmosphereGetPreview(Renderer* renderer, double x, double y, double headin
return renderer->atmosphere->getSkyColor(renderer, direction);
}
}
static void _getLightStatus(Renderer* renderer, LightStatus* status, Vector3 location)
{
LightingDefinition def;
def = lightingCreateDefinition();
lightingGetStatus(&def, renderer, location, status);
lightingDeleteDefinition(&def);
}
static Color _applyLightStatus(Renderer* renderer, LightStatus* status, Vector3 location, Vector3 normal, SurfaceMaterial material)
{
return lightingApplyStatusToSurface(renderer, status, location, normal, material);
}
Renderer atmosphereCreatePreviewRenderer()
{
Renderer result = rendererCreate();
result.camera_location.x = 0.0;
result.camera_location.y = 8.0;
result.camera_location.z = 0.0;
result.getLightStatus = _getLightStatus;
result.applyLightStatus = _applyLightStatus;
return result;
}

View file

@ -75,6 +75,7 @@ extern StandardDefinition AtmosphereDefinitionClass;
extern StandardRenderer AtmosphereRendererClass;
void atmosphereRenderSkydome(Renderer* renderer);
Renderer atmosphereCreatePreviewRenderer();
Color atmosphereGetPreview(Renderer* renderer, double x, double y, double heading);
#ifdef __cplusplus

View file

@ -465,15 +465,14 @@ static int _findSegments(CloudsLayerDefinition* definition, Renderer* renderer,
return 0;
}
render_precision = 15.2 - 1.5 * (double)renderer->render_quality;
render_precision = render_precision * definition->shape_scaling / 150.0;
render_precision = 1.005 - 0.01 * (double)(renderer->render_quality * renderer->render_quality);
if (render_precision > max_total_length / 10.0)
{
render_precision = max_total_length / 10.0;
}
else if (render_precision < max_total_length / 2000.0)
else if (render_precision < max_total_length / 10000.0)
{
render_precision = max_total_length / 2000.0;
render_precision = max_total_length / 10000.0;
}
segment_count = 0;

View file

@ -48,7 +48,7 @@ void layersDelete(Layers* layers)
layers->type.callback_delete(layers->layers_info[i].definition);
}
free(layers->null_layer);
layers->type.callback_delete(layers->null_layer);
free(layers->layers_info);
free(layers);
}