summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/classes/File.xml1
-rw-r--r--drivers/unix/thread_posix.cpp17
-rw-r--r--editor/import/editor_scene_importer_gltf.cpp33
-rw-r--r--platform/android/thread_jandroid.cpp17
4 files changed, 57 insertions, 11 deletions
diff --git a/doc/classes/File.xml b/doc/classes/File.xml
index 1967349546..6462176c73 100644
--- a/doc/classes/File.xml
+++ b/doc/classes/File.xml
@@ -48,6 +48,7 @@
</argument>
<description>
Returns [code]true[/code] if the file exists in the given path.
+ Note that many resources types are imported (e.g. textures or sound files), and that their source asset will not be included in the exported game, as only the imported version is used (in the [code]res://.import[/code] folder). To check for the existence of such resources while taking into account the remapping to their imported location, use [method ResourceLoader.exists]. Typically, using [code]File.file_exists[/code] on an imported resource would work while you are developing in the editor (the source asset is present in [code]res://[/code], but fail when exported).
</description>
</method>
<method name="get_16" qualifiers="const">
diff --git a/drivers/unix/thread_posix.cpp b/drivers/unix/thread_posix.cpp
index a81292d4a2..ef3f5fb49c 100644
--- a/drivers/unix/thread_posix.cpp
+++ b/drivers/unix/thread_posix.cpp
@@ -40,9 +40,13 @@
#include "core/os/memory.h"
#include "core/safe_refcount.h"
+static void _thread_id_key_destr_callback(void *p_value) {
+ memdelete(static_cast<Thread::ID *>(p_value));
+}
+
static pthread_key_t _create_thread_id_key() {
pthread_key_t key;
- pthread_key_create(&key, NULL);
+ pthread_key_create(&key, &_thread_id_key_destr_callback);
return key;
}
@@ -63,7 +67,7 @@ void *ThreadPosix::thread_callback(void *userdata) {
ThreadPosix *t = reinterpret_cast<ThreadPosix *>(userdata);
t->id = atomic_increment(&next_thread_id);
- pthread_setspecific(thread_id_key, (void *)t->id);
+ pthread_setspecific(thread_id_key, (void *)memnew(ID(t->id)));
ScriptServer::thread_enter(); //scripts may need to attach a stack
@@ -89,7 +93,14 @@ Thread *ThreadPosix::create_func_posix(ThreadCreateCallback p_callback, void *p_
}
Thread::ID ThreadPosix::get_thread_id_func_posix() {
- return (ID)pthread_getspecific(thread_id_key);
+ void *value = pthread_getspecific(thread_id_key);
+
+ if (value)
+ return *static_cast<ID *>(value);
+
+ ID new_id = atomic_increment(&next_thread_id);
+ pthread_setspecific(thread_id_key, (void *)memnew(ID(new_id)));
+ return new_id;
}
void ThreadPosix::wait_to_finish_func_posix(Thread *p_thread) {
diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp
index 654dfc62e0..c29e9281fa 100644
--- a/editor/import/editor_scene_importer_gltf.cpp
+++ b/editor/import/editor_scene_importer_gltf.cpp
@@ -1030,11 +1030,19 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
int size = src_varr.size();
ERR_FAIL_COND_V(size == 0, ERR_PARSE_ERROR);
{
+
+ int max_idx = varr.size();
+ varr.resize(size);
+
PoolVector<Vector3>::Write w_varr = varr.write();
PoolVector<Vector3>::Read r_varr = varr.read();
PoolVector<Vector3>::Read r_src_varr = src_varr.read();
for (int l = 0; l < size; l++) {
- w_varr[l] = r_varr[l] + r_src_varr[l];
+ if (l < max_idx) {
+ w_varr[l] = r_varr[l] + r_src_varr[l];
+ } else {
+ w_varr[l] = r_src_varr[l];
+ }
}
}
array_copy[Mesh::ARRAY_VERTEX] = varr;
@@ -1045,11 +1053,18 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
int size = src_narr.size();
ERR_FAIL_COND_V(size == 0, ERR_PARSE_ERROR);
{
+ int max_idx = narr.size();
+ narr.resize(size);
+
PoolVector<Vector3>::Write w_narr = narr.write();
PoolVector<Vector3>::Read r_narr = narr.read();
PoolVector<Vector3>::Read r_src_narr = src_narr.read();
for (int l = 0; l < size; l++) {
- w_narr[l] = r_narr[l] + r_src_narr[l];
+ if (l < max_idx) {
+ w_narr[l] = r_narr[l] + r_src_narr[l];
+ } else {
+ w_narr[l] = r_src_narr[l];
+ }
}
}
array_copy[Mesh::ARRAY_NORMAL] = narr;
@@ -1062,6 +1077,8 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
{
+ int max_idx = tangents_v3.size();
+
int size4 = src_tangents.size();
tangents_v4.resize(size4);
PoolVector<float>::Write w4 = tangents_v4.write();
@@ -1071,9 +1088,15 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
for (int l = 0; l < size4 / 4; l++) {
- w4[l * 4 + 0] = r3[l].x + r4[l * 4 + 0];
- w4[l * 4 + 1] = r3[l].y + r4[l * 4 + 1];
- w4[l * 4 + 2] = r3[l].z + r4[l * 4 + 2];
+ if (l < max_idx) {
+ w4[l * 4 + 0] = r3[l].x + r4[l * 4 + 0];
+ w4[l * 4 + 1] = r3[l].y + r4[l * 4 + 1];
+ w4[l * 4 + 2] = r3[l].z + r4[l * 4 + 2];
+ } else {
+ w4[l * 4 + 0] = r4[l * 4 + 0];
+ w4[l * 4 + 1] = r4[l * 4 + 1];
+ w4[l * 4 + 2] = r4[l * 4 + 2];
+ }
w4[l * 4 + 3] = r4[l * 4 + 3]; //copy flip value
}
}
diff --git a/platform/android/thread_jandroid.cpp b/platform/android/thread_jandroid.cpp
index 98f6e79dcb..9df9e57b24 100644
--- a/platform/android/thread_jandroid.cpp
+++ b/platform/android/thread_jandroid.cpp
@@ -34,9 +34,13 @@
#include "core/safe_refcount.h"
#include "core/script_language.h"
+static void _thread_id_key_destr_callback(void *p_value) {
+ memdelete(static_cast<Thread::ID *>(p_value));
+}
+
static pthread_key_t _create_thread_id_key() {
pthread_key_t key;
- pthread_key_create(&key, NULL);
+ pthread_key_create(&key, &_thread_id_key_destr_callback);
return key;
}
@@ -59,7 +63,7 @@ void *ThreadAndroid::thread_callback(void *userdata) {
setup_thread();
ScriptServer::thread_enter(); //scripts may need to attach a stack
t->id = atomic_increment(&next_thread_id);
- pthread_setspecific(thread_id_key, (void *)t->id);
+ pthread_setspecific(thread_id_key, (void *)memnew(ID(t->id)));
t->callback(t->user);
ScriptServer::thread_exit();
return NULL;
@@ -80,7 +84,14 @@ Thread *ThreadAndroid::create_func_jandroid(ThreadCreateCallback p_callback, voi
Thread::ID ThreadAndroid::get_thread_id_func_jandroid() {
- return (ID)pthread_getspecific(thread_id_key);
+ void *value = pthread_getspecific(thread_id_key);
+
+ if (value)
+ return *static_cast<ID *>(value);
+
+ ID new_id = atomic_increment(&next_thread_id);
+ pthread_setspecific(thread_id_key, (void *)memnew(ID(new_id)));
+ return new_id;
}
void ThreadAndroid::wait_to_finish_func_jandroid(Thread *p_thread) {