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;
|
2013-08-13 15:11:39 +00:00
|
|
|
double local_density;
|
2013-05-31 19:36:59 +00:00
|
|
|
} 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-06-01 14:57:23 +00:00
|
|
|
int refined;
|
2013-07-03 11:06:08 +00:00
|
|
|
int subdivided;
|
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
|
|
|
|
*/
|
2013-10-20 14:47:59 +00:00
|
|
|
RENDERINGSHARED_EXPORT int cloudsOptimizeWalkingBounds(CloudsLayerDefinition* layer, Vector3* start, Vector3* end);
|
2013-05-18 21:43:19 +00:00
|
|
|
|
|
|
|
/**
|
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
|
|
|
|
*/
|
2013-10-20 14:47:59 +00:00
|
|
|
RENDERINGSHARED_EXPORT CloudsWalker* cloudsCreateWalker(Renderer* renderer, CloudsLayerDefinition* layer, Vector3 start, Vector3 end);
|
2013-05-28 20:43:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete a cloud walker.
|
|
|
|
*
|
|
|
|
* @param walker The walker to free
|
|
|
|
*/
|
2013-10-20 14:47:59 +00:00
|
|
|
RENDERINGSHARED_EXPORT void cloudsDeleteWalker(CloudsWalker* walker);
|
2013-05-28 20:43:51 +00:00
|
|
|
|
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
|
|
|
|
*/
|
2013-10-20 14:47:59 +00:00
|
|
|
RENDERINGSHARED_EXPORT void cloudsWalkerSetStepSize(CloudsWalker* walker, double step);
|
2013-05-29 20:01:09 +00:00
|
|
|
|
2013-07-03 11:06:08 +00:00
|
|
|
/**
|
|
|
|
* Set the void skipping mode.
|
|
|
|
*
|
|
|
|
* @param walker The walker to configure
|
|
|
|
* @param enabled 1 to enable the void skipping, 0 to disable
|
|
|
|
*/
|
2013-10-20 14:47:59 +00:00
|
|
|
RENDERINGSHARED_EXPORT void cloudsWalkerSetVoidSkipping(CloudsWalker* walker, int enabled);
|
2013-07-03 11:06:08 +00:00
|
|
|
|
2013-08-13 15:11:39 +00:00
|
|
|
/**
|
|
|
|
* Toggle the local density computing.
|
|
|
|
*
|
|
|
|
* When this option is set, the CloudWalkerStepInfo will contain information about local density.
|
|
|
|
* The automatic setting will set to 1 on subdivided steps, and 0 elsewhere.
|
|
|
|
* @param walker The walker to configure
|
|
|
|
* @param enabled 1 to enable local density, 0 to disable it, -1 for automatic setting.
|
|
|
|
*/
|
2013-10-20 14:47:59 +00:00
|
|
|
RENDERINGSHARED_EXPORT void cloudsWalkerToggleLocalDensity(CloudsWalker* walker, int enabled);
|
2013-08-13 15:11:39 +00:00
|
|
|
|
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-10-20 14:47:59 +00:00
|
|
|
RENDERINGSHARED_EXPORT int cloudsWalkerPerformStep(CloudsWalker* walker);
|
2013-05-28 20:43:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Order the walker to stop.
|
|
|
|
*
|
|
|
|
* @param walker The walker to use
|
|
|
|
*/
|
2013-10-20 14:47:59 +00:00
|
|
|
RENDERINGSHARED_EXPORT void cloudsWalkerOrderStop(CloudsWalker* walker);
|
2013-05-28 20:43:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2013-10-20 14:47:59 +00:00
|
|
|
RENDERINGSHARED_EXPORT void cloudsWalkerOrderRefine(CloudsWalker* walker, double precision);
|
2013-05-28 20:43:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Order the walker to subdivide the previous segment in smaller segments.
|
|
|
|
*
|
2013-07-03 11:06:08 +00:00
|
|
|
* Next steps will yield subdivided segments. Once subdivided segments have been processed, normal walking
|
|
|
|
* will resume automatically.
|
2013-05-28 20:43:51 +00:00
|
|
|
* @param walker The walker to use
|
|
|
|
* @param max_segments Maximal number of segments
|
|
|
|
*/
|
2013-10-20 14:47:59 +00:00
|
|
|
RENDERINGSHARED_EXPORT void cloudsWalkerOrderSubdivide(CloudsWalker* walker, double max_segments);
|
2013-05-28 20:43:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the last segment information.
|
|
|
|
*
|
|
|
|
* @param walker The walker to use
|
|
|
|
*/
|
2013-10-20 14:47:59 +00:00
|
|
|
RENDERINGSHARED_EXPORT CloudWalkerStepInfo* cloudsWalkerGetLastSegment(CloudsWalker* walker);
|
2013-05-28 20:43:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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-10-20 14:47:59 +00:00
|
|
|
RENDERINGSHARED_EXPORT 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
|