paysages3d/src/rendering/clouds/clo_walking.h

120 lines
2.8 KiB
C
Raw Normal View History

#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.
*/
#ifdef __cplusplus
extern "C"
{
#endif
2013-05-26 18:28:44 +00:00
/**
* Information on a segment yielded by walking.
*/
typedef struct
{
2013-05-26 18:28:44 +00:00
Renderer* renderer;
CloudsLayerDefinition* layer;
double walked_distance;
Vector3 start;
Vector3 end;
double length;
2013-05-26 18:28:44 +00:00
int refined;
int subdivision_level;
double precision_asked;
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
/**
* 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);
/**
* Perform a single step.
*
* @param walker The walker to use
*/
void cloudsWalkerPerformStep(CloudsWalker* walker);
/**
* 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.
*
* @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
#ifdef __cplusplus
}
#endif
#endif