diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/bullet/rigid_body_bullet.cpp | 5 | ||||
-rw-r--r-- | modules/bullet/space_bullet.cpp | 44 | ||||
-rw-r--r-- | modules/gdscript/gdscript.cpp | 5 | ||||
-rw-r--r-- | modules/gdscript/gdscript_compiler.cpp | 16 | ||||
-rw-r--r-- | modules/gdscript/gdscript_editor.cpp | 15 | ||||
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 46 | ||||
-rw-r--r-- | modules/opensimplex/doc_classes/SimplexNoise.xml | 32 | ||||
-rw-r--r-- | modules/opensimplex/simplex_noise.cpp | 20 | ||||
-rw-r--r-- | modules/opensimplex/simplex_noise.h | 6 |
9 files changed, 116 insertions, 73 deletions
diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp index f81cfe84fb..f24c8670a3 100644 --- a/modules/bullet/rigid_body_bullet.cpp +++ b/modules/bullet/rigid_body_bullet.cpp @@ -351,7 +351,7 @@ void RigidBodyBullet::set_space(SpaceBullet *p_space) { void RigidBodyBullet::dispatch_callbacks() { /// The check isTransformChanged is necessary in order to call integrated forces only when the first transform is sent - if ((btBody->isActive() || previousActiveState != btBody->isActive()) && force_integration_callback && isTransformChanged) { + if ((btBody->isKinematicObject() || btBody->isActive() || previousActiveState != btBody->isActive()) && force_integration_callback && isTransformChanged) { if (omit_forces_integration) btBody->clearForces(); @@ -774,10 +774,13 @@ Vector3 RigidBodyBullet::get_angular_velocity() const { void RigidBodyBullet::set_transform__bullet(const btTransform &p_global_transform) { if (mode == PhysicsServer::BODY_MODE_KINEMATIC) { + if (space) + btBody->setLinearVelocity((p_global_transform.getOrigin() - btBody->getWorldTransform().getOrigin()) / space->get_delta_time()); // The kinematic use MotionState class godotMotionState->moveBody(p_global_transform); } btBody->setWorldTransform(p_global_transform); + scratch(); } const btTransform &RigidBodyBullet::get_transform__bullet() const { diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index 5b220e1039..404cb8e37b 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -786,30 +786,32 @@ void SpaceBullet::check_body_collision() { if (numContacts) { btManifoldPoint &pt = contactManifold->getContactPoint(0); #endif - Vector3 collisionWorldPosition; - Vector3 collisionLocalPosition; - Vector3 normalOnB; - float appliedImpulse = pt.m_appliedImpulse; - B_TO_G(pt.m_normalWorldOnB, normalOnB); - - if (bodyA->can_add_collision()) { - B_TO_G(pt.getPositionWorldOnB(), collisionWorldPosition); - /// pt.m_localPointB Doesn't report the exact point in local space - B_TO_G(pt.getPositionWorldOnB() - contactManifold->getBody1()->getWorldTransform().getOrigin(), collisionLocalPosition); - bodyA->add_collision_object(bodyB, collisionWorldPosition, collisionLocalPosition, normalOnB, appliedImpulse, pt.m_index1, pt.m_index0); - } - if (bodyB->can_add_collision()) { - B_TO_G(pt.getPositionWorldOnA(), collisionWorldPosition); - /// pt.m_localPointA Doesn't report the exact point in local space - B_TO_G(pt.getPositionWorldOnA() - contactManifold->getBody0()->getWorldTransform().getOrigin(), collisionLocalPosition); - bodyB->add_collision_object(bodyA, collisionWorldPosition, collisionLocalPosition, normalOnB * -1, appliedImpulse * -1, pt.m_index0, pt.m_index1); - } + if (pt.getDistance() <= 0.0) { + Vector3 collisionWorldPosition; + Vector3 collisionLocalPosition; + Vector3 normalOnB; + float appliedImpulse = pt.m_appliedImpulse; + B_TO_G(pt.m_normalWorldOnB, normalOnB); + + if (bodyA->can_add_collision()) { + B_TO_G(pt.getPositionWorldOnB(), collisionWorldPosition); + /// pt.m_localPointB Doesn't report the exact point in local space + B_TO_G(pt.getPositionWorldOnB() - contactManifold->getBody1()->getWorldTransform().getOrigin(), collisionLocalPosition); + bodyA->add_collision_object(bodyB, collisionWorldPosition, collisionLocalPosition, normalOnB, appliedImpulse, pt.m_index1, pt.m_index0); + } + if (bodyB->can_add_collision()) { + B_TO_G(pt.getPositionWorldOnA(), collisionWorldPosition); + /// pt.m_localPointA Doesn't report the exact point in local space + B_TO_G(pt.getPositionWorldOnA() - contactManifold->getBody0()->getWorldTransform().getOrigin(), collisionLocalPosition); + bodyB->add_collision_object(bodyA, collisionWorldPosition, collisionLocalPosition, normalOnB * -1, appliedImpulse * -1, pt.m_index0, pt.m_index1); + } #ifdef DEBUG_ENABLED - if (is_debugging_contacts()) { - add_debug_contact(collisionWorldPosition); - } + if (is_debugging_contacts()) { + add_debug_contact(collisionWorldPosition); + } #endif + } } } } diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index d12c1f555c..b0d5422afe 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -126,10 +126,7 @@ GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argco GDScriptLanguage::singleton->lock->unlock(); #endif - if (r_error.error != Variant::CallError::CALL_OK) { - memdelete(instance); - ERR_FAIL_COND_V(r_error.error != Variant::CallError::CALL_OK, NULL); //error constructing - } + ERR_FAIL_COND_V(r_error.error != Variant::CallError::CALL_OK, NULL); //error constructing } //@TODO make thread safe diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 741b837b05..310c4e21f2 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -388,7 +388,7 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser:: int ret = _parse_expression(codegen, an->elements[i], slevel); if (ret < 0) return ret; - if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) { + if ((ret >> GDScriptFunction::ADDR_BITS & GDScriptFunction::ADDR_TYPE_STACK) == GDScriptFunction::ADDR_TYPE_STACK) { slevel++; codegen.alloc_stack(slevel); } @@ -419,7 +419,7 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser:: int ret = _parse_expression(codegen, dn->elements[i].key, slevel); if (ret < 0) return ret; - if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) { + if ((ret >> GDScriptFunction::ADDR_BITS & GDScriptFunction::ADDR_TYPE_STACK) == GDScriptFunction::ADDR_TYPE_STACK) { slevel++; codegen.alloc_stack(slevel); } @@ -429,7 +429,7 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser:: ret = _parse_expression(codegen, dn->elements[i].value, slevel); if (ret < 0) return ret; - if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) { + if ((ret >> GDScriptFunction::ADDR_BITS & GDScriptFunction::ADDR_TYPE_STACK) == GDScriptFunction::ADDR_TYPE_STACK) { slevel++; codegen.alloc_stack(slevel); } @@ -545,7 +545,7 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser:: int ret = _parse_expression(codegen, on->arguments[i], slevel); if (ret < 0) return ret; - if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) { + if ((ret >> GDScriptFunction::ADDR_BITS & GDScriptFunction::ADDR_TYPE_STACK) == GDScriptFunction::ADDR_TYPE_STACK) { slevel++; codegen.alloc_stack(slevel); } @@ -578,7 +578,7 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser:: int ret = _parse_expression(codegen, on->arguments[i], slevel); if (ret < 0) return ret; - if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) { + if ((ret >> GDScriptFunction::ADDR_BITS & GDScriptFunction::ADDR_TYPE_STACK) == GDScriptFunction::ADDR_TYPE_STACK) { slevel++; codegen.alloc_stack(slevel); } @@ -606,7 +606,7 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser:: if (ret < 0) return ret; - if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) { + if ((ret >> GDScriptFunction::ADDR_BITS & GDScriptFunction::ADDR_TYPE_STACK) == GDScriptFunction::ADDR_TYPE_STACK) { slevel++; codegen.alloc_stack(slevel); } @@ -655,7 +655,7 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser:: ret = _parse_expression(codegen, on->arguments[i], slevel); if (ret < 0) return ret; - if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) { + if ((ret >> GDScriptFunction::ADDR_BITS & GDScriptFunction::ADDR_TYPE_STACK) == GDScriptFunction::ADDR_TYPE_STACK) { slevel++; codegen.alloc_stack(slevel); } @@ -681,7 +681,7 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser:: int ret = _parse_expression(codegen, on->arguments[i], slevel); if (ret < 0) return ret; - if (ret & (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS)) { + if ((ret >> GDScriptFunction::ADDR_BITS & GDScriptFunction::ADDR_TYPE_STACK) == GDScriptFunction::ADDR_TYPE_STACK) { slevel++; codegen.alloc_stack(slevel); } diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 32a7668760..a9b641de50 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -1189,6 +1189,7 @@ static bool _guess_identifier_type(const GDScriptCompletionContext &p_context, c c.line = op->line; c.block = blk; if (_guess_expression_type(p_context, op->arguments[1], r_type)) { + r_type.type.is_meta_type = false; return true; } } @@ -1221,7 +1222,7 @@ static bool _guess_identifier_type(const GDScriptCompletionContext &p_context, c int def_from = p_context.function->arguments.size() - p_context.function->default_values.size(); if (i >= def_from) { - int def_idx = def_from - i; + int def_idx = i - def_from; if (p_context.function->default_values[def_idx]->type == GDScriptParser::Node::TYPE_OPERATOR) { const GDScriptParser::OperatorNode *op = static_cast<const GDScriptParser::OperatorNode *>(p_context.function->default_values[def_idx]); if (op->arguments.size() < 2) { @@ -1376,11 +1377,11 @@ static bool _guess_identifier_type_from_base(const GDScriptCompletionContext &p_ for (int i = 0; i < base_type.class_type->variables.size(); i++) { GDScriptParser::ClassNode::Member m = base_type.class_type->variables[i]; if (m.identifier == p_identifier) { - if (m.data_type.has_type) { - r_type.type = m.data_type; - return true; - } if (m.expression) { + if (p_context.line == m.expression->line) { + // Variable used in the same expression + return false; + } if (_guess_expression_type(p_context, m.expression, r_type)) { return true; } @@ -1389,6 +1390,10 @@ static bool _guess_identifier_type_from_base(const GDScriptCompletionContext &p_ return true; } } + if (m.data_type.has_type) { + r_type.type = m.data_type; + return true; + } return false; } } diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 81652c3d37..ea1287374b 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -81,8 +81,11 @@ bool GDScriptParser::_enter_indent_block(BlockNode *p_block) { } tokenizer->advance(); - if (tokenizer->get_token() != GDScriptTokenizer::TK_NEWLINE) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_EOF) { + return false; + } + if (tokenizer->get_token() != GDScriptTokenizer::TK_NEWLINE) { // be more python-like int current = tab_level.back()->get(); tab_level.push_back(current); @@ -92,10 +95,11 @@ bool GDScriptParser::_enter_indent_block(BlockNode *p_block) { } while (true) { - if (tokenizer->get_token() != GDScriptTokenizer::TK_NEWLINE) { return false; //wtf + } else if (tokenizer->get_token(1) == GDScriptTokenizer::TK_EOF) { + return false; } else if (tokenizer->get_token(1) != GDScriptTokenizer::TK_NEWLINE) { int indent = tokenizer->get_token_line_indent(); @@ -637,9 +641,21 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s expr = op; } else { - - _set_error("Static constant '" + identifier.operator String() + "' not present in built-in type " + Variant::get_type_name(bi_type) + "."); - return NULL; + // Object is a special case + bool valid = false; + if (bi_type == Variant::OBJECT) { + int object_constant = ClassDB::get_integer_constant("Object", identifier, &valid); + if (valid) { + ConstantNode *cn = alloc_node<ConstantNode>(); + cn->value = object_constant; + cn->datatype = _type_from_variant(cn->value); + expr = cn; + } + } + if (!valid) { + _set_error("Static constant '" + identifier.operator String() + "' not present in built-in type " + Variant::get_type_name(bi_type) + "."); + return NULL; + } } } else { @@ -4851,6 +4867,20 @@ void GDScriptParser::_parse_class(ClassNode *p_class) { StringName const_id = tokenizer->get_token_literal(); + if (current_class->constant_expressions.has(const_id)) { + _set_error("A constant named '" + String(const_id) + "' already exists in this class (at line: " + + itos(current_class->constant_expressions[const_id].expression->line) + ")."); + return; + } + + for (int i = 0; i < current_class->variables.size(); i++) { + if (current_class->variables[i].identifier == const_id) { + _set_error("A variable named '" + String(const_id) + "' already exists in this class (at line: " + + itos(current_class->variables[i].line) + ")."); + return; + } + } + tokenizer->advance(); if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ASSIGN) { @@ -7204,6 +7234,12 @@ void GDScriptParser::_check_class_level_types(ClassNode *p_class) { expr.is_constant = true; c.type = expr; c.expression->set_datatype(expr); + + DataType tmp; + if (_get_member_type(p_class->base_type, E->key(), tmp)) { + _set_error("Member '" + String(E->key()) + "' already exists in parent class.", c.expression->line); + return; + } } // Function declarations diff --git a/modules/opensimplex/doc_classes/SimplexNoise.xml b/modules/opensimplex/doc_classes/SimplexNoise.xml index a5a01d88a7..1be7b5896d 100644 --- a/modules/opensimplex/doc_classes/SimplexNoise.xml +++ b/modules/opensimplex/doc_classes/SimplexNoise.xml @@ -15,12 +15,12 @@ noise.octaves = 4 noise.period = 20.0 noise.persistance = 0.8 - - #Sample + + # Sample print("Values:") - print(noise.get_noise_2d(1.0,1.0)) - print(noise.get_noise_3d(0.5,3.0,15.0)) - print(noise.get_noise_3d(0.5,1.9,4.7,0.0)) + print(noise.get_noise_2d(1.0, 1.0)) + print(noise.get_noise_3d(0.5, 3.0, 15.0)) + print(noise.get_noise_3d(0.5, 1.9, 4.7, 0.0)) [/codeblock] </description> <tutorials> @@ -47,7 +47,7 @@ <argument index="1" name="y" type="float"> </argument> <description> - 2D noise value [-1,1] at position [code]x[/code],[code]y[/code]. + Returns the 2D noise value [code][-1,1][/code] at the given position. </description> </method> <method name="get_noise_2dv"> @@ -56,7 +56,7 @@ <argument index="0" name="pos" type="Vector2"> </argument> <description> - 2D noise value [-1,1] at position [code]pos.x[/code],[code]pos.y[/code]. + Returns the 2D noise value [code][-1,1][/code] at the given position. </description> </method> <method name="get_noise_3d"> @@ -69,7 +69,7 @@ <argument index="2" name="z" type="float"> </argument> <description> - 3D noise value [-1,1] at position [code]x[/code],[code]y[/code],[code]z[/code]. + Returns the 3D noise value [code][-1,1][/code] at the given position. </description> </method> <method name="get_noise_3dv"> @@ -78,7 +78,7 @@ <argument index="0" name="pos" type="Vector3"> </argument> <description> - 3D noise value [-1,1] at position [code]pos.x[/code],[code]pos.y[/code],[code]pos.z[/code]. + Returns the 3D noise value [code][-1,1][/code] at the given position. </description> </method> <method name="get_noise_4d"> @@ -93,7 +93,7 @@ <argument index="3" name="w" type="float"> </argument> <description> - 4D noise value [-1,1] at position [code]x[/code],[code]y[/code],[code]z[/code],[code]w[/code]. + Returns the 4D noise value [code][-1,1][/code] at the given position. </description> </method> <method name="get_seamless_image"> @@ -102,8 +102,8 @@ <argument index="0" name="size" type="int"> </argument> <description> - Generate a tileable noise image, based on the current noise parameters. - Generated seamless images are always square ([code]size[/code]x[code]size[/code]). + Generate a tileable noise image, based on the current noise parameters. + Generated seamless images are always square ([code]size[/code] x [code]size[/code]). </description> </method> </methods> @@ -112,14 +112,14 @@ Difference in period between [member octaves]. </member> <member name="octaves" type="int" setter="set_octaves" getter="get_octaves"> - Number of Simplex Noise layers that are sampled to get the fractal noise. + Number of Simplex noise layers that are sampled to get the fractal noise. </member> <member name="period" type="float" setter="set_period" getter="get_period"> - Period of the base octave. - A lower period results in a higher frequancy noise (more value changes across the same distance). + Period of the base octave. + A lower period results in a higher-frequency noise (more value changes across the same distance). </member> <member name="persistance" type="float" setter="set_persistance" getter="get_persistance"> - Contribuiton factor of the different octaves. + Contribution factor of the different octaves. A [code]persistance[/code] value of 1 means all the octaves have the same contribution, a value of 0.5 means each octave contributes half as much as the previous one. </member> <member name="seed" type="int" setter="set_seed" getter="get_seed"> diff --git a/modules/opensimplex/simplex_noise.cpp b/modules/opensimplex/simplex_noise.cpp index 6d66c7110e..e489b7f6f0 100644 --- a/modules/opensimplex/simplex_noise.cpp +++ b/modules/opensimplex/simplex_noise.cpp @@ -35,7 +35,7 @@ SimplexNoise::SimplexNoise() { seed = 0; - persistance = 0.5; + persistence = 0.5; octaves = 3; period = 64; lacunarity = 2.0; @@ -81,9 +81,9 @@ void SimplexNoise::set_period(float p_period) { emit_changed(); } -void SimplexNoise::set_persistance(float p_persistance) { - if (p_persistance == persistance) return; - persistance = p_persistance; +void SimplexNoise::set_persistence(float p_persistence) { + if (p_persistence == persistence) return; + persistence = p_persistence; emit_changed(); } @@ -164,8 +164,8 @@ void SimplexNoise::_bind_methods() { ClassDB::bind_method(D_METHOD("set_period", "period"), &SimplexNoise::set_period); ClassDB::bind_method(D_METHOD("get_period"), &SimplexNoise::get_period); - ClassDB::bind_method(D_METHOD("set_persistance", "persistance"), &SimplexNoise::set_persistance); - ClassDB::bind_method(D_METHOD("get_persistance"), &SimplexNoise::get_persistance); + ClassDB::bind_method(D_METHOD("set_persistence", "persistence"), &SimplexNoise::set_persistence); + ClassDB::bind_method(D_METHOD("get_persistence"), &SimplexNoise::get_persistence); ClassDB::bind_method(D_METHOD("set_lacunarity", "lacunarity"), &SimplexNoise::set_lacunarity); ClassDB::bind_method(D_METHOD("get_lacunarity"), &SimplexNoise::get_lacunarity); @@ -183,7 +183,7 @@ void SimplexNoise::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "seed"), "set_seed", "get_seed"); ADD_PROPERTY(PropertyInfo(Variant::INT, "octaves", PROPERTY_HINT_RANGE, "1,6,1"), "set_octaves", "get_octaves"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "period", PROPERTY_HINT_RANGE, "0.1,256.0,0.1"), "set_period", "get_period"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "persistance", PROPERTY_HINT_RANGE, "0.0,1.0,0.001"), "set_persistance", "get_persistance"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "persistence", PROPERTY_HINT_RANGE, "0.0,1.0,0.001"), "set_persistence", "get_persistence"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "lacunarity", PROPERTY_HINT_RANGE, "0.1,4.0,0.01"), "set_lacunarity", "get_lacunarity"); } @@ -200,7 +200,7 @@ float SimplexNoise::get_noise_2d(float x, float y) { while (++i < octaves) { x *= lacunarity; y *= lacunarity; - amp *= persistance; + amp *= persistence; max += amp; sum += _get_octave_noise_2d(i, x, y) * amp; } @@ -223,7 +223,7 @@ float SimplexNoise::get_noise_3d(float x, float y, float z) { x *= lacunarity; y *= lacunarity; z *= lacunarity; - amp *= persistance; + amp *= persistence; max += amp; sum += _get_octave_noise_3d(i, x, y, z) * amp; } @@ -248,7 +248,7 @@ float SimplexNoise::get_noise_4d(float x, float y, float z, float w) { y *= lacunarity; z *= lacunarity; w *= lacunarity; - amp *= persistance; + amp *= persistence; max += amp; sum += _get_octave_noise_4d(i, x, y, z, w) * amp; } diff --git a/modules/opensimplex/simplex_noise.h b/modules/opensimplex/simplex_noise.h index 59390c6172..9a48dbf809 100644 --- a/modules/opensimplex/simplex_noise.h +++ b/modules/opensimplex/simplex_noise.h @@ -44,7 +44,7 @@ class SimplexNoise : public Resource { osn_context contexts[6]; int seed; - float persistance; // Controls details, value in [0,1]. Higher increases grain, lower increases smoothness. + float persistence; // Controls details, value in [0,1]. Higher increases grain, lower increases smoothness. int octaves; // Number of noise layers float period; // Distance above which we start to see similarities. The higher, the longer "hills" will be on a terrain. float lacunarity; // Controls period change across octaves. 2 is usually a good value to address all detail levels. @@ -64,8 +64,8 @@ public: void set_period(float p_period); float get_period() const { return period; } - void set_persistance(float p_persistance); - float get_persistance() const { return persistance; } + void set_persistence(float p_persistence); + float get_persistence() const { return persistence; } void set_lacunarity(float p_lacunarity); float get_lacunarity() const { return lacunarity; } |