summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/etc/SCsub4
-rw-r--r--modules/gdnative/godot/basis.cpp18
-rw-r--r--modules/gdnative/godot/basis.h6
-rw-r--r--modules/svg/image_loader_svg.cpp51
-rw-r--r--modules/svg/image_loader_svg.h7
-rw-r--r--modules/visual_script/visual_script_editor.cpp24
6 files changed, 68 insertions, 42 deletions
diff --git a/modules/etc/SCsub b/modules/etc/SCsub
index 8f5937017e..f0c1ee64b9 100644
--- a/modules/etc/SCsub
+++ b/modules/etc/SCsub
@@ -35,3 +35,7 @@ env_etc.add_source_files(env.modules_sources, "*.cpp")
# upstream uses c++11
env_etc.Append(CXXFLAGS="-std=gnu++11")
+# -ffast-math seems to be incompatible with ec2comp on recent versions of
+# GCC and Clang
+if '-ffast-math' in env_etc['CCFLAGS']:
+ env_etc['CCFLAGS'].remove('-ffast-math')
diff --git a/modules/gdnative/godot/basis.cpp b/modules/gdnative/godot/basis.cpp
index 8433355c12..1d7aa18a70 100644
--- a/modules/gdnative/godot/basis.cpp
+++ b/modules/gdnative/godot/basis.cpp
@@ -107,24 +107,6 @@ godot_basis GDAPI godot_basis_scaled(const godot_basis *p_self, const godot_vect
return dest;
}
-void GDAPI godot_basis_set_scale(godot_basis *p_self, const godot_vector3 *p_scale) {
- Basis *self = (Basis *)p_self;
- const Vector3 *scale = (const Vector3 *)p_scale;
- self->set_scale(*scale);
-}
-
-void GDAPI godot_basis_set_rotation_euler(godot_basis *p_self, const godot_vector3 *p_euler) {
- Basis *self = (Basis *)p_self;
- const Vector3 *euler = (const Vector3 *)p_euler;
- self->set_rotation_euler(*euler);
-}
-
-void GDAPI godot_basis_set_rotation_axis_angle(godot_basis *p_self, const godot_vector3 *p_axis, const godot_real p_angle) {
- Basis *self = (Basis *)p_self;
- const Vector3 *axis = (const Vector3 *)p_axis;
- self->set_rotation_axis_angle(*axis, p_angle);
-}
-
godot_vector3 GDAPI godot_basis_get_scale(const godot_basis *p_self) {
godot_vector3 dest;
const Basis *self = (const Basis *)p_self;
diff --git a/modules/gdnative/godot/basis.h b/modules/gdnative/godot/basis.h
index d336bb9bc1..f36d2199de 100644
--- a/modules/gdnative/godot/basis.h
+++ b/modules/gdnative/godot/basis.h
@@ -67,12 +67,6 @@ godot_basis GDAPI godot_basis_rotated(const godot_basis *p_self, const godot_vec
godot_basis GDAPI godot_basis_scaled(const godot_basis *p_self, const godot_vector3 *p_scale);
-void GDAPI godot_basis_set_scale(godot_basis *p_self, const godot_vector3 *p_scale);
-
-void GDAPI godot_basis_set_rotation_euler(godot_basis *p_self, const godot_vector3 *p_euler);
-
-void GDAPI godot_basis_set_rotation_axis_angle(godot_basis *p_self, const godot_vector3 *p_axis, const godot_real p_angle);
-
godot_vector3 GDAPI godot_basis_get_scale(const godot_basis *p_self);
godot_vector3 GDAPI godot_basis_get_euler(const godot_basis *p_self);
diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp
index 086cc202f9..f5c379d32e 100644
--- a/modules/svg/image_loader_svg.cpp
+++ b/modules/svg/image_loader_svg.cpp
@@ -47,7 +47,49 @@ SVGRasterizer::~SVGRasterizer() {
SVGRasterizer ImageLoaderSVG::rasterizer;
-Error ImageLoaderSVG::_create_image(Ref<Image> p_image, const PoolVector<uint8_t> *p_data, float p_scale, bool upsample) {
+inline void change_nsvg_paint_color(NSVGpaint *p_paint, const uint32_t p_old, const uint32_t p_new) {
+
+ if (p_paint->type == NSVG_PAINT_COLOR) {
+ if (p_paint->color << 8 == p_old << 8) {
+ p_paint->color = p_new;
+ }
+ }
+
+ if (p_paint->type == NSVG_PAINT_LINEAR_GRADIENT || p_paint->type == NSVG_PAINT_RADIAL_GRADIENT) {
+ for (int stop_index = 0; stop_index < p_paint->gradient->nstops; stop_index++) {
+ if (p_paint->gradient->stops[stop_index].color << 8 == p_old << 8) {
+ p_paint->gradient->stops[stop_index].color = p_new;
+ }
+ }
+ }
+}
+void ImageLoaderSVG::_convert_colors(NSVGimage *p_svg_image, const Dictionary p_colors) {
+ List<uint32_t> replace_colors_i;
+ List<uint32_t> new_colors_i;
+ List<Color> replace_colors;
+ List<Color> new_colors;
+
+ for (int i = 0; i < p_colors.keys().size(); i++) {
+ Variant r_c = p_colors.keys()[i];
+ Variant n_c = p_colors[p_colors.keys()[i]];
+ if (r_c.get_type() == Variant::COLOR && n_c.get_type() == Variant::COLOR) {
+ Color replace_color = r_c;
+ Color new_color = n_c;
+ replace_colors_i.push_back(replace_color.to_ABGR32());
+ new_colors_i.push_back(new_color.to_ABGR32());
+ }
+ }
+
+ for (NSVGshape *shape = p_svg_image->shapes; shape != NULL; shape = shape->next) {
+
+ for (int i = 0; i < replace_colors_i.size(); i++) {
+ change_nsvg_paint_color(&(shape->stroke), replace_colors_i[i], new_colors_i[i]);
+ change_nsvg_paint_color(&(shape->fill), replace_colors_i[i], new_colors_i[i]);
+ }
+ }
+}
+
+Error ImageLoaderSVG::_create_image(Ref<Image> p_image, const PoolVector<uint8_t> *p_data, float p_scale, bool upsample, const Dictionary *p_replace_colors) {
NSVGimage *svg_image;
PoolVector<uint8_t>::Read src_r = p_data->read();
svg_image = nsvgParse((char *)src_r.ptr(), "px", 96);
@@ -56,6 +98,9 @@ Error ImageLoaderSVG::_create_image(Ref<Image> p_image, const PoolVector<uint8_t
return ERR_FILE_CORRUPT;
}
+ if (p_replace_colors != NULL) {
+ _convert_colors(svg_image, *p_replace_colors);
+ }
float upscale = upsample ? 2.0 : 1.0;
int w = (int)(svg_image->width * p_scale * upscale);
@@ -78,7 +123,7 @@ Error ImageLoaderSVG::_create_image(Ref<Image> p_image, const PoolVector<uint8_t
return OK;
}
-Error ImageLoaderSVG::create_image_from_string(Ref<Image> p_image, const char *svg_str, float p_scale, bool upsample) {
+Error ImageLoaderSVG::create_image_from_string(Ref<Image> p_image, const char *svg_str, float p_scale, bool upsample, const Dictionary *p_replace_colors) {
size_t str_len = strlen(svg_str);
PoolVector<uint8_t> src_data;
@@ -86,7 +131,7 @@ Error ImageLoaderSVG::create_image_from_string(Ref<Image> p_image, const char *s
PoolVector<uint8_t>::Write src_w = src_data.write();
memcpy(src_w.ptr(), svg_str, str_len + 1);
- return _create_image(p_image, &src_data, p_scale, upsample);
+ return _create_image(p_image, &src_data, p_scale, upsample, p_replace_colors);
}
Error ImageLoaderSVG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
diff --git a/modules/svg/image_loader_svg.h b/modules/svg/image_loader_svg.h
index 1f2ec3c1c2..f692b1b28c 100644
--- a/modules/svg/image_loader_svg.h
+++ b/modules/svg/image_loader_svg.h
@@ -54,14 +54,15 @@ public:
class ImageLoaderSVG : public ImageFormatLoader {
static SVGRasterizer rasterizer;
- static Error _create_image(Ref<Image> p_image, const PoolVector<uint8_t> *p_data, float p_scale, bool upsample);
+ static void _convert_colors(NSVGimage *p_svg_imge, const Dictionary p_colors);
+ static Error _create_image(Ref<Image> p_image, const PoolVector<uint8_t> *p_data, float p_scale, bool upsample, const Dictionary *p_replace_color = NULL);
public:
- static Error create_image_from_string(Ref<Image> p_image, const char *p_svg_str, float p_scale, bool upsample);
+ static Error create_image_from_string(Ref<Image> p_image, const char *p_svg_str, float p_scale, bool upsample, const Dictionary *p_replace_color = NULL);
virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
ImageLoaderSVG();
};
-#endif \ No newline at end of file
+#endif
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 7ab2a93b55..05ceb7a38f 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -886,8 +886,8 @@ void VisualScriptEditor::_member_edited() {
undo_redo->add_undo_method(this, "_update_members");
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
- undo_redo->add_do_method(this, "emit_signal", "script_changed");
- undo_redo->add_undo_method(this, "emit_signal", "script_changed");
+ undo_redo->add_do_method(this, "emit_signal", "edited_script_changed");
+ undo_redo->add_undo_method(this, "emit_signal", "edited_script_changed");
undo_redo->commit_action();
// _update_graph();
@@ -903,8 +903,8 @@ void VisualScriptEditor::_member_edited() {
undo_redo->add_undo_method(script.ptr(), "rename_variable", new_name, name);
undo_redo->add_do_method(this, "_update_members");
undo_redo->add_undo_method(this, "_update_members");
- undo_redo->add_do_method(this, "emit_signal", "script_changed");
- undo_redo->add_undo_method(this, "emit_signal", "script_changed");
+ undo_redo->add_do_method(this, "emit_signal", "edited_script_changed");
+ undo_redo->add_undo_method(this, "emit_signal", "edited_script_changed");
undo_redo->commit_action();
return; //or crash because it will become invalid
@@ -918,8 +918,8 @@ void VisualScriptEditor::_member_edited() {
undo_redo->add_undo_method(script.ptr(), "rename_custom_signal", new_name, name);
undo_redo->add_do_method(this, "_update_members");
undo_redo->add_undo_method(this, "_update_members");
- undo_redo->add_do_method(this, "emit_signal", "script_changed");
- undo_redo->add_undo_method(this, "emit_signal", "script_changed");
+ undo_redo->add_do_method(this, "emit_signal", "edited_script_changed");
+ undo_redo->add_undo_method(this, "emit_signal", "edited_script_changed");
undo_redo->commit_action();
return; //or crash because it will become invalid
@@ -1057,8 +1057,8 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
undo_redo->add_undo_method(this, "_update_members");
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
- undo_redo->add_do_method(this, "emit_signal", "script_changed");
- undo_redo->add_undo_method(this, "emit_signal", "script_changed");
+ undo_redo->add_do_method(this, "emit_signal", "edited_script_changed");
+ undo_redo->add_undo_method(this, "emit_signal", "edited_script_changed");
undo_redo->commit_action();
_update_graph();
@@ -1077,8 +1077,8 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
undo_redo->add_undo_method(script.ptr(), "remove_variable", name);
undo_redo->add_do_method(this, "_update_members");
undo_redo->add_undo_method(this, "_update_members");
- undo_redo->add_do_method(this, "emit_signal", "script_changed");
- undo_redo->add_undo_method(this, "emit_signal", "script_changed");
+ undo_redo->add_do_method(this, "emit_signal", "edited_script_changed");
+ undo_redo->add_undo_method(this, "emit_signal", "edited_script_changed");
undo_redo->commit_action();
return; //or crash because it will become invalid
}
@@ -1093,8 +1093,8 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
undo_redo->add_undo_method(script.ptr(), "remove_custom_signal", name);
undo_redo->add_do_method(this, "_update_members");
undo_redo->add_undo_method(this, "_update_members");
- undo_redo->add_do_method(this, "emit_signal", "script_changed");
- undo_redo->add_undo_method(this, "emit_signal", "script_changed");
+ undo_redo->add_do_method(this, "emit_signal", "edited_script_changed");
+ undo_redo->add_undo_method(this, "emit_signal", "edited_script_changed");
undo_redo->commit_action();
return; //or crash because it will become invalid
}