summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/string/ustring.cpp16
-rw-r--r--doc/classes/XRInterface.xml20
-rw-r--r--platform/android/java/app/config.gradle8
-rw-r--r--platform/android/java/gradle/wrapper/gradle-wrapper.properties2
-rw-r--r--platform/android/java/lib/AndroidManifest.xml3
-rw-r--r--platform/android/java/lib/build.gradle13
-rw-r--r--scene/3d/visual_instance_3d.cpp30
-rw-r--r--scene/3d/visual_instance_3d.h6
-rw-r--r--servers/rendering/shader_language.cpp4
-rw-r--r--servers/xr/xr_interface.cpp2
10 files changed, 67 insertions, 37 deletions
diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp
index c6cc4cc4ac..2ba389fc4d 100644
--- a/core/string/ustring.cpp
+++ b/core/string/ustring.cpp
@@ -1460,15 +1460,25 @@ String String::num(double p_num, int p_decimals) {
fmt[5] = 'f';
fmt[6] = 0;
}
- char buf[256];
+ // if we want to convert a double with as much decimal places as as
+ // DBL_MAX or DBL_MIN then we would theoretically need a buffer of at least
+ // DBL_MAX_10_EXP + 2 for DBL_MAX and DBL_MAX_10_EXP + 4 for DBL_MIN.
+ // BUT those values where still giving me exceptions, so I tested from
+ // DBL_MAX_10_EXP + 10 incrementing one by one and DBL_MAX_10_EXP + 17 (325)
+ // was the first buffer size not to throw an exception
+ char buf[325];
#if defined(__GNUC__) || defined(_MSC_VER)
- snprintf(buf, 256, fmt, p_num);
+ // PLEASE NOTE that, albeit vcrt online reference states that snprintf
+ // should safely truncate the output to the given buffer size, we have
+ // found a case where this is not true, so we should create a buffer
+ // as big as needed
+ snprintf(buf, 325, fmt, p_num);
#else
sprintf(buf, fmt, p_num);
#endif
- buf[255] = 0;
+ buf[324] = 0;
//destroy trailing zeroes
{
bool period = false;
diff --git a/doc/classes/XRInterface.xml b/doc/classes/XRInterface.xml
index cc483dbd02..05d5eb6673 100644
--- a/doc/classes/XRInterface.xml
+++ b/doc/classes/XRInterface.xml
@@ -35,6 +35,16 @@
Returns an array of vectors that denotes the physical play area mapped to the virtual space around the [XROrigin3D] point. The points form a convex polygon that can be used to react to or visualize the play area. This returns an empty array if this feature is not supported or if the information is not yet available.
</description>
</method>
+ <method name="get_projection_for_view">
+ <return type="Projection" />
+ <param index="0" name="view" type="int" />
+ <param index="1" name="aspect" type="float" />
+ <param index="2" name="near" type="float" />
+ <param index="3" name="far" type="float" />
+ <description>
+ Returns the projection matrix for a view/eye.
+ </description>
+ </method>
<method name="get_render_target_size">
<return type="Vector2" />
<description>
@@ -47,6 +57,16 @@
If supported, returns the status of our tracking. This will allow you to provide feedback to the user whether there are issues with positional tracking.
</description>
</method>
+ <method name="get_transform_for_view">
+ <return type="Transform3D" />
+ <param index="0" name="view" type="int" />
+ <param index="1" name="cam_transform" type="Transform3D" />
+ <description>
+ Returns the transform for a view/eye.
+ [param view] is the view/eye index.
+ [param cam_transform] is the transform that maps device coordinates to scene coordinates, typically the global_transform of the current XROrigin3D.
+ </description>
+ </method>
<method name="get_view_count">
<return type="int" />
<description>
diff --git a/platform/android/java/app/config.gradle b/platform/android/java/app/config.gradle
index 0346625e4b..e1d9dc4cde 100644
--- a/platform/android/java/app/config.gradle
+++ b/platform/android/java/app/config.gradle
@@ -1,10 +1,10 @@
ext.versions = [
- androidGradlePlugin: '7.0.3',
+ androidGradlePlugin: '7.2.1',
compileSdk : 32,
- minSdk : 19, // Also update 'platform/android/java/lib/AndroidManifest.xml#minSdkVersion' & 'platform/android/export/export_plugin.cpp#DEFAULT_MIN_SDK_VERSION'
- targetSdk : 32, // Also update 'platform/android/java/lib/AndroidManifest.xml#targetSdkVersion' & 'platform/android/export/export_plugin.cpp#DEFAULT_TARGET_SDK_VERSION'
+ minSdk : 19, // Also update 'platform/android/export/export_plugin.cpp#DEFAULT_MIN_SDK_VERSION'
+ targetSdk : 32, // Also update 'platform/android/export/export_plugin.cpp#DEFAULT_TARGET_SDK_VERSION'
buildTools : '32.0.0',
- kotlinVersion : '1.6.21',
+ kotlinVersion : '1.7.0',
fragmentVersion : '1.3.6',
nexusPublishVersion: '1.1.0',
javaVersion : 11,
diff --git a/platform/android/java/gradle/wrapper/gradle-wrapper.properties b/platform/android/java/gradle/wrapper/gradle-wrapper.properties
index ffed3a254e..41dfb87909 100644
--- a/platform/android/java/gradle/wrapper/gradle-wrapper.properties
+++ b/platform/android/java/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/platform/android/java/lib/AndroidManifest.xml b/platform/android/java/lib/AndroidManifest.xml
index 79b5aadf2a..1f77e2fc34 100644
--- a/platform/android/java/lib/AndroidManifest.xml
+++ b/platform/android/java/lib/AndroidManifest.xml
@@ -4,9 +4,6 @@
android:versionCode="1"
android:versionName="1.0">
- <!-- Should match the mindSdk and targetSdk values in platform/android/java/app/config.gradle -->
- <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="32" />
-
<application>
<!-- Records the version of the Godot library -->
diff --git a/platform/android/java/lib/build.gradle b/platform/android/java/lib/build.gradle
index c9e2a5d7d2..841656a240 100644
--- a/platform/android/java/lib/build.gradle
+++ b/platform/android/java/lib/build.gradle
@@ -176,11 +176,10 @@ android {
}
}
- // TODO: Enable when issues with AGP 7.1+ are resolved (https://github.com/GodotVR/godot_openxr/issues/187).
-// publishing {
-// singleVariant("templateRelease") {
-// withSourcesJar()
-// withJavadocJar()
-// }
-// }
+ publishing {
+ singleVariant("templateRelease") {
+ withSourcesJar()
+ withJavadocJar()
+ }
+ }
}
diff --git a/scene/3d/visual_instance_3d.cpp b/scene/3d/visual_instance_3d.cpp
index 09d31b1ca0..b5b37bf837 100644
--- a/scene/3d/visual_instance_3d.cpp
+++ b/scene/3d/visual_instance_3d.cpp
@@ -74,10 +74,6 @@ RID VisualInstance3D::get_instance() const {
return instance;
}
-RID VisualInstance3D::_get_visual_instance_rid() const {
- return instance;
-}
-
void VisualInstance3D::set_layer_mask(uint32_t p_mask) {
layers = p_mask;
RenderingServer::get_singleton()->instance_set_layer_mask(instance, p_mask);
@@ -106,7 +102,6 @@ bool VisualInstance3D::get_layer_mask_value(int p_layer_number) const {
}
void VisualInstance3D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("_get_visual_instance_rid"), &VisualInstance3D::_get_visual_instance_rid);
ClassDB::bind_method(D_METHOD("set_base", "base"), &VisualInstance3D::set_base);
ClassDB::bind_method(D_METHOD("get_base"), &VisualInstance3D::get_base);
ClassDB::bind_method(D_METHOD("get_instance"), &VisualInstance3D::get_instance);
@@ -216,15 +211,20 @@ GeometryInstance3D::VisibilityRangeFadeMode GeometryInstance3D::get_visibility_r
}
const StringName *GeometryInstance3D::_instance_uniform_get_remap(const StringName p_name) const {
- StringName *r = instance_uniform_property_remap.getptr(p_name);
+ StringName *r = instance_shader_parameter_property_remap.getptr(p_name);
if (!r) {
String s = p_name;
+#ifndef DISABLE_DEPRECATED
if (s.begins_with("shader_uniforms/")) {
- StringName name = s.replace("shader_uniforms/", "");
- instance_uniform_property_remap[p_name] = name;
- return instance_uniform_property_remap.getptr(p_name);
+ s = s.replace("shader_uniforms/", "instance_shader_parameters/");
+ }
+#endif // DISABLE_DEPRECATED
+ if (s.begins_with("instance_shader_parameters/")) {
+ StringName pname = StringName(s);
+ StringName name = s.replace("instance_shader_parameters/", "");
+ instance_shader_parameter_property_remap[pname] = name;
+ return instance_shader_parameter_property_remap.getptr(pname);
}
-
return nullptr;
}
@@ -247,7 +247,7 @@ bool GeometryInstance3D::_set(const StringName &p_name, const Variant &p_value)
set_gi_mode(GI_MODE_DYNAMIC);
return true;
}
-#endif
+#endif // DISABLE_DEPRECATED
return false;
}
@@ -270,13 +270,13 @@ void GeometryInstance3D::_get_property_list(List<PropertyInfo> *p_list) const {
if (def_value.get_type() != Variant::NIL) {
has_def_value = true;
}
- if (instance_uniforms.has(pi.name)) {
+ if (instance_shader_parameters.has(pi.name)) {
pi.usage = PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_STORAGE | (has_def_value ? (PROPERTY_USAGE_CHECKABLE | PROPERTY_USAGE_CHECKED) : PROPERTY_USAGE_NONE);
} else {
pi.usage = PROPERTY_USAGE_EDITOR | (has_def_value ? PROPERTY_USAGE_CHECKABLE : PROPERTY_USAGE_NONE); //do not save if not changed
}
- pi.name = "shader_uniforms/" + pi.name;
+ pi.name = "instance_shader_parameters/" + pi.name;
p_list->push_back(pi);
}
}
@@ -315,9 +315,9 @@ void GeometryInstance3D::set_instance_shader_parameter(const StringName &p_name,
if (p_value.get_type() == Variant::NIL) {
Variant def_value = RS::get_singleton()->instance_geometry_get_shader_parameter_default_value(get_instance(), p_name);
RS::get_singleton()->instance_geometry_set_shader_parameter(get_instance(), p_name, def_value);
- instance_uniforms.erase(p_value);
+ instance_shader_parameters.erase(p_value);
} else {
- instance_uniforms[p_name] = p_value;
+ instance_shader_parameters[p_name] = p_value;
if (p_value.get_type() == Variant::OBJECT) {
RID tex_id = p_value;
RS::get_singleton()->instance_geometry_set_shader_parameter(get_instance(), p_name, tex_id);
diff --git a/scene/3d/visual_instance_3d.h b/scene/3d/visual_instance_3d.h
index c9a25d9705..f18bff2ddc 100644
--- a/scene/3d/visual_instance_3d.h
+++ b/scene/3d/visual_instance_3d.h
@@ -40,8 +40,6 @@ class VisualInstance3D : public Node3D {
RID instance;
uint32_t layers = 1;
- RID _get_visual_instance_rid() const;
-
protected:
void _update_visibility();
@@ -119,8 +117,8 @@ private:
float lod_bias = 1.0;
- mutable HashMap<StringName, Variant> instance_uniforms;
- mutable HashMap<StringName, StringName> instance_uniform_property_remap;
+ mutable HashMap<StringName, Variant> instance_shader_parameters;
+ mutable HashMap<StringName, StringName> instance_shader_parameter_property_remap;
float extra_cull_margin = 0.0;
LightmapScale lightmap_scale = LIGHTMAP_SCALE_1X;
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp
index 2f5846f520..14c09c1512 100644
--- a/servers/rendering/shader_language.cpp
+++ b/servers/rendering/shader_language.cpp
@@ -8178,6 +8178,10 @@ Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_f
}
}
#endif // DEBUG_ENABLED
+ if (String(shader_type_identifier) != "spatial") {
+ _set_error(vformat(RTR("Uniform instances are not yet implemented for '%s' shaders."), shader_type_identifier));
+ return ERR_PARSE_ERROR;
+ }
if (uniform_scope == ShaderNode::Uniform::SCOPE_LOCAL) {
tk = _get_token();
if (tk.type != TK_UNIFORM) {
diff --git a/servers/xr/xr_interface.cpp b/servers/xr/xr_interface.cpp
index a5ee1d5726..4d58d24405 100644
--- a/servers/xr/xr_interface.cpp
+++ b/servers/xr/xr_interface.cpp
@@ -72,6 +72,8 @@ void XRInterface::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_passthrough_enabled"), &XRInterface::is_passthrough_enabled);
ClassDB::bind_method(D_METHOD("start_passthrough"), &XRInterface::start_passthrough);
ClassDB::bind_method(D_METHOD("stop_passthrough"), &XRInterface::stop_passthrough);
+ ClassDB::bind_method(D_METHOD("get_transform_for_view", "view", "cam_transform"), &XRInterface::get_transform_for_view);
+ ClassDB::bind_method(D_METHOD("get_projection_for_view", "view", "aspect", "near", "far"), &XRInterface::get_projection_for_view);
ADD_GROUP("AR", "ar_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ar_is_anchor_detection_enabled"), "set_anchor_detection_is_enabled", "get_anchor_detection_is_enabled");