Fix: Draw: Bounds usage #128125
@ -22,7 +22,7 @@ void main()
|
||||
}
|
||||
|
||||
ObjectBounds bounds = bounds_buf[index];
|
||||
if (!drw_bounds_are_valid(bounds) || bounds._inner_sphere_radius <= 0.0) {
|
||||
if (!drw_bounds_are_valid(bounds)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ shared int global_max;
|
||||
|
||||
void main()
|
||||
{
|
||||
IsectBox box;
|
||||
Box box;
|
||||
bool is_valid = true;
|
||||
|
||||
if (resource_len > 0) {
|
||||
@ -31,16 +31,18 @@ void main()
|
||||
resource_id = (resource_id & 0x7FFFFFFFu);
|
||||
|
||||
ObjectBounds bounds = bounds_buf[resource_id];
|
||||
is_valid = drw_bounds_are_valid(bounds);
|
||||
box = isect_box_setup(bounds.bounding_corners[0].xyz,
|
||||
bounds.bounding_corners[1].xyz,
|
||||
bounds.bounding_corners[2].xyz,
|
||||
bounds.bounding_corners[3].xyz);
|
||||
is_valid = drw_bounds_corners_are_valid(bounds);
|
||||
box = shape_box(bounds.bounding_corners[0].xyz,
|
||||
bounds.bounding_corners[0].xyz + bounds.bounding_corners[1].xyz,
|
||||
bounds.bounding_corners[0].xyz + bounds.bounding_corners[2].xyz,
|
||||
bounds.bounding_corners[0].xyz + bounds.bounding_corners[3].xyz);
|
||||
}
|
||||
else {
|
||||
/* Create a dummy box so initialization happens even when there are no shadow casters. */
|
||||
box = isect_box_setup(
|
||||
vec3(-1.0), vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, 0.0, 1.0));
|
||||
box = shape_box(vec3(-1.0),
|
||||
vec3(-1.0) + vec3(1.0, 0.0, 0.0),
|
||||
vec3(-1.0) + vec3(0.0, 1.0, 0.0),
|
||||
vec3(-1.0) + vec3(0.0, 0.0, 1.0));
|
||||
}
|
||||
|
||||
LIGHT_FOREACH_BEGIN_DIRECTIONAL (light_cull_buf, l_idx) {
|
||||
|
@ -205,15 +205,18 @@ struct ObjectBounds {
|
||||
BLI_STATIC_ASSERT_ALIGN(ObjectBounds, 16)
|
||||
|
||||
/* Return true if `bounding_corners` are valid. Should be checked before accessing them.
|
||||
* Does not guarantee that `bounding_sphere` is valid. */
|
||||
inline bool drw_bounds_are_valid(ObjectBounds bounds)
|
||||
* Does not guarantee that `bounding_sphere` is valid.
|
||||
* Converting these bounds to an `IsectBox` may generate invalid clip planes.
|
||||
* For safe `IsectBox` generation check `drw_bounds_are_valid`. */
|
||||
inline bool drw_bounds_corners_are_valid(ObjectBounds bounds)
|
||||
{
|
||||
return bounds.bounding_sphere.w != -1.0f;
|
||||
}
|
||||
|
||||
|
||||
/* Return true if bounds are ready for culling.
|
||||
* In this case, both `bounding_corners` and `bounding_sphere` are valid. */
|
||||
inline bool drw_bounds_culling_enabled(ObjectBounds bounds)
|
||||
* In this case, both `bounding_corners` and `bounding_sphere` are valid.
|
||||
* These bounds can be safely converted to an `IsectBox` with valid clip planes. */
|
||||
inline bool drw_bounds_are_valid(ObjectBounds bounds)
|
||||
{
|
||||
return bounds.bounding_sphere.w >= 0.0f;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ void main()
|
||||
ObjectInfos infos = infos_buf[resource_id];
|
||||
ObjectBounds bounds = bounds_buf[resource_id];
|
||||
|
||||
if (drw_bounds_are_valid(bounds)) {
|
||||
if (drw_bounds_corners_are_valid(bounds)) {
|
||||
/* Convert corners to origin + sides in world space. */
|
||||
vec3 p0 = bounds.bounding_corners[0].xyz;
|
||||
vec3 p01 = bounds.bounding_corners[1].xyz - p0;
|
||||
|
@ -32,7 +32,7 @@ void main()
|
||||
|
||||
ObjectBounds bounds = bounds_buf[gl_GlobalInvocationID.x];
|
||||
|
||||
if (drw_bounds_culling_enabled(bounds)) {
|
||||
if (drw_bounds_are_valid(bounds)) {
|
||||
IsectBox box = isect_box_setup(bounds.bounding_corners[0].xyz,
|
||||
bounds.bounding_corners[1].xyz,
|
||||
bounds.bounding_corners[2].xyz,
|
||||
|
Loading…
Reference in New Issue
Block a user
Maybe we can add something like
Converting these bounds to #IsectBox will result if valid clip planes.
and the inverse fordrw_bounds_corners_are_valid
pointing todrw_bounds_are_valid
.