paysages : Factorized layer management + started terrain canvas layers (WIP).

git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@383 b1fd45b6-86a6-48da-8261-f70d1f35bdcc
This commit is contained in:
Michaël Lemaire 2012-07-10 14:28:47 +00:00 committed by ThunderK
parent 4a7e1c6b45
commit daf3002297
17 changed files with 449 additions and 152 deletions

View file

@ -5,14 +5,6 @@
#include "color.h" #include "color.h"
#include "tools.h" #include "tools.h"
void atmosphereInit()
{
}
void atmosphereQuit()
{
}
void atmosphereSave(PackStream* stream, AtmosphereDefinition* definition) void atmosphereSave(PackStream* stream, AtmosphereDefinition* definition)
{ {
packWriteDouble(stream, &definition->distance_near); packWriteDouble(stream, &definition->distance_near);

View file

@ -19,8 +19,6 @@ typedef struct
Color color; Color color;
} AtmosphereDefinition; } AtmosphereDefinition;
void atmosphereInit();
void atmosphereQuit();
void atmosphereSave(PackStream* stream, AtmosphereDefinition* definition); void atmosphereSave(PackStream* stream, AtmosphereDefinition* definition);
void atmosphereLoad(PackStream* stream, AtmosphereDefinition* definition); void atmosphereLoad(PackStream* stream, AtmosphereDefinition* definition);

View file

