mirror of
https://github.com/Relintai/voxelman.git
synced 2025-01-12 15:01:09 +01:00
Ported PropToolProp aswell.
This commit is contained in:
parent
0a27c60136
commit
c9978d13ba
1
SCsub
1
SCsub
@ -58,6 +58,7 @@ sources = [
|
|||||||
|
|
||||||
"world/voxel_world_editor.cpp",
|
"world/voxel_world_editor.cpp",
|
||||||
|
|
||||||
|
"prop_tool/prop_tool_prop.cpp",
|
||||||
"prop_tool/prop_tool_scene.cpp",
|
"prop_tool/prop_tool_scene.cpp",
|
||||||
"prop_tool/prop_tool_light.cpp",
|
"prop_tool/prop_tool_light.cpp",
|
||||||
"prop_tool/prop_tool_mesh.cpp",
|
"prop_tool/prop_tool_mesh.cpp",
|
||||||
|
95
prop_tool/prop_tool_prop.cpp
Normal file
95
prop_tool/prop_tool_prop.cpp
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2020 Péter Magyar
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "prop_tool_prop.h"
|
||||||
|
|
||||||
|
Ref<PropDataProp> PropToolProp::get_data() {
|
||||||
|
if (!is_visible() || !_prop_data.is_valid())
|
||||||
|
return Ref<PropDataProp>();
|
||||||
|
|
||||||
|
if (!_prop_data.is_valid())
|
||||||
|
_prop_data.instance();
|
||||||
|
|
||||||
|
_prop_prop->set_prop(_prop_data);
|
||||||
|
_prop_prop->set_snap_to_mesh(_snap_to_mesh);
|
||||||
|
_prop_prop->set_snap_axis(_snap_axis);
|
||||||
|
|
||||||
|
return _prop_prop;
|
||||||
|
}
|
||||||
|
void PropToolProp::set_data(const Ref<PropDataProp> &data) {
|
||||||
|
_prop_prop = data;
|
||||||
|
|
||||||
|
if (!_prop_prop.is_valid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
_prop_data = _prop_prop->get_prop();
|
||||||
|
_snap_to_mesh = _prop_prop->get_snap_to_mesh();
|
||||||
|
_snap_axis = _prop_prop->get_snap_axis();
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<PropData> PropToolProp::get_prop_data() {
|
||||||
|
return _prop_data;
|
||||||
|
}
|
||||||
|
void PropToolProp::set_prop_data(const Ref<PropData> &data) {
|
||||||
|
_prop_data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PropToolProp::get_snap_to_mesh() const {
|
||||||
|
return _snap_to_mesh;
|
||||||
|
}
|
||||||
|
void PropToolProp::set_snap_to_mesh(const bool value) {
|
||||||
|
_snap_to_mesh = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3 PropToolProp::get_snap_axis() const {
|
||||||
|
return _snap_axis;
|
||||||
|
}
|
||||||
|
void PropToolProp::set_snap_axis(const Vector3 &value) {
|
||||||
|
_snap_axis = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
PropToolProp::PropToolProp() {
|
||||||
|
_snap_to_mesh = false;
|
||||||
|
_snap_axis = Vector3(0, -1, 0);
|
||||||
|
}
|
||||||
|
PropToolProp::~PropToolProp() {
|
||||||
|
_prop_data.unref();
|
||||||
|
_prop_prop.unref();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PropToolProp::_bind_methods() {
|
||||||
|
ClassDB::bind_method(D_METHOD("get_data"), &PropToolProp::get_data);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_data", "value"), &PropToolProp::set_data);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "PropDataProp"), "set_data", "get_data");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropToolProp::get_snap_to_mesh);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropToolProp::set_snap_to_mesh);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_snap_axis"), &PropToolProp::get_snap_axis);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropToolProp::set_snap_axis);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_prop_data"), &PropToolProp::get_prop_data);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_prop_data", "value"), &PropToolProp::set_prop_data);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_data", PROPERTY_HINT_RESOURCE_TYPE, "PropData"), "set_prop_data", "get_prop_data");
|
||||||
|
}
|
60
prop_tool/prop_tool_prop.h
Normal file
60
prop_tool/prop_tool_prop.h
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
Copyright (c) 2020 Péter Magyar
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef PROP_TOOL_PROP_H
|
||||||
|
#define PROP_TOOL_PROP_H
|
||||||
|
|
||||||
|
#include "scene/3d/spatial.h"
|
||||||
|
|
||||||
|
#include "../props/prop_data.h"
|
||||||
|
#include "../props/prop_data_prop.h"
|
||||||
|
|
||||||
|
class PropToolProp : public Spatial {
|
||||||
|
GDCLASS(PropToolProp, Spatial);
|
||||||
|
|
||||||
|
public:
|
||||||
|
Ref<PropDataProp> get_data();
|
||||||
|
void set_data(const Ref<PropDataProp> &data);
|
||||||
|
|
||||||
|
Ref<PropData> get_prop_data();
|
||||||
|
void set_prop_data(const Ref<PropData> &data);
|
||||||
|
|
||||||
|
bool get_snap_to_mesh() const;
|
||||||
|
void set_snap_to_mesh(const bool value);
|
||||||
|
|
||||||
|
Vector3 get_snap_axis() const;
|
||||||
|
void set_snap_axis(const Vector3 &value);
|
||||||
|
|
||||||
|
PropToolProp();
|
||||||
|
~PropToolProp();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static void _bind_methods();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ref<PropData> _prop_data;
|
||||||
|
bool _snap_to_mesh;
|
||||||
|
Vector3 _snap_axis;
|
||||||
|
Ref<PropDataProp> _prop_prop;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -66,6 +66,7 @@ SOFTWARE.
|
|||||||
|
|
||||||
#include "prop_tool/prop_tool_light.h"
|
#include "prop_tool/prop_tool_light.h"
|
||||||
#include "prop_tool/prop_tool_mesh.h"
|
#include "prop_tool/prop_tool_mesh.h"
|
||||||
|
#include "prop_tool/prop_tool_prop.h"
|
||||||
#include "prop_tool/prop_tool_scene.h"
|
#include "prop_tool/prop_tool_scene.h"
|
||||||
//#include "prop_tool/prop_tool_editor_plugin.h"
|
//#include "prop_tool/prop_tool_editor_plugin.h"
|
||||||
|
|
||||||
@ -110,6 +111,7 @@ void register_voxelman_types() {
|
|||||||
|
|
||||||
ClassDB::register_class<GroundClutterFoliage>();
|
ClassDB::register_class<GroundClutterFoliage>();
|
||||||
|
|
||||||
|
ClassDB::register_class<PropToolProp>();
|
||||||
ClassDB::register_class<PropToolMesh>();
|
ClassDB::register_class<PropToolMesh>();
|
||||||
ClassDB::register_class<PropToolLight>();
|
ClassDB::register_class<PropToolLight>();
|
||||||
ClassDB::register_class<PropToolScene>();
|
ClassDB::register_class<PropToolScene>();
|
||||||
|
Loading…
Reference in New Issue
Block a user