Cleaned up the sdf2d operations.

This commit is contained in:
Relintai 2022-06-17 21:38:22 +02:00
parent f2fb6b8b7d
commit efb00f2fbb
17 changed files with 720 additions and 1089 deletions

View File

@ -92,6 +92,8 @@ sources = [
"nodes/sdf3d/sdf3d_op_circle_repeat.cpp", "nodes/sdf3d/sdf3d_op_circle_repeat.cpp",
"nodes/sdf3d/sdf3d_op_bool.cpp", "nodes/sdf3d/sdf3d_op_bool.cpp",
"nodes/sdf2d/sd_show.cpp",
"nodes/sdf2d/sd_shape_rhombus.cpp", "nodes/sdf2d/sd_shape_rhombus.cpp",
"nodes/sdf2d/sd_shape_polygon.cpp", "nodes/sdf2d/sd_shape_polygon.cpp",
"nodes/sdf2d/sd_shape_line.cpp", "nodes/sdf2d/sd_shape_line.cpp",
@ -103,8 +105,13 @@ sources = [
"nodes/sdf2d/sd_tf_scale.cpp", "nodes/sdf2d/sd_tf_scale.cpp",
"nodes/sdf2d/sd_tf_rotate.cpp", "nodes/sdf2d/sd_tf_rotate.cpp",
"nodes/sdf2d/sd_show.cpp", "nodes/sdf2d/sd_op_smooth_bool.cpp",
"nodes/sdf2d/sd_op_rounded_shape.cpp",
"nodes/sdf2d/sd_op_repeat.cpp",
"nodes/sdf2d/sd_op_morph.cpp",
"nodes/sdf2d/sd_op_circle_repeat.cpp",
"nodes/sdf2d/sd_op_bool.cpp",
"nodes/sdf2d/sd_op_annular_shape.cpp",
] ]
if env["tools"]: if env["tools"]:

View File

@ -74,6 +74,14 @@ def get_doc_classes():
"MMSdShapeCircle", "MMSdShapeCircle",
"MMSdShapeBox", "MMSdShapeBox",
"MMSdShapeArc", "MMSdShapeArc",
"MMSdOpSmoothBool",
"MMSdOpRoundedShape",
"MMSdOpRepeat",
"MMSdOpMorph",
"MMSdOpCircleRepeat",
"MMSdOpBool",
"MMSdOpAnnularShape",
] ]
def get_doc_path(): def get_doc_path():

View File

@ -1,135 +1,83 @@
#include "sd_op_annular_shape.h" #include "sd_op_annular_shape.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> SdOpAnnularShape::get_output() { Ref<MMNodeUniversalProperty> MMSdOpAnnularShape::get_output() {
return output; return output;
} }
void SdOpAnnularShape::set_output(const Ref<Resource> &val) { void MMSdOpAnnularShape::set_output(const Ref<MMNodeUniversalProperty> &val) {
output = val; output = val;
} }
float MMSdOpAnnularShape::get_width() const {
float SdOpAnnularShape::get_width() const { return width;
return width;
} }
void SdOpAnnularShape::set_width(const float val) { void MMSdOpAnnularShape::set_width(const float val) {
width = val; width = val;
emit_changed();
output->do_emit_changed();
} }
int MMSdOpAnnularShape::get_ripples() const {
int SdOpAnnularShape::get_ripples() const { return ripples;
return ripples;
} }
void SdOpAnnularShape::set_ripples(const int val) { void MMSdOpAnnularShape::set_ripples(const int val) {
ripples = val; ripples = val;
emit_changed();
output->do_emit_changed();
} }
void MMSdOpAnnularShape::_init_properties() {
if (!output.is_valid()) {
output.instance();
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
}
output->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
//output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output->set_slot_name(">>> Apply >>>");
output->set_get_value_from_owner(true);
//tool; register_input_property(output);
//export(Resource) ; register_output_property(output);
Ref<Resource> output;
//export(float) ;
float width = 0.1;
//export(int) ;
int ripples = 1;
void SdOpAnnularShape::_init_properties() {
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
} }
output.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL; void MMSdOpAnnularShape::_register_methods(MMGraphNode *mm_graph_node) {
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL; mm_graph_node->add_slot_label_universal(output);
//output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT; mm_graph_node->add_slot_float("get_width", "set_width", "Width", 0.01);
output.slot_name = ">>> Apply >>>"; mm_graph_node->add_slot_int("get_ripples", "set_ripples", "Ripples");
output.get_value_from_owner = true;
register_input_property(output);
register_output_property(output);
} }
Variant MMSdOpAnnularShape::_get_property_value(const Vector2 &uv) {
void SdOpAnnularShape::_register_methods(const Variant &mm_graph_node) { float val = output->get_value(uv, true);
mm_graph_node.add_slot_label_universal(output); return MMAlgos::sdRipples(val, width, ripples);
mm_graph_node.add_slot_float("get_width", "set_width", "Width", 0.01);
mm_graph_node.add_slot_int("get_ripples", "set_ripples", "Ripples");
} }
MMSdOpAnnularShape::MMSdOpAnnularShape() {
void SdOpAnnularShape::_get_property_value(const Vector2 &uv) { width = 0.1;
float val = output.get_value(uv, true); ripples = 1;
return MMAlgos.sdRipples(val, width, ripples);
} }
//width; MMSdOpAnnularShape::~MMSdOpAnnularShape() {
float SdOpAnnularShape::get_width() {
return width;
} }
void MMSdOpAnnularShape::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &MMSdOpAnnularShape::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdOpAnnularShape::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
void SdOpAnnularShape::set_width(const float val) { ClassDB::bind_method(D_METHOD("get_width"), &MMSdOpAnnularShape::get_width);
width = val; ClassDB::bind_method(D_METHOD("set_width", "value"), &MMSdOpAnnularShape::set_width);
emit_changed(); ADD_PROPERTY(PropertyInfo(Variant::REAL, "width"), "set_width", "get_width");
output.emit_changed();
ClassDB::bind_method(D_METHOD("get_ripples"), &MMSdOpAnnularShape::get_ripples);
ClassDB::bind_method(D_METHOD("set_ripples", "value"), &MMSdOpAnnularShape::set_ripples);
ADD_PROPERTY(PropertyInfo(Variant::INT, "ripples"), "set_ripples", "get_ripples");
} }
//ripples;
int SdOpAnnularShape::get_ripples() {
return ripples;
}
void SdOpAnnularShape::set_ripples(const int val) {
ripples = val;
emit_changed();
output.emit_changed();
}
}
SdOpAnnularShape::SdOpAnnularShape() {
output;
width = 0.1;
ripples = 1;
}
SdOpAnnularShape::~SdOpAnnularShape() {
}
static void SdOpAnnularShape::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &SdOpAnnularShape::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdOpAnnularShape::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_width"), &SdOpAnnularShape::get_width);
ClassDB::bind_method(D_METHOD("set_width", "value"), &SdOpAnnularShape::set_width);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "width"), "set_width", "get_width");
ClassDB::bind_method(D_METHOD("get_ripples"), &SdOpAnnularShape::get_ripples);
ClassDB::bind_method(D_METHOD("set_ripples", "value"), &SdOpAnnularShape::set_ripples);
ADD_PROPERTY(PropertyInfo(Variant::INT, "ripples"), "set_ripples", "get_ripples");
ClassDB::bind_method(D_METHOD("_init_properties"), &SdOpAnnularShape::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdOpAnnularShape::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdOpAnnularShape::_get_property_value);
ClassDB::bind_method(D_METHOD("get_width"), &SdOpAnnularShape::get_width);
ClassDB::bind_method(D_METHOD("set_width", "val"), &SdOpAnnularShape::set_width);
ClassDB::bind_method(D_METHOD("get_ripples"), &SdOpAnnularShape::get_ripples);
ClassDB::bind_method(D_METHOD("set_ripples", "val"), &SdOpAnnularShape::set_ripples);
}

View File

