mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 07:53:26 +00:00
Use correct AABB for SpotLight3Ds when spot_angle > 90
This commit is contained in:
parent
b7c5fcaf1e
commit
91167c3c23
2 changed files with 16 additions and 2 deletions
|
@ -350,7 +350,14 @@ AABB LightStorage::light_get_aabb(RID p_light) const {
|
||||||
switch (light->type) {
|
switch (light->type) {
|
||||||
case RS::LIGHT_SPOT: {
|
case RS::LIGHT_SPOT: {
|
||||||
float len = light->param[RS::LIGHT_PARAM_RANGE];
|
float len = light->param[RS::LIGHT_PARAM_RANGE];
|
||||||
float size = Math::tan(Math::deg_to_rad(light->param[RS::LIGHT_PARAM_SPOT_ANGLE])) * len;
|
float angle = Math::deg_to_rad(light->param[RS::LIGHT_PARAM_SPOT_ANGLE]);
|
||||||
|
|
||||||
|
if (angle > Math::PI * 0.5) {
|
||||||
|
// Light casts backwards as well.
|
||||||
|
return AABB(Vector3(-1, -1, -1) * len, Vector3(2, 2, 2) * len);
|
||||||
|
}
|
||||||
|
|
||||||
|
float size = Math::sin(angle) * len;
|
||||||
return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len));
|
return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len));
|
||||||
};
|
};
|
||||||
case RS::LIGHT_OMNI: {
|
case RS::LIGHT_OMNI: {
|
||||||
|
|
|
@ -432,7 +432,14 @@ AABB LightStorage::light_get_aabb(RID p_light) const {
|
||||||
switch (light->type) {
|
switch (light->type) {
|
||||||
case RS::LIGHT_SPOT: {
|
case RS::LIGHT_SPOT: {
|
||||||
float len = light->param[RS::LIGHT_PARAM_RANGE];
|
float len = light->param[RS::LIGHT_PARAM_RANGE];
|
||||||
float size = Math::tan(Math::deg_to_rad(light->param[RS::LIGHT_PARAM_SPOT_ANGLE])) * len;
|
float angle = Math::deg_to_rad(light->param[RS::LIGHT_PARAM_SPOT_ANGLE]);
|
||||||
|
|
||||||
|
if (angle > Math::PI * 0.5) {
|
||||||
|
// Light casts backwards as well.
|
||||||
|
return AABB(Vector3(-1, -1, -1) * len, Vector3(2, 2, 2) * len);
|
||||||
|
}
|
||||||
|
|
||||||
|
float size = Math::sin(angle) * len;
|
||||||
return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len));
|
return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len));
|
||||||
};
|
};
|
||||||
case RS::LIGHT_OMNI: {
|
case RS::LIGHT_OMNI: {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue