feat: implemented adding primitive with UI

This commit is contained in:
Sara Gerretsen 2025-12-08 15:33:02 +01:00
parent 670cfa1779
commit b6e8ca9225
8 changed files with 120 additions and 31 deletions

View file

@ -258,6 +258,21 @@ void TerrainMeshGenerator::push_task(Rect2 area, Ref<ArrayMesh> mesh, size_t poi
this->input_lock.unlock();
}
void TerrainMeshGenerator::add_primitive(Ref<TerrainPrimitive> primitive) {
Array list = get_primitives();
list.push_front(primitive);
set_primitives(list);
}
void TerrainMeshGenerator::remove_primitive(Ref<TerrainPrimitive> primitive) {
Array list = get_primitives();
int idx{ list.find(primitive) };
if (idx >= 0 && idx < list.size()) {
list.remove_at(idx);
}
set_primitives(list);
}
void TerrainMeshGenerator::set_primitives(Array primitives) {
// synchronise primitives
for (Variant var : this->primitives_buffer) {