@ -1,45 +1,35 @@
#ifndef SD_OP_ANNULAR_SHAPE_H #ifndef MM_SD_OP_ANNULAR_SHAPE_H
#define SD_OP_ANNULAR_SHAPE_H #define MM_SD_OP_ANNULAR_SHAPE_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class SdOpAnnularShape : public MMNode { class MMSdOpAnnularShape : public MMNode {
GDCLASS(SdOpAnnularShape, MMNode); GDCLASS(MMSdOpAnnularShape, MMNode);
public: public:
Ref<MMNodeUniversalProperty> get_output();
void set_output(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_output(); float get_width() const;
void set_output(const Ref<Resource> &val); void set_width(const float val);
float get_width() const; int get_ripples() const;
void set_width(const float val); void set_ripples(const int val);
int get_ripples() const; void _init_properties();
void set_ripples(const int val); void _register_methods(MMGraphNode *mm_graph_node);
Variant _get_property_value(const Vector2 &uv);
void _init_properties(); MMSdOpAnnularShape();
void _register_methods(const Variant &mm_graph_node); ~MMSdOpAnnularShape();
void _get_property_value(const Vector2 &uv);
float get_width();
void set_width(const float val);
int get_ripples();
void set_ripples(const int val);
SdOpAnnularShape(); protected:
~SdOpAnnularShape(); static void _bind_methods();
protected: Ref<MMNodeUniversalProperty> output;
static void _bind_methods(); float width;
int ripples;
//tool
//export(Resource)
Ref<Resource> output;
//export(float)
float width = 0.1;
//export(int)
int ripples = 1;
//width
//ripples
}; };
#endif #endif

View File

@ -1,187 +1,139 @@
#include "sd_op_bool.h" #include "sd_op_bool.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> SdOpBool::get_input1() { Ref<MMNodeUniversalProperty> MMSdOpBool::get_input1() {
return input1; return input1;
} }
void SdOpBool::set_input1(const Ref<Resource> &val) { void MMSdOpBool::set_input1(const Ref<MMNodeUniversalProperty> &val) {
input1 = val; input1 = val;
} }
Ref<MMNodeUniversalProperty> MMSdOpBool::get_input2() {
Ref<Resource> SdOpBool::get_input2() { return input2;
return input2;
} }
void SdOpBool::set_input2(const Ref<Resource> &val) { void MMSdOpBool::set_input2(const Ref<MMNodeUniversalProperty> &val) {
input2 = val; input2 = val;
} }
Ref<MMNodeUniversalProperty> MMSdOpBool::get_output() {
Ref<Resource> SdOpBool::get_output() { return output;
return output;
} }
void SdOpBool::set_output(const Ref<Resource> &val) { void MMSdOpBool::set_output(const Ref<MMNodeUniversalProperty> &val) {
output = val; output = val;
} }
int MMSdOpBool::get_operation() const {
int SdOpBool::get_operation() const { return operation;
return operation;
} }
void SdOpBool::set_operation(const int val) { void MMSdOpBool::set_operation(const int val) {
operation = val; operation = val;
emit_changed();
output->do_emit_changed();
} }
void MMSdOpBool::_init_properties() {
if (!input1.is_valid()) {
input1.instance();
input1->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
}
input1->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
// input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
input1->set_slot_name(">>> Input 1 ");
//tool; if (!input1->is_connected("changed", this, "on_input_changed")) {
//export(Resource) ; input1->connect("changed", this, "on_input_changed");
Ref<Resource> input1; }
//export(Resource) ;
Ref<Resource> input2;
//export(Resource) ;
Ref<Resource> output;
//export(int, "Union,Substraction,Intersection") ;
int operation = 0;
void SdOpBool::_init_properties() { if (!input2.is_valid()) {
input2.instance();
input2->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
}
if (!input1) { input2->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input1 = MMNodeUniversalProperty.new(); // input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
input1.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT; input2->set_slot_name(">>> Input 2 ");
if (!input2->is_connected("changed", this, "on_input_changed")) {
input2->connect("changed", this, "on_input_changed");
}
if (!output.is_valid()) {
output.instance();
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
}
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
// output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output->set_slot_name(" Output >>>");
output->set_get_value_from_owner(true);
register_input_property(input1);
register_input_property(input2);
register_output_property(output);
} }
input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL; void MMSdOpBool::_register_methods(MMGraphNode *mm_graph_node) {
// input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT; mm_graph_node->add_slot_label_universal(input1);
input1.slot_name = ">>> Input 1 "; mm_graph_node->add_slot_label_universal(input2);
mm_graph_node->add_slot_label_universal(output);
if (!input1.is_connected("changed", self, "on_input_changed")) { Array arr;
input1.connect("changed", self, "on_input_changed"); arr.push_back("Union");
arr.push_back("Substraction");
arr.push_back("Intersection");
mm_graph_node->add_slot_enum("get_operation", "set_operation", "Operation", arr);
} }
Variant MMSdOpBool::_get_property_value(const Vector2 &uv) {
if (operation == 0) {
return MMAlgos::sdf_boolean_union(input1->get_value(uv), input2->get_value(uv));
} else if (operation == 1) {
return MMAlgos::sdf_boolean_substraction(input1->get_value(uv), input2->get_value(uv));
} else if (operation == 2) {
return MMAlgos::sdf_boolean_intersection(input1->get_value(uv), input2->get_value(uv));
}
if (!input2) { return 0.0;
input2 = MMNodeUniversalProperty.new();
input2.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
} }
input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL; void MMSdOpBool::on_input_changed() {
// input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT; emit_changed();
input2.slot_name = ">>> Input 2 "; output->do_emit_changed();
if (!input2.is_connected("changed", self, "on_input_changed")) {
input2.connect("changed", self, "on_input_changed");
} }
MMSdOpBool::MMSdOpBool() {
if (!output) { operation = 0;
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
} }
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL; MMSdOpBool::~MMSdOpBool() {
// output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = " Output >>>";
output.get_value_from_owner = true;
register_input_property(input1);
register_input_property(input2);
register_output_property(output);
} }
void MMSdOpBool::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_input1"), &MMSdOpBool::get_input1);
ClassDB::bind_method(D_METHOD("set_input1", "value"), &MMSdOpBool::set_input1);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input1", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input1", "get_input1");
void SdOpBool::_register_methods(const Variant &mm_graph_node) { ClassDB::bind_method(D_METHOD("get_input2"), &MMSdOpBool::get_input2);
mm_graph_node.add_slot_label_universal(input1); ClassDB::bind_method(D_METHOD("set_input2", "value"), &MMSdOpBool::set_input2);
mm_graph_node.add_slot_label_universal(input2); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input2", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input2", "get_input2");
mm_graph_node.add_slot_label_universal(output);
mm_graph_node.add_slot_enum("get_operation", "set_operation", "Operation", [ "Union", "Substraction", "Intersection" ]); ClassDB::bind_method(D_METHOD("get_output"), &MMSdOpBool::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdOpBool::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_operation"), &MMSdOpBool::get_operation);
ClassDB::bind_method(D_METHOD("set_operation", "value"), &MMSdOpBool::set_operation);
ADD_PROPERTY(PropertyInfo(Variant::INT, "operation"), "set_operation", "get_operation");
ClassDB::bind_method(D_METHOD("on_input_changed"), &MMSdOpBool::on_input_changed);
} }
float SdOpBool::_get_property_value(const Vector2 &uv) {
if (operation == 0) {
return MMAlgos.sdf_boolean_union(input1.get_value(uv), input2.get_value(uv));
}
else if (operation == 1) {
return MMAlgos.sdf_boolean_substraction(input1.get_value(uv), input2.get_value(uv));
}
else if (operation == 2) {
return MMAlgos.sdf_boolean_intersection(input1.get_value(uv), input2.get_value(uv));
}
return 0.0;
}
//operation;
int SdOpBool::get_operation() {
return operation;
}
void SdOpBool::set_operation(const int val) {
operation = val;
emit_changed();
output.emit_changed();
}
void SdOpBool::on_input_changed() {
emit_changed();
output.emit_changed();
}
}
SdOpBool::SdOpBool() {
input1;
input2;
output;
operation = 0;
}
SdOpBool::~SdOpBool() {
}
static void SdOpBool::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_input1"), &SdOpBool::get_input1);
ClassDB::bind_method(D_METHOD("set_input1", "value"), &SdOpBool::set_input1);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input1", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input1", "get_input1");
ClassDB::bind_method(D_METHOD("get_input2"), &SdOpBool::get_input2);
ClassDB::bind_method(D_METHOD("set_input2", "value"), &SdOpBool::set_input2);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input2", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input2", "get_input2");
ClassDB::bind_method(D_METHOD("get_output"), &SdOpBool::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdOpBool::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_operation"), &SdOpBool::get_operation);
ClassDB::bind_method(D_METHOD("set_operation", "value"), &SdOpBool::set_operation);
ADD_PROPERTY(PropertyInfo(Variant::INT, "operation"), "set_operation", "get_operation");
ClassDB::bind_method(D_METHOD("_init_properties"), &SdOpBool::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdOpBool::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdOpBool::_get_property_value);
ClassDB::bind_method(D_METHOD("get_operation"), &SdOpBool::get_operation);
ClassDB::bind_method(D_METHOD("set_operation", "val"), &SdOpBool::set_operation);
ClassDB::bind_method(D_METHOD("on_input_changed"), &SdOpBool::on_input_changed);
}

