Cleaned up the rest of the SDShapes.

This commit is contained in:
Relintai 2022-06-17 19:58:57 +02:00
parent d339fb1fdb
commit f2fb6b8b7d
14 changed files with 409 additions and 693 deletions

View File

@ -93,6 +93,11 @@ sources = [
"nodes/sdf3d/sdf3d_op_bool.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_scale.cpp",

View File

@ -69,6 +69,11 @@ def get_doc_classes():
"MMSdTfRotate",
"MMSdShapeRhombus",
"MMSdShapePolygon",
"MMSdShapeLine",
"MMSdShapeCircle",
"MMSdShapeBox",
"MMSdShapeArc",
]
def get_doc_path():

View File

@ -1,164 +1,95 @@
#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() {
return output;
Ref<MMNodeUniversalProperty> MMSdShapeArc::get_output() {
return output;
}
void SdShapeArc::set_output(const Ref<Resource> &val) {
output = val;
void MMSdShapeArc::set_output(const Ref<MMNodeUniversalProperty> &val) {
output = val;
}
Vector2 SdShapeArc::get_angle() {
return angle;
Vector2 MMSdShapeArc::get_angle() {
return angle;
}
void SdShapeArc::set_angle(const Vector2 &val) {
angle = val;
void MMSdShapeArc::set_angle(const Vector2 &val) {
angle = val;
emit_changed();
output->do_emit_changed();
}
float SdShapeArc::get_radius() const {
return radius;
float MMSdShapeArc::get_radius() const {
return radius;
}
void SdShapeArc::set_radius(const float val) {
radius = val;
void MMSdShapeArc::set_radius(const float val) {
radius = val;
emit_changed();
output->do_emit_changed();
}
float SdShapeArc::get_width() const {
return width;
float MMSdShapeArc::get_width() const {
return width;
}
void SdShapeArc::set_width(const float val) {
width = val;
void MMSdShapeArc::set_width(const float 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;
register_output_property(output);
}
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = ">>> Output >>>";
output.get_value_from_owner = true;
register_output_property(output);
void MMSdShapeArc::_register_methods(MMGraphNode *mm_graph_node) {
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_float("get_radius", "set_radius", "Radius", 0.01);
mm_graph_node->add_slot_float("get_width", "set_width", "Width", 0.01);
}
void SdShapeArc::_register_methods(const Variant &mm_graph_node) {
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_float("get_radius", "set_radius", "Radius", 0.01);
mm_graph_node.add_slot_float("get_width", "set_width", "Width", 0.01);
Variant MMSdShapeArc::_get_property_value(const Vector2 &uv) {
return MMAlgos::sdf_arc(uv, angle, Vector2(radius, width));
}
float SdShapeArc::_get_property_value(const Vector2 &uv) {
return MMAlgos.sdf_arc(uv, angle, Vector2(radius, width));
MMSdShapeArc::MMSdShapeArc() {
angle = Vector2(30, 150);
radius = 0.3;
width = 0.1;
}
//angle;
Vector2 SdShapeArc::get_angle() {
return angle;
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");
void SdShapeArc::set_angle(const Vector2 &val) {
angle = val;
emit_changed();
output.emit_changed();
ClassDB::bind_method(D_METHOD("get_angle"), &MMSdShapeArc::get_angle);
ClassDB::bind_method(D_METHOD("set_angle", "value"), &MMSdShapeArc::set_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("set_radius", "value"), &MMSdShapeArc::set_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("set_width", "value"), &MMSdShapeArc::set_width);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "width"), "set_width", "get_width");
}
//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);
radius = 0.3;
width = 0.1;
}
SdShapeArc::~SdShapeArc() {
}
static void SdShapeArc::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &SdShapeArc::get_output);
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");
ClassDB::bind_method(D_METHOD("get_radius"), &SdShapeArc::get_radius);
ClassDB::bind_method(D_METHOD("set_radius", "value"), &SdShapeArc::set_radius);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius");
ClassDB::bind_method(D_METHOD("get_width"), &SdShapeArc::get_width);
ClassDB::bind_method(D_METHOD("set_width", "value"), &SdShapeArc::set_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);
}

View File

@ -1,53 +1,39 @@
#ifndef SD_SHAPE_ARC_H
#define SD_SHAPE_ARC_H
#ifndef MM_SD_SHAPE_ARC_H
#define MM_SD_SHAPE_ARC_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class SdShapeArc : public MMNode {
GDCLASS(SdShapeArc, MMNode);
class MMSdShapeArc : public MMNode {
GDCLASS(MMSdShapeArc, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_output();
void set_output(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
Vector2 get_angle();
void set_angle(const Vector2 &val);
Vector2 get_angle();
void set_angle(const Vector2 &val);
float get_radius() const;
void set_radius(const float val);
float get_radius() const;
void set_radius(const float val);
float get_width() const;
void set_width(const float val);
float get_width() const;
void set_width(const float val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
Variant _get_property_value(const Vector2 &uv);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
float _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);
MMSdShapeArc();
~MMSdShapeArc();
SdShapeArc();
~SdShapeArc();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//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;
//angle
//radius
//width
Ref<MMNodeUniversalProperty> output;
Vector2 angle;
float radius;
float width;
};
#endif

View File

@ -1,131 +1,79 @@
#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() {
return output;
Ref<MMNodeUniversalProperty> MMSdShapeBox::get_output() {
return output;
}
void SdShapeBox::set_output(const Ref<Resource> &val) {
output = val;
void MMSdShapeBox::set_output(const Ref<MMNodeUniversalProperty> &val) {
output = val;
}
Vector2 SdShapeBox::get_center() {
return center;
Vector2 MMSdShapeBox::get_center() {
return center;
}
void SdShapeBox::set_center(const Vector2 &val) {
center = val;
void MMSdShapeBox::set_center(const Vector2 &val) {
center = val;
emit_changed();
output->do_emit_changed();
}
Vector2 SdShapeBox::get_size() {
return size;
Vector2 MMSdShapeBox::get_size() {
return size;
}
void SdShapeBox::set_size(const Vector2 &val) {
size = val;
void MMSdShapeBox::set_size(const Vector2 &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;
register_output_property(output);
}
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = ">>> Output >>>";
output.get_value_from_owner = true;
register_output_property(output);
void MMSdShapeBox::_register_methods(MMGraphNode *mm_graph_node) {
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_size", "set_size", "Size", 0.01);
}
void SdShapeBox::_register_methods(const Variant &mm_graph_node) {
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_size", "set_size", "Size", 0.01);
Variant MMSdShapeBox::_get_property_value(const Vector2 &uv) {
return MMAlgos::sdf_box(uv, center, size);
}
float SdShapeBox::_get_property_value(const Vector2 &uv) {
return MMAlgos.sdf_box(uv, center, size);
MMSdShapeBox::MMSdShapeBox() {
center = Vector2(0, 0);
size = Vector2(0.3, 0.2);
}
//center;
Vector2 SdShapeBox::get_center() {
return center;
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");
void SdShapeBox::set_center(const Vector2 &val) {
center = val;
emit_changed();
output.emit_changed();
ClassDB::bind_method(D_METHOD("get_center"), &MMSdShapeBox::get_center);
ClassDB::bind_method(D_METHOD("set_center", "value"), &MMSdShapeBox::set_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("set_size", "value"), &MMSdShapeBox::set_size);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
}
//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);
size = Vector2(0.3, 0.2);
}
SdShapeBox::~SdShapeBox() {
}
static void SdShapeBox::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &SdShapeBox::get_output);
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");
ClassDB::bind_method(D_METHOD("get_size"), &SdShapeBox::get_size);
ClassDB::bind_method(D_METHOD("set_size", "value"), &SdShapeBox::set_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);
}

View File

@ -1,45 +1,35 @@
#ifndef SD_SHAPE_BOX_H
#define SD_SHAPE_BOX_H
#ifndef MM_SD_SHAPE_BOX_H
#define MM_SD_SHAPE_BOX_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class SdShapeBox : public MMNode {
GDCLASS(SdShapeBox, MMNode);
class MMSdShapeBox : public MMNode {
GDCLASS(MMSdShapeBox, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_output();
void set_output(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
Vector2 get_center();
void set_center(const Vector2 &val);
Vector2 get_center();
void set_center(const Vector2 &val);
Vector2 get_size();
void set_size(const Vector2 &val);
Vector2 get_size();
void set_size(const Vector2 &val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
Variant _get_property_value(const Vector2 &uv);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
float _get_property_value(const Vector2 &uv);
Vector2 get_center();
void set_center(const Vector2 &val);
Vector2 get_size();
void set_size(const Vector2 &val);
MMSdShapeBox();
~MMSdShapeBox();
SdShapeBox();
~SdShapeBox();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> output;
//export(Vector2)
Vector2 center = Vector2(0, 0);
//export(Vector2)
Vector2 size = Vector2(0.3, 0.2);
//center
//size
Ref<MMNodeUniversalProperty> output;
Vector2 center;
Vector2 size;
};
#endif

View File

@ -1,131 +1,79 @@
#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() {
return output;
Ref<MMNodeUniversalProperty> MMSdShapeCircle::get_output() {
return output;
}
void SdShapeCircle::set_output(const Ref<Resource> &val) {
output = val;
void MMSdShapeCircle::set_output(const Ref<MMNodeUniversalProperty> &val) {
output = val;
}
Vector2 SdShapeCircle::get_center() {
return center;
Vector2 MMSdShapeCircle::get_center() {
return center;
}
void SdShapeCircle::set_center(const Vector2 &val) {
center = val;
void MMSdShapeCircle::set_center(const Vector2 &val) {
center = val;
emit_changed();
output->do_emit_changed();
}
float SdShapeCircle::get_radius() const {
return radius;
float MMSdShapeCircle::get_radius() const {
return radius;
}
void SdShapeCircle::set_radius(const float val) {
radius = val;
void MMSdShapeCircle::set_radius(const float 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;
register_output_property(output);
}
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = ">>> Output >>>";
output.get_value_from_owner = true;
register_output_property(output);
void MMSdShapeCircle::_register_methods(MMGraphNode *mm_graph_node) {
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_float("get_radius", "set_radius", "Radius", 0.01);
}
void SdShapeCircle::_register_methods(const Variant &mm_graph_node) {
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_float("get_radius", "set_radius", "Radius", 0.01);
Variant MMSdShapeCircle::_get_property_value(const Vector2 &uv) {
return MMAlgos::sdf_circle(uv, center, radius);
}
float SdShapeCircle::_get_property_value(const Vector2 &uv) {
return MMAlgos.sdf_circle(uv, center, radius);
MMSdShapeCircle::MMSdShapeCircle() {
center = Vector2(0, 0);
radius = 0.4;
}
//center;
Vector2 SdShapeCircle::get_center() {
return center;
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");
void SdShapeCircle::set_center(const Vector2 &val) {
center = val;
emit_changed();
output.emit_changed();
ClassDB::bind_method(D_METHOD("get_center"), &MMSdShapeCircle::get_center);
ClassDB::bind_method(D_METHOD("set_center", "value"), &MMSdShapeCircle::set_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("set_radius", "value"), &MMSdShapeCircle::set_radius);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius");
}
//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);
radius = 0.4;
}
SdShapeCircle::~SdShapeCircle() {
}
static void SdShapeCircle::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &SdShapeCircle::get_output);
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");
ClassDB::bind_method(D_METHOD("get_radius"), &SdShapeCircle::get_radius);
ClassDB::bind_method(D_METHOD("set_radius", "value"), &SdShapeCircle::set_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);
}

View File

@ -1,45 +1,35 @@
#ifndef SD_SHAPE_CIRCLE_H
#define SD_SHAPE_CIRCLE_H
#ifndef MM_SD_SHAPE_CIRCLE_H
#define MM_SD_SHAPE_CIRCLE_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class SdShapeCircle : public MMNode {
GDCLASS(SdShapeCircle, MMNode);
class MMSdShapeCircle : public MMNode {
GDCLASS(MMSdShapeCircle, MMNode);
public:
public:
Ref<MMNodeUniversalProperty> get_output();
void set_output(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
Vector2 get_center();
void set_center(const Vector2 &val);
Vector2 get_center();
void set_center(const Vector2 &val);
float get_radius() const;
void set_radius(const float val);
float get_radius() const;
void set_radius(const float val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
Variant _get_property_value(const Vector2 &uv);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
float _get_property_value(const Vector2 &uv);
Vector2 get_center();
void set_center(const Vector2 &val);
float get_radius();
void set_radius(const float val);
MMSdShapeCircle();
~MMSdShapeCircle();
SdShapeCircle();
~SdShapeCircle();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> output;
//export(Vector2)
Vector2 center = Vector2(0, 0);
//export(float)
float radius = 0.4;
//center
//radius
Ref<MMNodeUniversalProperty> output;
Vector2 center;
float radius;
};
#endif

View File

@ -1,180 +1,111 @@
#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() {
return output;
Ref<MMNodeUniversalProperty> MMSdShapeLine::get_output() {
return output;
}
void SdShapeLine::set_output(const Ref<Resource> &val) {
output = val;
void MMSdShapeLine::set_output(const Ref<MMNodeUniversalProperty> &val) {
output = val;
}
Vector2 SdShapeLine::get_A() {
return A;
Vector2 MMSdShapeLine::get_a() {
return A;
}
void SdShapeLine::set_A(const Vector2 &val) {
A = val;
void MMSdShapeLine::set_a(const Vector2 &val) {
A = val;
emit_changed();
output->do_emit_changed();
}
Vector2 SdShapeLine::get_B() {
return B;
Vector2 MMSdShapeLine::get_b() {
return B;
}
void SdShapeLine::set_B(const Vector2 &val) {
B = val;
void MMSdShapeLine::set_b(const Vector2 &val) {
B = val;
emit_changed();
output->do_emit_changed();
}
float SdShapeLine::get_width() const {
return width;
float MMSdShapeLine::get_width() const {
return width;
}
void SdShapeLine::set_width(const float val) {
width = val;
void MMSdShapeLine::set_width(const float 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();
register_output_property(output);
}
void SdShapeLine::_init_properties() {
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
void MMSdShapeLine::_register_methods(MMGraphNode *mm_graph_node) {
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_b", "set_b", "B", 0.01);
mm_graph_node->add_slot_float("get_width", "set_width", "Width", 0.01);
mm_graph_node->add_slot_curve();
}
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = ">>> Output >>>";
output.get_value_from_owner = true;
register_output_property(output);
Variant MMSdShapeLine::_get_property_value(const Vector2 &uv) {
Vector2 line = MMAlgos::sdf_line(uv, A, B, width);
//$(name_uv)_sdl.x - $r * $profile($(name_uv)_sdl.y);
return line.x - width * MMAlgos::curve(line.y, points);
}
void SdShapeLine::_register_methods(const Variant &mm_graph_node) {
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_b", "set_b", "B", 0.01);
mm_graph_node.add_slot_float("get_width", "set_width", "Width", 0.01);
mm_graph_node.add_slot_curve();
void MMSdShapeLine::_curve_changed() {
emit_changed();
output->do_emit_changed();
}
float SdShapeLine::_get_property_value(const Vector2 &uv) {
Vector2 line = MMAlgos.sdf_line(uv, A, B, width);
//$(name_uv)_sdl.x - $r * $profile($(name_uv)_sdl.y);
return line.x - width * MMAlgos.curve(line.y, points_array);
MMSdShapeLine::MMSdShapeLine() {
A = Vector2(-0.3, -0.3);
B = Vector2(0.3, 0.3);
width = 0.1;
}
//a;
Vector2 SdShapeLine::get_a() {
return A;
MMSdShapeLine::~MMSdShapeLine() {
}
void SdShapeLine::set_a(const Vector2 &val) {
A = val;
emit_changed();
output.emit_changed();
void MMSdShapeLine::_notification(int p_what) {
if (p_what == NOTIFICATION_POSTINITIALIZE) {
if (points.size() == 0) {
init_points_11();
}
}
}
//b;
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");
Vector2 SdShapeLine::get_b() {
return B;
ClassDB::bind_method(D_METHOD("get_a"), &MMSdShapeLine::get_a);
ClassDB::bind_method(D_METHOD("set_a", "value"), &MMSdShapeLine::set_a);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "A"), "set_a", "get_a");
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_width"), &MMSdShapeLine::get_width);
ClassDB::bind_method(D_METHOD("set_width", "value"), &MMSdShapeLine::set_width);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "width"), "set_width", "get_width");
}
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);
B = Vector2(0.3, 0.3);
width = 0.1;
}
SdShapeLine::~SdShapeLine() {
}
static void SdShapeLine::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &SdShapeLine::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdShapeLine::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_A"), &SdShapeLine::get_A);
ClassDB::bind_method(D_METHOD("set_A", "value"), &SdShapeLine::set_A);
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");
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);
}

View File

@ -1,55 +1,43 @@
#ifndef SD_SHAPE_LINE_H
#define SD_SHAPE_LINE_H
#ifndef MM_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 {
GDCLASS(SdShapeLine, CurveBase);
class MMSdShapeLine : public CurveBase {
GDCLASS(MMSdShapeLine, CurveBase);
public:
public:
Ref<MMNodeUniversalProperty> get_output();
void set_output(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
Vector2 get_a();
void set_a(const Vector2 &val);
Vector2 get_A();
void set_A(const Vector2 &val);
Vector2 get_b();
void set_b(const Vector2 &val);
Vector2 get_B();
void set_B(const Vector2 &val);
float get_width() const;
void set_width(const float val);
float get_width() const;
void set_width(const float val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
Variant _get_property_value(const Vector2 &uv);
void _init();
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
float _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();
~SdShapeLine();
MMSdShapeLine();
~MMSdShapeLine();
protected:
static void _bind_methods();
protected:
void _notification(int p_what);
//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;
//a
//b
//width
static void _bind_methods();
Ref<MMNodeUniversalProperty> output;
Vector2 A;
Vector2 B;
float width;
};
#endif

View File

@ -1,73 +1,53 @@
#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() {
return output;
Ref<MMNodeUniversalProperty> MMSdShapePolygon::get_output() {
return output;
}
void SdShapePolygon::set_output(const Ref<Resource> &val) {
output = val;
void MMSdShapePolygon::set_output(const Ref<MMNodeUniversalProperty> &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;
register_output_property(output);
}
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = ">>> Output >>>";
output.get_value_from_owner = true;
register_output_property(output);
void MMSdShapePolygon::_register_methods(MMGraphNode *mm_graph_node) {
mm_graph_node->add_slot_label_universal(output);
mm_graph_node->add_slot_polygon();
}
void SdShapePolygon::_register_methods(const Variant &mm_graph_node) {
mm_graph_node.add_slot_label_universal(output);
mm_graph_node.add_slot_polygon();
Variant MMSdShapePolygon::_get_property_value(const Vector2 &uv) {
return MMAlgos::sdPolygon(uv, points);
}
float SdShapePolygon::_get_property_value(const Vector2 &uv) {
return MMAlgos.sdPolygon(uv, points);
void MMSdShapePolygon::_polygon_changed() {
emit_changed();
output->do_emit_changed();
}
void SdShapePolygon::_polygon_changed() {
emit_changed();
output.emit_changed();
MMSdShapePolygon::MMSdShapePolygon() {
}
MMSdShapePolygon::~MMSdShapePolygon() {
}
SdShapePolygon::SdShapePolygon() {
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");
}

View File

@ -1,30 +1,29 @@
#ifndef SD_SHAPE_POLYGON_H
#define SD_SHAPE_POLYGON_H
#ifndef MM_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 {
GDCLASS(SdShapePolygon, PolygonBase);
class MMSdShapePolygon : public PolygonBase {
GDCLASS(MMSdShapePolygon, PolygonBase);
public:
public:
Ref<MMNodeUniversalProperty> get_output();
void set_output(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_output();
void set_output(const Ref<Resource> &val);
void _init_properties();
void _register_methods(MMGraphNode *mm_graph_node);
Variant _get_property_value(const Vector2 &uv);
void _init_properties();
void _register_methods(const Variant &mm_graph_node);
float _get_property_value(const Vector2 &uv);
void _polygon_changed();
void _polygon_changed();
SdShapePolygon();
~SdShapePolygon();
MMSdShapePolygon();
~MMSdShapePolygon();
protected:
static void _bind_methods();
protected:
static void _bind_methods();
//tool
//export(Resource)
Ref<Resource> output;
Ref<MMNodeUniversalProperty> output;
};
#endif

View File

@ -1,5 +1,5 @@
#ifndef SD_TF_ROTATE_H
#define SD_TF_ROTATE_H
#ifndef MM_SD_TF_ROTATE_H
#define MM_SD_TF_ROTATE_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"

View File

@ -84,6 +84,11 @@ SOFTWARE.
#include "nodes/sdf3d/sdf3d_op_rounded.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_tf_rotate.h"
@ -190,6 +195,16 @@ void register_material_maker_types() {
ClassDB::register_class<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>();
MMAlgos::register_node_class("SDF2D - TF", "MMSdTfTranslate");