diff options
-rw-r--r-- | SConstruct | 7 | ||||
-rw-r--r-- | doc/classes/Node.xml | 3 | ||||
-rw-r--r-- | misc/scons/compilation_db.py | 177 | ||||
-rw-r--r-- | modules/csg/csg.cpp | 4 | ||||
-rw-r--r-- | modules/gdscript/gdscript_analyzer.cpp | 41 | ||||
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 12 | ||||
-rw-r--r-- | scene/main/node.cpp | 1 | ||||
-rw-r--r-- | scene/resources/gradient.cpp | 19 | ||||
-rw-r--r-- | scene/resources/gradient.h | 15 |
9 files changed, 40 insertions, 239 deletions
diff --git a/SConstruct b/SConstruct index 96d2f1abe7..04fe07cb7b 100644 --- a/SConstruct +++ b/SConstruct @@ -310,9 +310,10 @@ if selected_platform in platform_list: from SCons import __version__ as scons_raw_version scons_ver = env._get_major_minor_revision(scons_raw_version) - if scons_ver >= (3, 1, 1): - env.Tool("compilation_db", toolpath=["misc/scons"]) - env.Alias("compiledb", env.CompilationDatabase("compile_commands.json")) + + if scons_ver >= (4, 0, 0): + env.Tool("compilation_db") + env.Alias("compiledb", env.CompilationDatabase()) if env["dev"]: env["verbose"] = True diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml index e921cbd58a..8f66c9df38 100644 --- a/doc/classes/Node.xml +++ b/doc/classes/Node.xml @@ -918,6 +918,9 @@ <constant name="NOTIFICATION_INTERNAL_PHYSICS_PROCESS" value="26"> Notification received every frame when the internal physics process flag is set (see [method set_physics_process_internal]). </constant> + <constant name="NOTIFICATION_POST_ENTER_TREE" value="27"> + Notification received when the node is ready, just before [constant NOTIFICATION_READY] is received. Unlike the latter, it's sent every time the node enters tree, instead of only once. + </constant> <constant name="NOTIFICATION_WM_MOUSE_ENTER" value="1002"> Notification received from the OS when the mouse enters the game window. Implemented on desktop and web platforms. diff --git a/misc/scons/compilation_db.py b/misc/scons/compilation_db.py deleted file mode 100644 index 87db32adc9..0000000000 --- a/misc/scons/compilation_db.py +++ /dev/null @@ -1,177 +0,0 @@ -# Copyright 2015 MongoDB Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import json -import SCons -import itertools - -# Implements the ability for SCons to emit a compilation database for the MongoDB project. See -# http://clang.llvm.org/docs/JSONCompilationDatabase.html for details on what a compilation -# database is, and why you might want one. The only user visible entry point here is -# 'env.CompilationDatabase'. This method takes an optional 'target' to name the file that -# should hold the compilation database, otherwise, the file defaults to compile_commands.json, -# which is the name that most clang tools search for by default. - -# TODO: Is there a better way to do this than this global? Right now this exists so that the -# emitter we add can record all of the things it emits, so that the scanner for the top level -# compilation database can access the complete list, and also so that the writer has easy -# access to write all of the files. But it seems clunky. How can the emitter and the scanner -# communicate more gracefully? -__COMPILATION_DB_ENTRIES = [] - -# We make no effort to avoid rebuilding the entries. Someday, perhaps we could and even -# integrate with the cache, but there doesn't seem to be much call for it. -class __CompilationDbNode(SCons.Node.Python.Value): - def __init__(self, value): - SCons.Node.Python.Value.__init__(self, value) - self.Decider(changed_since_last_build_node) - - -def changed_since_last_build_node(child, target, prev_ni, node): - """ Dummy decider to force always building""" - return True - - -def makeEmitCompilationDbEntry(comstr): - """ - Effectively this creates a lambda function to capture: - * command line - * source - * target - :param comstr: unevaluated command line - :return: an emitter which has captured the above - """ - user_action = SCons.Action.Action(comstr) - - def EmitCompilationDbEntry(target, source, env): - """ - This emitter will be added to each c/c++ object build to capture the info needed - for clang tools - :param target: target node(s) - :param source: source node(s) - :param env: Environment for use building this node - :return: target(s), source(s) - """ - - dbtarget = __CompilationDbNode(source) - - entry = env.__COMPILATIONDB_Entry( - target=dbtarget, - source=[], - __COMPILATIONDB_UTARGET=target, - __COMPILATIONDB_USOURCE=source, - __COMPILATIONDB_UACTION=user_action, - __COMPILATIONDB_ENV=env, - ) - - # TODO: Technically, these next two lines should not be required: it should be fine to - # cache the entries. However, they don't seem to update properly. Since they are quick - # to re-generate disable caching and sidestep this problem. - env.AlwaysBuild(entry) - env.NoCache(entry) - - __COMPILATION_DB_ENTRIES.append(dbtarget) - - return target, source - - return EmitCompilationDbEntry - - -def CompilationDbEntryAction(target, source, env, **kw): - """ - Create a dictionary with evaluated command line, target, source - and store that info as an attribute on the target - (Which has been stored in __COMPILATION_DB_ENTRIES array - :param target: target node(s) - :param source: source node(s) - :param env: Environment for use building this node - :param kw: - :return: None - """ - - command = env["__COMPILATIONDB_UACTION"].strfunction( - target=env["__COMPILATIONDB_UTARGET"], source=env["__COMPILATIONDB_USOURCE"], env=env["__COMPILATIONDB_ENV"], - ) - - entry = { - "directory": env.Dir("#").abspath, - "command": command, - "file": str(env["__COMPILATIONDB_USOURCE"][0]), - } - - target[0].write(entry) - - -def WriteCompilationDb(target, source, env): - entries = [] - - for s in __COMPILATION_DB_ENTRIES: - entries.append(s.read()) - - with open(str(target[0]), "w") as target_file: - json.dump(entries, target_file, sort_keys=True, indent=4, separators=(",", ": ")) - - -def ScanCompilationDb(node, env, path): - return __COMPILATION_DB_ENTRIES - - -def generate(env, **kwargs): - - static_obj, shared_obj = SCons.Tool.createObjBuilders(env) - - env["COMPILATIONDB_COMSTR"] = kwargs.get("COMPILATIONDB_COMSTR", "Building compilation database $TARGET") - - components_by_suffix = itertools.chain( - itertools.product( - env["CPPSUFFIXES"], - [ - (static_obj, SCons.Defaults.StaticObjectEmitter, "$CXXCOM"), - (shared_obj, SCons.Defaults.SharedObjectEmitter, "$SHCXXCOM"), - ], - ), - ) - - for entry in components_by_suffix: - suffix = entry[0] - builder, base_emitter, command = entry[1] - - # Ensure we have a valid entry - # used to auto ignore header files - if suffix in builder.emitter: - emitter = builder.emitter[suffix] - builder.emitter[suffix] = SCons.Builder.ListEmitter([emitter, makeEmitCompilationDbEntry(command),]) - - env["BUILDERS"]["__COMPILATIONDB_Entry"] = SCons.Builder.Builder( - action=SCons.Action.Action(CompilationDbEntryAction, None), - ) - - env["BUILDERS"]["__COMPILATIONDB_Database"] = SCons.Builder.Builder( - action=SCons.Action.Action(WriteCompilationDb, "$COMPILATIONDB_COMSTR"), - target_scanner=SCons.Scanner.Scanner(function=ScanCompilationDb, node_class=None), - ) - - def CompilationDatabase(env, target): - result = env.__COMPILATIONDB_Database(target=target, source=[]) - - env.AlwaysBuild(result) - env.NoCache(result) - - return result - - env.AddMethod(CompilationDatabase, "CompilationDatabase") - - -def exists(env): - return True diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp index 6c0a3a4ca3..b270e04c63 100644 --- a/modules/csg/csg.cpp +++ b/modules/csg/csg.cpp @@ -583,8 +583,8 @@ bool CSGBrushOperation::MeshMerge::_bvh_inside(FaceBVH *facebvhptr, int p_max_de // Check if faces are co-planar. if ((current_normal - face_normal).length_squared() < CMP_EPSILON2 && is_point_in_triangle(face_center, current_points)) { - // Only add an intersection if checking a B face. - if (face.from_b) { + // Only add an intersection if not a B face. + if (!face.from_b) { _add_distance(intersectionsA, intersectionsB, current_face.from_b, 0); } } else if (ray_intersects_triangle(face_center, face_normal, current_points, CMP_EPSILON, intersection_point)) { diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index 616fb1485e..561cdbbda4 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -1374,48 +1374,11 @@ void GDScriptAnalyzer::reduce_assignment(GDScriptParser::AssignmentNode *p_assig push_error("Cannot assign a new value to a constant.", p_assignment->assignee); } - Variant::Operator vop = Variant::Operator::OP_EQUAL; - switch (p_assignment->operation) { - case GDScriptParser::AssignmentNode::OP_NONE: - vop = Variant::Operator::OP_EQUAL; - break; - case GDScriptParser::AssignmentNode::OP_ADDITION: - vop = Variant::Operator::OP_ADD; - break; - case GDScriptParser::AssignmentNode::OP_SUBTRACTION: - vop = Variant::Operator::OP_SUBTRACT; - break; - case GDScriptParser::AssignmentNode::OP_MULTIPLICATION: - vop = Variant::Operator::OP_MULTIPLY; - break; - case GDScriptParser::AssignmentNode::OP_DIVISION: - vop = Variant::Operator::OP_DIVIDE; - break; - case GDScriptParser::AssignmentNode::OP_MODULO: - vop = Variant::Operator::OP_MODULE; - break; - case GDScriptParser::AssignmentNode::OP_BIT_SHIFT_LEFT: - vop = Variant::Operator::OP_SHIFT_LEFT; - break; - case GDScriptParser::AssignmentNode::OP_BIT_SHIFT_RIGHT: - vop = Variant::Operator::OP_SHIFT_RIGHT; - break; - case GDScriptParser::AssignmentNode::OP_BIT_AND: - vop = Variant::Operator::OP_BIT_AND; - break; - case GDScriptParser::AssignmentNode::OP_BIT_OR: - vop = Variant::Operator::OP_BIT_OR; - break; - case GDScriptParser::AssignmentNode::OP_BIT_XOR: - vop = Variant::Operator::OP_BIT_XOR; - break; - } - if (!p_assignment->assignee->get_datatype().is_variant() && !p_assignment->assigned_value->get_datatype().is_variant()) { bool compatible = true; GDScriptParser::DataType op_type = p_assignment->assigned_value->get_datatype(); - if (vop != Variant::OP_EQUAL) { - op_type = get_operation_type(vop, p_assignment->assignee->get_datatype(), p_assignment->assigned_value->get_datatype(), compatible); + if (p_assignment->operation != GDScriptParser::AssignmentNode::OP_NONE) { + op_type = get_operation_type(p_assignment->variant_op, p_assignment->assignee->get_datatype(), p_assignment->assigned_value->get_datatype(), compatible); } if (compatible) { diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index d09d9e2998..0967f74285 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -2009,7 +2009,6 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_binary_operator(Expression push_error(vformat(R"(Expected expression after "%s" operator.")", op.get_name())); } - // TODO: Store the Variant operator here too (in the node). // TODO: Also for unary, ternary, and assignment. switch (op.type) { case GDScriptTokenizer::Token::PLUS: @@ -2171,39 +2170,50 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_assignment(ExpressionNode switch (previous.type) { case GDScriptTokenizer::Token::EQUAL: assignment->operation = AssignmentNode::OP_NONE; + assignment->variant_op = Variant::OP_MAX; #ifdef DEBUG_ENABLED has_operator = false; #endif break; case GDScriptTokenizer::Token::PLUS_EQUAL: assignment->operation = AssignmentNode::OP_ADDITION; + assignment->variant_op = Variant::OP_ADD; break; case GDScriptTokenizer::Token::MINUS_EQUAL: assignment->operation = AssignmentNode::OP_SUBTRACTION; + assignment->variant_op = Variant::OP_SUBTRACT; break; case GDScriptTokenizer::Token::STAR_EQUAL: assignment->operation = AssignmentNode::OP_MULTIPLICATION; + assignment->variant_op = Variant::OP_MULTIPLY; break; case GDScriptTokenizer::Token::SLASH_EQUAL: assignment->operation = AssignmentNode::OP_DIVISION; + assignment->variant_op = Variant::OP_DIVIDE; break; case GDScriptTokenizer::Token::PERCENT_EQUAL: assignment->operation = AssignmentNode::OP_MODULO; + assignment->variant_op = Variant::OP_MODULE; break; case GDScriptTokenizer::Token::LESS_LESS_EQUAL: assignment->operation = AssignmentNode::OP_BIT_SHIFT_LEFT; + assignment->variant_op = Variant::OP_SHIFT_LEFT; break; case GDScriptTokenizer::Token::GREATER_GREATER_EQUAL: assignment->operation = AssignmentNode::OP_BIT_SHIFT_RIGHT; + assignment->variant_op = Variant::OP_SHIFT_RIGHT; break; case GDScriptTokenizer::Token::AMPERSAND_EQUAL: assignment->operation = AssignmentNode::OP_BIT_AND; + assignment->variant_op = Variant::OP_BIT_AND; break; case GDScriptTokenizer::Token::PIPE_EQUAL: assignment->operation = AssignmentNode::OP_BIT_OR; + assignment->variant_op = Variant::OP_BIT_OR; break; case GDScriptTokenizer::Token::CARET_EQUAL: assignment->operation = AssignmentNode::OP_BIT_XOR; + assignment->variant_op = Variant::OP_BIT_XOR; break; default: break; // Unreachable. diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 4dcfcd9d96..653eb698d4 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -2852,6 +2852,7 @@ void Node::_bind_methods() { BIND_CONSTANT(NOTIFICATION_PATH_CHANGED); BIND_CONSTANT(NOTIFICATION_INTERNAL_PROCESS); BIND_CONSTANT(NOTIFICATION_INTERNAL_PHYSICS_PROCESS); + BIND_CONSTANT(NOTIFICATION_POST_ENTER_TREE); BIND_CONSTANT(NOTIFICATION_WM_MOUSE_ENTER); BIND_CONSTANT(NOTIFICATION_WM_MOUSE_EXIT); diff --git a/scene/resources/gradient.cpp b/scene/resources/gradient.cpp index d271c906ff..4bcc52776b 100644 --- a/scene/resources/gradient.cpp +++ b/scene/resources/gradient.cpp @@ -141,32 +141,29 @@ void Gradient::set_points(Vector<Gradient::Point> &p_points) { } void Gradient::set_offset(int pos, const float offset) { - ERR_FAIL_COND(pos < 0); - if (points.size() <= pos) { - points.resize(pos + 1); - } + ERR_FAIL_INDEX(pos, points.size()); + _update_sorting(); points.write[pos].offset = offset; is_sorted = false; emit_signal(CoreStringNames::get_singleton()->changed); } -float Gradient::get_offset(int pos) const { +float Gradient::get_offset(int pos) { ERR_FAIL_INDEX_V(pos, points.size(), 0.0); + _update_sorting(); return points[pos].offset; } void Gradient::set_color(int pos, const Color &color) { - ERR_FAIL_COND(pos < 0); - if (points.size() <= pos) { - points.resize(pos + 1); - is_sorted = false; - } + ERR_FAIL_INDEX(pos, points.size()); + _update_sorting(); points.write[pos].color = color; emit_signal(CoreStringNames::get_singleton()->changed); } -Color Gradient::get_color(int pos) const { +Color Gradient::get_color(int pos) { ERR_FAIL_INDEX_V(pos, points.size(), Color()); + _update_sorting(); return points[pos].color; } diff --git a/scene/resources/gradient.h b/scene/resources/gradient.h index d40dcc8d44..6518b13ee8 100644 --- a/scene/resources/gradient.h +++ b/scene/resources/gradient.h @@ -49,6 +49,12 @@ public: private: Vector<Point> points; bool is_sorted; + _FORCE_INLINE_ void _update_sorting() { + if (!is_sorted) { + points.sort(); + is_sorted = true; + } + } protected: static void _bind_methods(); @@ -64,10 +70,10 @@ public: Vector<Point> &get_points(); void set_offset(int pos, const float offset); - float get_offset(int pos) const; + float get_offset(int pos); void set_color(int pos, const Color &color); - Color get_color(int pos) const; + Color get_color(int pos); void set_offsets(const Vector<float> &p_offsets); Vector<float> get_offsets() const; @@ -80,10 +86,7 @@ public: return Color(0, 0, 0, 1); } - if (!is_sorted) { - points.sort(); - is_sorted = true; - } + _update_sorting(); //binary search int low = 0; |