diff --git a/SCsub b/SCsub index 8bd6dee..8bd4b57 100644 --- a/SCsub +++ b/SCsub @@ -28,6 +28,8 @@ sources = [ "prop_tool/prop_tool_scene.cpp", "prop_tool/prop_tool_light.cpp", "prop_tool/prop_tool_mesh.cpp", + + "prop_instance.cpp", ] if env['tools']: diff --git a/prop_instance.cpp b/prop_instance.cpp new file mode 100644 index 0000000..2a06b86 --- /dev/null +++ b/prop_instance.cpp @@ -0,0 +1,32 @@ +#include "prop_instance.h" + +bool PropInstance::get_snap_to_mesh() const { + return _snap_to_mesh; +} +void PropInstance::set_snap_to_mesh(const bool value) { + _snap_to_mesh = value; +} + +Vector3 PropInstance::get_snap_axis() const { + return _snap_axis; +} +void PropInstance::set_snap_axis(const Vector3 &value) { + _snap_axis = value; +} + +PropInstance::PropInstance() { + _snap_to_mesh = false; + _snap_axis = Vector3(0, -1, 0); +} +PropInstance::~PropInstance() { +} + +void PropInstance::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &PropInstance::get_snap_to_mesh); + ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &PropInstance::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"), &PropInstance::get_snap_axis); + ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &PropInstance::set_snap_axis); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis"); +} diff --git a/prop_instance.h b/prop_instance.h new file mode 100644 index 0000000..3a61362 --- /dev/null +++ b/prop_instance.h @@ -0,0 +1,51 @@ +/* +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_INSTANCE_H +#define PROP_INSTANCE_H + +#include "scene/3d/spatial.h" + +#include "core/math/vector3.h" + +class PropInstance : public Spatial { + GDCLASS(PropInstance, Spatial); + +public: + 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); + + PropInstance(); + ~PropInstance(); + +protected: + static void _bind_methods(); + +private: + bool _snap_to_mesh; + Vector3 _snap_axis; +}; + +#endif diff --git a/register_types.cpp b/register_types.cpp index 2b964d1..72b38a5 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -40,9 +40,7 @@ SOFTWARE. #include "prop_tool/prop_tool_prop.h" #include "prop_tool/prop_tool_scene.h" -#ifdef TOOLS_ENABLED -#include "prop_tool/prop_tool_editor_plugin.h" -#endif +#include "prop_instance.h" void register_props_types() { ClassDB::register_class(); @@ -53,6 +51,7 @@ void register_props_types() { ClassDB::register_class(); ClassDB::register_class(); + ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); @@ -62,9 +61,7 @@ void register_props_types() { ClassDB::register_class(); ClassDB::register_class(); -#ifdef TOOLS_ENABLED - EditorPlugins::add_by_type(); -#endif + ClassDB::register_class(); } void unregister_props_types() {