Working on clouds walking

This commit is contained in:
Michaël Lemaire 2013-05-25 15:20:11 +02:00 committed by Michael Lemaire
parent b7f64c6d79
commit 5e4b4e59a9
5 changed files with 79 additions and 17 deletions

View file

@ -0,0 +1,2 @@
#include "clo_lighting.h"

View file

@ -0,0 +1,30 @@
#ifndef _PAYSAGES_CLOUDS_LIGHTING_H_
#define _PAYSAGES_CLOUDS_LIGHTING_H_
#include "public.h"
#include "../tools/euclid.h"
/**
* Cloud lighting helpers.
*/
#ifdef __cplusplus
extern "C"
{
#endif
/*
* Bind fake lighting functions to a renderer.
*/
void cloudsBindFakeLightingToRenderer(CloudsRenderer* renderer);
/*
* Bind real lighting functions to a renderer.
*/
void cloudsBindRealLightingToRenderer(CloudsRenderer* renderer);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -136,8 +136,8 @@ int cloudsGetLayerPrimarySegments(Renderer* renderer, CloudsLayerDefinition* lay
/* exiting the cloud */
segment_length += step_length;
out_segments->enter = segment_start;
out_segments->exit = walker;
out_segments->entry_point = segment_start;
out_segments->exit_point = walker;
out_segments->length = segment_length;
out_segments++;
if (++segment_count >= max_segments)
@ -155,3 +155,7 @@ int cloudsGetLayerPrimarySegments(Renderer* renderer, CloudsLayerDefinition* lay
return segment_count;
}
int cloudsGetLayerSecondarySampling(Renderer* renderer, CloudsLayerDefinition* layer, CloudPrimarySegment* segment, int max_control_points, CloudSecondaryControlPoint* out_control_points)
{
}

View file

@ -5,7 +5,7 @@
#include "../tools/euclid.h"
/**
* Functions to walk through a cloud layer.
* Functions to walk through a cloud layer (sampling).
*/
#ifdef __cplusplus
@ -15,11 +15,25 @@ extern "C"
typedef struct
{
Vector3 enter;
Vector3 exit;
Vector3 entry_point;
Vector3 exit_point;
double length;
} CloudPrimarySegment;
typedef struct
{
/** Distance factor of the control point from the segment start */
double distance;
/** Location of the control point */
Vector3 location;
/** Global density at the control point (no edge noise applied) */
double global_density;
/** Particle dentisy at the control point, using edge noise */
double particle_density;
/** Estimated distance to nearest cloud exit */
double nearest_exit_distance;
} CloudSecondaryControlPoint;
/**
* Optimize the search limits in a layer.
*
@ -38,11 +52,23 @@ int cloudsOptimizeWalkingBounds(CloudsLayerDefinition* layer, Vector3* start, Ve
* @param start Start position of the lookup
* @param end End position of the lookup
* @param max_segments Maximum number of segments to collect
* @param out_segments Allocated space to fill found segments
* @param out_segments Allocated space to fill found segments (must be at least 'max_segments' long)
* @return Number of segments found
*/
int cloudsGetLayerPrimarySegments(Renderer* renderer, CloudsLayerDefinition* layer, Vector3 start, Vector3 end, int max_segments, CloudPrimarySegment* out_segments);
/**
* Sample a primary segment with refined details, collecting material interaction.
*
* @param renderer The renderer environment
* @param layer The cloud layer
* @param segment The primary segment to sample
* @param max_control_points Maximum number of control points to sample
* @param out_control_points Allocated space to fill with secondary control points (must be at least 'max_control_points' long)
* @return Number of control points sampled
*/
int cloudsGetLayerSecondarySampling(Renderer* renderer, CloudsLayerDefinition* layer, CloudPrimarySegment* segment, int max_control_points, CloudSecondaryControlPoint* out_control_points);
#ifdef __cplusplus
}
#endif

View file

@ -221,18 +221,18 @@ START_TEST(test_clouds_primary_segments)
ck_assert_int_eq(segment_count, 2);
for (i = 0; i < segment_count; i++)
{
ck_assert_double_eq(segments[i].enter.y, 0.0);
ck_assert_double_eq(segments[i].enter.z, 0.0);
ck_assert_double_eq(segments[i].exit.y, 0.0);
ck_assert_double_eq(segments[i].exit.z, 0.0);
ck_assert_double_eq(segments[i].entry_point.y, 0.0);
ck_assert_double_eq(segments[i].entry_point.z, 0.0);
ck_assert_double_eq(segments[i].exit_point.y, 0.0);
ck_assert_double_eq(segments[i].exit_point.z, 0.0);
}
ck_assert_double_in_range(segments[0].enter.x, -0.5, 0.0);
ck_assert_double_in_range(segments[0].exit.x, 0.5, 1.0);
ck_assert_double_in_range(segments[0].length, 0.5, 1.5);
ck_assert_double_gte(segments[1].enter.x, segments[0].exit.x);
ck_assert_double_in_range(segments[1].enter.x, 0.5, 1.0);
ck_assert_double_in_range(segments[1].exit.x, 1.5, 2.0);
ck_assert_double_in_range(segments[1].length, 0.5, 1.5);
ck_assert_double_in_range(segments[0].entry_point.x, -0.4, 0.0);
ck_assert_double_in_range(segments[0].exit_point.x, 0.5, 1.0);
ck_assert_double_in_range(segments[0].length, 0.5, 1.3);
ck_assert_double_gte(segments[1].entry_point.x, segments[0].exit_point.x);
ck_assert_double_in_range(segments[1].entry_point.x, 0.5, 1.0);
ck_assert_double_in_range(segments[1].exit_point.x, 1.5, 1.9);
ck_assert_double_in_range(segments[1].length, 0.5, 1.3);
cloudsGetLayerType().callback_delete(layer);
rendererDelete(renderer);