GPv3: Add Compound Shapes Rendering (i.e. Hole rendering) #12

Closed
casey-bianco-davis wants to merge 8 commits from GPv3-Compound-Shapes-2 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Showing only changes of commit 674df0b9d8 - Show all commits

View File

@ -1038,10 +1038,9 @@ static void grease_pencil_geom_batch_ensure(Object &object,
ed::greasepencil::retrieve_visible_drawings(scene, grease_pencil, true); ed::greasepencil::retrieve_visible_drawings(scene, grease_pencil, true);
/* First, count how many vertices and triangles are needed for the whole object. Also record the /* First, count how many vertices and triangles are needed for the whole object. Also record the
* offsets into the curves for the vertices and triangles. */ * offsets into the curves for the vertices. */
int total_verts_num = 0; int total_verts_num = 0;
int total_triangles_num = 0; int total_triangles_num = 0;
int v_offset = 0;
Vector<Array<int>> verts_start_offsets_per_visible_drawing; Vector<Array<int>> verts_start_offsets_per_visible_drawing;
for (const ed::greasepencil::DrawingInfo &info : drawings) { for (const ed::greasepencil::DrawingInfo &info : drawings) {
const bke::CurvesGeometry &curves = info.drawing.strokes(); const bke::CurvesGeometry &curves = info.drawing.strokes();
@ -1050,35 +1049,37 @@ static void grease_pencil_geom_batch_ensure(Object &object,
IndexMaskMemory memory; IndexMaskMemory memory;
const IndexMask visible_strokes = ed::greasepencil::retrieve_visible_strokes( const IndexMask visible_strokes = ed::greasepencil::retrieve_visible_strokes(
object, info.drawing, memory); object, info.drawing, memory);
const Span<Vector<uint3>> triangles = info.drawing.triangles();
const Vector<IndexMask> shapes = info.drawing.shapes(memory);
const int num_curves = visible_strokes.size(); Array<int> verts_start_offsets(curves.curves_num(), 0);
const int verts_start_offsets_size = num_curves;
Array<int> verts_start_offsets(verts_start_offsets_size);
/* Calculate the vertex offsets for all the visible curves. */ /* Calculate the vertex offsets for all the visible curves. */
int num_cyclic = 0; int num_cyclic = 0;
int num_points = 0; int num_points = 0;
visible_strokes.foreach_index([&](const int curve_i, const int pos) { for (const int shape_index : shapes.index_range()) {
IndexRange points = points_by_curve[curve_i]; const IndexMask &shape = shapes[shape_index];
const bool is_cyclic = cyclic[curve_i] && (points.size() > 2);
if (is_cyclic) { total_triangles_num += triangles[shape_index].size();
num_cyclic++;
}
verts_start_offsets[pos] = v_offset; shape.foreach_index([&](const int curve_i) {
v_offset += 1 + points.size() + (is_cyclic ? 1 : 0) + 1; IndexRange points = points_by_curve[curve_i];
num_points += points.size(); const bool is_cyclic = cyclic[curve_i] && (points.size() > 2);
});
/* One vertex is stored before and after as padding. Cyclic strokes have one extra vertex. */ if (is_cyclic) {
total_verts_num += num_points + num_cyclic + num_curves * 2; num_cyclic++;
total_triangles_num += (num_points + num_cyclic) * 2; }
for (const int group_id : info.drawing.triangles().index_range()) { verts_start_offsets[curve_i] = total_verts_num;
total_triangles_num += info.drawing.triangles()[group_id].size(); /* One vertex is stored before and after as padding. Cyclic strokes have one extra vertex.
*/
total_verts_num += 1 + points.size() + (is_cyclic ? 1 : 0) + 1;
num_points += points.size();
});
} }
total_triangles_num += (num_points + num_cyclic) * 2;
verts_start_offsets_per_visible_drawing.append(std::move(verts_start_offsets)); verts_start_offsets_per_visible_drawing.append(std::move(verts_start_offsets));
} }