Added PropInstance. This module will be reworked to be Node based. This design will simplify everything.

This commit is contained in:
Relintai 2020-04-03 12:00:02 +02:00
parent c1e692f968
commit 7cacfed933
4 changed files with 88 additions and 6 deletions

2
SCsub
View File

@ -28,6 +28,8 @@ sources = [
"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",
"prop_instance.cpp",
] ]
if env['tools']: if env['tools']:

32
prop_instance.cpp Normal file
View File

@ -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");
}

51
prop_instance.h Normal file
View File

@ -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

View File

@ -40,9 +40,7 @@ SOFTWARE.
#include "prop_tool/prop_tool_prop.h" #include "prop_tool/prop_tool_prop.h"
#include "prop_tool/prop_tool_scene.h" #include "prop_tool/prop_tool_scene.h"
#ifdef TOOLS_ENABLED #include "prop_instance.h"
#include "prop_tool/prop_tool_editor_plugin.h"
#endif
void register_props_types() { void register_props_types() {
ClassDB::register_class<PropData>(); ClassDB::register_class<PropData>();
@ -53,6 +51,7 @@ void register_props_types() {
ClassDB::register_class<PropDataProp>(); ClassDB::register_class<PropDataProp>();
ClassDB::register_class<PropDataEntity>(); ClassDB::register_class<PropDataEntity>();
ClassDB::register_class<GroundClutter>();
ClassDB::register_class<GroundClutterFoliage>(); ClassDB::register_class<GroundClutterFoliage>();
ClassDB::register_class<PropTool>(); ClassDB::register_class<PropTool>();
@ -62,9 +61,7 @@ void register_props_types() {
ClassDB::register_class<PropToolLight>(); ClassDB::register_class<PropToolLight>();
ClassDB::register_class<PropToolScene>(); ClassDB::register_class<PropToolScene>();
#ifdef TOOLS_ENABLED ClassDB::register_class<PropInstance>();
EditorPlugins::add_by_type<PropToolEditorPlugin>();
#endif
} }
void unregister_props_types() { void unregister_props_types() {