summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/bullet/bullet_physics_server.cpp10
-rw-r--r--modules/bullet/bullet_physics_server.h4
-rw-r--r--modules/bullet/godot_result_callbacks.h9
-rw-r--r--modules/bullet/rigid_body_bullet.cpp56
-rw-r--r--modules/bullet/rigid_body_bullet.h7
-rw-r--r--modules/bullet/space_bullet.cpp2
-rw-r--r--modules/gdnative/register_types.cpp7
-rw-r--r--modules/gdscript/gdscript_function.cpp4
-rw-r--r--modules/gdscript/gdscript_parser.cpp4
-rw-r--r--modules/thekla_unwrap/SCsub3
-rw-r--r--modules/thekla_unwrap/register_types.cpp85
-rw-r--r--modules/visual_script/visual_script.cpp1
12 files changed, 140 insertions, 52 deletions
diff --git a/modules/bullet/bullet_physics_server.cpp b/modules/bullet/bullet_physics_server.cpp
index 26c879fddb..b233edc0d4 100644
--- a/modules/bullet/bullet_physics_server.cpp
+++ b/modules/bullet/bullet_physics_server.cpp
@@ -723,16 +723,16 @@ void BulletPhysicsServer::body_set_axis_velocity(RID p_body, const Vector3 &p_ax
body->set_linear_velocity(v);
}
-void BulletPhysicsServer::body_set_axis_lock(RID p_body, PhysicsServer::BodyAxisLock p_lock) {
+void BulletPhysicsServer::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock) {
RigidBodyBullet *body = rigid_body_owner.get(p_body);
ERR_FAIL_COND(!body);
- body->set_axis_lock(p_lock);
+ body->set_axis_lock(p_axis, p_lock);
}
-PhysicsServer::BodyAxisLock BulletPhysicsServer::body_get_axis_lock(RID p_body) const {
+bool BulletPhysicsServer::body_is_axis_locked(RID p_body, BodyAxis p_axis) const {
const RigidBodyBullet *body = rigid_body_owner.get(p_body);
- ERR_FAIL_COND_V(!body, BODY_AXIS_LOCK_DISABLED);
- return body->get_axis_lock();
+ ERR_FAIL_COND_V(!body, 0);
+ return body->is_axis_locked(p_axis);
}
void BulletPhysicsServer::body_add_collision_exception(RID p_body, RID p_body_b) {
diff --git a/modules/bullet/bullet_physics_server.h b/modules/bullet/bullet_physics_server.h
index ad8137ee2f..8a10c87fc6 100644
--- a/modules/bullet/bullet_physics_server.h
+++ b/modules/bullet/bullet_physics_server.h
@@ -226,8 +226,8 @@ public:
virtual void body_apply_torque_impulse(RID p_body, const Vector3 &p_impulse);
virtual void body_set_axis_velocity(RID p_body, const Vector3 &p_axis_velocity);
- virtual void body_set_axis_lock(RID p_body, BodyAxisLock p_lock);
- virtual BodyAxisLock body_get_axis_lock(RID p_body) const;
+ virtual void body_set_axis_lock(RID p_body, BodyAxis p_axis, bool p_lock);
+ virtual bool body_is_axis_locked(RID p_body, BodyAxis p_axis) const;
virtual void body_add_collision_exception(RID p_body, RID p_body_b);
virtual void body_remove_collision_exception(RID p_body, RID p_body_b);
diff --git a/modules/bullet/godot_result_callbacks.h b/modules/bullet/godot_result_callbacks.h
index 5750dc2acd..9d2fb1fce4 100644
--- a/modules/bullet/godot_result_callbacks.h
+++ b/modules/bullet/godot_result_callbacks.h
@@ -50,14 +50,21 @@ struct GodotFilterCallback : public btOverlapFilterCallback {
struct GodotClosestRayResultCallback : public btCollisionWorld::ClosestRayResultCallback {
const Set<RID> *m_exclude;
bool m_pickRay;
+ int m_shapeId;
public:
GodotClosestRayResultCallback(const btVector3 &rayFromWorld, const btVector3 &rayToWorld, const Set<RID> *p_exclude) :
btCollisionWorld::ClosestRayResultCallback(rayFromWorld, rayToWorld),
m_exclude(p_exclude),
- m_pickRay(false) {}
+ m_pickRay(false),
+ m_shapeId(0) {}
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
+ return btCollisionWorld::ClosestRayResultCallback::addSingleResult(rayResult, normalInWorldSpace);
+ }
};
// store all colliding object
diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp
index b9621a0585..669b2c3f0c 100644
--- a/modules/bullet/rigid_body_bullet.cpp
+++ b/modules/bullet/rigid_body_bullet.cpp
@@ -256,6 +256,7 @@ void RigidBodyBullet::KinematicUtilities::just_delete_shapes(int new_size) {
RigidBodyBullet::RigidBodyBullet() :
RigidCollisionObjectBullet(CollisionObjectBullet::TYPE_RIGID_BODY),
kinematic_utilities(NULL),
+ locked_axis(0),
gravity_scale(1),
mass(1),
linearDamp(0),
@@ -280,7 +281,7 @@ RigidBodyBullet::RigidBodyBullet() :
setupBulletCollisionObject(btBody);
set_mode(PhysicsServer::BODY_MODE_RIGID);
- set_axis_lock(PhysicsServer::BODY_AXIS_LOCK_DISABLED);
+ reload_axis_lock();
areasWhereIam.resize(maxAreasWhereIam);
for (int i = areasWhereIam.size() - 1; 0 <= i; --i) {
@@ -501,25 +502,25 @@ void RigidBodyBullet::set_mode(PhysicsServer::BodyMode p_mode) {
switch (p_mode) {
case PhysicsServer::BODY_MODE_KINEMATIC:
mode = PhysicsServer::BODY_MODE_KINEMATIC;
- set_axis_lock(axis_lock); // Reload axis lock
+ reload_axis_lock();
_internal_set_mass(0);
init_kinematic_utilities();
break;
case PhysicsServer::BODY_MODE_STATIC:
mode = PhysicsServer::BODY_MODE_STATIC;
- set_axis_lock(axis_lock); // Reload axis lock
+ reload_axis_lock();
_internal_set_mass(0);
break;
case PhysicsServer::BODY_MODE_RIGID: {
mode = PhysicsServer::BODY_MODE_RIGID;
- set_axis_lock(axis_lock); // Reload axis lock
+ reload_axis_lock();
_internal_set_mass(0 == mass ? 1 : mass);
scratch_space_override_modificator();
break;
}
case PhysicsServer::BODY_MODE_CHARACTER: {
mode = PhysicsServer::BODY_MODE_CHARACTER;
- set_axis_lock(axis_lock); // Reload axis lock
+ reload_axis_lock();
_internal_set_mass(0 == mass ? 1 : mass);
scratch_space_override_modificator();
break;
@@ -658,39 +659,28 @@ Vector3 RigidBodyBullet::get_applied_torque() const {
return gTotTorq;
}
-void RigidBodyBullet::set_axis_lock(PhysicsServer::BodyAxisLock p_lock) {
- axis_lock = p_lock;
-
- if (PhysicsServer::BODY_AXIS_LOCK_DISABLED == axis_lock) {
- btBody->setLinearFactor(btVector3(1., 1., 1.));
- btBody->setAngularFactor(btVector3(1., 1., 1.));
- } else if (PhysicsServer::BODY_AXIS_LOCK_X == axis_lock) {
- btBody->setLinearFactor(btVector3(0., 1., 1.));
- btBody->setAngularFactor(btVector3(1., 0., 0.));
- } else if (PhysicsServer::BODY_AXIS_LOCK_Y == axis_lock) {
- btBody->setLinearFactor(btVector3(1., 0., 1.));
- btBody->setAngularFactor(btVector3(0., 1., 0.));
- } else if (PhysicsServer::BODY_AXIS_LOCK_Z == axis_lock) {
- btBody->setLinearFactor(btVector3(1., 1., 0.));
- btBody->setAngularFactor(btVector3(0., 0., 1.));
+void RigidBodyBullet::set_axis_lock(PhysicsServer::BodyAxis p_axis, bool lock) {
+ if (lock) {
+ locked_axis |= p_axis;
+ } else {
+ locked_axis &= ~p_axis;
}
- if (PhysicsServer::BODY_MODE_CHARACTER == mode) {
- /// When character lock angular
- btBody->setAngularFactor(btVector3(0., 0., 0.));
- }
+ reload_axis_lock();
}
-PhysicsServer::BodyAxisLock RigidBodyBullet::get_axis_lock() const {
- btVector3 vec = btBody->getLinearFactor();
- if (0. == vec.x()) {
- return PhysicsServer::BODY_AXIS_LOCK_X;
- } else if (0. == vec.y()) {
- return PhysicsServer::BODY_AXIS_LOCK_Y;
- } else if (0. == vec.z()) {
- return PhysicsServer::BODY_AXIS_LOCK_Z;
+bool RigidBodyBullet::is_axis_locked(PhysicsServer::BodyAxis p_axis) const {
+ return locked_axis & p_axis;
+}
+
+void RigidBodyBullet::reload_axis_lock() {
+
+ btBody->setLinearFactor(btVector3(!is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_X), !is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_Y), !is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_Z)));
+ if (PhysicsServer::BODY_MODE_CHARACTER == mode) {
+ /// When character angular is always locked
+ btBody->setAngularFactor(btVector3(0., 0., 0.));
} else {
- return PhysicsServer::BODY_AXIS_LOCK_DISABLED;
+ btBody->setAngularFactor(btVector3(!is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_X), !is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_Y), !is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_Z)));
}
}
diff --git a/modules/bullet/rigid_body_bullet.h b/modules/bullet/rigid_body_bullet.h
index c54b5784b5..c0eb148e24 100644
--- a/modules/bullet/rigid_body_bullet.h
+++ b/modules/bullet/rigid_body_bullet.h
@@ -184,9 +184,9 @@ private:
KinematicUtilities *kinematic_utilities;
PhysicsServer::BodyMode mode;
- PhysicsServer::BodyAxisLock axis_lock;
GodotMotionState *godotMotionState;
btRigidBody *btBody;
+ uint16_t locked_axis;
real_t mass;
real_t gravity_scale;
real_t linearDamp;
@@ -269,8 +269,9 @@ public:
void set_applied_torque(const Vector3 &p_torque);
Vector3 get_applied_torque() const;
- void set_axis_lock(PhysicsServer::BodyAxisLock p_lock);
- PhysicsServer::BodyAxisLock get_axis_lock() const;
+ void set_axis_lock(PhysicsServer::BodyAxis p_axis, bool lock);
+ bool is_axis_locked(PhysicsServer::BodyAxis p_axis) const;
+ void reload_axis_lock();
/// Doc:
/// http://www.bulletphysics.org/mediawiki-1.5.8/index.php?title=Anti_tunneling_by_Motion_Clamping
diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp
index c1f6e81734..3ce4b294db 100644
--- a/modules/bullet/space_bullet.cpp
+++ b/modules/bullet/space_bullet.cpp
@@ -97,7 +97,7 @@ bool BulletPhysicsDirectSpaceState::intersect_ray(const Vector3 &p_from, const V
B_TO_G(btResult.m_hitNormalWorld.normalize(), r_result.normal);
CollisionObjectBullet *gObj = static_cast<CollisionObjectBullet *>(btResult.m_collisionObject->getUserPointer());
if (gObj) {
- r_result.shape = 0;
+ r_result.shape = btResult.m_shapeId;
r_result.rid = gObj->get_self();
r_result.collider_id = gObj->get_instance_id();
r_result.collider = 0 == r_result.collider_id ? NULL : ObjectDB::get_instance(r_result.collider_id);
diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp
index 365def75bc..1cb35ec006 100644
--- a/modules/gdnative/register_types.cpp
+++ b/modules/gdnative/register_types.cpp
@@ -99,12 +99,16 @@ static Set<String> get_gdnative_singletons(EditorFileSystemDirectory *p_dir) {
}
static void actual_discoverer_handler() {
+
EditorFileSystemDirectory *dir = EditorFileSystem::get_singleton()->get_filesystem();
Set<String> file_paths = get_gdnative_singletons(dir);
bool changed = false;
- Array current_files = ProjectSettings::get_singleton()->get("gdnative/singletons");
+ Array current_files;
+ if (ProjectSettings::get_singleton()->has_setting("gdnative/singletons")) {
+ current_files = ProjectSettings::get_singleton()->get("gdnative/singletons");
+ }
Array files;
files.resize(file_paths.size());
int i = 0;
@@ -128,7 +132,6 @@ static void actual_discoverer_handler() {
if (changed) {
ProjectSettings::get_singleton()->set("gdnative/singletons", files);
-
ProjectSettings::get_singleton()->save();
}
}
diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp
index d2ce318f82..ee23f0ea0f 100644
--- a/modules/gdscript/gdscript_function.cpp
+++ b/modules/gdscript/gdscript_function.cpp
@@ -515,7 +515,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
} else {
v = "of type '" + _get_var_type(index) + "'";
}
- err_text = "Invalid set index " + v + " (on base: '" + _get_var_type(dst) + "') with value of type '"+_get_var_type(value)+"'";
+ err_text = "Invalid set index " + v + " (on base: '" + _get_var_type(dst) + "') with value of type '" + _get_var_type(value) + "'";
OPCODE_BREAK;
}
#endif
@@ -574,7 +574,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
#ifdef DEBUG_ENABLED
if (!valid) {
String err_type;
- err_text = "Invalid set index '" + String(*index) + "' (on base: '" + _get_var_type(dst) + "') with value of type '"+_get_var_type(value)+"'.";
+ err_text = "Invalid set index '" + String(*index) + "' (on base: '" + _get_var_type(dst) + "') with value of type '" + _get_var_type(value) + "'.";
OPCODE_BREAK;
}
#endif
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index e48b03968b..599f204184 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -3389,6 +3389,10 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
_set_error("Can't export null type.");
return;
}
+ if (type == Variant::OBJECT) {
+ _set_error("Can't export raw object type.");
+ return;
+ }
current_export.type = type;
current_export.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE;
tokenizer->advance();
diff --git a/modules/thekla_unwrap/SCsub b/modules/thekla_unwrap/SCsub
index 2b1349a15f..1d4b086848 100644
--- a/modules/thekla_unwrap/SCsub
+++ b/modules/thekla_unwrap/SCsub
@@ -47,7 +47,8 @@ if env['builtin_thekla_atlas']:
"nvmesh/param/SingleFaceMap.cpp",
"nvmesh/param/Util.cpp",
"nvmesh/weld/VertexWeld.cpp",
- "nvmesh/weld/Snap.cpp"
+ "nvmesh/weld/Snap.cpp",
+ "thekla/thekla_atlas.cpp"
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
diff --git a/modules/thekla_unwrap/register_types.cpp b/modules/thekla_unwrap/register_types.cpp
index 8a9f8341e8..01b834f8cb 100644
--- a/modules/thekla_unwrap/register_types.cpp
+++ b/modules/thekla_unwrap/register_types.cpp
@@ -28,7 +28,88 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "register_types.h"
+#include "thirdparty/thekla_atlas/thekla/thekla_atlas.h"
+#include <stdio.h>
+#include <stdlib.h>
+extern bool (*array_mesh_lightmap_unwrap_callback)(float p_texel_size, const float *p_vertices, const float *p_normals, int p_vertex_count, const int *p_indices, const int *p_face_materials, int p_index_count, float **r_uv, int **r_vertex, int *r_vertex_count, int **r_index, int *r_index_count, int *r_size_hint_x, int *r_size_hint_y);
-void register_thekla_unwrap_types() {}
+bool thekla_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_vertices, const float *p_normals, int p_vertex_count, const int *p_indices, const int *p_face_materials, int p_index_count, float **r_uv, int **r_vertex, int *r_vertex_count, int **r_index, int *r_index_count, int *r_size_hint_x, int *r_size_hint_y) {
-void unregister_thekla_unwrap_types() {}
+ //set up input mesh
+ Thekla::Atlas_Input_Mesh input_mesh;
+ input_mesh.face_array = new Thekla::Atlas_Input_Face[p_index_count / 3];
+ for (int i = 0; i < p_index_count / 3; i++) {
+ input_mesh.face_array[i].vertex_index[0] = p_indices[i * 3 + 0];
+ input_mesh.face_array[i].vertex_index[1] = p_indices[i * 3 + 1];
+ input_mesh.face_array[i].vertex_index[2] = p_indices[i * 3 + 2];
+ printf("face %i - %i, %i, %i - mat %i\n", i, input_mesh.face_array[i].vertex_index[0], input_mesh.face_array[i].vertex_index[1], input_mesh.face_array[i].vertex_index[2], p_face_materials[i]);
+ input_mesh.face_array[i].material_index = p_face_materials[i];
+ }
+ input_mesh.vertex_array = new Thekla::Atlas_Input_Vertex[p_vertex_count];
+ for (int i = 0; i < p_vertex_count; i++) {
+ input_mesh.vertex_array[i].first_colocal = i; //wtf
+ for (int j = 0; j < 3; j++) {
+ input_mesh.vertex_array[i].position[j] = p_vertices[i * 3 + j];
+ input_mesh.vertex_array[i].normal[j] = p_normals[i * 3 + j];
+ }
+ input_mesh.vertex_array[i].uv[0] = 0;
+ input_mesh.vertex_array[i].uv[1] = 0;
+ printf("vertex %i - %f, %f, %f\n", i, input_mesh.vertex_array[i].position[0], input_mesh.vertex_array[i].position[1], input_mesh.vertex_array[i].position[2]);
+ printf("normal %i - %f, %f, %f\n", i, input_mesh.vertex_array[i].normal[0], input_mesh.vertex_array[i].normal[1], input_mesh.vertex_array[i].normal[2]);
+ }
+ input_mesh.face_count = p_index_count / 3;
+ input_mesh.vertex_count = p_vertex_count;
+
+ //set up options
+ Thekla::Atlas_Options options;
+ Thekla::atlas_set_default_options(&options);
+ options.packer_options.witness.packing_quality = 1;
+ options.packer_options.witness.texel_area = 1.0 / p_texel_size;
+
+ //generate
+ Thekla::Atlas_Error err;
+ Thekla::Atlas_Output_Mesh *output = atlas_generate(&input_mesh, &options, &err);
+
+ delete[] input_mesh.face_array;
+ delete[] input_mesh.vertex_array;
+
+ if (err != Thekla::Atlas_Error_Success) {
+ printf("error with atlas\n");
+ } else {
+ *r_vertex = (int *)malloc(sizeof(int) * output->vertex_count);
+ *r_uv = (float *)malloc(sizeof(float) * output->vertex_count * 3);
+ *r_index = (int *)malloc(sizeof(int) * output->index_count);
+
+ // printf("w: %i, h: %i\n", output->atlas_width, output->atlas_height);
+ for (int i = 0; i < output->vertex_count; i++) {
+ (*r_vertex)[i] = output->vertex_array[i].xref;
+ (*r_uv)[i * 2 + 0] = output->vertex_array[i].uv[0] / output->atlas_width;
+ (*r_uv)[i * 2 + 1] = output->vertex_array[i].uv[1] / output->atlas_height;
+ // printf("uv: %f,%f\n", (*r_uv)[i * 2 + 0], (*r_uv)[i * 2 + 1]);
+ }
+ *r_vertex_count = output->vertex_count;
+
+ for (int i = 0; i < output->index_count; i++) {
+ (*r_index)[i] = output->index_array[i];
+ }
+
+ *r_index_count = output->index_count;
+
+ *r_size_hint_x = output->atlas_height;
+ *r_size_hint_y = output->atlas_width;
+ }
+
+ if (output) {
+ atlas_free(output);
+ }
+
+ return err == Thekla::Atlas_Error_Success;
+}
+
+void register_thekla_unwrap_types() {
+
+ array_mesh_lightmap_unwrap_callback = thekla_mesh_lightmap_unwrap_callback;
+}
+
+void unregister_thekla_unwrap_types() {
+}
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index bb6c32e9e0..53d93798d9 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -2047,6 +2047,7 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
function.argument_count = func_node->get_argument_count();
function.max_stack += function.argument_count;
function.flow_stack_size = func_node->is_stack_less() ? 0 : func_node->get_stack_size();
+ max_input_args = MAX(max_input_args, function.argument_count);
}
//multiple passes are required to set up this complex thing..