mirror of
https://github.com/Relintai/voxelman.git
synced 2025-01-27 15:19:18 +01:00
Fully ported PropToolScene aswell.
This commit is contained in:
parent
eeb0a8b198
commit
0a27c60136
1
SCsub
1
SCsub
@ -58,6 +58,7 @@ sources = [
|
||||
|
||||
"world/voxel_world_editor.cpp",
|
||||
|
||||
"prop_tool/prop_tool_scene.cpp",
|
||||
"prop_tool/prop_tool_light.cpp",
|
||||
"prop_tool/prop_tool_mesh.cpp",
|
||||
#"prop_tool/prop_tool_editor_plugin.cpp",
|
||||
|
95
prop_tool/prop_tool_scene.cpp
Normal file
95
prop_tool/prop_tool_scene.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_scene.h"
|
||||
|
||||
Ref<PropDataScene> PropToolScene::get_data() {
|
||||
if (!is_visible() || !_scene_data.is_valid())
|
||||
return Ref<PropDataScene>();
|
||||
|
||||
if (!_prop_scene.is_valid())
|
||||
_prop_scene.instance();
|
||||
|
||||
_prop_scene->set_scene(_scene_data);
|
||||
_prop_scene->set_snap_to_mesh(_snap_to_mesh);
|
||||
_prop_scene->set_snap_axis(_snap_axis);
|
||||
|
||||
return _prop_scene;
|
||||
}
|
||||
void PropToolScene::set_data(const Ref<PropDataScene> &data) {
|
||||
_prop_scene = data;
|
||||
|
||||
if (!_prop_scene.is_valid())
|
||||
return;
|
||||
|
||||
_scene_data = _prop_scene->get_scene();
|
||||
_snap_to_mesh = _prop_scene->get_snap_to_mesh();
|
||||
_snap_axis = _prop_scene->get_snap_axis();
|
||||
}
|
||||
|
||||
Ref<PackedScene> PropToolScene::get_scene_data() {
|
||||
return _scene_data;
|
||||
}
|
||||
void PropToolScene::set_scene_data(const Ref<PackedScene> &data) {
|
||||
_scene_data = data;
|
||||
}
|
||||
|
||||
bool PropToolScene::get_snap_to_mesh() const {
|
||||
return _snap_to_mesh;
|
||||
}
|
||||
void PropToolScene::set_snap_to_mesh(const bool value) {
|
||||
_snap_to_mesh = value;
|
||||
}
|
||||
|
||||
Vector3 PropToolScene::get_snap_axis() const {
|
||||
return _snap_axis;
|
||||
}
|
||||
void PropToolScene::set_snap_axis(const Vector3 &value) {
|
||||
_snap_axis = value;
|
||||
}
|
||||
|
||||
PropToolScene::PropToolScene() {
|
||||
_snap_to_mesh = false;
|
||||
_snap_axis = Vector3(0, -1, 0);
|
||||
}
|
||||
PropToolScene::~PropToolScene() {
|
||||
_scene_data.unref();
|
||||
_prop_scene.unref();
|
||||
}
|
||||
|
||||
void PropToolScene::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_data"), &PropToolScene::get_data);
|
||||
ClassDB::bind_method(D_METHOD("set_data", "value"), &PropToolScene::set_data);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "PropDataScene"), "set_data", "get_data");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropToolScene::get_snap_to_mesh);
|
||||
ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropToolScene::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"), &PropToolScene::get_snap_axis);
|
||||
ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropToolScene::set_snap_axis);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_scene_data"), &PropToolScene::get_scene_data);
|
||||
ClassDB::bind_method(D_METHOD("set_scene_data", "value"), &PropToolScene::set_scene_data);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "scene_data", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_scene_data", "get_scene_data");
|
||||
}
|
59
prop_tool/prop_tool_scene.h
Normal file
59
prop_tool/prop_tool_scene.h
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
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_SCENE_H
|
||||
#define PROP_TOOL_SCENE_H
|
||||
|
||||
#include "scene/3d/spatial.h"
|
||||
|
||||
#include "../props/prop_data_scene.h"
|
||||
|
||||
class PropToolScene : public Spatial {
|
||||
GDCLASS(PropToolScene, Spatial);
|
||||
|
||||
public:
|
||||
Ref<PropDataScene> get_data();
|
||||
void set_data(const Ref<PropDataScene> &data);
|
||||
|
||||
Ref<PackedScene> get_scene_data();
|
||||
void set_scene_data(const Ref<PackedScene> &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);
|
||||
|
||||
PropToolScene();
|
||||
~PropToolScene();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
Ref<PackedScene> _scene_data;
|
||||
bool _snap_to_mesh;
|
||||
Vector3 _snap_axis;
|
||||
Ref<PropDataScene> _prop_scene;
|
||||
};
|
||||
|
||||
#endif
|
@ -66,6 +66,7 @@ SOFTWARE.
|
||||
|
||||
#include "prop_tool/prop_tool_light.h"
|
||||
#include "prop_tool/prop_tool_mesh.h"
|
||||
#include "prop_tool/prop_tool_scene.h"
|
||||
//#include "prop_tool/prop_tool_editor_plugin.h"
|
||||
|
||||
void register_voxelman_types() {
|
||||
@ -111,6 +112,7 @@ void register_voxelman_types() {
|
||||
|
||||
ClassDB::register_class<PropToolMesh>();
|
||||
ClassDB::register_class<PropToolLight>();
|
||||
ClassDB::register_class<PropToolScene>();
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
EditorPlugins::add_by_type<VoxelWorldEditorPlugin>();
|
||||
|
Loading…
Reference in New Issue
Block a user