@ -9,14 +9,6 @@
#include "scenery.h" #include "scenery.h"
#include "tools.h" #include "tools.h"
void cameraInit()
{
}
void cameraQuit()
{
}
void cameraSave(PackStream* stream, CameraDefinition* camera) void cameraSave(PackStream* stream, CameraDefinition* camera)
{ {
v3Save(stream, &camera->location); v3Save(stream, &camera->location);

View file

@ -9,8 +9,6 @@
extern "C" { extern "C" {
#endif #endif
void cameraInit();
void cameraQuit();
void cameraSave(PackStream* stream, CameraDefinition* camera); void cameraSave(PackStream* stream, CameraDefinition* camera);
void cameraLoad(PackStream* stream, CameraDefinition* camera); void cameraLoad(PackStream* stream, CameraDefinition* camera);

189
lib_paysages/layers.c Normal file
View file

@ -0,0 +1,189 @@
#include "layers.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#define LAYERS_MAX_NAME_LENGTH 50
typedef struct
{
void* definition;
char name[LAYERS_MAX_NAME_LENGTH + 1];
} LayerInfo;
struct Layers {
LayerType type;
int count;
int max_count;
void* null_layer;
LayerInfo* layers_info;
};
Layers* layersCreate(LayerType type, int max_layer_count)
{
Layers* result = malloc(sizeof(Layers));
result->type = type;
result->count = 0;
result->max_count = max_layer_count;
result->null_layer = type.callback_create();
result->layers_info = malloc(sizeof(LayerInfo) * max_layer_count);
return result;
}
void layersDelete(Layers* layers)
{
int i;
for (i = 0; i < layers->count; i++)
{
layers->type.callback_delete(layers->layers_info[i].definition);
}
free(layers->null_layer);
free(layers->layers_info);
free(layers);
}
void layersCopy(Layers* source, Layers* destination)
{
int i;
assert(source->type == destination->type);
assert(source->max_count == destination->max_count);
/* TODO Optimize by reusing common layers */
while (destination->count > 0)
{
layersDeleteLayer(destination, 0);
}
for (i = 0; i < source->count; i++)
{
layersAddLayer(destination, source->layers_info[i].definition);
layersSetName(destination, i, layersGetName(source, i));
}
}
void layersValidate(Layers* layers)
{
int i;
for (i = 0; i < layers->count; i++)
{
layers->type.callback_validate(layers->layers_info[i].definition);
layers->layers_info[i].name[LAYERS_MAX_NAME_LENGTH] = '\0';
}
}
void layersSave(PackStream* stream, Layers* layers)
{
int i;
packWriteInt(stream, &layers->count);
for (i = 0; i < layers->count; i++)
{
packWriteString(stream, layers->layers_info[i].name, LAYERS_MAX_NAME_LENGTH);
layers->type.callback_save(stream, layers->layers_info[i].definition);
}
}
void layersLoad(PackStream* stream, Layers* layers)
{
int i;
packReadInt(stream, &layers->count);
for (i = 0; i < layers->count; i++)
{
packReadString(stream, layers->layers_info[i].name, LAYERS_MAX_NAME_LENGTH);
layers->type.callback_load(stream, layers->layers_info[i].definition);
}
layersValidate(layers);
}
const char* layersGetName(Layers* layers, int layer)
{
if (layer >= 0 && layer < layers->count)
{
return layers->layers_info[layer].name;
}
else
{
return "";
}
}
void layersSetName(Layers* layers, int layer, const char* name)
{
if (layer >= 0 && layer < layers->count)
{
strncpy(layers->layers_info[layer].name, name, LAYERS_MAX_NAME_LENGTH);
}
}
int layersCount(Layers* layers)
{
return layers->count;
}
void* layersGetLayer(Layers* layers, int layer)
{
if (layer >= 0 && layer < layers->count)
{
return layers->layers_info[layer].definition;
}
else
{
return layers->null_layer;
}
}
int layersAddLayer(Layers* layers, void* definition)
{
if (layers->count < layers->max_count)
{
layers->layers_info[layers->count].definition = layers->type.callback_create();
if (definition)
{
layers->type.callback_copy(definition, layers->layers_info[layers->count].definition);
}
layers->count++;
layersSetName(layers, layers->count - 1, "unnamed");
}
else
{
return -1;
}
}
void layersDeleteLayer(Layers* layers, int layer)
{
if (layer >= 0 && layer < layers->count)
{
layers->type.callback_delete(layers->layers_info[layer].definition);
if (layers->count > 1 && layer < layers->count - 1)
{
memmove(layers->layers_info + layer, layers->layers_info + layer + 1, sizeof(LayerInfo) * (layers->count - layer - 1));
}
layers->count--;
}
}
void layersMove(Layers* layers, int layer, int new_position)
{
if (layer >= 0 && layer < layers->count && new_position != layer && new_position >= 0 && new_position < layers->count)
{
LayerInfo temp;
temp = layers->layers_info[layer];
if (new_position > layer)
{
memmove(layers->layers_info + layer, layers->layers_info + layer + 1, sizeof(LayerInfo) * (new_position - layer));
}
else
{
memmove(layers->layers_info + new_position + 1, layers->layers_info + new_position, sizeof(LayerInfo) * (layer - new_position));
}
layers->layers_info[new_position] = temp;
}
}

52
lib_paysages/layers.h Normal file
View file

@ -0,0 +1,52 @@
#ifndef _PAYSAGES_LAYERS_H_
#define _PAYSAGES_LAYERS_H_
/* Factorized layer management (with names) */
#include "pack.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef void* (*LayerCallbackCreate)();
typedef void (*LayerCallbackDelete)(void* layer);
typedef void (*LayerCallbackCopy)(void* source, void* definition);
typedef void (*LayerCallbackValidate)(void* layer);
typedef void (*LayerCallbackSave)(PackStream* stream, void* layer);
typedef void (*LayerCallbackLoad)(PackStream* stream, void* layer);
typedef struct {
LayerCallbackCreate callback_create;
LayerCallbackDelete callback_delete;
LayerCallbackCopy callback_copy;
LayerCallbackValidate callback_validate;
LayerCallbackSave callback_save;
LayerCallbackLoad callback_load;
} LayerType;
typedef struct Layers Layers;
Layers* layersCreate(LayerType type, int max_layer_count);
void layersDelete(Layers* layers);
void layersCopy(Layers* source, Layers* destination);
void layersValidate(Layers* layers);
void layersSave(PackStream* stream, Layers* layers);
void layersLoad(PackStream* stream, Layers* layers);
const char* layersGetName(Layers* layers, int layer);
void layersSetName(Layers* layers, int layer, const char* name);
int layersCount(Layers* layers);
void* layersGetLayer(Layers* layers, int layer);
int layersAddLayer(Layers* layers, void* definition);
void layersDeleteLayer(Layers* layers, int layer);
void layersMove(Layers* layers, int layer, int new_position);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -24,15 +24,9 @@ static void* _custom_data = NULL;
void sceneryInit() void sceneryInit()
{ {
noiseInit(); noiseInit();
atmosphereInit();
cameraInit();
cloudsInit(); cloudsInit();
lightingInit(); lightingInit();
skyInit();
terrainInit();
texturesInit(); texturesInit();
vegetationInit();
waterInit();
_atmosphere = atmosphereCreateDefinition(); _atmosphere = atmosphereCreateDefinition();
_camera = cameraCreateDefinition(); _camera = cameraCreateDefinition();
@ -60,15 +54,9 @@ void sceneryQuit()
vegetationDeleteDefinition(_vegetation); vegetationDeleteDefinition(_vegetation);
waterDeleteDefinition(&_water); waterDeleteDefinition(&_water);
atmosphereQuit();
cameraQuit();
cloudsQuit(); cloudsQuit();
lightingQuit(); lightingQuit();
skyQuit();
terrainQuit();
texturesQuit(); texturesQuit();
vegetationQuit();
waterQuit();
noiseQuit(); noiseQuit();
} }

View file

@ -16,14 +16,6 @@
#define SPHERE_SIZE 1000.0 #define SPHERE_SIZE 1000.0
/******************************** Configuration ********************************/ /******************************** Configuration ********************************/
void skyInit()
{
}
void skyQuit()
{
}
void skySave(PackStream* stream, SkyDefinition* definition) void skySave(PackStream* stream, SkyDefinition* definition)
{ {
packWriteInt(stream, (int*)&definition->model); packWriteInt(stream, (int*)&definition->model);

View file

@ -39,8 +39,6 @@ typedef struct
} model_preetham; } model_preetham;
} SkyDefinition; } SkyDefinition;
void skyInit();
void skyQuit();
void skySave(PackStream* stream, SkyDefinition* definition); void skySave(PackStream* stream, SkyDefinition* definition);
void skyLoad(PackStream* stream, SkyDefinition* definition); void skyLoad(PackStream* stream, SkyDefinition* definition);

View file

@ -11,54 +11,26 @@
#include "textures.h" #include "textures.h"
#include "water.h" #include "water.h"
#include "tools.h" #include "tools.h"
#include "layers.h"
void terrainInit() #include "terraincanvas.h"
{
}
void terrainQuit()
{
}
void terrainSave(PackStream* stream, TerrainDefinition* definition) void terrainSave(PackStream* stream, TerrainDefinition* definition)
{ {
int i;
noiseSaveGenerator(stream, definition->height_noise); noiseSaveGenerator(stream, definition->height_noise);
packWriteDouble(stream, &definition->height_factor); packWriteDouble(stream, &definition->height_factor);
packWriteDouble(stream, &definition->scaling); packWriteDouble(stream, &definition->scaling);
layersSave(stream, &definition->canvases);
packWriteDouble(stream, &definition->shadow_smoothing); packWriteDouble(stream, &definition->shadow_smoothing);
packWriteInt(stream, &definition->height_modifiers_count);
for (i = 0; i < definition->height_modifiers_count; i++)
{
modifierSave(stream, definition->height_modifiers[i]);
}
} }
void terrainLoad(PackStream* stream, TerrainDefinition* definition) void terrainLoad(PackStream* stream, TerrainDefinition* definition)
{ {
int i, n;
HeightModifier* modifier;
noiseLoadGenerator(stream, definition->height_noise); noiseLoadGenerator(stream, definition->height_noise);
packReadDouble(stream, &definition->height_factor); packReadDouble(stream, &definition->height_factor);
packReadDouble(stream, &definition->scaling); packReadDouble(stream, &definition->scaling);
layersLoad(stream, &definition->canvases);
packReadDouble(stream, &definition->shadow_smoothing); packReadDouble(stream, &definition->shadow_smoothing);
while (definition->height_modifiers_count > 0)
{
terrainDelModifier(definition, 0);
}
packReadInt(stream, &n);
for (i = 0; i < n; i++)
{
modifier = modifierCreate();
modifierLoad(stream, modifier);
terrainAddModifier(definition, modifier);
modifierDelete(modifier);
}
terrainValidateDefinition(definition); terrainValidateDefinition(definition);
} }
@ -69,7 +41,7 @@ TerrainDefinition terrainCreateDefinition()
definition.height_noise = noiseCreateGenerator(); definition.height_noise = noiseCreateGenerator();
definition.height_factor = 0.0; definition.height_factor = 0.0;
definition.scaling = 1.0; definition.scaling = 1.0;
definition.height_modifiers_count = 0; definition.canvases = layersCreate(terrainCanvasGetLayerType(), 50);
definition.shadow_smoothing = 0.0; definition.shadow_smoothing = 0.0;
terrainValidateDefinition(&definition); terrainValidateDefinition(&definition);
@ -82,10 +54,7 @@ void terrainDeleteDefinition(TerrainDefinition* definition)
int i; int i;
noiseDeleteGenerator(definition->height_noise); noiseDeleteGenerator(definition->height_noise);
for (i = 0; i < definition->height_modifiers_count; i++) layersDelete(definition->canvases);
{
modifierDelete(definition->height_modifiers[i]);
}
} }
void terrainCopyDefinition(TerrainDefinition* source, TerrainDefinition* destination) void terrainCopyDefinition(TerrainDefinition* source, TerrainDefinition* destination)
@ -95,52 +64,19 @@ void terrainCopyDefinition(TerrainDefinition* source, TerrainDefinition* destina
noiseCopy(source->height_noise, destination->height_noise); noiseCopy(source->height_noise, destination->height_noise);
destination->height_factor = source->height_factor; destination->height_factor = source->height_factor;
destination->scaling = source->scaling; destination->scaling = source->scaling;
layersCopy(source->canvases, destination->canvases);
destination->shadow_smoothing = source->shadow_smoothing; destination->shadow_smoothing = source->shadow_smoothing;
for (i = 0; i < destination->height_modifiers_count; i++)
{
modifierDelete(destination->height_modifiers[i]);
}
destination->height_modifiers_count = 0;
for (i = 0; i < source->height_modifiers_count; i++)
{
terrainAddModifier(destination, source->height_modifiers[i]);
}
terrainValidateDefinition(destination); terrainValidateDefinition(destination);
} }
void terrainValidateDefinition(TerrainDefinition* definition) void terrainValidateDefinition(TerrainDefinition* definition)
{ {
noiseValidate(definition->height_noise);
layersValidate(definition->canvases);
definition->_max_height = noiseGetMaxValue(definition->height_noise) * definition->height_factor; definition->_max_height = noiseGetMaxValue(definition->height_noise) * definition->height_factor;
/* FIXME _max_height depends on modifiers */ /* FIXME _max_height depends on canvases/modifiers */
}
int terrainAddModifier(TerrainDefinition* definition, HeightModifier* modifier)
{
if (definition->height_modifiers_count < TERRAIN_MAX_MODIFIERS)
{
definition->height_modifiers[definition->height_modifiers_count] = modifierCreateCopy(modifier);
return definition->height_modifiers_count++;
}
else
{
return -1;
}
}
void terrainDelModifier(TerrainDefinition* definition, int modifier_position)
{
if (modifier_position >= 0 && modifier_position < definition->height_modifiers_count)
{
modifierDelete(definition->height_modifiers[modifier_position]);
if (definition->height_modifiers_count > 1 && modifier_position < definition->height_modifiers_count - 1)
{
memmove(definition->height_modifiers + modifier_position, definition->height_modifiers + modifier_position + 1, sizeof(HeightModifier*) * (definition->height_modifiers_count - modifier_position - 1));
}
definition->height_modifiers_count--;
}
} }
static inline double _getHeight(TerrainDefinition* definition, double x, double z) static inline double _getHeight(TerrainDefinition* definition, double x, double z)
@ -152,10 +88,7 @@ static inline double _getHeight(TerrainDefinition* definition, double x, double
location.y = noiseGet2DTotal(definition->height_noise, x / definition->scaling, z / definition->scaling) * definition->height_factor; location.y = noiseGet2DTotal(definition->height_noise, x / definition->scaling, z / definition->scaling) * definition->height_factor;
location.z = z; location.z = z;
for (i = 0; i < definition->height_modifiers_count; i++) /* TODO Apply canvases and modifiers */
{
location = modifierApply(definition->height_modifiers[i], location);
}
return location.y; return location.y;
} }
@ -169,10 +102,7 @@ static inline double _getHeightDetail(TerrainDefinition* definition, double x, d
location.y = noiseGet2DDetail(definition->height_noise, x / definition->scaling, z / definition->scaling, detail / definition->height_factor) * definition->height_factor; location.y = noiseGet2DDetail(definition->height_noise, x / definition->scaling, z / definition->scaling, detail / definition->height_factor) * definition->height_factor;
location.z = z; location.z = z;
for (i = 0; i < definition->height_modifiers_count; i++) /* TODO Apply canvases and modifiers */
{
location = modifierApply(definition->height_modifiers[i], location);
}
return location.y; return location.y;
} }

