1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-22 20:35:24 +02:00

Add L-system trees as decorations (#14355)

This commit is contained in:
cx384
2024-03-12 20:10:28 +01:00
committed by GitHub
parent f07e1026ac
commit 60810c2d37
10 changed files with 125 additions and 46 deletions

View File

@@ -27,6 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/numeric.h"
#include <algorithm>
#include <vector>
#include "mapgen/treegen.h"
FlagDesc flagdesc_deco[] = {
@@ -472,3 +473,24 @@ size_t DecoSchematic::generate(MMVManip *vm, PcgRandom *pr, v3s16 p, bool ceilin
return 1;
}
///////////////////////////////////////////////////////////////////////////////
ObjDef *DecoLSystem::clone() const
{
auto def = new DecoLSystem();
Decoration::cloneTo(def);
def->tree_def = tree_def;
return def;
}
size_t DecoLSystem::generate(MMVManip *vm, PcgRandom *pr, v3s16 p, bool ceiling)
{
if (!canPlaceDecoration(vm, p))
return 0;
// Make sure that tree_def can't be modified, since it is shared.
const auto &ref = *tree_def;
return treegen::make_ltree(*vm, p, m_ndef, ref);
}