View File

@ -1,48 +1,42 @@
#ifndef SD_OP_BOOL_H #ifndef MM_SD_OP_BOOL_H
#define SD_OP_BOOL_H #define MM_SD_OP_BOOL_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class SdOpBool : public MMNode { class MMSdOpBool : public MMNode {
GDCLASS(SdOpBool, MMNode); GDCLASS(MMSdOpBool, MMNode);
public: public:
Ref<MMNodeUniversalProperty> get_input1();
void set_input1(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input1(); Ref<MMNodeUniversalProperty> get_input2();
void set_input1(const Ref<Resource> &val); void set_input2(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input2(); Ref<MMNodeUniversalProperty> get_output();
void set_input2(const Ref<Resource> &val); void set_output(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_output(); int get_operation() const;
void set_output(const Ref<Resource> &val); void set_operation(const int val);
int get_operation() const; void _init_properties();
void set_operation(const int val); void _register_methods(MMGraphNode *mm_graph_node);
Variant _get_property_value(const Vector2 &uv);
void _init_properties(); void on_input_changed();
void _register_methods(const Variant &mm_graph_node);
float _get_property_value(const Vector2 &uv);
int get_operation();
void set_operation(const int val);
void on_input_changed();
SdOpBool(); MMSdOpBool();
~SdOpBool(); ~MMSdOpBool();
protected: protected:
static void _bind_methods(); static void _bind_methods();
//tool Ref<MMNodeUniversalProperty> input1;
//export(Resource) Ref<MMNodeUniversalProperty> input2;
Ref<Resource> input1; Ref<MMNodeUniversalProperty> output;
//export(Resource) //export(int, "Union,Substraction,Intersection")
Ref<Resource> input2; int operation;
//export(Resource)
Ref<Resource> output;
//export(int, "Union,Substraction,Intersection")
int operation = 0;
//operation
}; };
#endif #endif

View File

@ -1,103 +1,69 @@
#include "sd_op_circle_repeat.h" #include "sd_op_circle_repeat.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> SdOpCircleRepeat::get_output() { Ref<MMNodeUniversalProperty> MMSdOpCircleRepeat::get_output() {
return output; return output;
} }
void SdOpCircleRepeat::set_output(const Ref<Resource> &val) { void MMSdOpCircleRepeat::set_output(const Ref<MMNodeUniversalProperty> &val) {
output = val; output = val;
} }
int MMSdOpCircleRepeat::get_count() const {
int SdOpCircleRepeat::get_count() const { return count;
return count;
} }
void SdOpCircleRepeat::set_count(const int val) { void MMSdOpCircleRepeat::set_count(const int val) {
count = val; count = val;
emit_changed();
output->do_emit_changed();
} }
void MMSdOpCircleRepeat::_init_properties() {
if (!output.is_valid()) {
output.instance();
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
}
output->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
//output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output->set_slot_name(">>> Apply >>>");
output->set_get_value_from_owner(true);
//tool; register_input_property(output);
//export(Resource) ; register_output_property(output);
Ref<Resource> output;
//export(int) ;
int count = 6;
void SdOpCircleRepeat::_init_properties() {
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
} }
output.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL; void MMSdOpCircleRepeat::_register_methods(MMGraphNode *mm_graph_node) {
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL; mm_graph_node->add_slot_label_universal(output);
//output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT; mm_graph_node->add_slot_int("get_count", "set_count", "Count");
output.slot_name = ">>> Apply >>>";
output.get_value_from_owner = true;
register_input_property(output);
register_output_property(output);
} }
Variant MMSdOpCircleRepeat::_get_property_value(const Vector2 &uv) {
void SdOpCircleRepeat::_register_methods(const Variant &mm_graph_node) { //$in(circle_repeat_transform_2d($uv-vec2(0.5), $c)+vec2(0.5));
mm_graph_node.add_slot_label_universal(output); Vector2 new_uv = MMAlgos::circle_repeat_transform_2d(uv - Vector2(0.5, 0.5), count) + Vector2(0.5, 0.5);
mm_graph_node.add_slot_int("get_count", "set_count", "Count"); return output->get_value(new_uv, true);
} }
MMSdOpCircleRepeat::MMSdOpCircleRepeat() {
void SdOpCircleRepeat::_get_property_value(const Vector2 &uv) { count = 6;
//$in(circle_repeat_transform_2d($uv-vec2(0.5), $c)+vec2(0.5));
Vector2 new_uv = MMAlgos.circle_repeat_transform_2d(uv - Vector2(0.5, 0.5), count) + Vector2(0.5, 0.5);
return output.get_value(new_uv, true);
} }
//count; MMSdOpCircleRepeat::~MMSdOpCircleRepeat() {
int SdOpCircleRepeat::get_count() {
return count;
} }
void MMSdOpCircleRepeat::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &MMSdOpCircleRepeat::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdOpCircleRepeat::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
void SdOpCircleRepeat::set_count(const int val) { ClassDB::bind_method(D_METHOD("get_count"), &MMSdOpCircleRepeat::get_count);
count = val; ClassDB::bind_method(D_METHOD("set_count", "value"), &MMSdOpCircleRepeat::set_count);
emit_changed(); ADD_PROPERTY(PropertyInfo(Variant::INT, "count"), "set_count", "get_count");
output.emit_changed();
} }
}
SdOpCircleRepeat::SdOpCircleRepeat() {
output;
count = 6;
}
SdOpCircleRepeat::~SdOpCircleRepeat() {
}
static void SdOpCircleRepeat::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &SdOpCircleRepeat::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdOpCircleRepeat::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_count"), &SdOpCircleRepeat::get_count);
ClassDB::bind_method(D_METHOD("set_count", "value"), &SdOpCircleRepeat::set_count);
ADD_PROPERTY(PropertyInfo(Variant::INT, "count"), "set_count", "get_count");
ClassDB::bind_method(D_METHOD("_init_properties"), &SdOpCircleRepeat::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdOpCircleRepeat::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdOpCircleRepeat::_get_property_value);
ClassDB::bind_method(D_METHOD("get_count"), &SdOpCircleRepeat::get_count);
ClassDB::bind_method(D_METHOD("set_count", "val"), &SdOpCircleRepeat::set_count);
}

View File

@ -1,37 +1,31 @@
#ifndef SD_OP_CIRCLE_REPEAT_H #ifndef MM_SD_OP_CIRCLE_REPEAT_H
#define SD_OP_CIRCLE_REPEAT_H #define MM_SD_OP_CIRCLE_REPEAT_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class SdOpCircleRepeat : public MMNode { class MMSdOpCircleRepeat : public MMNode {
GDCLASS(SdOpCircleRepeat, MMNode); GDCLASS(MMSdOpCircleRepeat, MMNode);
public: public:
Ref<MMNodeUniversalProperty> get_output();
void set_output(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_output(); int get_count() const;
void set_output(const Ref<Resource> &val); void set_count(const int val);
int get_count() const; void _init_properties();
void set_count(const int val); void _register_methods(MMGraphNode *mm_graph_node);
Variant _get_property_value(const Vector2 &uv);
void _init_properties(); MMSdOpCircleRepeat();
void _register_methods(const Variant &mm_graph_node); ~MMSdOpCircleRepeat();
void _get_property_value(const Vector2 &uv);
int get_count();
void set_count(const int val);
SdOpCircleRepeat(); protected:
~SdOpCircleRepeat(); static void _bind_methods();
protected: Ref<MMNodeUniversalProperty> output;
static void _bind_methods(); int count;
//tool
//export(Resource)
Ref<Resource> output;
//export(int)
int count = 6;
//count
}; };
#endif #endif