View file

@ -6,6 +6,7 @@
#include "noise.h" #include "noise.h"
#include "lighting.h" #include "lighting.h"
#include "pack.h" #include "pack.h"
#include "layers.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -18,15 +19,12 @@ typedef struct
NoiseGenerator* height_noise; NoiseGenerator* height_noise;
double height_factor; double height_factor;
double scaling; double scaling;
int height_modifiers_count; Layers* canvases;
HeightModifier* height_modifiers[TERRAIN_MAX_MODIFIERS];
double shadow_smoothing; double shadow_smoothing;
double _max_height; double _max_height;
} TerrainDefinition; } TerrainDefinition;
void terrainInit();
void terrainQuit();
void terrainSave(PackStream* stream, TerrainDefinition* definition); void terrainSave(PackStream* stream, TerrainDefinition* definition);
void terrainLoad(PackStream* stream, TerrainDefinition* definition); void terrainLoad(PackStream* stream, TerrainDefinition* definition);
@ -35,9 +33,6 @@ void terrainDeleteDefinition(TerrainDefinition* definition);
void terrainCopyDefinition(TerrainDefinition* source, TerrainDefinition* destination); void terrainCopyDefinition(TerrainDefinition* source, TerrainDefinition* destination);
void terrainValidateDefinition(TerrainDefinition* definition); void terrainValidateDefinition(TerrainDefinition* definition);
int terrainAddModifier(TerrainDefinition* definition, HeightModifier* modifier);
void terrainDelModifier(TerrainDefinition* definition, int modifier_position);
Color terrainLightFilter(TerrainDefinition* definition, Renderer* renderer, Color light, Vector3 location, Vector3 light_location, Vector3 direction_to_light); Color terrainLightFilter(TerrainDefinition* definition, Renderer* renderer, Color light, Vector3 location, Vector3 light_location, Vector3 direction_to_light);
int terrainProjectRay(TerrainDefinition* definition, Renderer* renderer, Vector3 start, Vector3 direction, Vector3* hit_point, Color* hit_color); int terrainProjectRay(TerrainDefinition* definition, Renderer* renderer, Vector3 start, Vector3 direction, Vector3* hit_point, Color* hit_color);
double terrainGetHeight(TerrainDefinition* definition, double x, double z); double terrainGetHeight(TerrainDefinition* definition, double x, double z);

