Merge branch 'blender-v5.0-release'

This commit is contained in:
Miguel Pozo
2025-10-09 17:00:34 +02:00
4 changed files with 24 additions and 18 deletions

View File

@@ -210,8 +210,8 @@ class Outline : Overlay {
for (FlatObjectRef flag_ob_ref : flat_objects_) {
flag_ob_ref.if_flat_axis_orthogonal_to_view(
manager, view, [&](gpu::Batch *geom, ResourceHandleRange handle) {
pass.draw_expand(geom, GPU_PRIM_LINES, 1, 1, handle);
manager, view, [&](gpu::Batch *geom, ResourceIndex resource_index) {
pass.draw_expand(geom, GPU_PRIM_LINES, 1, 1, resource_index);
});
}
}

View File

@@ -1014,24 +1014,26 @@ struct FlatObjectRef {
return -1;
}
using Callback = FunctionRef<void(gpu::Batch *geom, ResourceHandleRange handle)>;
using Callback = FunctionRef<void(gpu::Batch *geom, ResourceIndex handle)>;
/* Execute callback for every handles that is orthogonal to the view.
* Note: Only works in orthogonal view. */
void if_flat_axis_orthogonal_to_view(Manager &manager, const View &view, Callback callback) const
{
const float4x4 &object_to_world =
manager.matrix_buf.current().get_or_resize(handle.resource_index()).model;
for (ResourceIndex resource_index : handle.index_range()) {
const float4x4 &object_to_world =
manager.matrix_buf.current().get_or_resize(resource_index.resource_index()).model;
float3 view_forward = view.forward();
float3 axis_not_flat_a = (flattened_axis_id == 0) ? object_to_world.y_axis() :
object_to_world.x_axis();
float3 axis_not_flat_b = (flattened_axis_id == 1) ? object_to_world.z_axis() :
object_to_world.y_axis();
float3 axis_flat = math::cross(axis_not_flat_a, axis_not_flat_b);
float3 view_forward = view.forward();
float3 axis_not_flat_a = (flattened_axis_id == 0) ? object_to_world.y_axis() :
object_to_world.x_axis();
float3 axis_not_flat_b = (flattened_axis_id == 1) ? object_to_world.z_axis() :
object_to_world.y_axis();
float3 axis_flat = math::cross(axis_not_flat_a, axis_not_flat_b);
if (math::abs(math::dot(view_forward, axis_flat)) < 1e-3f) {
callback(geom, handle);
if (math::abs(math::dot(view_forward, axis_flat)) < 1e-3f) {
callback(geom, resource_index);
}
}
}
};

View File

@@ -107,7 +107,7 @@ void geometry_main(VertOut geom_in[4],
float fac3 = dot(view_vec, n3);
/* If one of the face is perpendicular to the view,
* consider it and outline edge. */
* consider it an outline edge. */
if (abs(fac0) > 1e-5f && abs(fac3) > 1e-5f) {
/* If both adjacent verts are facing the camera the same way,
* then it isn't an outline edge. */

View File

@@ -91,10 +91,14 @@ void geometry_main(VertOut geom_in[4],
float fac0 = dot(view_vec, n0);
float fac3 = dot(view_vec, n3);
/* If both adjacent verts are facing the camera the same way,
* then it isn't an outline edge. */
if (sign(fac0) == sign(fac3)) {
return;
/* If one of the face is perpendicular to the view,
* consider it an outline edge. */
if (abs(fac0) > 1e-5f && abs(fac3) > 1e-5f) {
/* If both adjacent verts are facing the camera the same way,
* then it isn't an outline edge. */
if (sign(fac0) == sign(fac3)) {
return;
}
}
VertOut export_vert = (out_vertex_id == 0) ? geom_in[1] : geom_in[2];