View File

@ -1,172 +1,125 @@
#include "sd_op_morph.h" #include "sd_op_morph.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> SdOpMorph::get_input1() { Ref<MMNodeUniversalProperty> MMSdOpMorph::get_input1() {
return input1; return input1;
} }
void SdOpMorph::set_input1(const Ref<Resource> &val) { void MMSdOpMorph::set_input1(const Ref<MMNodeUniversalProperty> &val) {
input1 = val; input1 = val;
} }
Ref<MMNodeUniversalProperty> MMSdOpMorph::get_input2() {
Ref<Resource> SdOpMorph::get_input2() { return input2;
return input2;
} }
void SdOpMorph::set_input2(const Ref<Resource> &val) { void MMSdOpMorph::set_input2(const Ref<MMNodeUniversalProperty> &val) {
input2 = val; input2 = val;
} }
Ref<MMNodeUniversalProperty> MMSdOpMorph::get_output() {
Ref<Resource> SdOpMorph::get_output() { return output;
return output;
} }
void SdOpMorph::set_output(const Ref<Resource> &val) { void MMSdOpMorph::set_output(const Ref<MMNodeUniversalProperty> &val) {
output = val; output = val;
} }
float MMSdOpMorph::get_amount() const {
float SdOpMorph::get_amount() const { return amount;
return amount;
} }
void SdOpMorph::set_amount(const float val) { void MMSdOpMorph::set_amount(const float val) {
amount = val; amount = val;
emit_changed();
output->do_emit_changed();
} }
void MMSdOpMorph::_init_properties() {
if (!input1.is_valid()) {
input1.instance();
input1->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
}
input1->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
// input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
input1->set_slot_name(">>> Input 1 ");
//tool; if (!input1->is_connected("changed", this, "on_input_changed")) {
//export(Resource) ; input1->connect("changed", this, "on_input_changed");
Ref<Resource> input1; }
//export(Resource) ;
Ref<Resource> input2;
//export(Resource) ;
Ref<Resource> output;
//export(float) ;
float amount = 0.5;
void SdOpMorph::_init_properties() { if (!input2.is_valid()) {
input2.instance();
input2->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
}
if (!input1) { input2->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input1 = MMNodeUniversalProperty.new(); // input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
input1.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT; input2->set_slot_name(">>> Input 2 ");
if (!input2->is_connected("changed", this, "on_input_changed")) {
input2->connect("changed", this, "on_input_changed");
}
if (!output.is_valid()) {
output.instance();
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
}
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
// output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output->set_slot_name(" Output >>>");
output->set_get_value_from_owner(true);
register_input_property(input1);
register_input_property(input2);
register_output_property(output);
} }
input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL; void MMSdOpMorph::_register_methods(MMGraphNode *mm_graph_node) {
// input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT; mm_graph_node->add_slot_label_universal(input1);
input1.slot_name = ">>> Input 1 "; mm_graph_node->add_slot_label_universal(input2);
mm_graph_node->add_slot_label_universal(output);
if (!input1.is_connected("changed", self, "on_input_changed")) { mm_graph_node->add_slot_float("get_amount", "set_amount", "Amount", 0.01);
input1.connect("changed", self, "on_input_changed");
} }
Variant MMSdOpMorph::_get_property_value(const Vector2 &uv) {
if (!input2) { return MMAlgos::sdf_morph(input1->get_value(uv), input2->get_value(uv), amount);
input2 = MMNodeUniversalProperty.new();
input2.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
} }
input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL; void MMSdOpMorph::on_input_changed() {
// input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT; emit_changed();
input2.slot_name = ">>> Input 2 "; output->do_emit_changed();
if (!input2.is_connected("changed", self, "on_input_changed")) {
input2.connect("changed", self, "on_input_changed");
} }
MMSdOpMorph::MMSdOpMorph() {
if (!output) { amount = 0.5;
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
} }
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL; MMSdOpMorph::~MMSdOpMorph() {
// output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = " Output >>>";
output.get_value_from_owner = true;
register_input_property(input1);
register_input_property(input2);
register_output_property(output);
} }
void MMSdOpMorph::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_input1"), &MMSdOpMorph::get_input1);
ClassDB::bind_method(D_METHOD("set_input1", "value"), &MMSdOpMorph::set_input1);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input1", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input1", "get_input1");
void SdOpMorph::_register_methods(const Variant &mm_graph_node) { ClassDB::bind_method(D_METHOD("get_input2"), &MMSdOpMorph::get_input2);
mm_graph_node.add_slot_label_universal(input1); ClassDB::bind_method(D_METHOD("set_input2", "value"), &MMSdOpMorph::set_input2);
mm_graph_node.add_slot_label_universal(input2); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input2", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input2", "get_input2");
mm_graph_node.add_slot_label_universal(output);
mm_graph_node.add_slot_float("get_amount", "set_amount", "Amount", 0.01); ClassDB::bind_method(D_METHOD("get_output"), &MMSdOpMorph::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdOpMorph::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_amount"), &MMSdOpMorph::get_amount);
ClassDB::bind_method(D_METHOD("set_amount", "value"), &MMSdOpMorph::set_amount);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "amount"), "set_amount", "get_amount");
ClassDB::bind_method(D_METHOD("on_input_changed"), &MMSdOpMorph::on_input_changed);
} }
float SdOpMorph::_get_property_value(const Vector2 &uv) {
return MMAlgos.sdf_morph(input1.get_value(uv), input2.get_value(uv), amount);
}
//amount;
float SdOpMorph::get_amount() {
return amount;
}
void SdOpMorph::set_amount(const float val) {
amount = val;
emit_changed();
output.emit_changed();
}
void SdOpMorph::on_input_changed() {
emit_changed();
output.emit_changed();
}
}
SdOpMorph::SdOpMorph() {
input1;
input2;
output;
amount = 0.5;
}
SdOpMorph::~SdOpMorph() {
}
static void SdOpMorph::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_input1"), &SdOpMorph::get_input1);
ClassDB::bind_method(D_METHOD("set_input1", "value"), &SdOpMorph::set_input1);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input1", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input1", "get_input1");
ClassDB::bind_method(D_METHOD("get_input2"), &SdOpMorph::get_input2);
ClassDB::bind_method(D_METHOD("set_input2", "value"), &SdOpMorph::set_input2);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input2", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input2", "get_input2");
ClassDB::bind_method(D_METHOD("get_output"), &SdOpMorph::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdOpMorph::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_amount"), &SdOpMorph::get_amount);
ClassDB::bind_method(D_METHOD("set_amount", "value"), &SdOpMorph::set_amount);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "amount"), "set_amount", "get_amount");
ClassDB::bind_method(D_METHOD("_init_properties"), &SdOpMorph::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdOpMorph::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdOpMorph::_get_property_value);
ClassDB::bind_method(D_METHOD("get_amount"), &SdOpMorph::get_amount);
ClassDB::bind_method(D_METHOD("set_amount", "val"), &SdOpMorph::set_amount);
ClassDB::bind_method(D_METHOD("on_input_changed"), &SdOpMorph::on_input_changed);
}

View File

