GPv3: Initial Geometry Nodes support #112535
|
@ -42,8 +42,8 @@ typedef enum eAttrDomainMask {
|
|||
ATTR_DOMAIN_MASK_FACE = (1 << 2),
|
||||
ATTR_DOMAIN_MASK_CORNER = (1 << 3),
|
||||
ATTR_DOMAIN_MASK_CURVE = (1 << 4),
|
||||
ATTR_DOMAIN_MASK_GREASE_PENCIL_LAYER = (1 << 5),
|
||||
ATTR_DOMAIN_MASK_ALL = (1 << 6) - 1
|
||||
ATTR_DOMAIN_MASK_GREASE_PENCIL_LAYER = (1 << 6),
|
||||
ATTR_DOMAIN_MASK_ALL = (1 << 7) - 1
|
||||
} eAttrDomainMask;
|
||||
ENUM_OPERATORS(eAttrDomainMask, ATTR_DOMAIN_MASK_ALL);
|
||||
|
||||
|
|
|
@ -719,6 +719,9 @@ class GreasePencilComponent : public GeometryComponent {
|
|||
void ensure_owns_direct_data() override;
|
||||
|
||||
static constexpr inline GeometryComponent::Type static_type = Type::GreasePencil;
|
||||
|
||||
std::optional<AttributeAccessor> attributes() const final;
|
||||
std::optional<MutableAttributeAccessor> attributes_for_write() final;
|
||||
};
|
||||
|
||||
} // namespace blender::bke
|
||||
|
|
|
@ -96,6 +96,7 @@ static void get_domains(const ID *id, DomainInfo info[ATTR_DOMAIN_NUM])
|
|||
GreasePencil *grease_pencil = (GreasePencil *)id;
|
||||
info[ATTR_DOMAIN_GREASE_PENCIL_LAYER].customdata = &grease_pencil->layers_data;
|
||||
info[ATTR_DOMAIN_GREASE_PENCIL_LAYER].length = grease_pencil->layers().size();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
@ -123,6 +124,10 @@ static std::optional<blender::bke::MutableAttributeAccessor> get_attribute_acces
|
|||
CurvesGeometry &curves = curves_id.geometry.wrap();
|
||||
return curves.attributes_for_write();
|
||||
}
|
||||
case ID_GP: {
|
||||
GreasePencil &grease_pencil = reinterpret_cast<GreasePencil &>(id);
|
||||
return grease_pencil.attributes_for_write();
|
||||
}
|
||||
default: {
|
||||
BLI_assert_unreachable();
|
||||
return {};
|
||||
|
@ -717,6 +722,9 @@ int *BKE_id_attributes_active_index_p(ID *id)
|
|||
case ID_CV: {
|
||||
return &((Curves *)id)->attributes_active_index;
|
||||
}
|
||||
case ID_GP: {
|
||||
return &((GreasePencil *)id)->attributes_active_index;
|
||||
}
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -197,3 +197,18 @@ blender::bke::MutableAttributeAccessor GreasePencil::attributes_for_write()
|
|||
return blender::bke::MutableAttributeAccessor(
|
||||
this, blender::bke::get_grease_pencil_accessor_functions_ref());
|
||||
}
|
||||
|
||||
namespace blender::bke {
|
||||
|
||||
std::optional<AttributeAccessor> GreasePencilComponent::attributes() const
|
||||
{
|
||||
return AttributeAccessor(grease_pencil_, get_grease_pencil_accessor_functions_ref());
|
||||
}
|
||||
|
||||
std::optional<MutableAttributeAccessor> GreasePencilComponent::attributes_for_write()
|
||||
{
|
||||
GreasePencil *grease_pencil = this->get_for_write();
|
||||
return MutableAttributeAccessor(grease_pencil, get_grease_pencil_accessor_functions_ref());
|
||||
}
|
||||
|
||||
} // namespace blender::bke
|
|
@ -126,7 +126,6 @@ static void grease_pencil_copy_data(Main * /*bmain*/,
|
|||
grease_pencil_dst->find_layer_by_name(grease_pencil_src->active_layer->wrap().name()));
|
||||
}
|
||||
|
||||
CustomData_free(&grease_pencil_dst->layers_data, grease_pencil_dst->layers().size());
|
||||
CustomData_copy(&grease_pencil_src->layers_data,
|
||||
&grease_pencil_dst->layers_data,
|
||||
CD_MASK_ALL,
|
||||
|
@ -1063,8 +1062,10 @@ GreasePencil *BKE_grease_pencil_new_nomain()
|
|||
|
||||
GreasePencil *BKE_grease_pencil_copy_for_eval(const GreasePencil *grease_pencil_src)
|
||||
{
|
||||
return reinterpret_cast<GreasePencil *>(
|
||||
GreasePencil *grease_pencil = reinterpret_cast<GreasePencil *>(
|
||||
BKE_id_copy_ex(nullptr, &grease_pencil_src->id, nullptr, LIB_ID_COPY_LOCALIZE));
|
||||
grease_pencil->runtime->eval_frame = grease_pencil_src->runtime->eval_frame;
|
||||
return grease_pencil;
|
||||
}
|
||||
|
||||
BoundBox *BKE_grease_pencil_boundbox_get(Object *ob)
|
||||
|
@ -1132,6 +1133,8 @@ void BKE_grease_pencil_data_update(Depsgraph *depsgraph, Scene *scene, Object *o
|
|||
|
||||
/* Evaluate modifiers. */
|
||||
GreasePencil *grease_pencil = static_cast<GreasePencil *>(object->data);
|
||||
/* Store the frame that this grease pencil is evaluated on. */
|
||||
grease_pencil->runtime->eval_frame = int(DEG_get_ctime(depsgraph));
|
||||
GeometrySet geometry_set = GeometrySet::from_grease_pencil(grease_pencil,
|
||||
GeometryOwnershipType::ReadOnly);
|
||||
grease_pencil_evaluate_modifiers(depsgraph, scene, object, geometry_set);
|
||||
|
@ -1144,9 +1147,6 @@ void BKE_grease_pencil_data_update(Depsgraph *depsgraph, Scene *scene, Object *o
|
|||
* would result in a copy when it's shared. So for now, we use a const_cast here. */
|
||||
GreasePencil *grease_pencil_eval = const_cast<GreasePencil *>(geometry_set.get_grease_pencil());
|
||||
|
||||
/* Store the frame that this grease pencil data was evaluated on. */
|
||||
grease_pencil_eval->runtime->eval_frame = int(DEG_get_ctime(depsgraph));
|
||||
|
||||
/* Assign evaluated object. */
|
||||
BKE_object_eval_assign_data(object, &grease_pencil_eval->id, false);
|
||||
object->runtime.geometry_set_eval = new GeometrySet(std::move(geometry_set));
|
||||
|
|
|
@ -407,6 +407,11 @@ typedef struct GreasePencil {
|
|||
* All attributes stored on the grease pencil layers (#ATTR_DOMAIN_GREASE_PENCIL_LAYER).
|
||||
*/
|
||||
CustomData layers_data;
|
||||
/**
|
||||
* The index of the active attribute in the UI.
|
||||
*/
|
||||
int attributes_active_index;
|
||||
char _pad2[4];
|
||||
|
||||
/**
|
||||
* Pointer to the active layer. Can be NULL.
|
||||
|
@ -419,7 +424,7 @@ typedef struct GreasePencil {
|
|||
*/
|
||||
struct Material **material_array;
|
||||
short material_array_num;
|
||||
char _pad2[2];
|
||||
char _pad3[2];
|
||||
/**
|
||||
* Global flag on the data-block.
|
||||
*/
|
||||
|
|
|
@ -88,6 +88,11 @@ const EnumPropertyItem rna_enum_attribute_domain_items[] = {
|
|||
// {ATTR_DOMAIN_GRIDS, "GRIDS", 0, "Grids", "Attribute on mesh multires grids"},
|
||||
{ATTR_DOMAIN_CURVE, "CURVE", 0, "Spline", "Attribute on spline"},
|
||||
{ATTR_DOMAIN_INSTANCE, "INSTANCE", 0, "Instance", "Attribute on instance"},
|
||||
{ATTR_DOMAIN_GREASE_PENCIL_LAYER,
|
||||
"GREASE_PENCIL_LAYER",
|
||||
0,
|
||||
"Grease Pencil Layer",
|
||||
"Attribute on grease pencil layer"},
|
||||
{0, nullptr, 0, nullptr, nullptr},
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue