summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/bullet/SCsub2
-rw-r--r--modules/bullet/area_bullet.cpp10
-rw-r--r--modules/bullet/area_bullet.h1
-rw-r--r--modules/bullet/bullet_physics_server.h2
-rw-r--r--modules/bullet/bullet_utilities.h2
-rw-r--r--modules/bullet/collision_object_bullet.cpp57
-rw-r--r--modules/bullet/collision_object_bullet.h13
-rw-r--r--modules/bullet/cone_twist_joint_bullet.cpp7
-rw-r--r--modules/bullet/generic_6dof_joint_bullet.cpp14
-rw-r--r--modules/bullet/godot_result_callbacks.cpp8
-rw-r--r--modules/bullet/godot_result_callbacks.h8
-rw-r--r--modules/bullet/hinge_joint_bullet.cpp12
-rw-r--r--modules/bullet/pin_joint_bullet.cpp3
-rw-r--r--modules/bullet/rigid_body_bullet.cpp36
-rw-r--r--modules/bullet/rigid_body_bullet.h1
-rw-r--r--modules/bullet/shape_bullet.cpp10
-rw-r--r--modules/bullet/space_bullet.cpp68
-rw-r--r--modules/bullet/space_bullet.h2
-rw-r--r--modules/csg/csg_gizmos.cpp12
-rw-r--r--modules/csg/csg_shape.cpp8
-rw-r--r--modules/cvtt/image_compress_cvtt.cpp4
-rw-r--r--modules/gdnative/gdnative/basis.cpp34
-rw-r--r--modules/gdnative/gdnative/dictionary.cpp6
-rw-r--r--modules/gdnative/gdnative/gdnative.cpp4
-rw-r--r--modules/gdnative/gdnative/quat.cpp12
-rw-r--r--modules/gdnative/gdnative/transform.cpp6
-rw-r--r--modules/gdnative/gdnative_api.json129
-rw-r--r--modules/gdnative/gdnative_builders.py49
-rw-r--r--modules/gdnative/include/gdnative/basis.h13
-rw-r--r--modules/gdnative/include/gdnative/dictionary.h2
-rw-r--r--modules/gdnative/include/gdnative/gdnative.h4
-rw-r--r--modules/gdnative/include/gdnative/quat.h2
-rw-r--r--modules/gdnative/include/gdnative/transform.h1
-rw-r--r--modules/gdnative/include/nativescript/godot_nativescript.h2
-rw-r--r--modules/gdnative/nativescript/nativescript.cpp60
-rw-r--r--modules/gdnative/nativescript/nativescript.h2
-rw-r--r--modules/gdscript/editor/gdscript_highlighter.cpp4
-rw-r--r--modules/gdscript/gdscript_compiler.cpp19
-rw-r--r--modules/gdscript/gdscript_editor.cpp14
-rw-r--r--modules/gdscript/gdscript_function.cpp16
-rw-r--r--modules/gdscript/gdscript_function.h1
-rw-r--r--modules/gdscript/gdscript_functions.cpp2
-rw-r--r--modules/gdscript/gdscript_parser.cpp46
-rw-r--r--modules/gdscript/gdscript_parser.h1
-rw-r--r--modules/gridmap/doc_classes/GridMap.xml5
-rw-r--r--modules/gridmap/grid_map.cpp10
-rw-r--r--modules/mobile_vr/shaders/lens_distorted.glsl67
-rw-r--r--modules/mono/editor/bindings_generator.cpp48
-rw-r--r--modules/mono/editor/bindings_generator.h11
-rw-r--r--modules/mono/glue/cs_files/Basis.cs2
-rw-r--r--modules/mono/glue/cs_files/Quat.cs97
-rw-r--r--modules/squish/image_compress_squish.cpp4
-rw-r--r--modules/tinyexr/image_loader_tinyexr.cpp81
-rw-r--r--modules/visual_script/visual_script_editor.cpp8
-rw-r--r--modules/visual_script/visual_script_editor.h4
-rw-r--r--modules/visual_script/visual_script_property_selector.cpp4
-rw-r--r--modules/webm/libvpx/SCsub12
-rw-r--r--modules/websocket/emws_client.cpp18
-rw-r--r--modules/websocket/lws_client.cpp15
-rw-r--r--modules/websocket/lws_helper.h47
-rw-r--r--modules/websocket/lws_server.cpp3
61 files changed, 854 insertions, 291 deletions
diff --git a/modules/bullet/SCsub b/modules/bullet/SCsub
index d8d0b930a5..2557e8cb1d 100644
--- a/modules/bullet/SCsub
+++ b/modules/bullet/SCsub
@@ -68,11 +68,13 @@ if env['builtin_bullet']:
, "BulletCollision/CollisionShapes/btEmptyShape.cpp"
, "BulletCollision/CollisionShapes/btHeightfieldTerrainShape.cpp"
, "BulletCollision/CollisionShapes/btMinkowskiSumShape.cpp"
+ , "BulletCollision/CollisionShapes/btMiniSDF.cpp"
, "BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.cpp"
, "BulletCollision/CollisionShapes/btMultiSphereShape.cpp"
, "BulletCollision/CollisionShapes/btOptimizedBvh.cpp"
, "BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp"
, "BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.cpp"
+ , "BulletCollision/CollisionShapes/btSdfCollisionShape.cpp"
, "BulletCollision/CollisionShapes/btShapeHull.cpp"
, "BulletCollision/CollisionShapes/btSphereShape.cpp"
, "BulletCollision/CollisionShapes/btStaticPlaneShape.cpp"
diff --git a/modules/bullet/area_bullet.cpp b/modules/bullet/area_bullet.cpp
index 3668088590..3200b4a214 100644
--- a/modules/bullet/area_bullet.cpp
+++ b/modules/bullet/area_bullet.cpp
@@ -30,6 +30,7 @@
#include "area_bullet.h"
+#include "bullet_physics_server.h"
#include "bullet_types_converter.h"
#include "bullet_utilities.h"
#include "collision_object_bullet.h"
@@ -57,7 +58,7 @@ AreaBullet::AreaBullet() :
spOv_priority(0) {
btGhost = bulletnew(btGhostObject);
- btGhost->setCollisionShape(compoundShape);
+ btGhost->setCollisionShape(BulletPhysicsServer::get_empty_shape());
setupBulletCollisionObject(btGhost);
/// Collision objects with a callback still have collision response with dynamic rigid bodies.
/// In order to use collision objects as trigger, you have to disable the collision response.
@@ -162,6 +163,13 @@ bool AreaBullet::is_monitoring() const {
return get_godot_object_flags() & GOF_IS_MONITORING_AREA;
}
+void AreaBullet::main_shape_resetted() {
+ if (get_main_shape())
+ btGhost->setCollisionShape(get_main_shape());
+ else
+ btGhost->setCollisionShape(BulletPhysicsServer::get_empty_shape());
+}
+
void AreaBullet::reload_body() {
if (space) {
space->remove_area(this);
diff --git a/modules/bullet/area_bullet.h b/modules/bullet/area_bullet.h
index b2046c684e..a6bf73906c 100644
--- a/modules/bullet/area_bullet.h
+++ b/modules/bullet/area_bullet.h
@@ -142,6 +142,7 @@ public:
_FORCE_INLINE_ void set_spOv_priority(int p_priority) { spOv_priority = p_priority; }
_FORCE_INLINE_ int get_spOv_priority() { return spOv_priority; }
+ virtual void main_shape_resetted();
virtual void reload_body();
virtual void set_space(SpaceBullet *p_space);
diff --git a/modules/bullet/bullet_physics_server.h b/modules/bullet/bullet_physics_server.h
index e9c568d605..87719383f8 100644
--- a/modules/bullet/bullet_physics_server.h
+++ b/modules/bullet/bullet_physics_server.h
@@ -61,7 +61,7 @@ class BulletPhysicsServer : public PhysicsServer {
mutable RID_Owner<JointBullet> joint_owner;
private:
- /// This is used when a collision shape is not active, so the bullet compound shapes index are always sync with godot index
+ /// This is used as replacement of collision shape inside a compound or main shape
static btEmptyShape *emptyShape;
public:
diff --git a/modules/bullet/bullet_utilities.h b/modules/bullet/bullet_utilities.h
index 2841dfbe69..029eb6691a 100644
--- a/modules/bullet/bullet_utilities.h
+++ b/modules/bullet/bullet_utilities.h
@@ -35,8 +35,6 @@
@author AndreaCatania
*/
-#pragma once
-
#define bulletnew(cl) \
new cl
diff --git a/modules/bullet/collision_object_bullet.cpp b/modules/bullet/collision_object_bullet.cpp
index 271cdb0223..df67f8d7ab 100644
--- a/modules/bullet/collision_object_bullet.cpp
+++ b/modules/bullet/collision_object_bullet.cpp
@@ -53,10 +53,17 @@ void CollisionObjectBullet::ShapeWrapper::set_transform(const Transform &p_trans
G_TO_B(p_transform, transform);
UNSCALE_BT_BASIS(transform);
}
+
void CollisionObjectBullet::ShapeWrapper::set_transform(const btTransform &p_transform) {
transform = p_transform;
}
+void CollisionObjectBullet::ShapeWrapper::claim_bt_shape(const btVector3 &body_scale) {
+ if (!bt_shape) {
+ bt_shape = shape->create_bt_shape(scale * body_scale);
+ }
+}
+
CollisionObjectBullet::CollisionObjectBullet(Type p_type) :
RIDBullet(),
space(NULL),
@@ -107,6 +114,7 @@ void CollisionObjectBullet::setupBulletCollisionObject(btCollisionObject *p_coll
bt_collision_object->setUserIndex(type);
// Force the enabling of collision and avoid problems
set_collision_enabled(collisionsEnabled);
+ p_collisionObject->setCollisionFlags(p_collisionObject->getCollisionFlags() | btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
}
void CollisionObjectBullet::add_collision_exception(const CollisionObjectBullet *p_ignoreCollisionObject) {
@@ -186,13 +194,14 @@ const btTransform &CollisionObjectBullet::get_transform__bullet() const {
RigidCollisionObjectBullet::RigidCollisionObjectBullet(Type p_type) :
CollisionObjectBullet(p_type),
- compoundShape(bulletnew(btCompoundShape(enableDynamicAabbTree, initialChildCapacity))) {
+ mainShape(NULL) {
}
RigidCollisionObjectBullet::~RigidCollisionObjectBullet() {
remove_all_shapes(true);
- bt_collision_object->setCollisionShape(NULL);
- bulletdelete(compoundShape);
+ if (mainShape && mainShape->isCompound()) {
+ bulletdelete(mainShape);
+ }
}
/* Not used
@@ -277,6 +286,10 @@ btCollisionShape *RigidCollisionObjectBullet::get_bt_shape(int p_index) const {
return shapes[p_index].bt_shape;
}
+const btTransform &RigidCollisionObjectBullet::get_bt_shape_transform(int p_index) const {
+ return shapes[p_index].transform;
+}
+
Transform RigidCollisionObjectBullet::get_shape_transform(int p_index) const {
Transform trs;
B_TO_G(shapes[p_index].transform, trs);
@@ -294,33 +307,47 @@ void RigidCollisionObjectBullet::on_shape_changed(const ShapeBullet *const p_sha
}
void RigidCollisionObjectBullet::on_shapes_changed() {
- int i;
- // Remove all shapes, reverse order for performance reason (Array resize)
- for (i = compoundShape->getNumChildShapes() - 1; 0 <= i; --i) {
- compoundShape->removeChildShapeByIndex(i);
+ if (mainShape && mainShape->isCompound()) {
+ bulletdelete(mainShape);
}
+ mainShape = NULL;
ShapeWrapper *shpWrapper;
- const int shapes_size = shapes.size();
+ const int shape_count = shapes.size();
// Reset shape if required
if (force_shape_reset) {
- for (i = 0; i < shapes_size; ++i) {
+ for (int i(0); i < shape_count; ++i) {
shpWrapper = &shapes.write[i];
bulletdelete(shpWrapper->bt_shape);
}
force_shape_reset = false;
}
- // Insert all shapes
btVector3 body_scale(get_bt_body_scale());
- for (i = 0; i < shapes_size; ++i) {
+
+ if (!shape_count)
+ return;
+
+ // Try to optimize by not using compound
+ if (1 == shape_count) {
+ shpWrapper = &shapes.write[0];
+ if (shpWrapper->active && shpWrapper->transform.getOrigin().isZero() && shpWrapper->transform.getBasis() == shpWrapper->transform.getBasis().getIdentity()) {
+ shpWrapper->claim_bt_shape(body_scale);
+ mainShape = shpWrapper->bt_shape;
+ main_shape_resetted();
+ return;
+ }
+ }
+
+ btCompoundShape *compoundShape = bulletnew(btCompoundShape(enableDynamicAabbTree, initialChildCapacity));
+
+ // Insert all shapes into compound
+ for (int i(0); i < shape_count; ++i) {
shpWrapper = &shapes.write[i];
if (shpWrapper->active) {
- if (!shpWrapper->bt_shape) {
- shpWrapper->bt_shape = shpWrapper->shape->create_bt_shape(shpWrapper->scale * body_scale);
- }
+ shpWrapper->claim_bt_shape(body_scale);
btTransform scaled_shape_transform(shpWrapper->transform);
scaled_shape_transform.getOrigin() *= body_scale;
@@ -331,6 +358,8 @@ void RigidCollisionObjectBullet::on_shapes_changed() {
}
compoundShape->recalculateLocalAabb();
+ mainShape = compoundShape;
+ main_shape_resetted();
}
void RigidCollisionObjectBullet::set_shape_disabled(int p_index, bool p_disabled) {
diff --git a/modules/bullet/collision_object_bullet.h b/modules/bullet/collision_object_bullet.h
index 506976eabf..d14fdd3301 100644
--- a/modules/bullet/collision_object_bullet.h
+++ b/modules/bullet/collision_object_bullet.h
@@ -109,6 +109,8 @@ public:
void set_transform(const Transform &p_transform);
void set_transform(const btTransform &p_transform);
+
+ void claim_bt_shape(const btVector3 &body_scale);
};
protected:
@@ -207,10 +209,8 @@ public:
class RigidCollisionObjectBullet : public CollisionObjectBullet, public ShapeOwnerBullet {
protected:
- /// This is required to combine some shapes together.
- /// Since Godot allow to have multiple shapes for each body with custom relative location,
- /// each body will attach the shapes using this class even if there is only one shape.
- btCompoundShape *compoundShape;
+ /// This could be a compound shape in case multi please collision are found
+ btCollisionShape *mainShape;
Vector<ShapeWrapper> shapes;
public:
@@ -231,15 +231,18 @@ public:
virtual void on_shape_changed(const ShapeBullet *const p_shape);
virtual void on_shapes_changed();
- _FORCE_INLINE_ btCompoundShape *get_compound_shape() const { return compoundShape; }
+ _FORCE_INLINE_ btCollisionShape *get_main_shape() const { return mainShape; }
+
int get_shape_count() const;
ShapeBullet *get_shape(int p_index) const;
btCollisionShape *get_bt_shape(int p_index) const;
+ const btTransform &get_bt_shape_transform(int p_index) const;
Transform get_shape_transform(int p_index) const;
void set_shape_disabled(int p_index, bool p_disabled);
bool is_shape_disabled(int p_index);
+ virtual void main_shape_resetted() = 0;
virtual void on_body_scale_changed();
private:
diff --git a/modules/bullet/cone_twist_joint_bullet.cpp b/modules/bullet/cone_twist_joint_bullet.cpp
index 6b5438c60f..ecacce0bee 100644
--- a/modules/bullet/cone_twist_joint_bullet.cpp
+++ b/modules/bullet/cone_twist_joint_bullet.cpp
@@ -83,7 +83,9 @@ void ConeTwistJointBullet::set_param(PhysicsServer::ConeTwistJointParam p_param,
coneConstraint->setLimit(coneConstraint->getSwingSpan1(), coneConstraint->getSwingSpan2(), coneConstraint->getTwistSpan(), coneConstraint->getLimitSoftness(), coneConstraint->getBiasFactor(), p_value);
break;
default:
- WARN_PRINT("This parameter is not supported by Bullet engine");
+ ERR_EXPLAIN("This parameter " + itos(p_param) + " is deprecated");
+ WARN_DEPRECATED
+ break;
}
}
@@ -100,7 +102,8 @@ real_t ConeTwistJointBullet::get_param(PhysicsServer::ConeTwistJointParam p_para
case PhysicsServer::CONE_TWIST_JOINT_RELAXATION:
return coneConstraint->getRelaxationFactor();
default:
- WARN_PRINT("This parameter is not supported by Bullet engine");
+ ERR_EXPLAIN("This parameter " + itos(p_param) + " is deprecated");
+ WARN_DEPRECATED;
return 0;
}
}
diff --git a/modules/bullet/generic_6dof_joint_bullet.cpp b/modules/bullet/generic_6dof_joint_bullet.cpp
index 6275a0d2ed..a36f1123bc 100644
--- a/modules/bullet/generic_6dof_joint_bullet.cpp
+++ b/modules/bullet/generic_6dof_joint_bullet.cpp
@@ -153,7 +153,9 @@ void Generic6DOFJointBullet::set_param(Vector3::Axis p_axis, PhysicsServer::G6DO
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_maxMotorForce = p_value;
break;
default:
- WARN_PRINT("This parameter is not supported");
+ ERR_EXPLAIN("This parameter " + itos(p_param) + " is deprecated");
+ WARN_DEPRECATED
+ break;
}
}
@@ -181,8 +183,9 @@ real_t Generic6DOFJointBullet::get_param(Vector3::Axis p_axis, PhysicsServer::G6
case PhysicsServer::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT:
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_maxMotorForce;
default:
- WARN_PRINT("This parameter is not supported");
- return 0.;
+ ERR_EXPLAIN("This parameter " + itos(p_param) + " is deprecated");
+ WARN_DEPRECATED;
+ return 0;
}
}
@@ -213,8 +216,9 @@ void Generic6DOFJointBullet::set_flag(Vector3::Axis p_axis, PhysicsServer::G6DOF
sixDOFConstraint->getTranslationalLimitMotor()->m_enableMotor[p_axis] = flags[p_axis][p_flag];
break;
default:
- WARN_PRINT("This flag is not supported by Bullet engine");
- return;
+ ERR_EXPLAIN("This flag " + itos(p_flag) + " is deprecated");
+ WARN_DEPRECATED
+ break;
}
}
diff --git a/modules/bullet/godot_result_callbacks.cpp b/modules/bullet/godot_result_callbacks.cpp
index 534034d707..08d8b8c6f6 100644
--- a/modules/bullet/godot_result_callbacks.cpp
+++ b/modules/bullet/godot_result_callbacks.cpp
@@ -34,11 +34,19 @@
#include "bullet_types_converter.h"
#include "collision_object_bullet.h"
#include "rigid_body_bullet.h"
+#include <BulletCollision/CollisionDispatch/btInternalEdgeUtility.h>
/**
@author AndreaCatania
*/
+bool godotContactAddedCallback(btManifoldPoint &cp, const btCollisionObjectWrapper *colObj0Wrap, int partId0, int index0, const btCollisionObjectWrapper *colObj1Wrap, int partId1, int index1) {
+ if (!colObj1Wrap->getCollisionObject()->getCollisionShape()->isCompound()) {
+ btAdjustInternalEdgeContacts(cp, colObj1Wrap, colObj0Wrap, partId1, index1);
+ }
+ return true;
+}
+
bool GodotFilterCallback::test_collision_filters(uint32_t body0_collision_layer, uint32_t body0_collision_mask, uint32_t body1_collision_layer, uint32_t body1_collision_mask) {
return body0_collision_layer & body1_collision_mask || body1_collision_layer & body0_collision_mask;
}
diff --git a/modules/bullet/godot_result_callbacks.h b/modules/bullet/godot_result_callbacks.h
index 3948f43c00..8e70b72841 100644
--- a/modules/bullet/godot_result_callbacks.h
+++ b/modules/bullet/godot_result_callbacks.h
@@ -42,6 +42,9 @@
class RigidBodyBullet;
+/// This callback is injected inside bullet server and allow me to smooth contacts against trimesh
+bool godotContactAddedCallback(btManifoldPoint &cp, const btCollisionObjectWrapper *colObj0Wrap, int partId0, int index0, const btCollisionObjectWrapper *colObj1Wrap, int partId1, int index1);
+
/// This class is required to implement custom collision behaviour in the broadphase
struct GodotFilterCallback : public btOverlapFilterCallback {
static bool test_collision_filters(uint32_t body0_collision_layer, uint32_t body0_collision_mask, uint32_t body1_collision_layer, uint32_t body1_collision_mask);
@@ -71,7 +74,10 @@ public:
virtual bool needsCollision(btBroadphaseProxy *proxy0) const;
virtual btScalar addSingleResult(btCollisionWorld::LocalRayResult &rayResult, bool normalInWorldSpace) {
- m_shapeId = rayResult.m_localShapeInfo->m_triangleIndex; // "m_triangleIndex" Is a odd name but contains the compound shape ID
+ if (rayResult.m_localShapeInfo)
+ m_shapeId = rayResult.m_localShapeInfo->m_triangleIndex; // "m_triangleIndex" Is a odd name but contains the compound shape ID
+ else
+ m_shapeId = 0;
return btCollisionWorld::ClosestRayResultCallback::addSingleResult(rayResult, normalInWorldSpace);
}
};
diff --git a/modules/bullet/hinge_joint_bullet.cpp b/modules/bullet/hinge_joint_bullet.cpp
index 07fde6efb9..86c6a632cd 100644
--- a/modules/bullet/hinge_joint_bullet.cpp
+++ b/modules/bullet/hinge_joint_bullet.cpp
@@ -95,11 +95,6 @@ real_t HingeJointBullet::get_hinge_angle() {
void HingeJointBullet::set_param(PhysicsServer::HingeJointParam p_param, real_t p_value) {
switch (p_param) {
- case PhysicsServer::HINGE_JOINT_BIAS:
- if (0 < p_value) {
- WARN_PRINTS("HingeJoint doesn't support bias in the Bullet backend, so it's always 0.");
- }
- break;
case PhysicsServer::HINGE_JOINT_LIMIT_UPPER:
hingeConstraint->setLimit(hingeConstraint->getLowerLimit(), p_value, hingeConstraint->getLimitSoftness(), hingeConstraint->getLimitBiasFactor(), hingeConstraint->getLimitRelaxationFactor());
break;
@@ -122,7 +117,9 @@ void HingeJointBullet::set_param(PhysicsServer::HingeJointParam p_param, real_t
hingeConstraint->setMaxMotorImpulse(p_value);
break;
default:
- WARN_PRINTS("HingeJoint doesn't support this parameter in the Bullet backend: " + itos(p_param) + ", value: " + itos(p_value));
+ ERR_EXPLAIN("This parameter " + itos(p_param) + " is deprecated");
+ WARN_DEPRECATED
+ break;
}
}
@@ -146,7 +143,8 @@ real_t HingeJointBullet::get_param(PhysicsServer::HingeJointParam p_param) const
case PhysicsServer::HINGE_JOINT_MOTOR_MAX_IMPULSE:
return hingeConstraint->getMaxMotorImpulse();
default:
- WARN_PRINTS("HingeJoint doesn't support this parameter in the Bullet backend: " + itos(p_param));
+ ERR_EXPLAIN("This parameter " + itos(p_param) + " is deprecated");
+ WARN_DEPRECATED;
return 0;
}
}
diff --git a/modules/bullet/pin_joint_bullet.cpp b/modules/bullet/pin_joint_bullet.cpp
index c4e5b8cdbe..183a7e75b9 100644
--- a/modules/bullet/pin_joint_bullet.cpp
+++ b/modules/bullet/pin_joint_bullet.cpp
@@ -85,7 +85,8 @@ real_t PinJointBullet::get_param(PhysicsServer::PinJointParam p_param) const {
case PhysicsServer::PIN_JOINT_IMPULSE_CLAMP:
return p2pConstraint->m_setting.m_impulseClamp;
default:
- WARN_PRINTS("This get parameter is not supported");
+ ERR_EXPLAIN("This parameter " + itos(p_param) + " is deprecated");
+ WARN_DEPRECATED
return 0;
}
}
diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp
index 9c0e802be5..2d0e74eb6f 100644
--- a/modules/bullet/rigid_body_bullet.cpp
+++ b/modules/bullet/rigid_body_bullet.cpp
@@ -279,7 +279,7 @@ RigidBodyBullet::RigidBodyBullet() :
// Initial properties
const btVector3 localInertia(0, 0, 0);
- btRigidBody::btRigidBodyConstructionInfo cInfo(mass, godotMotionState, compoundShape, localInertia);
+ btRigidBody::btRigidBodyConstructionInfo cInfo(mass, godotMotionState, BulletPhysicsServer::get_empty_shape(), localInertia);
btBody = bulletnew(btRigidBody(cInfo));
setupBulletCollisionObject(btBody);
@@ -314,10 +314,19 @@ void RigidBodyBullet::destroy_kinematic_utilities() {
}
}
+void RigidBodyBullet::main_shape_resetted() {
+ if (get_main_shape())
+ btBody->setCollisionShape(get_main_shape());
+ else
+ btBody->setCollisionShape(BulletPhysicsServer::get_empty_shape());
+ set_continuous_collision_detection(is_continuous_collision_detection_enabled()); // Reset
+}
+
void RigidBodyBullet::reload_body() {
if (space) {
space->remove_rigid_body(this);
- space->add_rigid_body(this);
+ if (get_main_shape())
+ space->add_rigid_body(this);
}
}
@@ -711,15 +720,19 @@ void RigidBodyBullet::set_continuous_collision_detection(bool p_enable) {
if (p_enable) {
// This threshold enable CCD if the object moves more than
// 1 meter in one simulation frame
- btBody->setCcdMotionThreshold(1);
+ btBody->setCcdMotionThreshold(0.1);
/// Calculate using the rule writte below the CCD swept sphere radius
/// CCD works on an embedded sphere of radius, make sure this radius
/// is embedded inside the convex objects, preferably smaller:
/// for an object of dimensions 1 meter, try 0.2
- btVector3 center;
btScalar radius;
- btBody->getCollisionShape()->getBoundingSphere(center, radius);
+ if (btBody->getCollisionShape()) {
+ btVector3 center;
+ btBody->getCollisionShape()->getBoundingSphere(center, radius);
+ } else {
+ radius = 0;
+ }
btBody->setCcdSweptSphereRadius(radius * 0.2);
} else {
btBody->setCcdMotionThreshold(0.);
@@ -728,7 +741,7 @@ void RigidBodyBullet::set_continuous_collision_detection(bool p_enable) {
}
bool RigidBodyBullet::is_continuous_collision_detection_enabled() const {
- return 0. != btBody->getCcdMotionThreshold();
+ return 0. < btBody->getCcdMotionThreshold();
}
void RigidBodyBullet::set_linear_velocity(const Vector3 &p_velocity) {
@@ -783,9 +796,11 @@ void RigidBodyBullet::on_shapes_changed() {
const btScalar invMass = btBody->getInvMass();
const btScalar mass = invMass == 0 ? 0 : 1 / invMass;
- btVector3 inertia;
- btBody->getCollisionShape()->calculateLocalInertia(mass, inertia);
- btBody->setMassProps(mass, inertia);
+ if (mainShape) {
+ btVector3 inertia;
+ mainShape->calculateLocalInertia(mass, inertia);
+ btBody->setMassProps(mass, inertia);
+ }
btBody->updateInertiaTensor();
reload_kinematic_shapes();
@@ -986,7 +1001,8 @@ void RigidBodyBullet::_internal_set_mass(real_t p_mass) {
return;
m_isStatic = false;
- compoundShape->calculateLocalInertia(p_mass, localInertia);
+ if (mainShape)
+ mainShape->calculateLocalInertia(p_mass, localInertia);
if (PhysicsServer::BODY_MODE_RIGID == mode) {
diff --git a/modules/bullet/rigid_body_bullet.h b/modules/bullet/rigid_body_bullet.h
index f03009bce9..cd2f215906 100644
--- a/modules/bullet/rigid_body_bullet.h
+++ b/modules/bullet/rigid_body_bullet.h
@@ -231,6 +231,7 @@ public:
_FORCE_INLINE_ btRigidBody *get_bt_rigid_body() { return btBody; }
+ virtual void main_shape_resetted();
virtual void reload_body();
virtual void set_space(SpaceBullet *p_space);
diff --git a/modules/bullet/shape_bullet.cpp b/modules/bullet/shape_bullet.cpp
index fab8d0cf3d..4a2263407c 100644
--- a/modules/bullet/shape_bullet.cpp
+++ b/modules/bullet/shape_bullet.cpp
@@ -36,6 +36,7 @@
#include "bullet_utilities.h"
#include "shape_owner_bullet.h"
+#include <BulletCollision/CollisionDispatch/btInternalEdgeUtility.h>
#include <BulletCollision/CollisionShapes/btConvexPointCloudShape.h>
#include <BulletCollision/CollisionShapes/btHeightfieldTerrainShape.h>
#include <btBulletCollisionCommon.h>
@@ -340,6 +341,9 @@ void ConvexPolygonShapeBullet::setup(const Vector<Vector3> &p_vertices) {
}
btCollisionShape *ConvexPolygonShapeBullet::create_bt_shape(const btVector3 &p_implicit_scale, real_t p_extra_edge) {
+ if (!vertices.size())
+ // This is necessary since 0 vertices
+ return prepare(ShapeBullet::create_shape_empty());
btCollisionShape *cs(ShapeBullet::create_shape_convex(vertices));
cs->setLocalScaling(p_implicit_scale);
prepare(cs);
@@ -355,7 +359,8 @@ ConcavePolygonShapeBullet::ConcavePolygonShapeBullet() :
ConcavePolygonShapeBullet::~ConcavePolygonShapeBullet() {
if (meshShape) {
delete meshShape->getMeshInterface();
- delete meshShape;
+ delete meshShape->getTriangleInfoMap();
+ bulletdelete(meshShape);
}
faces = PoolVector<Vector3>();
}
@@ -377,6 +382,7 @@ void ConcavePolygonShapeBullet::setup(PoolVector<Vector3> p_faces) {
if (meshShape) {
/// Clear previous created shape
delete meshShape->getMeshInterface();
+ delete meshShape->getTriangleInfoMap();
bulletdelete(meshShape);
}
int src_face_count = faces.size();
@@ -404,6 +410,8 @@ void ConcavePolygonShapeBullet::setup(PoolVector<Vector3> p_faces) {
const bool useQuantizedAabbCompression = true;
meshShape = bulletnew(btBvhTriangleMeshShape(shapeInterface, useQuantizedAabbCompression));
+ btTriangleInfoMap *triangleInfoMap = new btTriangleInfoMap();
+ btGenerateInternalEdgeInfo(meshShape, triangleInfoMap);
} else {
meshShape = NULL;
ERR_PRINT("The faces count are 0, the mesh shape cannot be created");
diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp
index b5329bc347..6d00b3d1d8 100644
--- a/modules/bullet/space_bullet.cpp
+++ b/modules/bullet/space_bullet.cpp
@@ -178,7 +178,9 @@ bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transf
space->dynamicsWorld->convexSweepTest(bt_convex_shape, bt_xform_from, bt_xform_to, btResult, 0.002);
if (btResult.hasHit()) {
- p_closest_safe = p_closest_unsafe = btResult.m_closestHitFraction;
+ const btScalar l = bt_motion.length();
+ p_closest_unsafe = btResult.m_closestHitFraction;
+ p_closest_safe = MAX(p_closest_unsafe - (1 - ((l - 0.01) / l)), 0);
if (r_info) {
if (btCollisionObject::CO_RIGID_BODY == btResult.m_hitCollisionObject->getInternalType()) {
B_TO_G(static_cast<const btRigidBody *>(btResult.m_hitCollisionObject)->getVelocityInLocalPoint(btResult.m_hitPointWorld), r_info->linear_velocity);
@@ -293,11 +295,10 @@ Vector3 BulletPhysicsDirectSpaceState::get_closest_point_to_object_volume(RID p_
bool shapes_found = false;
- btCompoundShape *compound = rigid_object->get_compound_shape();
- for (int i = compound->getNumChildShapes() - 1; 0 <= i; --i) {
- shape = compound->getChildShape(i);
+ for (int i = rigid_object->get_shape_count() - 1; 0 <= i; --i) {
+ shape = rigid_object->get_bt_shape(i);
if (shape->isConvex()) {
- child_transform = compound->getChildTransform(i);
+ child_transform = rigid_object->get_bt_shape_transform(i);
convex_shape = static_cast<btConvexShape *>(shape);
input.m_transformB = body_transform * child_transform;
@@ -596,6 +597,7 @@ void SpaceBullet::create_empty_world(bool p_create_soft_world) {
godotFilterCallback = bulletnew(GodotFilterCallback);
gCalculateCombinedRestitutionCallback = &calculateGodotCombinedRestitution;
gCalculateCombinedFrictionCallback = &calculateGodotCombinedFriction;
+ gContactAddedCallback = &godotContactAddedCallback;
dynamicsWorld->setWorldUserInfo(this);
@@ -640,7 +642,7 @@ void SpaceBullet::destroy_world() {
void SpaceBullet::check_ghost_overlaps() {
/// Algorithm support variables
- btConvexShape *other_body_shape;
+ btCollisionShape *other_body_shape;
btConvexShape *area_shape;
btGjkPairDetector::ClosestPointInput gjk_input;
AreaBullet *area;
@@ -682,30 +684,52 @@ void SpaceBullet::check_ghost_overlaps() {
bool hasOverlap = false;
// For each area shape
- for (y = area->get_compound_shape()->getNumChildShapes() - 1; 0 <= y; --y) {
- if (!area->get_compound_shape()->getChildShape(y)->isConvex())
+ for (y = area->get_shape_count() - 1; 0 <= y; --y) {
+ if (!area->get_bt_shape(y)->isConvex())
continue;
- gjk_input.m_transformA = area->get_transform__bullet() * area->get_compound_shape()->getChildTransform(y);
- area_shape = static_cast<btConvexShape *>(area->get_compound_shape()->getChildShape(y));
+ gjk_input.m_transformA = area->get_transform__bullet() * area->get_bt_shape_transform(y);
+ area_shape = static_cast<btConvexShape *>(area->get_bt_shape(y));
// For each other object shape
- for (z = otherObject->get_compound_shape()->getNumChildShapes() - 1; 0 <= z; --z) {
+ for (z = otherObject->get_shape_count() - 1; 0 <= z; --z) {
- if (!otherObject->get_compound_shape()->getChildShape(z)->isConvex())
- continue;
+ other_body_shape = static_cast<btCollisionShape *>(otherObject->get_bt_shape(z));
+ gjk_input.m_transformB = otherObject->get_transform__bullet() * otherObject->get_bt_shape_transform(z);
- other_body_shape = static_cast<btConvexShape *>(otherObject->get_compound_shape()->getChildShape(z));
- gjk_input.m_transformB = otherObject->get_transform__bullet() * otherObject->get_compound_shape()->getChildTransform(z);
+ if (other_body_shape->isConvex()) {
- btPointCollector result;
- btGjkPairDetector gjk_pair_detector(area_shape, other_body_shape, gjk_simplex_solver, gjk_epa_pen_solver);
- gjk_pair_detector.getClosestPoints(gjk_input, result, 0);
+ btPointCollector result;
+ btGjkPairDetector gjk_pair_detector(area_shape, static_cast<btConvexShape *>(other_body_shape), gjk_simplex_solver, gjk_epa_pen_solver);
+ gjk_pair_detector.getClosestPoints(gjk_input, result, 0);
- if (0 >= result.m_distance) {
- hasOverlap = true;
- goto collision_found;
+ if (0 >= result.m_distance) {
+ hasOverlap = true;
+ goto collision_found;
+ }
+
+ } else {
+
+ btCollisionObjectWrapper obA(NULL, area_shape, area->get_bt_ghost(), gjk_input.m_transformA, -1, y);
+ btCollisionObjectWrapper obB(NULL, other_body_shape, otherObject->get_bt_collision_object(), gjk_input.m_transformB, -1, z);
+
+ btCollisionAlgorithm *algorithm = dispatcher->findAlgorithm(&obA, &obB, NULL, BT_CONTACT_POINT_ALGORITHMS);
+
+ if (!algorithm)
+ continue;
+
+ GodotDeepPenetrationContactResultCallback contactPointResult(&obA, &obB);
+ algorithm->processCollision(&obA, &obB, dynamicsWorld->getDispatchInfo(), &contactPointResult);
+
+ algorithm->~btCollisionAlgorithm();
+ dispatcher->freeCollisionAlgorithm(algorithm);
+
+ if (contactPointResult.hasHit()) {
+ hasOverlap = true;
+ goto collision_found;
+ }
}
+
} // ~For each other object shape
} // ~For each area shape
@@ -978,7 +1002,7 @@ int SpaceBullet::test_ray_separation(RigidBodyBullet *p_body, const Transform &p
btVector3 recover_motion(0, 0, 0);
- int rays_found;
+ int rays_found = 0;
for (int t(RECOVERING_MOVEMENT_CYCLES); 0 < t; --t) {
int last_ray_index = recover_from_penetration_ray(p_body, body_transform, RECOVERING_MOVEMENT_SCALE, p_infinite_inertia, p_result_max, recover_motion, r_results);
diff --git a/modules/bullet/space_bullet.h b/modules/bullet/space_bullet.h
index 517ec67ffa..0649e1f7e3 100644
--- a/modules/bullet/space_bullet.h
+++ b/modules/bullet/space_bullet.h
@@ -65,6 +65,8 @@ class SpaceBullet;
class SoftBodyBullet;
class btGjkEpaPenetrationDepthSolver;
+extern ContactAddedCallback gContactAddedCallback;
+
class BulletPhysicsDirectSpaceState : public PhysicsDirectSpaceState {
GDCLASS(BulletPhysicsDirectSpaceState, PhysicsDirectSpaceState)
private:
diff --git a/modules/csg/csg_gizmos.cpp b/modules/csg/csg_gizmos.cpp
index f9744c72af..07c33ed670 100644
--- a/modules/csg/csg_gizmos.cpp
+++ b/modules/csg/csg_gizmos.cpp
@@ -139,9 +139,9 @@ void CSGShapeSpatialGizmoPlugin::set_handle(EditorSpatialGizmo *p_gizmo, int p_i
d = 0.001;
switch (p_idx) {
- case 0: s->set_width(d); break;
- case 1: s->set_height(d); break;
- case 2: s->set_depth(d); break;
+ case 0: s->set_width(d * 2); break;
+ case 1: s->set_height(d * 2); break;
+ case 2: s->set_depth(d * 2); break;
}
}
@@ -329,9 +329,9 @@ void CSGShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) {
CSGBox *s = Object::cast_to<CSGBox>(cs);
Vector<Vector3> handles;
- handles.push_back(Vector3(s->get_width(), 0, 0));
- handles.push_back(Vector3(0, s->get_height(), 0));
- handles.push_back(Vector3(0, 0, s->get_depth()));
+ handles.push_back(Vector3(s->get_width() * 0.5, 0, 0));
+ handles.push_back(Vector3(0, s->get_height() * 0.5, 0));
+ handles.push_back(Vector3(0, 0, s->get_depth() * 0.5));
p_gizmo->add_handles(handles, handles_material);
}
diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp
index 258c628d93..714be16db7 100644
--- a/modules/csg/csg_shape.cpp
+++ b/modules/csg/csg_shape.cpp
@@ -917,7 +917,7 @@ CSGBrush *CSGBox::_build_brush() {
int face = 0;
- Vector3 vertex_mul(width, height, depth);
+ Vector3 vertex_mul(width * 0.5, height * 0.5, depth * 0.5);
{
@@ -1051,9 +1051,9 @@ Ref<Material> CSGBox::get_material() const {
CSGBox::CSGBox() {
// defaults
- width = 1.0;
- height = 1.0;
- depth = 1.0;
+ width = 2.0;
+ height = 2.0;
+ depth = 2.0;
}
///////////////
diff --git a/modules/cvtt/image_compress_cvtt.cpp b/modules/cvtt/image_compress_cvtt.cpp
index 3a371c8597..af92861352 100644
--- a/modules/cvtt/image_compress_cvtt.cpp
+++ b/modules/cvtt/image_compress_cvtt.cpp
@@ -247,8 +247,8 @@ void image_compress_cvtt(Image *p_image, float p_lossy_quality, Image::CompressS
}
dst_ofs += (MAX(4, bw) * MAX(4, bh)) >> shift;
- w >>= 1;
- h >>= 1;
+ w = MAX(w / 2, 1);
+ h = MAX(h / 2, 1);
}
if (num_job_threads > 0) {
diff --git a/modules/gdnative/gdnative/basis.cpp b/modules/gdnative/gdnative/basis.cpp
index 372bdf3fb1..70d2814577 100644
--- a/modules/gdnative/gdnative/basis.cpp
+++ b/modules/gdnative/gdnative/basis.cpp
@@ -113,6 +113,40 @@ godot_vector3 GDAPI godot_basis_get_scale(const godot_basis *p_self) {
return dest;
}
+godot_quat GDAPI godot_basis_get_quat(const godot_basis *p_self) {
+ godot_quat dest;
+ const Basis *self = (const Basis *)p_self;
+ *((Quat *)&dest) = self->get_quat();
+ return dest;
+}
+
+void GDAPI godot_basis_set_quat(godot_basis *p_self, const godot_quat *p_quat) {
+ Basis *self = (Basis *)p_self;
+ const Quat *quat = (const Quat *)p_quat;
+ self->set_quat(*quat);
+}
+
+void GDAPI godot_basis_set_axis_angle_scale(godot_basis *p_self, const godot_vector3 *p_axis, godot_real p_phi, const godot_vector3 *p_scale) {
+ Basis *self = (Basis *)p_self;
+ const Vector3 *axis = (const Vector3 *)p_axis;
+ const Vector3 *scale = (const Vector3 *)p_scale;
+ self->set_axis_angle_scale(*axis, p_phi, *scale);
+}
+
+void GDAPI godot_basis_set_euler_scale(godot_basis *p_self, const godot_vector3 *p_euler, const godot_vector3 *p_scale) {
+ Basis *self = (Basis *)p_self;
+ const Vector3 *euler = (const Vector3 *)p_euler;
+ const Vector3 *scale = (const Vector3 *)p_scale;
+ self->set_euler_scale(*euler, *scale);
+}
+
+void GDAPI godot_basis_set_quat_scale(godot_basis *p_self, const godot_quat *p_quat, const godot_vector3 *p_scale) {
+ Basis *self = (Basis *)p_self;
+ const Quat *quat = (const Quat *)p_quat;
+ const Vector3 *scale = (const Vector3 *)p_scale;
+ self->set_quat_scale(*quat, *scale);
+}
+
godot_vector3 GDAPI godot_basis_get_euler(const godot_basis *p_self) {
godot_vector3 dest;
const Basis *self = (const Basis *)p_self;
diff --git a/modules/gdnative/gdnative/dictionary.cpp b/modules/gdnative/gdnative/dictionary.cpp
index 786e614158..34cc91129e 100644
--- a/modules/gdnative/gdnative/dictionary.cpp
+++ b/modules/gdnative/gdnative/dictionary.cpp
@@ -155,6 +155,12 @@ godot_string GDAPI godot_dictionary_to_json(const godot_dictionary *p_self) {
return raw_dest;
}
+godot_bool GDAPI godot_dictionary_erase_with_return(godot_dictionary *p_self, const godot_variant *p_key) {
+ Dictionary *self = (Dictionary *)p_self;
+ const Variant *key = (const Variant *)p_key;
+ return self->erase(*key);
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/modules/gdnative/gdnative/gdnative.cpp b/modules/gdnative/gdnative/gdnative.cpp
index 041990e137..73fca655a8 100644
--- a/modules/gdnative/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative/gdnative.cpp
@@ -166,6 +166,10 @@ void _gdnative_report_loading_error(const godot_object *p_library, const char *p
_err_print_error("gdnative_init", library->get_current_library_path().utf8().ptr(), 0, message.utf8().ptr());
}
+bool GDAPI godot_is_instance_valid(const godot_object *p_object) {
+ return ObjectDB::instance_validate((Object *)p_object);
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/modules/gdnative/gdnative/quat.cpp b/modules/gdnative/gdnative/quat.cpp
index 56ff7fe3a8..ddec77edcd 100644
--- a/modules/gdnative/gdnative/quat.cpp
+++ b/modules/gdnative/gdnative/quat.cpp
@@ -49,6 +49,18 @@ void GDAPI godot_quat_new_with_axis_angle(godot_quat *r_dest, const godot_vector
*dest = Quat(*axis, p_angle);
}
+void GDAPI godot_quat_new_with_basis(godot_quat *r_dest, const godot_basis *p_basis) {
+ const Basis *basis = (const Basis *)p_basis;
+ Quat *dest = (Quat *)r_dest;
+ *dest = Quat(*basis);
+}
+
+void GDAPI godot_quat_new_with_euler(godot_quat *r_dest, const godot_vector3 *p_euler) {
+ const Vector3 *euler = (const Vector3 *)p_euler;
+ Quat *dest = (Quat *)r_dest;
+ *dest = Quat(*euler);
+}
+
godot_real GDAPI godot_quat_get_x(const godot_quat *p_self) {
const Quat *self = (const Quat *)p_self;
return self->x;
diff --git a/modules/gdnative/gdnative/transform.cpp b/modules/gdnative/gdnative/transform.cpp
index 715f2e3c08..ee6140c7d0 100644
--- a/modules/gdnative/gdnative/transform.cpp
+++ b/modules/gdnative/gdnative/transform.cpp
@@ -56,6 +56,12 @@ void GDAPI godot_transform_new(godot_transform *r_dest, const godot_basis *p_bas
*dest = Transform(*basis, *origin);
}
+void GDAPI godot_transform_new_with_quat(godot_transform *r_dest, const godot_quat *p_quat) {
+ const Quat *quat = (const Quat *)p_quat;
+ Transform *dest = (Transform *)r_dest;
+ *dest = Transform(*quat);
+}
+
godot_basis GDAPI godot_transform_get_basis(const godot_transform *p_self) {
godot_basis dest;
const Transform *self = (const Transform *)p_self;
diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json
index e326d11a84..dce3d7e96b 100644
--- a/modules/gdnative/gdnative_api.json
+++ b/modules/gdnative/gdnative_api.json
@@ -5,7 +5,98 @@
"major": 1,
"minor": 0
},
- "next": null,
+ "next": {
+ "type": "CORE",
+ "version": {
+ "major": 1,
+ "minor": 1
+ },
+ "next": null,
+ "api": [
+ {
+ "name": "godot_basis_get_quat",
+ "return_type": "godot_quat",
+ "arguments": [
+ ["const godot_basis *", "p_self"]
+ ]
+ },
+ {
+ "name": "godot_basis_set_quat",
+ "return_type": "void",
+ "arguments": [
+ ["godot_basis *", "p_self"],
+ ["const godot_quat *", "p_quat"]
+ ]
+ },
+ {
+ "name": "godot_basis_set_axis_angle_scale",
+ "return_type": "void",
+ "arguments": [
+ ["godot_basis *", "p_self"],
+ ["const godot_vector3 *", "p_axis"],
+ ["godot_real", "p_phi"],
+ ["const godot_vector3 *", "p_scale"]
+ ]
+ },
+ {
+ "name": "godot_basis_set_euler_scale",
+ "return_type": "void",
+ "arguments": [
+ ["godot_basis *", "p_self"],
+ ["const godot_vector3 *", "p_euler"],
+ ["const godot_vector3 *", "p_scale"]
+ ]
+ },
+ {
+ "name": "godot_basis_set_quat_scale",
+ "return_type": "void",
+ "arguments": [
+ ["godot_basis *", "p_self"],
+ ["const godot_quat *", "p_quat"],
+ ["const godot_vector3 *", "p_scale"]
+ ]
+ },
+ {
+ "name": "godot_dictionary_erase_with_return",
+ "return_type": "bool",
+ "arguments": [
+ ["godot_dictionary *", "p_self"],
+ ["const godot_variant *", "p_key"]
+ ]
+ },
+ {
+ "name": "godot_is_instance_valid",
+ "return_type": "bool",
+ "arguments": [
+ ["const godot_object *", "p_object"]
+ ]
+ },
+ {
+ "name": "godot_quat_new_with_basis",
+ "return_type": "void",
+ "arguments": [
+ ["godot_quat *", "r_dest"],
+ ["const godot_basis *", "p_basis"]
+ ]
+ },
+ {
+ "name": "godot_quat_new_with_euler",
+ "return_type": "void",
+ "arguments": [
+ ["godot_quat *", "r_dest"],
+ ["const godot_vector3 *", "p_euler"]
+ ]
+ },
+ {
+ "name": "godot_transform_new_with_quat",
+ "return_type": "void",
+ "arguments": [
+ ["godot_transform *", "r_dest"],
+ ["const godot_quat *", "p_quat"]
+ ]
+ }
+ ]
+ },
"api": [
{
"name": "godot_color_new_rgba",
@@ -4484,7 +4575,7 @@
]
},
{
- "name": "godot_string_wide_str",
+ "name": "godot_string_wide_str",
"return_type": "const wchar_t *",
"arguments": [
["const godot_string *", "p_self"]
@@ -5253,21 +5344,21 @@
"name": "godot_string_ascii",
"return_type": "godot_char_string",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_string *", "p_self"]
]
},
{
"name": "godot_string_ascii_extended",
"return_type": "godot_char_string",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_string *", "p_self"]
]
},
{
"name": "godot_string_utf8",
"return_type": "godot_char_string",
"arguments": [
- ["const godot_string *", "p_self"]
+ ["const godot_string *", "p_self"]
]
},
{
@@ -5765,15 +5856,15 @@
"minor": 0
},
"next": {
- "type": "NATIVESCRIPT",
- "version": {
- "major": 1,
- "minor": 1
- },
- "next": null,
- "api": [
+ "type": "NATIVESCRIPT",
+ "version": {
+ "major": 1,
+ "minor": 1
+ },
+ "next": null,
+ "api": [
{
- "name": "godot_nativescript_set_method_argument_information",
+ "name": "godot_nativescript_set_method_argument_information",
"return_type": "void",
"arguments": [
["void *", "p_gdnative_handle"],
@@ -5784,7 +5875,7 @@
]
},
{
- "name": "godot_nativescript_set_class_documentation",
+ "name": "godot_nativescript_set_class_documentation",
"return_type": "void",
"arguments": [
["void *", "p_gdnative_handle"],
@@ -5793,7 +5884,7 @@
]
},
{
- "name": "godot_nativescript_set_method_documentation",
+ "name": "godot_nativescript_set_method_documentation",
"return_type": "void",
"arguments": [
["void *", "p_gdnative_handle"],
@@ -5803,7 +5894,7 @@
]
},
{
- "name": "godot_nativescript_set_property_documentation",
+ "name": "godot_nativescript_set_property_documentation",
"return_type": "void",
"arguments": [
["void *", "p_gdnative_handle"],
@@ -5813,7 +5904,7 @@
]
},
{
- "name": "godot_nativescript_set_signal_documentation",
+ "name": "godot_nativescript_set_signal_documentation",
"return_type": "void",
"arguments": [
["void *", "p_gdnative_handle"],
@@ -5874,7 +5965,7 @@
"return_type": "void *",
"arguments": [
["int", "p_idx"],
- ["godot_object *", "p_object"]
+ ["godot_object *", "p_object"]
]
},
{
@@ -5885,7 +5976,7 @@
["uint64_t", "p_line"]
]
}
- ]
+ ]
},
"api": [
{
diff --git a/modules/gdnative/gdnative_builders.py b/modules/gdnative/gdnative_builders.py
index 8a1cd049af..f9d1ed9dc5 100644
--- a/modules/gdnative/gdnative_builders.py
+++ b/modules/gdnative/gdnative_builders.py
@@ -82,10 +82,35 @@ def _build_gdnative_api_struct_header(api):
return ret_val
+
+ def generate_core_extension_struct(core):
+ ret_val = []
+ if core['next']:
+ ret_val += generate_core_extension_struct(core['next'])
+
+ ret_val += [
+ 'typedef struct godot_gdnative_core_' + ('{0}_{1}'.format(core['version']['major'], core['version']['minor'])) + '_api_struct {',
+ '\tunsigned int type;',
+ '\tgodot_gdnative_api_version version;',
+ '\tconst godot_gdnative_api_struct *next;',
+ ]
+
+ for funcdef in core['api']:
+ args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']])
+ ret_val.append('\t%s(*%s)(%s);' % (_spaced(funcdef['return_type']), funcdef['name'], args))
+
+ ret_val += ['} godot_gdnative_core_' + '{0}_{1}'.format(core['version']['major'], core['version']['minor']) + '_api_struct;', '']
+
+ return ret_val
+
+
for ext in api['extensions']:
name = ext['name']
out += generate_extension_struct(name, ext, False)
+ if api['core']['next']:
+ out += generate_core_extension_struct(api['core']['next'])
+
out += [
'typedef struct godot_gdnative_core_api_struct {',
'\tunsigned int type;',
@@ -146,6 +171,27 @@ def _build_gdnative_api_struct_source(api):
ret_val += ['};\n']
return ret_val
+
+
+ def get_core_struct_definition(core):
+ ret_val = []
+
+ if core['next']:
+ ret_val += get_core_struct_definition(core['next'])
+
+ ret_val += [
+ 'extern const godot_gdnative_core_' + ('{0}_{1}_api_struct api_{0}_{1}'.format(core['version']['major'], core['version']['minor'])) + ' = {',
+ '\tGDNATIVE_' + core['type'] + ',',
+ '\t{' + str(core['version']['major']) + ', ' + str(core['version']['minor']) + '},',
+ '\t' + ('NULL' if not core['next'] else ('(const godot_gdnative_api_struct *)& api_{0}_{1}'.format(core['version']['major'], core['version']['minor']))) + ','
+ ]
+
+ for funcdef in core['api']:
+ ret_val.append('\t%s,' % funcdef['name'])
+
+ ret_val += ['};\n']
+
+ return ret_val
for ext in api['extensions']:
name = ext['name']
@@ -158,6 +204,9 @@ def _build_gdnative_api_struct_source(api):
out += ['\t(godot_gdnative_api_struct *)&api_extension_' + name + '_struct,']
out += ['};\n']
+
+ if api['core']['next']:
+ out += get_core_struct_definition(api['core']['next'])
out += [
'extern const godot_gdnative_core_api_struct api_struct = {',
diff --git a/modules/gdnative/include/gdnative/basis.h b/modules/gdnative/include/gdnative/basis.h
index 53e950b4a2..ebe2b1125b 100644
--- a/modules/gdnative/include/gdnative/basis.h
+++ b/modules/gdnative/include/gdnative/basis.h
@@ -62,6 +62,7 @@ extern "C" {
void GDAPI godot_basis_new_with_rows(godot_basis *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis);
void GDAPI godot_basis_new_with_axis_and_angle(godot_basis *r_dest, const godot_vector3 *p_axis, const godot_real p_phi);
void GDAPI godot_basis_new_with_euler(godot_basis *r_dest, const godot_vector3 *p_euler);
+void GDAPI godot_basis_new_with_euler_quat(godot_basis *r_dest, const godot_quat *p_euler);
godot_string GDAPI godot_basis_as_string(const godot_basis *p_self);
@@ -81,6 +82,16 @@ godot_vector3 GDAPI godot_basis_get_scale(const godot_basis *p_self);
godot_vector3 GDAPI godot_basis_get_euler(const godot_basis *p_self);
+godot_quat GDAPI godot_basis_get_quat(const godot_basis *p_self);
+
+void GDAPI godot_basis_set_quat(godot_basis *p_self, const godot_quat *p_quat);
+
+void GDAPI godot_basis_set_axis_angle_scale(godot_basis *p_self, const godot_vector3 *p_axis, godot_real p_phi, const godot_vector3 *p_scale);
+
+void GDAPI godot_basis_set_euler_scale(godot_basis *p_self, const godot_vector3 *p_euler, const godot_vector3 *p_scale);
+
+void GDAPI godot_basis_set_quat_scale(godot_basis *p_self, const godot_quat *p_quat, const godot_vector3 *p_scale);
+
godot_real GDAPI godot_basis_tdotx(const godot_basis *p_self, const godot_vector3 *p_with);
godot_real GDAPI godot_basis_tdoty(const godot_basis *p_self, const godot_vector3 *p_with);
@@ -95,8 +106,6 @@ godot_int GDAPI godot_basis_get_orthogonal_index(const godot_basis *p_self);
void GDAPI godot_basis_new(godot_basis *r_dest);
-void GDAPI godot_basis_new_with_euler_quat(godot_basis *r_dest, const godot_quat *p_euler);
-
// p_elements is a pointer to an array of 3 (!!) vector3
void GDAPI godot_basis_get_elements(const godot_basis *p_self, godot_vector3 *p_elements);
diff --git a/modules/gdnative/include/gdnative/dictionary.h b/modules/gdnative/include/gdnative/dictionary.h
index a86d60dc72..faace818ee 100644
--- a/modules/gdnative/include/gdnative/dictionary.h
+++ b/modules/gdnative/include/gdnative/dictionary.h
@@ -94,6 +94,8 @@ godot_bool GDAPI godot_dictionary_operator_equal(const godot_dictionary *p_self,
godot_string GDAPI godot_dictionary_to_json(const godot_dictionary *p_self);
+godot_bool GDAPI godot_dictionary_erase_with_return(godot_dictionary *p_self, const godot_variant *p_key);
+
#ifdef __cplusplus
}
#endif
diff --git a/modules/gdnative/include/gdnative/gdnative.h b/modules/gdnative/include/gdnative/gdnative.h
index 4cf6e99b06..616c305f25 100644
--- a/modules/gdnative/include/gdnative/gdnative.h
+++ b/modules/gdnative/include/gdnative/gdnative.h
@@ -282,6 +282,10 @@ void GDAPI godot_print_error(const char *p_description, const char *p_function,
void GDAPI godot_print_warning(const char *p_description, const char *p_function, const char *p_file, int p_line);
void GDAPI godot_print(const godot_string *p_message);
+// GDNATIVE CORE 1.0.1
+
+bool GDAPI godot_is_instance_valid(const godot_object *p_object);
+
#ifdef __cplusplus
}
#endif
diff --git a/modules/gdnative/include/gdnative/quat.h b/modules/gdnative/include/gdnative/quat.h
index 4e86960aaf..b1290f745c 100644
--- a/modules/gdnative/include/gdnative/quat.h
+++ b/modules/gdnative/include/gdnative/quat.h
@@ -60,6 +60,8 @@ extern "C" {
void GDAPI godot_quat_new(godot_quat *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_z, const godot_real p_w);
void GDAPI godot_quat_new_with_axis_angle(godot_quat *r_dest, const godot_vector3 *p_axis, const godot_real p_angle);
+void GDAPI godot_quat_new_with_basis(godot_quat *r_dest, const godot_basis *p_basis);
+void GDAPI godot_quat_new_with_euler(godot_quat *r_dest, const godot_vector3 *p_euler);
godot_real GDAPI godot_quat_get_x(const godot_quat *p_self);
void GDAPI godot_quat_set_x(godot_quat *p_self, const godot_real val);
diff --git a/modules/gdnative/include/gdnative/transform.h b/modules/gdnative/include/gdnative/transform.h
index a646da146a..880f21c88a 100644
--- a/modules/gdnative/include/gdnative/transform.h
+++ b/modules/gdnative/include/gdnative/transform.h
@@ -62,6 +62,7 @@ extern "C" {
void GDAPI godot_transform_new_with_axis_origin(godot_transform *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis, const godot_vector3 *p_origin);
void GDAPI godot_transform_new(godot_transform *r_dest, const godot_basis *p_basis, const godot_vector3 *p_origin);
+void GDAPI godot_transform_new_with_quat(godot_transform *r_dest, const godot_quat *p_quat);
godot_basis GDAPI godot_transform_get_basis(const godot_transform *p_self);
void GDAPI godot_transform_set_basis(godot_transform *p_self, const godot_basis *p_v);
diff --git a/modules/gdnative/include/nativescript/godot_nativescript.h b/modules/gdnative/include/nativescript/godot_nativescript.h
index 29bd9eec5a..d6a729be47 100644
--- a/modules/gdnative/include/nativescript/godot_nativescript.h
+++ b/modules/gdnative/include/nativescript/godot_nativescript.h
@@ -229,6 +229,8 @@ const void GDAPI *godot_nativescript_get_type_tag(const godot_object *p_object);
typedef struct {
GDCALLINGCONV void *(*alloc_instance_binding_data)(void *, const void *, godot_object *);
GDCALLINGCONV void (*free_instance_binding_data)(void *, void *);
+ GDCALLINGCONV void (*refcount_incremented_instance_binding)(void *, godot_object *);
+ GDCALLINGCONV bool (*refcount_decremented_instance_binding)(void *, godot_object *);
void *data;
GDCALLINGCONV void (*free_func)(void *);
} godot_instance_binding_functions;
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp
index 608c7aa4a5..3f88fabebd 100644
--- a/modules/gdnative/nativescript/nativescript.cpp
+++ b/modules/gdnative/nativescript/nativescript.cpp
@@ -1370,6 +1370,54 @@ void NativeScriptLanguage::free_instance_binding_data(void *p_data) {
delete &binding_data;
}
+void NativeScriptLanguage::refcount_incremented_instance_binding(Object *p_object) {
+
+ void *data = p_object->get_script_instance_binding(lang_idx);
+
+ if (!data)
+ return;
+
+ Vector<void *> &binding_data = *(Vector<void *> *)data;
+
+ for (int i = 0; i < binding_data.size(); i++) {
+ if (!binding_data[i])
+ continue;
+
+ if (!binding_functions[i].first)
+ continue;
+
+ if (binding_functions[i].second.refcount_incremented_instance_binding) {
+ binding_functions[i].second.refcount_incremented_instance_binding(binding_data[i], p_object);
+ }
+ }
+}
+
+bool NativeScriptLanguage::refcount_decremented_instance_binding(Object *p_object) {
+
+ void *data = p_object->get_script_instance_binding(lang_idx);
+
+ if (!data)
+ return true;
+
+ Vector<void *> &binding_data = *(Vector<void *> *)data;
+
+ bool can_die = true;
+
+ for (int i = 0; i < binding_data.size(); i++) {
+ if (!binding_data[i])
+ continue;
+
+ if (!binding_functions[i].first)
+ continue;
+
+ if (binding_functions[i].second.refcount_decremented_instance_binding) {
+ can_die = can_die && binding_functions[i].second.refcount_decremented_instance_binding(binding_data[i], p_object);
+ }
+ }
+
+ return can_die;
+}
+
void NativeScriptLanguage::set_global_type_tag(int p_idx, StringName p_class_name, const void *p_type_tag) {
if (!global_type_tags.has(p_idx)) {
global_type_tags.insert(p_idx, HashMap<StringName, const void *>());
@@ -1537,12 +1585,16 @@ bool NativeScriptLanguage::handles_global_class_type(const String &p_type) const
String NativeScriptLanguage::get_global_class_name(const String &p_path, String *r_base_type, String *r_icon_path) const {
Ref<NativeScript> script = ResourceLoader::load(p_path, "NativeScript");
if (script.is_valid()) {
- *r_base_type = script->get_instance_base_type();
- *r_icon_path = script->get_script_class_icon_path();
+ if (r_base_type)
+ *r_base_type = script->get_instance_base_type();
+ if (r_icon_path)
+ *r_icon_path = script->get_script_class_icon_path();
return script->get_script_class_name();
}
- *r_base_type = String();
- *r_icon_path = String();
+ if (r_base_type)
+ *r_base_type = String();
+ if (r_icon_path)
+ *r_icon_path = String();
return String();
}
diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h
index 6f18e2db27..ebfe36fd94 100644
--- a/modules/gdnative/nativescript/nativescript.h
+++ b/modules/gdnative/nativescript/nativescript.h
@@ -353,6 +353,8 @@ public:
virtual void *alloc_instance_binding_data(Object *p_object);
virtual void free_instance_binding_data(void *p_data);
+ virtual void refcount_incremented_instance_binding(Object *p_object);
+ virtual bool refcount_decremented_instance_binding(Object *p_object);
void set_global_type_tag(int p_idx, StringName p_class_name, const void *p_type_tag);
const void *get_global_type_tag(int p_idx, StringName p_class_name) const;
diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp
index f2a1a5b50c..a1163b5d8d 100644
--- a/modules/gdscript/editor/gdscript_highlighter.cpp
+++ b/modules/gdscript/editor/gdscript_highlighter.cpp
@@ -121,8 +121,8 @@ Map<int, TextEdit::HighlighterInfo> GDScriptSyntaxHighlighter::_get_line_syntax_
is_hex_notation = false;
}
- // check for dot or underscore or 'x' for hex notation in floating point number
- if ((str[j] == '.' || str[j] == 'x' || str[j] == '_') && !in_word && prev_is_number && !is_number) {
+ // check for dot or underscore or 'x' for hex notation in floating point number or 'e' for scientific notation
+ if ((str[j] == '.' || str[j] == 'x' || str[j] == '_' || str[j] == 'e') && !in_word && prev_is_number && !is_number) {
is_number = true;
is_symbol = false;
is_char = false;
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index 3b494dbae7..006fbece53 100644
--- a/modules/gdscript/gdscript_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -1253,6 +1253,25 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
codegen.opcodes.push_back(src_address_b); // argument 2 (unary only takes one parameter)
} break;
+ case GDScriptParser::OperatorNode::OP_IS_BUILTIN: {
+ ERR_FAIL_COND_V(on->arguments.size() != 2, false);
+ ERR_FAIL_COND_V(on->arguments[1]->type != GDScriptParser::Node::TYPE_TYPE, false);
+
+ int slevel = p_stack_level;
+
+ int src_address_a = _parse_expression(codegen, on->arguments[0], slevel);
+ if (src_address_a < 0)
+ return -1;
+
+ if (src_address_a & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS)
+ slevel++; //uses stack for return, increase stack
+
+ const GDScriptParser::TypeNode *tn = static_cast<const GDScriptParser::TypeNode *>(on->arguments[1]);
+
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_IS_BUILTIN); // perform operator
+ codegen.opcodes.push_back(src_address_a); // argument 1
+ codegen.opcodes.push_back((int)tn->vtype); // argument 2 (unary only takes one parameter)
+ } break;
default: {
ERR_EXPLAIN("Bug in bytecode compiler, unexpected operator #" + itos(on->op) + " in parse tree while parsing expression.");
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 30400f01e9..d3068fb6d0 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -63,8 +63,8 @@ Ref<Script> GDScriptLanguage::get_template(const String &p_class_name, const Str
String _template = "extends %BASE%\n"
"\n"
"# Declare member variables here. Examples:\n"
- "# var a %INT_TYPE%= 2\n"
- "# var b %STRING_TYPE%= \"text\"\n"
+ "# var a%INT_TYPE% = 2\n"
+ "# var b%STRING_TYPE% = \"text\"\n"
"\n"
"# Called when the node enters the scene tree for the first time.\n"
"func _ready()%VOID_RETURN%:\n"
@@ -76,9 +76,9 @@ Ref<Script> GDScriptLanguage::get_template(const String &p_class_name, const Str
#ifdef TOOLS_ENABLED
if (EDITOR_DEF("text_editor/completion/add_type_hints", false)) {
- _template = _template.replace("%INT_TYPE%", ": int ");
- _template = _template.replace("%STRING_TYPE%", ": String ");
- _template = _template.replace("%FLOAT_TYPE%", " : float");
+ _template = _template.replace("%INT_TYPE%", ": int");
+ _template = _template.replace("%STRING_TYPE%", ": String");
+ _template = _template.replace("%FLOAT_TYPE%", ": float");
_template = _template.replace("%VOID_RETURN%", " -> void");
} else {
_template = _template.replace("%INT_TYPE%", "");
@@ -466,7 +466,7 @@ String GDScriptLanguage::make_function(const String &p_class, const String &p_na
if (th) {
String type = p_args[i].get_slice(":", 1);
if (!type.empty() && type != "var") {
- s += " : " + type;
+ s += ": " + type;
}
}
}
@@ -2596,7 +2596,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
}
method_hint += arg;
if (use_type_hint && mi.arguments[i].type != Variant::NIL) {
- method_hint += " : ";
+ method_hint += ": ";
if (mi.arguments[i].type == Variant::OBJECT && mi.arguments[i].class_name != StringName()) {
method_hint += mi.arguments[i].class_name.operator String();
} else {
diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp
index bae3f48923..d615b58b24 100644
--- a/modules/gdscript/gdscript_function.cpp
+++ b/modules/gdscript/gdscript_function.cpp
@@ -191,6 +191,7 @@ static String _get_var_type(const Variant *p_type) {
static const void *switch_table_ops[] = { \
&&OPCODE_OPERATOR, \
&&OPCODE_EXTENDS_TEST, \
+ &&OPCODE_IS_BUILTIN, \
&&OPCODE_SET, \
&&OPCODE_GET, \
&&OPCODE_SET_NAMED, \
@@ -536,6 +537,21 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
}
DISPATCH_OPCODE;
+ OPCODE(OPCODE_IS_BUILTIN) {
+
+ CHECK_SPACE(4);
+
+ GET_VARIANT_PTR(value, 1);
+ Variant::Type var_type = (Variant::Type)_code_ptr[ip + 2];
+ GET_VARIANT_PTR(dst, 3);
+
+ GD_ERR_BREAK(var_type < 0 || var_type >= Variant::VARIANT_MAX);
+
+ *dst = value->get_type() == var_type;
+ ip += 4;
+ }
+ DISPATCH_OPCODE;
+
OPCODE(OPCODE_SET) {
CHECK_SPACE(3);
diff --git a/modules/gdscript/gdscript_function.h b/modules/gdscript/gdscript_function.h
index 3ce84290fd..633cca35d3 100644
--- a/modules/gdscript/gdscript_function.h
+++ b/modules/gdscript/gdscript_function.h
@@ -136,6 +136,7 @@ public:
enum Opcode {
OPCODE_OPERATOR,
OPCODE_EXTENDS_TEST,
+ OPCODE_IS_BUILTIN,
OPCODE_SET,
OPCODE_GET,
OPCODE_SET_NAMED,
diff --git a/modules/gdscript/gdscript_functions.cpp b/modules/gdscript/gdscript_functions.cpp
index d9c20868bd..03e7740887 100644
--- a/modules/gdscript/gdscript_functions.cpp
+++ b/modules/gdscript/gdscript_functions.cpp
@@ -1853,7 +1853,7 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
} break;
case GET_STACK: {
MethodInfo mi("get_stack");
- mi.return_val.type = Variant::NIL;
+ mi.return_val.type = Variant::ARRAY;
return mi;
} break;
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index a3f5e1819e..7502f09d8a 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -861,6 +861,20 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
op->arguments.push_back(subexpr);
expr=op;*/
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_PR_IS && tokenizer->get_token(1) == GDScriptTokenizer::TK_BUILT_IN_TYPE) {
+ // 'is' operator with built-in type
+ OperatorNode *op = alloc_node<OperatorNode>();
+ op->op = OperatorNode::OP_IS_BUILTIN;
+ op->arguments.push_back(expr);
+
+ tokenizer->advance();
+
+ TypeNode *tn = alloc_node<TypeNode>();
+ tn->vtype = tokenizer->get_token_type();
+ op->arguments.push_back(tn);
+ tokenizer->advance();
+
+ expr = op;
} else if (tokenizer->get_token() == GDScriptTokenizer::TK_BRACKET_OPEN) {
// array
tokenizer->advance();
@@ -1071,6 +1085,15 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
expr = op;
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE && expression.size() > 0 && expression[expression.size() - 1].is_op && expression[expression.size() - 1].op == OperatorNode::OP_IS) {
+ Expression e = expression[expression.size() - 1];
+ e.op = OperatorNode::OP_IS_BUILTIN;
+ expression.write[expression.size() - 1] = e;
+
+ TypeNode *tn = alloc_node<TypeNode>();
+ tn->vtype = tokenizer->get_token_type();
+ expr = tn;
+ tokenizer->advance();
} else {
//find list [ or find dictionary {
@@ -1329,6 +1352,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
switch (expression[i].op) {
case OperatorNode::OP_IS:
+ case OperatorNode::OP_IS_BUILTIN:
priority = -1;
break; //before anything
@@ -3915,14 +3939,15 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "FLAGS") {
- //current_export.hint=PROPERTY_HINT_ALL_FLAGS;
tokenizer->advance();
if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
+ ERR_EXPLAIN("Exporting bit flags hint requires string constants.");
+ WARN_DEPRECATED
break;
}
if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
- _set_error("Expected ')' or ',' in bit flags hint.");
+ _set_error("Expected ',' in bit flags hint.");
return;
}
@@ -5793,6 +5818,13 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
case Node::TYPE_CONSTANT: {
node_type = _type_from_variant(static_cast<ConstantNode *>(p_node)->value);
} break;
+ case Node::TYPE_TYPE: {
+ TypeNode *tn = static_cast<TypeNode *>(p_node);
+ node_type.has_type = true;
+ node_type.is_meta_type = true;
+ node_type.kind = DataType::BUILTIN;
+ node_type.builtin_type = tn->vtype;
+ } break;
case Node::TYPE_ARRAY: {
node_type.has_type = true;
node_type.kind = DataType::BUILTIN;
@@ -5896,7 +5928,8 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
// yield can return anything
node_type.has_type = false;
} break;
- case OperatorNode::OP_IS: {
+ case OperatorNode::OP_IS:
+ case OperatorNode::OP_IS_BUILTIN: {
if (op->arguments.size() != 2) {
_set_error("Parser bug: binary operation without 2 arguments.", op->line);
@@ -5913,8 +5946,11 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) {
}
type_type.is_meta_type = false; // Test the actual type
if (!_is_type_compatible(type_type, value_type) && !_is_type_compatible(value_type, type_type)) {
- // TODO: Make this a warning?
- _set_error("A value of type '" + value_type.to_string() + "' will never be an instance of '" + type_type.to_string() + "'.", op->line);
+ if (op->op == OperatorNode::OP_IS) {
+ _set_error("A value of type '" + value_type.to_string() + "' will never be an instance of '" + type_type.to_string() + "'.", op->line);
+ } else {
+ _set_error("A value of type '" + value_type.to_string() + "' will never be of type '" + type_type.to_string() + "'.", op->line);
+ }
return DataType();
}
}
diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h
index dbe523a0b9..3c51e3f372 100644
--- a/modules/gdscript/gdscript_parser.h
+++ b/modules/gdscript/gdscript_parser.h
@@ -345,6 +345,7 @@ public:
OP_PARENT_CALL,
OP_YIELD,
OP_IS,
+ OP_IS_BUILTIN,
//indexing operator
OP_INDEX,
OP_INDEX_NAMED,
diff --git a/modules/gridmap/doc_classes/GridMap.xml b/modules/gridmap/doc_classes/GridMap.xml
index d5f9563600..09e8e39796 100644
--- a/modules/gridmap/doc_classes/GridMap.xml
+++ b/modules/gridmap/doc_classes/GridMap.xml
@@ -212,9 +212,12 @@
</member>
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask">
</member>
- <member name="theme" type="MeshLibrary" setter="set_theme" getter="get_theme">
+ <member name="mesh_library" type="MeshLibrary" setter="set_mesh_library" getter="get_mesh_library">
The assigned [MeshLibrary].
</member>
+ <member name="theme" type="MeshLibrary" setter="set_theme" getter="get_theme">
+ Deprecated, use [member mesh_library] instead.
+ </member>
</members>
<constants>
<constant name="INVALID_CELL_ITEM" value="-1">
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index 776c18da64..919607c3f6 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -211,13 +211,17 @@ bool GridMap::get_collision_layer_bit(int p_bit) const {
#ifndef DISABLE_DEPRECATED
void GridMap::set_theme(const Ref<MeshLibrary> &p_theme) {
- WARN_PRINTS("GridMap.theme/set_theme() is deprecated and will be removed in a future version. Use GridMap.mesh_library/set_mesh_library() instead.");
+ ERR_EXPLAIN("GridMap.theme/set_theme() is deprecated and will be removed in a future version. Use GridMap.mesh_library/set_mesh_library() instead.");
+ WARN_DEPRECATED
+
set_mesh_library(p_theme);
}
Ref<MeshLibrary> GridMap::get_theme() const {
- WARN_PRINTS("GridMap.theme/get_theme() is deprecated and will be removed in a future version. Use GridMap.mesh_library/get_mesh_library() instead.");
+ ERR_EXPLAIN("GridMap.theme/get_theme() is deprecated and will be removed in a future version. Use GridMap.mesh_library/get_mesh_library() instead.");
+ WARN_DEPRECATED
+
return get_mesh_library();
}
#endif // DISABLE_DEPRECATED
@@ -903,7 +907,7 @@ void GridMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("make_baked_meshes", "gen_lightmap_uv", "lightmap_uv_texel_size"), &GridMap::make_baked_meshes, DEFVAL(false), DEFVAL(0.1));
#ifndef DISABLE_DEPRECATED
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "theme", PROPERTY_HINT_RESOURCE_TYPE, "MeshLibrary", PROPERTY_USAGE_NOEDITOR), "set_theme", "get_theme");
+ ADD_PROPERTYNO(PropertyInfo(Variant::OBJECT, "theme", PROPERTY_HINT_RESOURCE_TYPE, "MeshLibrary", 0), "set_theme", "get_theme");
#endif // DISABLE_DEPRECATED
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh_library", PROPERTY_HINT_RESOURCE_TYPE, "MeshLibrary"), "set_mesh_library", "get_mesh_library");
diff --git a/modules/mobile_vr/shaders/lens_distorted.glsl b/modules/mobile_vr/shaders/lens_distorted.glsl
index 5a2975d737..92604c891c 100644
--- a/modules/mobile_vr/shaders/lens_distorted.glsl
+++ b/modules/mobile_vr/shaders/lens_distorted.glsl
@@ -1,7 +1,9 @@
+/* clang-format off */
[vertex]
-layout(location=0) in highp vec4 vertex_attrib;
-layout(location=4) in vec2 uv_in;
+layout(location = 0) in highp vec4 vertex_attrib;
+/* clang-format on */
+layout(location = 4) in vec2 uv_in;
uniform float offset_x;
@@ -9,13 +11,15 @@ out vec2 uv_interp;
void main() {
- uv_interp = uv_in;
- gl_Position = vec4(vertex_attrib.x + offset_x, vertex_attrib.y, 0.0, 1.0);
+ uv_interp = uv_in;
+ gl_Position = vec4(vertex_attrib.x + offset_x, vertex_attrib.y, 0.0, 1.0);
}
+/* clang-format off */
[fragment]
uniform sampler2D source; //texunit:0
+/* clang-format on */
uniform vec2 eye_center;
uniform float k1;
@@ -28,32 +32,31 @@ in vec2 uv_interp;
layout(location = 0) out vec4 frag_color;
void main() {
- vec2 coords = uv_interp;
- vec2 offset = coords - eye_center;
-
- // take aspect ratio into account
- offset.y /= aspect_ratio;
-
- // distort
- vec2 offset_sq = offset * offset;
- float radius_sq = offset_sq.x + offset_sq.y;
- float radius_s4 = radius_sq * radius_sq;
- float distortion_scale = 1.0 + (k1 * radius_sq) + (k2 * radius_s4);
- offset *= distortion_scale;
-
- // reapply aspect ratio
- offset.y *= aspect_ratio;
-
- // add our eye center back in
- coords = offset + eye_center;
- coords /= upscale;
-
- // and check our color
- if (coords.x < -1.0 || coords.y < -1.0 || coords.x > 1.0 || coords.y > 1.0) {
- frag_color = vec4(0.0, 0.0, 0.0, 1.0);
- } else {
- coords = (coords + vec2(1.0)) / vec2(2.0);
- frag_color = textureLod(source, coords, 0.0);
- }
+ vec2 coords = uv_interp;
+ vec2 offset = coords - eye_center;
+
+ // take aspect ratio into account
+ offset.y /= aspect_ratio;
+
+ // distort
+ vec2 offset_sq = offset * offset;
+ float radius_sq = offset_sq.x + offset_sq.y;
+ float radius_s4 = radius_sq * radius_sq;
+ float distortion_scale = 1.0 + (k1 * radius_sq) + (k2 * radius_s4);
+ offset *= distortion_scale;
+
+ // reapply aspect ratio
+ offset.y *= aspect_ratio;
+
+ // add our eye center back in
+ coords = offset + eye_center;
+ coords /= upscale;
+
+ // and check our color
+ if (coords.x < -1.0 || coords.y < -1.0 || coords.x > 1.0 || coords.y > 1.0) {
+ frag_color = vec4(0.0, 0.0, 0.0, 1.0);
+ } else {
+ coords = (coords + vec2(1.0)) / vec2(2.0);
+ frag_color = textureLod(source, coords, 0.0);
+ }
}
-
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp
index 4185f3407d..cc954348f4 100644
--- a/modules/mono/editor/bindings_generator.cpp
+++ b/modules/mono/editor/bindings_generator.cpp
@@ -533,7 +533,6 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_output_dir, bo
cs_icalls_content.push_back("using System;\n"
"using System.Runtime.CompilerServices;\n"
- "using " BINDINGS_NAMESPACE_COLLECTIONS ";\n"
"\n");
cs_icalls_content.push_back("namespace " BINDINGS_NAMESPACE "\n" OPEN_BLOCK);
cs_icalls_content.push_back(INDENT1 "internal static class " BINDINGS_CLASS_NATIVECALLS "\n" INDENT1 OPEN_BLOCK);
@@ -638,7 +637,6 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_output_dir,
cs_icalls_content.push_back("using System;\n"
"using System.Runtime.CompilerServices;\n"
- "using " BINDINGS_NAMESPACE_COLLECTIONS ";\n"
"\n");
cs_icalls_content.push_back("namespace " BINDINGS_NAMESPACE "\n" OPEN_BLOCK);
cs_icalls_content.push_back(INDENT1 "internal static class " BINDINGS_CLASS_NATIVECALLS_EDITOR "\n" INDENT1 OPEN_BLOCK);
@@ -711,10 +709,8 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
List<String> output;
output.push_back("using System;\n"); // IntPtr
-
- if (itype.requires_collections)
- output.push_back("using " BINDINGS_NAMESPACE_COLLECTIONS ";\n"); // Dictionary
-
+ output.push_back("\n#pragma warning disable CS1591 // Disable warning: "
+ "'Missing XML comment for publicly visible type or member'\n");
output.push_back("\nnamespace " BINDINGS_NAMESPACE "\n" OPEN_BLOCK);
const DocData::ClassDoc *class_doc = itype.class_doc;
@@ -737,8 +733,15 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
}
output.push_back(INDENT1 "public ");
- bool is_abstract = itype.is_object_type && !ClassDB::can_instance(itype.name) && ClassDB::is_class_enabled(itype.name); // can_instance returns true if there's a constructor and the class is not 'disabled'
- output.push_back(itype.is_singleton ? "static partial class " : (is_abstract ? "abstract partial class " : "partial class "));
+ if (itype.is_object_type) {
+ if (itype.is_singleton) {
+ output.push_back("static partial class ");
+ } else {
+ output.push_back(itype.is_instantiable ? "partial class " : "abstract partial class ");
+ }
+ } else {
+ output.push_back("partial class ");
+ }
output.push_back(itype.proxy_name);
if (itype.is_singleton) {
@@ -1034,7 +1037,10 @@ Error BindingsGenerator::_generate_cs_type(const TypeInterface &itype, const Str
custom_icalls.push_back(ctor_icall);
}
- output.push_back(INDENT1 CLOSE_BLOCK CLOSE_BLOCK);
+ output.push_back(INDENT1 CLOSE_BLOCK /* class */
+ CLOSE_BLOCK /* namespace */);
+
+ output.push_back("\n#pragma warning restore CS1591\n");
return _save_file(p_output_file, output);
}
@@ -1922,9 +1928,6 @@ void BindingsGenerator::_populate_object_type_interfaces() {
imethod.return_type.cname = Variant::get_type_name(return_info.type);
}
- if (!itype.requires_collections && imethod.return_type.cname == name_cache.type_Dictionary || imethod.return_type.cname == name_cache.type_Array)
- itype.requires_collections = true;
-
for (int i = 0; i < argc; i++) {
PropertyInfo arginfo = method_info.arguments[i];
@@ -1946,9 +1949,6 @@ void BindingsGenerator::_populate_object_type_interfaces() {
iarg.name = escape_csharp_keyword(snake_to_camel_case(iarg.name));
- if (!itype.requires_collections && iarg.type.cname == name_cache.type_Dictionary || imethod.return_type.cname == name_cache.type_Array)
- itype.requires_collections = true;
-
if (m && m->has_default_argument(i)) {
_default_argument_from_variant(m->get_default_argument(i), iarg);
}
@@ -2371,14 +2371,14 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
itype = TypeInterface();
itype.name = "Array";
itype.cname = itype.name;
- itype.proxy_name = "Collections.Array";
+ itype.proxy_name = itype.name;
itype.c_out = "\treturn memnew(Array(%1));\n";
itype.c_type = itype.name;
itype.c_type_in = itype.c_type + "*";
itype.c_type_out = itype.c_type + "*";
- itype.cs_type = itype.proxy_name;
+ itype.cs_type = BINDINGS_NAMESPACE_COLLECTIONS "." + itype.proxy_name;
itype.cs_in = "%0." CS_SMETHOD_GETINSTANCE "()";
- itype.cs_out = "return new Collections.Array(%0);";
+ itype.cs_out = "return new " + itype.cs_type + "(%0);";
itype.im_type_in = "IntPtr";
itype.im_type_out = "IntPtr";
builtin_types.insert(itype.cname, itype);
@@ -2387,14 +2387,14 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
itype = TypeInterface();
itype.name = "Dictionary";
itype.cname = itype.name;
- itype.proxy_name = "Collections.Dictionary";
+ itype.proxy_name = itype.name;
itype.c_out = "\treturn memnew(Dictionary(%1));\n";
itype.c_type = itype.name;
itype.c_type_in = itype.c_type + "*";
itype.c_type_out = itype.c_type + "*";
- itype.cs_type = itype.proxy_name;
+ itype.cs_type = BINDINGS_NAMESPACE_COLLECTIONS "." + itype.proxy_name;
itype.cs_in = "%0." CS_SMETHOD_GETINSTANCE "()";
- itype.cs_out = "return new Collections.Dictionary(%0);";
+ itype.cs_out = "return new " + itype.cs_type + "(%0);";
itype.im_type_in = "IntPtr";
itype.im_type_out = "IntPtr";
builtin_types.insert(itype.cname, itype);
@@ -2441,9 +2441,6 @@ void BindingsGenerator::_populate_builtin_type(TypeInterface &r_itype, Variant::
else
iarg.type.cname = Variant::get_type_name(pi.type);
- if (!r_itype.requires_collections && iarg.type.cname == name_cache.type_Dictionary || imethod.return_type.cname == name_cache.type_Array)
- r_itype.requires_collections = true;
-
if ((mi.default_arguments.size() - mi.arguments.size() + i) >= 0)
_default_argument_from_variant(Variant::construct(pi.type, NULL, 0, cerror), iarg);
@@ -2457,9 +2454,6 @@ void BindingsGenerator::_populate_builtin_type(TypeInterface &r_itype, Variant::
imethod.return_type.cname = Variant::get_type_name(mi.return_val.type);
}
- if (!r_itype.requires_collections && imethod.return_type.cname == name_cache.type_Dictionary || imethod.return_type.cname == name_cache.type_Array)
- r_itype.requires_collections = true;
-
if (r_itype.class_doc) {
for (int i = 0; i < r_itype.class_doc->methods.size(); i++) {
if (r_itype.class_doc->methods[i].name == imethod.name) {
diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h
index 5b33a0e53f..735e7ce7cc 100644
--- a/modules/mono/editor/bindings_generator.h
+++ b/modules/mono/editor/bindings_generator.h
@@ -192,7 +192,7 @@ class BindingsGenerator {
/**
* Used only by Object-derived types.
- * Determines if this type is not virtual (incomplete).
+ * Determines if this type is not abstract (incomplete).
* e.g.: CanvasItem cannot be instantiated.
*/
bool is_instantiable;
@@ -204,12 +204,6 @@ class BindingsGenerator {
*/
bool memory_own;
- /**
- * Determines if the file must have a using directive for System.Collections.Generic
- * e.g.: When the generated class makes use of Dictionary
- */
- bool requires_collections;
-
// !! The comments of the following fields make reference to other fields via square brackets, e.g.: [field_name]
// !! When renaming those fields, make sure to rename their references in the comments
@@ -295,7 +289,7 @@ class BindingsGenerator {
/**
* Type used for method signatures, both for parameters and the return type.
- * Same as [proxy_name] except for variable arguments (VarArg).
+ * Same as [proxy_name] except for variable arguments (VarArg) and collections (which include the namespace).
*/
String cs_type;
@@ -414,7 +408,6 @@ class BindingsGenerator {
is_instantiable = false;
memory_own = false;
- requires_collections = false;
c_arg_in = "%s";
diff --git a/modules/mono/glue/cs_files/Basis.cs b/modules/mono/glue/cs_files/Basis.cs
index c280d32c61..10286f3832 100644
--- a/modules/mono/glue/cs_files/Basis.cs
+++ b/modules/mono/glue/cs_files/Basis.cs
@@ -426,7 +426,7 @@ namespace Godot
public Basis(Quat quat)
{
- real_t s = 2.0f / quat.LengthSquared();
+ real_t s = 2.0f / quat.LengthSquared;
real_t xs = quat.x * s;
real_t ys = quat.y * s;
diff --git a/modules/mono/glue/cs_files/Quat.cs b/modules/mono/glue/cs_files/Quat.cs
index c69c55d997..eaa027eb69 100644
--- a/modules/mono/glue/cs_files/Quat.cs
+++ b/modules/mono/glue/cs_files/Quat.cs
@@ -11,18 +11,11 @@ namespace Godot
[StructLayout(LayoutKind.Sequential)]
public struct Quat : IEquatable<Quat>
{
- private static readonly Quat identity = new Quat(0f, 0f, 0f, 1f);
-
public real_t x;
public real_t y;
public real_t z;
public real_t w;
- public static Quat Identity
- {
- get { return identity; }
- }
-
public real_t this[int index]
{
get
@@ -63,6 +56,16 @@ namespace Godot
}
}
+ public real_t Length
+ {
+ get { return Mathf.Sqrt(LengthSquared); }
+ }
+
+ public real_t LengthSquared
+ {
+ get { return Dot(this); }
+ }
+
public Quat CubicSlerp(Quat b, Quat preA, Quat postB, real_t t)
{
real_t t2 = (1.0f - t) * t * 2f;
@@ -76,24 +79,20 @@ namespace Godot
return x * b.x + y * b.y + z * b.z + w * b.w;
}
- public Quat Inverse()
- {
- return new Quat(-x, -y, -z, w);
- }
-
- public real_t Length()
+ public Vector3 GetEuler()
{
- return Mathf.Sqrt(LengthSquared());
+ var basis = new Basis(this);
+ return basis.GetEuler();
}
- public real_t LengthSquared()
+ public Quat Inverse()
{
- return Dot(this);
+ return new Quat(-x, -y, -z, w);
}
public Quat Normalized()
{
- return this / Length();
+ return this / Length;
}
public void Set(real_t x, real_t y, real_t z, real_t w)
@@ -103,12 +102,20 @@ namespace Godot
this.z = z;
this.w = w;
}
+
public void Set(Quat q)
{
- x = q.x;
- y = q.y;
- z = q.z;
- w = q.w;
+ this = q;
+ }
+
+ public void SetAxisAngle(Vector3 axis, real_t angle)
+ {
+ this = new Quat(axis, angle);
+ }
+
+ public void SetEuler(Vector3 eulerYXZ)
+ {
+ this = new Quat(eulerYXZ);
}
public Quat Slerp(Quat b, real_t t)
@@ -192,6 +199,9 @@ namespace Godot
return new Vector3(q.x, q.y, q.z);
}
+ // Static Readonly Properties
+ public static Quat Identity { get; } = new Quat(0f, 0f, 0f, 1f);
+
// Constructors
public Quat(real_t x, real_t y, real_t z, real_t w)
{
@@ -199,15 +209,46 @@ namespace Godot
this.y = y;
this.z = z;
this.w = w;
- }
+ }
+
+ public bool IsNormalized()
+ {
+ return Mathf.Abs(LengthSquared - 1) <= Mathf.Epsilon;
+ }
+
public Quat(Quat q)
- {
- x = q.x;
- y = q.y;
- z = q.z;
- w = q.w;
+ {
+ this = q;
+ }
+
+ public Quat(Basis basis)
+ {
+ this = basis.Quat();
}
-
+
+ public Quat(Vector3 eulerYXZ)
+ {
+ real_t half_a1 = eulerYXZ.y * (real_t)0.5;
+ real_t half_a2 = eulerYXZ.x * (real_t)0.5;
+ real_t half_a3 = eulerYXZ.z * (real_t)0.5;
+
+ // R = Y(a1).X(a2).Z(a3) convention for Euler angles.
+ // Conversion to quaternion as listed in https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19770024290.pdf (page A-6)
+ // a3 is the angle of the first rotation, following the notation in this reference.
+
+ real_t cos_a1 = Mathf.Cos(half_a1);
+ real_t sin_a1 = Mathf.Sin(half_a1);
+ real_t cos_a2 = Mathf.Cos(half_a2);
+ real_t sin_a2 = Mathf.Sin(half_a2);
+ real_t cos_a3 = Mathf.Cos(half_a3);
+ real_t sin_a3 = Mathf.Sin(half_a3);
+
+ x = sin_a1 * cos_a2 * sin_a3 + cos_a1 * sin_a2 * cos_a3;
+ y = sin_a1 * cos_a2 * cos_a3 - cos_a1 * sin_a2 * sin_a3;
+ z = -sin_a1 * sin_a2 * cos_a3 + cos_a1 * cos_a2 * sin_a3;
+ w = sin_a1 * sin_a2 * sin_a3 + cos_a1 * cos_a2 * cos_a3;
+ }
+
public Quat(Vector3 axis, real_t angle)
{
real_t d = axis.Length();
diff --git a/modules/squish/image_compress_squish.cpp b/modules/squish/image_compress_squish.cpp
index 653dd82351..bb8a4bdbea 100644
--- a/modules/squish/image_compress_squish.cpp
+++ b/modules/squish/image_compress_squish.cpp
@@ -193,8 +193,8 @@ void image_compress_squish(Image *p_image, float p_lossy_quality, Image::Compres
int src_ofs = p_image->get_mipmap_offset(i);
squish::CompressImage(&rb[src_ofs], w, h, &wb[dst_ofs], squish_comp);
dst_ofs += (MAX(4, bw) * MAX(4, bh)) >> shift;
- w >>= 1;
- h >>= 1;
+ w = MAX(w / 2, 1);
+ h = MAX(h / 2, 1);
}
rb = PoolVector<uint8_t>::Read();
diff --git a/modules/tinyexr/image_loader_tinyexr.cpp b/modules/tinyexr/image_loader_tinyexr.cpp
index 0abefe11ee..b19bcfefcb 100644
--- a/modules/tinyexr/image_loader_tinyexr.cpp
+++ b/modules/tinyexr/image_loader_tinyexr.cpp
@@ -129,15 +129,45 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
PoolVector<uint8_t> imgdata;
Image::Format format;
+ int output_channels = 0;
if (idxA > 0) {
imgdata.resize(exr_image.width * exr_image.height * 8); //RGBA16
format = Image::FORMAT_RGBAH;
+ output_channels = 4;
} else {
imgdata.resize(exr_image.width * exr_image.height * 6); //RGB16
format = Image::FORMAT_RGBH;
+ output_channels = 3;
+ }
+
+ EXRTile single_image_tile;
+ int num_tiles;
+ int tile_width = 0;
+ int tile_height = 0;
+
+ const EXRTile *exr_tiles;
+
+ if (!exr_header.tiled) {
+ single_image_tile.images = exr_image.images;
+ single_image_tile.width = exr_image.width;
+ single_image_tile.height = exr_image.height;
+ single_image_tile.level_x = exr_image.width;
+ single_image_tile.level_y = exr_image.height;
+ single_image_tile.offset_x = 0;
+ single_image_tile.offset_y = 0;
+
+ exr_tiles = &single_image_tile;
+ num_tiles = 1;
+ tile_width = exr_image.width;
+ tile_height = exr_image.height;
+ } else {
+ tile_width = exr_header.tile_size_x;
+ tile_height = exr_header.tile_size_y;
+ num_tiles = exr_image.num_tiles;
+ exr_tiles = exr_image.tiles;
}
{
@@ -145,22 +175,51 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f
uint16_t *iw = (uint16_t *)wd.ptr();
// Assume `out_rgba` have enough memory allocated.
- for (int i = 0; i < exr_image.width * exr_image.height; i++) {
+ for (int tile_index = 0; tile_index < num_tiles; tile_index++) {
- Color color(
- reinterpret_cast<float **>(exr_image.images)[idxR][i],
- reinterpret_cast<float **>(exr_image.images)[idxG][i],
- reinterpret_cast<float **>(exr_image.images)[idxB][i]);
+ const EXRTile &tile = exr_tiles[tile_index];
- if (p_force_linear)
- color = color.to_linear();
+ int tw = tile.width;
+ int th = tile.height;
- *iw++ = Math::make_half_float(color.r);
- *iw++ = Math::make_half_float(color.g);
- *iw++ = Math::make_half_float(color.b);
+ const float *r_channel_start = reinterpret_cast<const float *>(tile.images[idxR]);
+ const float *g_channel_start = reinterpret_cast<const float *>(tile.images[idxG]);
+ const float *b_channel_start = reinterpret_cast<const float *>(tile.images[idxB]);
+ const float *a_channel_start = NULL;
if (idxA > 0) {
- *iw++ = Math::make_half_float(reinterpret_cast<float **>(exr_image.images)[idxA][i]);
+ a_channel_start = reinterpret_cast<const float *>(tile.images[idxA]);
+ }
+
+ uint16_t *first_row_w = iw + (tile.offset_y * tile_height * exr_image.width + tile.offset_x * tile_width) * output_channels;
+
+ for (int y = 0; y < th; y++) {
+ const float *r_channel = r_channel_start + y * tile_width;
+ const float *g_channel = g_channel_start + y * tile_width;
+ const float *b_channel = b_channel_start + y * tile_width;
+ const float *a_channel = NULL;
+
+ if (a_channel_start) {
+ a_channel = a_channel_start + y * tile_width;
+ }
+
+ uint16_t *row_w = first_row_w + (y * exr_image.width * output_channels);
+
+ for (int x = 0; x < tw; x++) {
+
+ Color color(*r_channel++, *g_channel++, *b_channel++);
+
+ if (p_force_linear)
+ color = color.to_linear();
+
+ *row_w++ = Math::make_half_float(color.r);
+ *row_w++ = Math::make_half_float(color.g);
+ *row_w++ = Math::make_half_float(color.b);
+
+ if (idxA > 0) {
+ *row_w++ = Math::make_half_float(*a_channel++);
+ }
+ }
}
}
}
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 4471fbd0c4..4d1deb6a89 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -321,7 +321,7 @@ protected:
p_list->push_back(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, argt));
p_list->push_back(PropertyInfo(script->get_variable_info(var).type, "value", script->get_variable_info(var).hint, script->get_variable_info(var).hint_string, PROPERTY_USAGE_DEFAULT));
// Update this when PropertyHint changes
- p_list->push_back(PropertyInfo(Variant::INT, "hint", PROPERTY_HINT_ENUM, "None,Range,ExpRange,Enum,ExpEasing,Length,SpriteFrame,KeyAccel,Flags,Layers2dRender,Layers2dPhysics,Layer3dRender,Layer3dPhysics,File,Dir,GlobalFile,GlobalDir,ResourceType,MultilineText,ColorNoAlpha,ImageCompressLossy,ImageCompressLossLess,ObjectId,String,NodePathToEditedNode,MethodOfVariantType,MethodOfBaseType,MethodOfInstance,MethodOfScript,PropertyOfVariantType,PropertyOfBaseType,PropertyOfInstance,PropertyOfScript,ObjectTooBig"));
+ p_list->push_back(PropertyInfo(Variant::INT, "hint", PROPERTY_HINT_ENUM, "None,Range,ExpRange,Enum,ExpEasing,Length,SpriteFrame,KeyAccel,Flags,Layers2dRender,Layers2dPhysics,Layer3dRender,Layer3dPhysics,File,Dir,GlobalFile,GlobalDir,ResourceType,MultilineText,PlaceholderText,ColorNoAlpha,ImageCompressLossy,ImageCompressLossLess,ObjectId,String,NodePathToEditedNode,MethodOfVariantType,MethodOfBaseType,MethodOfInstance,MethodOfScript,PropertyOfVariantType,PropertyOfBaseType,PropertyOfInstance,PropertyOfScript,ObjectTooBig,NodePathValidTypes"));
p_list->push_back(PropertyInfo(Variant::STRING, "hint_string"));
p_list->push_back(PropertyInfo(Variant::BOOL, "export"));
}
@@ -3615,8 +3615,7 @@ VisualScriptEditor::VisualScriptEditor() {
edit_signal_dialog->set_title(TTR("Edit Signal Arguments:"));
signal_editor = memnew(VisualScriptEditorSignalEdit);
- edit_signal_edit = memnew(PropertyEditor);
- edit_signal_edit->hide_top_label();
+ edit_signal_edit = memnew(EditorInspector);
edit_signal_dialog->add_child(edit_signal_edit);
edit_signal_edit->edit(signal_editor);
@@ -3627,8 +3626,7 @@ VisualScriptEditor::VisualScriptEditor() {
edit_variable_dialog->set_title(TTR("Edit Variable:"));
variable_editor = memnew(VisualScriptEditorVariableEdit);
- edit_variable_edit = memnew(PropertyEditor);
- edit_variable_edit->hide_top_label();
+ edit_variable_edit = memnew(EditorInspector);
edit_variable_dialog->add_child(edit_variable_edit);
edit_variable_edit->edit(variable_editor);
diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h
index 8bfd147519..b0bf971630 100644
--- a/modules/visual_script/visual_script_editor.h
+++ b/modules/visual_script/visual_script_editor.h
@@ -93,7 +93,7 @@ class VisualScriptEditor : public ScriptEditorBase {
VisualScriptEditorSignalEdit *signal_editor;
AcceptDialog *edit_signal_dialog;
- PropertyEditor *edit_signal_edit;
+ EditorInspector *edit_signal_edit;
VisualScriptPropertySelector *method_select;
VisualScriptPropertySelector *new_connect_node_select;
@@ -102,7 +102,7 @@ class VisualScriptEditor : public ScriptEditorBase {
VisualScriptEditorVariableEdit *variable_editor;
AcceptDialog *edit_variable_dialog;
- PropertyEditor *edit_variable_edit;
+ EditorInspector *edit_variable_edit;
CustomPropertyEditor *default_value_edit;
diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp
index f79c81ad88..8d465c8872 100644
--- a/modules/visual_script/visual_script_property_selector.cpp
+++ b/modules/visual_script/visual_script_property_selector.cpp
@@ -191,10 +191,10 @@ void VisualScriptPropertySelector::_update_search() {
if (type_filter.size() && type_filter.find(E->get().type) == -1)
continue;
- String get_text_raw = String(TTR("Get")) + String(" ") + E->get().name;
+ String get_text_raw = String(vformat(TTR("Get %s"), E->get().name));
String get_text = get_text_raw.capitalize();
- String set_text_raw = String(TTR("Set ")) + String(" ") + E->get().name;
+ String set_text_raw = String(vformat(TTR("Set %s"), E->get().name));
String set_text = set_text_raw.capitalize();
String input = search_box->get_text().capitalize();
if (input == String() ||
diff --git a/modules/webm/libvpx/SCsub b/modules/webm/libvpx/SCsub
index c681e2b34f..2daf8c282f 100644
--- a/modules/webm/libvpx/SCsub
+++ b/modules/webm/libvpx/SCsub
@@ -38,7 +38,6 @@ libvpx_sources = [
"vp8/decoder/decodemv.c",
"vp8/decoder/detokenize.c",
"vp8/decoder/onyxd_if.c",
- "vp8/decoder/threading.c",
"vp9/vp9_dx_iface.c",
@@ -102,6 +101,10 @@ libvpx_sources = [
"vpx_util/vpx_thread.c"
]
+libvpx_sources_mt = [
+ "vp8/decoder/threading.c",
+]
+
libvpx_sources_intrin_x86 = [
"vp8/common/x86/filter_x86.c",
"vp8/common/x86/loopfilter_x86.c",
@@ -231,6 +234,7 @@ libvpx_sources_arm_neon_gas_apple = [
]
libvpx_sources = [libvpx_dir + file for file in libvpx_sources]
+libvpx_sources_mt = [libvpx_dir + file for file in libvpx_sources_mt]
libvpx_sources_intrin_x86 = [libvpx_dir + file for file in libvpx_sources_intrin_x86]
libvpx_sources_intrin_x86_mmx = [libvpx_dir + file for file in libvpx_sources_intrin_x86_mmx]
libvpx_sources_intrin_x86_sse2 = [libvpx_dir + file for file in libvpx_sources_intrin_x86_sse2]
@@ -253,6 +257,8 @@ env_webm.Append(CPPPATH=[libvpx_dir])
env_libvpx = env.Clone()
env_libvpx.Append(CPPPATH=[libvpx_dir])
+webm_multithread = env["platform"] != 'javascript'
+
cpu_bits = env["bits"]
webm_cpu_x86 = False
webm_cpu_arm = False
@@ -338,6 +344,10 @@ if webm_simd_optimizations == False:
print("WebM SIMD optimizations are disabled. Check if your CPU architecture, CPU bits or platform are supported!")
env_libvpx.add_source_files(env.modules_sources, libvpx_sources)
+
+if webm_multithread:
+ env_libvpx.add_source_files(env.modules_sources, libvpx_sources_mt)
+
if webm_cpu_x86:
is_clang_or_gcc = ('gcc' in env["CC"]) or ('clang' in env["CC"]) or ("OSXCROSS_ROOT" in os.environ)
diff --git a/modules/websocket/emws_client.cpp b/modules/websocket/emws_client.cpp
index 00c36ebb47..836b564de8 100644
--- a/modules/websocket/emws_client.cpp
+++ b/modules/websocket/emws_client.cpp
@@ -62,25 +62,23 @@ EMSCRIPTEN_KEEPALIVE void _esws_on_close(void *obj, int code, char *reason, int
Error EMWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, PoolVector<String> p_protocols) {
+ String proto_string = p_protocols.join(",");
String str = "ws://";
- String proto_string = "";
if (p_ssl)
str = "wss://";
str += p_host + ":" + itos(p_port) + p_path;
- for (int i = 0; i < p_protocols.size(); i++) {
- proto_string += p_protocols[i];
- proto_string += ",";
- }
- if (proto_string == "")
- proto_string = "binary,";
-
- proto_string = proto_string.substr(0, proto_string.length() - 1);
_is_connecting = true;
/* clang-format off */
int peer_sock = EM_ASM_INT({
- var socket = new WebSocket(UTF8ToString($1), UTF8ToString($2).split(","));
+ var proto_str = UTF8ToString($2);
+ var socket = null;
+ if (proto_str) {
+ socket = new WebSocket(UTF8ToString($1), proto_str.split(","));
+ } else {
+ socket = new WebSocket(UTF8ToString($1));
+ }
var c_ptr = Module.IDHandler.get($0);
socket.binaryType = "arraybuffer";
diff --git a/modules/websocket/lws_client.cpp b/modules/websocket/lws_client.cpp
index ac31daa108..09f6422058 100644
--- a/modules/websocket/lws_client.cpp
+++ b/modules/websocket/lws_client.cpp
@@ -48,12 +48,10 @@ Error LWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port,
ERR_FAIL_COND_V(!addr.is_valid(), ERR_INVALID_PARAMETER);
- // prepare protocols
- if (p_protocols.size() == 0) // default to binary protocol
- p_protocols.append("binary");
+ // Prepare protocols
_lws_make_protocols(this, &LWSClient::_lws_gd_callback, p_protocols, &_lws_ref);
- // init lws client
+ // Init lws client
struct lws_context_creation_info info;
struct lws_client_connect_info i;
@@ -87,7 +85,10 @@ Error LWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port,
strncpy(pbuf, p_path.utf8().get_data(), 2048);
i.context = context;
- i.protocol = _lws_ref->lws_names;
+ if (p_protocols.size() > 0)
+ i.protocol = _lws_ref->lws_names;
+ else
+ i.protocol = NULL;
i.address = abuf;
i.host = hbuf;
i.path = pbuf;
@@ -134,13 +135,13 @@ int LWSClient::_handle_cb(struct lws *wsi, enum lws_callback_reasons reason, voi
case LWS_CALLBACK_CLIENT_CONNECTION_ERROR:
_on_error();
destroy_context();
- return -1; // we should close the connection (would probably happen anyway)
+ return -1; // We should close the connection (would probably happen anyway)
case LWS_CALLBACK_CLIENT_CLOSED:
peer->close();
destroy_context();
_on_disconnect();
- return 0; // we can end here
+ return 0; // We can end here
case LWS_CALLBACK_CLIENT_RECEIVE:
peer->read_wsi(in, len);
diff --git a/modules/websocket/lws_helper.h b/modules/websocket/lws_helper.h
index 85a1e3769f..70256ccf16 100644
--- a/modules/websocket/lws_helper.h
+++ b/modules/websocket/lws_helper.h
@@ -105,53 +105,54 @@ static bool _lws_poll(struct lws_context *context, _LWSRef *ref) {
}
/*
- * prepare the protocol_structs to be fed to context
- * also prepare the protocol string used by the client
+ * Prepare the protocol_structs to be fed to context.
+ * Also prepare the protocol string used by the client.
*/
static void _lws_make_protocols(void *p_obj, lws_callback_function *p_callback, PoolVector<String> p_names, _LWSRef **r_lws_ref) {
- /* the input strings might go away after this call,
- * we need to copy them. Will clear them when
- * destroying the context */
+ // The input strings might go away after this call, we need to copy them.
+ // We will clear them when destroying the context.
int i;
int len = p_names.size();
size_t data_size = sizeof(struct LWSPeer::PeerData);
PoolVector<String>::Read pnr = p_names.read();
- /*
- * This is a reference connecting the object with lws
- * keep track of status, mallocs, etc.
- * Must survive as long the context
- * Must be freed manually when context creation fails.
- */
+ // This is a reference connecting the object with lws keep track of status, mallocs, etc.
+ // Must survive as long the context.
+ // Must be freed manually when context creation fails.
_LWSRef *ref = _lws_create_ref(p_obj);
- /* LWS protocol structs */
+ // LWS protocol structs.
ref->lws_structs = (struct lws_protocols *)memalloc(sizeof(struct lws_protocols) * (len + 2));
memset(ref->lws_structs, 0, sizeof(struct lws_protocols) * (len + 2));
CharString strings = p_names.join(",").ascii();
int str_len = strings.length();
- /* Joined string of protocols, double the size: comma separated first, NULL separated last */
- ref->lws_names = (char *)memalloc((str_len + 1) * 2); /* plus the terminator */
+ // Joined string of protocols, double the size: comma separated first, NULL separated last
+ ref->lws_names = (char *)memalloc((str_len + 1) * 2); // Plus the terminator
char *names_ptr = ref->lws_names;
struct lws_protocols *structs_ptr = ref->lws_structs;
- copymem(names_ptr, strings.get_data(), str_len);
- names_ptr[str_len] = '\0'; /* NULL terminator */
- /* NULL terminated strings to be used in protocol structs */
- copymem(&names_ptr[str_len + 1], strings.get_data(), str_len);
- names_ptr[(str_len * 2) + 1] = '\0'; /* NULL terminator */
+ // Comma separated protocols string to be used in client Sec-WebSocket-Protocol header
+ if (str_len > 0)
+ copymem(names_ptr, strings.get_data(), str_len);
+ names_ptr[str_len] = '\0'; // NULL terminator
+
+ // NULL terminated protocol strings to be used in protocol structs
+ if (str_len > 0)
+ copymem(&names_ptr[str_len + 1], strings.get_data(), str_len);
+ names_ptr[(str_len * 2) + 1] = '\0'; // NULL terminator
int pos = str_len + 1;
- /* the first protocol is always http-only */
- structs_ptr[0].name = "http-only";
+ // The first protocol is the default for any http request (before upgrade).
+ // It is also used as the websocket protocol when no subprotocol is specified.
+ structs_ptr[0].name = "default";
structs_ptr[0].callback = p_callback;
structs_ptr[0].per_session_data_size = data_size;
structs_ptr[0].rx_buffer_size = LWS_BUF_SIZE;
structs_ptr[0].tx_packet_size = LWS_PACKET_SIZE;
- /* add user defined protocols */
+ // Add user defined protocols
for (i = 0; i < len; i++) {
structs_ptr[i + 1].name = (const char *)&names_ptr[pos];
structs_ptr[i + 1].callback = p_callback;
@@ -161,7 +162,7 @@ static void _lws_make_protocols(void *p_obj, lws_callback_function *p_callback,
pos += pnr[i].ascii().length() + 1;
names_ptr[pos - 1] = '\0';
}
- /* add protocols terminator */
+ // Add protocols terminator
structs_ptr[len + 1].name = NULL;
structs_ptr[len + 1].callback = NULL;
structs_ptr[len + 1].per_session_data_size = 0;
diff --git a/modules/websocket/lws_server.cpp b/modules/websocket/lws_server.cpp
index bb724bce9c..4a614f6933 100644
--- a/modules/websocket/lws_server.cpp
+++ b/modules/websocket/lws_server.cpp
@@ -41,9 +41,6 @@ Error LWSServer::listen(int p_port, PoolVector<String> p_protocols, bool gd_mp_a
struct lws_context_creation_info info;
memset(&info, 0, sizeof info);
- if (p_protocols.size() == 0) // default to binary protocol
- p_protocols.append(String("binary"));
-
// Prepare lws protocol structs
_lws_make_protocols(this, &LWSServer::_lws_gd_callback, p_protocols, &_lws_ref);