Clean up Prop2DSceneInstance.

This commit is contained in:
Relintai 2022-02-25 23:57:33 +01:00
parent 4eb6cf82de
commit 2efb03b6d2
2 changed files with 4 additions and 44 deletions

View File

@ -20,20 +20,6 @@ void Prop2DSceneInstance::set_scene(const Ref<PackedScene> &data) {
build(); build();
} }
bool Prop2DSceneInstance::get_snap_to_mesh() const {
return _snap_to_mesh;
}
void Prop2DSceneInstance::set_snap_to_mesh(const bool value) {
_snap_to_mesh = value;
}
Vector3 Prop2DSceneInstance::get_snap_axis() const {
return _snap_axis;
}
void Prop2DSceneInstance::set_snap_axis(const Vector3 &value) {
_snap_axis = value;
}
void Prop2DSceneInstance::build() { void Prop2DSceneInstance::build() {
if (!is_inside_tree()) { if (!is_inside_tree()) {
return; return;
@ -60,8 +46,6 @@ void Prop2DSceneInstance::build() {
} }
Prop2DSceneInstance::Prop2DSceneInstance() { Prop2DSceneInstance::Prop2DSceneInstance() {
_snap_to_mesh = false;
_snap_axis = Vector3(0, -1, 0);
} }
Prop2DSceneInstance::~Prop2DSceneInstance() { Prop2DSceneInstance::~Prop2DSceneInstance() {
_scene.unref(); _scene.unref();
@ -79,14 +63,6 @@ void Prop2DSceneInstance::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_scene"), &Prop2DSceneInstance::get_scene); ClassDB::bind_method(D_METHOD("get_scene"), &Prop2DSceneInstance::get_scene);
ClassDB::bind_method(D_METHOD("set_scene", "value"), &Prop2DSceneInstance::set_scene); ClassDB::bind_method(D_METHOD("set_scene", "value"), &Prop2DSceneInstance::set_scene);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "scene", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_scene", "get_scene"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "scene", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_scene", "get_scene");
ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &Prop2DSceneInstance::get_snap_to_mesh);
ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &Prop2DSceneInstance::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"), &Prop2DSceneInstance::get_snap_axis);
ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &Prop2DSceneInstance::set_snap_axis);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis");
ClassDB::bind_method(D_METHOD("build"), &Prop2DSceneInstance::build); ClassDB::bind_method(D_METHOD("build"), &Prop2DSceneInstance::build);
} }

View File

@ -25,32 +25,18 @@ SOFTWARE.
#include "core/version.h" #include "core/version.h"
#if VERSION_MAJOR < 4 #include "scene/2d/node_2d.h"
#include "scene/3d/spatial.h"
#else
#include "scene/3d/node_3d.h"
#define Spatial Node3D
#endif
#include "core/math/vector3.h"
#include "props/prop_2d_data.h" #include "props/prop_2d_data.h"
#include "scene/resources/packed_scene.h" #include "scene/resources/packed_scene.h"
class Prop2DSceneInstance : public Spatial { class Prop2DSceneInstance : public Node2D {
GDCLASS(Prop2DSceneInstance, Spatial); GDCLASS(Prop2DSceneInstance, Node2D);
public: public:
Ref<PackedScene> get_scene(); Ref<PackedScene> get_scene();
void set_scene(const Ref<PackedScene> &data); void set_scene(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);
void build(); void build();
Prop2DSceneInstance(); Prop2DSceneInstance();
@ -62,8 +48,6 @@ protected:
private: private:
Ref<PackedScene> _scene; Ref<PackedScene> _scene;
bool _snap_to_mesh;
Vector3 _snap_axis;
}; };
#endif #endif