View file

@ -0,0 +1,130 @@
#include "terraincanvas.h"
#include <stdlib.h>
#include <string.h>
TerrainCanvas* terrainCanvasCreate()
{
TerrainCanvas* result = malloc(sizeof(TerrainCanvas));
result->area.bounded = 1;
result->area.location_x = 0.0;
result->area.location_z = 0.0;
result->area.size_x = 1.0;
result->area.size_z = 1.0;
result->offset_z = 0.0;
result->height_map.data = malloc(sizeof(double));
result->height_map.resolution_x = 1;
result->height_map.resolution_z = 1;
result->height_factor = 1.0;
result->detail_noise = noiseCreateGenerator();
result->detail_height_factor = 0.1;
result->detail_scaling = 1.0;
result->mask_mode = TERRAINCANVAS_MASKMODE_SQUARE;
result->mask_smoothing = 0.0;
return result;
}
void terrainCanvasDelete(TerrainCanvas* canvas)
{
free(canvas->height_map.data);
noiseDeleteGenerator(canvas->detail_noise);
free(canvas);
}
void terrainCanvasCopy(TerrainCanvas* source, TerrainCanvas* destination)
{
destination->area = source->area;
destination->offset_z = source->offset_z;
destination->height_map.resolution_x = source->height_map.resolution_x;
destination->height_map.resolution_z = source->height_map.resolution_z;
destination->height_map.data = realloc(destination->height_map.data, sizeof(double) * destination->height_map.resolution_x * destination->height_map.resolution_z);
memcpy(destination->height_map.data, source->height_map.data, sizeof(double) * destination->height_map.resolution_x * destination->height_map.resolution_z);
destination->height_factor = source->height_factor;
noiseCopy(source->detail_noise, destination->detail_noise);
destination->detail_height_factor = source->detail_height_factor;
destination->detail_scaling = source->detail_scaling;
destination->mask_mode = source->mask_mode;
destination->mask_smoothing = source->mask_smoothing;
}
void terrainCanvasValidate(TerrainCanvas* canvas)
{
if (canvas->detail_scaling < 0.00001)
{
canvas->detail_scaling = 0.00001;
}
noiseValidate(canvas->detail_noise);
}
LayerType terrainCanvasGetLayerType()
{
LayerType result;
result.callback_create = (LayerCallbackCreate)terrainCanvasCreate;
result.callback_delete = (LayerCallbackDelete)terrainCanvasDelete;
result.callback_copy = (LayerCallbackCopy)terrainCanvasCopy;
result.callback_validate = (LayerCallbackValidate)terrainCanvasValidate;
result.callback_save = (LayerCallbackSave)terrainCanvasSave;
result.callback_load = (LayerCallbackLoad)terrainCanvasLoad;
return result;
}
void terrainCanvasSave(PackStream* stream, TerrainCanvas* canvas)
{
int i;
packWriteInt(stream, &canvas->area.bounded);
packWriteDouble(stream, &canvas->area.location_x);
packWriteDouble(stream, &canvas->area.location_z);
packWriteDouble(stream, &canvas->area.size_x);
packWriteDouble(stream, &canvas->area.size_z);
packWriteDouble(stream, &canvas->offset_z);
packWriteInt(stream, &canvas->height_map.resolution_x);
packWriteInt(stream, &canvas->height_map.resolution_z);
for (i = 0; i < canvas->height_map.resolution_x * canvas->height_map.resolution_z; i++)
{
packWriteDouble(stream, &canvas->height_map.data[i]);
}
packWriteDouble(stream, &canvas->height_factor);
noiseSaveGenerator(stream, canvas->detail_noise);
packWriteDouble(stream, &canvas->detail_height_factor);
packWriteDouble(stream, &canvas->detail_scaling);
packWriteInt(stream, &canvas->mask_mode);
packWriteDouble(stream, &canvas->mask_smoothing);
}
void terrainCanvasLoad(PackStream* stream, TerrainCanvas* canvas)
{
int i;
packReadInt(stream, &canvas->area.bounded);
packReadDouble(stream, &canvas->area.location_x);
packReadDouble(stream, &canvas->area.location_z);
packReadDouble(stream, &canvas->area.size_x);
packReadDouble(stream, &canvas->area.size_z);
packReadDouble(stream, &canvas->offset_z);
packReadInt(stream, &canvas->height_map.resolution_x);
packReadInt(stream, &canvas->height_map.resolution_z);
canvas->height_map.data = realloc(canvas->height_map.data, sizeof(double) * canvas->height_map.resolution_x * canvas->height_map.resolution_z);
for (i = 0; i < canvas->height_map.resolution_x * canvas->height_map.resolution_z; i++)
{
packReadDouble(stream, &canvas->height_map.data[i]);
}
packReadDouble(stream, &canvas->height_factor);
noiseLoadGenerator(stream, canvas->detail_noise);
packReadDouble(stream, &canvas->detail_height_factor);
packReadDouble(stream, &canvas->detail_scaling);
packReadInt(stream, &canvas->mask_mode);
packReadDouble(stream, &canvas->mask_smoothing);
}
void terrainCanvasRevertToTerrain(TerrainCanvas* canvas, TerrainDefinition* terrain, int only_masked)
{
}
Vector3 terrainCanvasApply(TerrainCanvas* canvas, Vector3 position)
{
}

