diff options
author | Juan Linietsky <juan@godotengine.org> | 2020-02-24 15:20:53 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2020-02-25 12:55:53 +0100 |
commit | 33b5c571995cce60a21784ac33fcf958640ed1e2 (patch) | |
tree | b6f087b46a88fe8e2bac093c521da829108714f5 /platform/android/java_godot_lib_jni.cpp | |
parent | c19488bd895f911f37bf2c03624d05ea8d0ec1ee (diff) | |
download | redot-engine-33b5c571995cce60a21784ac33fcf958640ed1e2.tar.gz |
Variant: Added 64-bit packed arrays, renamed Variant::REAL to FLOAT.
- Renames PackedIntArray to PackedInt32Array.
- Renames PackedFloatArray to PackedFloat32Array.
- Adds PackedInt64Array and PackedFloat64Array.
- Renames Variant::REAL to Variant::FLOAT for consistency.
Packed arrays are for storing large amount of data and creating stuff like
meshes, buffers. textures, etc. Forcing them to be 64 is a huge waste of
memory. That said, many users requested the ability to have 64 bits packed
arrays for their games, so this is just an optional added type.
For Variant, the float datatype is always 64 bits, and exposed as `float`.
We still have `real_t` which is the datatype that can change from 32 to 64
bits depending on a compile flag (not entirely working right now, but that's
the idea). It affects math related datatypes and code only.
Neither Variant nor PackedArray make use of real_t, which is only intended
for math precision, so the term is removed from there to keep only float.
Diffstat (limited to 'platform/android/java_godot_lib_jni.cpp')
-rw-r--r-- | platform/android/java_godot_lib_jni.cpp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp index b99cf70659..900a452024 100644 --- a/platform/android/java_godot_lib_jni.cpp +++ b/platform/android/java_godot_lib_jni.cpp @@ -99,7 +99,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a v.val.i = *p_arg; }; } break; - case Variant::REAL: { + case Variant::FLOAT: { if (force_jobject) { @@ -182,7 +182,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a v.obj = jdict; } break; - case Variant::PACKED_INT_ARRAY: { + case Variant::PACKED_INT32_ARRAY: { Vector<int> array = *p_arg; jintArray arr = env->NewIntArray(array.size()); @@ -201,7 +201,7 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a v.obj = arr; } break; - case Variant::PACKED_REAL_ARRAY: { + case Variant::PACKED_FLOAT32_ARRAY: { Vector<float> array = *p_arg; jfloatArray arr = env->NewFloatArray(array.size()); @@ -211,6 +211,10 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a v.obj = arr; } break; +#ifndef _MSC_VER +#warning This is missing 64 bits arrays, I have no idea how to do it in JNI +#endif + default: { v.val.i = 0; @@ -319,7 +323,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { jdoubleArray arr = (jdoubleArray)obj; int fCount = env->GetArrayLength(arr); - PackedRealArray sarr; + PackedFloat32Array sarr; sarr.resize(fCount); real_t *w = sarr.ptrw(); @@ -337,7 +341,7 @@ Variant _jobject_to_variant(JNIEnv *env, jobject obj) { jfloatArray arr = (jfloatArray)obj; int fCount = env->GetArrayLength(arr); - PackedRealArray sarr; + PackedFloat32Array sarr; sarr.resize(fCount); real_t *w = sarr.ptrw(); @@ -487,7 +491,7 @@ public: ret = env->CallIntMethodA(instance, E->get().method, v); } break; - case Variant::REAL: { + case Variant::FLOAT: { ret = env->CallFloatMethodA(instance, E->get().method, v); } break; @@ -505,7 +509,7 @@ public: env->DeleteLocalRef(arr); } break; - case Variant::PACKED_INT_ARRAY: { + case Variant::PACKED_INT32_ARRAY: { jintArray arr = (jintArray)env->CallObjectMethodA(instance, E->get().method, v); @@ -519,7 +523,7 @@ public: ret = sarr; env->DeleteLocalRef(arr); } break; - case Variant::PACKED_REAL_ARRAY: { + case Variant::PACKED_FLOAT32_ARRAY: { jfloatArray arr = (jfloatArray)env->CallObjectMethodA(instance, E->get().method, v); @@ -534,6 +538,9 @@ public: env->DeleteLocalRef(arr); } break; +#ifndef _MSC_VER +#warning This is missing 64 bits arrays, I have no idea how to do it in JNI +#endif case Variant::DICTIONARY: { jobject obj = env->CallObjectMethodA(instance, E->get().method, v); @@ -1246,12 +1253,12 @@ static Variant::Type get_jni_type(const String &p_type) { { "void", Variant::NIL }, { "boolean", Variant::BOOL }, { "int", Variant::INT }, - { "float", Variant::REAL }, - { "double", Variant::REAL }, + { "float", Variant::FLOAT }, + { "double", Variant::FLOAT }, { "java.lang.String", Variant::STRING }, - { "[I", Variant::PACKED_INT_ARRAY }, + { "[I", Variant::PACKED_INT32_ARRAY }, { "[B", Variant::PACKED_BYTE_ARRAY }, - { "[F", Variant::PACKED_REAL_ARRAY }, + { "[F", Variant::PACKED_FLOAT32_ARRAY }, { "[Ljava.lang.String;", Variant::PACKED_STRING_ARRAY }, { "org.godotengine.godot.Dictionary", Variant::DICTIONARY }, { NULL, Variant::NIL } |