feat: updated engine version to 4.4-rc1

This commit is contained in:
Sara 2025-02-23 14:38:14 +01:00
parent ee00efde1f
commit 21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions

View file

@ -30,6 +30,8 @@
#include "visual_instance_3d.h"
#include "core/config/project_settings.h"
AABB VisualInstance3D::get_aabb() const {
AABB ret;
GDVIRTUAL_CALL(_get_aabb, ret);
@ -41,7 +43,38 @@ void VisualInstance3D::_update_visibility() {
return;
}
RS::get_singleton()->instance_set_visible(get_instance(), is_visible_in_tree());
bool already_visible = _is_vi_visible();
bool visible = is_visible_in_tree();
_set_vi_visible(visible);
// If making visible, make sure the rendering server is up to date with the transform.
if (visible && !already_visible) {
if (!_is_using_identity_transform()) {
Transform3D gt = get_global_transform();
RS::get_singleton()->instance_set_transform(instance, gt);
}
}
RS::get_singleton()->instance_set_visible(instance, visible);
}
void VisualInstance3D::_physics_interpolated_changed() {
RenderingServer::get_singleton()->instance_set_interpolated(instance, is_physics_interpolated());
}
void VisualInstance3D::set_instance_use_identity_transform(bool p_enable) {
// Prevent sending instance transforms when using global coordinates.
_set_use_identity_transform(p_enable);
if (is_inside_tree()) {
if (p_enable) {
// Want to make sure instance is using identity transform.
RS::get_singleton()->instance_set_transform(instance, Transform3D());
} else {
// Want to make sure instance is up to date.
RS::get_singleton()->instance_set_transform(instance, get_global_transform());
}
}
}
void VisualInstance3D::_notification(int p_what) {
@ -53,13 +86,39 @@ void VisualInstance3D::_notification(int p_what) {
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
Transform3D gt = get_global_transform();
RenderingServer::get_singleton()->instance_set_transform(instance, gt);
if (_is_vi_visible() || is_physics_interpolated_and_enabled()) {
if (!_is_using_identity_transform()) {
RenderingServer::get_singleton()->instance_set_transform(instance, get_global_transform());
// For instance when first adding to the tree, when the previous transform is
// unset, to prevent streaking from the origin.
if (_is_physics_interpolation_reset_requested() && is_physics_interpolated_and_enabled() && is_inside_tree()) {
if (_is_vi_visible()) {
_notification(NOTIFICATION_RESET_PHYSICS_INTERPOLATION);
}
_set_physics_interpolation_reset_requested(false);
}
}
}
} break;
case NOTIFICATION_RESET_PHYSICS_INTERPOLATION: {
if (_is_vi_visible() && is_physics_interpolated() && is_inside_tree()) {
// We must ensure the RenderingServer transform is up to date before resetting.
// This is because NOTIFICATION_TRANSFORM_CHANGED is deferred,
// and cannot be relied to be called in order before NOTIFICATION_RESET_PHYSICS_INTERPOLATION.
if (!_is_using_identity_transform()) {
RenderingServer::get_singleton()->instance_set_transform(instance, get_global_transform());
}
RenderingServer::get_singleton()->instance_reset_physics_interpolation(instance);
}
} break;
case NOTIFICATION_EXIT_WORLD: {
RenderingServer::get_singleton()->instance_set_scenario(instance, RID());
RenderingServer::get_singleton()->instance_attach_skeleton(instance, RID());
_set_vi_visible(false);
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
@ -382,14 +441,48 @@ AABB GeometryInstance3D::get_custom_aabb() const {
return custom_aabb;
}
void GeometryInstance3D::set_lightmap_texel_scale(float p_scale) {
lightmap_texel_scale = p_scale;
}
float GeometryInstance3D::get_lightmap_texel_scale() const {
return lightmap_texel_scale;
}
#ifndef DISABLE_DEPRECATED
void GeometryInstance3D::set_lightmap_scale(LightmapScale p_scale) {
ERR_FAIL_INDEX(p_scale, LIGHTMAP_SCALE_MAX);
lightmap_scale = p_scale;
switch (p_scale) {
case GeometryInstance3D::LIGHTMAP_SCALE_1X:
lightmap_texel_scale = 1.0f;
break;
case GeometryInstance3D::LIGHTMAP_SCALE_2X:
lightmap_texel_scale = 2.0f;
break;
case GeometryInstance3D::LIGHTMAP_SCALE_4X:
lightmap_texel_scale = 4.0f;
break;
case GeometryInstance3D::LIGHTMAP_SCALE_8X:
lightmap_texel_scale = 8.0f;
break;
case GeometryInstance3D::LIGHTMAP_SCALE_MAX:
break; // Can't happen, but silences warning.
}
}
GeometryInstance3D::LightmapScale GeometryInstance3D::get_lightmap_scale() const {
return lightmap_scale;
// Return closest approximation.
if (lightmap_texel_scale < 1.5f) {
return GeometryInstance3D::LIGHTMAP_SCALE_1X;
} else if (lightmap_texel_scale < 3.0f) {
return GeometryInstance3D::LIGHTMAP_SCALE_2X;
} else if (lightmap_texel_scale < 6.0f) {
return GeometryInstance3D::LIGHTMAP_SCALE_4X;
}
return GeometryInstance3D::LIGHTMAP_SCALE_8X;
}
#endif // DISABLE_DEPRECATED
void GeometryInstance3D::set_gi_mode(GIMode p_mode) {
switch (p_mode) {
@ -424,8 +517,12 @@ bool GeometryInstance3D::is_ignoring_occlusion_culling() {
return ignore_occlusion_culling;
}
Ref<TriangleMesh> GeometryInstance3D::generate_triangle_mesh() const {
return Ref<TriangleMesh>();
}
PackedStringArray GeometryInstance3D::get_configuration_warnings() const {
PackedStringArray warnings = Node::get_configuration_warnings();
PackedStringArray warnings = VisualInstance3D::get_configuration_warnings();
if (!Math::is_zero_approx(visibility_range_end) && visibility_range_end <= visibility_range_begin) {
warnings.push_back(RTR("The GeometryInstance3D visibility range's End distance is set to a non-zero value, but is lower than the Begin distance.\nThis means the GeometryInstance3D will never be visible.\nTo resolve this, set the End distance to 0 or to a value greater than the Begin distance."));
@ -493,8 +590,13 @@ void GeometryInstance3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_extra_cull_margin", "margin"), &GeometryInstance3D::set_extra_cull_margin);
ClassDB::bind_method(D_METHOD("get_extra_cull_margin"), &GeometryInstance3D::get_extra_cull_margin);
ClassDB::bind_method(D_METHOD("set_lightmap_texel_scale", "scale"), &GeometryInstance3D::set_lightmap_texel_scale);
ClassDB::bind_method(D_METHOD("get_lightmap_texel_scale"), &GeometryInstance3D::get_lightmap_texel_scale);
#ifndef DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("set_lightmap_scale", "scale"), &GeometryInstance3D::set_lightmap_scale);
ClassDB::bind_method(D_METHOD("get_lightmap_scale"), &GeometryInstance3D::get_lightmap_scale);
#endif // DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("set_gi_mode", "mode"), &GeometryInstance3D::set_gi_mode);
ClassDB::bind_method(D_METHOD("get_gi_mode"), &GeometryInstance3D::get_gi_mode);
@ -519,7 +621,10 @@ void GeometryInstance3D::_bind_methods() {
ADD_GROUP("Global Illumination", "gi_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "gi_mode", PROPERTY_HINT_ENUM, "Disabled,Static,Dynamic"), "set_gi_mode", "get_gi_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "gi_lightmap_scale", PROPERTY_HINT_ENUM, String::utf8("1×,2×,4×,8×")), "set_lightmap_scale", "get_lightmap_scale");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "gi_lightmap_texel_scale", PROPERTY_HINT_RANGE, "0.01,10,0.0001,or_greater"), "set_lightmap_texel_scale", "get_lightmap_texel_scale");
#ifndef DISABLE_DEPRECATED
ADD_PROPERTY(PropertyInfo(Variant::INT, "gi_lightmap_scale", PROPERTY_HINT_ENUM, String::utf8("1×,2×,4×,8×"), PROPERTY_USAGE_NONE), "set_lightmap_scale", "get_lightmap_scale");
#endif // DISABLE_DEPRECATED
ADD_GROUP("Visibility Range", "visibility_range_");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "visibility_range_begin", PROPERTY_HINT_RANGE, "0.0,4096.0,0.01,or_greater,suffix:m"), "set_visibility_range_begin", "get_visibility_range_begin");