add heightmap-based test generation
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "constants.hpp"
|
||||
#include "engine.hpp"
|
||||
#include "content/Content.hpp"
|
||||
#include "files/engine_paths.hpp"
|
||||
#include "files/settings_io.hpp"
|
||||
#include "frontend/menu.hpp"
|
||||
@@ -11,8 +12,8 @@
|
||||
#include "logic/LevelController.hpp"
|
||||
#include "window/Events.hpp"
|
||||
#include "window/Window.hpp"
|
||||
#include "voxels/WorldGenerator.hpp"
|
||||
#include "world/Level.hpp"
|
||||
#include "world/WorldGenerators.hpp"
|
||||
#include "api_lua.hpp"
|
||||
|
||||
using namespace scripting;
|
||||
@@ -173,18 +174,19 @@ static int l_quit(lua::State*) {
|
||||
/// @brief Get the default world generator
|
||||
/// @return The ID of the default world generator
|
||||
static int l_get_default_generator(lua::State* L) {
|
||||
return lua::pushstring(L, WorldGenerators::getDefaultGeneratorID());
|
||||
return lua::pushstring(L, WorldGenerator::DEFAULT);
|
||||
}
|
||||
|
||||
/// @brief Get a list of all world generators
|
||||
/// @return A table with the IDs of all world generators
|
||||
static int l_get_generators(lua::State* L) {
|
||||
const auto& generators = WorldGenerators::getGeneratorsIDs();
|
||||
const auto& generators = content->generators.getDefs();
|
||||
lua::createtable(L, generators.size(), 0);
|
||||
|
||||
int i = 0;
|
||||
for (auto& id : generators) {
|
||||
lua::pushstring(L, id);
|
||||
for (auto& [name, _] : generators) {
|
||||
std::cout << name << std::endl;
|
||||
lua::pushstring(L, name);
|
||||
lua::rawseti(L, i + 1);
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace lua {
|
||||
LuaHeightmap(uint width, uint height)
|
||||
: map(std::make_shared<Heightmap>(width, height)) {}
|
||||
|
||||
virtual ~LuaHeightmap() = default;
|
||||
virtual ~LuaHeightmap();
|
||||
|
||||
uint getWidth() const {
|
||||
return map->getWidth();
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <filesystem>
|
||||
|
||||
#include "util/functional_util.hpp"
|
||||
#define FNL_IMPL
|
||||
#include "maths/FastNoiseLite.h"
|
||||
#include "coders/png.hpp"
|
||||
#include "files/util.hpp"
|
||||
@@ -16,6 +17,9 @@ using namespace lua;
|
||||
|
||||
static fnl_state noise = fnlCreateState();
|
||||
|
||||
LuaHeightmap::~LuaHeightmap() {;
|
||||
}
|
||||
|
||||
static int l_dump(lua::State* L) {
|
||||
if (auto heightmap = touserdata<LuaHeightmap>(L, 1)) {
|
||||
auto filename = tostring(L, 2);
|
||||
@@ -95,7 +99,7 @@ static int l_noise(lua::State* L) {
|
||||
template<template<class> class Op>
|
||||
static int l_binop_func(lua::State* L) {
|
||||
Op<float> op;
|
||||
if (auto heightmap = touserdata<Heightmap>(L, 1)) {
|
||||
if (auto heightmap = touserdata<LuaHeightmap>(L, 1)) {
|
||||
uint w = heightmap->getWidth();
|
||||
uint h = heightmap->getHeight();
|
||||
auto heights = heightmap->getValues();
|
||||
@@ -124,7 +128,7 @@ static int l_binop_func(lua::State* L) {
|
||||
template<template<class> class Op>
|
||||
static int l_unaryop_func(lua::State* L) {
|
||||
Op<float> op;
|
||||
if (auto heightmap = touserdata<Heightmap>(L, 1)) {
|
||||
if (auto heightmap = touserdata<LuaHeightmap>(L, 1)) {
|
||||
uint w = heightmap->getWidth();
|
||||
uint h = heightmap->getHeight();
|
||||
auto heights = heightmap->getValues();
|
||||
|
||||
Reference in New Issue
Block a user