Removed old 'testing' directory
This commit is contained in:
parent
0627603f5a
commit
3652333b36
5 changed files with 0 additions and 465 deletions
|
@ -1,92 +0,0 @@
|
||||||
#ifndef _PAYSAGES_TESTING_COMMON_H_
|
|
||||||
#define _PAYSAGES_TESTING_COMMON_H_
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <check.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
extern int tests_cpu_count;
|
|
||||||
|
|
||||||
static inline void _add_methods_to_case(TCase* tc, ...)
|
|
||||||
{
|
|
||||||
void* method;
|
|
||||||
va_list argp;
|
|
||||||
|
|
||||||
va_start(argp, tc);
|
|
||||||
while ((method = va_arg(argp, void*)) != NULL)
|
|
||||||
{
|
|
||||||
tcase_add_test(tc, method);
|
|
||||||
}
|
|
||||||
va_end(argp);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define TEST_CASE(_name_,...) void test_ ## _name_ ## _case(Suite* s) { \
|
|
||||||
TCase *tc = tcase_create(#_name_); \
|
|
||||||
_add_methods_to_case(tc, __VA_ARGS__, NULL); \
|
|
||||||
suite_add_tcase(s, tc); \
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Boolean assertions *****/
|
|
||||||
#define ck_assert_true(_X_) ck_assert_int_ne((_X_), 0)
|
|
||||||
#define ck_assert_false(_X_) ck_assert_int_eq((_X_), 0)
|
|
||||||
|
|
||||||
/***** Floating point assertions *****/
|
|
||||||
static inline int _double_equals(double x, double y)
|
|
||||||
{
|
|
||||||
return fabs(x - y) < 0.00000000001;
|
|
||||||
}
|
|
||||||
static inline int _double_not_equals(double x, double y)
|
|
||||||
{
|
|
||||||
return fabs(x - y) >= 0.00000000001;
|
|
||||||
}
|
|
||||||
static inline int _double_greater(double x, double y)
|
|
||||||
{
|
|
||||||
return _double_not_equals(x, y) && (x > y);
|
|
||||||
}
|
|
||||||
static inline int _double_greater_or_equal(double x, double y)
|
|
||||||
{
|
|
||||||
return _double_equals(x, y) || (x >= y);
|
|
||||||
}
|
|
||||||
static inline int _double_less(double x, double y)
|
|
||||||
{
|
|
||||||
return _double_not_equals(x, y) && (x < y);
|
|
||||||
}
|
|
||||||
static inline int _double_less_or_equal(double x, double y)
|
|
||||||
{
|
|
||||||
return _double_equals(x, y) || (x <= y);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define _ck_assert_double(F, X, O, Y) ck_assert_msg(F(X, Y), "Assertion '"#X#O#Y"' failed: "#X"=%.12f, "#Y"=%.12f", X, Y)
|
|
||||||
#define ck_assert_double_eq(X, Y) _ck_assert_double(_double_equals, X, ==, Y)
|
|
||||||
#define ck_assert_double_ne(X, Y) _ck_assert_double(_double_not_equals, X, !=, Y)
|
|
||||||
#define ck_assert_double_gt(X, Y) _ck_assert_double(_double_greater, X, >, Y)
|
|
||||||
#define ck_assert_double_lt(X, Y) _ck_assert_double(_double_less, X, <, Y)
|
|
||||||
#define ck_assert_double_gte(X, Y) _ck_assert_double(_double_greater_or_equal, X, >=, Y)
|
|
||||||
#define ck_assert_double_lte(X, Y) _ck_assert_double(_double_less_or_equal, X, <=, Y)
|
|
||||||
|
|
||||||
|
|
||||||
/***** Generic comparison assertions *****/
|
|
||||||
#define DEFINE_COMPARE_ASSERT(_type_, _cmpfunc_, _strfunc_) \
|
|
||||||
static inline int _ck_gen_##_type_##_cmp(_type_ X, _type_ Y) { \
|
|
||||||
return _cmpfunc_(X, Y); \
|
|
||||||
} \
|
|
||||||
static inline char* _ck_gen_##_type_##_str(char* buffer, _type_ X) { \
|
|
||||||
_strfunc_(X, buffer, 99); \
|
|
||||||
buffer[100] = '\0'; \
|
|
||||||
return buffer; \
|
|
||||||
}
|
|
||||||
#define ck_assert_generic_eq(_type_, X, Y) ck_assert_msg(_ck_gen_##_type_##_cmp(X, Y) == 0, "Assertion '"#X"=="#Y"' failed : "#X"=%s, "#Y"=%s", _ck_gen_##_type_##_str(_ck_gen_strbuf1, X), _ck_gen_##_type_##_str(_ck_gen_strbuf2, Y))
|
|
||||||
|
|
||||||
static char _ck_gen_strbuf1[101];
|
|
||||||
static char _ck_gen_strbuf2[101];
|
|
||||||
|
|
||||||
|
|
||||||
/***** Some builtin comparisons *****/
|
|
||||||
#define ck_assert_double_in_range(_double_, _x_, _y_) ck_assert_double_gte(_double_, _x_);ck_assert_double_lte(_double_, _y_)
|
|
||||||
#define ck_assert_vector_values(_vector_, _x_, _y_, _z_) ck_assert_double_eq(_vector_.x, _x_);ck_assert_double_eq(_vector_.y, _y_);ck_assert_double_eq(_vector_.z, _z_)
|
|
||||||
#define ck_assert_color_values(_color_, _r_, _g_, _b_, _a_) ck_assert_double_eq(_color_.r, _r_);ck_assert_double_eq(_color_.g, _g_);ck_assert_double_eq(_color_.b, _b_);ck_assert_double_eq(_color_.a, _a_)
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,34 +0,0 @@
|
||||||
#include <check.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "rendering/main.h"
|
|
||||||
#include "System.h"
|
|
||||||
|
|
||||||
int tests_cpu_count;
|
|
||||||
extern void test_render_case(Suite* s);
|
|
||||||
extern void test_terrain_painting_case(Suite* s);
|
|
||||||
extern void test_zone_case(Suite* s);
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
int number_failed;
|
|
||||||
Suite *s = suite_create("rendering");
|
|
||||||
|
|
||||||
paysagesInit();
|
|
||||||
|
|
||||||
tests_cpu_count = systemGetCoreCount();
|
|
||||||
|
|
||||||
/* TODO Find a way to automate this */
|
|
||||||
test_render_case(s);
|
|
||||||
test_terrain_painting_case(s);
|
|
||||||
test_zone_case(s);
|
|
||||||
|
|
||||||
SRunner *sr = srunner_create(s);
|
|
||||||
srunner_run_all(sr, CK_NORMAL);
|
|
||||||
number_failed = srunner_ntests_failed(sr);
|
|
||||||
srunner_free(sr);
|
|
||||||
|
|
||||||
paysagesQuit();
|
|
||||||
|
|
||||||
return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
||||||
}
|
|
|
@ -1,237 +0,0 @@
|
||||||
#include "testing/common.h"
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
#include "rendering/tools.h"
|
|
||||||
#include "rendering/terrain/public.h"
|
|
||||||
|
|
||||||
/* Noise sin period is defined at 20.0 */
|
|
||||||
#define X_FACTOR (M_PI / 10.0)
|
|
||||||
|
|
||||||
static double _noise1dMock(double x)
|
|
||||||
{
|
|
||||||
return sin(x * X_FACTOR) * 0.5 + 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
static double _noise2dMock(double x, double y)
|
|
||||||
{
|
|
||||||
UNUSED(y);
|
|
||||||
return sin(x * X_FACTOR) * 0.5 + 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
static double _noise3dMock(double x, double y, double z)
|
|
||||||
{
|
|
||||||
UNUSED(y);
|
|
||||||
UNUSED(z);
|
|
||||||
return sin(x * X_FACTOR) * 0.5 + 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
static TerrainDefinition* _setUpDefinition()
|
|
||||||
{
|
|
||||||
TerrainDefinition* terrain = (TerrainDefinition*)TerrainDefinitionClass.create();
|
|
||||||
terrain->height = 3.0;
|
|
||||||
terrain->scaling = 1.0;
|
|
||||||
noiseClearLevels(terrain->_height_noise);
|
|
||||||
NoiseLevel level = {1.0, 2.0, -1.0, 0.0, 0.0, 0.0};
|
|
||||||
noiseAddLevel(terrain->_height_noise, level, 0);
|
|
||||||
noiseSetCustomFunction(terrain->_height_noise, _noise1dMock, _noise2dMock, _noise3dMock);
|
|
||||||
return terrain;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _tearDownDefinition(TerrainDefinition* terrain)
|
|
||||||
{
|
|
||||||
TerrainDefinitionClass.destroy(terrain);
|
|
||||||
}
|
|
||||||
|
|
||||||
START_TEST(test_terrain_painting_grid)
|
|
||||||
{
|
|
||||||
/* Set up */
|
|
||||||
TerrainDefinition* terrain = _setUpDefinition();
|
|
||||||
|
|
||||||
/* Test base grid */
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, 0, 0, 0), 0.0);
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, 0, 1, 0), 0.0);
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, 0, 0, 1), 0.0);
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, 1, 0, 0), sin(1.0 * X_FACTOR));
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, 2, 0, 0), sin(2.0 * X_FACTOR));
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, 3, 0, 0), sin(3.0 * X_FACTOR));
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, 4, 0, 0), sin(4.0 * X_FACTOR));
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, 5, 0, 0), 1.0);
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, 6, 0, 0), sin(4.0 * X_FACTOR));
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, -1, 0, 0), -sin(1.0 * X_FACTOR));
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, 10, 0, 0), 0.0);
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, 15, 0, 0), -1.0);
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, 20, 0, 0), 0.0);
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, -5, 0, 0), -1.0);
|
|
||||||
|
|
||||||
/* Test interpolated result */
|
|
||||||
ck_assert_double_eq(terrainGetInterpolatedHeight(terrain, 0.0, 0.0, 0, 0), 0.0);
|
|
||||||
ck_assert_double_in_range(terrainGetInterpolatedHeight(terrain, 0.5, 0.0, 0, 0), 0.1564, 0.1566);
|
|
||||||
ck_assert_double_eq(terrainGetInterpolatedHeight(terrain, 1.0, 0.0, 0, 0), sin(1.0 * X_FACTOR));
|
|
||||||
ck_assert_double_eq(terrainGetInterpolatedHeight(terrain, 0.0, 0.0, 1, 0), 0.0);
|
|
||||||
ck_assert_double_in_range(terrainGetInterpolatedHeight(terrain, 0.5, 0.0, 1, 0), 3.0 * 0.1564, 3.0 * 0.1566);
|
|
||||||
ck_assert_double_eq(terrainGetInterpolatedHeight(terrain, 1.0, 0.0, 1, 0), 3.0 * sin(1.0 * X_FACTOR));
|
|
||||||
|
|
||||||
/* Test scaling */
|
|
||||||
terrain->scaling = 2.0;
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, 0, 0, 0), 0.0);
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, 1, 0, 0), sin(1.0 * X_FACTOR));
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, 2, 0, 0), sin(2.0 * X_FACTOR));
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, 3, 0, 0), sin(3.0 * X_FACTOR));
|
|
||||||
ck_assert_double_eq(terrainGetInterpolatedHeight(terrain, 0, 0, 0, 0), 0.0);
|
|
||||||
ck_assert_double_eq(terrainGetInterpolatedHeight(terrain, 1, 0, 0, 0), sin(0.5 * X_FACTOR));
|
|
||||||
ck_assert_double_eq(terrainGetInterpolatedHeight(terrain, 2, 0, 0, 0), sin(1.0 * X_FACTOR));
|
|
||||||
ck_assert_double_eq(terrainGetInterpolatedHeight(terrain, 3, 0, 0, 0), sin(1.5 * X_FACTOR));
|
|
||||||
ck_assert_double_eq(terrainGetInterpolatedHeight(terrain, 0, 0, 1, 0), 0.0);
|
|
||||||
ck_assert_double_eq(terrainGetInterpolatedHeight(terrain, 1, 0, 1, 0), 6.0 * sin(0.5 * X_FACTOR));
|
|
||||||
ck_assert_double_eq(terrainGetInterpolatedHeight(terrain, 2, 0, 1, 0), 6.0 * sin(1.0 * X_FACTOR));
|
|
||||||
ck_assert_double_eq(terrainGetInterpolatedHeight(terrain, 3, 0, 1, 0), 6.0 * sin(1.5 * X_FACTOR));
|
|
||||||
|
|
||||||
/* Tear down */
|
|
||||||
_tearDownDefinition(terrain);
|
|
||||||
}
|
|
||||||
END_TEST
|
|
||||||
|
|
||||||
static void _checkBrushResultSides(TerrainDefinition* terrain, TerrainBrush* brush, double center, double midhard, double hard, double midsoft, double soft, double exter, double neg_midhard, double neg_hard, double neg_midsoft, double neg_soft, double neg_exter)
|
|
||||||
{
|
|
||||||
UNUSED(brush);
|
|
||||||
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, 0, 0, 1), center);
|
|
||||||
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, 1, 0, 1), midhard);
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, 2, 0, 1), hard);
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, 3, 0, 1), midsoft);
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, 4, 0, 1), soft);
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, 5, 0, 1), exter);
|
|
||||||
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, -1, 0, 1), neg_midhard);
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, -2, 0, 1), neg_hard);
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, -3, 0, 1), neg_midsoft);
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, -4, 0, 1), neg_soft);
|
|
||||||
ck_assert_double_eq(terrainGetGridHeight(terrain, -5, 0, 1), neg_exter);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _checkBrushResult(TerrainDefinition* terrain, TerrainBrush* brush, double center, double midhard, double hard, double midsoft, double soft, double exter, int mirror)
|
|
||||||
{
|
|
||||||
if (mirror)
|
|
||||||
{
|
|
||||||
_checkBrushResultSides(terrain, brush, center, midhard, hard, midsoft, soft, exter, -midhard, -hard, -midsoft, -soft, -exter);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_checkBrushResultSides(terrain, brush, center, midhard, hard, midsoft, soft, exter, midhard, hard, midsoft, soft, exter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
START_TEST(test_terrain_painting_brush_flatten)
|
|
||||||
{
|
|
||||||
/* Set up */
|
|
||||||
TerrainDefinition* terrain = _setUpDefinition();
|
|
||||||
TerrainBrush brush = {0.0, 0.0, 2.0, 2.0, 4.0};
|
|
||||||
terrain->height = 1.0;
|
|
||||||
terrain->scaling = 1.0;
|
|
||||||
noiseForceValue(terrain->_height_noise, 0.0);
|
|
||||||
|
|
||||||
/* Test flattening center at 0.5 */
|
|
||||||
_checkBrushResult(terrain, &brush, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0);
|
|
||||||
terrainBrushFlatten(terrain->height_map, &brush, 0.5, 1.0);
|
|
||||||
_checkBrushResult(terrain, &brush, 0.5, 0.5, 0.5, 0.25, 0.0, 0.0, 0);
|
|
||||||
|
|
||||||
/* Test brush strength */
|
|
||||||
terrainClearPainting(terrain->height_map);
|
|
||||||
_checkBrushResult(terrain, &brush, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0);
|
|
||||||
terrainBrushFlatten(terrain->height_map, &brush, 0.5, 0.01);
|
|
||||||
_checkBrushResult(terrain, &brush, 0.005, 0.005, 0.005, 0.0025, 0.0, 0.0, 0);
|
|
||||||
|
|
||||||
/* Test cumulative effect */
|
|
||||||
terrainBrushFlatten(terrain->height_map, &brush, 0.5, 0.01);
|
|
||||||
_checkBrushResult(terrain, &brush, 0.00995, 0.00995, 0.00995, 0.0049875, 0.0, 0.0, 0);
|
|
||||||
|
|
||||||
/* Test with height modifier */
|
|
||||||
terrain->height = 10.0;
|
|
||||||
terrainClearPainting(terrain->height_map);
|
|
||||||
_checkBrushResult(terrain, &brush, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0);
|
|
||||||
terrainBrushFlatten(terrain->height_map, &brush, 0.5, 1.0);
|
|
||||||
_checkBrushResult(terrain, &brush, 0.05, 0.05, 0.05, 0.025, 0.0, 0.0, 0);
|
|
||||||
|
|
||||||
/* Test with scaling modifier */
|
|
||||||
terrain->height = 10.0;
|
|
||||||
terrain->scaling = 2.0;
|
|
||||||
terrainClearPainting(terrain->height_map);
|
|
||||||
_checkBrushResult(terrain, &brush, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0);
|
|
||||||
terrainBrushFlatten(terrain->height_map, &brush, 0.5, 1.0);
|
|
||||||
_checkBrushResult(terrain, &brush, 0.05, 0.05, 0.05, 0.025, 0.0, 0.0, 0);
|
|
||||||
|
|
||||||
/* Tear down */
|
|
||||||
_tearDownDefinition(terrain);
|
|
||||||
}
|
|
||||||
END_TEST
|
|
||||||
|
|
||||||
START_TEST(test_terrain_painting_brush_reset)
|
|
||||||
{
|
|
||||||
/* Set up */
|
|
||||||
TerrainDefinition* terrain = _setUpDefinition();
|
|
||||||
TerrainBrush brush = {0.0, 0.0, 2.0, 2.0, 4.0};
|
|
||||||
TerrainBrush brush_full = {0.0, 0.0, 4.0, 0.0, 4.0};
|
|
||||||
terrain->height = 1.0;
|
|
||||||
terrain->scaling = 1.0;
|
|
||||||
noiseForceValue(terrain->_height_noise, 1.0);
|
|
||||||
|
|
||||||
/* Test resetting at center */
|
|
||||||
_checkBrushResult(terrain, &brush, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0);
|
|
||||||
terrainBrushFlatten(terrain->height_map, &brush_full, 2.0, 1.0);
|
|
||||||
_checkBrushResult(terrain, &brush, 2.0, 2.0, 2.0, 2.0, 2.0, 1.0, 0);
|
|
||||||
terrainBrushReset(terrain->height_map, &brush, 1.0);
|
|
||||||
_checkBrushResult(terrain, &brush, 1.0, 1.0, 1.0, 1.5, 2.0, 1.0, 0);
|
|
||||||
|
|
||||||
/* Test brush strength */
|
|
||||||
terrainClearPainting(terrain->height_map);
|
|
||||||
_checkBrushResult(terrain, &brush, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0);
|
|
||||||
terrainBrushFlatten(terrain->height_map, &brush_full, 2.0, 1.0);
|
|
||||||
_checkBrushResult(terrain, &brush, 2.0, 2.0, 2.0, 2.0, 2.0, 1.0, 0);
|
|
||||||
terrainBrushReset(terrain->height_map, &brush, 0.1);
|
|
||||||
_checkBrushResult(terrain, &brush, 1.9, 1.9, 1.9, 1.95, 2.0, 1.0, 0);
|
|
||||||
|
|
||||||
/* Test cumulative effect */
|
|
||||||
terrainBrushReset(terrain->height_map, &brush, 0.1);
|
|
||||||
_checkBrushResult(terrain, &brush, 1.81, 1.81, 1.81, 1.9025, 2.0, 1.0, 0);
|
|
||||||
|
|
||||||
/* Test with height modifier */
|
|
||||||
terrain->height = 10.0;
|
|
||||||
terrainClearPainting(terrain->height_map);
|
|
||||||
_checkBrushResult(terrain, &brush, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0);
|
|
||||||
terrainBrushFlatten(terrain->height_map, &brush_full, 2.0, 1.0);
|
|
||||||
_checkBrushResult(terrain, &brush, 1.1, 1.1, 1.1, 1.1, 1.1, 1.0, 0);
|
|
||||||
terrainBrushReset(terrain->height_map, &brush, 0.1);
|
|
||||||
_checkBrushResult(terrain, &brush, 1.099, 1.099, 1.099, 1.0995, 1.1, 1.0, 0);
|
|
||||||
|
|
||||||
/* Test with scaling modifier */
|
|
||||||
terrain->height = 10.0;
|
|
||||||
terrain->scaling = 2.0;
|
|
||||||
terrainClearPainting(terrain->height_map);
|
|
||||||
_checkBrushResult(terrain, &brush, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0);
|
|
||||||
terrainBrushFlatten(terrain->height_map, &brush_full, 2.0, 1.0);
|
|
||||||
_checkBrushResult(terrain, &brush, 1.1, 1.1, 1.1, 1.1, 1.1, 1.0, 0);
|
|
||||||
terrainBrushReset(terrain->height_map, &brush, 0.1);
|
|
||||||
_checkBrushResult(terrain, &brush, 1.099, 1.099, 1.099, 1.0995, 1.1, 1.0, 0);
|
|
||||||
|
|
||||||
/* Tear down */
|
|
||||||
_tearDownDefinition(terrain);
|
|
||||||
|
|
||||||
/* Test with scaling and the sinusoid setup (to test the basevalue sampling) */
|
|
||||||
terrain = _setUpDefinition();
|
|
||||||
terrain->height = 1.0;
|
|
||||||
terrain->scaling = 2.0;
|
|
||||||
_checkBrushResult(terrain, &brush, 0.0, 0.309016994375, 0.587785252292, 0.809016994375, 0.951056516295, 1.0, 1);
|
|
||||||
terrainBrushFlatten(terrain->height_map, &brush_full, 2.0, 1.0);
|
|
||||||
_checkBrushResultSides(terrain, &brush, 2.0, 2.0, 2.0, 2.0, 2.0, 1.0, 2.0, 2.0, 2.0, 2.0, -1.0);
|
|
||||||
terrainBrushReset(terrain->height_map, &brush, 1.0);
|
|
||||||
_checkBrushResultSides(terrain, &brush, 0.0, 0.309016994375, 0.587785252292, 2.0 - (2.0 - 0.809016994375) * 0.5, 2.0, 1.0, -0.309016994375, -0.587785252292, 2.0 - (2.0 + 0.809016994375) * 0.5, 2.0, -1.0);
|
|
||||||
_tearDownDefinition(terrain);
|
|
||||||
}
|
|
||||||
END_TEST
|
|
||||||
|
|
||||||
TEST_CASE(terrain_painting,
|
|
||||||
test_terrain_painting_grid,
|
|
||||||
test_terrain_painting_brush_flatten,
|
|
||||||
test_terrain_painting_brush_reset)
|
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
#include "testing/common.h"
|
|
||||||
|
|
||||||
#include "rendering/tools/zone.h"
|
|
||||||
|
|
||||||
START_TEST(testZoneAbsoluteHeight)
|
|
||||||
{
|
|
||||||
Zone* zone = zoneCreate();
|
|
||||||
|
|
||||||
zoneAddHeightRangeQuick(zone, 1.0, -1.0, 2.0, 5.0, 6.0);
|
|
||||||
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, -10.0, 0.0), VECTOR_UP), 0.0);
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, -2.0, 0.0), VECTOR_UP), 0.0);
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, -1.0, 0.0), VECTOR_UP), 0.0);
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, -0.5, 0.0), VECTOR_UP), 1.0 / 6.0);
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, 0.0, 0.0), VECTOR_UP), 1.0 / 3.0);
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, 0.5, 0.0), VECTOR_UP), 0.5);
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, 2.0, 0.0), VECTOR_UP), 1.0);
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, 2.1, 0.0), VECTOR_UP), 1.0);
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, 3.5, 0.0), VECTOR_UP), 1.0);
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, 4.9, 0.0), VECTOR_UP), 1.0);
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, 5.0, 0.0), VECTOR_UP), 1.0);
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, 5.2, 0.0), VECTOR_UP), 0.8);
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, 5.7, 0.0), VECTOR_UP), 0.3);
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, 6.0, 0.0), VECTOR_UP), 0.0);
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, 15.0, 0.0), VECTOR_UP), 0.0);
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, 150.0, 0.0), VECTOR_UP), 0.0);
|
|
||||||
|
|
||||||
zoneDelete(zone);
|
|
||||||
}
|
|
||||||
END_TEST
|
|
||||||
|
|
||||||
START_TEST(testZoneRelativeHeight)
|
|
||||||
{
|
|
||||||
Zone* zone = zoneCreate();
|
|
||||||
|
|
||||||
zoneAddHeightRangeQuick(zone, 1.0, 0.2, 0.3, 0.6, 0.9);
|
|
||||||
zoneSetRelativeHeight(zone, -2.0, 2.0, 8.0);
|
|
||||||
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, -10.0, 0.0), VECTOR_UP), 0.0);
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, -2.1, 0.0), VECTOR_UP), 0.0);
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, -2.0, 0.0), VECTOR_UP), 0.0);
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, -1.0, 0.0), VECTOR_UP), 0.0);
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, -0.5, 0.0), VECTOR_UP), 0.0);
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, -0.2, 0.0), VECTOR_UP), 0.25);
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, 0.0, 0.0), VECTOR_UP), 0.5);
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, 0.3, 0.0), VECTOR_UP), 0.875);
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, 0.5, 0.0), VECTOR_UP), 1.0);
|
|
||||||
ck_assert_double_eq(zoneGetValue(zone, v3(0.0, 1.0, 0.0), VECTOR_UP), 1.0);
|
|
||||||
|
|
||||||
zoneDelete(zone);
|
|
||||||
}
|
|
||||||
END_TEST
|
|
||||||
|
|
||||||
TEST_CASE(zone,
|
|
||||||
testZoneAbsoluteHeight,
|
|
||||||
testZoneRelativeHeight)
|
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
TEMPLATE = app
|
|
||||||
CONFIG += console
|
|
||||||
CONFIG -= app_bundle
|
|
||||||
|
|
||||||
TARGET = paysages-tests
|
|
||||||
|
|
||||||
CONFIG(release, debug|release): DEFINES += NDEBUG
|
|
||||||
|
|
||||||
unix {
|
|
||||||
CONFIG += link_pkgconfig
|
|
||||||
PKGCONFIG += check
|
|
||||||
}
|
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD/..
|
|
||||||
|
|
||||||
SOURCES += main.c \
|
|
||||||
test_terrain_painting.c \
|
|
||||||
test_zone.c
|
|
||||||
|
|
||||||
HEADERS += \
|
|
||||||
common.h
|
|
||||||
|
|
||||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../system/release/ -lpaysages_system
|
|
||||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../system/debug/ -lpaysages_system
|
|
||||||
else:unix: LIBS += -L$$OUT_PWD/../system/ -lpaysages_system
|
|
||||||
INCLUDEPATH += $$PWD/../system
|
|
||||||
DEPENDPATH += $$PWD/../system
|
|
||||||
|
|
||||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../basics/release/ -lpaysages_basics
|
|
||||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../basics/debug/ -lpaysages_basics
|
|
||||||
else:unix: LIBS += -L$$OUT_PWD/../basics/ -lpaysages_basics
|
|
||||||
INCLUDEPATH += $$PWD/../basics
|
|
||||||
DEPENDPATH += $$PWD/../basics
|
|
||||||
|
|
||||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../definition/release/ -lpaysages_definition
|
|
||||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../definition/debug/ -lpaysages_definition
|
|
||||||
else:unix: LIBS += -L$$OUT_PWD/../definition/ -lpaysages_definition
|
|
||||||
INCLUDEPATH += $$PWD/../definition
|
|
||||||
DEPENDPATH += $$PWD/../definition
|
|
||||||
|
|
||||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../rendering/release/ -lpaysages_rendering
|
|
||||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../rendering/debug/ -lpaysages_rendering
|
|
||||||
else:unix: LIBS += -L$$OUT_PWD/../rendering/ -lpaysages_rendering
|
|
||||||
INCLUDEPATH += $$PWD/../rendering
|
|
||||||
DEPENDPATH += $$PWD/../rendering
|
|
Loading…
Reference in a new issue