summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/enet/networked_multiplayer_enet.cpp10
-rw-r--r--modules/gdnative/gdnative.cpp7
-rw-r--r--modules/gdscript/gd_compiler.cpp4
-rw-r--r--modules/gdscript/gd_editor.cpp3
-rw-r--r--modules/gdscript/gd_functions.cpp30
-rw-r--r--modules/gdscript/gd_functions.h2
-rw-r--r--modules/gdscript/gd_parser.cpp20
-rw-r--r--modules/gdscript/gd_tokenizer.cpp4
-rw-r--r--modules/hdr/image_loader_hdr.cpp2
-rw-r--r--modules/hdr/image_loader_hdr.h2
-rw-r--r--modules/jpg/image_loader_jpegd.cpp2
-rw-r--r--modules/jpg/image_loader_jpegd.h2
-rw-r--r--modules/nativescript/api_generator.cpp3
-rw-r--r--modules/openssl/stream_peer_openssl.cpp13
-rw-r--r--modules/pbm/bitmap_loader_pbm.cpp3
-rw-r--r--modules/svg/SCsub34
-rw-r--r--modules/svg/config.py7
-rw-r--r--modules/svg/image_loader_svg.cpp110
-rw-r--r--modules/svg/image_loader_svg.h67
-rw-r--r--modules/svg/register_types.cpp45
-rw-r--r--modules/svg/register_types.h31
-rw-r--r--modules/tga/image_loader_tga.cpp2
-rw-r--r--modules/tga/image_loader_tga.h2
-rw-r--r--modules/theora/video_stream_theora.cpp1
-rw-r--r--modules/tinyexr/image_loader_tinyexr.cpp2
-rw-r--r--modules/tinyexr/image_loader_tinyexr.h2
-rw-r--r--modules/visual_script/visual_script.cpp2
-rw-r--r--modules/visual_script/visual_script_func_nodes.cpp23
-rw-r--r--modules/visual_script/visual_script_nodes.cpp6
-rw-r--r--modules/visual_script/visual_script_nodes.h2
-rw-r--r--modules/visual_script/visual_script_yield_nodes.cpp12
-rw-r--r--modules/webp/image_loader_webp.cpp2
-rw-r--r--modules/webp/image_loader_webp.h2
33 files changed, 385 insertions, 74 deletions
diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp
index 68d5c9e611..c76e0c6675 100644
--- a/modules/enet/networked_multiplayer_enet.cpp
+++ b/modules/enet/networked_multiplayer_enet.cpp
@@ -658,11 +658,11 @@ void NetworkedMultiplayerENet::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_compression_mode"), &NetworkedMultiplayerENet::get_compression_mode);
ClassDB::bind_method(D_METHOD("set_bind_ip", "ip"), &NetworkedMultiplayerENet::set_bind_ip);
- BIND_CONSTANT(COMPRESS_NONE);
- BIND_CONSTANT(COMPRESS_RANGE_CODER);
- BIND_CONSTANT(COMPRESS_FASTLZ);
- BIND_CONSTANT(COMPRESS_ZLIB);
- BIND_CONSTANT(COMPRESS_ZSTD);
+ BIND_ENUM_CONSTANT(COMPRESS_NONE);
+ BIND_ENUM_CONSTANT(COMPRESS_RANGE_CODER);
+ BIND_ENUM_CONSTANT(COMPRESS_FASTLZ);
+ BIND_ENUM_CONSTANT(COMPRESS_ZLIB);
+ BIND_ENUM_CONSTANT(COMPRESS_ZSTD);
}
NetworkedMultiplayerENet::NetworkedMultiplayerENet() {
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp
index 440cc45479..ccc7e5f2da 100644
--- a/modules/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative.cpp
@@ -229,7 +229,7 @@ bool GDNative::initialize() {
godot_gdnative_init_options options;
- options.in_editor = SceneTree::get_singleton()->is_editor_hint();
+ options.in_editor = Engine::get_singleton()->is_editor_hint();
options.core_api_hash = ClassDB::get_api_hash(ClassDB::API_CORE);
options.editor_api_hash = ClassDB::get_api_hash(ClassDB::API_EDITOR);
options.no_api_hash = ClassDB::get_api_hash(ClassDB::API_NONE);
@@ -247,9 +247,8 @@ bool GDNative::terminate() {
return false;
}
- Error error = OK;
void *library_terminate;
- error = OS::get_singleton()->get_dynamic_library_symbol_handle(
+ Error error = OS::get_singleton()->get_dynamic_library_symbol_handle(
native_handle,
terminate_symbol,
library_terminate);
@@ -265,7 +264,7 @@ bool GDNative::terminate() {
// TODO(karroffel): remove this? Should be part of NativeScript, not
// GDNative IMO
godot_gdnative_terminate_options options;
- options.in_editor = SceneTree::get_singleton()->is_editor_hint();
+ options.in_editor = Engine::get_singleton()->is_editor_hint();
library_terminate_pointer(&options);
diff --git a/modules/gdscript/gd_compiler.cpp b/modules/gdscript/gd_compiler.cpp
index d4ede4cb17..c243f88b7a 100644
--- a/modules/gdscript/gd_compiler.cpp
+++ b/modules/gdscript/gd_compiler.cpp
@@ -1451,15 +1451,13 @@ Error GDCompiler::_parse_function(GDScript *p_script, const GDParser::ClassNode
codegen.opcodes.push_back(GDFunction::OPCODE_END);
- GDFunction *gdfunc = NULL;
-
/*
if (String(p_func->name)=="") { //initializer func
gdfunc = &p_script->initializer;
*/
//} else { //regular func
p_script->member_functions[func_name] = memnew(GDFunction);
- gdfunc = p_script->member_functions[func_name];
+ GDFunction *gdfunc = p_script->member_functions[func_name];
//}
if (p_func) {
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp
index f8b45af85a..3fa0a38024 100644
--- a/modules/gdscript/gd_editor.cpp
+++ b/modules/gdscript/gd_editor.cpp
@@ -35,6 +35,7 @@
#ifdef TOOLS_ENABLED
#include "editor/editor_file_system.h"
#include "editor/editor_settings.h"
+#include "engine.h"
#endif
void GDScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const {
@@ -2371,7 +2372,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
String GDScriptLanguage::_get_indentation() const {
#ifdef TOOLS_ENABLED
- if (SceneTree::get_singleton()->is_editor_hint()) {
+ if (Engine::get_singleton()->is_editor_hint()) {
bool use_space_indentation = EDITOR_DEF("text_editor/indent/type", 0);
if (use_space_indentation) {
diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp
index 094dd287e6..65f0cbbe7d 100644
--- a/modules/gdscript/gd_functions.cpp
+++ b/modules/gdscript/gd_functions.cpp
@@ -70,6 +70,8 @@ const char *GDFunctions::get_func_name(Function p_func) {
"decimals",
"stepify",
"lerp",
+ "inverse_lerp",
+ "range_lerp",
"dectime",
"randomize",
"randi",
@@ -326,6 +328,22 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count,
VALIDATE_ARG_NUM(2);
r_ret = Math::lerp((double)*p_args[0], (double)*p_args[1], (double)*p_args[2]);
} break;
+ case MATH_INVERSE_LERP: {
+ VALIDATE_ARG_COUNT(3);
+ VALIDATE_ARG_NUM(0);
+ VALIDATE_ARG_NUM(1);
+ VALIDATE_ARG_NUM(2);
+ r_ret = Math::inverse_lerp((double)*p_args[0], (double)*p_args[1], (double)*p_args[2]);
+ } break;
+ case MATH_RANGE_LERP: {
+ VALIDATE_ARG_COUNT(5);
+ VALIDATE_ARG_NUM(0);
+ VALIDATE_ARG_NUM(1);
+ VALIDATE_ARG_NUM(2);
+ VALIDATE_ARG_NUM(3);
+ VALIDATE_ARG_NUM(4);
+ r_ret = Math::range_lerp((double)*p_args[0], (double)*p_args[1], (double)*p_args[2], (double)*p_args[3], (double)*p_args[4]);
+ } break;
case MATH_DECTIME: {
VALIDATE_ARG_COUNT(3);
VALIDATE_ARG_NUM(0);
@@ -1252,6 +1270,8 @@ bool GDFunctions::is_deterministic(Function p_func) {
case MATH_DECIMALS:
case MATH_STEPIFY:
case MATH_LERP:
+ case MATH_INVERSE_LERP:
+ case MATH_RANGE_LERP:
case MATH_DECTIME:
case MATH_DEG2RAD:
case MATH_RAD2DEG:
@@ -1420,6 +1440,16 @@ MethodInfo GDFunctions::get_info(Function p_func) {
mi.return_val.type = Variant::REAL;
return mi;
} break;
+ case MATH_INVERSE_LERP: {
+ MethodInfo mi("inverse_lerp", PropertyInfo(Variant::REAL, "from"), PropertyInfo(Variant::REAL, "to"), PropertyInfo(Variant::REAL, "value"));
+ mi.return_val.type = Variant::REAL;
+ return mi;
+ } break;
+ case MATH_RANGE_LERP: {
+ MethodInfo mi("range_lerp", PropertyInfo(Variant::REAL, "value"), PropertyInfo(Variant::REAL, "istart"), PropertyInfo(Variant::REAL, "istop"), PropertyInfo(Variant::REAL, "ostart"), PropertyInfo(Variant::REAL, "ostop"));
+ mi.return_val.type = Variant::REAL;
+ return mi;
+ } break;
case MATH_DECTIME: {
MethodInfo mi("dectime", PropertyInfo(Variant::REAL, "value"), PropertyInfo(Variant::REAL, "amount"), PropertyInfo(Variant::REAL, "step"));
mi.return_val.type = Variant::REAL;
diff --git a/modules/gdscript/gd_functions.h b/modules/gdscript/gd_functions.h
index 93cb524118..11dfbd473c 100644
--- a/modules/gdscript/gd_functions.h
+++ b/modules/gdscript/gd_functions.h
@@ -62,6 +62,8 @@ public:
MATH_DECIMALS,
MATH_STEPIFY,
MATH_LERP,
+ MATH_INVERSE_LERP,
+ MATH_RANGE_LERP,
MATH_DECTIME,
MATH_RANDOMIZE,
MATH_RAND,
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp
index 9023fd4bf4..7d3857266e 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gd_parser.cpp
@@ -2381,9 +2381,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
if (tokenizer->get_token() == GDTokenizer::TK_OP_ASSIGN) {
tokenizer->advance();
- Node *subexpr = NULL;
-
- subexpr = _parse_and_reduce_expression(p_block, p_static);
+ Node *subexpr = _parse_and_reduce_expression(p_block, p_static);
if (!subexpr) {
if (_recover_from_completion()) {
break;
@@ -3135,9 +3133,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
if (tokenizer->get_token() == GDTokenizer::TK_OP_ASSIGN) {
defaulting = true;
tokenizer->advance(1);
- Node *defval = NULL;
-
- defval = _parse_and_reduce_expression(p_class, _static);
+ Node *defval = _parse_and_reduce_expression(p_class, _static);
if (!defval || error_set)
return;
@@ -3875,9 +3871,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
#endif
tokenizer->advance();
- Node *subexpr = NULL;
-
- subexpr = _parse_and_reduce_expression(p_class, false, autoexport);
+ Node *subexpr = _parse_and_reduce_expression(p_class, false, autoexport);
if (!subexpr) {
if (_recover_from_completion()) {
break;
@@ -4035,9 +4029,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
- Node *subexpr = NULL;
-
- subexpr = _parse_and_reduce_expression(p_class, true, true);
+ Node *subexpr = _parse_and_reduce_expression(p_class, true, true);
if (!subexpr) {
if (_recover_from_completion()) {
break;
@@ -4103,9 +4095,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
if (tokenizer->get_token() == GDTokenizer::TK_OP_ASSIGN) {
tokenizer->advance();
- Node *subexpr = NULL;
-
- subexpr = _parse_and_reduce_expression(p_class, true, true);
+ Node *subexpr = _parse_and_reduce_expression(p_class, true, true);
if (!subexpr) {
if (_recover_from_completion()) {
break;
diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp
index 5803046185..f70982d7c0 100644
--- a/modules/gdscript/gd_tokenizer.cpp
+++ b/modules/gdscript/gd_tokenizer.cpp
@@ -1187,9 +1187,7 @@ Error GDTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer) {
int line_count = decode_uint32(&buf[16]);
int token_count = decode_uint32(&buf[20]);
- const uint8_t *b = buf;
-
- b = &buf[24];
+ const uint8_t *b = &buf[24];
total_len -= 24;
identifiers.resize(identifier_count);
diff --git a/modules/hdr/image_loader_hdr.cpp b/modules/hdr/image_loader_hdr.cpp
index 19df27b962..a3f0601043 100644
--- a/modules/hdr/image_loader_hdr.cpp
+++ b/modules/hdr/image_loader_hdr.cpp
@@ -34,7 +34,7 @@
#include "thirdparty/tinyexr/tinyexr.h"
-Error ImageLoaderHDR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear) {
+Error ImageLoaderHDR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
String header = f->get_token();
diff --git a/modules/hdr/image_loader_hdr.h b/modules/hdr/image_loader_hdr.h
index 127833ebd0..1e08e954e1 100644
--- a/modules/hdr/image_loader_hdr.h
+++ b/modules/hdr/image_loader_hdr.h
@@ -38,7 +38,7 @@
class ImageLoaderHDR : public ImageFormatLoader {
public:
- virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear);
+ 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;
ImageLoaderHDR();
};
diff --git a/modules/jpg/image_loader_jpegd.cpp b/modules/jpg/image_loader_jpegd.cpp
index 8c73b69f1b..4f38e83274 100644
--- a/modules/jpg/image_loader_jpegd.cpp
+++ b/modules/jpg/image_loader_jpegd.cpp
@@ -89,7 +89,7 @@ Error jpeg_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p
return OK;
}
-Error ImageLoaderJPG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear) {
+Error ImageLoaderJPG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
PoolVector<uint8_t> src_image;
int src_image_len = f->get_len();
diff --git a/modules/jpg/image_loader_jpegd.h b/modules/jpg/image_loader_jpegd.h
index aa073b493d..917c0e1d95 100644
--- a/modules/jpg/image_loader_jpegd.h
+++ b/modules/jpg/image_loader_jpegd.h
@@ -38,7 +38,7 @@
class ImageLoaderJPG : public ImageFormatLoader {
public:
- virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear);
+ 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;
ImageLoaderJPG();
};
diff --git a/modules/nativescript/api_generator.cpp b/modules/nativescript/api_generator.cpp
index 47162bfc49..d9e78ba54a 100644
--- a/modules/nativescript/api_generator.cpp
+++ b/modules/nativescript/api_generator.cpp
@@ -155,10 +155,9 @@ List<ClassAPI> generate_c_api_classes() {
class_api.is_instanciable = !class_api.is_singleton && ClassDB::can_instance(class_name);
{
- bool is_reference = false;
List<StringName> inheriters;
ClassDB::get_inheriters_from_class("Reference", &inheriters);
- is_reference = !!inheriters.find(class_name);
+ bool is_reference = !!inheriters.find(class_name);
// @Unclear
class_api.is_reference = !class_api.is_singleton && is_reference;
}
diff --git a/modules/openssl/stream_peer_openssl.cpp b/modules/openssl/stream_peer_openssl.cpp
index 7a9d5195a9..8c5e6f83c3 100644
--- a/modules/openssl/stream_peer_openssl.cpp
+++ b/modules/openssl/stream_peer_openssl.cpp
@@ -41,27 +41,22 @@ bool StreamPeerOpenSSL::_match_host_name(const char *name, const char *hostname)
Error StreamPeerOpenSSL::_match_common_name(const char *hostname, const X509 *server_cert) {
- int common_name_loc = -1;
- X509_NAME_ENTRY *common_name_entry = NULL;
- ASN1_STRING *common_name_asn1 = NULL;
- char *common_name_str = NULL;
-
// Find the position of the CN field in the Subject field of the certificate
- common_name_loc = X509_NAME_get_index_by_NID(X509_get_subject_name((X509 *)server_cert), NID_commonName, -1);
+ int common_name_loc = X509_NAME_get_index_by_NID(X509_get_subject_name((X509 *)server_cert), NID_commonName, -1);
ERR_FAIL_COND_V(common_name_loc < 0, ERR_INVALID_PARAMETER);
// Extract the CN field
- common_name_entry = X509_NAME_get_entry(X509_get_subject_name((X509 *)server_cert), common_name_loc);
+ X509_NAME_ENTRY *common_name_entry = X509_NAME_get_entry(X509_get_subject_name((X509 *)server_cert), common_name_loc);
ERR_FAIL_COND_V(common_name_entry == NULL, ERR_INVALID_PARAMETER);
// Convert the CN field to a C string
- common_name_asn1 = X509_NAME_ENTRY_get_data(common_name_entry);
+ ASN1_STRING *common_name_asn1 = X509_NAME_ENTRY_get_data(common_name_entry);
ERR_FAIL_COND_V(common_name_asn1 == NULL, ERR_INVALID_PARAMETER);
- common_name_str = (char *)ASN1_STRING_data(common_name_asn1);
+ char *common_name_str = (char *)ASN1_STRING_data(common_name_asn1);
// Make sure there isn't an embedded NUL character in the CN
bool malformed_certificate = (size_t)ASN1_STRING_length(common_name_asn1) != strlen(common_name_str);
diff --git a/modules/pbm/bitmap_loader_pbm.cpp b/modules/pbm/bitmap_loader_pbm.cpp
index c8f25ad68c..93dedbd05f 100644
--- a/modules/pbm/bitmap_loader_pbm.cpp
+++ b/modules/pbm/bitmap_loader_pbm.cpp
@@ -95,6 +95,9 @@ static bool _get_token(FileAccessRef &f, uint8_t &saved, PoolVector<uint8_t> &r_
resized = true;
}
if (resized) {
+ // Note: Certain C++ static analyzers might point out that the following assigment is unnecessary.
+ // This is wrong since PoolVector<class T>::Write has an operator= method where the lhs gets updated under certain conditions.
+ // See core/dvector.h.
w = PoolVector<uint8_t>::Write();
r_token.resize(token_max);
w = r_token.write();
diff --git a/modules/svg/SCsub b/modules/svg/SCsub
new file mode 100644
index 0000000000..0d3a347b7e
--- /dev/null
+++ b/modules/svg/SCsub
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+
+Import('env')
+
+# Thirdparty source files
+thirdparty_dir = "#thirdparty/nanosvg/src/"
+thirdparty_sources = [
+ "nanosvg.cc"
+]
+thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
+
+# env.add_source_files(env.modules_sources, thirdparty_sources)
+
+lib = env.Library("svg_builtin", thirdparty_sources)
+# Needs to be appended to arrive after libscene in the linker call,
+# but we don't want it to arrive *after* system libs, so manual hack
+# LIBS contains first SCons Library objects ("SCons.Node.FS.File object")
+# and then plain strings for system library. We insert between the two.
+inserted = False
+for idx, linklib in enumerate(env["LIBS"]):
+ if isinstance(linklib, basestring): # first system lib such as "X11", otherwise SCons lib object
+ env["LIBS"].insert(idx, lib)
+ inserted = True
+ break
+if not inserted:
+ env.Append(LIBS=[lib])
+
+env.Append(CPPPATH=[thirdparty_dir])
+env.Append(CCFLAGS=["-DSVG_ENABLED"])
+
+# Godot's own source files
+env.add_source_files(env.modules_sources, "*.cpp")
+
+Export('env') \ No newline at end of file
diff --git a/modules/svg/config.py b/modules/svg/config.py
new file mode 100644
index 0000000000..fb920482f5
--- /dev/null
+++ b/modules/svg/config.py
@@ -0,0 +1,7 @@
+
+def can_build(platform):
+ return True
+
+
+def configure(env):
+ pass
diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp
new file mode 100644
index 0000000000..46931fb0f6
--- /dev/null
+++ b/modules/svg/image_loader_svg.cpp
@@ -0,0 +1,110 @@
+/*************************************************************************/
+/* image_loader_svg.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#include "image_loader_svg.h"
+
+#include "os/os.h"
+#include "print_string.h"
+
+#include <ustring.h>
+
+void SVGRasterizer::rasterize(NSVGimage *p_image, float p_tx, float p_ty, float p_scale, unsigned char *p_dst, int p_w, int p_h, int p_stride) {
+ nsvgRasterize(rasterizer, p_image, p_tx, p_ty, p_scale, p_dst, p_w, p_h, p_stride);
+}
+
+SVGRasterizer::SVGRasterizer() {
+ rasterizer = nsvgCreateRasterizer();
+}
+SVGRasterizer::~SVGRasterizer() {
+ nsvgDeleteRasterizer(rasterizer);
+}
+
+SVGRasterizer ImageLoaderSVG::rasterizer;
+
+Error ImageLoaderSVG::_create_image(Ref<Image> p_image, const PoolVector<uint8_t> *p_data, float p_scale, bool upsample) {
+ NSVGimage *svg_image;
+ PoolVector<uint8_t>::Read src_r = p_data->read();
+ svg_image = nsvgParse((char *)src_r.ptr(), "px", 96);
+ if (svg_image == NULL) {
+ ERR_PRINT("SVG Corrupted");
+ return ERR_FILE_CORRUPT;
+ }
+
+ float upscale = upsample ? 2.0 : 1.0;
+
+ int w = (int)(svg_image->width * p_scale * upscale);
+ int h = (int)(svg_image->height * p_scale * upscale);
+
+ PoolVector<uint8_t> dst_image;
+ dst_image.resize(w * h * 4);
+
+ PoolVector<uint8_t>::Write dw = dst_image.write();
+
+ rasterizer.rasterize(svg_image, 0, 0, p_scale * upscale, (unsigned char *)dw.ptr(), w, h, w * 4);
+
+ dw = PoolVector<uint8_t>::Write();
+ p_image->create(w, h, false, Image::FORMAT_RGBA8, dst_image);
+ if (upsample)
+ p_image->shrink_x2();
+
+ nsvgDelete(svg_image);
+
+ return OK;
+}
+
+Error ImageLoaderSVG::create_image_from_string(Ref<Image> p_image, const char *svg_str, float p_scale, bool upsample) {
+
+ size_t str_len = strlen(svg_str);
+ PoolVector<uint8_t> src_data;
+ src_data.resize(str_len);
+ PoolVector<uint8_t>::Write src_w = src_data.write();
+ memcpy(src_w.ptr(), svg_str, str_len);
+
+ return _create_image(p_image, &src_data, p_scale, upsample);
+}
+
+Error ImageLoaderSVG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
+
+ uint32_t size = f->get_len();
+ PoolVector<uint8_t> src_image;
+ src_image.resize(size);
+ PoolVector<uint8_t>::Write src_w = src_image.write();
+ f->get_buffer(src_w.ptr(), size);
+
+ return _create_image(p_image, &src_image, p_scale, 1.0);
+}
+
+void ImageLoaderSVG::get_recognized_extensions(List<String> *p_extensions) const {
+
+ p_extensions->push_back("svg");
+ p_extensions->push_back("svgz");
+}
+
+ImageLoaderSVG::ImageLoaderSVG() {
+}
diff --git a/modules/svg/image_loader_svg.h b/modules/svg/image_loader_svg.h
new file mode 100644
index 0000000000..d93e1e3d62
--- /dev/null
+++ b/modules/svg/image_loader_svg.h
@@ -0,0 +1,67 @@
+/*************************************************************************/
+/* image_loader_svg.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef IMAGE_LOADER_SVG_H
+#define IMAGE_LOADER_SVG_H
+
+#include "io/image_loader.h"
+#include "ustring.h"
+
+#include <nanosvg.h>
+#include <nanosvgrast.h>
+
+/**
+ @author Daniel Ramirez <djrmuv@gmail.com>
+*/
+
+class SVGRasterizer {
+
+ NSVGrasterizer *rasterizer;
+
+public:
+ void rasterize(NSVGimage *p_image, float p_tx, float p_ty, float p_scale, unsigned char *p_dst, int p_w, int p_h, int p_stride);
+
+ SVGRasterizer();
+ ~SVGRasterizer();
+};
+
+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);
+
+public:
+ static Error create_image_from_string(Ref<Image> p_image, const char *p_svg_str, float p_scale, bool upsample);
+
+ 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
diff --git a/modules/svg/register_types.cpp b/modules/svg/register_types.cpp
new file mode 100644
index 0000000000..e0f967ca06
--- /dev/null
+++ b/modules/svg/register_types.cpp
@@ -0,0 +1,45 @@
+/*************************************************************************/
+/* register_types.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#include "register_types.h"
+
+#include "image_loader_svg.h"
+
+static ImageLoaderSVG *image_loader_svg = NULL;
+
+void register_svg_types() {
+
+ image_loader_svg = memnew(ImageLoaderSVG);
+ ImageLoader::add_image_format_loader(image_loader_svg);
+}
+
+void unregister_svg_types() {
+
+ memdelete(image_loader_svg);
+}
diff --git a/modules/svg/register_types.h b/modules/svg/register_types.h
new file mode 100644
index 0000000000..920b724623
--- /dev/null
+++ b/modules/svg/register_types.h
@@ -0,0 +1,31 @@
+/*************************************************************************/
+/* register_types.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+void register_svg_types();
+void unregister_svg_types();
diff --git a/modules/tga/image_loader_tga.cpp b/modules/tga/image_loader_tga.cpp
index 5b8610b975..2329d0bcc2 100644
--- a/modules/tga/image_loader_tga.cpp
+++ b/modules/tga/image_loader_tga.cpp
@@ -203,7 +203,7 @@ Error ImageLoaderTGA::convert_to_image(Ref<Image> p_image, const uint8_t *p_buff
return OK;
}
-Error ImageLoaderTGA::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear) {
+Error ImageLoaderTGA::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
PoolVector<uint8_t> src_image;
int src_image_len = f->get_len();
diff --git a/modules/tga/image_loader_tga.h b/modules/tga/image_loader_tga.h
index 11329ec68a..f42a3f7e75 100644
--- a/modules/tga/image_loader_tga.h
+++ b/modules/tga/image_loader_tga.h
@@ -75,7 +75,7 @@ class ImageLoaderTGA : public ImageFormatLoader {
static Error convert_to_image(Ref<Image> p_image, const uint8_t *p_buffer, const tga_header_s &p_header, const uint8_t *p_palette, const bool p_is_monochrome);
public:
- virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear);
+ 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;
ImageLoaderTGA();
};
diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp
index 977062dd14..a83d3ead0e 100644
--- a/modules/theora/video_stream_theora.cpp
+++ b/modules/theora/video_stream_theora.cpp
@@ -451,7 +451,6 @@ void VideoStreamPlaybackTheora::set_file(const String &p_file) {
ti.frame_width, ti.frame_height, ti.pic_x, ti.pic_y);
th_decode_ctl(td, TH_DECCTL_GET_PPLEVEL_MAX, &pp_level_max,
sizeof(pp_level_max));
- pp_level = pp_level_max;
pp_level = 0;
th_decode_ctl(td, TH_DECCTL_SET_PPLEVEL, &pp_level, sizeof(pp_level));
pp_inc = 0;
diff --git a/modules/tinyexr/image_loader_tinyexr.cpp b/modules/tinyexr/image_loader_tinyexr.cpp
index 4eb91da10b..18d453a717 100644
--- a/modules/tinyexr/image_loader_tinyexr.cpp
+++ b/modules/tinyexr/image_loader_tinyexr.cpp
@@ -34,7 +34,7 @@
#include "thirdparty/tinyexr/tinyexr.h"
-Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear) {
+Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
PoolVector<uint8_t> src_image;
int src_image_len = f->get_len();
diff --git a/modules/tinyexr/image_loader_tinyexr.h b/modules/tinyexr/image_loader_tinyexr.h
index a52894b12b..f9636a303e 100644
--- a/modules/tinyexr/image_loader_tinyexr.h
+++ b/modules/tinyexr/image_loader_tinyexr.h
@@ -38,7 +38,7 @@
class ImageLoaderTinyEXR : public ImageFormatLoader {
public:
- virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear);
+ 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;
ImageLoaderTinyEXR();
};
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index 8cbfb8f3fd..b4bdbe16b4 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -273,7 +273,7 @@ void VisualScript::_node_ports_changed(int p_id) {
Function &func = functions[function];
Ref<VisualScriptNode> vsn = func.nodes[p_id].node;
- if (OS::get_singleton()->get_main_loop() && OS::get_singleton()->get_main_loop()->cast_to<SceneTree>() && OS::get_singleton()->get_main_loop()->cast_to<SceneTree>()->is_editor_hint()) {
+ if (OS::get_singleton()->get_main_loop() && OS::get_singleton()->get_main_loop()->cast_to<SceneTree>() && Engine::get_singleton()->is_editor_hint()) {
vsn->validate_input_default_values(); //force validate default values when editing on editor
}
diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp
index afdf50027e..47cdfff494 100644
--- a/modules/visual_script/visual_script_func_nodes.cpp
+++ b/modules/visual_script/visual_script_func_nodes.cpp
@@ -747,10 +747,10 @@ void VisualScriptFunctionCall::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "validate"), "set_validate", "get_validate");
ADD_PROPERTY(PropertyInfo(Variant::INT, "rpc_call_mode", PROPERTY_HINT_ENUM, "Disabled,Reliable,Unreliable,ReliableToID,UnreliableToID"), "set_rpc_call_mode", "get_rpc_call_mode"); //when set, if loaded properly, will override argument count.
- BIND_CONSTANT(CALL_MODE_SELF);
- BIND_CONSTANT(CALL_MODE_NODE_PATH);
- BIND_CONSTANT(CALL_MODE_INSTANCE);
- BIND_CONSTANT(CALL_MODE_BASIC_TYPE);
+ BIND_ENUM_CONSTANT(CALL_MODE_SELF);
+ BIND_ENUM_CONSTANT(CALL_MODE_NODE_PATH);
+ BIND_ENUM_CONSTANT(CALL_MODE_INSTANCE);
+ BIND_ENUM_CONSTANT(CALL_MODE_BASIC_TYPE);
}
class VisualScriptNodeInstanceFunctionCall : public VisualScriptNodeInstance {
@@ -1164,7 +1164,7 @@ void VisualScriptPropertySet::_update_cache() {
if (!OS::get_singleton()->get_main_loop()->cast_to<SceneTree>())
return;
- if (!OS::get_singleton()->get_main_loop()->cast_to<SceneTree>()->is_editor_hint()) //only update cache if editor exists, it's pointless otherwise
+ if (!Engine::get_singleton()->is_editor_hint()) //only update cache if editor exists, it's pointless otherwise
return;
if (call_mode == CALL_MODE_BASIC_TYPE) {
@@ -1490,9 +1490,10 @@ void VisualScriptPropertySet::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::STRING, "property"), "set_property", "get_property");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "index"), "set_index", "get_index");
ADD_PROPERTY(PropertyInfo(Variant::INT, "assign_op", PROPERTY_HINT_ENUM, "Assign,Add,Sub,Mul,Div,Mod,ShiftLeft,ShiftRight,BitAnd,BitOr,Bitxor"), "set_assign_op", "get_assign_op");
- BIND_CONSTANT(CALL_MODE_SELF);
- BIND_CONSTANT(CALL_MODE_NODE_PATH);
- BIND_CONSTANT(CALL_MODE_INSTANCE);
+
+ BIND_ENUM_CONSTANT(CALL_MODE_SELF);
+ BIND_ENUM_CONSTANT(CALL_MODE_NODE_PATH);
+ BIND_ENUM_CONSTANT(CALL_MODE_INSTANCE);
}
class VisualScriptNodeInstancePropertySet : public VisualScriptNodeInstance {
@@ -2202,9 +2203,9 @@ void VisualScriptPropertyGet::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::STRING, "property"), "set_property", "get_property");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "index", PROPERTY_HINT_ENUM), "set_index", "get_index");
- BIND_CONSTANT(CALL_MODE_SELF);
- BIND_CONSTANT(CALL_MODE_NODE_PATH);
- BIND_CONSTANT(CALL_MODE_INSTANCE);
+ BIND_ENUM_CONSTANT(CALL_MODE_SELF);
+ BIND_ENUM_CONSTANT(CALL_MODE_NODE_PATH);
+ BIND_ENUM_CONSTANT(CALL_MODE_INSTANCE);
}
class VisualScriptNodeInstancePropertyGet : public VisualScriptNodeInstance {
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp
index 4f9cd4a33b..15e25c99ee 100644
--- a/modules/visual_script/visual_script_nodes.cpp
+++ b/modules/visual_script/visual_script_nodes.cpp
@@ -2712,9 +2712,9 @@ void VisualScriptCustomNode::_bind_methods() {
ClassDB::bind_method(D_METHOD("_script_changed"), &VisualScriptCustomNode::_script_changed);
- BIND_CONSTANT(START_MODE_BEGIN_SEQUENCE);
- BIND_CONSTANT(START_MODE_CONTINUE_SEQUENCE);
- BIND_CONSTANT(START_MODE_RESUME_YIELD);
+ BIND_ENUM_CONSTANT(START_MODE_BEGIN_SEQUENCE);
+ BIND_ENUM_CONSTANT(START_MODE_CONTINUE_SEQUENCE);
+ BIND_ENUM_CONSTANT(START_MODE_RESUME_YIELD);
BIND_CONSTANT(STEP_PUSH_STACK_BIT);
BIND_CONSTANT(STEP_GO_BACK_BIT);
diff --git a/modules/visual_script/visual_script_nodes.h b/modules/visual_script/visual_script_nodes.h
index 6ce906efe0..b5df761e7d 100644
--- a/modules/visual_script/visual_script_nodes.h
+++ b/modules/visual_script/visual_script_nodes.h
@@ -727,6 +727,8 @@ public:
VisualScriptCustomNode();
};
+VARIANT_ENUM_CAST(VisualScriptCustomNode::StartMode);
+
class VisualScriptSubCall : public VisualScriptNode {
GDCLASS(VisualScriptSubCall, VisualScriptNode)
diff --git a/modules/visual_script/visual_script_yield_nodes.cpp b/modules/visual_script/visual_script_yield_nodes.cpp
index 2e111511b7..df88d2e7f7 100644
--- a/modules/visual_script/visual_script_yield_nodes.cpp
+++ b/modules/visual_script/visual_script_yield_nodes.cpp
@@ -189,9 +189,9 @@ void VisualScriptYield::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Frame,FixedFrame,Time", PROPERTY_USAGE_NOEDITOR), "set_yield_mode", "get_yield_mode");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "wait_time"), "set_wait_time", "get_wait_time");
- BIND_CONSTANT(YIELD_FRAME);
- BIND_CONSTANT(YIELD_FIXED_FRAME);
- BIND_CONSTANT(YIELD_WAIT);
+ BIND_ENUM_CONSTANT(YIELD_FRAME);
+ BIND_ENUM_CONSTANT(YIELD_FIXED_FRAME);
+ BIND_ENUM_CONSTANT(YIELD_WAIT);
}
VisualScriptYield::VisualScriptYield() {
@@ -493,9 +493,9 @@ void VisualScriptYieldSignal::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "node_path", PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE), "set_base_path", "get_base_path");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "signal"), "set_signal", "get_signal");
- BIND_CONSTANT(CALL_MODE_SELF);
- BIND_CONSTANT(CALL_MODE_NODE_PATH);
- BIND_CONSTANT(CALL_MODE_INSTANCE);
+ BIND_ENUM_CONSTANT(CALL_MODE_SELF);
+ BIND_ENUM_CONSTANT(CALL_MODE_NODE_PATH);
+ BIND_ENUM_CONSTANT(CALL_MODE_INSTANCE);
}
class VisualScriptNodeInstanceYieldSignal : public VisualScriptNodeInstance {
diff --git a/modules/webp/image_loader_webp.cpp b/modules/webp/image_loader_webp.cpp
index 87c2e811b3..4ffcdefbe9 100644
--- a/modules/webp/image_loader_webp.cpp
+++ b/modules/webp/image_loader_webp.cpp
@@ -115,7 +115,7 @@ static Ref<Image> _webp_lossy_unpack(const PoolVector<uint8_t> &p_buffer) {
return img;
}
-Error ImageLoaderWEBP::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear) {
+Error ImageLoaderWEBP::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
uint32_t size = f->get_len();
PoolVector<uint8_t> src_image;
diff --git a/modules/webp/image_loader_webp.h b/modules/webp/image_loader_webp.h
index 1ac2196a71..b8c5933512 100644
--- a/modules/webp/image_loader_webp.h
+++ b/modules/webp/image_loader_webp.h
@@ -38,7 +38,7 @@
class ImageLoaderWEBP : public ImageFormatLoader {
public:
- virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear);
+ 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;
ImageLoaderWEBP();
};