@ -1,48 +1,41 @@
#ifndef SD_OP_MORPH_H #ifndef MM_SD_OP_MORPH_H
#define SD_OP_MORPH_H #define MM_SD_OP_MORPH_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class SdOpMorph : public MMNode { class MMSdOpMorph : public MMNode {
GDCLASS(SdOpMorph, MMNode); GDCLASS(MMSdOpMorph, MMNode);
public: public:
Ref<MMNodeUniversalProperty> get_input1();
void set_input1(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input1(); Ref<MMNodeUniversalProperty> get_input2();
void set_input1(const Ref<Resource> &val); void set_input2(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input2(); Ref<MMNodeUniversalProperty> get_output();
void set_input2(const Ref<Resource> &val); void set_output(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_output(); float get_amount() const;
void set_output(const Ref<Resource> &val); void set_amount(const float val);
float get_amount() const; void _init_properties();
void set_amount(const float val); void _register_methods(MMGraphNode *mm_graph_node);
Variant _get_property_value(const Vector2 &uv);
void _init_properties(); void on_input_changed();
void _register_methods(const Variant &mm_graph_node);
float _get_property_value(const Vector2 &uv);
float get_amount();
void set_amount(const float val);
void on_input_changed();
SdOpMorph(); MMSdOpMorph();
~SdOpMorph(); ~MMSdOpMorph();
protected: protected:
static void _bind_methods(); static void _bind_methods();
//tool Ref<MMNodeUniversalProperty> input1;
//export(Resource) Ref<MMNodeUniversalProperty> input2;
Ref<Resource> input1; Ref<MMNodeUniversalProperty> output;
//export(Resource) float amount;
Ref<Resource> input2;
//export(Resource)
Ref<Resource> output;
//export(float)
float amount = 0.5;
//amount
}; };
#endif #endif

View File

@ -1,171 +1,102 @@
#include "sd_op_repeat.h" #include "sd_op_repeat.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> SdOpRepeat::get_output() { Ref<MMNodeUniversalProperty> MMSdOpRepeat::get_output() {
return output; return output;
} }
void SdOpRepeat::set_output(const Ref<Resource> &val) { void MMSdOpRepeat::set_output(const Ref<MMNodeUniversalProperty> &val) {
output = val; output = val;
} }
int MMSdOpRepeat::get_x() const {
int SdOpRepeat::get_x() const { return x;
return x;
} }
void SdOpRepeat::set_x(const int val) { void MMSdOpRepeat::set_x(const int val) {
x = val; x = val;
emit_changed();
output->do_emit_changed();
} }
int MMSdOpRepeat::get_y() const {
int SdOpRepeat::get_y() const { return y;
return y;
} }
void SdOpRepeat::set_y(const int val) { void MMSdOpRepeat::set_y(const int val) {
y = val; y = val;
emit_changed();
output->do_emit_changed();
} }
float MMSdOpRepeat::get_random_rotation() const {
float SdOpRepeat::get_random_rotation() const { return random_rotation;
return random_rotation;
} }
void SdOpRepeat::set_random_rotation(const float val) { void MMSdOpRepeat::set_random_rotation(const float val) {
random_rotation = val; random_rotation = val;
emit_changed();
output->do_emit_changed();
} }
void MMSdOpRepeat::_init_properties() {
if (!output.is_valid()) {
output.instance();
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
}
output->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
//output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output->set_slot_name(">>> Apply >>>");
output->set_get_value_from_owner(true);
//tool; register_input_property(output);
//export(Resource) ; register_output_property(output);
Ref<Resource> output;
//export(int) ;
int x = 3;
//export(int) ;
int y = 3;
//export(float) ;
float random_rotation = 0.5;
void SdOpRepeat::_init_properties() {
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
} }
output.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL; void MMSdOpRepeat::_register_methods(MMGraphNode *mm_graph_node) {
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL; mm_graph_node->add_slot_label_universal(output);
//output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT; mm_graph_node->add_slot_int("get_x", "set_x", "X");
output.slot_name = ">>> Apply >>>"; mm_graph_node->add_slot_int("get_y", "set_y", "Y");
output.get_value_from_owner = true; mm_graph_node->add_slot_float("get_random_rotation", "set_random_rotation", "Random rotation", 0.01);
register_input_property(output);
register_output_property(output);
} }
Variant MMSdOpRepeat::_get_property_value(const Vector2 &uv) {
void SdOpRepeat::_register_methods(const Variant &mm_graph_node) { //todo add this as a parameter;
mm_graph_node.add_slot_label_universal(output); int pseed = 123123;
mm_graph_node.add_slot_int("get_x", "set_x", "X"); //$in(repeat_2d($uv, vec2(1.0/$rx, 1.0/$ry), float($seed), $r));
mm_graph_node.add_slot_int("get_y", "set_y", "Y"); Vector2 new_uv = MMAlgos::repeat_2d(uv, Vector2(1.0 / float(x), 1.0 / float(y)), 1.0 / float(pseed), random_rotation);
mm_graph_node.add_slot_float("get_random_rotation", "set_random_rotation", "Random rotation", 0.01); return output->get_value(new_uv, true);
} }
MMSdOpRepeat::MMSdOpRepeat() {
void SdOpRepeat::_get_property_value(const Vector2 &uv) { x = 3;
//todo add this as a parameter; y = 3;
int pseed = 123123; random_rotation = 0.5;
//$in(repeat_2d($uv, vec2(1.0/$rx, 1.0/$ry), float($seed), $r));
Vector2 new_uv = MMAlgos.repeat_2d(uv, Vector2(1.0 / float(x), 1.0/ float(y)), 1.0/float(pseed), random_rotation);
return output.get_value(new_uv, true);
} }
//x; MMSdOpRepeat::~MMSdOpRepeat() {
int SdOpRepeat::get_x() {
return x;
} }
void MMSdOpRepeat::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &MMSdOpRepeat::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdOpRepeat::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
void SdOpRepeat::set_x(const int val) { ClassDB::bind_method(D_METHOD("get_x"), &MMSdOpRepeat::get_x);
x = val; ClassDB::bind_method(D_METHOD("set_x", "value"), &MMSdOpRepeat::set_x);
emit_changed(); ADD_PROPERTY(PropertyInfo(Variant::INT, "x"), "set_x", "get_x");
output.emit_changed();
ClassDB::bind_method(D_METHOD("get_y"), &MMSdOpRepeat::get_y);
ClassDB::bind_method(D_METHOD("set_y", "value"), &MMSdOpRepeat::set_y);
ADD_PROPERTY(PropertyInfo(Variant::INT, "y"), "set_y", "get_y");
ClassDB::bind_method(D_METHOD("get_random_rotation"), &MMSdOpRepeat::get_random_rotation);
ClassDB::bind_method(D_METHOD("set_random_rotation", "value"), &MMSdOpRepeat::set_random_rotation);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "random_rotation"), "set_random_rotation", "get_random_rotation");
} }
//y;
int SdOpRepeat::get_y() {
return y;
}
void SdOpRepeat::set_y(const int val) {
y = val;
emit_changed();
output.emit_changed();
}
//random_rotation;
float SdOpRepeat::get_random_rotation() {
return random_rotation;
}
void SdOpRepeat::set_random_rotation(const float val) {
random_rotation = val;
emit_changed();
output.emit_changed();
}
}
SdOpRepeat::SdOpRepeat() {
output;
x = 3;
y = 3;
random_rotation = 0.5;
}
SdOpRepeat::~SdOpRepeat() {
}
static void SdOpRepeat::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &SdOpRepeat::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdOpRepeat::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_x"), &SdOpRepeat::get_x);
ClassDB::bind_method(D_METHOD("set_x", "value"), &SdOpRepeat::set_x);
ADD_PROPERTY(PropertyInfo(Variant::INT, "x"), "set_x", "get_x");
ClassDB::bind_method(D_METHOD("get_y"), &SdOpRepeat::get_y);
ClassDB::bind_method(D_METHOD("set_y", "value"), &SdOpRepeat::set_y);
ADD_PROPERTY(PropertyInfo(Variant::INT, "y"), "set_y", "get_y");
ClassDB::bind_method(D_METHOD("get_random_rotation"), &SdOpRepeat::get_random_rotation);
ClassDB::bind_method(D_METHOD("set_random_rotation", "value"), &SdOpRepeat::set_random_rotation);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "random_rotation"), "set_random_rotation", "get_random_rotation");
ClassDB::bind_method(D_METHOD("_init_properties"), &SdOpRepeat::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdOpRepeat::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdOpRepeat::_get_property_value);
ClassDB::bind_method(D_METHOD("get_x"), &SdOpRepeat::get_x);
ClassDB::bind_method(D_METHOD("set_x", "val"), &SdOpRepeat::set_x);
ClassDB::bind_method(D_METHOD("get_y"), &SdOpRepeat::get_y);
ClassDB::bind_method(D_METHOD("set_y", "val"), &SdOpRepeat::set_y);
ClassDB::bind_method(D_METHOD("get_random_rotation"), &SdOpRepeat::get_random_rotation);
ClassDB::bind_method(D_METHOD("set_random_rotation", "val"), &SdOpRepeat::set_random_rotation);
}

