feat: implemented adding primitive with UI
This commit is contained in:
parent
670cfa1779
commit
b6e8ca9225
8 changed files with 120 additions and 31 deletions
31
modules/terrain_editor/add_primitive_button.cpp
Normal file
31
modules/terrain_editor/add_primitive_button.cpp
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue