From f93a4287cf833134020e5b35c4b800c2edff1b94 Mon Sep 17 00:00:00 2001 From: Ninni Pipping Date: Thu, 11 May 2023 12:32:23 +0200 Subject: Enable shadow warnings and fix raised errors (cherry picked from commit 71ee65dc5701a0675ae6b1879a694a28c7206a63) --- SConstruct | 6 +- core/math/convex_hull.cpp | 20 +- core/math/static_raycaster.h | 16 +- core/os/time.cpp | 8 +- drivers/gl_context/SCsub | 6 +- drivers/pulseaudio/audio_driver_pulseaudio.cpp | 4 +- drivers/unix/file_access_unix.cpp | 12 +- editor/import/collada.cpp | 1008 ++++++++++---------- editor/import/collada.h | 72 +- modules/csg/csg.cpp | 36 +- modules/csg/csg.h | 4 +- .../gltf/editor/editor_scene_importer_blend.cpp | 4 +- modules/text_server_adv/SCsub | 6 +- modules/text_server_fb/SCsub | 6 +- platform/ios/ios.mm | 18 +- platform/linuxbsd/x11/detect_prime_x11.cpp | 3 + platform/linuxbsd/x11/display_server_x11.cpp | 22 +- platform/linuxbsd/x11/display_server_x11.h | 2 +- platform/linuxbsd/x11/gl_manager_x11.cpp | 3 + platform/macos/display_server_macos.mm | 10 +- platform/windows/os_windows.cpp | 14 +- scene/3d/lightmapper.h | 16 +- scene/resources/audio_stream_wav.cpp | 56 +- scene/resources/audio_stream_wav.h | 2 +- servers/rendering/shader_compiler.cpp | 36 +- servers/rendering/shader_language.cpp | 114 +-- servers/rendering/shader_language.h | 48 +- 27 files changed, 785 insertions(+), 767 deletions(-) diff --git a/SConstruct b/SConstruct index cb4bf95467..403304f49f 100644 --- a/SConstruct +++ b/SConstruct @@ -686,7 +686,8 @@ if selected_platform in platform_list: if env["warnings"] == "extra": env.Append(CCFLAGS=["/W4"]) elif env["warnings"] == "all": - env.Append(CCFLAGS=["/W3"]) + # C4458 is like -Wshadow. Part of /W4 but let's apply it for the default /W3 too. + env.Append(CCFLAGS=["/W3", "/w34458"]) elif env["warnings"] == "moderate": env.Append(CCFLAGS=["/W2"]) # Disable warnings which we don't plan to fix. @@ -715,7 +716,7 @@ if selected_platform in platform_list: common_warnings = [] if methods.using_gcc(env): - common_warnings += ["-Wshadow-local", "-Wno-misleading-indentation"] + common_warnings += ["-Wshadow", "-Wno-misleading-indentation"] if cc_version_major == 7: # Bogus warning fixed in 8+. common_warnings += ["-Wno-strict-overflow"] if cc_version_major < 11: @@ -725,6 +726,7 @@ if selected_platform in platform_list: if cc_version_major >= 12: # False positives in our error macros, see GH-58747. common_warnings += ["-Wno-return-type"] elif methods.using_clang(env) or methods.using_emcc(env): + common_warnings += ["-Wshadow-field-in-constructor", "-Wshadow-uncaptured-local"] # We often implement `operator<` for structs of pointers as a requirement # for putting them in `Set` or `Map`. We don't mind about unreliable ordering. common_warnings += ["-Wno-ordered-compare-function-pointers"] diff --git a/core/math/convex_hull.cpp b/core/math/convex_hull.cpp index a03438a339..76b3062944 100644 --- a/core/math/convex_hull.cpp +++ b/core/math/convex_hull.cpp @@ -596,9 +596,9 @@ private: } }; - enum Orientation { NONE, - CLOCKWISE, - COUNTER_CLOCKWISE }; + enum Orientation { ORIENTATION_NONE, + ORIENTATION_CLOCKWISE, + ORIENTATION_COUNTER_CLOCKWISE }; Vector3 scaling; Vector3 center; @@ -1140,13 +1140,13 @@ ConvexHullInternal::Orientation ConvexHullInternal::get_orientation(const Edge * CHULL_ASSERT(!m.is_zero()); int64_t dot = n.dot(m); CHULL_ASSERT(dot != 0); - return (dot > 0) ? COUNTER_CLOCKWISE : CLOCKWISE; + return (dot > 0) ? ORIENTATION_COUNTER_CLOCKWISE : ORIENTATION_CLOCKWISE; } - return COUNTER_CLOCKWISE; + return ORIENTATION_COUNTER_CLOCKWISE; } else if (p_prev->prev == p_next) { - return CLOCKWISE; + return ORIENTATION_CLOCKWISE; } else { - return NONE; + return ORIENTATION_NONE; } } @@ -1176,7 +1176,7 @@ ConvexHullInternal::Edge *ConvexHullInternal::find_max_angle(bool p_ccw, const V } else if ((cmp = cot.compare(p_min_cot)) < 0) { p_min_cot = cot; min_edge = e; - } else if ((cmp == 0) && (p_ccw == (get_orientation(min_edge, e, p_s, t) == COUNTER_CLOCKWISE))) { + } else if ((cmp == 0) && (p_ccw == (get_orientation(min_edge, e, p_s, t) == ORIENTATION_COUNTER_CLOCKWISE))) { min_edge = e; } } @@ -1375,7 +1375,7 @@ void ConvexHullInternal::merge(IntermediateHull &p_h0, IntermediateHull &p_h1) { int64_t dot = (*e->target - *c0).dot(normal); CHULL_ASSERT(dot <= 0); if ((dot == 0) && ((*e->target - *c0).dot(t) > 0)) { - if (!start0 || (get_orientation(start0, e, s, Point32(0, 0, -1)) == CLOCKWISE)) { + if (!start0 || (get_orientation(start0, e, s, Point32(0, 0, -1)) == ORIENTATION_CLOCKWISE)) { start0 = e; } } @@ -1390,7 +1390,7 @@ void ConvexHullInternal::merge(IntermediateHull &p_h0, IntermediateHull &p_h1) { int64_t dot = (*e->target - *c1).dot(normal); CHULL_ASSERT(dot <= 0); if ((dot == 0) && ((*e->target - *c1).dot(t) > 0)) { - if (!start1 || (get_orientation(start1, e, s, Point32(0, 0, -1)) == COUNTER_CLOCKWISE)) { + if (!start1 || (get_orientation(start1, e, s, Point32(0, 0, -1)) == ORIENTATION_COUNTER_CLOCKWISE)) { start1 = e; } } diff --git a/core/math/static_raycaster.h b/core/math/static_raycaster.h index 1bafc29c57..c53868e12d 100644 --- a/core/math/static_raycaster.h +++ b/core/math/static_raycaster.h @@ -59,15 +59,15 @@ public: /*! Constructs a ray from origin, direction, and ray segment. Near * has to be smaller than far. */ - _FORCE_INLINE_ Ray(const Vector3 &org, - const Vector3 &dir, - float tnear = 0.0f, - float tfar = INFINITY) : - org(org), - tnear(tnear), - dir(dir), + _FORCE_INLINE_ Ray(const Vector3 &p_org, + const Vector3 &p_dir, + float p_tnear = 0.0f, + float p_tfar = INFINITY) : + org(p_org), + tnear(p_tnear), + dir(p_dir), time(0.0f), - tfar(tfar), + tfar(p_tfar), mask(-1), u(0.0), v(0.0), diff --git a/core/os/time.cpp b/core/os/time.cpp index 12e6f08525..038e4adc03 100644 --- a/core/os/time.cpp +++ b/core/os/time.cpp @@ -382,10 +382,10 @@ String Time::get_time_string_from_system(bool p_utc) const { Dictionary Time::get_time_zone_from_system() const { OS::TimeZoneInfo info = OS::get_singleton()->get_time_zone_info(); - Dictionary timezone; - timezone["bias"] = info.bias; - timezone["name"] = info.name; - return timezone; + Dictionary ret_timezone; + ret_timezone["bias"] = info.bias; + ret_timezone["name"] = info.name; + return ret_timezone; } double Time::get_unix_time_from_system() const { diff --git a/drivers/gl_context/SCsub b/drivers/gl_context/SCsub index 2204c486c6..91240ce3e3 100644 --- a/drivers/gl_context/SCsub +++ b/drivers/gl_context/SCsub @@ -10,7 +10,11 @@ if env["platform"] in ["haiku", "macos", "windows", "linuxbsd"]: ] thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] - env.Prepend(CPPPATH=[thirdparty_dir]) + # Treat glad headers as system headers to avoid raising warnings. Not supported on MSVC. + if not env.msvc: + env.Append(CPPFLAGS=["-isystem", Dir(thirdparty_dir).path]) + else: + env.Prepend(CPPPATH=[thirdparty_dir]) env.Append(CPPDEFINES=["GLAD_ENABLED"]) env.Append(CPPDEFINES=["GLES_OVER_GL"]) diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp index 744d0319b5..2bafc559bd 100644 --- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp +++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp @@ -222,8 +222,8 @@ Error AudioDriverPulseAudio::init_output_device() { break; } - int latency = GLOBAL_GET("audio/driver/output_latency"); - buffer_frames = closest_power_of_2(latency * mix_rate / 1000); + int tmp_latency = GLOBAL_GET("audio/driver/output_latency"); + buffer_frames = closest_power_of_2(tmp_latency * mix_rate / 1000); pa_buffer_size = buffer_frames * pa_map.channels; print_verbose("PulseAudio: detected " + itos(pa_map.channels) + " output channels"); diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp index ee3cb876cf..172f2a044c 100644 --- a/drivers/unix/file_access_unix.cpp +++ b/drivers/unix/file_access_unix.cpp @@ -284,11 +284,11 @@ bool FileAccessUnix::file_exists(const String &p_path) { uint64_t FileAccessUnix::_get_modified_time(const String &p_file) { String file = fix_path(p_file); - struct stat flags = {}; - int err = stat(file.utf8().get_data(), &flags); + struct stat status = {}; + int err = stat(file.utf8().get_data(), &status); if (!err) { - return flags.st_mtime; + return status.st_mtime; } else { print_verbose("Failed to get modified time for: " + p_file + ""); return 0; @@ -297,11 +297,11 @@ uint64_t FileAccessUnix::_get_modified_time(const String &p_file) { uint32_t FileAccessUnix::_get_unix_permissions(const String &p_file) { String file = fix_path(p_file); - struct stat flags = {}; - int err = stat(file.utf8().get_data(), &flags); + struct stat status = {}; + int err = stat(file.utf8().get_data(), &status); if (!err) { - return flags.st_mode & 0x7FF; //only permissions + return status.st_mode & 0x7FF; //only permissions } else { ERR_FAIL_V_MSG(0, "Failed to get unix permissions for: " + p_file + "."); } diff --git a/editor/import/collada.cpp b/editor/import/collada.cpp index a8d746fde6..a499fc4feb 100644 --- a/editor/import/collada.cpp +++ b/editor/import/collada.cpp @@ -44,10 +44,10 @@ /* HELPERS */ -String Collada::Effect::get_texture_path(const String &p_source, Collada &state) const { +String Collada::Effect::get_texture_path(const String &p_source, Collada &p_state) const { const String &image = p_source; - ERR_FAIL_COND_V(!state.state.image_map.has(image), ""); - return state.state.image_map[image].path; + ERR_FAIL_COND_V(!p_state.state.image_map.has(image), ""); + return p_state.state.image_map[image].path; } Transform3D Collada::get_root_transform() const { @@ -58,9 +58,9 @@ Transform3D Collada::get_root_transform() const { return unit_scale_transform; } -void Collada::Vertex::fix_unit_scale(const Collada &state) { +void Collada::Vertex::fix_unit_scale(const Collada &p_state) { #ifdef COLLADA_IMPORT_SCALE_SCENE - vertex *= state.state.unit_scale; + vertex *= p_state.state.unit_scale; #endif } @@ -102,27 +102,27 @@ Transform3D Collada::fix_transform(const Transform3D &p_transform) { //return state.matrix_fix * p_transform; } -static Transform3D _read_transform_from_array(const Vector &array, int ofs = 0) { +static Transform3D _read_transform_from_array(const Vector &p_array, int p_ofs = 0) { Transform3D tr; // i wonder why collada matrices are transposed, given that's opposed to opengl.. - tr.basis.rows[0][0] = array[0 + ofs]; - tr.basis.rows[0][1] = array[1 + ofs]; - tr.basis.rows[0][2] = array[2 + ofs]; - tr.basis.rows[1][0] = array[4 + ofs]; - tr.basis.rows[1][1] = array[5 + ofs]; - tr.basis.rows[1][2] = array[6 + ofs]; - tr.basis.rows[2][0] = array[8 + ofs]; - tr.basis.rows[2][1] = array[9 + ofs]; - tr.basis.rows[2][2] = array[10 + ofs]; - tr.origin.x = array[3 + ofs]; - tr.origin.y = array[7 + ofs]; - tr.origin.z = array[11 + ofs]; + tr.basis.rows[0][0] = p_array[0 + p_ofs]; + tr.basis.rows[0][1] = p_array[1 + p_ofs]; + tr.basis.rows[0][2] = p_array[2 + p_ofs]; + tr.basis.rows[1][0] = p_array[4 + p_ofs]; + tr.basis.rows[1][1] = p_array[5 + p_ofs]; + tr.basis.rows[1][2] = p_array[6 + p_ofs]; + tr.basis.rows[2][0] = p_array[8 + p_ofs]; + tr.basis.rows[2][1] = p_array[9 + p_ofs]; + tr.basis.rows[2][2] = p_array[10 + p_ofs]; + tr.origin.x = p_array[3 + p_ofs]; + tr.origin.y = p_array[7 + p_ofs]; + tr.origin.z = p_array[11 + p_ofs]; return tr; } /* STRUCTURES */ -Transform3D Collada::Node::compute_transform(const Collada &state) const { +Transform3D Collada::Node::compute_transform(const Collada &p_state) const { Transform3D xform; for (int i = 0; i < xform_list.size(); i++) { @@ -160,7 +160,7 @@ Transform3D Collada::Node::compute_transform(const Collada &state) const { } #ifdef COLLADA_IMPORT_SCALE_SCENE - xform.origin *= state.state.unit_scale; + xform.origin *= p_state.state.unit_scale; #endif return xform; } @@ -243,41 +243,41 @@ Vector Collada::AnimationTrack::get_value_at_time(float p_time) const { ERR_FAIL_V(Vector()); } -void Collada::_parse_asset(XMLParser &parser) { - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String name = parser.get_node_name(); +void Collada::_parse_asset(XMLParser &p_parser) { + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + String name = p_parser.get_node_name(); if (name == "up_axis") { - parser.read(); - if (parser.get_node_data() == "X_UP") { + p_parser.read(); + if (p_parser.get_node_data() == "X_UP") { state.up_axis = Vector3::AXIS_X; } - if (parser.get_node_data() == "Y_UP") { + if (p_parser.get_node_data() == "Y_UP") { state.up_axis = Vector3::AXIS_Y; } - if (parser.get_node_data() == "Z_UP") { + if (p_parser.get_node_data() == "Z_UP") { state.up_axis = Vector3::AXIS_Z; } - COLLADA_PRINT("up axis: " + parser.get_node_data()); + COLLADA_PRINT("up axis: " + p_parser.get_node_data()); } else if (name == "unit") { - state.unit_scale = parser.get_named_attribute_value("meter").to_float(); + state.unit_scale = p_parser.get_named_attribute_value("meter").to_float(); COLLADA_PRINT("unit scale: " + rtos(state.unit_scale)); } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "asset") { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == "asset") { break; //end of } } } -void Collada::_parse_image(XMLParser &parser) { - String id = parser.get_named_attribute_value("id"); +void Collada::_parse_image(XMLParser &p_parser) { + String id = p_parser.get_named_attribute_value("id"); if (!(state.import_flags & IMPORT_FLAG_SCENE)) { - if (!parser.is_empty()) { - parser.skip_section(); + if (!p_parser.is_empty()) { + p_parser.skip_section(); } return; } @@ -286,19 +286,19 @@ void Collada::_parse_image(XMLParser &parser) { if (state.version < State::Version(1, 4, 0)) { /* <1.4 */ - String path = parser.get_named_attribute_value("source").strip_edges(); + String path = p_parser.get_named_attribute_value("source").strip_edges(); if (!path.contains("://") && path.is_relative_path()) { // path is relative to file being loaded, so convert to a resource path image.path = ProjectSettings::get_singleton()->localize_path(state.local_path.get_base_dir().path_join(path.uri_decode())); } } else { - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String name = parser.get_node_name(); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + String name = p_parser.get_node_name(); if (name == "init_from") { - parser.read(); - String path = parser.get_node_data().strip_edges().uri_decode(); + p_parser.read(); + String path = p_parser.get_node_data().strip_edges().uri_decode(); if (!path.contains("://") && path.is_relative_path()) { // path is relative to file being loaded, so convert to a resource path @@ -314,11 +314,11 @@ void Collada::_parse_image(XMLParser &parser) { } else if (name == "data") { ERR_PRINT("COLLADA Embedded image data not supported!"); - } else if (name == "extra" && !parser.is_empty()) { - parser.skip_section(); + } else if (name == "extra" && !p_parser.is_empty()) { + p_parser.skip_section(); } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "image") { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == "image") { break; //end of } } @@ -327,29 +327,29 @@ void Collada::_parse_image(XMLParser &parser) { state.image_map[id] = image; } -void Collada::_parse_material(XMLParser &parser) { +void Collada::_parse_material(XMLParser &p_parser) { if (!(state.import_flags & IMPORT_FLAG_SCENE)) { - if (!parser.is_empty()) { - parser.skip_section(); + if (!p_parser.is_empty()) { + p_parser.skip_section(); } return; } Material material; - String id = parser.get_named_attribute_value("id"); - if (parser.has_attribute("name")) { - material.name = parser.get_named_attribute_value("name"); + String id = p_parser.get_named_attribute_value("id"); + if (p_parser.has_attribute("name")) { + material.name = p_parser.get_named_attribute_value("name"); } if (state.version < State::Version(1, 4, 0)) { /* <1.4 */ ERR_PRINT("Collada Materials < 1.4 are not supported (yet)"); } else { - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT && parser.get_node_name() == "instance_effect") { - material.instance_effect = _uri_to_id(parser.get_named_attribute_value("url")); - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "material") { + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT && p_parser.get_node_name() == "instance_effect") { + material.instance_effect = _uri_to_id(p_parser.get_named_attribute_value("url")); + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == "material") { break; //end of } } @@ -359,8 +359,8 @@ void Collada::_parse_material(XMLParser &parser) { } //! reads floats from inside of xml element until end of xml element -Vector Collada::_read_float_array(XMLParser &parser) { - if (parser.is_empty()) { +Vector Collada::_read_float_array(XMLParser &p_parser) { + if (p_parser.is_empty()) { return Vector(); } @@ -371,16 +371,16 @@ Vector Collada::_read_float_array(XMLParser &parser) { splitters.push_back("\t"); Vector array; - while (parser.read() == OK) { + while (p_parser.read() == OK) { // TODO: check for comments inside the element // and ignore them. - if (parser.get_node_type() == XMLParser::NODE_TEXT) { + if (p_parser.get_node_type() == XMLParser::NODE_TEXT) { // parse float data - String str = parser.get_node_data(); + String str = p_parser.get_node_data(); array = str.split_floats_mk(splitters, false); //array=str.split_floats(" ",false); - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END) { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END) { break; // end parsing text } } @@ -388,21 +388,21 @@ Vector Collada::_read_float_array(XMLParser &parser) { return array; } -Vector Collada::_read_string_array(XMLParser &parser) { - if (parser.is_empty()) { +Vector Collada::_read_string_array(XMLParser &p_parser) { + if (p_parser.is_empty()) { return Vector(); } Vector array; - while (parser.read() == OK) { + while (p_parser.read() == OK) { // TODO: check for comments inside the element // and ignore them. - if (parser.get_node_type() == XMLParser::NODE_TEXT) { + if (p_parser.get_node_type() == XMLParser::NODE_TEXT) { // parse String data - String str = parser.get_node_data(); + String str = p_parser.get_node_data(); array = str.split_spaces(); - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END) { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END) { break; // end parsing text } } @@ -410,21 +410,21 @@ Vector Collada::_read_string_array(XMLParser &parser) { return array; } -Transform3D Collada::_read_transform(XMLParser &parser) { - if (parser.is_empty()) { +Transform3D Collada::_read_transform(XMLParser &p_parser) { + if (p_parser.is_empty()) { return Transform3D(); } Vector array; - while (parser.read() == OK) { + while (p_parser.read() == OK) { // TODO: check for comments inside the element // and ignore them. - if (parser.get_node_type() == XMLParser::NODE_TEXT) { + if (p_parser.get_node_type() == XMLParser::NODE_TEXT) { // parse float data - String str = parser.get_node_data(); + String str = p_parser.get_node_data(); array = str.split_spaces(); - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END) { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END) { break; // end parsing text } } @@ -439,332 +439,332 @@ Transform3D Collada::_read_transform(XMLParser &parser) { return _read_transform_from_array(farr); } -String Collada::_read_empty_draw_type(XMLParser &parser) { +String Collada::_read_empty_draw_type(XMLParser &p_parser) { String empty_draw_type = ""; - if (parser.is_empty()) { + if (p_parser.is_empty()) { return empty_draw_type; } - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_TEXT) { - empty_draw_type = parser.get_node_data(); - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END) { + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_TEXT) { + empty_draw_type = p_parser.get_node_data(); + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END) { break; // end parsing text } } return empty_draw_type; } -Variant Collada::_parse_param(XMLParser &parser) { - if (parser.is_empty()) { +Variant Collada::_parse_param(XMLParser &p_parser) { + if (p_parser.is_empty()) { return Variant(); } - String from = parser.get_node_name(); + String from = p_parser.get_node_name(); Variant data; - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "float") { - parser.read(); - if (parser.get_node_type() == XMLParser::NODE_TEXT) { - data = parser.get_node_data().to_float(); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + if (p_parser.get_node_name() == "float") { + p_parser.read(); + if (p_parser.get_node_type() == XMLParser::NODE_TEXT) { + data = p_parser.get_node_data().to_float(); } - } else if (parser.get_node_name() == "float2") { - Vector v2 = _read_float_array(parser); + } else if (p_parser.get_node_name() == "float2") { + Vector v2 = _read_float_array(p_parser); if (v2.size() >= 2) { data = Vector2(v2[0], v2[1]); } - } else if (parser.get_node_name() == "float3") { - Vector v3 = _read_float_array(parser); + } else if (p_parser.get_node_name() == "float3") { + Vector v3 = _read_float_array(p_parser); if (v3.size() >= 3) { data = Vector3(v3[0], v3[1], v3[2]); } - } else if (parser.get_node_name() == "float4") { - Vector v4 = _read_float_array(parser); + } else if (p_parser.get_node_name() == "float4") { + Vector v4 = _read_float_array(p_parser); if (v4.size() >= 4) { data = Color(v4[0], v4[1], v4[2], v4[3]); } - } else if (parser.get_node_name() == "sampler2D") { - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "source") { - parser.read(); + } else if (p_parser.get_node_name() == "sampler2D") { + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + if (p_parser.get_node_name() == "source") { + p_parser.read(); - if (parser.get_node_type() == XMLParser::NODE_TEXT) { - data = parser.get_node_data(); + if (p_parser.get_node_type() == XMLParser::NODE_TEXT) { + data = p_parser.get_node_data(); } } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "sampler2D") { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == "sampler2D") { break; } } - } else if (parser.get_node_name() == "surface") { - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "init_from") { - parser.read(); + } else if (p_parser.get_node_name() == "surface") { + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + if (p_parser.get_node_name() == "init_from") { + p_parser.read(); - if (parser.get_node_type() == XMLParser::NODE_TEXT) { - data = parser.get_node_data(); + if (p_parser.get_node_type() == XMLParser::NODE_TEXT) { + data = p_parser.get_node_data(); } } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "surface") { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == "surface") { break; } } } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == from) { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == from) { break; } } - COLLADA_PRINT("newparam ending " + parser.get_node_name()); + COLLADA_PRINT("newparam ending " + p_parser.get_node_name()); return data; } -void Collada::_parse_effect_material(XMLParser &parser, Effect &effect, String &id) { +void Collada::_parse_effect_material(XMLParser &p_parser, Effect &p_effect, String &p_id) { if (!(state.import_flags & IMPORT_FLAG_SCENE)) { - if (!parser.is_empty()) { - parser.skip_section(); + if (!p_parser.is_empty()) { + p_parser.skip_section(); } return; } - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { // first come the tags we descend, but ignore the top-levels - COLLADA_PRINT("node name: " + parser.get_node_name()); + COLLADA_PRINT("node name: " + p_parser.get_node_name()); - if (!parser.is_empty() && - (parser.get_node_name() == "profile_COMMON" || - parser.get_node_name() == "technique" || - parser.get_node_name() == "extra")) { - _parse_effect_material(parser, effect, id); // try again + if (!p_parser.is_empty() && + (p_parser.get_node_name() == "profile_COMMON" || + p_parser.get_node_name() == "technique" || + p_parser.get_node_name() == "extra")) { + _parse_effect_material(p_parser, p_effect, p_id); // try again - } else if (parser.get_node_name() == "newparam") { - String name = parser.get_named_attribute_value("sid"); - Variant value = _parse_param(parser); - effect.params[name] = value; + } else if (p_parser.get_node_name() == "newparam") { + String name = p_parser.get_named_attribute_value("sid"); + Variant value = _parse_param(p_parser); + p_effect.params[name] = value; COLLADA_PRINT("param: " + name + " value:" + String(value)); - } else if (parser.get_node_name() == "constant" || - parser.get_node_name() == "lambert" || - parser.get_node_name() == "phong" || - parser.get_node_name() == "blinn") { - COLLADA_PRINT("shade model: " + parser.get_node_name()); - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String what = parser.get_node_name(); + } else if (p_parser.get_node_name() == "constant" || + p_parser.get_node_name() == "lambert" || + p_parser.get_node_name() == "phong" || + p_parser.get_node_name() == "blinn") { + COLLADA_PRINT("shade model: " + p_parser.get_node_name()); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + String what = p_parser.get_node_name(); if (what == "emission" || what == "diffuse" || what == "specular" || what == "reflective") { // color or texture types - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "color") { - Vector colorarr = _read_float_array(parser); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + if (p_parser.get_node_name() == "color") { + Vector colorarr = _read_float_array(p_parser); COLLADA_PRINT("colorarr size: " + rtos(colorarr.size())); if (colorarr.size() >= 3) { // alpha strangely not alright? maybe it needs to be multiplied by value as a channel intensity Color color(colorarr[0], colorarr[1], colorarr[2], 1.0); if (what == "diffuse") { - effect.diffuse.color = color; + p_effect.diffuse.color = color; } if (what == "specular") { - effect.specular.color = color; + p_effect.specular.color = color; } if (what == "emission") { - effect.emission.color = color; + p_effect.emission.color = color; } COLLADA_PRINT(what + " color: " + color); } - } else if (parser.get_node_name() == "texture") { - String sampler = parser.get_named_attribute_value("texture"); - if (!effect.params.has(sampler)) { - ERR_PRINT(String("Couldn't find sampler: " + sampler + " in material:" + id).utf8().get_data()); + } else if (p_parser.get_node_name() == "texture") { + String sampler = p_parser.get_named_attribute_value("texture"); + if (!p_effect.params.has(sampler)) { + ERR_PRINT(String("Couldn't find sampler: " + sampler + " in material:" + p_id).utf8().get_data()); } else { - String surface = effect.params[sampler]; + String surface = p_effect.params[sampler]; - if (!effect.params.has(surface)) { - ERR_PRINT(String("Couldn't find surface: " + surface + " in material:" + id).utf8().get_data()); + if (!p_effect.params.has(surface)) { + ERR_PRINT(String("Couldn't find surface: " + surface + " in material:" + p_id).utf8().get_data()); } else { - String uri = effect.params[surface]; + String uri = p_effect.params[surface]; if (what == "diffuse") { - effect.diffuse.texture = uri; + p_effect.diffuse.texture = uri; } else if (what == "specular") { - effect.specular.texture = uri; + p_effect.specular.texture = uri; } else if (what == "emission") { - effect.emission.texture = uri; + p_effect.emission.texture = uri; } else if (what == "bump") { - if (parser.has_attribute("bumptype") && parser.get_named_attribute_value("bumptype") != "NORMALMAP") { + if (p_parser.has_attribute("bumptype") && p_parser.get_named_attribute_value("bumptype") != "NORMALMAP") { WARN_PRINT("'bump' texture type is not NORMALMAP, only NORMALMAP is supported."); } - effect.bump.texture = uri; + p_effect.bump.texture = uri; } COLLADA_PRINT(what + " texture: " + uri); } } - } else if (!parser.is_empty()) { - parser.skip_section(); + } else if (!p_parser.is_empty()) { + p_parser.skip_section(); } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == what) { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == what) { break; } } } else if (what == "shininess") { - effect.shininess = _parse_param(parser); + p_effect.shininess = _parse_param(p_parser); } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && - (parser.get_node_name() == "constant" || - parser.get_node_name() == "lambert" || - parser.get_node_name() == "phong" || - parser.get_node_name() == "blinn")) { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && + (p_parser.get_node_name() == "constant" || + p_parser.get_node_name() == "lambert" || + p_parser.get_node_name() == "phong" || + p_parser.get_node_name() == "blinn")) { break; } } - } else if (parser.get_node_name() == "double_sided" || parser.get_node_name() == "show_double_sided") { // colladamax / google earth + } else if (p_parser.get_node_name() == "double_sided" || p_parser.get_node_name() == "show_double_sided") { // colladamax / google earth // 3DS Max / Google Earth double sided extension - parser.read(); - effect.found_double_sided = true; - effect.double_sided = parser.get_node_data().to_int(); - COLLADA_PRINT("double sided: " + itos(parser.get_node_data().to_int())); - } else if (parser.get_node_name() == "unshaded") { - parser.read(); - effect.unshaded = parser.get_node_data().to_int(); - } else if (parser.get_node_name() == "bump") { + p_parser.read(); + p_effect.found_double_sided = true; + p_effect.double_sided = p_parser.get_node_data().to_int(); + COLLADA_PRINT("double sided: " + itos(p_parser.get_node_data().to_int())); + } else if (p_parser.get_node_name() == "unshaded") { + p_parser.read(); + p_effect.unshaded = p_parser.get_node_data().to_int(); + } else if (p_parser.get_node_name() == "bump") { // color or texture types - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "texture") { - String sampler = parser.get_named_attribute_value("texture"); - if (!effect.params.has(sampler)) { - ERR_PRINT(String("Couldn't find sampler: " + sampler + " in material:" + id).utf8().get_data()); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + if (p_parser.get_node_name() == "texture") { + String sampler = p_parser.get_named_attribute_value("texture"); + if (!p_effect.params.has(sampler)) { + ERR_PRINT(String("Couldn't find sampler: " + sampler + " in material:" + p_id).utf8().get_data()); } else { - String surface = effect.params[sampler]; + String surface = p_effect.params[sampler]; - if (!effect.params.has(surface)) { - ERR_PRINT(String("Couldn't find surface: " + surface + " in material:" + id).utf8().get_data()); + if (!p_effect.params.has(surface)) { + ERR_PRINT(String("Couldn't find surface: " + surface + " in material:" + p_id).utf8().get_data()); } else { - String uri = effect.params[surface]; + String uri = p_effect.params[surface]; - if (parser.has_attribute("bumptype") && parser.get_named_attribute_value("bumptype") != "NORMALMAP") { + if (p_parser.has_attribute("bumptype") && p_parser.get_named_attribute_value("bumptype") != "NORMALMAP") { WARN_PRINT("'bump' texture type is not NORMALMAP, only NORMALMAP is supported."); } - effect.bump.texture = uri; + p_effect.bump.texture = uri; COLLADA_PRINT(" bump: " + uri); } } - } else if (!parser.is_empty()) { - parser.skip_section(); + } else if (!p_parser.is_empty()) { + p_parser.skip_section(); } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "bump") { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == "bump") { break; } } - } else if (!parser.is_empty()) { - parser.skip_section(); + } else if (!p_parser.is_empty()) { + p_parser.skip_section(); } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && - (parser.get_node_name() == "effect" || - parser.get_node_name() == "profile_COMMON" || - parser.get_node_name() == "technique" || - parser.get_node_name() == "extra")) { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && + (p_parser.get_node_name() == "effect" || + p_parser.get_node_name() == "profile_COMMON" || + p_parser.get_node_name() == "technique" || + p_parser.get_node_name() == "extra")) { break; } } } -void Collada::_parse_effect(XMLParser &parser) { +void Collada::_parse_effect(XMLParser &p_parser) { if (!(state.import_flags & IMPORT_FLAG_SCENE)) { - if (!parser.is_empty()) { - parser.skip_section(); + if (!p_parser.is_empty()) { + p_parser.skip_section(); } return; } - String id = parser.get_named_attribute_value("id"); + String id = p_parser.get_named_attribute_value("id"); Effect effect; - if (parser.has_attribute("name")) { - effect.name = parser.get_named_attribute_value("name"); + if (p_parser.has_attribute("name")) { + effect.name = p_parser.get_named_attribute_value("name"); } - _parse_effect_material(parser, effect, id); + _parse_effect_material(p_parser, effect, id); state.effect_map[id] = effect; COLLADA_PRINT("Effect ID:" + id); } -void Collada::_parse_camera(XMLParser &parser) { +void Collada::_parse_camera(XMLParser &p_parser) { if (!(state.import_flags & IMPORT_FLAG_SCENE)) { - if (!parser.is_empty()) { - parser.skip_section(); + if (!p_parser.is_empty()) { + p_parser.skip_section(); } return; } - String id = parser.get_named_attribute_value("id"); + String id = p_parser.get_named_attribute_value("id"); state.camera_data_map[id] = CameraData(); CameraData &camera = state.camera_data_map[id]; - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String name = parser.get_node_name(); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + String name = p_parser.get_node_name(); if (name == "perspective") { camera.mode = CameraData::MODE_PERSPECTIVE; } else if (name == "orthographic") { camera.mode = CameraData::MODE_ORTHOGONAL; } else if (name == "xfov") { - parser.read(); - camera.perspective.x_fov = parser.get_node_data().to_float(); + p_parser.read(); + camera.perspective.x_fov = p_parser.get_node_data().to_float(); } else if (name == "yfov") { - parser.read(); - camera.perspective.y_fov = parser.get_node_data().to_float(); + p_parser.read(); + camera.perspective.y_fov = p_parser.get_node_data().to_float(); } else if (name == "xmag") { - parser.read(); - camera.orthogonal.x_mag = parser.get_node_data().to_float(); + p_parser.read(); + camera.orthogonal.x_mag = p_parser.get_node_data().to_float(); } else if (name == "ymag") { - parser.read(); - camera.orthogonal.y_mag = parser.get_node_data().to_float(); + p_parser.read(); + camera.orthogonal.y_mag = p_parser.get_node_data().to_float(); } else if (name == "aspect_ratio") { - parser.read(); - camera.aspect = parser.get_node_data().to_float(); + p_parser.read(); + camera.aspect = p_parser.get_node_data().to_float(); } else if (name == "znear") { - parser.read(); - camera.z_near = parser.get_node_data().to_float(); + p_parser.read(); + camera.z_near = p_parser.get_node_data().to_float(); } else if (name == "zfar") { - parser.read(); - camera.z_far = parser.get_node_data().to_float(); + p_parser.read(); + camera.z_far = p_parser.get_node_data().to_float(); } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "camera") { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == "camera") { break; //end of } } @@ -772,22 +772,22 @@ void Collada::_parse_camera(XMLParser &parser) { COLLADA_PRINT("Camera ID:" + id); } -void Collada::_parse_light(XMLParser &parser) { +void Collada::_parse_light(XMLParser &p_parser) { if (!(state.import_flags & IMPORT_FLAG_SCENE)) { - if (!parser.is_empty()) { - parser.skip_section(); + if (!p_parser.is_empty()) { + p_parser.skip_section(); } return; } - String id = parser.get_named_attribute_value("id"); + String id = p_parser.get_named_attribute_value("id"); state.light_data_map[id] = LightData(); LightData &light = state.light_data_map[id]; - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String name = parser.get_node_name(); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + String name = p_parser.get_node_name(); if (name == "ambient") { light.mode = LightData::MODE_AMBIENT; @@ -798,8 +798,8 @@ void Collada::_parse_light(XMLParser &parser) { } else if (name == "spot") { light.mode = LightData::MODE_SPOT; } else if (name == "color") { - parser.read(); - Vector colorarr = _read_float_array(parser); + p_parser.read(); + Vector colorarr = _read_float_array(p_parser); COLLADA_PRINT("colorarr size: " + rtos(colorarr.size())); if (colorarr.size() >= 4) { @@ -809,24 +809,24 @@ void Collada::_parse_light(XMLParser &parser) { } } else if (name == "constant_attenuation") { - parser.read(); - light.constant_att = parser.get_node_data().to_float(); + p_parser.read(); + light.constant_att = p_parser.get_node_data().to_float(); } else if (name == "linear_attenuation") { - parser.read(); - light.linear_att = parser.get_node_data().to_float(); + p_parser.read(); + light.linear_att = p_parser.get_node_data().to_float(); } else if (name == "quadratic_attenuation") { - parser.read(); - light.quad_att = parser.get_node_data().to_float(); + p_parser.read(); + light.quad_att = p_parser.get_node_data().to_float(); } else if (name == "falloff_angle") { - parser.read(); - light.spot_angle = parser.get_node_data().to_float(); + p_parser.read(); + light.spot_angle = p_parser.get_node_data().to_float(); } else if (name == "falloff_exponent") { - parser.read(); - light.spot_exp = parser.get_node_data().to_float(); + p_parser.read(); + light.spot_exp = p_parser.get_node_data().to_float(); } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "light") { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == "light") { break; //end of } } @@ -834,10 +834,10 @@ void Collada::_parse_light(XMLParser &parser) { COLLADA_PRINT("Light ID:" + id); } -void Collada::_parse_curve_geometry(XMLParser &parser, String p_id, String p_name) { +void Collada::_parse_curve_geometry(XMLParser &p_parser, String p_id, String p_name) { if (!(state.import_flags & IMPORT_FLAG_SCENE)) { - if (!parser.is_empty()) { - parser.skip_section(); + if (!p_parser.is_empty()) { + p_parser.skip_section(); } return; } @@ -848,7 +848,7 @@ void Collada::_parse_curve_geometry(XMLParser &parser, String p_id, String p_nam CurveData &curvedata = state.curve_data_map[p_id]; curvedata.name = p_name; - String closed = parser.get_named_attribute_value_safe("closed").to_lower(); + String closed = p_parser.get_named_attribute_value_safe("closed").to_lower(); curvedata.closed = closed == "true" || closed == "1"; COLLADA_PRINT("curve name: " + p_name); @@ -856,16 +856,16 @@ void Collada::_parse_curve_geometry(XMLParser &parser, String p_id, String p_nam String current_source; // handles geometry node and the curve children in this loop // read sources with arrays and accessor for each curve - if (parser.is_empty()) { + if (p_parser.is_empty()) { return; } - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String section = parser.get_node_name(); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + String section = p_parser.get_node_name(); if (section == "source") { - String id = parser.get_named_attribute_value("id"); + String id = p_parser.get_named_attribute_value("id"); curvedata.sources[id] = CurveData::Source(); current_source = id; COLLADA_PRINT("source data: " + id); @@ -873,13 +873,13 @@ void Collada::_parse_curve_geometry(XMLParser &parser, String p_id, String p_nam } else if (section == "float_array" || section == "array") { // create a new array and read it. if (curvedata.sources.has(current_source)) { - curvedata.sources[current_source].array = _read_float_array(parser); + curvedata.sources[current_source].array = _read_float_array(p_parser); COLLADA_PRINT("section: " + current_source + " read " + itos(curvedata.sources[current_source].array.size()) + " values."); } } else if (section == "Name_array") { // create a new array and read it. if (curvedata.sources.has(current_source)) { - curvedata.sources[current_source].sarray = _read_string_array(parser); + curvedata.sources[current_source].sarray = _read_string_array(p_parser); COLLADA_PRINT("section: " + current_source + " read " + itos(curvedata.sources[current_source].array.size()) + " values."); } @@ -888,38 +888,38 @@ void Collada::_parse_curve_geometry(XMLParser &parser, String p_id, String p_nam } else if (section == "accessor") { // child of source (below a technique tag) if (curvedata.sources.has(current_source)) { - curvedata.sources[current_source].stride = parser.get_named_attribute_value("stride").to_int(); + curvedata.sources[current_source].stride = p_parser.get_named_attribute_value("stride").to_int(); COLLADA_PRINT("section: " + current_source + " stride " + itos(curvedata.sources[current_source].stride)); } } else if (section == "control_vertices") { - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "input") { - String semantic = parser.get_named_attribute_value("semantic"); - String source = _uri_to_id(parser.get_named_attribute_value("source")); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + if (p_parser.get_node_name() == "input") { + String semantic = p_parser.get_named_attribute_value("semantic"); + String source = _uri_to_id(p_parser.get_named_attribute_value("source")); curvedata.control_vertices[semantic] = source; COLLADA_PRINT(section + " input semantic: " + semantic + " source: " + source); } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == section) { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == section) { break; } } - } else if (!parser.is_empty()) { - parser.skip_section(); + } else if (!p_parser.is_empty()) { + p_parser.skip_section(); } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "spline") { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == "spline") { break; } } } -void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name) { +void Collada::_parse_mesh_geometry(XMLParser &p_parser, String p_id, String p_name) { if (!(state.import_flags & IMPORT_FLAG_SCENE)) { - if (!parser.is_empty()) { - parser.skip_section(); + if (!p_parser.is_empty()) { + p_parser.skip_section(); } return; } @@ -936,16 +936,16 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name String current_source; // handles geometry node and the mesh children in this loop // read sources with arrays and accessor for each mesh - if (parser.is_empty()) { + if (p_parser.is_empty()) { return; } - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String section = parser.get_node_name(); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + String section = p_parser.get_node_name(); if (section == "source") { - String id = parser.get_named_attribute_value("id"); + String id = p_parser.get_named_attribute_value("id"); meshdata.sources[id] = MeshData::Source(); current_source = id; COLLADA_PRINT("source data: " + id); @@ -953,7 +953,7 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name } else if (section == "float_array" || section == "array") { // create a new array and read it. if (meshdata.sources.has(current_source)) { - meshdata.sources[current_source].array = _read_float_array(parser); + meshdata.sources[current_source].array = _read_float_array(p_parser); COLLADA_PRINT("section: " + current_source + " read " + itos(meshdata.sources[current_source].array.size()) + " values."); } } else if (section == "technique_common") { @@ -961,19 +961,19 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name } else if (section == "accessor") { // child of source (below a technique tag) if (meshdata.sources.has(current_source)) { - meshdata.sources[current_source].stride = parser.get_named_attribute_value("stride").to_int(); + meshdata.sources[current_source].stride = p_parser.get_named_attribute_value("stride").to_int(); COLLADA_PRINT("section: " + current_source + " stride " + itos(meshdata.sources[current_source].stride)); } } else if (section == "vertices") { MeshData::Vertices vert; - String id = parser.get_named_attribute_value("id"); + String id = p_parser.get_named_attribute_value("id"); int last_ref = 0; - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "input") { - String semantic = parser.get_named_attribute_value("semantic"); - String source = _uri_to_id(parser.get_named_attribute_value("source")); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + if (p_parser.get_node_name() == "input") { + String semantic = p_parser.get_named_attribute_value("semantic"); + String source = _uri_to_id(p_parser.get_named_attribute_value("source")); if (semantic == "TEXCOORD") { semantic = "TEXCOORD" + itos(last_ref++); @@ -983,7 +983,7 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name COLLADA_PRINT(section + " input semantic: " + semantic + " source: " + source); } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == section) { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == section) { break; } } @@ -997,23 +997,23 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name } MeshData::Primitives prim; - if (parser.has_attribute("material")) { - prim.material = parser.get_named_attribute_value("material"); + if (p_parser.has_attribute("material")) { + prim.material = p_parser.get_named_attribute_value("material"); } - prim.count = parser.get_named_attribute_value("count").to_int(); + prim.count = p_parser.get_named_attribute_value("count").to_int(); prim.vertex_size = 0; int last_ref = 0; - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "input") { - String semantic = parser.get_named_attribute_value("semantic"); - String source = _uri_to_id(parser.get_named_attribute_value("source")); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + if (p_parser.get_node_name() == "input") { + String semantic = p_parser.get_named_attribute_value("semantic"); + String source = _uri_to_id(p_parser.get_named_attribute_value("source")); if (semantic == "TEXCOORD") { semantic = "TEXCOORD" + itos(last_ref++); } - int offset = parser.get_named_attribute_value("offset").to_int(); + int offset = p_parser.get_named_attribute_value("offset").to_int(); MeshData::Primitives::SourceRef sref; sref.source = source; @@ -1023,9 +1023,9 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name COLLADA_PRINT(section + " input semantic: " + semantic + " source: " + source + " offset: " + itos(offset)); - } else if (parser.get_node_name() == "p") { //indices + } else if (p_parser.get_node_name() == "p") { //indices - Vector values = _read_float_array(parser); + Vector values = _read_float_array(p_parser); if (polygons) { ERR_CONTINUE(prim.vertex_size == 0); prim.polygons.push_back(values.size() / prim.vertex_size); @@ -1041,49 +1041,49 @@ void Collada::_parse_mesh_geometry(XMLParser &parser, String p_id, String p_name COLLADA_PRINT("read " + itos(values.size()) + " index values"); - } else if (parser.get_node_name() == "vcount") { // primitive + } else if (p_parser.get_node_name() == "vcount") { // primitive - Vector values = _read_float_array(parser); + Vector values = _read_float_array(p_parser); prim.polygons = values; COLLADA_PRINT("read " + itos(values.size()) + " polygon values"); } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == section) { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == section) { break; } } meshdata.primitives.push_back(prim); - } else if (parser.get_node_name() == "double_sided") { - parser.read(); + } else if (p_parser.get_node_name() == "double_sided") { + p_parser.read(); meshdata.found_double_sided = true; - meshdata.double_sided = parser.get_node_data().to_int(); + meshdata.double_sided = p_parser.get_node_data().to_int(); - } else if (parser.get_node_name() == "polygons") { + } else if (p_parser.get_node_name() == "polygons") { ERR_PRINT("Primitive type \"polygons\" not supported, re-export using \"polylist\" or \"triangles\"."); - } else if (!parser.is_empty()) { - parser.skip_section(); + } else if (!p_parser.is_empty()) { + p_parser.skip_section(); } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "mesh") { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == "mesh") { break; } } } -void Collada::_parse_skin_controller(XMLParser &parser, String p_id) { +void Collada::_parse_skin_controller(XMLParser &p_parser, String p_id) { state.skin_controller_data_map[p_id] = SkinControllerData(); SkinControllerData &skindata = state.skin_controller_data_map[p_id]; - skindata.base = _uri_to_id(parser.get_named_attribute_value("source")); + skindata.base = _uri_to_id(p_parser.get_named_attribute_value("source")); String current_source; - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String section = parser.get_node_name(); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + String section = p_parser.get_node_name(); if (section == "bind_shape_matrix") { - skindata.bind_shape = _read_transform(parser); + skindata.bind_shape = _read_transform(p_parser); #ifdef COLLADA_IMPORT_SCALE_SCENE skindata.bind_shape.origin *= state.unit_scale; @@ -1091,7 +1091,7 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) { COLLADA_PRINT("skeleton bind shape transform: " + skindata.bind_shape); } else if (section == "source") { - String id = parser.get_named_attribute_value("id"); + String id = p_parser.get_named_attribute_value("id"); skindata.sources[id] = SkinControllerData::Source(); current_source = id; COLLADA_PRINT("source data: " + id); @@ -1099,7 +1099,7 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) { } else if (section == "float_array" || section == "array") { // create a new array and read it. if (skindata.sources.has(current_source)) { - skindata.sources[current_source].array = _read_float_array(parser); + skindata.sources[current_source].array = _read_float_array(p_parser); COLLADA_PRINT("section: " + current_source + " read " + itos(skindata.sources[current_source].array.size()) + " values."); } } else if (section == "Name_array" || section == "IDREF_array") { @@ -1109,7 +1109,7 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) { skindata.use_idrefs = true; } if (skindata.sources.has(current_source)) { - skindata.sources[current_source].sarray = _read_string_array(parser); + skindata.sources[current_source].sarray = _read_string_array(p_parser); if (section == "IDREF_array") { Vector sa = skindata.sources[current_source].sarray; for (int i = 0; i < sa.size(); i++) { @@ -1124,8 +1124,8 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) { if (skindata.sources.has(current_source)) { int stride = 1; - if (parser.has_attribute("stride")) { - stride = parser.get_named_attribute_value("stride").to_int(); + if (p_parser.has_attribute("stride")) { + stride = p_parser.get_named_attribute_value("stride").to_int(); } skindata.sources[current_source].stride = stride; @@ -1135,17 +1135,17 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) { } else if (section == "joints") { SkinControllerData::Joints joint; - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "input") { - String semantic = parser.get_named_attribute_value("semantic"); - String source = _uri_to_id(parser.get_named_attribute_value("source")); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + if (p_parser.get_node_name() == "input") { + String semantic = p_parser.get_named_attribute_value("semantic"); + String source = _uri_to_id(p_parser.get_named_attribute_value("source")); joint.sources[semantic] = source; COLLADA_PRINT(section + " input semantic: " + semantic + " source: " + source); } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == section) { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == section) { break; } } @@ -1155,15 +1155,15 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) { } else if (section == "vertex_weights") { SkinControllerData::Weights weights; - weights.count = parser.get_named_attribute_value("count").to_int(); + weights.count = p_parser.get_named_attribute_value("count").to_int(); - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "input") { - String semantic = parser.get_named_attribute_value("semantic"); - String source = _uri_to_id(parser.get_named_attribute_value("source")); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + if (p_parser.get_node_name() == "input") { + String semantic = p_parser.get_named_attribute_value("semantic"); + String source = _uri_to_id(p_parser.get_named_attribute_value("source")); - int offset = parser.get_named_attribute_value("offset").to_int(); + int offset = p_parser.get_named_attribute_value("offset").to_int(); SkinControllerData::Weights::SourceRef sref; sref.source = source; @@ -1172,26 +1172,26 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) { COLLADA_PRINT(section + " input semantic: " + semantic + " source: " + source + " offset: " + itos(offset)); - } else if (parser.get_node_name() == "v") { //indices + } else if (p_parser.get_node_name() == "v") { //indices - Vector values = _read_float_array(parser); + Vector values = _read_float_array(p_parser); weights.indices = values; COLLADA_PRINT("read " + itos(values.size()) + " index values"); - } else if (parser.get_node_name() == "vcount") { // weightsitive + } else if (p_parser.get_node_name() == "vcount") { // weightsitive - Vector values = _read_float_array(parser); + Vector values = _read_float_array(p_parser); weights.sets = values; COLLADA_PRINT("read " + itos(values.size()) + " polygon values"); } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == section) { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == section) { break; } } skindata.weights = weights; } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "skin") { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == "skin") { break; } } @@ -1224,20 +1224,20 @@ void Collada::_parse_skin_controller(XMLParser &parser, String p_id) { } } -void Collada::_parse_morph_controller(XMLParser &parser, String p_id) { +void Collada::_parse_morph_controller(XMLParser &p_parser, String p_id) { state.morph_controller_data_map[p_id] = MorphControllerData(); MorphControllerData &morphdata = state.morph_controller_data_map[p_id]; - morphdata.mesh = _uri_to_id(parser.get_named_attribute_value("source")); - morphdata.mode = parser.get_named_attribute_value("method"); + morphdata.mesh = _uri_to_id(p_parser.get_named_attribute_value("source")); + morphdata.mode = p_parser.get_named_attribute_value("method"); String current_source; - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String section = parser.get_node_name(); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + String section = p_parser.get_node_name(); if (section == "source") { - String id = parser.get_named_attribute_value("id"); + String id = p_parser.get_named_attribute_value("id"); morphdata.sources[id] = MorphControllerData::Source(); current_source = id; COLLADA_PRINT("source data: " + id); @@ -1245,13 +1245,13 @@ void Collada::_parse_morph_controller(XMLParser &parser, String p_id) { } else if (section == "float_array" || section == "array") { // create a new array and read it. if (morphdata.sources.has(current_source)) { - morphdata.sources[current_source].array = _read_float_array(parser); + morphdata.sources[current_source].array = _read_float_array(p_parser); COLLADA_PRINT("section: " + current_source + " read " + itos(morphdata.sources[current_source].array.size()) + " values."); } } else if (section == "Name_array" || section == "IDREF_array") { // create a new array and read it. if (morphdata.sources.has(current_source)) { - morphdata.sources[current_source].sarray = _read_string_array(parser); + morphdata.sources[current_source].sarray = _read_string_array(p_parser); COLLADA_PRINT("section: " + current_source + " read " + itos(morphdata.sources[current_source].array.size()) + " values."); } } else if (section == "technique_common") { @@ -1260,8 +1260,8 @@ void Collada::_parse_morph_controller(XMLParser &parser, String p_id) { if (morphdata.sources.has(current_source)) { int stride = 1; - if (parser.has_attribute("stride")) { - stride = parser.get_named_attribute_value("stride").to_int(); + if (p_parser.has_attribute("stride")) { + stride = p_parser.get_named_attribute_value("stride").to_int(); } morphdata.sources[current_source].stride = stride; @@ -1269,22 +1269,22 @@ void Collada::_parse_morph_controller(XMLParser &parser, String p_id) { } } else if (section == "targets") { - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "input") { - String semantic = parser.get_named_attribute_value("semantic"); - String source = _uri_to_id(parser.get_named_attribute_value("source")); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + if (p_parser.get_node_name() == "input") { + String semantic = p_parser.get_named_attribute_value("semantic"); + String source = _uri_to_id(p_parser.get_named_attribute_value("source")); morphdata.targets[semantic] = source; COLLADA_PRINT(section + " input semantic: " + semantic + " source: " + source); } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == section) { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == section) { break; } } } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "morph") { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == "morph") { break; } } @@ -1294,57 +1294,57 @@ void Collada::_parse_morph_controller(XMLParser &parser, String p_id) { } } -void Collada::_parse_controller(XMLParser &parser) { - String id = parser.get_named_attribute_value("id"); +void Collada::_parse_controller(XMLParser &p_parser) { + String id = p_parser.get_named_attribute_value("id"); - if (parser.is_empty()) { + if (p_parser.is_empty()) { return; } - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String section = parser.get_node_name(); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + String section = p_parser.get_node_name(); if (section == "skin") { - _parse_skin_controller(parser, id); + _parse_skin_controller(p_parser, id); } else if (section == "morph") { - _parse_morph_controller(parser, id); + _parse_morph_controller(p_parser, id); } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "controller") { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == "controller") { break; } } } -Collada::Node *Collada::_parse_visual_instance_geometry(XMLParser &parser) { - String type = parser.get_node_name(); +Collada::Node *Collada::_parse_visual_instance_geometry(XMLParser &p_parser) { + String type = p_parser.get_node_name(); NodeGeometry *geom = memnew(NodeGeometry); geom->controller = type == "instance_controller"; - geom->source = _uri_to_id(parser.get_named_attribute_value_safe("url")); + geom->source = _uri_to_id(p_parser.get_named_attribute_value_safe("url")); - if (parser.is_empty()) { //nothing else to parse... + if (p_parser.is_empty()) { //nothing else to parse... return geom; } // try to find also many materials and skeletons! - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "instance_material") { - String symbol = parser.get_named_attribute_value("symbol"); - String target = _uri_to_id(parser.get_named_attribute_value("target")); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + if (p_parser.get_node_name() == "instance_material") { + String symbol = p_parser.get_named_attribute_value("symbol"); + String target = _uri_to_id(p_parser.get_named_attribute_value("target")); NodeGeometry::Material mat; mat.target = target; geom->material_map[symbol] = mat; COLLADA_PRINT("uses material: '" + target + "' on primitive'" + symbol + "'"); - } else if (parser.get_node_name() == "skeleton") { - parser.read(); - String uri = _uri_to_id(parser.get_node_data()); + } else if (p_parser.get_node_name() == "skeleton") { + p_parser.read(); + String uri = _uri_to_id(p_parser.get_node_data()); if (!uri.is_empty()) { geom->skeletons.push_back(uri); } } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == type) { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == type) { break; } } @@ -1368,20 +1368,20 @@ Collada::Node *Collada::_parse_visual_instance_geometry(XMLParser &parser) { return geom; } -Collada::Node *Collada::_parse_visual_instance_camera(XMLParser &parser) { +Collada::Node *Collada::_parse_visual_instance_camera(XMLParser &p_parser) { NodeCamera *cam = memnew(NodeCamera); - cam->camera = _uri_to_id(parser.get_named_attribute_value_safe("url")); + cam->camera = _uri_to_id(p_parser.get_named_attribute_value_safe("url")); if (state.up_axis == Vector3::AXIS_Z) { //collada weirdness cam->post_transform.basis.rotate(Vector3(1, 0, 0), -Math_PI * 0.5); } - if (parser.is_empty()) { //nothing else to parse... + if (p_parser.is_empty()) { //nothing else to parse... return cam; } - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "instance_camera") { + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == "instance_camera") { break; } } @@ -1389,20 +1389,20 @@ Collada::Node *Collada::_parse_visual_instance_camera(XMLParser &parser) { return cam; } -Collada::Node *Collada::_parse_visual_instance_light(XMLParser &parser) { +Collada::Node *Collada::_parse_visual_instance_light(XMLParser &p_parser) { NodeLight *cam = memnew(NodeLight); - cam->light = _uri_to_id(parser.get_named_attribute_value_safe("url")); + cam->light = _uri_to_id(p_parser.get_named_attribute_value_safe("url")); if (state.up_axis == Vector3::AXIS_Z) { //collada weirdness cam->post_transform.basis.rotate(Vector3(1, 0, 0), -Math_PI * 0.5); } - if (parser.is_empty()) { //nothing else to parse... + if (p_parser.is_empty()) { //nothing else to parse... return cam; } - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "instance_light") { + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == "instance_light") { break; } } @@ -1410,23 +1410,23 @@ Collada::Node *Collada::_parse_visual_instance_light(XMLParser &parser) { return cam; } -Collada::Node *Collada::_parse_visual_node_instance_data(XMLParser &parser) { - String instance_type = parser.get_node_name(); +Collada::Node *Collada::_parse_visual_node_instance_data(XMLParser &p_parser) { + String instance_type = p_parser.get_node_name(); if (instance_type == "instance_geometry" || instance_type == "instance_controller") { - return _parse_visual_instance_geometry(parser); + return _parse_visual_instance_geometry(p_parser); } else if (instance_type == "instance_camera") { - return _parse_visual_instance_camera(parser); + return _parse_visual_instance_camera(p_parser); } else if (instance_type == "instance_light") { - return _parse_visual_instance_light(parser); + return _parse_visual_instance_light(p_parser); } - if (parser.is_empty()) { //nothing else to parse... + if (p_parser.is_empty()) { //nothing else to parse... return nullptr; } - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == instance_type) { + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == instance_type) { break; } } @@ -1434,10 +1434,10 @@ Collada::Node *Collada::_parse_visual_node_instance_data(XMLParser &parser) { return nullptr; } -Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) { +Collada::Node *Collada::_parse_visual_scene_node(XMLParser &p_parser) { String name; - String id = parser.get_named_attribute_value_safe("id"); + String id = p_parser.get_named_attribute_value_safe("id"); bool found_name = false; @@ -1455,25 +1455,25 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) { Node *node = nullptr; - name = parser.has_attribute("name") ? parser.get_named_attribute_value_safe("name") : parser.get_named_attribute_value_safe("id"); + name = p_parser.has_attribute("name") ? p_parser.get_named_attribute_value_safe("name") : p_parser.get_named_attribute_value_safe("id"); if (name.is_empty()) { name = id; } else { found_name = true; } - if ((parser.has_attribute("type") && parser.get_named_attribute_value("type") == "JOINT") || state.idref_joints.has(name)) { + if ((p_parser.has_attribute("type") && p_parser.get_named_attribute_value("type") == "JOINT") || state.idref_joints.has(name)) { // handle a bone NodeJoint *joint = memnew(NodeJoint); - if (parser.has_attribute("sid")) { //bones may not have sid - joint->sid = parser.get_named_attribute_value("sid"); + if (p_parser.has_attribute("sid")) { //bones may not have sid + joint->sid = p_parser.get_named_attribute_value("sid"); //state.bone_map[joint->sid]=joint; } else if (state.idref_joints.has(name)) { joint->sid = name; //kind of a cheat but.. - } else if (parser.has_attribute("name")) { - joint->sid = parser.get_named_attribute_value_safe("name"); + } else if (p_parser.has_attribute("name")) { + joint->sid = p_parser.get_named_attribute_value_safe("name"); } if (!joint->sid.is_empty()) { @@ -1483,42 +1483,42 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) { node = joint; } - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String section = parser.get_node_name(); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + String section = p_parser.get_node_name(); if (section == "translate") { Node::XForm xf; - if (parser.has_attribute("sid")) { - xf.id = parser.get_named_attribute_value("sid"); + if (p_parser.has_attribute("sid")) { + xf.id = p_parser.get_named_attribute_value("sid"); } xf.op = Node::XForm::OP_TRANSLATE; - Vector xlt = _read_float_array(parser); + Vector xlt = _read_float_array(p_parser); xf.data = xlt; xform_list.push_back(xf); } else if (section == "rotate") { Node::XForm xf; - if (parser.has_attribute("sid")) { - xf.id = parser.get_named_attribute_value("sid"); + if (p_parser.has_attribute("sid")) { + xf.id = p_parser.get_named_attribute_value("sid"); } xf.op = Node::XForm::OP_ROTATE; - Vector rot = _read_float_array(parser); + Vector rot = _read_float_array(p_parser); xf.data = rot; xform_list.push_back(xf); } else if (section == "scale") { Node::XForm xf; - if (parser.has_attribute("sid")) { - xf.id = parser.get_named_attribute_value("sid"); + if (p_parser.has_attribute("sid")) { + xf.id = p_parser.get_named_attribute_value("sid"); } xf.op = Node::XForm::OP_SCALE; - Vector scale = _read_float_array(parser); + Vector scale = _read_float_array(p_parser); xf.data = scale; @@ -1526,12 +1526,12 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) { } else if (section == "matrix") { Node::XForm xf; - if (parser.has_attribute("sid")) { - xf.id = parser.get_named_attribute_value("sid"); + if (p_parser.has_attribute("sid")) { + xf.id = p_parser.get_named_attribute_value("sid"); } xf.op = Node::XForm::OP_MATRIX; - Vector matrix = _read_float_array(parser); + Vector matrix = _read_float_array(p_parser); xf.data = matrix; String mtx; @@ -1543,25 +1543,25 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) { } else if (section == "visibility") { Node::XForm xf; - if (parser.has_attribute("sid")) { - xf.id = parser.get_named_attribute_value("sid"); + if (p_parser.has_attribute("sid")) { + xf.id = p_parser.get_named_attribute_value("sid"); } xf.op = Node::XForm::OP_VISIBILITY; - Vector visible = _read_float_array(parser); + Vector visible = _read_float_array(p_parser); xf.data = visible; xform_list.push_back(xf); } else if (section == "empty_draw_type") { - empty_draw_type = _read_empty_draw_type(parser); + empty_draw_type = _read_empty_draw_type(p_parser); } else if (section == "technique" || section == "extra") { } else if (section != "node") { //usually what defines the type of node if (section.begins_with("instance_")) { if (!node) { - node = _parse_visual_node_instance_data(parser); + node = _parse_visual_node_instance_data(p_parser); } else { ERR_PRINT("Multiple instance_* not supported."); @@ -1571,11 +1571,11 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) { } else { /* Found a child node!! what to do..*/ - Node *child = _parse_visual_scene_node(parser); + Node *child = _parse_visual_scene_node(p_parser); children.push_back(child); } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "node") { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == "node") { break; } } @@ -1608,29 +1608,29 @@ Collada::Node *Collada::_parse_visual_scene_node(XMLParser &parser) { return node; } -void Collada::_parse_visual_scene(XMLParser &parser) { - String id = parser.get_named_attribute_value("id"); +void Collada::_parse_visual_scene(XMLParser &p_parser) { + String id = p_parser.get_named_attribute_value("id"); - if (parser.is_empty()) { + if (p_parser.is_empty()) { return; } state.visual_scene_map[id] = VisualScene(); VisualScene &vscene = state.visual_scene_map[id]; - if (parser.has_attribute("name")) { - vscene.name = parser.get_named_attribute_value("name"); + if (p_parser.has_attribute("name")) { + vscene.name = p_parser.get_named_attribute_value("name"); } - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String section = parser.get_node_name(); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + String section = p_parser.get_node_name(); if (section == "node") { - vscene.root_nodes.push_back(_parse_visual_scene_node(parser)); + vscene.root_nodes.push_back(_parse_visual_scene_node(p_parser)); } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "visual_scene") { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == "visual_scene") { break; } } @@ -1638,10 +1638,10 @@ void Collada::_parse_visual_scene(XMLParser &parser) { COLLADA_PRINT("Scene ID:" + id); } -void Collada::_parse_animation(XMLParser &parser) { +void Collada::_parse_animation(XMLParser &p_parser) { if (!(state.import_flags & IMPORT_FLAG_ANIMATION)) { - if (!parser.is_empty()) { - parser.skip_section(); + if (!p_parser.is_empty()) { + p_parser.skip_section(); } return; @@ -1655,8 +1655,8 @@ void Collada::_parse_animation(XMLParser &parser) { HashMap> source_param_types; String id = ""; - if (parser.has_attribute("id")) { - id = parser.get_named_attribute_value("id"); + if (p_parser.has_attribute("id")) { + id = p_parser.get_named_attribute_value("id"); } String current_source; @@ -1664,54 +1664,54 @@ void Collada::_parse_animation(XMLParser &parser) { Vector channel_sources; Vector channel_targets; - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String name = parser.get_node_name(); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + String name = p_parser.get_node_name(); if (name == "source") { - current_source = parser.get_named_attribute_value("id"); + current_source = p_parser.get_named_attribute_value("id"); source_param_names[current_source] = Vector(); source_param_types[current_source] = Vector(); } else if (name == "float_array") { if (!current_source.is_empty()) { - float_sources[current_source] = _read_float_array(parser); + float_sources[current_source] = _read_float_array(p_parser); } } else if (name == "Name_array") { if (!current_source.is_empty()) { - string_sources[current_source] = _read_string_array(parser); + string_sources[current_source] = _read_string_array(p_parser); } } else if (name == "accessor") { - if (!current_source.is_empty() && parser.has_attribute("stride")) { - source_strides[current_source] = parser.get_named_attribute_value("stride").to_int(); + if (!current_source.is_empty() && p_parser.has_attribute("stride")) { + source_strides[current_source] = p_parser.get_named_attribute_value("stride").to_int(); } } else if (name == "sampler") { - current_sampler = parser.get_named_attribute_value("id"); + current_sampler = p_parser.get_named_attribute_value("id"); samplers[current_sampler] = HashMap(); } else if (name == "param") { - if (parser.has_attribute("name")) { - source_param_names[current_source].push_back(parser.get_named_attribute_value("name")); + if (p_parser.has_attribute("name")) { + source_param_names[current_source].push_back(p_parser.get_named_attribute_value("name")); } else { source_param_names[current_source].push_back(""); } - if (parser.has_attribute("type")) { - source_param_types[current_source].push_back(parser.get_named_attribute_value("type")); + if (p_parser.has_attribute("type")) { + source_param_types[current_source].push_back(p_parser.get_named_attribute_value("type")); } else { source_param_types[current_source].push_back(""); } } else if (name == "input") { if (!current_sampler.is_empty()) { - samplers[current_sampler][parser.get_named_attribute_value("semantic")] = parser.get_named_attribute_value("source"); + samplers[current_sampler][p_parser.get_named_attribute_value("semantic")] = p_parser.get_named_attribute_value("source"); } } else if (name == "channel") { - channel_sources.push_back(parser.get_named_attribute_value("source")); - channel_targets.push_back(parser.get_named_attribute_value("target")); + channel_sources.push_back(p_parser.get_named_attribute_value("source")); + channel_targets.push_back(p_parser.get_named_attribute_value("target")); } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "animation") { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == "animation") { break; //end of } } @@ -1845,10 +1845,10 @@ void Collada::_parse_animation(XMLParser &parser) { } } -void Collada::_parse_animation_clip(XMLParser &parser) { +void Collada::_parse_animation_clip(XMLParser &p_parser) { if (!(state.import_flags & IMPORT_FLAG_ANIMATION)) { - if (!parser.is_empty()) { - parser.skip_section(); + if (!p_parser.is_empty()) { + p_parser.skip_section(); } return; @@ -1856,27 +1856,27 @@ void Collada::_parse_animation_clip(XMLParser &parser) { AnimationClip clip; - if (parser.has_attribute("name")) { - clip.name = parser.get_named_attribute_value("name"); - } else if (parser.has_attribute("id")) { - clip.name = parser.get_named_attribute_value("id"); + if (p_parser.has_attribute("name")) { + clip.name = p_parser.get_named_attribute_value("name"); + } else if (p_parser.has_attribute("id")) { + clip.name = p_parser.get_named_attribute_value("id"); } - if (parser.has_attribute("start")) { - clip.begin = parser.get_named_attribute_value("start").to_float(); + if (p_parser.has_attribute("start")) { + clip.begin = p_parser.get_named_attribute_value("start").to_float(); } - if (parser.has_attribute("end")) { - clip.end = parser.get_named_attribute_value("end").to_float(); + if (p_parser.has_attribute("end")) { + clip.end = p_parser.get_named_attribute_value("end").to_float(); } - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String name = parser.get_node_name(); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + String name = p_parser.get_node_name(); if (name == "instance_animation") { - String url = _uri_to_id(parser.get_named_attribute_value("url")); + String url = _uri_to_id(p_parser.get_named_attribute_value("url")); clip.tracks.push_back(url); } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "animation_clip") { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == "animation_clip") { break; //end of } } @@ -1884,79 +1884,79 @@ void Collada::_parse_animation_clip(XMLParser &parser) { state.animation_clips.push_back(clip); } -void Collada::_parse_scene(XMLParser &parser) { - if (parser.is_empty()) { +void Collada::_parse_scene(XMLParser &p_parser) { + if (p_parser.is_empty()) { return; } - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String name = parser.get_node_name(); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + String name = p_parser.get_node_name(); if (name == "instance_visual_scene") { - state.root_visual_scene = _uri_to_id(parser.get_named_attribute_value("url")); + state.root_visual_scene = _uri_to_id(p_parser.get_named_attribute_value("url")); } else if (name == "instance_physics_scene") { - state.root_physics_scene = _uri_to_id(parser.get_named_attribute_value("url")); + state.root_physics_scene = _uri_to_id(p_parser.get_named_attribute_value("url")); } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "scene") { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == "scene") { break; //end of } } } -void Collada::_parse_library(XMLParser &parser) { - if (parser.is_empty()) { +void Collada::_parse_library(XMLParser &p_parser) { + if (p_parser.is_empty()) { return; } - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - String name = parser.get_node_name(); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + String name = p_parser.get_node_name(); COLLADA_PRINT("library name is: " + name); if (name == "image") { - _parse_image(parser); + _parse_image(p_parser); } else if (name == "material") { - _parse_material(parser); + _parse_material(p_parser); } else if (name == "effect") { - _parse_effect(parser); + _parse_effect(p_parser); } else if (name == "camera") { - _parse_camera(parser); + _parse_camera(p_parser); } else if (name == "light") { - _parse_light(parser); + _parse_light(p_parser); } else if (name == "geometry") { - String id = parser.get_named_attribute_value("id"); - String name2 = parser.get_named_attribute_value_safe("name"); - while (parser.read() == OK) { - if (parser.get_node_type() == XMLParser::NODE_ELEMENT) { - if (parser.get_node_name() == "mesh") { + String id = p_parser.get_named_attribute_value("id"); + String name2 = p_parser.get_named_attribute_value_safe("name"); + while (p_parser.read() == OK) { + if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT) { + if (p_parser.get_node_name() == "mesh") { state.mesh_name_map[id] = (!name2.is_empty()) ? name2 : id; - _parse_mesh_geometry(parser, id, name2); - } else if (parser.get_node_name() == "spline") { + _parse_mesh_geometry(p_parser, id, name2); + } else if (p_parser.get_node_name() == "spline") { state.mesh_name_map[id] = (!name2.is_empty()) ? name2 : id; - _parse_curve_geometry(parser, id, name2); - } else if (!parser.is_empty()) { - parser.skip_section(); + _parse_curve_geometry(p_parser, id, name2); + } else if (!p_parser.is_empty()) { + p_parser.skip_section(); } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name() == "geometry") { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name() == "geometry") { break; } } } else if (name == "controller") { - _parse_controller(parser); + _parse_controller(p_parser); } else if (name == "animation") { - _parse_animation(parser); + _parse_animation(p_parser); } else if (name == "animation_clip") { - _parse_animation_clip(parser); + _parse_animation_clip(p_parser); } else if (name == "visual_scene") { COLLADA_PRINT("visual scene"); - _parse_visual_scene(parser); - } else if (!parser.is_empty()) { - parser.skip_section(); + _parse_visual_scene(p_parser); + } else if (!p_parser.is_empty()) { + p_parser.skip_section(); } - } else if (parser.get_node_type() == XMLParser::NODE_ELEMENT_END && parser.get_node_name().begins_with("library_")) { + } else if (p_parser.get_node_type() == XMLParser::NODE_ELEMENT_END && p_parser.get_node_name().begins_with("library_")) { break; //end of } } diff --git a/editor/import/collada.h b/editor/import/collada.h index 12b32f982d..7877b1e86d 100644 --- a/editor/import/collada.h +++ b/editor/import/collada.h @@ -69,7 +69,7 @@ public: bool double_sided = true; bool unshaded = false; - String get_texture_path(const String &p_source, Collada &state) const; + String get_texture_path(const String &p_source, Collada &p_state) const; Effect() { diffuse.color = Color(1, 1, 1, 1); @@ -266,7 +266,7 @@ public: } } - void fix_unit_scale(const Collada &state); + void fix_unit_scale(const Collada &p_state); bool operator<(const Vertex &p_vert) const { if (uid == p_vert.uid) { @@ -348,7 +348,7 @@ public: Node *parent = nullptr; - Transform3D compute_transform(const Collada &state) const; + Transform3D compute_transform(const Collada &p_state) const; Transform3D get_global_transform() const; Transform3D get_transform() const; @@ -526,39 +526,39 @@ public: private: // private stuff HashMap channel_map; - void _parse_asset(XMLParser &parser); - void _parse_image(XMLParser &parser); - void _parse_material(XMLParser &parser); - void _parse_effect_material(XMLParser &parser, Effect &effect, String &id); - void _parse_effect(XMLParser &parser); - void _parse_camera(XMLParser &parser); - void _parse_light(XMLParser &parser); - void _parse_animation_clip(XMLParser &parser); - - void _parse_mesh_geometry(XMLParser &parser, String p_id, String p_name); - void _parse_curve_geometry(XMLParser &parser, String p_id, String p_name); - - void _parse_skin_controller(XMLParser &parser, String p_id); - void _parse_morph_controller(XMLParser &parser, String p_id); - void _parse_controller(XMLParser &parser); - - Node *_parse_visual_instance_geometry(XMLParser &parser); - Node *_parse_visual_instance_camera(XMLParser &parser); - Node *_parse_visual_instance_light(XMLParser &parser); - - Node *_parse_visual_node_instance_data(XMLParser &parser); - Node *_parse_visual_scene_node(XMLParser &parser); - void _parse_visual_scene(XMLParser &parser); - - void _parse_animation(XMLParser &parser); - void _parse_scene(XMLParser &parser); - void _parse_library(XMLParser &parser); - - Variant _parse_param(XMLParser &parser); - Vector _read_float_array(XMLParser &parser); - Vector _read_string_array(XMLParser &parser); - Transform3D _read_transform(XMLParser &parser); - String _read_empty_draw_type(XMLParser &parser); + void _parse_asset(XMLParser &p_parser); + void _parse_image(XMLParser &p_parser); + void _parse_material(XMLParser &p_parser); + void _parse_effect_material(XMLParser &p_parser, Effect &p_effect, String &p_id); + void _parse_effect(XMLParser &p_parser); + void _parse_camera(XMLParser &p_parser); + void _parse_light(XMLParser &p_parser); + void _parse_animation_clip(XMLParser &p_parser); + + void _parse_mesh_geometry(XMLParser &p_parser, String p_id, String p_name); + void _parse_curve_geometry(XMLParser &p_parser, String p_id, String p_name); + + void _parse_skin_controller(XMLParser &p_parser, String p_id); + void _parse_morph_controller(XMLParser &p_parser, String p_id); + void _parse_controller(XMLParser &p_parser); + + Node *_parse_visual_instance_geometry(XMLParser &p_parser); + Node *_parse_visual_instance_camera(XMLParser &p_parser); + Node *_parse_visual_instance_light(XMLParser &p_parser); + + Node *_parse_visual_node_instance_data(XMLParser &p_parser); + Node *_parse_visual_scene_node(XMLParser &p_parser); + void _parse_visual_scene(XMLParser &p_parser); + + void _parse_animation(XMLParser &p_parser); + void _parse_scene(XMLParser &p_parser); + void _parse_library(XMLParser &p_parser); + + Variant _parse_param(XMLParser &p_parser); + Vector _read_float_array(XMLParser &p_parser); + Vector _read_string_array(XMLParser &p_parser); + Transform3D _read_transform(XMLParser &p_parser); + String _read_empty_draw_type(XMLParser &p_parser); void _joint_set_owner(Collada::Node *p_node, NodeSkeleton *p_owner); void _create_skeletons(Collada::Node **p_node, NodeSkeleton *p_skeleton = nullptr); diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp index 0bd8e5d9ad..878664bb9c 100644 --- a/modules/csg/csg.cpp +++ b/modules/csg/csg.cpp @@ -467,7 +467,7 @@ void CSGBrushOperation::merge_brushes(Operation p_operation, const CSGBrush &p_b // Use a limit to speed up bvh and limit the depth. #define BVH_LIMIT 8 -int CSGBrushOperation::MeshMerge::_create_bvh(FaceBVH *facebvhptr, FaceBVH **facebvhptrptr, int p_from, int p_size, int p_depth, int &r_max_depth, int &r_max_alloc) { +int CSGBrushOperation::MeshMerge::_create_bvh(FaceBVH *r_facebvhptr, FaceBVH **r_facebvhptrptr, int p_from, int p_size, int p_depth, int &r_max_depth, int &r_max_alloc) { if (p_depth > r_max_depth) { r_max_depth = p_depth; } @@ -478,15 +478,15 @@ int CSGBrushOperation::MeshMerge::_create_bvh(FaceBVH *facebvhptr, FaceBVH **fac if (p_size <= BVH_LIMIT) { for (int i = 0; i < p_size - 1; i++) { - facebvhptrptr[p_from + i]->next = facebvhptrptr[p_from + i + 1] - facebvhptr; + r_facebvhptrptr[p_from + i]->next = r_facebvhptrptr[p_from + i + 1] - r_facebvhptr; } - return facebvhptrptr[p_from] - facebvhptr; + return r_facebvhptrptr[p_from] - r_facebvhptr; } AABB aabb; - aabb = facebvhptrptr[p_from]->aabb; + aabb = r_facebvhptrptr[p_from]->aabb; for (int i = 1; i < p_size; i++) { - aabb.merge_with(facebvhptrptr[p_from + i]->aabb); + aabb.merge_with(r_facebvhptrptr[p_from + i]->aabb); } int li = aabb.get_longest_axis_index(); @@ -494,28 +494,28 @@ int CSGBrushOperation::MeshMerge::_create_bvh(FaceBVH *facebvhptr, FaceBVH **fac switch (li) { case Vector3::AXIS_X: { SortArray sort_x; - sort_x.nth_element(0, p_size, p_size / 2, &facebvhptrptr[p_from]); + sort_x.nth_element(0, p_size, p_size / 2, &r_facebvhptrptr[p_from]); //sort_x.sort(&p_bb[p_from],p_size); } break; case Vector3::AXIS_Y: { SortArray sort_y; - sort_y.nth_element(0, p_size, p_size / 2, &facebvhptrptr[p_from]); + sort_y.nth_element(0, p_size, p_size / 2, &r_facebvhptrptr[p_from]); //sort_y.sort(&p_bb[p_from],p_size); } break; case Vector3::AXIS_Z: { SortArray sort_z; - sort_z.nth_element(0, p_size, p_size / 2, &facebvhptrptr[p_from]); + sort_z.nth_element(0, p_size, p_size / 2, &r_facebvhptrptr[p_from]); //sort_z.sort(&p_bb[p_from],p_size); } break; } - int left = _create_bvh(facebvhptr, facebvhptrptr, p_from, p_size / 2, p_depth + 1, r_max_depth, r_max_alloc); - int right = _create_bvh(facebvhptr, facebvhptrptr, p_from + p_size / 2, p_size - p_size / 2, p_depth + 1, r_max_depth, r_max_alloc); + int left = _create_bvh(r_facebvhptr, r_facebvhptrptr, p_from, p_size / 2, p_depth + 1, r_max_depth, r_max_alloc); + int right = _create_bvh(r_facebvhptr, r_facebvhptrptr, p_from + p_size / 2, p_size - p_size / 2, p_depth + 1, r_max_depth, r_max_alloc); int index = r_max_alloc++; - FaceBVH *_new = &facebvhptr[index]; + FaceBVH *_new = &r_facebvhptr[index]; _new->aabb = aabb; _new->center = aabb.get_center(); _new->face = -1; @@ -535,13 +535,13 @@ void CSGBrushOperation::MeshMerge::_add_distance(List &r_i return; } } - IntersectionDistance IntersectionDistance; - IntersectionDistance.is_conormal = p_is_conormal; - IntersectionDistance.distance_squared = p_distance_squared; - intersections.push_back(IntersectionDistance); + IntersectionDistance distance; + distance.is_conormal = p_is_conormal; + distance.distance_squared = p_distance_squared; + intersections.push_back(distance); } -bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_depth, int p_bvh_first, int p_face_idx) const { +bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *r_facebvhptr, int p_max_depth, int p_bvh_first, int p_face_idx) const { Face face = faces[p_face_idx]; Vector3 face_points[3] = { points[face.points[0]], @@ -575,7 +575,7 @@ bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_de while (true) { uint32_t node = stack[level] & NODE_IDX_MASK; - const FaceBVH *current_facebvhptr = &(facebvhptr[node]); + const FaceBVH *current_facebvhptr = &(r_facebvhptr[node]); bool done = false; switch (stack[level] >> VISITED_BIT_SHIFT) { @@ -651,7 +651,7 @@ bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_de } if (current_facebvhptr->next != -1) { - current_facebvhptr = &facebvhptr[current_facebvhptr->next]; + current_facebvhptr = &r_facebvhptr[current_facebvhptr->next]; } else { current_facebvhptr = nullptr; } diff --git a/modules/csg/csg.h b/modules/csg/csg.h index 473a23e39f..2a0831e1ce 100644 --- a/modules/csg/csg.h +++ b/modules/csg/csg.h @@ -155,8 +155,8 @@ struct CSGBrushOperation { float vertex_snap = 0.0; inline void _add_distance(List &r_intersectionsA, List &r_intersectionsB, bool p_from_B, real_t p_distance, bool p_is_conormal) const; - inline bool _bvh_inside(FaceBVH *facebvhptr, int p_max_depth, int p_bvh_first, int p_face_idx) const; - inline int _create_bvh(FaceBVH *facebvhptr, FaceBVH **facebvhptrptr, int p_from, int p_size, int p_depth, int &r_max_depth, int &r_max_alloc); + inline bool _bvh_inside(FaceBVH *r_facebvhptr, int p_max_depth, int p_bvh_first, int p_face_idx) const; + inline int _create_bvh(FaceBVH *r_facebvhptr, FaceBVH **r_facebvhptrptr, int p_from, int p_size, int p_depth, int &r_max_depth, int &r_max_alloc); void add_face(const Vector3 p_points[3], const Vector2 p_uvs[3], bool p_smooth, bool p_invert, const Ref &p_material, bool p_from_b); void mark_inside_faces(); diff --git a/modules/gltf/editor/editor_scene_importer_blend.cpp b/modules/gltf/editor/editor_scene_importer_blend.cpp index a736e36c6a..51e00011db 100644 --- a/modules/gltf/editor/editor_scene_importer_blend.cpp +++ b/modules/gltf/editor/editor_scene_importer_blend.cpp @@ -466,8 +466,8 @@ bool EditorFileSystemImportFormatSupportQueryBlend::query() { } bool found = false; - for (const String &path : mdfind_paths) { - found = _autodetect_path(path.path_join("Contents/MacOS")); + for (const String &found_path : mdfind_paths) { + found = _autodetect_path(found_path.path_join("Contents/MacOS")); if (found) { break; } diff --git a/modules/text_server_adv/SCsub b/modules/text_server_adv/SCsub index b7b7dccdb0..30a263e0c1 100644 --- a/modules/text_server_adv/SCsub +++ b/modules/text_server_adv/SCsub @@ -513,7 +513,11 @@ if env["builtin_icu4c"]: module_obj = [] if env["builtin_msdfgen"] and msdfgen_enabled: - env_text_server_adv.Prepend(CPPPATH=["#thirdparty/msdfgen"]) + # Treat msdfgen headers as system headers to avoid raising warnings. Not supported on MSVC. + if not env.msvc: + env_text_server_adv.Append(CPPFLAGS=["-isystem", Dir("#thirdparty/msdfgen").path]) + else: + env_text_server_adv.Prepend(CPPPATH=["#thirdparty/msdfgen"]) if env["builtin_freetype"] and freetype_enabled: env_text_server_adv.Append(CPPDEFINES=["FT_CONFIG_OPTION_USE_BROTLI"]) diff --git a/modules/text_server_fb/SCsub b/modules/text_server_fb/SCsub index f1d57ec4d3..582e622147 100644 --- a/modules/text_server_fb/SCsub +++ b/modules/text_server_fb/SCsub @@ -12,7 +12,11 @@ if "svg" in env.module_list: env_text_server_fb.Prepend(CPPPATH=["#thirdparty/thorvg/inc", "#thirdparty/thorvg/src/lib"]) if env["builtin_msdfgen"] and msdfgen_enabled: - env_text_server_fb.Prepend(CPPPATH=["#thirdparty/msdfgen"]) + # Treat msdfgen headers as system headers to avoid raising warnings. Not supported on MSVC. + if not env.msvc: + env_text_server_fb.Append(CPPFLAGS=["-isystem", Dir("#thirdparty/msdfgen").path]) + else: + env_text_server_fb.Prepend(CPPPATH=["#thirdparty/msdfgen"]) if env["builtin_freetype"] and freetype_enabled: env_text_server_fb.Append(CPPDEFINES=["FT_CONFIG_OPTION_USE_BROTLI"]) diff --git a/platform/ios/ios.mm b/platform/ios/ios.mm index d240891a5c..93bf45f0b9 100644 --- a/platform/ios/ios.mm +++ b/platform/ios/ios.mm @@ -72,8 +72,8 @@ CHHapticEngine *iOS::get_haptic_engine_instance() API_AVAILABLE(ios(13)) { void iOS::vibrate_haptic_engine(float p_duration_seconds) API_AVAILABLE(ios(13)) { if (@available(iOS 13, *)) { // We need the @available check every time to make the compiler happy... if (supports_haptic_engine()) { - CHHapticEngine *haptic_engine = get_haptic_engine_instance(); - if (haptic_engine) { + CHHapticEngine *cur_haptic_engine = get_haptic_engine_instance(); + if (cur_haptic_engine) { NSDictionary *hapticDict = @{ CHHapticPatternKeyPattern : @[ @{CHHapticPatternKeyEvent : @{ @@ -88,7 +88,7 @@ void iOS::vibrate_haptic_engine(float p_duration_seconds) API_AVAILABLE(ios(13)) NSError *error; CHHapticPattern *pattern = [[CHHapticPattern alloc] initWithDictionary:hapticDict error:&error]; - [[haptic_engine createPlayerWithPattern:pattern error:&error] startAtTime:0 error:&error]; + [[cur_haptic_engine createPlayerWithPattern:pattern error:&error] startAtTime:0 error:&error]; NSLog(@"Could not vibrate using haptic engine: %@", error); } @@ -103,9 +103,9 @@ void iOS::vibrate_haptic_engine(float p_duration_seconds) API_AVAILABLE(ios(13)) void iOS::start_haptic_engine() { if (@available(iOS 13, *)) { if (supports_haptic_engine()) { - CHHapticEngine *haptic_engine = get_haptic_engine_instance(); - if (haptic_engine) { - [haptic_engine startWithCompletionHandler:^(NSError *returnedError) { + CHHapticEngine *cur_haptic_engine = get_haptic_engine_instance(); + if (cur_haptic_engine) { + [cur_haptic_engine startWithCompletionHandler:^(NSError *returnedError) { if (returnedError) { NSLog(@"Could not start haptic engine: %@", returnedError); } @@ -122,9 +122,9 @@ void iOS::start_haptic_engine() { void iOS::stop_haptic_engine() { if (@available(iOS 13, *)) { if (supports_haptic_engine()) { - CHHapticEngine *haptic_engine = get_haptic_engine_instance(); - if (haptic_engine) { - [haptic_engine stopWithCompletionHandler:^(NSError *returnedError) { + CHHapticEngine *cur_haptic_engine = get_haptic_engine_instance(); + if (cur_haptic_engine) { + [cur_haptic_engine stopWithCompletionHandler:^(NSError *returnedError) { if (returnedError) { NSLog(@"Could not stop haptic engine: %@", returnedError); } diff --git a/platform/linuxbsd/x11/detect_prime_x11.cpp b/platform/linuxbsd/x11/detect_prime_x11.cpp index 3d07be1c76..78778a8b56 100644 --- a/platform/linuxbsd/x11/detect_prime_x11.cpp +++ b/platform/linuxbsd/x11/detect_prime_x11.cpp @@ -60,6 +60,9 @@ typedef GLXContext (*GLXCREATECONTEXTATTRIBSARBPROC)(Display *, GLXFBConfig, GLXContext, Bool, const int *); +// To prevent shadowing warnings +#undef glGetString + struct vendor { const char *glxvendor = nullptr; int priority = 0; diff --git a/platform/linuxbsd/x11/display_server_x11.cpp b/platform/linuxbsd/x11/display_server_x11.cpp index d70efb53f8..7f7a2bcfcd 100644 --- a/platform/linuxbsd/x11/display_server_x11.cpp +++ b/platform/linuxbsd/x11/display_server_x11.cpp @@ -2710,8 +2710,8 @@ void DisplayServerX11::cursor_set_custom_image(const Ref &p_cursor, Cu XcursorImageDestroy(cursor_image); } else { // Reset to default system cursor - if (img[p_shape]) { - cursors[p_shape] = XcursorImageLoadCursor(x11_display, img[p_shape]); + if (cursor_img[p_shape]) { + cursors[p_shape] = XcursorImageLoadCursor(x11_display, cursor_img[p_shape]); } CursorShape c = current_cursor; @@ -5319,7 +5319,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode for (int i = 0; i < CURSOR_MAX; i++) { cursors[i] = None; - img[i] = nullptr; + cursor_img[i] = nullptr; } XInitThreads(); //always use threads @@ -5611,8 +5611,8 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode "question_arrow" }; - img[i] = XcursorLibraryLoadImage(cursor_file[i], cursor_theme, cursor_size); - if (!img[i]) { + cursor_img[i] = XcursorLibraryLoadImage(cursor_file[i], cursor_theme, cursor_size); + if (!cursor_img[i]) { const char *fallback = nullptr; switch (i) { @@ -5650,7 +5650,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode fallback = "bd_double_arrow"; break; case CURSOR_MOVE: - img[i] = img[CURSOR_DRAG]; + cursor_img[i] = cursor_img[CURSOR_DRAG]; break; case CURSOR_VSPLIT: fallback = "sb_v_double_arrow"; @@ -5663,11 +5663,11 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode break; } if (fallback != nullptr) { - img[i] = XcursorLibraryLoadImage(fallback, cursor_theme, cursor_size); + cursor_img[i] = XcursorLibraryLoadImage(fallback, cursor_theme, cursor_size); } } - if (img[i]) { - cursors[i] = XcursorImageLoadCursor(x11_display, img[i]); + if (cursor_img[i]) { + cursors[i] = XcursorImageLoadCursor(x11_display, cursor_img[i]); } else { print_verbose("Failed loading custom cursor: " + String(cursor_file[i])); } @@ -5806,8 +5806,8 @@ DisplayServerX11::~DisplayServerX11() { if (cursors[i] != None) { XFreeCursor(x11_display, cursors[i]); } - if (img[i] != nullptr) { - XcursorImageDestroy(img[i]); + if (cursor_img[i] != nullptr) { + XcursorImageDestroy(cursor_img[i]); } } diff --git a/platform/linuxbsd/x11/display_server_x11.h b/platform/linuxbsd/x11/display_server_x11.h index dbe8a0ce2b..c0fae38874 100644 --- a/platform/linuxbsd/x11/display_server_x11.h +++ b/platform/linuxbsd/x11/display_server_x11.h @@ -305,7 +305,7 @@ class DisplayServerX11 : public DisplayServer { const char *cursor_theme = nullptr; int cursor_size = 0; - XcursorImage *img[CURSOR_MAX]; + XcursorImage *cursor_img[CURSOR_MAX]; Cursor cursors[CURSOR_MAX]; Cursor null_cursor; CursorShape current_cursor = CURSOR_ARROW; diff --git a/platform/linuxbsd/x11/gl_manager_x11.cpp b/platform/linuxbsd/x11/gl_manager_x11.cpp index ee767dfa80..1e579c9f01 100644 --- a/platform/linuxbsd/x11/gl_manager_x11.cpp +++ b/platform/linuxbsd/x11/gl_manager_x11.cpp @@ -44,6 +44,9 @@ typedef GLXContext (*GLXCREATECONTEXTATTRIBSARBPROC)(Display *, GLXFBConfig, GLXContext, Bool, const int *); +// To prevent shadowing warnings +#undef glXCreateContextAttribsARB + struct GLManager_X11_Private { ::GLXContext glx_context; }; diff --git a/platform/macos/display_server_macos.mm b/platform/macos/display_server_macos.mm index 2d0335f95a..95d9e32e17 100644 --- a/platform/macos/display_server_macos.mm +++ b/platform/macos/display_server_macos.mm @@ -1839,9 +1839,9 @@ Error DisplayServerMacOS::dialog_show(String p_title, String p_description, Vect if (!p_callback.is_null()) { Variant button = button_pressed; Variant *buttonp = &button; - Variant ret; + Variant fun_ret; Callable::CallError ce; - p_callback.callp((const Variant **)&buttonp, 1, ret, ce); + p_callback.callp((const Variant **)&buttonp, 1, fun_ret, ce); } return OK; @@ -1871,9 +1871,9 @@ Error DisplayServerMacOS::dialog_input_text(String p_title, String p_description if (!p_callback.is_null()) { Variant text = ret; Variant *textp = &text; - Variant ret; + Variant fun_ret; Callable::CallError ce; - p_callback.callp((const Variant **)&textp, 1, ret, ce); + p_callback.callp((const Variant **)&textp, 1, fun_ret, ce); } return OK; @@ -1896,7 +1896,7 @@ void DisplayServerMacOS::mouse_set_mode(MouseMode p_mode) { bool previously_shown = (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED); if (show_cursor && !previously_shown) { - WindowID window_id = get_window_at_screen_position(mouse_get_position()); + window_id = get_window_at_screen_position(mouse_get_position()); if (window_id != INVALID_WINDOW_ID) { send_window_event(windows[window_id], WINDOW_EVENT_MOUSE_ENTER); } diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 66b7d1284e..4ac76a5179 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -339,8 +339,6 @@ String OS_Windows::get_distribution_name() const { } String OS_Windows::get_version() const { - typedef LONG NTSTATUS; - typedef NTSTATUS(WINAPI * RtlGetVersionPtr)(PRTL_OSVERSIONINFOW); RtlGetVersionPtr version_ptr = (RtlGetVersionPtr)GetProcAddress(GetModuleHandle("ntdll.dll"), "RtlGetVersion"); if (version_ptr != nullptr) { RTL_OSVERSIONINFOW fow; @@ -458,9 +456,9 @@ OS::DateTime OS_Windows::get_datetime(bool p_utc) const { //Get DST information from Windows, but only if p_utc is false. TIME_ZONE_INFORMATION info; - bool daylight = false; + bool is_daylight = false; if (!p_utc && GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT) { - daylight = true; + is_daylight = true; } DateTime dt; @@ -471,20 +469,20 @@ OS::DateTime OS_Windows::get_datetime(bool p_utc) const { dt.hour = systemtime.wHour; dt.minute = systemtime.wMinute; dt.second = systemtime.wSecond; - dt.dst = daylight; + dt.dst = is_daylight; return dt; } OS::TimeZoneInfo OS_Windows::get_time_zone_info() const { TIME_ZONE_INFORMATION info; - bool daylight = false; + bool is_daylight = false; if (GetTimeZoneInformation(&info) == TIME_ZONE_ID_DAYLIGHT) { - daylight = true; + is_daylight = true; } // Daylight Bias needs to be added to the bias if DST is in effect, or else it will not properly update. TimeZoneInfo ret; - if (daylight) { + if (is_daylight) { ret.name = info.DaylightName; ret.bias = info.Bias + info.DaylightBias; } else { diff --git a/scene/3d/lightmapper.h b/scene/3d/lightmapper.h index 018ed9485d..5a390eaede 100644 --- a/scene/3d/lightmapper.h +++ b/scene/3d/lightmapper.h @@ -71,15 +71,15 @@ public: /*! Constructs a ray from origin, direction, and ray segment. Near * has to be smaller than far. */ - _FORCE_INLINE_ Ray(const Vector3 &org, - const Vector3 &dir, - float tnear = 0.0f, - float tfar = INFINITY) : - org(org), - tnear(tnear), - dir(dir), + _FORCE_INLINE_ Ray(const Vector3 &p_org, + const Vector3 &p_dir, + float p_tnear = 0.0f, + float p_tfar = INFINITY) : + org(p_org), + tnear(p_tnear), + dir(p_dir), time(0.0f), - tfar(tfar), + tfar(p_tfar), mask(-1), u(0.0), v(0.0), diff --git a/scene/resources/audio_stream_wav.cpp b/scene/resources/audio_stream_wav.cpp index f331e3a22c..669b455f89 100644 --- a/scene/resources/audio_stream_wav.cpp +++ b/scene/resources/audio_stream_wav.cpp @@ -87,21 +87,21 @@ void AudioStreamPlaybackWAV::seek(double p_time) { } template -void AudioStreamPlaybackWAV::do_resample(const Depth *p_src, AudioFrame *p_dst, int64_t &offset, int32_t &increment, uint32_t amount, IMA_ADPCM_State *ima_adpcm) { +void AudioStreamPlaybackWAV::do_resample(const Depth *p_src, AudioFrame *p_dst, int64_t &p_offset, int32_t &p_increment, uint32_t p_amount, IMA_ADPCM_State *p_ima_adpcm) { // this function will be compiled branchless by any decent compiler int32_t final, final_r, next, next_r; - while (amount) { - amount--; - int64_t pos = offset >> MIX_FRAC_BITS; + while (p_amount) { + p_amount--; + int64_t pos = p_offset >> MIX_FRAC_BITS; if (is_stereo && !is_ima_adpcm) { pos <<= 1; } if (is_ima_adpcm) { - int64_t sample_pos = pos + ima_adpcm[0].window_ofs; + int64_t sample_pos = pos + p_ima_adpcm[0].window_ofs; - while (sample_pos > ima_adpcm[0].last_nibble) { + while (sample_pos > p_ima_adpcm[0].last_nibble) { static const int16_t _ima_adpcm_step_table[89] = { 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, @@ -122,20 +122,20 @@ void AudioStreamPlaybackWAV::do_resample(const Depth *p_src, AudioFrame *p_dst, for (int i = 0; i < (is_stereo ? 2 : 1); i++) { int16_t nibble, diff, step; - ima_adpcm[i].last_nibble++; + p_ima_adpcm[i].last_nibble++; const uint8_t *src_ptr = (const uint8_t *)base->data; src_ptr += AudioStreamWAV::DATA_PAD; - uint8_t nbb = src_ptr[(ima_adpcm[i].last_nibble >> 1) * (is_stereo ? 2 : 1) + i]; - nibble = (ima_adpcm[i].last_nibble & 1) ? (nbb >> 4) : (nbb & 0xF); - step = _ima_adpcm_step_table[ima_adpcm[i].step_index]; + uint8_t nbb = src_ptr[(p_ima_adpcm[i].last_nibble >> 1) * (is_stereo ? 2 : 1) + i]; + nibble = (p_ima_adpcm[i].last_nibble & 1) ? (nbb >> 4) : (nbb & 0xF); + step = _ima_adpcm_step_table[p_ima_adpcm[i].step_index]; - ima_adpcm[i].step_index += _ima_adpcm_index_table[nibble]; - if (ima_adpcm[i].step_index < 0) { - ima_adpcm[i].step_index = 0; + p_ima_adpcm[i].step_index += _ima_adpcm_index_table[nibble]; + if (p_ima_adpcm[i].step_index < 0) { + p_ima_adpcm[i].step_index = 0; } - if (ima_adpcm[i].step_index > 88) { - ima_adpcm[i].step_index = 88; + if (p_ima_adpcm[i].step_index > 88) { + p_ima_adpcm[i].step_index = 88; } diff = step >> 3; @@ -152,26 +152,26 @@ void AudioStreamPlaybackWAV::do_resample(const Depth *p_src, AudioFrame *p_dst, diff = -diff; } - ima_adpcm[i].predictor += diff; - if (ima_adpcm[i].predictor < -0x8000) { - ima_adpcm[i].predictor = -0x8000; - } else if (ima_adpcm[i].predictor > 0x7FFF) { - ima_adpcm[i].predictor = 0x7FFF; + p_ima_adpcm[i].predictor += diff; + if (p_ima_adpcm[i].predictor < -0x8000) { + p_ima_adpcm[i].predictor = -0x8000; + } else if (p_ima_adpcm[i].predictor > 0x7FFF) { + p_ima_adpcm[i].predictor = 0x7FFF; } /* store loop if there */ - if (ima_adpcm[i].last_nibble == ima_adpcm[i].loop_pos) { - ima_adpcm[i].loop_step_index = ima_adpcm[i].step_index; - ima_adpcm[i].loop_predictor = ima_adpcm[i].predictor; + if (p_ima_adpcm[i].last_nibble == p_ima_adpcm[i].loop_pos) { + p_ima_adpcm[i].loop_step_index = p_ima_adpcm[i].step_index; + p_ima_adpcm[i].loop_predictor = p_ima_adpcm[i].predictor; } - //printf("%i - %i - pred %i\n",int(ima_adpcm[i].last_nibble),int(nibble),int(ima_adpcm[i].predictor)); + //printf("%i - %i - pred %i\n",int(p_ima_adpcm[i].last_nibble),int(nibble),int(p_ima_adpcm[i].predictor)); } } - final = ima_adpcm[0].predictor; + final = p_ima_adpcm[0].predictor; if (is_stereo) { - final_r = ima_adpcm[1].predictor; + final_r = p_ima_adpcm[1].predictor; } } else { @@ -201,7 +201,7 @@ void AudioStreamPlaybackWAV::do_resample(const Depth *p_src, AudioFrame *p_dst, } } - int32_t frac = int64_t(offset & MIX_FRAC_MASK); + int32_t frac = int64_t(p_offset & MIX_FRAC_MASK); final = final + ((next - final) * frac >> MIX_FRAC_BITS); if (is_stereo) { @@ -217,7 +217,7 @@ void AudioStreamPlaybackWAV::do_resample(const Depth *p_src, AudioFrame *p_dst, p_dst->r = final_r / 32767.0; p_dst++; - offset += increment; + p_offset += p_increment; } } diff --git a/scene/resources/audio_stream_wav.h b/scene/resources/audio_stream_wav.h index bea273720c..f150a17d21 100644 --- a/scene/resources/audio_stream_wav.h +++ b/scene/resources/audio_stream_wav.h @@ -61,7 +61,7 @@ class AudioStreamPlaybackWAV : public AudioStreamPlayback { Ref base; template - void do_resample(const Depth *p_src, AudioFrame *p_dst, int64_t &offset, int32_t &increment, uint32_t amount, IMA_ADPCM_State *ima_adpcm); + void do_resample(const Depth *p_src, AudioFrame *p_dst, int64_t &p_offset, int32_t &p_increment, uint32_t p_amount, IMA_ADPCM_State *p_ima_adpcm); public: virtual void start(double p_from_pos = 0.0) override; diff --git a/servers/rendering/shader_compiler.cpp b/servers/rendering/shader_compiler.cpp index 8737d3b217..1f889572df 100644 --- a/servers/rendering/shader_compiler.cpp +++ b/servers/rendering/shader_compiler.cpp @@ -441,7 +441,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene String code; switch (p_node->type) { - case SL::Node::TYPE_SHADER: { + case SL::Node::NODE_TYPE_SHADER: { SL::ShaderNode *pnode = (SL::ShaderNode *)p_node; for (int i = 0; i < pnode->render_modes.size(); i++) { @@ -786,11 +786,11 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene //code+=dump_node_code(pnode->body,p_level); } break; - case SL::Node::TYPE_STRUCT: { + case SL::Node::NODE_TYPE_STRUCT: { } break; - case SL::Node::TYPE_FUNCTION: { + case SL::Node::NODE_TYPE_FUNCTION: { } break; - case SL::Node::TYPE_BLOCK: { + case SL::Node::NODE_TYPE_BLOCK: { SL::BlockNode *bnode = (SL::BlockNode *)p_node; //variables @@ -801,7 +801,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene for (int i = 0; i < bnode->statements.size(); i++) { String scode = _dump_node_code(bnode->statements[i], p_level, r_gen_code, p_actions, p_default_actions, p_assigning); - if (bnode->statements[i]->type == SL::Node::TYPE_CONTROL_FLOW || bnode->single_statement) { + if (bnode->statements[i]->type == SL::Node::NODE_TYPE_CONTROL_FLOW || bnode->single_statement) { code += scode; //use directly if (bnode->use_comma_between_statements && i + 1 < bnode->statements.size()) { code += ","; @@ -815,7 +815,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene } } break; - case SL::Node::TYPE_VARIABLE_DECLARATION: { + case SL::Node::NODE_TYPE_VARIABLE_DECLARATION: { SL::VariableDeclarationNode *vdnode = (SL::VariableDeclarationNode *)p_node; String declaration; @@ -873,7 +873,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene code += declaration; } break; - case SL::Node::TYPE_VARIABLE: { + case SL::Node::NODE_TYPE_VARIABLE: { SL::VariableNode *vnode = (SL::VariableNode *)p_node; bool use_fragment_varying = false; @@ -966,7 +966,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene } } break; - case SL::Node::TYPE_ARRAY_CONSTRUCT: { + case SL::Node::NODE_TYPE_ARRAY_CONSTRUCT: { SL::ArrayConstructNode *acnode = (SL::ArrayConstructNode *)p_node; int sz = acnode->initializer.size(); if (acnode->datatype == SL::TYPE_STRUCT) { @@ -986,7 +986,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene } code += ")"; } break; - case SL::Node::TYPE_ARRAY: { + case SL::Node::NODE_TYPE_ARRAY: { SL::ArrayNode *anode = (SL::ArrayNode *)p_node; bool use_fragment_varying = false; @@ -1077,7 +1077,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene } } break; - case SL::Node::TYPE_CONSTANT: { + case SL::Node::NODE_TYPE_CONSTANT: { SL::ConstantNode *cnode = (SL::ConstantNode *)p_node; if (cnode->array_size == 0) { @@ -1104,7 +1104,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene } } break; - case SL::Node::TYPE_OPERATOR: { + case SL::Node::NODE_TYPE_OPERATOR: { SL::OperatorNode *onode = (SL::OperatorNode *)p_node; switch (onode->op) { @@ -1135,7 +1135,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene case SL::OP_CALL: case SL::OP_STRUCT: case SL::OP_CONSTRUCT: { - ERR_FAIL_COND_V(onode->arguments[0]->type != SL::Node::TYPE_VARIABLE, String()); + ERR_FAIL_COND_V(onode->arguments[0]->type != SL::Node::NODE_TYPE_VARIABLE, String()); const SL::VariableNode *vnode = static_cast(onode->arguments[0]); const SL::FunctionNode *func = nullptr; const bool is_internal_func = internal_functions.has(vnode->name); @@ -1205,12 +1205,12 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene bool done = false; do { switch (node->type) { - case SL::Node::TYPE_VARIABLE: { + case SL::Node::NODE_TYPE_VARIABLE: { name = static_cast(node)->name; done = true; found = true; } break; - case SL::Node::TYPE_MEMBER: { + case SL::Node::NODE_TYPE_MEMBER: { node = static_cast(node)->owner; } break; default: { @@ -1232,12 +1232,12 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene bool correct_texture_uniform = false; switch (onode->arguments[i]->type) { - case SL::Node::TYPE_VARIABLE: { + case SL::Node::NODE_TYPE_VARIABLE: { const SL::VariableNode *varnode = static_cast(onode->arguments[i]); texture_uniform = varnode->name; correct_texture_uniform = true; } break; - case SL::Node::TYPE_ARRAY: { + case SL::Node::NODE_TYPE_ARRAY: { const SL::ArrayNode *anode = static_cast(onode->arguments[i]); texture_uniform = anode->name; correct_texture_uniform = true; @@ -1366,7 +1366,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene } } break; - case SL::Node::TYPE_CONTROL_FLOW: { + case SL::Node::NODE_TYPE_CONTROL_FLOW: { SL::ControlFlowNode *cfnode = (SL::ControlFlowNode *)p_node; if (cfnode->flow_op == SL::FLOW_OP_IF) { code += _mktab(p_level) + "if (" + _dump_node_code(cfnode->expressions[0], p_level, r_gen_code, p_actions, p_default_actions, p_assigning) + ")\n"; @@ -1418,7 +1418,7 @@ String ShaderCompiler::_dump_node_code(const SL::Node *p_node, int p_level, Gene } } break; - case SL::Node::TYPE_MEMBER: { + case SL::Node::NODE_TYPE_MEMBER: { SL::MemberNode *mnode = (SL::MemberNode *)p_node; code = _dump_node_code(mnode->owner, p_level, r_gen_code, p_actions, p_default_actions, p_assigning) + "." + mnode->name; if (mnode->index_expression != nullptr) { diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 084fb64a53..0e880e5cf1 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -3063,7 +3063,7 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI Vector args2; Vector args3; - ERR_FAIL_COND_V(p_func->arguments[0]->type != Node::TYPE_VARIABLE, false); + ERR_FAIL_COND_V(p_func->arguments[0]->type != Node::NODE_TYPE_VARIABLE, false); StringName name = static_cast(p_func->arguments[0])->name.operator String(); @@ -3117,14 +3117,14 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI failed_builtin = true; bool fail = false; for (int i = 0; i < argcount; i++) { - if (p_func->arguments[i + 1]->type == Node::TYPE_ARRAY) { + if (p_func->arguments[i + 1]->type == Node::NODE_TYPE_ARRAY) { const ArrayNode *anode = static_cast(p_func->arguments[i + 1]); if (anode->call_expression == nullptr && !anode->is_indexed()) { fail = true; break; } } - if (get_scalar_type(args[i]) == args[i] && p_func->arguments[i + 1]->type == Node::TYPE_CONSTANT && convert_constant(static_cast(p_func->arguments[i + 1]), builtin_func_defs[idx].args[i])) { + if (get_scalar_type(args[i]) == args[i] && p_func->arguments[i + 1]->type == Node::NODE_TYPE_CONSTANT && convert_constant(static_cast(p_func->arguments[i + 1]), builtin_func_defs[idx].args[i])) { //all good, but needs implicit conversion later } else if (args[i] != builtin_func_defs[idx].args[i]) { fail = true; @@ -3160,7 +3160,7 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI int max = builtin_func_const_args[constarg_idx].max; bool error = false; - if (p_func->arguments[arg]->type == Node::TYPE_VARIABLE) { + if (p_func->arguments[arg]->type == Node::NODE_TYPE_VARIABLE) { const VariableNode *vn = static_cast(p_func->arguments[arg]); bool is_const = false; @@ -3172,7 +3172,7 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI error = true; } } else { - if (p_func->arguments[arg]->type == Node::TYPE_CONSTANT) { + if (p_func->arguments[arg]->type == Node::NODE_TYPE_CONSTANT) { const ConstantNode *cn = static_cast(p_func->arguments[arg]); if (cn->get_datatype() == TYPE_INT && cn->values.size() == 1) { @@ -3207,17 +3207,17 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI break; } if (arg_idx < argcount) { - if (p_func->arguments[arg_idx + 1]->type != Node::TYPE_VARIABLE && p_func->arguments[arg_idx + 1]->type != Node::TYPE_MEMBER && p_func->arguments[arg_idx + 1]->type != Node::TYPE_ARRAY) { + if (p_func->arguments[arg_idx + 1]->type != Node::NODE_TYPE_VARIABLE && p_func->arguments[arg_idx + 1]->type != Node::NODE_TYPE_MEMBER && p_func->arguments[arg_idx + 1]->type != Node::NODE_TYPE_ARRAY) { _set_error(vformat(RTR("Argument %d of function '%s' is not a variable, array, or member."), arg_idx + 1, String(name))); return false; } - if (p_func->arguments[arg_idx + 1]->type == Node::TYPE_ARRAY) { + if (p_func->arguments[arg_idx + 1]->type == Node::NODE_TYPE_ARRAY) { ArrayNode *mn = static_cast(p_func->arguments[arg_idx + 1]); if (mn->is_const) { fail = true; } - } else if (p_func->arguments[arg_idx + 1]->type == Node::TYPE_MEMBER) { + } else if (p_func->arguments[arg_idx + 1]->type == Node::NODE_TYPE_MEMBER) { MemberNode *mn = static_cast(p_func->arguments[arg_idx + 1]); if (mn->basetype_const) { fail = true; @@ -3250,18 +3250,18 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI } StringName var_name; - if (p_func->arguments[arg_idx + 1]->type == Node::TYPE_ARRAY) { + if (p_func->arguments[arg_idx + 1]->type == Node::NODE_TYPE_ARRAY) { var_name = static_cast(p_func->arguments[arg_idx + 1])->name; - } else if (p_func->arguments[arg_idx + 1]->type == Node::TYPE_MEMBER) { + } else if (p_func->arguments[arg_idx + 1]->type == Node::NODE_TYPE_MEMBER) { Node *n = static_cast(p_func->arguments[arg_idx + 1])->owner; - while (n->type == Node::TYPE_MEMBER) { + while (n->type == Node::NODE_TYPE_MEMBER) { n = static_cast(n)->owner; } - if (n->type != Node::TYPE_VARIABLE && n->type != Node::TYPE_ARRAY) { + if (n->type != Node::NODE_TYPE_VARIABLE && n->type != Node::NODE_TYPE_ARRAY) { _set_error(vformat(RTR("Argument %d of function '%s' is not a variable, array, or member."), arg_idx + 1, String(name))); return false; } - if (n->type == Node::TYPE_VARIABLE) { + if (n->type == Node::NODE_TYPE_VARIABLE) { var_name = static_cast(n)->name; } else { // TYPE_ARRAY var_name = static_cast(n)->name; @@ -3298,7 +3298,7 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI } //implicitly convert values if possible for (int i = 0; i < argcount; i++) { - if (get_scalar_type(args[i]) != args[i] || args[i] == builtin_func_defs[idx].args[i] || p_func->arguments[i + 1]->type != Node::TYPE_CONSTANT) { + if (get_scalar_type(args[i]) != args[i] || args[i] == builtin_func_defs[idx].args[i] || p_func->arguments[i + 1]->type != Node::NODE_TYPE_CONSTANT) { //can't do implicit conversion here continue; } @@ -3422,7 +3422,7 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI bool fail = false; for (int j = 0; j < args.size(); j++) { - if (get_scalar_type(args[j]) == args[j] && p_func->arguments[j + 1]->type == Node::TYPE_CONSTANT && args3[j] == 0 && convert_constant(static_cast(p_func->arguments[j + 1]), pfunc->arguments[j].type)) { + if (get_scalar_type(args[j]) == args[j] && p_func->arguments[j + 1]->type == Node::NODE_TYPE_CONSTANT && args3[j] == 0 && convert_constant(static_cast(p_func->arguments[j + 1]), pfunc->arguments[j].type)) { //all good, but it needs implicit conversion later } else if (args[j] != pfunc->arguments[j].type || (args[j] == TYPE_STRUCT && args2[j] != pfunc->arguments[j].type_str) || args3[j] != pfunc->arguments[j].array_size) { String func_arg_name; @@ -3457,7 +3457,7 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, const FunctionI if (!fail) { //implicitly convert values if possible for (int k = 0; k < args.size(); k++) { - if (get_scalar_type(args[k]) != args[k] || args[k] == pfunc->arguments[k].type || p_func->arguments[k + 1]->type != Node::TYPE_CONSTANT) { + if (get_scalar_type(args[k]) != args[k] || args[k] == pfunc->arguments[k].type || p_func->arguments[k + 1]->type != Node::NODE_TYPE_CONSTANT) { //can't do implicit conversion here continue; } @@ -3565,7 +3565,7 @@ bool ShaderLanguage::_parse_function_arguments(BlockNode *p_block, const Functio return false; } - if (is_const_decl && arg->type == Node::TYPE_VARIABLE) { + if (is_const_decl && arg->type == Node::NODE_TYPE_VARIABLE) { const VariableNode *var = static_cast(arg); if (!var->is_const) { _set_error(RTR("Expected constant expression.")); @@ -4531,7 +4531,7 @@ bool ShaderLanguage::_validate_varying_assign(ShaderNode::Varying &p_varying, St bool ShaderLanguage::_check_node_constness(const Node *p_node) const { switch (p_node->type) { - case Node::TYPE_OPERATOR: { + case Node::NODE_TYPE_OPERATOR: { const OperatorNode *op_node = static_cast(p_node); for (int i = int(op_node->op == OP_CALL); i < op_node->arguments.size(); i++) { if (!_check_node_constness(op_node->arguments[i])) { @@ -4539,15 +4539,15 @@ bool ShaderLanguage::_check_node_constness(const Node *p_node) const { } } } break; - case Node::TYPE_CONSTANT: + case Node::NODE_TYPE_CONSTANT: break; - case Node::TYPE_VARIABLE: { + case Node::NODE_TYPE_VARIABLE: { const VariableNode *var_node = static_cast(p_node); if (!var_node->is_const) { return false; } } break; - case Node::TYPE_ARRAY: { + case Node::NODE_TYPE_ARRAY: { const ArrayNode *arr_node = static_cast(p_node); if (!arr_node->is_const) { return false; @@ -4560,7 +4560,7 @@ bool ShaderLanguage::_check_node_constness(const Node *p_node) const { } bool ShaderLanguage::_validate_assign(Node *p_node, const FunctionInfo &p_function_info, String *r_message) { - if (p_node->type == Node::TYPE_OPERATOR) { + if (p_node->type == Node::NODE_TYPE_OPERATOR) { OperatorNode *op = static_cast(p_node); if (op->op == OP_INDEX) { @@ -4577,7 +4577,7 @@ bool ShaderLanguage::_validate_assign(Node *p_node, const FunctionInfo &p_functi return false; } - } else if (p_node->type == Node::TYPE_MEMBER) { + } else if (p_node->type == Node::NODE_TYPE_MEMBER) { MemberNode *member = static_cast(p_node); if (member->has_swizzling_duplicates) { @@ -4589,7 +4589,7 @@ bool ShaderLanguage::_validate_assign(Node *p_node, const FunctionInfo &p_functi return _validate_assign(member->owner, p_function_info, r_message); - } else if (p_node->type == Node::TYPE_VARIABLE) { + } else if (p_node->type == Node::NODE_TYPE_VARIABLE) { VariableNode *var = static_cast(p_node); if (shader->uniforms.has(var->name)) { @@ -4609,7 +4609,7 @@ bool ShaderLanguage::_validate_assign(Node *p_node, const FunctionInfo &p_functi if (!(p_function_info.built_ins.has(var->name) && p_function_info.built_ins[var->name].constant)) { return true; } - } else if (p_node->type == Node::TYPE_ARRAY) { + } else if (p_node->type == Node::NODE_TYPE_ARRAY) { ArrayNode *arr = static_cast(p_node); if (shader->constants.has(arr->name) || arr->is_const) { @@ -4727,7 +4727,7 @@ Error ShaderLanguage::_parse_array_size(BlockNode *p_block, const FunctionInfo & _set_tkpos(pos); Node *n = _parse_and_reduce_expression(p_block, p_function_info); if (n) { - if (n->type == Node::TYPE_VARIABLE) { + if (n->type == Node::NODE_TYPE_VARIABLE) { VariableNode *vn = static_cast(n); if (vn) { ConstantNode::Value v; @@ -4750,7 +4750,7 @@ Error ShaderLanguage::_parse_array_size(BlockNode *p_block, const FunctionInfo & } } } - } else if (n->type == Node::TYPE_OPERATOR) { + } else if (n->type == Node::NODE_TYPE_OPERATOR) { _set_error(vformat(RTR("Array size expressions are not supported."))); return ERR_PARSE_ERROR; } @@ -5296,10 +5296,10 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons ArgumentQualifier arg_qual = call_function->arguments[i].qualifier; bool is_out_arg = arg_qual != ArgumentQualifier::ARGUMENT_QUALIFIER_IN; - if (n->type == Node::TYPE_VARIABLE || n->type == Node::TYPE_ARRAY) { + if (n->type == Node::NODE_TYPE_VARIABLE || n->type == Node::NODE_TYPE_ARRAY) { StringName varname; - if (n->type == Node::TYPE_VARIABLE) { + if (n->type == Node::NODE_TYPE_VARIABLE) { VariableNode *vn = static_cast(n); varname = vn->name; } else { // TYPE_ARRAY @@ -5347,23 +5347,23 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons if (is_const_arg || is_out_arg) { StringName varname; - if (n->type == Node::TYPE_CONSTANT || n->type == Node::TYPE_OPERATOR || n->type == Node::TYPE_ARRAY_CONSTRUCT) { + if (n->type == Node::NODE_TYPE_CONSTANT || n->type == Node::NODE_TYPE_OPERATOR || n->type == Node::NODE_TYPE_ARRAY_CONSTRUCT) { if (!is_const_arg) { error = true; } - } else if (n->type == Node::TYPE_ARRAY) { + } else if (n->type == Node::NODE_TYPE_ARRAY) { ArrayNode *an = static_cast(n); if (!is_const_arg && (an->call_expression != nullptr || an->is_const)) { error = true; } varname = an->name; - } else if (n->type == Node::TYPE_VARIABLE) { + } else if (n->type == Node::NODE_TYPE_VARIABLE) { VariableNode *vn = static_cast(n); if (vn->is_const && !is_const_arg) { error = true; } varname = vn->name; - } else if (n->type == Node::TYPE_MEMBER) { + } else if (n->type == Node::NODE_TYPE_MEMBER) { MemberNode *mn = static_cast(n); if (mn->basetype_const && is_out_arg) { error = true; @@ -5389,7 +5389,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons } if (is_sampler_type(call_function->arguments[i].type)) { //let's see where our argument comes from - ERR_CONTINUE(n->type != Node::TYPE_VARIABLE); //bug? this should always be a variable + ERR_CONTINUE(n->type != Node::NODE_TYPE_VARIABLE); //bug? this should always be a variable VariableNode *vn = static_cast(n); StringName varname = vn->name; if (shader->uniforms.has(varname)) { @@ -5599,7 +5599,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons return nullptr; } - if (index_expression->type == Node::TYPE_CONSTANT) { + if (index_expression->type == Node::NODE_TYPE_CONSTANT) { ConstantNode *cnode = static_cast(index_expression); if (cnode) { if (!cnode->values.is_empty()) { @@ -6064,7 +6064,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons return nullptr; } - if (index_expression->type == Node::TYPE_CONSTANT) { + if (index_expression->type == Node::NODE_TYPE_CONSTANT) { ConstantNode *cnode = static_cast(index_expression); if (cnode) { if (!cnode->values.is_empty()) { @@ -6118,7 +6118,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons String member_struct_name; if (expr->get_array_size() > 0) { - if (index->type == Node::TYPE_CONSTANT) { + if (index->type == Node::NODE_TYPE_CONSTANT) { uint32_t index_constant = static_cast(index)->values[0].uint; if (index_constant >= (uint32_t)expr->get_array_size()) { _set_error(vformat(RTR("Index [%d] out of range [%d..%d]."), index_constant, 0, expr->get_array_size() - 1)); @@ -6136,7 +6136,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons case TYPE_IVEC2: case TYPE_UVEC2: case TYPE_MAT2: - if (index->type == Node::TYPE_CONSTANT) { + if (index->type == Node::NODE_TYPE_CONSTANT) { uint32_t index_constant = static_cast(index)->values[0].uint; if (index_constant >= 2) { _set_error(vformat(RTR("Index [%d] out of range [%d..%d]."), index_constant, 0, 1)); @@ -6170,7 +6170,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons case TYPE_IVEC3: case TYPE_UVEC3: case TYPE_MAT3: - if (index->type == Node::TYPE_CONSTANT) { + if (index->type == Node::NODE_TYPE_CONSTANT) { uint32_t index_constant = static_cast(index)->values[0].uint; if (index_constant >= 3) { _set_error(vformat(RTR("Index [%d] out of range [%d..%d]."), index_constant, 0, 2)); @@ -6203,7 +6203,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons case TYPE_IVEC4: case TYPE_UVEC4: case TYPE_MAT4: - if (index->type == Node::TYPE_CONSTANT) { + if (index->type == Node::NODE_TYPE_CONSTANT) { uint32_t index_constant = static_cast(index)->values[0].uint; if (index_constant >= 4) { _set_error(vformat(RTR("Index [%d] out of range [%d..%d]."), index_constant, 0, 3)); @@ -6702,7 +6702,7 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons } ShaderLanguage::Node *ShaderLanguage::_reduce_expression(BlockNode *p_block, ShaderLanguage::Node *p_node) { - if (p_node->type != Node::TYPE_OPERATOR) { + if (p_node->type != Node::NODE_TYPE_OPERATOR) { return p_node; } @@ -6710,7 +6710,7 @@ ShaderLanguage::Node *ShaderLanguage::_reduce_expression(BlockNode *p_block, Sha OperatorNode *op = static_cast(p_node); if (op->op == OP_CONSTRUCT) { - ERR_FAIL_COND_V(op->arguments[0]->type != Node::TYPE_VARIABLE, p_node); + ERR_FAIL_COND_V(op->arguments[0]->type != Node::NODE_TYPE_VARIABLE, p_node); DataType type = op->get_datatype(); DataType base = get_scalar_type(type); @@ -6720,7 +6720,7 @@ ShaderLanguage::Node *ShaderLanguage::_reduce_expression(BlockNode *p_block, Sha for (int i = 1; i < op->arguments.size(); i++) { op->arguments.write[i] = _reduce_expression(p_block, op->arguments[i]); - if (op->arguments[i]->type == Node::TYPE_CONSTANT) { + if (op->arguments[i]->type == Node::NODE_TYPE_CONSTANT) { ConstantNode *cn = static_cast(op->arguments[i]); if (get_scalar_type(cn->datatype) == base) { @@ -6772,7 +6772,7 @@ ShaderLanguage::Node *ShaderLanguage::_reduce_expression(BlockNode *p_block, Sha return cn; } else if (op->op == OP_NEGATE) { op->arguments.write[0] = _reduce_expression(p_block, op->arguments[0]); - if (op->arguments[0]->type == Node::TYPE_CONSTANT) { + if (op->arguments[0]->type == Node::NODE_TYPE_CONSTANT) { ConstantNode *cn = static_cast(op->arguments[0]); DataType base = get_scalar_type(cn->datatype); @@ -7179,7 +7179,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun return ERR_PARSE_ERROR; } - if (is_const && n->type == Node::TYPE_OPERATOR && static_cast(n)->op == OP_CALL) { + if (is_const && n->type == Node::NODE_TYPE_OPERATOR && static_cast(n)->op == OP_CALL) { _set_error(RTR("Expected a constant expression.")); return ERR_PARSE_ERROR; } @@ -7235,7 +7235,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun if (!n) { return ERR_PARSE_ERROR; } - if (is_const && n->type == Node::TYPE_OPERATOR && static_cast(n)->op == OP_CALL) { + if (is_const && n->type == Node::NODE_TYPE_OPERATOR && static_cast(n)->op == OP_CALL) { OperatorNode *op = static_cast(n); for (int i = 1; i < op->arguments.size(); i++) { if (!_check_node_constness(op->arguments[i])) { @@ -7245,7 +7245,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun } } - if (n->type == Node::TYPE_CONSTANT) { + if (n->type == Node::NODE_TYPE_CONSTANT) { ConstantNode *const_node = static_cast(n); if (const_node && const_node->values.size() == 1) { var.value = const_node->values[0]; @@ -7412,7 +7412,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun ControlFlowNode *flow = static_cast(switch_block->statements[i]); if (flow) { if (flow->flow_op == FLOW_OP_CASE) { - if (flow->expressions[0]->type == Node::TYPE_CONSTANT) { + if (flow->expressions[0]->type == Node::NODE_TYPE_CONSTANT) { ConstantNode *cn = static_cast(flow->expressions[0]); if (!cn || cn->values.is_empty()) { return ERR_PARSE_ERROR; @@ -7422,7 +7422,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun return ERR_PARSE_ERROR; } constants.insert(cn->values[0].sint); - } else if (flow->expressions[0]->type == Node::TYPE_VARIABLE) { + } else if (flow->expressions[0]->type == Node::NODE_TYPE_VARIABLE) { VariableNode *vn = static_cast(flow->expressions[0]); if (!vn) { return ERR_PARSE_ERROR; @@ -7852,9 +7852,9 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun if (!expr) { return ERR_PARSE_ERROR; } - is_condition = expr->type == Node::TYPE_OPERATOR && expr->get_datatype() == TYPE_BOOL; + is_condition = expr->type == Node::NODE_TYPE_OPERATOR && expr->get_datatype() == TYPE_BOOL; - if (expr->type == Node::TYPE_OPERATOR) { + if (expr->type == Node::NODE_TYPE_OPERATOR) { OperatorNode *op = static_cast(expr); if (op->op == OP_EMPTY) { is_var_init = true; @@ -8916,7 +8916,7 @@ Error ShaderLanguage::_parse_shader(const HashMap &p_f if (!expr) { return ERR_PARSE_ERROR; } - if (expr->type != Node::TYPE_CONSTANT) { + if (expr->type != Node::NODE_TYPE_CONSTANT) { _set_error(RTR("Expected constant expression after '='.")); return ERR_PARSE_ERROR; } @@ -9276,7 +9276,7 @@ Error ShaderLanguage::_parse_shader(const HashMap &p_f return ERR_PARSE_ERROR; } - if (n->type == Node::TYPE_OPERATOR && static_cast(n)->op == OP_CALL) { + if (n->type == Node::NODE_TYPE_OPERATOR && static_cast(n)->op == OP_CALL) { _set_error(RTR("Expected constant expression.")); return ERR_PARSE_ERROR; } @@ -9343,7 +9343,7 @@ Error ShaderLanguage::_parse_shader(const HashMap &p_f keyword_completion_context = CF_GLOBAL_SPACE; } #endif // DEBUG_ENABLED - if (expr->type == Node::TYPE_OPERATOR && static_cast(expr)->op == OP_CALL) { + if (expr->type == Node::NODE_TYPE_OPERATOR && static_cast(expr)->op == OP_CALL) { OperatorNode *op = static_cast(expr); for (int i = 1; i < op->arguments.size(); i++) { if (!_check_node_constness(op->arguments[i])) { @@ -9756,7 +9756,7 @@ Error ShaderLanguage::_find_last_flow_op_in_op(ControlFlowNode *p_flow, FlowOper bool found = false; for (int i = p_flow->blocks.size() - 1; i >= 0; i--) { - if (p_flow->blocks[i]->type == Node::TYPE_BLOCK) { + if (p_flow->blocks[i]->type == Node::NODE_TYPE_BLOCK) { BlockNode *last_block = static_cast(p_flow->blocks[i]); if (_find_last_flow_op_in_block(last_block, p_op) == OK) { found = true; @@ -9774,7 +9774,7 @@ Error ShaderLanguage::_find_last_flow_op_in_block(BlockNode *p_block, FlowOperat bool found = false; for (int i = p_block->statements.size() - 1; i >= 0; i--) { - if (p_block->statements[i]->type == Node::TYPE_CONTROL_FLOW) { + if (p_block->statements[i]->type == Node::NODE_TYPE_CONTROL_FLOW) { ControlFlowNode *flow = static_cast(p_block->statements[i]); if (flow->flow_op == p_op) { found = true; @@ -9785,7 +9785,7 @@ Error ShaderLanguage::_find_last_flow_op_in_block(BlockNode *p_block, FlowOperat break; } } - } else if (p_block->statements[i]->type == Node::TYPE_BLOCK) { + } else if (p_block->statements[i]->type == Node::NODE_TYPE_BLOCK) { BlockNode *block = static_cast(p_block->statements[i]); if (_find_last_flow_op_in_block(block, p_op) == OK) { found = true; diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h index 220160e5fd..0ddd27f028 100644 --- a/servers/rendering/shader_language.h +++ b/servers/rendering/shader_language.h @@ -357,18 +357,18 @@ public: Node *next = nullptr; enum Type { - TYPE_SHADER, - TYPE_FUNCTION, - TYPE_BLOCK, - TYPE_VARIABLE, - TYPE_VARIABLE_DECLARATION, - TYPE_CONSTANT, - TYPE_OPERATOR, - TYPE_CONTROL_FLOW, - TYPE_MEMBER, - TYPE_ARRAY, - TYPE_ARRAY_CONSTRUCT, - TYPE_STRUCT, + NODE_TYPE_SHADER, + NODE_TYPE_FUNCTION, + NODE_TYPE_BLOCK, + NODE_TYPE_VARIABLE, + NODE_TYPE_VARIABLE_DECLARATION, + NODE_TYPE_CONSTANT, + NODE_TYPE_OPERATOR, + NODE_TYPE_CONTROL_FLOW, + NODE_TYPE_MEMBER, + NODE_TYPE_ARRAY, + NODE_TYPE_ARRAY_CONSTRUCT, + NODE_TYPE_STRUCT, }; Type type; @@ -407,7 +407,7 @@ public: virtual bool is_indexed() const override { return op == OP_INDEX; } OperatorNode() : - Node(TYPE_OPERATOR) {} + Node(NODE_TYPE_OPERATOR) {} }; struct VariableNode : public Node { @@ -421,7 +421,7 @@ public: virtual String get_datatype_name() const override { return String(struct_name); } VariableNode() : - Node(TYPE_VARIABLE) {} + Node(NODE_TYPE_VARIABLE) {} }; struct VariableDeclarationNode : public Node { @@ -442,7 +442,7 @@ public: virtual DataType get_datatype() const override { return datatype; } VariableDeclarationNode() : - Node(TYPE_VARIABLE_DECLARATION) {} + Node(NODE_TYPE_VARIABLE_DECLARATION) {} }; struct ArrayNode : public Node { @@ -462,7 +462,7 @@ public: virtual bool is_indexed() const override { return index_expression != nullptr; } ArrayNode() : - Node(TYPE_ARRAY) {} + Node(NODE_TYPE_ARRAY) {} }; struct ArrayConstructNode : public Node { @@ -475,7 +475,7 @@ public: virtual int get_array_size() const override { return initializer.size(); } ArrayConstructNode() : - Node(TYPE_ARRAY_CONSTRUCT) {} + Node(NODE_TYPE_ARRAY_CONSTRUCT) {} }; struct ConstantNode : public Node { @@ -498,7 +498,7 @@ public: virtual int get_array_size() const override { return array_size; } ConstantNode() : - Node(TYPE_CONSTANT) {} + Node(NODE_TYPE_CONSTANT) {} }; struct FunctionNode; @@ -536,7 +536,7 @@ public: bool use_comma_between_statements = false; BlockNode() : - Node(TYPE_BLOCK) {} + Node(NODE_TYPE_BLOCK) {} }; struct ControlFlowNode : public Node { @@ -545,7 +545,7 @@ public: Vector blocks; ControlFlowNode() : - Node(TYPE_CONTROL_FLOW) {} + Node(NODE_TYPE_CONTROL_FLOW) {} }; struct MemberNode : public Node { @@ -569,13 +569,13 @@ public: virtual bool is_indexed() const override { return index_expression != nullptr || call_expression != nullptr; } MemberNode() : - Node(TYPE_MEMBER) {} + Node(NODE_TYPE_MEMBER) {} }; struct StructNode : public Node { List members; StructNode() : - Node(TYPE_STRUCT) {} + Node(NODE_TYPE_STRUCT) {} }; struct FunctionNode : public Node { @@ -611,7 +611,7 @@ public: virtual int get_array_size() const override { return return_array_size; } FunctionNode() : - Node(TYPE_FUNCTION) {} + Node(NODE_TYPE_FUNCTION) {} }; struct ShaderNode : public Node { @@ -718,7 +718,7 @@ public: Vector vstructs; ShaderNode() : - Node(TYPE_SHADER) {} + Node(NODE_TYPE_SHADER) {} }; struct UniformOrderComparator { -- cgit v1.2.3