Fully ported ProlToolLight aswell.

This commit is contained in:
Relintai 2020-02-27 21:06:45 +01:00
parent 0e12fd732d
commit eeb0a8b198
4 changed files with 46 additions and 25 deletions

1
SCsub
View File

@ -58,6 +58,7 @@ sources = [
"world/voxel_world_editor.cpp",
"prop_tool/prop_tool_light.cpp",
"prop_tool/prop_tool_mesh.cpp",
#"prop_tool/prop_tool_editor_plugin.cpp",
]

View File

@ -22,27 +22,49 @@ SOFTWARE.
#include "prop_tool_light.h"
/*
Ref<PropDataLight> PropToolLight::get_data() {
var _prop_light : PropDataLight
if (!is_visible())
return Ref<PropDataLight>();
func get_data() -> PropDataLight:
if not visible:
return null
if _prop_light == null:
_prop_light = PropDataLight.new()
_prop_light.light_color = light_color
_prop_light.light_size = omni_range
return _prop_light
if (!_prop_light.is_valid())
_prop_light.instance();
func set_data(light : PropDataLight) -> void:
_prop_light = light
light_color = _prop_light.light_color
omni_range = _prop_light.light_size
light_energy = _prop_light.light_size
_prop_light->set_light_color(get_color());
_prop_light->set_light_size(get_param(Light::PARAM_RANGE));
*/
return _prop_light;
}
void PropToolLight::set_data(const Ref<PropDataLight> &data) {
_prop_light = data;
if (!_prop_light.is_valid())
return;
set_color(_prop_light->get_light_color());
set_param(Light::PARAM_RANGE, _prop_light->get_light_size());
set_param(Light::PARAM_ENERGY, _prop_light->get_light_size());
}
bool PropToolLight::get_snap_to_mesh() const {
return _snap_to_mesh;
}
void PropToolLight::set_snap_to_mesh(const bool value) {
_snap_to_mesh = value;
}
PropToolLight::PropToolLight() {
}
PropToolLight::~PropToolLight() {
_prop_light.unref();
}
void PropToolLight::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_data"), &PropToolLight::get_data);
ClassDB::bind_method(D_METHOD("set_data", "value"), &PropToolLight::set_data);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "PropDataLight"), "set_data", "get_data");
ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropToolLight::get_snap_to_mesh);
ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropToolLight::set_snap_to_mesh);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh");
}

View File

@ -42,18 +42,14 @@ public:
bool get_snap_to_mesh() const;
void set_snap_to_mesh(const bool value);
void generate();
PropToolLight();
~PropToolLight();
protected:
void set_generate(bool value);
static void _bind_methods();
private:
Ref<PropDataLight> _prop_mesh;
Ref<PropDataLight> _prop_light;
bool _snap_to_mesh;
};

View File

@ -64,6 +64,7 @@ SOFTWARE.
#include "world/voxel_world_editor.h"
#include "prop_tool/prop_tool_light.h"
#include "prop_tool/prop_tool_mesh.h"
//#include "prop_tool/prop_tool_editor_plugin.h"
@ -109,6 +110,7 @@ void register_voxelman_types() {
ClassDB::register_class<GroundClutterFoliage>();
ClassDB::register_class<PropToolMesh>();
ClassDB::register_class<PropToolLight>();
#ifdef TOOLS_ENABLED
EditorPlugins::add_by_type<VoxelWorldEditorPlugin>();