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,7 @@
#include "gltf_light.h"
#include "../structures/gltf_object_model_property.h"
#include "scene/3d/light_3d.h"
void GLTFLight::_bind_methods() {
@ -62,6 +63,21 @@ void GLTFLight::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "outer_cone_angle"), "set_outer_cone_angle", "get_outer_cone_angle"); // float
}
void GLTFLight::set_cone_inner_attenuation_conversion_expressions(Ref<GLTFObjectModelProperty> &r_obj_model_prop) {
// Expression to convert glTF innerConeAngle to Godot spot_angle_attenuation.
Ref<Expression> gltf_to_godot_expr;
gltf_to_godot_expr.instantiate();
PackedStringArray gltf_to_godot_args = { "inner_cone_angle" };
gltf_to_godot_expr->parse("0.2 / (1.0 - inner_cone_angle / spot_angle) - 0.1", gltf_to_godot_args);
r_obj_model_prop->set_gltf_to_godot_expression(gltf_to_godot_expr);
// Expression to convert Godot spot_angle_attenuation to glTF innerConeAngle.
Ref<Expression> godot_to_gltf_expr;
godot_to_gltf_expr.instantiate();
PackedStringArray godot_to_gltf_args = { "godot_spot_angle_att" };
godot_to_gltf_expr->parse("spot_angle * maxf(0.0, 1.0 - (0.2 / (0.1 + godot_spot_angle_att)))", godot_to_gltf_args);
r_obj_model_prop->set_godot_to_gltf_expression(godot_to_gltf_expr);
}
Color GLTFLight::get_color() {
return color;
}
@ -170,7 +186,7 @@ Light3D *GLTFLight::to_node() const {
}
Ref<GLTFLight> GLTFLight::from_dictionary(const Dictionary p_dictionary) {
ERR_FAIL_COND_V_MSG(!p_dictionary.has("type"), Ref<GLTFLight>(), "Failed to parse GLTF light, missing required field 'type'.");
ERR_FAIL_COND_V_MSG(!p_dictionary.has("type"), Ref<GLTFLight>(), "Failed to parse glTF light, missing required field 'type'.");
Ref<GLTFLight> light;
light.instantiate();
const String &type = p_dictionary["type"];
@ -181,7 +197,7 @@ Ref<GLTFLight> GLTFLight::from_dictionary(const Dictionary p_dictionary) {
if (arr.size() == 3) {
light->color = Color(arr[0], arr[1], arr[2]).linear_to_srgb();
} else {
ERR_PRINT("Error parsing GLTF light: The color must have exactly 3 numbers.");
ERR_PRINT("Error parsing glTF light: The color must have exactly 3 numbers.");
}
}
if (p_dictionary.has("intensity")) {
@ -195,31 +211,37 @@ Ref<GLTFLight> GLTFLight::from_dictionary(const Dictionary p_dictionary) {
light->inner_cone_angle = spot["innerConeAngle"];
light->outer_cone_angle = spot["outerConeAngle"];
if (light->inner_cone_angle >= light->outer_cone_angle) {
ERR_PRINT("Error parsing GLTF light: The inner angle must be smaller than the outer angle.");
ERR_PRINT("Error parsing glTF light: The inner angle must be smaller than the outer angle.");
}
} else if (type != "point" && type != "directional") {
ERR_PRINT("Error parsing GLTF light: Light type '" + type + "' is unknown.");
ERR_PRINT("Error parsing glTF light: Light type '" + type + "' is unknown.");
}
return light;
}
Dictionary GLTFLight::to_dictionary() const {
Dictionary d;
Array color_array;
color_array.resize(3);
color_array[0] = color.r;
color_array[1] = color.g;
color_array[2] = color.b;
d["color"] = color_array;
d["type"] = light_type;
if (color != Color(1.0f, 1.0f, 1.0f)) {
Array color_array;
color_array.resize(3);
color_array[0] = color.r;
color_array[1] = color.g;
color_array[2] = color.b;
d["color"] = color_array;
}
if (intensity != 1.0f) {
d["intensity"] = intensity;
}
if (light_type != "directional" && range != INFINITY) {
d["range"] = range;
}
if (light_type == "spot") {
Dictionary spot_dict;
spot_dict["innerConeAngle"] = inner_cone_angle;
spot_dict["outerConeAngle"] = outer_cone_angle;
d["spot"] = spot_dict;
}
d["intensity"] = intensity;
d["range"] = range;
d["type"] = light_type;
return d;
}