View File

@ -1,53 +1,39 @@
#ifndef SD_OP_REPEAT_H #ifndef MM_SD_OP_REPEAT_H
#define SD_OP_REPEAT_H #define MM_SD_OP_REPEAT_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class SdOpRepeat : public MMNode { class MMSdOpRepeat : public MMNode {
GDCLASS(SdOpRepeat, MMNode); GDCLASS(MMSdOpRepeat, MMNode);
public: public:
Ref<MMNodeUniversalProperty> get_output();
void set_output(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_output(); int get_x() const;
void set_output(const Ref<Resource> &val); void set_x(const int val);
int get_x() const; int get_y() const;
void set_x(const int val); void set_y(const int val);
int get_y() const; float get_random_rotation() const;
void set_y(const int val); void set_random_rotation(const float val);
float get_random_rotation() const; void _init_properties();
void set_random_rotation(const float val); void _register_methods(MMGraphNode *mm_graph_node);
Variant _get_property_value(const Vector2 &uv);
void _init_properties(); MMSdOpRepeat();
void _register_methods(const Variant &mm_graph_node); ~MMSdOpRepeat();
void _get_property_value(const Vector2 &uv);
int get_x();
void set_x(const int val);
int get_y();
void set_y(const int val);
float get_random_rotation();
void set_random_rotation(const float val);
SdOpRepeat(); protected:
~SdOpRepeat(); static void _bind_methods();
protected: Ref<MMNodeUniversalProperty> output;
static void _bind_methods(); int x;
int y;
//tool float random_rotation;
//export(Resource)
Ref<Resource> output;
//export(int)
int x = 3;
//export(int)
int y = 3;
//export(float)
float random_rotation = 0.5;
//x
//y
//random_rotation
}; };
#endif #endif

View File

@ -1,102 +1,67 @@
#include "sd_op_rounded_shape.h" #include "sd_op_rounded_shape.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> SdOpRoundedShape::get_output() { Ref<MMNodeUniversalProperty> MMSdOpRoundedShape::get_output() {
return output; return output;
} }
void SdOpRoundedShape::set_output(const Ref<Resource> &val) { void MMSdOpRoundedShape::set_output(const Ref<MMNodeUniversalProperty> &val) {
output = val; output = val;
} }
float MMSdOpRoundedShape::get_radius() const {
float SdOpRoundedShape::get_radius() const { return radius;
return radius;
} }
void SdOpRoundedShape::set_radius(const float val) { void MMSdOpRoundedShape::set_radius(const float val) {
radius = val; radius = val;
emit_changed();
output->do_emit_changed();
} }
void MMSdOpRoundedShape::_init_properties() {
if (!output.is_valid()) {
output.instance();
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
}
output->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
//output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output->set_slot_name(">>> Apply >>>");
output->set_get_value_from_owner(true);
//tool; register_input_property(output);
//export(Resource) ; register_output_property(output);
Ref<Resource> output;
//export(float) ;
float radius = 0;
void SdOpRoundedShape::_init_properties() {
if (!output) {
output = MMNodeUniversalProperty.new();
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
} }
output.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL; void MMSdOpRoundedShape::_register_methods(MMGraphNode *mm_graph_node) {
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL; mm_graph_node->add_slot_label_universal(output);
//output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT; mm_graph_node->add_slot_float("get_radius", "set_radius", "Radius", 0.01);
output.slot_name = ">>> Apply >>>";
output.get_value_from_owner = true;
register_input_property(output);
register_output_property(output);
} }
Variant MMSdOpRoundedShape::_get_property_value(const Vector2 &uv) {
void SdOpRoundedShape::_register_methods(const Variant &mm_graph_node) { float val = output->get_value(uv, true);
mm_graph_node.add_slot_label_universal(output); return MMAlgos::sdf_rounded_shape(val, radius);
mm_graph_node.add_slot_float("get_radius", "set_radius", "Radius", 0.01);
} }
MMSdOpRoundedShape::MMSdOpRoundedShape() {
void SdOpRoundedShape::_get_property_value(const Vector2 &uv) { radius = 0;
float val = output.get_value(uv, true);
return MMAlgos.sdf_rounded_shape(val, radius);
} }
//radius; MMSdOpRoundedShape::~MMSdOpRoundedShape() {
float SdOpRoundedShape::get_radius() {
return radius;
} }
void MMSdOpRoundedShape::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &MMSdOpRoundedShape::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdOpRoundedShape::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
void SdOpRoundedShape::set_radius(const float val) { ClassDB::bind_method(D_METHOD("get_radius"), &MMSdOpRoundedShape::get_radius);
radius = val; ClassDB::bind_method(D_METHOD("set_radius", "value"), &MMSdOpRoundedShape::set_radius);
emit_changed(); ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius");
output.emit_changed();
} }
}
SdOpRoundedShape::SdOpRoundedShape() {
output;
radius = 0;
}
SdOpRoundedShape::~SdOpRoundedShape() {
}
static void SdOpRoundedShape::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_output"), &SdOpRoundedShape::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdOpRoundedShape::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_radius"), &SdOpRoundedShape::get_radius);
ClassDB::bind_method(D_METHOD("set_radius", "value"), &SdOpRoundedShape::set_radius);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius"), "set_radius", "get_radius");
ClassDB::bind_method(D_METHOD("_init_properties"), &SdOpRoundedShape::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdOpRoundedShape::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdOpRoundedShape::_get_property_value);
ClassDB::bind_method(D_METHOD("get_radius"), &SdOpRoundedShape::get_radius);
ClassDB::bind_method(D_METHOD("set_radius", "val"), &SdOpRoundedShape::set_radius);
}

View File

@ -1,37 +1,31 @@
#ifndef SD_OP_ROUNDED_SHAPE_H #ifndef MM_SD_OP_ROUNDED_SHAPE_H
#define SD_OP_ROUNDED_SHAPE_H #define MM_SD_OP_ROUNDED_SHAPE_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class SdOpRoundedShape : public MMNode { class MMSdOpRoundedShape : public MMNode {
GDCLASS(SdOpRoundedShape, MMNode); GDCLASS(MMSdOpRoundedShape, MMNode);
public: public:
Ref<MMNodeUniversalProperty> get_output();
void set_output(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_output(); float get_radius() const;
void set_output(const Ref<Resource> &val); void set_radius(const float val);
float get_radius() const; void _init_properties();
void set_radius(const float val); void _register_methods(MMGraphNode *mm_graph_node);
Variant _get_property_value(const Vector2 &uv);
void _init_properties(); MMSdOpRoundedShape();
void _register_methods(const Variant &mm_graph_node); ~MMSdOpRoundedShape();
void _get_property_value(const Vector2 &uv);
float get_radius();
void set_radius(const float val);
SdOpRoundedShape(); protected:
~SdOpRoundedShape(); static void _bind_methods();
protected: Ref<MMNodeUniversalProperty> output;
static void _bind_methods(); float radius;
//tool
//export(Resource)
Ref<Resource> output;
//export(float)
float radius = 0;
//radius
}; };
#endif #endif

View File

