mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-12 05:41:15 +01:00
Cleaned up the rest of the SDShapes.
This commit is contained in:
parent
d339fb1fdb
commit
f2fb6b8b7d
@ -93,6 +93,11 @@ sources = [
|
|||||||
"nodes/sdf3d/sdf3d_op_bool.cpp",
|
"nodes/sdf3d/sdf3d_op_bool.cpp",
|
||||||
|
|
||||||
"nodes/sdf2d/sd_shape_rhombus.cpp",
|
"nodes/sdf2d/sd_shape_rhombus.cpp",
|
||||||
|
"nodes/sdf2d/sd_shape_polygon.cpp",
|
||||||
|
"nodes/sdf2d/sd_shape_line.cpp",
|
||||||
|
"nodes/sdf2d/sd_shape_circle.cpp",
|
||||||
|
"nodes/sdf2d/sd_shape_box.cpp",
|
||||||
|
"nodes/sdf2d/sd_shape_arc.cpp",
|
||||||
|
|
||||||
"nodes/sdf2d/sd_tf_translate.cpp",
|
"nodes/sdf2d/sd_tf_translate.cpp",
|
||||||
"nodes/sdf2d/sd_tf_scale.cpp",
|
"nodes/sdf2d/sd_tf_scale.cpp",
|
||||||
|
@ -69,6 +69,11 @@ def get_doc_classes():
|
|||||||
"MMSdTfRotate",
|
"MMSdTfRotate",
|
||||||
|
|
||||||
"MMSdShapeRhombus",
|
"MMSdShapeRhombus",
|
||||||
|
"MMSdShapePolygon",
|
||||||
|
"MMSdShapeLine",
|
||||||
|
"MMSdShapeCircle",
|
||||||
|
"MMSdShapeBox",
|
||||||
|
"MMSdShapeArc",
|
||||||
]
|
]
|
||||||
|
|
||||||
def get_doc_path():
|
def get_doc_path():
|
||||||
|
@ -1,164 +1,95 @@
|
|||||||
|
|
||||||
#include "sd_shape_arc.h"
|
#include "sd_shape_arc.h"
|
||||||
|
|
||||||
|
#include "../../algos/mm_algos.h"
|
||||||
|
#include "../../editor/mm_graph_node.h"
|
||||||
|
#include "../mm_material.h"
|
||||||
|
|
||||||
Ref<Resource> SdShapeArc::get_output() {
|
Ref<MMNodeUniversalProperty> MMSdShapeArc::get_output() {
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SdShapeArc::set_output(const Ref<Resource> &val) {
|
void MMSdShapeArc::set_output(const Ref<MMNodeUniversalProperty> &val) {
|
||||||
output = val;
|
output = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2 MMSdShapeArc::get_angle() {
|
||||||
Vector2 SdShapeArc::get_angle() {
|
|
||||||
return angle;
|
return angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SdShapeArc::set_angle(const Vector2 &val) {
|
void MMSdShapeArc::set_angle(const Vector2 &val) {
|
||||||
angle = val;
|
angle = val;
|
||||||
|
emit_changed();
|
||||||
|
output->do_emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float MMSdShapeArc::get_radius() const {
|
||||||
float SdShapeArc::get_radius() const {
|
|
||||||
return radius;
|
return radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SdShapeArc::set_radius(const float val) {
|
void MMSdShapeArc::set_radius(const float val) {
|
||||||
radius = val;
|
radius = val;
|
||||||
|
emit_changed();
|
||||||
|
output->do_emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float MMSdShapeArc::get_width() const {
|
||||||
float SdShapeArc::get_width() const {
|
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SdShapeArc::set_width(const float val) {
|
void MMSdShapeArc::set_width(const float val) {
|
||||||
width = val;
|
width = val;
|
||||||
|
emit_changed();
|
||||||
|
output->do_emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMSdShapeArc::_init_properties() {
|
||||||
|
if (!output.is_valid()) {
|
||||||
|
output.instance();
|
||||||
|
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
|
||||||
|
}
|
||||||
|
|
||||||
|
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_FLOAT);
|
||||||
|
output->set_slot_name(">>> Output >>>");
|
||||||
|
output->set_get_value_from_owner(true);
|
||||||
|
|
||||||
//tool;
|
|
||||||
//export(Resource) ;
|
|
||||||
Ref<Resource> output;
|
|
||||||
//export(Vector2) ;
|
|
||||||
Vector2 angle = Vector2(30, 150);
|
|
||||||
//export(float) ;
|
|
||||||
float radius = 0.3;
|
|
||||||
//export(float) ;
|
|
||||||
float width = 0.1;
|
|
||||||
|
|
||||||
void SdShapeArc::_init_properties() {
|
|
||||||
|
|
||||||
if (!output) {
|
|
||||||
output = MMNodeUniversalProperty.new();
|
|
||||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
|
|
||||||
}
|
|
||||||
|
|
||||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
|
||||||
output.slot_name = ">>> Output >>>";
|
|
||||||
output.get_value_from_owner = true;
|
|
||||||
register_output_property(output);
|
register_output_property(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMSdShapeArc::_register_methods(MMGraphNode *mm_graph_node) {
|
||||||
void SdShapeArc::_register_methods(const Variant &mm_graph_node) {
|
mm_graph_node->add_slot_label_universal(output);
|
||||||
mm_graph_node.add_slot_label_universal(output);
|
mm_graph_node->add_slot_vector2("get_angle", "set_angle", "Angle", 1);
|
||||||
mm_graph_node.add_slot_vector2("get_angle", "set_angle", "Angle", 1);
|
mm_graph_node->add_slot_float("get_radius", "set_radius", "Radius", 0.01);
|
||||||
mm_graph_node.add_slot_float("get_radius", "set_radius", "Radius", 0.01);
|
mm_graph_node->add_slot_float("get_width", "set_width", "Width", 0.01);
|
||||||
mm_graph_node.add_slot_float("get_width", "set_width", "Width", 0.01);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Variant MMSdShapeArc::_get_property_value(const Vector2 &uv) {
|
||||||
float SdShapeArc::_get_property_value(const Vector2 &uv) {
|
return MMAlgos::sdf_arc(uv, angle, Vector2(radius, width));
|
||||||
return MMAlgos.sdf_arc(uv, angle, Vector2(radius, width));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//angle;
|
MMSdShapeArc::MMSdShapeArc() {
|
||||||
|
|
||||||
Vector2 SdShapeArc::get_angle() {
|
|
||||||
return angle;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SdShapeArc::set_angle(const Vector2 &val) {
|
|
||||||
angle = val;
|
|
||||||
emit_changed();
|
|
||||||
output.emit_changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
//radius;
|
|
||||||
|
|
||||||
float SdShapeArc::get_radius() {
|
|
||||||
return radius;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SdShapeArc::set_radius(const float val) {
|
|
||||||
radius = val;
|
|
||||||
emit_changed();
|
|
||||||
output.emit_changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
//width;
|
|
||||||
|
|
||||||
float SdShapeArc::get_width() {
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SdShapeArc::set_width(const float val) {
|
|
||||||
width = val;
|
|
||||||
emit_changed();
|
|
||||||
output.emit_changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
SdShapeArc::SdShapeArc() {
|
|
||||||
output;
|
|
||||||
angle = Vector2(30, 150);
|
angle = Vector2(30, 150);
|
||||||
radius = 0.3;
|
radius = 0.3;
|
||||||
width = 0.1;
|
width = 0.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SdShapeArc::~SdShapeArc() {
|
MMSdShapeArc::~MMSdShapeArc() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMSdShapeArc::_bind_methods() {
|
||||||
|
ClassDB::bind_method(D_METHOD("get_output"), &MMSdShapeArc::get_output);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdShapeArc::set_output);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
|
||||||
|
|
||||||
static void SdShapeArc::_bind_methods() {
|
ClassDB::bind_method(D_METHOD("get_angle"), &MMSdShapeArc::get_angle);
|
||||||
ClassDB::bind_method(D_METHOD("get_output"), &SdShapeArc::get_output);
|
ClassDB::bind_method(D_METHOD("set_angle", "value"), &MMSdShapeArc::set_angle);
|
||||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdShapeArc::set_output);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
|
|
||||||
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_angle"), &SdShapeArc::get_angle);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_angle", "value"), &SdShapeArc::set_angle);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "angle"), "set_angle", "get_angle");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "angle"), "set_angle", "get_angle");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_radius"), &MMSdShapeArc::get_radius);
|
||||||
ClassDB::bind_method(D_METHOD("get_radius"), &SdShapeArc::get_radius);
|
ClassDB::bind_method(D_METHOD("set_radius", "value"), &MMSdShapeArc::set_radius);
|
||||||
ClassDB::bind_method(D_METHOD("set_radius", "value"), &SdShapeArc::set_radius);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius");
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_width"), &MMSdShapeArc::get_width);
|
||||||
ClassDB::bind_method(D_METHOD("get_width"), &SdShapeArc::get_width);
|
ClassDB::bind_method(D_METHOD("set_width", "value"), &MMSdShapeArc::set_width);
|
||||||
ClassDB::bind_method(D_METHOD("set_width", "value"), &SdShapeArc::set_width);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "width"), "set_width", "get_width");
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "width"), "set_width", "get_width");
|
||||||
|
}
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("_init_properties"), &SdShapeArc::_init_properties);
|
|
||||||
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdShapeArc::_register_methods);
|
|
||||||
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdShapeArc::_get_property_value);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_angle"), &SdShapeArc::get_angle);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_angle", "val"), &SdShapeArc::set_angle);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_radius"), &SdShapeArc::get_radius);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_radius", "val"), &SdShapeArc::set_radius);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_width"), &SdShapeArc::get_width);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_width", "val"), &SdShapeArc::set_width);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
#ifndef SD_SHAPE_ARC_H
|
#ifndef MM_SD_SHAPE_ARC_H
|
||||||
#define SD_SHAPE_ARC_H
|
#define MM_SD_SHAPE_ARC_H
|
||||||
|
|
||||||
|
#include "../mm_node.h"
|
||||||
|
#include "../mm_node_universal_property.h"
|
||||||
|
|
||||||
class SdShapeArc : public MMNode {
|
class MMSdShapeArc : public MMNode {
|
||||||
GDCLASS(SdShapeArc, MMNode);
|
GDCLASS(MMSdShapeArc, MMNode);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Ref<MMNodeUniversalProperty> get_output();
|
||||||
Ref<Resource> get_output();
|
void set_output(const Ref<MMNodeUniversalProperty> &val);
|
||||||
void set_output(const Ref<Resource> &val);
|
|
||||||
|
|
||||||
Vector2 get_angle();
|
Vector2 get_angle();
|
||||||
void set_angle(const Vector2 &val);
|
void set_angle(const Vector2 &val);
|
||||||
@ -20,34 +21,19 @@ class SdShapeArc : public MMNode {
|
|||||||
void set_width(const float val);
|
void set_width(const float val);
|
||||||
|
|
||||||
void _init_properties();
|
void _init_properties();
|
||||||
void _register_methods(const Variant &mm_graph_node);
|
void _register_methods(MMGraphNode *mm_graph_node);
|
||||||
float _get_property_value(const Vector2 &uv);
|
Variant _get_property_value(const Vector2 &uv);
|
||||||
Vector2 get_angle();
|
|
||||||
void set_angle(const Vector2 &val);
|
|
||||||
float get_radius();
|
|
||||||
void set_radius(const float val);
|
|
||||||
float get_width();
|
|
||||||
void set_width(const float val);
|
|
||||||
|
|
||||||
SdShapeArc();
|
MMSdShapeArc();
|
||||||
~SdShapeArc();
|
~MMSdShapeArc();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
//tool
|
Ref<MMNodeUniversalProperty> output;
|
||||||
//export(Resource)
|
Vector2 angle;
|
||||||
Ref<Resource> output;
|
float radius;
|
||||||
//export(Vector2)
|
float width;
|
||||||
Vector2 angle = Vector2(30, 150);
|
|
||||||
//export(float)
|
|
||||||
float radius = 0.3;
|
|
||||||
//export(float)
|
|
||||||
float width = 0.1;
|
|
||||||
//angle
|
|
||||||
//radius
|
|
||||||
//width
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,131 +1,79 @@
|
|||||||
|
|
||||||
#include "sd_shape_box.h"
|
#include "sd_shape_box.h"
|
||||||
|
|
||||||
|
#include "../../algos/mm_algos.h"
|
||||||
|
#include "../../editor/mm_graph_node.h"
|
||||||
|
#include "../mm_material.h"
|
||||||
|
|
||||||
Ref<Resource> SdShapeBox::get_output() {
|
Ref<MMNodeUniversalProperty> MMSdShapeBox::get_output() {
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SdShapeBox::set_output(const Ref<Resource> &val) {
|
void MMSdShapeBox::set_output(const Ref<MMNodeUniversalProperty> &val) {
|
||||||
output = val;
|
output = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2 MMSdShapeBox::get_center() {
|
||||||
Vector2 SdShapeBox::get_center() {
|
|
||||||
return center;
|
return center;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SdShapeBox::set_center(const Vector2 &val) {
|
void MMSdShapeBox::set_center(const Vector2 &val) {
|
||||||
center = val;
|
center = val;
|
||||||
|
emit_changed();
|
||||||
|
output->do_emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2 MMSdShapeBox::get_size() {
|
||||||
Vector2 SdShapeBox::get_size() {
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SdShapeBox::set_size(const Vector2 &val) {
|
void MMSdShapeBox::set_size(const Vector2 &val) {
|
||||||
size = val;
|
size = val;
|
||||||
|
emit_changed();
|
||||||
|
output->do_emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMSdShapeBox::_init_properties() {
|
||||||
|
if (!output.is_valid()) {
|
||||||
|
output.instance();
|
||||||
|
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
|
||||||
|
}
|
||||||
|
|
||||||
|
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_FLOAT);
|
||||||
|
output->set_slot_name(">>> Output >>>");
|
||||||
|
output->set_get_value_from_owner(true);
|
||||||
|
|
||||||
//tool;
|
|
||||||
//export(Resource) ;
|
|
||||||
Ref<Resource> output;
|
|
||||||
//export(Vector2) ;
|
|
||||||
Vector2 center = Vector2(0, 0);
|
|
||||||
//export(Vector2) ;
|
|
||||||
Vector2 size = Vector2(0.3, 0.2);
|
|
||||||
|
|
||||||
void SdShapeBox::_init_properties() {
|
|
||||||
|
|
||||||
if (!output) {
|
|
||||||
output = MMNodeUniversalProperty.new();
|
|
||||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
|
|
||||||
}
|
|
||||||
|
|
||||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
|
||||||
output.slot_name = ">>> Output >>>";
|
|
||||||
output.get_value_from_owner = true;
|
|
||||||
register_output_property(output);
|
register_output_property(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMSdShapeBox::_register_methods(MMGraphNode *mm_graph_node) {
|
||||||
void SdShapeBox::_register_methods(const Variant &mm_graph_node) {
|
mm_graph_node->add_slot_label_universal(output);
|
||||||
mm_graph_node.add_slot_label_universal(output);
|
mm_graph_node->add_slot_vector2("get_center", "set_center", "Center", 0.01);
|
||||||
mm_graph_node.add_slot_vector2("get_center", "set_center", "Center", 0.01);
|
mm_graph_node->add_slot_vector2("get_size", "set_size", "Size", 0.01);
|
||||||
mm_graph_node.add_slot_vector2("get_size", "set_size", "Size", 0.01);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Variant MMSdShapeBox::_get_property_value(const Vector2 &uv) {
|
||||||
float SdShapeBox::_get_property_value(const Vector2 &uv) {
|
return MMAlgos::sdf_box(uv, center, size);
|
||||||
return MMAlgos.sdf_box(uv, center, size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//center;
|
MMSdShapeBox::MMSdShapeBox() {
|
||||||
|
|
||||||
Vector2 SdShapeBox::get_center() {
|
|
||||||
return center;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SdShapeBox::set_center(const Vector2 &val) {
|
|
||||||
center = val;
|
|
||||||
emit_changed();
|
|
||||||
output.emit_changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
//size;
|
|
||||||
|
|
||||||
Vector2 SdShapeBox::get_size() {
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SdShapeBox::set_size(const Vector2 &val) {
|
|
||||||
size = val;
|
|
||||||
emit_changed();
|
|
||||||
output.emit_changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
SdShapeBox::SdShapeBox() {
|
|
||||||
output;
|
|
||||||
center = Vector2(0, 0);
|
center = Vector2(0, 0);
|
||||||
size = Vector2(0.3, 0.2);
|
size = Vector2(0.3, 0.2);
|
||||||
}
|
}
|
||||||
|
|
||||||
SdShapeBox::~SdShapeBox() {
|
MMSdShapeBox::~MMSdShapeBox() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMSdShapeBox::_bind_methods() {
|
||||||
|
ClassDB::bind_method(D_METHOD("get_output"), &MMSdShapeBox::get_output);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdShapeBox::set_output);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
|
||||||
|
|
||||||
static void SdShapeBox::_bind_methods() {
|
ClassDB::bind_method(D_METHOD("get_center"), &MMSdShapeBox::get_center);
|
||||||
ClassDB::bind_method(D_METHOD("get_output"), &SdShapeBox::get_output);
|
ClassDB::bind_method(D_METHOD("set_center", "value"), &MMSdShapeBox::set_center);
|
||||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdShapeBox::set_output);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
|
|
||||||
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_center"), &SdShapeBox::get_center);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_center", "value"), &SdShapeBox::set_center);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "center"), "set_center", "get_center");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "center"), "set_center", "get_center");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_size"), &MMSdShapeBox::get_size);
|
||||||
ClassDB::bind_method(D_METHOD("get_size"), &SdShapeBox::get_size);
|
ClassDB::bind_method(D_METHOD("set_size", "value"), &MMSdShapeBox::set_size);
|
||||||
ClassDB::bind_method(D_METHOD("set_size", "value"), &SdShapeBox::set_size);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
|
||||||
|
}
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("_init_properties"), &SdShapeBox::_init_properties);
|
|
||||||
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdShapeBox::_register_methods);
|
|
||||||
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdShapeBox::_get_property_value);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_center"), &SdShapeBox::get_center);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_center", "val"), &SdShapeBox::set_center);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_size"), &SdShapeBox::get_size);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_size", "val"), &SdShapeBox::set_size);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
#ifndef SD_SHAPE_BOX_H
|
#ifndef MM_SD_SHAPE_BOX_H
|
||||||
#define SD_SHAPE_BOX_H
|
#define MM_SD_SHAPE_BOX_H
|
||||||
|
|
||||||
|
#include "../mm_node.h"
|
||||||
|
#include "../mm_node_universal_property.h"
|
||||||
|
|
||||||
class SdShapeBox : public MMNode {
|
class MMSdShapeBox : public MMNode {
|
||||||
GDCLASS(SdShapeBox, MMNode);
|
GDCLASS(MMSdShapeBox, MMNode);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Ref<MMNodeUniversalProperty> get_output();
|
||||||
Ref<Resource> get_output();
|
void set_output(const Ref<MMNodeUniversalProperty> &val);
|
||||||
void set_output(const Ref<Resource> &val);
|
|
||||||
|
|
||||||
Vector2 get_center();
|
Vector2 get_center();
|
||||||
void set_center(const Vector2 &val);
|
void set_center(const Vector2 &val);
|
||||||
@ -17,29 +18,18 @@ class SdShapeBox : public MMNode {
|
|||||||
void set_size(const Vector2 &val);
|
void set_size(const Vector2 &val);
|
||||||
|
|
||||||
void _init_properties();
|
void _init_properties();
|
||||||
void _register_methods(const Variant &mm_graph_node);
|
void _register_methods(MMGraphNode *mm_graph_node);
|
||||||
float _get_property_value(const Vector2 &uv);
|
Variant _get_property_value(const Vector2 &uv);
|
||||||
Vector2 get_center();
|
|
||||||
void set_center(const Vector2 &val);
|
|
||||||
Vector2 get_size();
|
|
||||||
void set_size(const Vector2 &val);
|
|
||||||
|
|
||||||
SdShapeBox();
|
MMSdShapeBox();
|
||||||
~SdShapeBox();
|
~MMSdShapeBox();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
//tool
|
Ref<MMNodeUniversalProperty> output;
|
||||||
//export(Resource)
|
Vector2 center;
|
||||||
Ref<Resource> output;
|
Vector2 size;
|
||||||
//export(Vector2)
|
|
||||||
Vector2 center = Vector2(0, 0);
|
|
||||||
//export(Vector2)
|
|
||||||
Vector2 size = Vector2(0.3, 0.2);
|
|
||||||
//center
|
|
||||||
//size
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,131 +1,79 @@
|
|||||||
|
|
||||||
#include "sd_shape_circle.h"
|
#include "sd_shape_circle.h"
|
||||||
|
|
||||||
|
#include "../../algos/mm_algos.h"
|
||||||
|
#include "../../editor/mm_graph_node.h"
|
||||||
|
#include "../mm_material.h"
|
||||||
|
|
||||||
Ref<Resource> SdShapeCircle::get_output() {
|
Ref<MMNodeUniversalProperty> MMSdShapeCircle::get_output() {
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SdShapeCircle::set_output(const Ref<Resource> &val) {
|
void MMSdShapeCircle::set_output(const Ref<MMNodeUniversalProperty> &val) {
|
||||||
output = val;
|
output = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2 MMSdShapeCircle::get_center() {
|
||||||
Vector2 SdShapeCircle::get_center() {
|
|
||||||
return center;
|
return center;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SdShapeCircle::set_center(const Vector2 &val) {
|
void MMSdShapeCircle::set_center(const Vector2 &val) {
|
||||||
center = val;
|
center = val;
|
||||||
|
emit_changed();
|
||||||
|
output->do_emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float MMSdShapeCircle::get_radius() const {
|
||||||
float SdShapeCircle::get_radius() const {
|
|
||||||
return radius;
|
return radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SdShapeCircle::set_radius(const float val) {
|
void MMSdShapeCircle::set_radius(const float val) {
|
||||||
radius = val;
|
radius = val;
|
||||||
|
emit_changed();
|
||||||
|
output->do_emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMSdShapeCircle::_init_properties() {
|
||||||
|
if (!output.is_valid()) {
|
||||||
|
output.instance();
|
||||||
|
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
|
||||||
|
}
|
||||||
|
|
||||||
|
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_FLOAT);
|
||||||
|
output->set_slot_name(">>> Output >>>");
|
||||||
|
output->set_get_value_from_owner(true);
|
||||||
|
|
||||||
//tool;
|
|
||||||
//export(Resource) ;
|
|
||||||
Ref<Resource> output;
|
|
||||||
//export(Vector2) ;
|
|
||||||
Vector2 center = Vector2(0, 0);
|
|
||||||
//export(float) ;
|
|
||||||
float radius = 0.4;
|
|
||||||
|
|
||||||
void SdShapeCircle::_init_properties() {
|
|
||||||
|
|
||||||
if (!output) {
|
|
||||||
output = MMNodeUniversalProperty.new();
|
|
||||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
|
|
||||||
}
|
|
||||||
|
|
||||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
|
||||||
output.slot_name = ">>> Output >>>";
|
|
||||||
output.get_value_from_owner = true;
|
|
||||||
register_output_property(output);
|
register_output_property(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMSdShapeCircle::_register_methods(MMGraphNode *mm_graph_node) {
|
||||||
void SdShapeCircle::_register_methods(const Variant &mm_graph_node) {
|
mm_graph_node->add_slot_label_universal(output);
|
||||||
mm_graph_node.add_slot_label_universal(output);
|
mm_graph_node->add_slot_vector2("get_center", "set_center", "Center", 0.01);
|
||||||
mm_graph_node.add_slot_vector2("get_center", "set_center", "Center", 0.01);
|
mm_graph_node->add_slot_float("get_radius", "set_radius", "Radius", 0.01);
|
||||||
mm_graph_node.add_slot_float("get_radius", "set_radius", "Radius", 0.01);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Variant MMSdShapeCircle::_get_property_value(const Vector2 &uv) {
|
||||||
float SdShapeCircle::_get_property_value(const Vector2 &uv) {
|
return MMAlgos::sdf_circle(uv, center, radius);
|
||||||
return MMAlgos.sdf_circle(uv, center, radius);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//center;
|
MMSdShapeCircle::MMSdShapeCircle() {
|
||||||
|
|
||||||
Vector2 SdShapeCircle::get_center() {
|
|
||||||
return center;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SdShapeCircle::set_center(const Vector2 &val) {
|
|
||||||
center = val;
|
|
||||||
emit_changed();
|
|
||||||
output.emit_changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
//radius;
|
|
||||||
|
|
||||||
float SdShapeCircle::get_radius() {
|
|
||||||
return radius;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SdShapeCircle::set_radius(const float val) {
|
|
||||||
radius = val;
|
|
||||||
emit_changed();
|
|
||||||
output.emit_changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
SdShapeCircle::SdShapeCircle() {
|
|
||||||
output;
|
|
||||||
center = Vector2(0, 0);
|
center = Vector2(0, 0);
|
||||||
radius = 0.4;
|
radius = 0.4;
|
||||||
}
|
}
|
||||||
|
|
||||||
SdShapeCircle::~SdShapeCircle() {
|
MMSdShapeCircle::~MMSdShapeCircle() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMSdShapeCircle::_bind_methods() {
|
||||||
|
ClassDB::bind_method(D_METHOD("get_output"), &MMSdShapeCircle::get_output);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdShapeCircle::set_output);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
|
||||||
|
|
||||||
static void SdShapeCircle::_bind_methods() {
|
ClassDB::bind_method(D_METHOD("get_center"), &MMSdShapeCircle::get_center);
|
||||||
ClassDB::bind_method(D_METHOD("get_output"), &SdShapeCircle::get_output);
|
ClassDB::bind_method(D_METHOD("set_center", "value"), &MMSdShapeCircle::set_center);
|
||||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdShapeCircle::set_output);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
|
|
||||||
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_center"), &SdShapeCircle::get_center);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_center", "value"), &SdShapeCircle::set_center);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "center"), "set_center", "get_center");
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "center"), "set_center", "get_center");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_radius"), &MMSdShapeCircle::get_radius);
|
||||||
ClassDB::bind_method(D_METHOD("get_radius"), &SdShapeCircle::get_radius);
|
ClassDB::bind_method(D_METHOD("set_radius", "value"), &MMSdShapeCircle::set_radius);
|
||||||
ClassDB::bind_method(D_METHOD("set_radius", "value"), &SdShapeCircle::set_radius);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius");
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius");
|
||||||
|
}
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("_init_properties"), &SdShapeCircle::_init_properties);
|
|
||||||
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdShapeCircle::_register_methods);
|
|
||||||
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdShapeCircle::_get_property_value);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_center"), &SdShapeCircle::get_center);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_center", "val"), &SdShapeCircle::set_center);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_radius"), &SdShapeCircle::get_radius);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_radius", "val"), &SdShapeCircle::set_radius);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
#ifndef SD_SHAPE_CIRCLE_H
|
#ifndef MM_SD_SHAPE_CIRCLE_H
|
||||||
#define SD_SHAPE_CIRCLE_H
|
#define MM_SD_SHAPE_CIRCLE_H
|
||||||
|
|
||||||
|
#include "../mm_node.h"
|
||||||
|
#include "../mm_node_universal_property.h"
|
||||||
|
|
||||||
class SdShapeCircle : public MMNode {
|
class MMSdShapeCircle : public MMNode {
|
||||||
GDCLASS(SdShapeCircle, MMNode);
|
GDCLASS(MMSdShapeCircle, MMNode);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Ref<MMNodeUniversalProperty> get_output();
|
||||||
Ref<Resource> get_output();
|
void set_output(const Ref<MMNodeUniversalProperty> &val);
|
||||||
void set_output(const Ref<Resource> &val);
|
|
||||||
|
|
||||||
Vector2 get_center();
|
Vector2 get_center();
|
||||||
void set_center(const Vector2 &val);
|
void set_center(const Vector2 &val);
|
||||||
@ -17,29 +18,18 @@ class SdShapeCircle : public MMNode {
|
|||||||
void set_radius(const float val);
|
void set_radius(const float val);
|
||||||
|
|
||||||
void _init_properties();
|
void _init_properties();
|
||||||
void _register_methods(const Variant &mm_graph_node);
|
void _register_methods(MMGraphNode *mm_graph_node);
|
||||||
float _get_property_value(const Vector2 &uv);
|
Variant _get_property_value(const Vector2 &uv);
|
||||||
Vector2 get_center();
|
|
||||||
void set_center(const Vector2 &val);
|
|
||||||
float get_radius();
|
|
||||||
void set_radius(const float val);
|
|
||||||
|
|
||||||
SdShapeCircle();
|
MMSdShapeCircle();
|
||||||
~SdShapeCircle();
|
~MMSdShapeCircle();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
//tool
|
Ref<MMNodeUniversalProperty> output;
|
||||||
//export(Resource)
|
Vector2 center;
|
||||||
Ref<Resource> output;
|
float radius;
|
||||||
//export(Vector2)
|
|
||||||
Vector2 center = Vector2(0, 0);
|
|
||||||
//export(float)
|
|
||||||
float radius = 0.4;
|
|
||||||
//center
|
|
||||||
//radius
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,180 +1,111 @@
|
|||||||
|
|
||||||
#include "sd_shape_line.h"
|
#include "sd_shape_line.h"
|
||||||
|
|
||||||
|
#include "../../algos/mm_algos.h"
|
||||||
|
#include "../../editor/mm_graph_node.h"
|
||||||
|
#include "../mm_material.h"
|
||||||
|
|
||||||
Ref<Resource> SdShapeLine::get_output() {
|
Ref<MMNodeUniversalProperty> MMSdShapeLine::get_output() {
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SdShapeLine::set_output(const Ref<Resource> &val) {
|
void MMSdShapeLine::set_output(const Ref<MMNodeUniversalProperty> &val) {
|
||||||
output = val;
|
output = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2 MMSdShapeLine::get_a() {
|
||||||
Vector2 SdShapeLine::get_A() {
|
|
||||||
return A;
|
return A;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SdShapeLine::set_A(const Vector2 &val) {
|
void MMSdShapeLine::set_a(const Vector2 &val) {
|
||||||
A = val;
|
A = val;
|
||||||
|
emit_changed();
|
||||||
|
output->do_emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2 MMSdShapeLine::get_b() {
|
||||||
Vector2 SdShapeLine::get_B() {
|
|
||||||
return B;
|
return B;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SdShapeLine::set_B(const Vector2 &val) {
|
void MMSdShapeLine::set_b(const Vector2 &val) {
|
||||||
B = val;
|
B = val;
|
||||||
|
emit_changed();
|
||||||
|
output->do_emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float MMSdShapeLine::get_width() const {
|
||||||
float SdShapeLine::get_width() const {
|
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SdShapeLine::set_width(const float val) {
|
void MMSdShapeLine::set_width(const float val) {
|
||||||
width = val;
|
width = val;
|
||||||
|
emit_changed();
|
||||||
|
output->do_emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMSdShapeLine::_init_properties() {
|
||||||
|
if (!output.is_valid()) {
|
||||||
|
output.instance();
|
||||||
|
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
|
||||||
|
}
|
||||||
|
|
||||||
|
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_FLOAT);
|
||||||
|
output->set_slot_name(">>> Output >>>");
|
||||||
|
output->set_get_value_from_owner(true);
|
||||||
|
|
||||||
//tool;
|
|
||||||
//export(Resource) ;
|
|
||||||
Ref<Resource> output;
|
|
||||||
//export(Vector2) ;
|
|
||||||
Vector2 A = Vector2(-0.3, -0.3);
|
|
||||||
//export(Vector2) ;
|
|
||||||
Vector2 B = Vector2(0.3, 0.3);
|
|
||||||
//export(float) ;
|
|
||||||
float width = 0.1;
|
|
||||||
|
|
||||||
void SdShapeLine::_init() {
|
|
||||||
init_points_11();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SdShapeLine::_init_properties() {
|
|
||||||
|
|
||||||
if (!output) {
|
|
||||||
output = MMNodeUniversalProperty.new();
|
|
||||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
|
|
||||||
}
|
|
||||||
|
|
||||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
|
||||||
output.slot_name = ">>> Output >>>";
|
|
||||||
output.get_value_from_owner = true;
|
|
||||||
register_output_property(output);
|
register_output_property(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMSdShapeLine::_register_methods(MMGraphNode *mm_graph_node) {
|
||||||
void SdShapeLine::_register_methods(const Variant &mm_graph_node) {
|
mm_graph_node->add_slot_label_universal(output);
|
||||||
mm_graph_node.add_slot_label_universal(output);
|
mm_graph_node->add_slot_vector2("get_a", "set_a", "A", 0.01);
|
||||||
mm_graph_node.add_slot_vector2("get_a", "set_a", "A", 0.01);
|
mm_graph_node->add_slot_vector2("get_b", "set_b", "B", 0.01);
|
||||||
mm_graph_node.add_slot_vector2("get_b", "set_b", "B", 0.01);
|
mm_graph_node->add_slot_float("get_width", "set_width", "Width", 0.01);
|
||||||
mm_graph_node.add_slot_float("get_width", "set_width", "Width", 0.01);
|
mm_graph_node->add_slot_curve();
|
||||||
mm_graph_node.add_slot_curve();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Variant MMSdShapeLine::_get_property_value(const Vector2 &uv) {
|
||||||
float SdShapeLine::_get_property_value(const Vector2 &uv) {
|
Vector2 line = MMAlgos::sdf_line(uv, A, B, width);
|
||||||
Vector2 line = MMAlgos.sdf_line(uv, A, B, width);
|
|
||||||
//$(name_uv)_sdl.x - $r * $profile($(name_uv)_sdl.y);
|
//$(name_uv)_sdl.x - $r * $profile($(name_uv)_sdl.y);
|
||||||
return line.x - width * MMAlgos.curve(line.y, points_array);
|
return line.x - width * MMAlgos::curve(line.y, points);
|
||||||
}
|
}
|
||||||
|
|
||||||
//a;
|
void MMSdShapeLine::_curve_changed() {
|
||||||
|
|
||||||
Vector2 SdShapeLine::get_a() {
|
|
||||||
return A;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SdShapeLine::set_a(const Vector2 &val) {
|
|
||||||
A = val;
|
|
||||||
emit_changed();
|
emit_changed();
|
||||||
output.emit_changed();
|
output->do_emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
//b;
|
MMSdShapeLine::MMSdShapeLine() {
|
||||||
|
|
||||||
Vector2 SdShapeLine::get_b() {
|
|
||||||
return B;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SdShapeLine::set_b(const Vector2 &val) {
|
|
||||||
B = val;
|
|
||||||
emit_changed();
|
|
||||||
output.emit_changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
//width;
|
|
||||||
|
|
||||||
float SdShapeLine::get_width() {
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SdShapeLine::set_width(const float val) {
|
|
||||||
width = val;
|
|
||||||
emit_changed();
|
|
||||||
output.emit_changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SdShapeLine::_curve_changed() {
|
|
||||||
emit_changed();
|
|
||||||
output.emit_changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
SdShapeLine::SdShapeLine() {
|
|
||||||
output;
|
|
||||||
A = Vector2(-0.3, -0.3);
|
A = Vector2(-0.3, -0.3);
|
||||||
B = Vector2(0.3, 0.3);
|
B = Vector2(0.3, 0.3);
|
||||||
width = 0.1;
|
width = 0.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
MMSdShapeLine::~MMSdShapeLine() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void MMSdShapeLine::_notification(int p_what) {
|
||||||
|
if (p_what == NOTIFICATION_POSTINITIALIZE) {
|
||||||
|
if (points.size() == 0) {
|
||||||
|
init_points_11();
|
||||||
}
|
}
|
||||||
|
|
||||||
SdShapeLine::~SdShapeLine() {
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MMSdShapeLine::_bind_methods() {
|
||||||
|
ClassDB::bind_method(D_METHOD("get_output"), &MMSdShapeLine::get_output);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdShapeLine::set_output);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
|
||||||
|
|
||||||
static void SdShapeLine::_bind_methods() {
|
ClassDB::bind_method(D_METHOD("get_a"), &MMSdShapeLine::get_a);
|
||||||
ClassDB::bind_method(D_METHOD("get_output"), &SdShapeLine::get_output);
|
ClassDB::bind_method(D_METHOD("set_a", "value"), &MMSdShapeLine::set_a);
|
||||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdShapeLine::set_output);
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "A"), "set_a", "get_a");
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
|
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_b"), &MMSdShapeLine::get_b);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_b", "value"), &MMSdShapeLine::set_b);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "B"), "set_b", "get_b");
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_A"), &SdShapeLine::get_A);
|
ClassDB::bind_method(D_METHOD("get_width"), &MMSdShapeLine::get_width);
|
||||||
ClassDB::bind_method(D_METHOD("set_A", "value"), &SdShapeLine::set_A);
|
ClassDB::bind_method(D_METHOD("set_width", "value"), &MMSdShapeLine::set_width);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "A"), "set_A", "get_A");
|
|
||||||
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_B"), &SdShapeLine::get_B);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_B", "value"), &SdShapeLine::set_B);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "B"), "set_B", "get_B");
|
|
||||||
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_width"), &SdShapeLine::get_width);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_width", "value"), &SdShapeLine::set_width);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::REAL, "width"), "set_width", "get_width");
|
ADD_PROPERTY(PropertyInfo(Variant::REAL, "width"), "set_width", "get_width");
|
||||||
|
}
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("_init"), &SdShapeLine::_init);
|
|
||||||
ClassDB::bind_method(D_METHOD("_init_properties"), &SdShapeLine::_init_properties);
|
|
||||||
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdShapeLine::_register_methods);
|
|
||||||
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdShapeLine::_get_property_value);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_a"), &SdShapeLine::get_a);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_a", "val"), &SdShapeLine::set_a);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_b"), &SdShapeLine::get_b);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_b", "val"), &SdShapeLine::set_b);
|
|
||||||
ClassDB::bind_method(D_METHOD("get_width"), &SdShapeLine::get_width);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_width", "val"), &SdShapeLine::set_width);
|
|
||||||
ClassDB::bind_method(D_METHOD("_curve_changed"), &SdShapeLine::_curve_changed);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,55 +1,43 @@
|
|||||||
#ifndef SD_SHAPE_LINE_H
|
#ifndef MM_SD_SHAPE_LINE_H
|
||||||
#define SD_SHAPE_LINE_H
|
#define MM_SD_SHAPE_LINE_H
|
||||||
|
|
||||||
|
#include "../bases/curve_base.h"
|
||||||
|
#include "../mm_node_universal_property.h"
|
||||||
|
|
||||||
class SdShapeLine : public CurveBase {
|
class MMSdShapeLine : public CurveBase {
|
||||||
GDCLASS(SdShapeLine, CurveBase);
|
GDCLASS(MMSdShapeLine, CurveBase);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Ref<MMNodeUniversalProperty> get_output();
|
||||||
|
void set_output(const Ref<MMNodeUniversalProperty> &val);
|
||||||
|
|
||||||
Ref<Resource> get_output();
|
Vector2 get_a();
|
||||||
void set_output(const Ref<Resource> &val);
|
void set_a(const Vector2 &val);
|
||||||
|
|
||||||
Vector2 get_A();
|
Vector2 get_b();
|
||||||
void set_A(const Vector2 &val);
|
void set_b(const Vector2 &val);
|
||||||
|
|
||||||
Vector2 get_B();
|
|
||||||
void set_B(const Vector2 &val);
|
|
||||||
|
|
||||||
float get_width() const;
|
float get_width() const;
|
||||||
void set_width(const float val);
|
void set_width(const float val);
|
||||||
|
|
||||||
void _init();
|
|
||||||
void _init_properties();
|
void _init_properties();
|
||||||
void _register_methods(const Variant &mm_graph_node);
|
void _register_methods(MMGraphNode *mm_graph_node);
|
||||||
float _get_property_value(const Vector2 &uv);
|
Variant _get_property_value(const Vector2 &uv);
|
||||||
Vector2 get_a();
|
|
||||||
void set_a(const Vector2 &val);
|
|
||||||
Vector2 get_b();
|
|
||||||
void set_b(const Vector2 &val);
|
|
||||||
float get_width();
|
|
||||||
void set_width(const float val);
|
|
||||||
void _curve_changed();
|
void _curve_changed();
|
||||||
|
|
||||||
SdShapeLine();
|
MMSdShapeLine();
|
||||||
~SdShapeLine();
|
~MMSdShapeLine();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void _notification(int p_what);
|
||||||
|
|
||||||
protected:
|
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
//tool
|
Ref<MMNodeUniversalProperty> output;
|
||||||
//export(Resource)
|
Vector2 A;
|
||||||
Ref<Resource> output;
|
Vector2 B;
|
||||||
//export(Vector2)
|
float width;
|
||||||
Vector2 A = Vector2(-0.3, -0.3);
|
|
||||||
//export(Vector2)
|
|
||||||
Vector2 B = Vector2(0.3, 0.3);
|
|
||||||
//export(float)
|
|
||||||
float width = 0.1;
|
|
||||||
//a
|
|
||||||
//b
|
|
||||||
//width
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,73 +1,53 @@
|
|||||||
|
|
||||||
#include "sd_shape_polygon.h"
|
#include "sd_shape_polygon.h"
|
||||||
|
|
||||||
|
#include "../../algos/mm_algos.h"
|
||||||
|
#include "../../editor/mm_graph_node.h"
|
||||||
|
#include "../mm_material.h"
|
||||||
|
|
||||||
Ref<Resource> SdShapePolygon::get_output() {
|
Ref<MMNodeUniversalProperty> MMSdShapePolygon::get_output() {
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SdShapePolygon::set_output(const Ref<Resource> &val) {
|
void MMSdShapePolygon::set_output(const Ref<MMNodeUniversalProperty> &val) {
|
||||||
output = val;
|
output = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMSdShapePolygon::_init_properties() {
|
||||||
|
if (!output.is_valid()) {
|
||||||
|
output.instance();
|
||||||
|
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
|
||||||
|
}
|
||||||
|
|
||||||
|
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_FLOAT);
|
||||||
|
output->set_slot_name(">>> Output >>>");
|
||||||
|
output->set_get_value_from_owner(true);
|
||||||
|
|
||||||
//tool;
|
|
||||||
//export(Resource) ;
|
|
||||||
Ref<Resource> output;
|
|
||||||
|
|
||||||
void SdShapePolygon::_init_properties() {
|
|
||||||
|
|
||||||
if (!output) {
|
|
||||||
output = MMNodeUniversalProperty.new();
|
|
||||||
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
|
|
||||||
}
|
|
||||||
|
|
||||||
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
|
|
||||||
output.slot_name = ">>> Output >>>";
|
|
||||||
output.get_value_from_owner = true;
|
|
||||||
register_output_property(output);
|
register_output_property(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMSdShapePolygon::_register_methods(MMGraphNode *mm_graph_node) {
|
||||||
void SdShapePolygon::_register_methods(const Variant &mm_graph_node) {
|
mm_graph_node->add_slot_label_universal(output);
|
||||||
mm_graph_node.add_slot_label_universal(output);
|
mm_graph_node->add_slot_polygon();
|
||||||
mm_graph_node.add_slot_polygon();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Variant MMSdShapePolygon::_get_property_value(const Vector2 &uv) {
|
||||||
float SdShapePolygon::_get_property_value(const Vector2 &uv) {
|
return MMAlgos::sdPolygon(uv, points);
|
||||||
return MMAlgos.sdPolygon(uv, points);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MMSdShapePolygon::_polygon_changed() {
|
||||||
void SdShapePolygon::_polygon_changed() {
|
|
||||||
emit_changed();
|
emit_changed();
|
||||||
output.emit_changed();
|
output->do_emit_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MMSdShapePolygon::MMSdShapePolygon() {
|
||||||
}
|
}
|
||||||
|
|
||||||
SdShapePolygon::SdShapePolygon() {
|
MMSdShapePolygon::~MMSdShapePolygon() {
|
||||||
output;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
SdShapePolygon::~SdShapePolygon() {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void SdShapePolygon::_bind_methods() {
|
|
||||||
ClassDB::bind_method(D_METHOD("get_output"), &SdShapePolygon::get_output);
|
|
||||||
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdShapePolygon::set_output);
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
|
|
||||||
|
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("_init_properties"), &SdShapePolygon::_init_properties);
|
|
||||||
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdShapePolygon::_register_methods);
|
|
||||||
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdShapePolygon::_get_property_value);
|
|
||||||
ClassDB::bind_method(D_METHOD("_polygon_changed"), &SdShapePolygon::_polygon_changed);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void MMSdShapePolygon::_bind_methods() {
|
||||||
|
ClassDB::bind_method(D_METHOD("get_output"), &MMSdShapePolygon::get_output);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdShapePolygon::set_output);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
|
||||||
|
}
|
||||||
|
@ -1,30 +1,29 @@
|
|||||||
#ifndef SD_SHAPE_POLYGON_H
|
#ifndef MM_SD_SHAPE_POLYGON_H
|
||||||
#define SD_SHAPE_POLYGON_H
|
#define MM_SD_SHAPE_POLYGON_H
|
||||||
|
|
||||||
|
#include "../bases/polygon_base.h"
|
||||||
|
#include "../mm_node_universal_property.h"
|
||||||
|
|
||||||
class SdShapePolygon : public PolygonBase {
|
class MMSdShapePolygon : public PolygonBase {
|
||||||
GDCLASS(SdShapePolygon, PolygonBase);
|
GDCLASS(MMSdShapePolygon, PolygonBase);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Ref<MMNodeUniversalProperty> get_output();
|
||||||
Ref<Resource> get_output();
|
void set_output(const Ref<MMNodeUniversalProperty> &val);
|
||||||
void set_output(const Ref<Resource> &val);
|
|
||||||
|
|
||||||
void _init_properties();
|
void _init_properties();
|
||||||
void _register_methods(const Variant &mm_graph_node);
|
void _register_methods(MMGraphNode *mm_graph_node);
|
||||||
float _get_property_value(const Vector2 &uv);
|
Variant _get_property_value(const Vector2 &uv);
|
||||||
|
|
||||||
void _polygon_changed();
|
void _polygon_changed();
|
||||||
|
|
||||||
SdShapePolygon();
|
MMSdShapePolygon();
|
||||||
~SdShapePolygon();
|
~MMSdShapePolygon();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
//tool
|
Ref<MMNodeUniversalProperty> output;
|
||||||
//export(Resource)
|
|
||||||
Ref<Resource> output;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef SD_TF_ROTATE_H
|
#ifndef MM_SD_TF_ROTATE_H
|
||||||
#define SD_TF_ROTATE_H
|
#define MM_SD_TF_ROTATE_H
|
||||||
|
|
||||||
#include "../mm_node.h"
|
#include "../mm_node.h"
|
||||||
#include "../mm_node_universal_property.h"
|
#include "../mm_node_universal_property.h"
|
||||||
|
@ -84,6 +84,11 @@ SOFTWARE.
|
|||||||
#include "nodes/sdf3d/sdf3d_op_rounded.h"
|
#include "nodes/sdf3d/sdf3d_op_rounded.h"
|
||||||
#include "nodes/sdf3d/sdf3d_op_smooth_bool.h"
|
#include "nodes/sdf3d/sdf3d_op_smooth_bool.h"
|
||||||
|
|
||||||
|
#include "nodes/sdf2d/sd_shape_arc.h"
|
||||||
|
#include "nodes/sdf2d/sd_shape_box.h"
|
||||||
|
#include "nodes/sdf2d/sd_shape_circle.h"
|
||||||
|
#include "nodes/sdf2d/sd_shape_line.h"
|
||||||
|
#include "nodes/sdf2d/sd_shape_polygon.h"
|
||||||
#include "nodes/sdf2d/sd_shape_rhombus.h"
|
#include "nodes/sdf2d/sd_shape_rhombus.h"
|
||||||
|
|
||||||
#include "nodes/sdf2d/sd_tf_rotate.h"
|
#include "nodes/sdf2d/sd_tf_rotate.h"
|
||||||
@ -190,6 +195,16 @@ void register_material_maker_types() {
|
|||||||
|
|
||||||
ClassDB::register_class<MMSdShapeRhombus>();
|
ClassDB::register_class<MMSdShapeRhombus>();
|
||||||
MMAlgos::register_node_class("SDF2D - Shape", "MMSdShapeRhombus");
|
MMAlgos::register_node_class("SDF2D - Shape", "MMSdShapeRhombus");
|
||||||
|
ClassDB::register_class<MMSdShapePolygon>();
|
||||||
|
MMAlgos::register_node_class("SDF2D - Shape", "MMSdShapePolygon");
|
||||||
|
ClassDB::register_class<MMSdShapeLine>();
|
||||||
|
MMAlgos::register_node_class("SDF2D - Shape", "MMSdShapeLine");
|
||||||
|
ClassDB::register_class<MMSdShapeCircle>();
|
||||||
|
MMAlgos::register_node_class("SDF2D - Shape", "MMSdShapeCircle");
|
||||||
|
ClassDB::register_class<MMSdShapeBox>();
|
||||||
|
MMAlgos::register_node_class("SDF2D - Shape", "MMSdShapeBox");
|
||||||
|
ClassDB::register_class<MMSdShapeArc>();
|
||||||
|
MMAlgos::register_node_class("SDF2D - Shape", "MMSdShapeArc");
|
||||||
|
|
||||||
ClassDB::register_class<MMSdTfTranslate>();
|
ClassDB::register_class<MMSdTfTranslate>();
|
||||||
MMAlgos::register_node_class("SDF2D - TF", "MMSdTfTranslate");
|
MMAlgos::register_node_class("SDF2D - TF", "MMSdTfTranslate");
|
||||||
|
Loading…
Reference in New Issue
Block a user