GPv3: Initial Geometry Nodes support #112535
|
@ -404,9 +404,4 @@ bool try_capture_field_on_geometry(GeometryComponent &component,
|
|||
std::optional<eAttrDomain> try_detect_field_domain(const GeometryComponent &component,
|
||||
const fn::GField &field);
|
||||
|
||||
const greasepencil::Drawing *get_eval_grease_pencil_layer_drawing(
|
||||
const GreasePencil &grease_pencil, int layer_index);
|
||||
greasepencil::Drawing *get_eval_grease_pencil_layer_drawing_for_write(GreasePencil &grease_pencil,
|
||||
int layer_index);
|
||||
|
||||
} // namespace blender::bke
|
||||
filedescriptor marked this conversation as resolved
Outdated
|
||||
|
|
|
@ -646,6 +646,10 @@ void legacy_gpencil_to_grease_pencil(Main &main, GreasePencil &grease_pencil, bG
|
|||
|
||||
} // namespace convert
|
||||
|
||||
const Drawing *get_eval_grease_pencil_layer_drawing(const GreasePencil &grease_pencil,
|
||||
int layer_index);
|
||||
Drawing *get_eval_grease_pencil_layer_drawing_for_write(GreasePencil &grease_pencil,
|
||||
int layer_index);
|
||||
} // namespace greasepencil
|
||||
|
||||
class GreasePencilRuntime {
|
||||
|
|
|
@ -35,31 +35,6 @@ CurvesFieldContext::CurvesFieldContext(const CurvesGeometry &curves, const eAttr
|
|||
BLI_assert(curves.attributes().domain_supported(domain));
|
||||
}
|
||||
|
||||
const greasepencil::Drawing *get_eval_grease_pencil_layer_drawing(
|
||||
const GreasePencil &grease_pencil, const int layer_index)
|
||||
{
|
||||
BLI_assert(layer_index >= 0 && layer_index < grease_pencil.layers().size());
|
||||
const bke::greasepencil::Layer &layer = *grease_pencil.layers()[layer_index];
|
||||
const int drawing_index = layer.drawing_index_at(grease_pencil.runtime->eval_frame);
|
||||
if (drawing_index == -1) {
|
||||
return nullptr;
|
||||
}
|
||||
const GreasePencilDrawingBase *drawing_base = grease_pencil.drawing(drawing_index);
|
||||
if (drawing_base->type != GP_DRAWING) {
|
||||
return nullptr;
|
||||
}
|
||||
const bke::greasepencil::Drawing &drawing =
|
||||
reinterpret_cast<const GreasePencilDrawing *>(drawing_base)->wrap();
|
||||
return &drawing;
|
||||
}
|
||||
|
||||
greasepencil::Drawing *get_eval_grease_pencil_layer_drawing_for_write(GreasePencil &grease_pencil,
|
||||
const int layer)
|
||||
{
|
||||
return const_cast<greasepencil::Drawing *>(
|
||||
get_eval_grease_pencil_layer_drawing(grease_pencil, layer));
|
||||
}
|
||||
|
||||
GeometryFieldContext::GeometryFieldContext(const GeometryFieldContext &other,
|
||||
const eAttrDomain domain)
|
||||
: geometry_(other.geometry_),
|
||||
|
@ -172,8 +147,9 @@ std::optional<AttributeAccessor> GeometryFieldContext::attributes() const
|
|||
if (domain_ == ATTR_DOMAIN_GREASE_PENCIL_LAYER) {
|
||||
return grease_pencil->attributes();
|
||||
}
|
||||
else if (const greasepencil::Drawing *drawing = get_eval_grease_pencil_layer_drawing(
|
||||
*grease_pencil, grease_pencil_layer_index_))
|
||||
else if (const greasepencil::Drawing *drawing =
|
||||
greasepencil::get_eval_grease_pencil_layer_drawing(*grease_pencil,
|
||||
grease_pencil_layer_index_))
|
||||
{
|
||||
return drawing->strokes().attributes();
|
||||
}
|
||||
|
@ -214,8 +190,8 @@ const greasepencil::Drawing *GeometryFieldContext::grease_pencil_layer_drawing()
|
|||
{
|
||||
return nullptr;
|
||||
}
|
||||
return get_eval_grease_pencil_layer_drawing(*this->grease_pencil(),
|
||||
this->grease_pencil_layer_index_);
|
||||
return greasepencil::get_eval_grease_pencil_layer_drawing(*this->grease_pencil(),
|
||||
this->grease_pencil_layer_index_);
|
||||
}
|
||||
const CurvesGeometry *GeometryFieldContext::curves_or_strokes() const
|
||||
{
|
||||
|
@ -701,8 +677,9 @@ bool try_capture_field_on_geometry(GeometryComponent &component,
|
|||
bool any_success = false;
|
||||
threading::parallel_for(grease_pencil->layers().index_range(), 8, [&](const IndexRange range) {
|
||||
for (const int layer_index : range) {
|
||||
if (greasepencil::Drawing *drawing = get_eval_grease_pencil_layer_drawing_for_write(
|
||||
*grease_pencil, layer_index))
|
||||
if (greasepencil::Drawing *drawing =
|
||||
greasepencil::get_eval_grease_pencil_layer_drawing_for_write(*grease_pencil,
|
||||
layer_index))
|
||||
{
|
||||
const GeometryFieldContext field_context{*grease_pencil, domain, layer_index};
|
||||
const bool success = try_capture_field_on_geometry(
|
||||
|
|
|
@ -431,6 +431,29 @@ void Drawing::tag_topology_changed()
|
|||
this->tag_positions_changed();
|
||||
}
|
||||
|
||||
const Drawing *get_eval_grease_pencil_layer_drawing(const GreasePencil &grease_pencil,
|
||||
const int layer_index)
|
||||
{
|
||||
BLI_assert(layer_index >= 0 && layer_index < grease_pencil.layers().size());
|
||||
const Layer &layer = *grease_pencil.layers()[layer_index];
|
||||
const int drawing_index = layer.drawing_index_at(grease_pencil.runtime->eval_frame);
|
||||
if (drawing_index == -1) {
|
||||
return nullptr;
|
||||
}
|
||||
const GreasePencilDrawingBase *drawing_base = grease_pencil.drawing(drawing_index);
|
||||
if (drawing_base->type != GP_DRAWING) {
|
||||
return nullptr;
|
||||
}
|
||||
const Drawing &drawing = reinterpret_cast<const GreasePencilDrawing *>(drawing_base)->wrap();
|
||||
return &drawing;
|
||||
}
|
||||
|
||||
Drawing *get_eval_grease_pencil_layer_drawing_for_write(GreasePencil &grease_pencil,
|
||||
const int layer)
|
||||
{
|
||||
return const_cast<Drawing *>(get_eval_grease_pencil_layer_drawing(grease_pencil, layer));
|
||||
}
|
||||
|
||||
TreeNode::TreeNode()
|
||||
{
|
||||
this->next = this->prev = nullptr;
|
||||
|
@ -2044,12 +2067,15 @@ static void fill_reorder_indices_array(const int reorder_from,
|
|||
array_utils::fill_index_range(reorder_indices.slice(IndexRange(start)));
|
||||
reorder_indices[reorder_from] = reorder_to;
|
||||
if (reorder_from < reorder_to) {
|
||||
array_utils::fill_index_range(reorder_indices.slice(IndexRange(reorder_from + 1, dist)), reorder_from);
|
||||
array_utils::fill_index_range(reorder_indices.slice(IndexRange(reorder_from + 1, dist)),
|
||||
reorder_from);
|
||||
}
|
||||
else {
|
||||
array_utils::fill_index_range(reorder_indices.slice(IndexRange(reorder_to, dist)), reorder_to + 1);
|
||||
array_utils::fill_index_range(reorder_indices.slice(IndexRange(reorder_to, dist)),
|
||||
reorder_to + 1);
|
||||
}
|
||||
array_utils::fill_index_range(reorder_indices.slice(IndexRange(end + 1, size - end - 1)), end + 1);
|
||||
array_utils::fill_index_range(reorder_indices.slice(IndexRange(end + 1, size - end - 1)),
|
||||
end + 1);
|
||||
}
|
||||
|
||||
static void reorder_layer_data(GreasePencil &grease_pencil,
|
||||
|
|
|
@ -117,8 +117,8 @@ static void set_position_in_grease_pencil(GreasePencilComponent &grease_pencil_c
|
|||
GreasePencil &grease_pencil = *grease_pencil_component.get_for_write();
|
||||
/* Set position for each layer. */
|
||||
for (const int layer_index : grease_pencil.layers().index_range()) {
|
||||
Drawing *drawing = bke::get_eval_grease_pencil_layer_drawing_for_write(grease_pencil,
|
||||
layer_index);
|
||||
Drawing *drawing = bke::greasepencil::get_eval_grease_pencil_layer_drawing_for_write(
|
||||
grease_pencil, layer_index);
|
||||
if (drawing == nullptr || drawing->strokes().points_num() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
These seem unrelated to "geometry fields." Maybe they should go in the GP headers?