@ -1,220 +1,155 @@
#include "sd_op_smooth_bool.h" #include "sd_op_smooth_bool.h"
#include "../../algos/mm_algos.h"
#include "../../editor/mm_graph_node.h"
#include "../mm_material.h"
Ref<Resource> SdOpSmoothBool::get_input1() { Ref<MMNodeUniversalProperty> MMSdOpSmoothBool::get_input1() {
return input1; return input1;
} }
void SdOpSmoothBool::set_input1(const Ref<Resource> &val) { void MMSdOpSmoothBool::set_input1(const Ref<MMNodeUniversalProperty> &val) {
input1 = val; input1 = val;
} }
Ref<MMNodeUniversalProperty> MMSdOpSmoothBool::get_input2() {
Ref<Resource> SdOpSmoothBool::get_input2() { return input2;
return input2;
} }
void SdOpSmoothBool::set_input2(const Ref<Resource> &val) { void MMSdOpSmoothBool::set_input2(const Ref<MMNodeUniversalProperty> &val) {
input2 = val; input2 = val;
} }
Ref<MMNodeUniversalProperty> MMSdOpSmoothBool::get_output() {
Ref<Resource> SdOpSmoothBool::get_output() { return output;
return output;
} }
void SdOpSmoothBool::set_output(const Ref<Resource> &val) { void MMSdOpSmoothBool::set_output(const Ref<MMNodeUniversalProperty> &val) {
output = val; output = val;
} }
int MMSdOpSmoothBool::get_operation() const {
int SdOpSmoothBool::get_operation() const { return operation;
return operation;
} }
void SdOpSmoothBool::set_operation(const int val) { void MMSdOpSmoothBool::set_operation(const int val) {
operation = val; operation = val;
emit_changed();
output->do_emit_changed();
} }
float MMSdOpSmoothBool::get_smoothness() const {
float SdOpSmoothBool::get_smoothness() const { return smoothness;
return smoothness;
} }
void SdOpSmoothBool::set_smoothness(const float val) { void MMSdOpSmoothBool::set_smoothness(const float val) {
smoothness = val; smoothness = val;
emit_changed();
output->do_emit_changed();
} }
void MMSdOpSmoothBool::_init_properties() {
if (!input1.is_valid()) {
input1.instance();
input1->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
}
input1->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
// input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
input1->set_slot_name(">>> Input 1 ");
//tool; if (!input1->is_connected("changed", this, "on_input_changed")) {
//export(Resource) ; input1->connect("changed", this, "on_input_changed");
Ref<Resource> input1; }
//export(Resource) ;
Ref<Resource> input2;
//export(Resource) ;
Ref<Resource> output;
//export(int, "Union,Substraction,Intersection") ;
int operation = 0;
//export(float) ;
float smoothness = 0.15;
void SdOpSmoothBool::_init_properties() { if (!input2.is_valid()) {
input2.instance();
input2->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
}
if (!input1) { input2->set_input_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
input1 = MMNodeUniversalProperty.new(); // input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
input1.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT; input2->set_slot_name(">>> Input 2 ");
if (!input2->is_connected("changed", this, "on_input_changed")) {
input2->connect("changed", this, "on_input_changed");
}
if (!output.is_valid()) {
output.instance();
output->set_default_type(MMNodeUniversalProperty::DEFAULT_TYPE_FLOAT);
}
output->set_output_slot_type(MMNodeUniversalProperty::SLOT_TYPE_UNIVERSAL);
// output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output->set_slot_name(" Output >>>");
output->set_get_value_from_owner(true);
register_input_property(input1);
register_input_property(input2);
register_output_property(output);
} }
input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL; void MMSdOpSmoothBool::_register_methods(MMGraphNode *mm_graph_node) {
// input1.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT; mm_graph_node->add_slot_label_universal(input1);
input1.slot_name = ">>> Input 1 "; mm_graph_node->add_slot_label_universal(input2);
mm_graph_node->add_slot_label_universal(output);
if (!input1.is_connected("changed", self, "on_input_changed")) { Array arr;
input1.connect("changed", self, "on_input_changed"); arr.push_back("Union");
arr.push_back("Substraction");
arr.push_back("Intersection");
mm_graph_node->add_slot_enum("get_operation", "set_operation", "Operation", arr);
mm_graph_node->add_slot_float("get_smoothness", "set_smoothness", "Smoothness", 0.01);
} }
Variant MMSdOpSmoothBool::_get_property_value(const Vector2 &uv) {
if (operation == 0) {
return MMAlgos::sdf_smooth_boolean_union(input1->get_value(uv), input2->get_value(uv), smoothness);
} else if (operation == 1) {
return MMAlgos::sdf_smooth_boolean_substraction(input1->get_value(uv), input2->get_value(uv), smoothness);
} else if (operation == 2) {
return MMAlgos::sdf_smooth_boolean_intersection(input1->get_value(uv), input2->get_value(uv), smoothness);
}
if (!input2) { return 0.0;
input2 = MMNodeUniversalProperty.new();
input2.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
} }
input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL; void MMSdOpSmoothBool::on_input_changed() {
// input2.input_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT; emit_changed();
input2.slot_name = ">>> Input 2 "; output->do_emit_changed();
if (!input2.is_connected("changed", self, "on_input_changed")) {
input2.connect("changed", self, "on_input_changed");
} }
MMSdOpSmoothBool::MMSdOpSmoothBool() {
if (!output) { operation = 0;
output = MMNodeUniversalProperty.new(); smoothness = 0.15;
output.default_type = MMNodeUniversalProperty.DEFAULT_TYPE_FLOAT;
} }
output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_UNIVERSAL; MMSdOpSmoothBool::~MMSdOpSmoothBool() {
// output.output_slot_type = MMNodeUniversalProperty.SLOT_TYPE_FLOAT;
output.slot_name = " Output >>>";
output.get_value_from_owner = true;
register_input_property(input1);
register_input_property(input2);
register_output_property(output);
} }
void MMSdOpSmoothBool::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_input1"), &MMSdOpSmoothBool::get_input1);
ClassDB::bind_method(D_METHOD("set_input1", "value"), &MMSdOpSmoothBool::set_input1);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input1", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input1", "get_input1");
void SdOpSmoothBool::_register_methods(const Variant &mm_graph_node) { ClassDB::bind_method(D_METHOD("get_input2"), &MMSdOpSmoothBool::get_input2);
mm_graph_node.add_slot_label_universal(input1); ClassDB::bind_method(D_METHOD("set_input2", "value"), &MMSdOpSmoothBool::set_input2);
mm_graph_node.add_slot_label_universal(input2); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input2", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_input2", "get_input2");
mm_graph_node.add_slot_label_universal(output);
mm_graph_node.add_slot_enum("get_operation", "set_operation", "Operation", [ "Union", "Substraction", "Intersection" ]); ClassDB::bind_method(D_METHOD("get_output"), &MMSdOpSmoothBool::get_output);
mm_graph_node.add_slot_float("get_smoothness", "set_smoothness", "Smoothness", 0.01); ClassDB::bind_method(D_METHOD("set_output", "value"), &MMSdOpSmoothBool::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "MMNodeUniversalProperty"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_operation"), &MMSdOpSmoothBool::get_operation);
ClassDB::bind_method(D_METHOD("set_operation", "value"), &MMSdOpSmoothBool::set_operation);
ADD_PROPERTY(PropertyInfo(Variant::INT, "operation"), "set_operation", "get_operation");
ClassDB::bind_method(D_METHOD("get_smoothness"), &MMSdOpSmoothBool::get_smoothness);
ClassDB::bind_method(D_METHOD("set_smoothness", "value"), &MMSdOpSmoothBool::set_smoothness);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "smoothness"), "set_smoothness", "get_smoothness");
ClassDB::bind_method(D_METHOD("on_input_changed"), &MMSdOpSmoothBool::on_input_changed);
} }
float SdOpSmoothBool::_get_property_value(const Vector2 &uv) {
if (operation == 0) {
return MMAlgos.sdf_smooth_boolean_union(input1.get_value(uv), input2.get_value(uv), smoothness);
}
else if (operation == 1) {
return MMAlgos.sdf_smooth_boolean_substraction(input1.get_value(uv), input2.get_value(uv), smoothness);
}
else if (operation == 2) {
return MMAlgos.sdf_smooth_boolean_intersection(input1.get_value(uv), input2.get_value(uv), smoothness);
}
return 0.0;
}
//operation;
int SdOpSmoothBool::get_operation() {
return operation;
}
void SdOpSmoothBool::set_operation(const int val) {
operation = val;
emit_changed();
output.emit_changed();
}
//smoothness;
float SdOpSmoothBool::get_smoothness() {
return smoothness;
}
void SdOpSmoothBool::set_smoothness(const float val) {
smoothness = val;
emit_changed();
output.emit_changed();
}
void SdOpSmoothBool::on_input_changed() {
emit_changed();
output.emit_changed();
}
}
SdOpSmoothBool::SdOpSmoothBool() {
input1;
input2;
output;
operation = 0;
smoothness = 0.15;
}
SdOpSmoothBool::~SdOpSmoothBool() {
}
static void SdOpSmoothBool::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_input1"), &SdOpSmoothBool::get_input1);
ClassDB::bind_method(D_METHOD("set_input1", "value"), &SdOpSmoothBool::set_input1);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input1", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input1", "get_input1");
ClassDB::bind_method(D_METHOD("get_input2"), &SdOpSmoothBool::get_input2);
ClassDB::bind_method(D_METHOD("set_input2", "value"), &SdOpSmoothBool::set_input2);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "input2", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_input2", "get_input2");
ClassDB::bind_method(D_METHOD("get_output"), &SdOpSmoothBool::get_output);
ClassDB::bind_method(D_METHOD("set_output", "value"), &SdOpSmoothBool::set_output);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "output", PROPERTY_HINT_RESOURCE_TYPE, "Ref<Resource>"), "set_output", "get_output");
ClassDB::bind_method(D_METHOD("get_operation"), &SdOpSmoothBool::get_operation);
ClassDB::bind_method(D_METHOD("set_operation", "value"), &SdOpSmoothBool::set_operation);
ADD_PROPERTY(PropertyInfo(Variant::INT, "operation"), "set_operation", "get_operation");
ClassDB::bind_method(D_METHOD("get_smoothness"), &SdOpSmoothBool::get_smoothness);
ClassDB::bind_method(D_METHOD("set_smoothness", "value"), &SdOpSmoothBool::set_smoothness);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "smoothness"), "set_smoothness", "get_smoothness");
ClassDB::bind_method(D_METHOD("_init_properties"), &SdOpSmoothBool::_init_properties);
ClassDB::bind_method(D_METHOD("_register_methods", "mm_graph_node"), &SdOpSmoothBool::_register_methods);
ClassDB::bind_method(D_METHOD("_get_property_value", "uv"), &SdOpSmoothBool::_get_property_value);
ClassDB::bind_method(D_METHOD("get_operation"), &SdOpSmoothBool::get_operation);
ClassDB::bind_method(D_METHOD("set_operation", "val"), &SdOpSmoothBool::set_operation);
ClassDB::bind_method(D_METHOD("get_smoothness"), &SdOpSmoothBool::get_smoothness);
ClassDB::bind_method(D_METHOD("set_smoothness", "val"), &SdOpSmoothBool::set_smoothness);
ClassDB::bind_method(D_METHOD("on_input_changed"), &SdOpSmoothBool::on_input_changed);
}

