Initial Grease Pencil 3.0 stage #106848

Merged
Falk David merged 224 commits from filedescriptor/blender:grease-pencil-v3 into main 2023-05-30 11:14:22 +02:00
2 changed files with 32 additions and 20 deletions
Showing only changes of commit 0460a4c1a0 - Show all commits

View File

@ -702,26 +702,9 @@ BoundBox *BKE_grease_pencil_boundbox_get(Object *ob)
float3 min(FLT_MAX);
float3 max(-FLT_MAX);
/* FIXME: this should somehow go through the visible drawings. We don't have access to the
* scene time here, so we probably need to cache the visible drawing for each layer somehow. */
for (int i = 0; i < grease_pencil->drawing_array_size; i++) {
GreasePencilDrawingBase *drawing_base = grease_pencil->drawing_array[i];
switch (drawing_base->type) {
case GP_DRAWING: {
GreasePencilDrawing *drawing = reinterpret_cast<GreasePencilDrawing *>(drawing_base);
const blender::bke::CurvesGeometry &curves = drawing->geometry.wrap();
if (!curves.bounds_min_max(min, max)) {
blender::math::min_max(float3(-1), min, max);
blender::math::min_max(float3(1), min, max);
}
break;
}
case GP_DRAWING_REFERENCE: {
/* TODO: Calculate the bounding box of the reference drawing. */
break;
}
}
if (!grease_pencil->bounds_min_max(min, max)) {
min = float3(-1);
max = float3(1);
}
BKE_boundbox_init_from_minmax(ob->runtime.bb, min, max);
@ -1003,6 +986,33 @@ void GreasePencil::foreach_visible_drawing(
}
}

Pass a slice of the result vector to BLI_polyfill_calc_arena directly rather than allocating a temporary array here

Pass a slice of the result vector to `BLI_polyfill_calc_arena` directly rather than allocating a temporary array here
bool GreasePencil::bounds_min_max(float3 &min, float3 &max) const
{
bool found = false;
/* FIXME: this should somehow go through the visible drawings. We don't have access to the
* scene time here, so we probably need to cache the visible drawing for each layer somehow. */
for (int i = 0; i < this->drawing_array_size; i++) {
GreasePencilDrawingBase *drawing_base = this->drawing_array[i];
switch (drawing_base->type) {
case GP_DRAWING: {
GreasePencilDrawing *drawing = reinterpret_cast<GreasePencilDrawing *>(drawing_base);
const blender::bke::CurvesGeometry &curves = drawing->geometry.wrap();
if (curves.bounds_min_max(min, max)) {
found = true;
}
break;
}
case GP_DRAWING_REFERENCE: {
/* TODO: Calculate the bounding box of the reference drawing. */
break;
}
}
}
return found;
}
const blender::bke::greasepencil::LayerGroup &GreasePencil::root_group() const
{
BLI_assert(this->runtime != nullptr);

View File

@ -466,6 +466,8 @@ typedef struct GreasePencil {
void foreach_visible_drawing(int frame,
blender::FunctionRef<void(GreasePencilDrawing &)> function);
bool bounds_min_max(blender::float3 &min, blender::float3 &max) const;
/* For debugging purposes. */
void print_layer_tree();
#endif