View file

@ -0,0 +1,63 @@
#ifndef _PAYSAGES_TERRAINCANVAS_H_
#define _PAYSAGES_TERRAINCANVAS_H_
/* Terrain edition by painting over an area */
#include "pack.h"
#include "noise.h"
#include "terrain.h"
#include "layers.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct
{
int bounded;
double location_x;
double location_z;
double size_x;
double size_z;
} GeoArea;
typedef struct
{
int resolution_x;
int resolution_z;
double* data;
} HeightMap;
#define TERRAINCANVAS_MASKMODE_SQUARE 0
#define TERRAINCANVAS_MASKMODE_CIRCLE 1
typedef struct
{
GeoArea area;
double offset_z;
HeightMap height_map;
double height_factor;
NoiseGenerator* detail_noise;
double detail_height_factor;
double detail_scaling;
int mask_mode;
double mask_smoothing;
} TerrainCanvas;
TerrainCanvas* terrainCanvasCreate();
void terrainCanvasDelete(TerrainCanvas* canvas);
void terrainCanvasCopy(TerrainCanvas* source, TerrainCanvas* destination);
void terrainCanvasValidate(TerrainCanvas* canvas);
LayerType terrainCanvasGetLayerType();
void terrainCanvasSave(PackStream* stream, TerrainCanvas* canvas);
void terrainCanvasLoad(PackStream* stream, TerrainCanvas* canvas);
void terrainCanvasRevertToTerrain(TerrainCanvas* canvas, TerrainDefinition* terrain, int only_masked);
Vector3 terrainCanvasApply(TerrainCanvas* canvas, Vector3 position);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -7,14 +7,6 @@ struct VegetationDefinition {
VegetationLayerDefinition layers[MAX_LAYER_COUNT]; VegetationLayerDefinition layers[MAX_LAYER_COUNT];
}; };
void vegetationInit()
{
}
void vegetationQuit()
{
}
void vegetationSave(PackStream* stream, VegetationDefinition* definition) void vegetationSave(PackStream* stream, VegetationDefinition* definition)
{ {
} }