View File

@ -1,56 +1,46 @@
#ifndef SD_OP_SMOOTH_BOOL_H #ifndef MM_SD_OP_SMOOTH_BOOL_H
#define SD_OP_SMOOTH_BOOL_H #define MM_SD_OP_SMOOTH_BOOL_H
#include "../mm_node.h"
#include "../mm_node_universal_property.h"
class SdOpSmoothBool : public MMNode { class MMSdOpSmoothBool : public MMNode {
GDCLASS(SdOpSmoothBool, MMNode); GDCLASS(MMSdOpSmoothBool, MMNode);
public: public:
Ref<MMNodeUniversalProperty> get_input1();
void set_input1(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input1(); Ref<MMNodeUniversalProperty> get_input2();
void set_input1(const Ref<Resource> &val); void set_input2(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_input2(); Ref<MMNodeUniversalProperty> get_output();
void set_input2(const Ref<Resource> &val); void set_output(const Ref<MMNodeUniversalProperty> &val);
Ref<Resource> get_output(); int get_operation() const;
void set_output(const Ref<Resource> &val); void set_operation(const int val);
int get_operation() const; float get_smoothness() const;
void set_operation(const int val); void set_smoothness(const float val);
float get_smoothness() const; void _init_properties();
void set_smoothness(const float val); void _register_methods(MMGraphNode *mm_graph_node);
Variant _get_property_value(const Vector2 &uv);
void _init_properties(); void on_input_changed();
void _register_methods(const Variant &mm_graph_node);
float _get_property_value(const Vector2 &uv);
int get_operation();
void set_operation(const int val);
float get_smoothness();
void set_smoothness(const float val);
void on_input_changed();
SdOpSmoothBool(); MMSdOpSmoothBool();
~SdOpSmoothBool(); ~MMSdOpSmoothBool();
protected: protected:
static void _bind_methods(); static void _bind_methods();
//tool Ref<MMNodeUniversalProperty> input1;
//export(Resource) Ref<MMNodeUniversalProperty> input2;
Ref<Resource> input1; Ref<MMNodeUniversalProperty> output;
//export(Resource) //export(int, "Union,Substraction,Intersection")
Ref<Resource> input2; int operation;
//export(Resource) float smoothness;
Ref<Resource> output;
//export(int, "Union,Substraction,Intersection")
int operation = 0;
//export(float)
float smoothness = 0.15;
//operation
//smoothness
}; };
#endif #endif

View File

@ -84,6 +84,8 @@ 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_show.h"
#include "nodes/sdf2d/sd_shape_arc.h" #include "nodes/sdf2d/sd_shape_arc.h"
#include "nodes/sdf2d/sd_shape_box.h" #include "nodes/sdf2d/sd_shape_box.h"
#include "nodes/sdf2d/sd_shape_circle.h" #include "nodes/sdf2d/sd_shape_circle.h"
@ -95,7 +97,15 @@ SOFTWARE.
#include "nodes/sdf2d/sd_tf_scale.h" #include "nodes/sdf2d/sd_tf_scale.h"
#include "nodes/sdf2d/sd_tf_translate.h" #include "nodes/sdf2d/sd_tf_translate.h"
#include "nodes/sdf2d/sd_show.h" #include "nodes/sdf2d/sd_tf_translate.h"
#include "nodes/sdf2d/sd_op_annular_shape.h"
#include "nodes/sdf2d/sd_op_bool.h"
#include "nodes/sdf2d/sd_op_circle_repeat.h"
#include "nodes/sdf2d/sd_op_morph.h"
#include "nodes/sdf2d/sd_op_repeat.h"
#include "nodes/sdf2d/sd_op_rounded_shape.h"
#include "nodes/sdf2d/sd_op_smooth_bool.h"
static _MMAlgos *_mm_algos_singleton = nullptr; static _MMAlgos *_mm_algos_singleton = nullptr;
@ -213,6 +223,21 @@ void register_material_maker_types() {
ClassDB::register_class<MMSdTfRotate>(); ClassDB::register_class<MMSdTfRotate>();
MMAlgos::register_node_class("SDF2D - TF", "MMSdTfRotate"); MMAlgos::register_node_class("SDF2D - TF", "MMSdTfRotate");
ClassDB::register_class<MMSdOpSmoothBool>();
MMAlgos::register_node_class("SDF2D - OP", "MMSdOpSmoothBool");
ClassDB::register_class<MMSdOpRoundedShape>();
MMAlgos::register_node_class("SDF2D - OP", "MMSdOpRoundedShape");
ClassDB::register_class<MMSdOpRepeat>();
MMAlgos::register_node_class("SDF2D - OP", "MMSdOpRepeat");
ClassDB::register_class<MMSdOpMorph>();
MMAlgos::register_node_class("SDF2D - OP", "MMSdOpMorph");
ClassDB::register_class<MMSdOpCircleRepeat>();
MMAlgos::register_node_class("SDF2D - OP", "MMSdOpCircleRepeat");
ClassDB::register_class<MMSdOpBool>();
MMAlgos::register_node_class("SDF2D - OP", "MMSdOpBool");
ClassDB::register_class<MMSdOpAnnularShape>();
MMAlgos::register_node_class("SDF2D - OP", "MMSdOpAnnularShape");
_mm_algos_singleton = memnew(_MMAlgos); _mm_algos_singleton = memnew(_MMAlgos);
Engine::get_singleton()->add_singleton(Engine::Singleton("MMAlgos", _MMAlgos::get_singleton())); Engine::get_singleton()->add_singleton(Engine::Singleton("MMAlgos", _MMAlgos::get_singleton()));