2013-05-18 21:43:19 +00:00
|
|
|
#ifndef _PAYSAGES_CLOUDS_WALKING_H_
|
|
|
|
#define _PAYSAGES_CLOUDS_WALKING_H_
|
|
|
|
|
|
|
|
#include "public.h"
|
|
|
|
#include "../tools/euclid.h"
|
|
|
|
|
|
|
|
/**
|
2013-05-26 18:28:44 +00:00
|
|
|
* Functions to walk through a cloud layer.
|
2013-05-18 21:43:19 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
2013-05-31 19:36:59 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
double distance_from_start;
|
|
|
|
Vector3 location;
|
|
|
|
double global_density;
|
|
|
|
} CloudWalkerPoint;
|
|
|
|
|
2013-05-26 18:28:44 +00:00
|
|
|
/**
|
|
|
|
* Information on a segment yielded by walking.
|
|
|
|
*/
|
2013-05-18 21:43:19 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2013-05-26 18:28:44 +00:00
|
|
|
Renderer* renderer;
|
|
|
|
CloudsLayerDefinition* layer;
|
|
|
|
|
2013-05-31 19:36:59 +00:00
|
|
|
CloudWalkerPoint start;
|
|
|
|
CloudWalkerPoint end;
|
2013-05-18 21:43:19 +00:00
|
|
|
double length;
|
|
|
|
|
2013-05-29 20:01:09 +00:00
|
|
|
/*int refined;
|
2013-05-26 18:28:44 +00:00
|
|
|
int subdivision_level;
|
2013-05-29 20:01:09 +00:00
|
|
|
double precision_asked;*/
|
2013-05-26 18:28:44 +00:00
|
|
|
|
|
|
|
void* data;
|
2013-05-28 20:43:51 +00:00
|
|
|
} CloudWalkerStepInfo;
|
2013-05-26 18:28:44 +00:00
|
|
|
|
2013-05-28 20:43:51 +00:00
|
|
|
typedef struct CloudsWalker CloudsWalker;
|
2013-05-26 18:28:44 +00:00
|
|
|
|
2013-05-28 20:43:51 +00:00
|
|
|
typedef void (*FuncCloudsWalkingCallback)(CloudsWalker* walker);
|
2013-05-25 13:20:11 +00:00
|
|
|
|
2013-05-18 21:43:19 +00:00
|
|
|
/**
|
|
|
|
* Optimize the search limits in a layer.
|
|
|
|
*
|
|
|
|
* @param layer The cloud layer
|
|
|
|
* @param start Start of the search to optimize
|
|
|
|
* @param end End of the search to optimize
|
|
|
|
* @return 0 if the search is useless
|
|
|
|
*/
|
|
|
|
int cloudsOptimizeWalkingBounds(CloudsLayerDefinition* layer, Vector3* start, Vector3* end);
|
|
|
|
|
|
|
|
/**
|
2013-05-28 20:43:51 +00:00
|
|
|
* Create a cloud walker.
|
2013-05-25 13:20:11 +00:00
|
|
|
*
|
2013-05-26 18:28:44 +00:00
|
|
|
* For better performance, the segment should by optimized using cloudsOptimizeWalkingBounds.
|
2013-05-28 20:43:51 +00:00
|
|
|
* @param renderer Renderer context
|
|
|
|
* @param layer The cloud layer to traverse
|
|
|
|
* @param start Start of the walk
|
|
|
|
* @param end End of the walk
|
|
|
|
*/
|
|
|
|
CloudsWalker* cloudsCreateWalker(Renderer* renderer, CloudsLayerDefinition* layer, Vector3 start, Vector3 end);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete a cloud walker.
|
|
|
|
*
|
|
|
|
* @param walker The walker to free
|
|
|
|
*/
|
|
|
|
void cloudsDeleteWalker(CloudsWalker* walker);
|
|
|
|
|
2013-05-29 20:01:09 +00:00
|
|
|
/**
|
|
|
|
* Define the segment size for next steps.
|
|
|
|
*
|
|
|
|
* @param walker The walker to configure
|
|
|
|
* @param step The step length, negative for automatic
|
|
|
|
*/
|
|
|
|
void cloudsSetStepSize(CloudsWalker* walker, double step);
|
|
|
|
|
2013-05-28 20:43:51 +00:00
|
|
|
/**
|
|
|
|
* Perform a single step.
|
|
|
|
*
|
|
|
|
* @param walker The walker to use
|
2013-05-29 20:01:09 +00:00
|
|
|
* @return 1 to continue the loop, 0 to stop
|
2013-05-28 20:43:51 +00:00
|
|
|
*/
|
2013-05-29 20:01:09 +00:00
|
|
|
int cloudsWalkerPerformStep(CloudsWalker* walker);
|
2013-05-28 20:43:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Order the walker to stop.
|
|
|
|
*
|
|
|
|
* @param walker The walker to use
|
|
|
|
*/
|
|
|
|
void cloudsWalkerOrderStop(CloudsWalker* walker);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Order the walker to refine the search for cloud entry or exit.
|
|
|
|
*
|
2013-05-31 19:36:59 +00:00
|
|
|
* The refinement will next yield a shorter version of the segment, containing only the cloud-inside portion, with a
|
|
|
|
* tolerance fixed by precision. For an entry point, this will discard the part before cloud entry. For en exit point,
|
|
|
|
* the portion after this point will be part of the next step, as normal walking resumes.
|
2013-05-28 20:43:51 +00:00
|
|
|
* @param walker The walker to use
|
|
|
|
* @param precision Precision wanted for the refinement
|
|
|
|
*/
|
|
|
|
void cloudsWalkerOrderRefine(CloudsWalker* walker, double precision);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Order the walker to subdivide the previous segment in smaller segments.
|
|
|
|
*
|
|
|
|
* @param walker The walker to use
|
|
|
|
* @param max_segments Maximal number of segments
|
|
|
|
*/
|
|
|
|
void cloudsWalkerOrderSubdivide(CloudsWalker* walker, double max_segments);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the last segment information.
|
|
|
|
*
|
|
|
|
* @param walker The walker to use
|
|
|
|
*/
|
|
|
|
CloudWalkerStepInfo* cloudsWalkerGetLastSegment(CloudsWalker* walker);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Start walking automatically through a segment.
|
|
|
|
*
|
2013-05-26 18:28:44 +00:00
|
|
|
* The callback will be called with each segment found, giving info and asking for desired alteration on walking.
|
2013-05-28 20:43:51 +00:00
|
|
|
* @param walker The walker to use
|
2013-05-26 18:28:44 +00:00
|
|
|
* @param callback Callback to be called with each found segment
|
|
|
|
* @param data User data that will be passed back in the callback
|
2013-05-25 13:20:11 +00:00
|
|
|
*/
|
2013-05-28 20:43:51 +00:00
|
|
|
void cloudsStartWalking(CloudsWalker* walker, FuncCloudsWalkingCallback callback, void* data);
|
2013-05-25 13:20:11 +00:00
|
|
|
|
2013-05-18 21:43:19 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|