View file

@ -18,8 +18,6 @@ typedef struct
typedef struct VegetationDefinition VegetationDefinition; typedef struct VegetationDefinition VegetationDefinition;
void vegetationInit();
void vegetationQuit();
void vegetationSave(PackStream* stream, VegetationDefinition* definition); void vegetationSave(PackStream* stream, VegetationDefinition* definition);
void vegetationLoad(PackStream* stream, VegetationDefinition* definition); void vegetationLoad(PackStream* stream, VegetationDefinition* definition);

View file

@ -10,14 +10,6 @@
#include <math.h> #include <math.h>
void waterInit()
{
}
void waterQuit()
{
}
void waterSave(PackStream* stream, WaterDefinition* definition) void waterSave(PackStream* stream, WaterDefinition* definition)
{ {
packWriteDouble(stream, &definition->height); packWriteDouble(stream, &definition->height);

View file

@ -34,8 +34,6 @@ typedef struct
Color final; Color final;
} WaterResult; } WaterResult;
void waterInit();
void waterQuit();
void waterSave(PackStream* stream, WaterDefinition* definition); void waterSave(PackStream* stream, WaterDefinition* definition);
void waterLoad(PackStream* stream, WaterDefinition* definition); void waterLoad(PackStream* stream, WaterDefinition* definition);