You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
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.
This commit is contained in:
committed by
Juan Linietsky
parent
c19488bd89
commit
33b5c57199
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user