32 lines
1.1 KiB
C++
32 lines
1.1 KiB
C++
#include "add_primitive_button.h"
|
|
#include "terrain_editor/edit_history.h"
|
|
#include "terrain_editor/terrain_mesh_generator.h"
|
|
|
|
void AddPrimitiveButton::_bind_methods() {
|
|
BIND_HPROPERTY(Variant::OBJECT, primitive_blueprint, PROPERTY_HINT_RESOURCE_TYPE, "TerrainPrimitive");
|
|
BIND_HPROPERTY(Variant::OBJECT, terrain, PROPERTY_HINT_NODE_TYPE, "TerrainMeshGenerator");
|
|
}
|
|
|
|
void AddPrimitiveButton::pressed() {
|
|
if (this->terrain) {
|
|
Ref<TerrainPrimitive> copy{ this->primitive_blueprint->duplicate(true) };
|
|
EditHistory::get_singleton()->push_action(callable_mp(this->terrain, &TerrainMeshGenerator::add_primitive).bind(copy), callable_mp(this->terrain, &TerrainMeshGenerator::remove_primitive).bind(copy));
|
|
}
|
|
}
|
|
|
|
void AddPrimitiveButton::set_primitive_blueprint(Ref<TerrainPrimitive> blueprint) {
|
|
this->primitive_blueprint = blueprint;
|
|
}
|
|
|
|
Ref<TerrainPrimitive> AddPrimitiveButton::get_primitive_blueprint() const {
|
|
return this->primitive_blueprint;
|
|
}
|
|
|
|
void AddPrimitiveButton::set_terrain(TerrainMeshGenerator *terrain) {
|
|
this->terrain = terrain;
|
|
}
|
|
|
|
TerrainMeshGenerator *AddPrimitiveButton::get_terrain() const {
|
|
return this->terrain;
|
|
}
|