diff options
Diffstat (limited to 'modules')
26 files changed, 234 insertions, 99 deletions
diff --git a/modules/bullet/SCsub b/modules/bullet/SCsub index 7a37cca130..0967bca3f2 100644 --- a/modules/bullet/SCsub +++ b/modules/bullet/SCsub @@ -1,9 +1,13 @@ #!/usr/bin/env python Import('env') +Import('env_modules') # build only version 2 # Bullet 2.87 + +env_bullet = env_modules.Clone() + bullet_src__2_x = [ # BulletCollision "BulletCollision/BroadphaseCollision/btAxisSweep3.cpp" @@ -181,11 +185,11 @@ thirdparty_src = thirdparty_dir + "src/" bullet_sources = [thirdparty_src + file for file in bullet_src__2_x] # include headers -env.Append(CPPPATH=[thirdparty_src]) +env_bullet.Append(CPPPATH=[thirdparty_src]) -env.add_source_files(env.modules_sources, bullet_sources) +env_bullet.add_source_files(env.modules_sources, bullet_sources) # Godot source files -env.add_source_files(env.modules_sources, "*.cpp") +env_bullet.add_source_files(env.modules_sources, "*.cpp") Export('env') diff --git a/modules/bullet/collision_object_bullet.cpp b/modules/bullet/collision_object_bullet.cpp index da3a4b73cf..88d4108f82 100644 --- a/modules/bullet/collision_object_bullet.cpp +++ b/modules/bullet/collision_object_bullet.cpp @@ -76,11 +76,17 @@ bool equal(real_t first, real_t second) { void CollisionObjectBullet::set_body_scale(const Vector3 &p_new_scale) { if (!equal(p_new_scale[0], body_scale[0]) || !equal(p_new_scale[1], body_scale[1]) || !equal(p_new_scale[2], body_scale[2])) { - G_TO_B(p_new_scale, body_scale); + body_scale = p_new_scale; on_body_scale_changed(); } } +btVector3 CollisionObjectBullet::get_bt_body_scale() const { + btVector3 s; + G_TO_B(body_scale, s); + return s; +} + void CollisionObjectBullet::on_body_scale_changed() { } @@ -160,6 +166,7 @@ void CollisionObjectBullet::set_transform(const Transform &p_global_transform) { Transform CollisionObjectBullet::get_transform() const { Transform t; B_TO_G(get_transform__bullet(), t); + t.basis.scale(body_scale); return t; } @@ -302,7 +309,7 @@ void RigidCollisionObjectBullet::on_shapes_changed() { } } - compoundShape->setLocalScaling(body_scale); + compoundShape->setLocalScaling(get_bt_body_scale()); compoundShape->recalculateLocalAabb(); } diff --git a/modules/bullet/collision_object_bullet.h b/modules/bullet/collision_object_bullet.h index 51e48909e4..7d4659b64e 100644 --- a/modules/bullet/collision_object_bullet.h +++ b/modules/bullet/collision_object_bullet.h @@ -114,7 +114,7 @@ protected: bool m_isStatic; bool ray_pickable; btCollisionObject *bt_collision_object; - btVector3 body_scale; + Vector3 body_scale; SpaceBullet *space; VSet<RID> exceptions; @@ -146,6 +146,8 @@ public: _FORCE_INLINE_ bool is_ray_pickable() const { return ray_pickable; } void set_body_scale(const Vector3 &p_new_scale); + const Vector3 &get_body_scale() const { return body_scale; } + btVector3 get_bt_body_scale() const; virtual void on_body_scale_changed(); void add_collision_exception(const CollisionObjectBullet *p_ignoreCollisionObject); diff --git a/modules/bullet/cone_twist_joint_bullet.cpp b/modules/bullet/cone_twist_joint_bullet.cpp index 7ae5e79645..738835b910 100644 --- a/modules/bullet/cone_twist_joint_bullet.cpp +++ b/modules/bullet/cone_twist_joint_bullet.cpp @@ -37,11 +37,21 @@ ConeTwistJointBullet::ConeTwistJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &rbAFrame, const Transform &rbBFrame) : JointBullet() { + + Transform scaled_AFrame(rbAFrame.scaled(rbA->get_body_scale())); + scaled_AFrame.basis.rotref_posscale_decomposition(scaled_AFrame.basis); + btTransform btFrameA; - G_TO_B(rbAFrame, btFrameA); + G_TO_B(scaled_AFrame, btFrameA); + if (rbB) { + + Transform scaled_BFrame(rbBFrame.scaled(rbB->get_body_scale())); + scaled_BFrame.basis.rotref_posscale_decomposition(scaled_BFrame.basis); + btTransform btFrameB; - G_TO_B(rbBFrame, btFrameB); + G_TO_B(scaled_BFrame, btFrameB); + coneConstraint = bulletnew(btConeTwistConstraint(*rbA->get_bt_rigid_body(), *rbB->get_bt_rigid_body(), btFrameA, btFrameB)); } else { coneConstraint = bulletnew(btConeTwistConstraint(*rbA->get_bt_rigid_body(), btFrameA)); diff --git a/modules/bullet/generic_6dof_joint_bullet.cpp b/modules/bullet/generic_6dof_joint_bullet.cpp index 28928bd861..da09d4e12f 100644 --- a/modules/bullet/generic_6dof_joint_bullet.cpp +++ b/modules/bullet/generic_6dof_joint_bullet.cpp @@ -38,12 +38,20 @@ Generic6DOFJointBullet::Generic6DOFJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameInA, const Transform &frameInB, bool useLinearReferenceFrameA) : JointBullet() { + Transform scaled_AFrame(frameInA.scaled(rbA->get_body_scale())); + + scaled_AFrame.basis.rotref_posscale_decomposition(scaled_AFrame.basis); + btTransform btFrameA; - G_TO_B(frameInA, btFrameA); + G_TO_B(scaled_AFrame, btFrameA); if (rbB) { + Transform scaled_BFrame(frameInB.scaled(rbB->get_body_scale())); + + scaled_BFrame.basis.rotref_posscale_decomposition(scaled_BFrame.basis); + btTransform btFrameB; - G_TO_B(frameInB, btFrameB); + G_TO_B(scaled_BFrame, btFrameB); sixDOFConstraint = bulletnew(btGeneric6DofConstraint(*rbA->get_bt_rigid_body(), *rbB->get_bt_rigid_body(), btFrameA, btFrameB, useLinearReferenceFrameA)); } else { @@ -109,10 +117,12 @@ void Generic6DOFJointBullet::set_param(Vector3::Axis p_axis, PhysicsServer::G6DO ERR_FAIL_INDEX(p_axis, 3); switch (p_param) { case PhysicsServer::G6DOF_JOINT_LINEAR_LOWER_LIMIT: - sixDOFConstraint->getTranslationalLimitMotor()->m_lowerLimit[p_axis] = p_value; + limits_lower[0][p_axis] = p_value; + set_flag(p_axis, PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, flags[p_axis][p_param]); // Reload bullet parameter break; case PhysicsServer::G6DOF_JOINT_LINEAR_UPPER_LIMIT: - sixDOFConstraint->getTranslationalLimitMotor()->m_upperLimit[p_axis] = p_value; + limits_upper[0][p_axis] = p_value; + set_flag(p_axis, PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, flags[p_axis][p_param]); // Reload bullet parameter break; case PhysicsServer::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS: sixDOFConstraint->getTranslationalLimitMotor()->m_limitSoftness = p_value; @@ -124,10 +134,12 @@ void Generic6DOFJointBullet::set_param(Vector3::Axis p_axis, PhysicsServer::G6DO sixDOFConstraint->getTranslationalLimitMotor()->m_damping = p_value; break; case PhysicsServer::G6DOF_JOINT_ANGULAR_LOWER_LIMIT: - sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_loLimit = p_value; + limits_lower[1][p_axis] = p_value; + set_flag(p_axis, PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, flags[p_axis][p_param]); // Reload bullet parameter break; case PhysicsServer::G6DOF_JOINT_ANGULAR_UPPER_LIMIT: - sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_hiLimit = p_value; + limits_upper[1][p_axis] = p_value; + set_flag(p_axis, PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, flags[p_axis][p_param]); // Reload bullet parameter break; case PhysicsServer::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS: sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_limitSoftness = p_value; @@ -159,9 +171,9 @@ real_t Generic6DOFJointBullet::get_param(Vector3::Axis p_axis, PhysicsServer::G6 ERR_FAIL_INDEX_V(p_axis, 3, 0.); switch (p_param) { case PhysicsServer::G6DOF_JOINT_LINEAR_LOWER_LIMIT: - return sixDOFConstraint->getTranslationalLimitMotor()->m_lowerLimit[p_axis]; + return limits_lower[0][p_axis]; case PhysicsServer::G6DOF_JOINT_LINEAR_UPPER_LIMIT: - return sixDOFConstraint->getTranslationalLimitMotor()->m_upperLimit[p_axis]; + return limits_upper[0][p_axis]; case PhysicsServer::G6DOF_JOINT_LINEAR_LIMIT_SOFTNESS: return sixDOFConstraint->getTranslationalLimitMotor()->m_limitSoftness; case PhysicsServer::G6DOF_JOINT_LINEAR_RESTITUTION: @@ -169,9 +181,9 @@ real_t Generic6DOFJointBullet::get_param(Vector3::Axis p_axis, PhysicsServer::G6 case PhysicsServer::G6DOF_JOINT_LINEAR_DAMPING: return sixDOFConstraint->getTranslationalLimitMotor()->m_damping; case PhysicsServer::G6DOF_JOINT_ANGULAR_LOWER_LIMIT: - return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_loLimit; + return limits_lower[1][p_axis]; case PhysicsServer::G6DOF_JOINT_ANGULAR_UPPER_LIMIT: - return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_hiLimit; + return limits_upper[1][p_axis]; case PhysicsServer::G6DOF_JOINT_ANGULAR_LIMIT_SOFTNESS: return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_limitSoftness; case PhysicsServer::G6DOF_JOINT_ANGULAR_DAMPING: @@ -194,48 +206,35 @@ real_t Generic6DOFJointBullet::get_param(Vector3::Axis p_axis, PhysicsServer::G6 void Generic6DOFJointBullet::set_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag, bool p_value) { ERR_FAIL_INDEX(p_axis, 3); + + flags[p_axis][p_flag] = p_value; + switch (p_flag) { case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: - if (p_value) { - if (!get_flag(p_axis, p_flag)) // avoid overwrite, if limited - sixDOFConstraint->setLimit(p_axis, 0, 0); // Limited + if (flags[p_axis][p_flag]) { + sixDOFConstraint->setLimit(p_axis, limits_lower[0][p_axis], limits_upper[0][p_axis]); } else { - if (get_flag(p_axis, p_flag)) // avoid overwrite, if free - sixDOFConstraint->setLimit(p_axis, 0, -1); // Free + sixDOFConstraint->setLimit(p_axis, 0, -1); // Free } break; - case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT: { - int angularAxis = 3 + p_axis; - if (p_value) { - if (!get_flag(p_axis, p_flag)) // avoid overwrite, if Limited - sixDOFConstraint->setLimit(angularAxis, 0, 0); // Limited + case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT: + if (flags[p_axis][p_flag]) { + sixDOFConstraint->setLimit(p_axis + 3, limits_lower[1][p_axis], limits_upper[1][p_axis]); } else { - if (get_flag(p_axis, p_flag)) // avoid overwrite, if free - sixDOFConstraint->setLimit(angularAxis, 0, -1); // Free + sixDOFConstraint->setLimit(p_axis + 3, 0, -1); // Free } break; - } case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_MOTOR: - //sixDOFConstraint->getTranslationalLimitMotor()->m_enableMotor[p_axis] = p_value; - sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_enableMotor = p_value; + sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_enableMotor = flags[p_axis][p_flag]; break; default: WARN_PRINT("This flag is not supported by Bullet engine"); + return; } } bool Generic6DOFJointBullet::get_flag(Vector3::Axis p_axis, PhysicsServer::G6DOFJointAxisFlag p_flag) const { ERR_FAIL_INDEX_V(p_axis, 3, false); - switch (p_flag) { - case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: - return sixDOFConstraint->getTranslationalLimitMotor()->isLimited(p_axis); - case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT: - return sixDOFConstraint->getRotationalLimitMotor(p_axis)->isLimited(); - case PhysicsServer::G6DOF_JOINT_FLAG_ENABLE_MOTOR: - return //sixDOFConstraint->getTranslationalLimitMotor()->m_enableMotor[p_axis] && - sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_enableMotor; - default: - WARN_PRINT("This flag is not supported by Bullet engine"); - return false; - } + + return flags[p_axis][p_flag]; } diff --git a/modules/bullet/generic_6dof_joint_bullet.h b/modules/bullet/generic_6dof_joint_bullet.h index 0d47b823de..ba0ae08800 100644 --- a/modules/bullet/generic_6dof_joint_bullet.h +++ b/modules/bullet/generic_6dof_joint_bullet.h @@ -39,6 +39,11 @@ class RigidBodyBullet; class Generic6DOFJointBullet : public JointBullet { class btGeneric6DofConstraint *sixDOFConstraint; + // First is linear second is angular + Vector3 limits_lower[2]; + Vector3 limits_upper[2]; + bool flags[3][PhysicsServer::G6DOF_JOINT_FLAG_MAX]; + public: Generic6DOFJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameInA, const Transform &frameInB, bool useLinearReferenceFrameA); diff --git a/modules/bullet/hinge_joint_bullet.cpp b/modules/bullet/hinge_joint_bullet.cpp index d3288807b3..ee0d6707d6 100644 --- a/modules/bullet/hinge_joint_bullet.cpp +++ b/modules/bullet/hinge_joint_bullet.cpp @@ -37,12 +37,20 @@ HingeJointBullet::HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameA, const Transform &frameB) : JointBullet() { + + Transform scaled_AFrame(frameA.scaled(rbA->get_body_scale())); + scaled_AFrame.basis.rotref_posscale_decomposition(scaled_AFrame.basis); + btTransform btFrameA; - G_TO_B(frameA, btFrameA); + G_TO_B(scaled_AFrame, btFrameA); if (rbB) { + + Transform scaled_BFrame(frameB.scaled(rbB->get_body_scale())); + scaled_BFrame.basis.rotref_posscale_decomposition(scaled_BFrame.basis); + btTransform btFrameB; - G_TO_B(frameB, btFrameB); + G_TO_B(scaled_BFrame, btFrameB); hingeConstraint = bulletnew(btHingeConstraint(*rbA->get_bt_rigid_body(), *rbB->get_bt_rigid_body(), btFrameA, btFrameB)); } else { @@ -58,14 +66,14 @@ HingeJointBullet::HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, c btVector3 btPivotA; btVector3 btAxisA; - G_TO_B(pivotInA, btPivotA); - G_TO_B(axisInA, btAxisA); + G_TO_B(pivotInA * rbA->get_body_scale(), btPivotA); + G_TO_B(axisInA * rbA->get_body_scale(), btAxisA); if (rbB) { btVector3 btPivotB; btVector3 btAxisB; - G_TO_B(pivotInB, btPivotB); - G_TO_B(axisInB, btAxisB); + G_TO_B(pivotInB * rbB->get_body_scale(), btPivotB); + G_TO_B(axisInB * rbB->get_body_scale(), btAxisB); hingeConstraint = bulletnew(btHingeConstraint(*rbA->get_bt_rigid_body(), *rbB->get_bt_rigid_body(), btPivotA, btPivotB, btAxisA, btAxisB)); } else { diff --git a/modules/bullet/pin_joint_bullet.cpp b/modules/bullet/pin_joint_bullet.cpp index 8c74fcbc94..665e825967 100644 --- a/modules/bullet/pin_joint_bullet.cpp +++ b/modules/bullet/pin_joint_bullet.cpp @@ -40,8 +40,8 @@ PinJointBullet::PinJointBullet(RigidBodyBullet *p_body_a, const Vector3 &p_pos_a btVector3 btPivotA; btVector3 btPivotB; - G_TO_B(p_pos_a, btPivotA); - G_TO_B(p_pos_b, btPivotB); + G_TO_B(p_pos_a * p_body_a->get_body_scale(), btPivotA); + G_TO_B(p_pos_b * p_body_b->get_body_scale(), btPivotB); p2pConstraint = bulletnew(btPoint2PointConstraint(*p_body_a->get_bt_rigid_body(), *p_body_b->get_bt_rigid_body(), btPivotA, diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp index dd2e17c110..669b2c3f0c 100644 --- a/modules/bullet/rigid_body_bullet.cpp +++ b/modules/bullet/rigid_body_bullet.cpp @@ -198,6 +198,8 @@ void RigidBodyBullet::KinematicUtilities::copyAllOwnerShapes() { const CollisionObjectBullet::ShapeWrapper *shape_wrapper; + btVector3 owner_body_scale(owner->get_bt_body_scale()); + for (int i = shapes_count - 1; 0 <= i; --i) { shape_wrapper = &shapes_wrappers[i]; if (!shape_wrapper->active) { @@ -210,28 +212,29 @@ void RigidBodyBullet::KinematicUtilities::copyAllOwnerShapes() { switch (shape_wrapper->shape->get_type()) { case PhysicsServer::SHAPE_SPHERE: { SphereShapeBullet *sphere = static_cast<SphereShapeBullet *>(shape_wrapper->shape); - kin_shape_ref = ShapeBullet::create_shape_sphere(sphere->get_radius() * owner->body_scale[0] + safe_margin); + kin_shape_ref = ShapeBullet::create_shape_sphere(sphere->get_radius() * owner_body_scale[0] + safe_margin); break; } case PhysicsServer::SHAPE_BOX: { BoxShapeBullet *box = static_cast<BoxShapeBullet *>(shape_wrapper->shape); - kin_shape_ref = ShapeBullet::create_shape_box((box->get_half_extents() * owner->body_scale) + btVector3(safe_margin, safe_margin, safe_margin)); + kin_shape_ref = ShapeBullet::create_shape_box((box->get_half_extents() * owner_body_scale) + btVector3(safe_margin, safe_margin, safe_margin)); break; } case PhysicsServer::SHAPE_CAPSULE: { CapsuleShapeBullet *capsule = static_cast<CapsuleShapeBullet *>(shape_wrapper->shape); - kin_shape_ref = ShapeBullet::create_shape_capsule(capsule->get_radius() * owner->body_scale[0] + safe_margin, capsule->get_height() * owner->body_scale[1] + safe_margin); + + kin_shape_ref = ShapeBullet::create_shape_capsule(capsule->get_radius() * owner_body_scale[0] + safe_margin, capsule->get_height() * owner_body_scale[1] + safe_margin); break; } case PhysicsServer::SHAPE_CONVEX_POLYGON: { ConvexPolygonShapeBullet *godot_convex = static_cast<ConvexPolygonShapeBullet *>(shape_wrapper->shape); kin_shape_ref = ShapeBullet::create_shape_convex(godot_convex->vertices); - kin_shape_ref->setLocalScaling(owner->body_scale + btVector3(safe_margin, safe_margin, safe_margin)); + kin_shape_ref->setLocalScaling(owner_body_scale + btVector3(safe_margin, safe_margin, safe_margin)); break; } case PhysicsServer::SHAPE_RAY: { RayShapeBullet *godot_ray = static_cast<RayShapeBullet *>(shape_wrapper->shape); - kin_shape_ref = ShapeBullet::create_shape_ray(godot_ray->length * owner->body_scale[1] + safe_margin); + kin_shape_ref = ShapeBullet::create_shape_ray(godot_ray->length * owner_body_scale[1] + safe_margin); break; } default: diff --git a/modules/bullet/slider_joint_bullet.cpp b/modules/bullet/slider_joint_bullet.cpp index f1d60679ec..cfcd0b57f6 100644 --- a/modules/bullet/slider_joint_bullet.cpp +++ b/modules/bullet/slider_joint_bullet.cpp @@ -37,11 +37,20 @@ SliderJointBullet::SliderJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameInA, const Transform &frameInB) : JointBullet() { + + Transform scaled_AFrame(frameInA.scaled(rbA->get_body_scale())); + scaled_AFrame.basis.rotref_posscale_decomposition(scaled_AFrame.basis); + btTransform btFrameA; - G_TO_B(frameInA, btFrameA); + G_TO_B(scaled_AFrame, btFrameA); + if (rbB) { + + Transform scaled_BFrame(frameInB.scaled(rbB->get_body_scale())); + scaled_BFrame.basis.rotref_posscale_decomposition(scaled_BFrame.basis); + btTransform btFrameB; - G_TO_B(frameInB, btFrameB); + G_TO_B(scaled_BFrame, btFrameB); sliderConstraint = bulletnew(btSliderConstraint(*rbA->get_bt_rigid_body(), *rbB->get_bt_rigid_body(), btFrameA, btFrameB, true)); } else { diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp index ce485956b4..396bebf0ea 100644 --- a/modules/enet/networked_multiplayer_enet.cpp +++ b/modules/enet/networked_multiplayer_enet.cpp @@ -386,7 +386,7 @@ int NetworkedMultiplayerENet::get_available_packet_count() const { return incoming_packets.size(); } -Error NetworkedMultiplayerENet::get_packet(const uint8_t **r_buffer, int &r_buffer_size) const { +Error NetworkedMultiplayerENet::get_packet(const uint8_t **r_buffer, int &r_buffer_size) { ERR_FAIL_COND_V(incoming_packets.size() == 0, ERR_UNAVAILABLE); @@ -480,7 +480,7 @@ int NetworkedMultiplayerENet::get_max_packet_size() const { return 1 << 24; //anything is good } -void NetworkedMultiplayerENet::_pop_current_packet() const { +void NetworkedMultiplayerENet::_pop_current_packet() { if (current_packet.packet) { enet_packet_destroy(current_packet.packet); diff --git a/modules/enet/networked_multiplayer_enet.h b/modules/enet/networked_multiplayer_enet.h index 81d517147d..d7bc5c7849 100644 --- a/modules/enet/networked_multiplayer_enet.h +++ b/modules/enet/networked_multiplayer_enet.h @@ -86,12 +86,12 @@ private: CompressionMode compression_mode; - mutable List<Packet> incoming_packets; + List<Packet> incoming_packets; - mutable Packet current_packet; + Packet current_packet; uint32_t _gen_unique_id() const; - void _pop_current_packet() const; + void _pop_current_packet(); Vector<uint8_t> src_compressor_mem; Vector<uint8_t> dst_compressor_mem; @@ -123,7 +123,7 @@ public: virtual bool is_server() const; virtual int get_available_packet_count() const; - virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) const; ///< buffer is GONE after next get_packet + virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size); ///< buffer is GONE after next get_packet virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size); virtual int get_max_packet_size() const; diff --git a/modules/etc/SCsub b/modules/etc/SCsub index 9c3e703f11..31d8f00ef3 100644 --- a/modules/etc/SCsub +++ b/modules/etc/SCsub @@ -34,7 +34,8 @@ env_etc.Append(CPPPATH=[thirdparty_dir]) env_etc.add_source_files(env.modules_sources, "*.cpp") # upstream uses c++11 -env_etc.Append(CCFLAGS="-std=gnu++11") +if (not env_etc.msvc): + env_etc.Append(CCFLAGS="-std=c++11") # -ffast-math seems to be incompatible with ec2comp on recent versions of # GCC and Clang if '-ffast-math' in env_etc['CCFLAGS']: diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json index 31f3b0b77b..b7b2553435 100644 --- a/modules/gdnative/gdnative_api.json +++ b/modules/gdnative/gdnative_api.json @@ -5533,6 +5533,12 @@ ] }, { + "name": "godot_get_stack_bottom", + "return_type": "void *", + "arguments": [ + ] + }, + { "name": "godot_method_bind_get_method", "return_type": "godot_method_bind *", "arguments": [ @@ -5569,6 +5575,12 @@ ] }, { + "name": "godot_get_global_constants", + "return_type": "godot_dictionary", + "arguments": [ + ] + }, + { "name": "godot_register_native_call_type", "return_type": "void", "arguments": [ diff --git a/modules/gdscript/SCsub b/modules/gdscript/SCsub index 0882406761..13870170a5 100644 --- a/modules/gdscript/SCsub +++ b/modules/gdscript/SCsub @@ -1,7 +1,10 @@ #!/usr/bin/env python Import('env') +Import('env_modules') -env.add_source_files(env.modules_sources, "*.cpp") +env_gdscript = env_modules.Clone() + +env_gdscript.add_source_files(env.modules_sources, "*.cpp") Export('env') diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 599f204184..36ae61e388 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -1140,6 +1140,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s bool unary = false; bool ternary = false; bool error = false; + bool right_to_left = false; switch (expression[i].op) { @@ -1194,11 +1195,13 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s case OperatorNode::OP_TERNARY_IF: priority = 14; ternary = true; + right_to_left = true; break; case OperatorNode::OP_TERNARY_ELSE: priority = 14; error = true; - break; // Errors out when found without IF (since IF would consume it) + // Rigth-to-left should be false in this case, otherwise it would always error. + break; case OperatorNode::OP_ASSIGN: priority = 15; break; case OperatorNode::OP_ASSIGN_ADD: priority = 15; break; @@ -1218,13 +1221,13 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s } } - if (priority < min_priority) { + if (priority < min_priority || (right_to_left && priority == min_priority)) { + // < is used for left to right (default) + // <= is used for right to left if (error) { _set_error("Unexpected operator"); return NULL; } - // < is used for left to right (default) - // <= is used for right to left next_op = i; min_priority = priority; is_unary = unary; diff --git a/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp index 1e007ddb0f..e707032ed8 100644 --- a/modules/gdscript/register_types.cpp +++ b/modules/gdscript/register_types.cpp @@ -30,6 +30,7 @@ #include "register_types.h" #include "gdscript.h" +#include "gdscript_tokenizer.h" #include "io/file_access_encrypted.h" #include "io/resource_loader.h" #include "os/file_access.h" @@ -38,6 +39,45 @@ GDScriptLanguage *script_language_gd = NULL; ResourceFormatLoaderGDScript *resource_loader_gd = NULL; ResourceFormatSaverGDScript *resource_saver_gd = NULL; +#ifdef TOOLS_ENABLED + +#include "editor/editor_export.h" +#include "editor/editor_node.h" +#include "editor/editor_settings.h" + +class EditorExportGDScript : public EditorExportPlugin { + + GDCLASS(EditorExportGDScript, EditorExportPlugin); + +public: + virtual void _export_file(const String &p_path, const String &p_type, const Set<String> &p_features) { + + if (!p_path.ends_with(".gd")) + return; + + Vector<uint8_t> file = FileAccess::get_file_as_array(p_path); + if (file.empty()) + return; + String txt; + txt.parse_utf8((const char *)file.ptr(), file.size()); + file = GDScriptTokenizerBuffer::parse_code_string(txt); + + if (file.empty()) + return; + + add_file(p_path.get_basename() + ".gdc", file, true); + } +}; + +static void _editor_init() { + + Ref<EditorExportGDScript> gd_export; + gd_export.instance(); + EditorExport::get_singleton()->add_export_plugin(gd_export); +} + +#endif + void register_gdscript_types() { ClassDB::register_class<GDScript>(); @@ -49,6 +89,10 @@ void register_gdscript_types() { ResourceLoader::add_resource_format_loader(resource_loader_gd); resource_saver_gd = memnew(ResourceFormatSaverGDScript); ResourceSaver::add_resource_format_saver(resource_saver_gd); + +#ifdef TOOLS_ENABLED + EditorNode::add_init_callback(_editor_init); +#endif } void unregister_gdscript_types() { diff --git a/modules/gridmap/SCsub b/modules/gridmap/SCsub index 0882406761..2ffe15cd33 100644 --- a/modules/gridmap/SCsub +++ b/modules/gridmap/SCsub @@ -1,7 +1,10 @@ #!/usr/bin/env python Import('env') +Import('env_modules') -env.add_source_files(env.modules_sources, "*.cpp") +env_gridmap = env_modules.Clone() + +env_gridmap.add_source_files(env.modules_sources, "*.cpp") Export('env') diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index b3a1947647..bebf8bcf8f 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -469,7 +469,7 @@ bool GridMap::_octant_update(const OctantKey &p_key) { nm.xform = xform; if (navigation) { - nm.id = navigation->navmesh_create(navmesh, xform, this); + nm.id = navigation->navmesh_add(navmesh, xform, this); } else { nm.id = -1; } @@ -556,7 +556,7 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) { if (cell_map.has(F->key()) && F->get().id < 0) { Ref<NavigationMesh> nm = theme->get_item_navmesh(cell_map[F->key()].item); if (nm.is_valid()) { - F->get().id = navigation->navmesh_create(nm, F->get().xform, this); + F->get().id = navigation->navmesh_add(nm, F->get().xform, this); } } } diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h index 5bfdf1dac3..ab66bf123e 100644 --- a/modules/gridmap/grid_map.h +++ b/modules/gridmap/grid_map.h @@ -186,6 +186,11 @@ class GridMap : public Spatial { Vector3 _get_offset() const; + struct BakedMesh { + Ref<Mesh> mesh; + Transform transform; + }; + protected: bool _set(const StringName &p_name, const Variant &p_value); bool _get(const StringName &p_name, Variant &r_ret) const; diff --git a/modules/mono/SCsub b/modules/mono/SCsub index 18a20ecac4..320bbe7090 100644 --- a/modules/mono/SCsub +++ b/modules/mono/SCsub @@ -1,6 +1,9 @@ #!/usr/bin/env python Import('env') +Import('env_modules') + +env_mono = env_modules.Clone() from compat import byte_to_str @@ -43,12 +46,12 @@ def make_cs_files_header(src, dst): header.write('#endif // _CS_FILES_DATA_H') -env.add_source_files(env.modules_sources, '*.cpp') -env.add_source_files(env.modules_sources, 'mono_gd/*.cpp') -env.add_source_files(env.modules_sources, 'utils/*.cpp') +env_mono.add_source_files(env.modules_sources, '*.cpp') +env_mono.add_source_files(env.modules_sources, 'mono_gd/*.cpp') +env_mono.add_source_files(env.modules_sources, 'utils/*.cpp') if env['tools']: - env.add_source_files(env.modules_sources, 'editor/*.cpp') + env_mono.add_source_files(env.modules_sources, 'editor/*.cpp') make_cs_files_header('glue/cs_files', 'glue/cs_compressed.gen.h') vars = Variables() @@ -58,12 +61,12 @@ vars.Update(env) # Glue sources if env['mono_glue']: - env.add_source_files(env.modules_sources, 'glue/*.cpp') + env_mono.add_source_files(env.modules_sources, 'glue/*.cpp') else: - env.Append(CPPDEFINES=['MONO_GLUE_DISABLED']) + env_mono.Append(CPPDEFINES=['MONO_GLUE_DISABLED']) if ARGUMENTS.get('yolo_copy', False): - env.Append(CPPDEFINES=['YOLO_COPY']) + env_mono.Append(CPPDEFINES=['YOLO_COPY']) # Build GodotSharpTools solution @@ -201,8 +204,8 @@ def mono_build_solution(source, target, env): mono_sln_builder = Builder(action = mono_build_solution) -env.Append(BUILDERS={'MonoBuildSolution': mono_sln_builder}) -env.MonoBuildSolution( +env_mono.Append(BUILDERS={'MonoBuildSolution': mono_sln_builder}) +env_mono.MonoBuildSolution( os.path.join(Dir('#bin').abspath, 'GodotSharpTools.dll'), 'editor/GodotSharpTools/GodotSharpTools.sln' ) diff --git a/modules/openssl/stream_peer_openssl.cpp b/modules/openssl/stream_peer_openssl.cpp index 6d1d5485f3..7e8b308cf8 100644 --- a/modules/openssl/stream_peer_openssl.cpp +++ b/modules/openssl/stream_peer_openssl.cpp @@ -412,8 +412,12 @@ void StreamPeerOpenSSL::_print_error(int err) { err = SSL_get_error(ssl, err); switch (err) { - case SSL_ERROR_NONE: ERR_PRINT("NO ERROR: The TLS/SSL I/O operation completed"); break; - case SSL_ERROR_ZERO_RETURN: ERR_PRINT("The TLS/SSL connection has been closed."); + case SSL_ERROR_NONE: + ERR_PRINT("NO ERROR: The TLS/SSL I/O operation completed"); + break; + case SSL_ERROR_ZERO_RETURN: + ERR_PRINT("The TLS/SSL connection has been closed."); + break; case SSL_ERROR_WANT_READ: case SSL_ERROR_WANT_WRITE: ERR_PRINT("The operation did not complete."); diff --git a/modules/thekla_unwrap/SCsub b/modules/thekla_unwrap/SCsub index 1d4b086848..c57bf326ea 100644 --- a/modules/thekla_unwrap/SCsub +++ b/modules/thekla_unwrap/SCsub @@ -56,14 +56,19 @@ if env['builtin_thekla_atlas']: env_thekla_unwrap.Append(CPPPATH=[thirdparty_dir, thirdparty_dir + "/poshlib", thirdparty_dir + "/nvcore", thirdparty_dir + "/nvmesh"]) # upstream uses c++11 - env_thekla_unwrap.Append(CXXFLAGS="-std=gnu++11") + if (not env_thekla_unwrap.msvc): + env_thekla_unwrap.Append(CXXFLAGS="-std=c++11") if env["platform"] == 'x11': - env_thekla_unwrap.Append(CCFLAGS=["-DNV_OS_LINUX"]) + env_thekla_unwrap.Append(CCFLAGS=["-DNV_OS_LINUX", "-DPOSH_COMPILER_GCC"]) elif env["platform"] == 'osx': - env_thekla_unwrap.Append(CCFLAGS=["-DNV_OS_DARWIN"]) + env_thekla_unwrap.Append(CCFLAGS=["-DNV_OS_DARWIN", "-DPOSH_COMPILER_GCC"]) elif env["platform"] == 'windows': - env_thekla_unwrap.Append(CCFLAGS=["-DNV_OS_WIN32"]) + if env.msvc: + env_thekla_unwrap.Append(CCFLAGS=["-DNV_OS_WIN32", "-DNV_CC_MSVC", "-DPOSH_COMPILER_MSVC" ]) + else: + env_thekla_unwrap.Append(CCFLAGS=["-DNV_OS_MINGW", "-DNV_CC_GNUC", "-DPOSH_COMPILER_GCC", "-U__STRICT_ANSI__"]) + env.Append(LIBS=["dbghelp"]) # Godot source files env_thekla_unwrap.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/thekla_unwrap/register_types.cpp b/modules/thekla_unwrap/register_types.cpp index 01b834f8cb..ab3203068f 100644 --- a/modules/thekla_unwrap/register_types.cpp +++ b/modules/thekla_unwrap/register_types.cpp @@ -42,7 +42,7 @@ bool thekla_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver input_mesh.face_array[i].vertex_index[0] = p_indices[i * 3 + 0]; input_mesh.face_array[i].vertex_index[1] = p_indices[i * 3 + 1]; input_mesh.face_array[i].vertex_index[2] = p_indices[i * 3 + 2]; - printf("face %i - %i, %i, %i - mat %i\n", i, input_mesh.face_array[i].vertex_index[0], input_mesh.face_array[i].vertex_index[1], input_mesh.face_array[i].vertex_index[2], p_face_materials[i]); + //printf("face %i - %i, %i, %i - mat %i\n", i, input_mesh.face_array[i].vertex_index[0], input_mesh.face_array[i].vertex_index[1], input_mesh.face_array[i].vertex_index[2], p_face_materials[i]); input_mesh.face_array[i].material_index = p_face_materials[i]; } input_mesh.vertex_array = new Thekla::Atlas_Input_Vertex[p_vertex_count]; @@ -54,8 +54,8 @@ bool thekla_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver } input_mesh.vertex_array[i].uv[0] = 0; input_mesh.vertex_array[i].uv[1] = 0; - printf("vertex %i - %f, %f, %f\n", i, input_mesh.vertex_array[i].position[0], input_mesh.vertex_array[i].position[1], input_mesh.vertex_array[i].position[2]); - printf("normal %i - %f, %f, %f\n", i, input_mesh.vertex_array[i].normal[0], input_mesh.vertex_array[i].normal[1], input_mesh.vertex_array[i].normal[2]); + //printf("vertex %i - %f, %f, %f\n", i, input_mesh.vertex_array[i].position[0], input_mesh.vertex_array[i].position[1], input_mesh.vertex_array[i].position[2]); + //printf("normal %i - %f, %f, %f\n", i, input_mesh.vertex_array[i].normal[0], input_mesh.vertex_array[i].normal[1], input_mesh.vertex_array[i].normal[2]); } input_mesh.face_count = p_index_count / 3; input_mesh.vertex_count = p_vertex_count; @@ -65,6 +65,7 @@ bool thekla_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver Thekla::atlas_set_default_options(&options); options.packer_options.witness.packing_quality = 1; options.packer_options.witness.texel_area = 1.0 / p_texel_size; + options.packer_options.witness.conservative = true; //generate Thekla::Atlas_Error err; diff --git a/modules/visual_script/SCsub b/modules/visual_script/SCsub index 0882406761..96ee911ba0 100644 --- a/modules/visual_script/SCsub +++ b/modules/visual_script/SCsub @@ -1,7 +1,10 @@ #!/usr/bin/env python Import('env') +Import('env_modules') -env.add_source_files(env.modules_sources, "*.cpp") +env_vs = env_modules.Clone() + +env_vs.add_source_files(env.modules_sources, "*.cpp") Export('env') diff --git a/modules/webp/SCsub b/modules/webp/SCsub index f9295fed47..ea7af1bf9e 100644 --- a/modules/webp/SCsub +++ b/modules/webp/SCsub @@ -26,9 +26,6 @@ if env['builtin_libwebp']: "dsp/alpha_processing_neon.c", "dsp/alpha_processing_sse2.c", "dsp/alpha_processing_sse41.c", - "dsp/argb.c", - "dsp/argb_mips_dsp_r2.c", - "dsp/argb_sse2.c", "dsp/cost.c", "dsp/cost_mips32.c", "dsp/cost_mips_dsp_r2.c", @@ -36,6 +33,9 @@ if env['builtin_libwebp']: "dsp/cpu.c", "dsp/dec.c", "dsp/dec_clip_tables.c", + "dsp/ssim.c", + "dsp/ssim_sse2.c", + "dsp/yuv_neon.c", "dsp/dec_mips32.c", "dsp/dec_mips_dsp_r2.c", "dsp/dec_msa.c", @@ -84,6 +84,7 @@ if env['builtin_libwebp']: "dsp/yuv_sse2.c", "enc/alpha_enc.c", "enc/analysis_enc.c", + "enc/backward_references_cost_enc.c", "enc/backward_references_enc.c", "enc/config_enc.c", "enc/cost_enc.c", @@ -122,10 +123,10 @@ if env['builtin_libwebp']: "utils/thread_utils.c", "utils/utils.c", ] - thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] + thirdparty_sources = [thirdparty_dir + "src/" + file for file in thirdparty_sources] env_webp.add_source_files(env.modules_sources, thirdparty_sources) - env_webp.Append(CPPPATH=[thirdparty_dir]) + env_webp.Append(CPPPATH=[thirdparty_dir, thirdparty_dir + "src/"]) # Godot source files env_webp.add_source_files(env.modules_sources, "*.cpp") |