36#include "RNA_prototypes.hh"
57 if (
self ==
nullptr) {
61 self->instances_pointcloud =
nullptr;
65 self->geometry.ensure_no_shared_components();
71 static const char *kwlist[] = {
nullptr};
72 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"",
const_cast<char **
>(kwlist))) {
80 std::destroy_at(&
self->geometry);
81 if (
self->instances_pointcloud) {
84 Py_TYPE(
self)->tp_free(
reinterpret_cast<PyObject *
>(
self));
89 bpy_geometry_set_from_evaluated_object_doc,
90 ".. staticmethod:: from_evaluated_object(evaluated_object)\n"
92 " Create a geometry set from the evaluated geometry of an evaluated object.\n"
93 " Typically, it's more convenient to use :func:`bpy.types.Object.evaluated_geometry`.\n"
95 " :arg evaluated_object: The evaluated object to create a geometry set from.\n"
96 " :type evaluated_object: bpy.types.Object\n");
102 static const char *kwlist[] = {
"evaluated_object",
nullptr};
103 PyObject *py_evaluated_object;
104 if (!PyArg_ParseTupleAndKeywords(
105 args, kwds,
"O",
const_cast<char **
>(kwlist), &py_evaluated_object))
109 ID *evaluated_object_id =
nullptr;
112 PyExc_TypeError,
"Expected an Object, not %.200s", Py_TYPE(py_evaluated_object)->tp_name);
117 PyErr_Format(PyExc_TypeError,
118 "Expected an Object, not %.200s",
122 Object *evaluated_object =
reinterpret_cast<Object *
>(evaluated_object_id);
124 PyErr_SetString(PyExc_TypeError,
"Expected an evaluated object");
127 const bool is_instance_collection = evaluated_object->
type ==
OB_EMPTY &&
130 is_instance_collection;
131 if (!valid_object_type) {
132 const char *ob_type_name =
"<unknown>";
134 PyErr_Format(PyExc_TypeError,
"Expected a geometry object, not %.200s", ob_type_name);
138 PyErr_SetString(PyExc_TypeError,
139 "Object geometry is not yet evaluated, is the depsgraph evaluated?");
144 PyErr_SetString(PyExc_TypeError,
"Object is not owned by a depsgraph");
150 if (is_instance_collection) {
154 geometry.replace_instances(instances);
170 std::stringstream ss;
171 ss <<
self->geometry;
172 std::string
str = ss.str();
178 bpy_geometry_set_get_instances_pointcloud_doc,
179 ".. method:: instances_pointcloud()\n"
181 " Get a pointcloud that encodes information about the instances of the geometry.\n"
182 " The returned pointcloud should not be modified.\n"
183 " There is a point per instance and per-instance data is stored in point attributes.\n"
184 " The local transforms are stored in the ``instance_transform`` attribute.\n"
185 " The data instanced by each point is referenced by the ``.reference_index`` attribute,\n"
186 " indexing into the list returned by :func:`bpy.types.GeometrySet.instance_references`.\n"
188 " :rtype: bpy.types.PointCloud\n");
196 if (
self->instances_pointcloud ==
nullptr) {
204 pointcloud->attributes_for_write());
205 self->instances_pointcloud = pointcloud;
212 bpy_geometry_set_get_instance_references_doc,
213 ".. method:: instance_references()\n"
215 " This returns a list of geometries that is indexed by the ``.reference_index``\n"
216 " attribute of the pointcloud returned by \n"
217 " :func:`bpy.types.GeometrySet.instances_pointcloud`.\n"
218 " It may contain other geometry sets, objects, collections and None values.\n"
220 " :rtype: list[None | bpy.types.Object | bpy.types.Collection | bpy.types.GeometrySet]\n");
226 return PyList_New(0);
229 PyObject *py_references = PyList_New(references.
size());
232 switch (reference.
type()) {
234 PyList_SET_ITEM(py_references,
i, Py_NewRef(Py_None));
254 return py_references;
259 bpy_geometry_set_name_doc,
260 "The name of the geometry set. It can be used for debugging purposes and is not unique.\n"
270 if (!PyUnicode_Check(value)) {
271 PyErr_SetString(PyExc_TypeError,
"expected a string");
274 const char *
name = PyUnicode_AsUTF8(value);
281 bpy_geometry_set_mesh_doc,
282 "The mesh data-block in the geometry set.\n"
284 ":type: :class:`bpy.types.Mesh`\n");
287 Mesh *base_mesh =
self->geometry.get_mesh_for_write();
297 bpy_geometry_set_mesh_base_doc,
298 "The mesh data-block in the geometry set without final subdivision.\n"
300 ":type: :class:`bpy.types.Mesh`\n");
303 Mesh *base_mesh =
self->geometry.get_mesh_for_write();
309 bpy_geometry_set_pointcloud_doc,
310 "The point cloud data-block in the geometry set.\n"
312 ":type: :class:`bpy.types.PointCloud`\n");
316 reinterpret_cast<ID *
>(
self->geometry.get_pointcloud_for_write()));
321 bpy_geometry_set_curves_doc,
322 "The curves data-block in the geometry set.\n"
324 ":type: :class:`bpy.types.Curves`\n");
332 bpy_geometry_set_volume_doc,
333 "The volume data-block in the geometry set.\n"
335 ":type: :class:`bpy.types.Volume`\n");
343 bpy_geometry_set_grease_pencil_doc,
344 "The Grease Pencil data-block in the geometry set.\n"
346 ":type: :class:`bpy.types.GreasePencil`\n");
350 reinterpret_cast<ID *
>(
self->geometry.get_grease_pencil_for_write()));
358 bpy_geometry_set_name_doc,
365 bpy_geometry_set_mesh_doc,
372 bpy_geometry_set_mesh_base_doc,
379 bpy_geometry_set_pointcloud_doc,
386 bpy_geometry_set_curves_doc,
393 bpy_geometry_set_volume_doc,
400 bpy_geometry_set_grease_pencil_doc,
409# pragma clang diagnostic push
410# pragma clang diagnostic ignored "-Wcast-function-type"
412# pragma GCC diagnostic push
413# pragma GCC diagnostic ignored "-Wcast-function-type"
418 {
"from_evaluated_object",
420 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
421 bpy_geometry_set_from_evaluated_object_doc},
422 {
"instances_pointcloud",
425 bpy_geometry_set_get_instances_pointcloud_doc},
426 {
"instance_references",
429 bpy_geometry_set_get_instance_references_doc},
430 {
nullptr,
nullptr, 0,
nullptr},
435# pragma clang diagnostic pop
437# pragma GCC diagnostic pop
443 bpy_geometry_set_doc,
444 "Stores potentially multiple geometry components of different types.\n"
445 "For example, it might contain a mesh, curves and nested instances.\n");
447 PyVarObject_HEAD_INIT(
nullptr, 0)
466 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
467 bpy_geometry_set_doc,
blender::bke::Instances object_duplilist_legacy_instances(Depsgraph &depsgraph, Scene &scene, Object &ob)
const char * BKE_idtype_idcode_to_name(short idcode)
void BKE_id_free(Main *bmain, void *idv)
Mesh * BKE_mesh_wrapper_ensure_subdivision(Mesh *mesh)
General operations for point clouds.
PointCloud * BKE_pointcloud_new_nomain(int totpoint)
bool DEG_is_evaluated(const T *id)
Depsgraph * DEG_get_depsgraph_by_id(const ID &id)
bool DEG_object_geometry_is_evaluated(const Object &object)
Scene * DEG_get_input_scene(const Depsgraph *graph)
ID and Library types, which are fundamental for SDNA.
Object groups, one object can be in many groups at once.
Object is a sort of wrapper for general info.
#define OB_TYPE_IS_GEOMETRY(_type)
BPy_StructRNA * depsgraph
PyDoc_STRVAR(bpy_geometry_set_from_evaluated_object_doc, ".. staticmethod:: from_evaluated_object(evaluated_object)\n" "\n" " Create a geometry set from the evaluated geometry of an evaluated object.\n" " Typically, it's more convenient to use :func:`bpy.types.Object.evaluated_geometry`.\n" "\n" " :arg evaluated_object: The evaluated object to create a geometry set from.\n" " :type evaluated_object: bpy.types.Object\n")
static void BPy_GeometrySet_dealloc(BPy_GeometrySet *self)
static PyObject * BPy_GeometrySet_get_pointcloud(BPy_GeometrySet *self, void *)
PyObject * BPyInit_geometry_set_type()
static PyObject * BPy_GeometrySet_new(PyTypeObject *, PyObject *args, PyObject *kwds)
static BPy_GeometrySet * BPy_GeometrySet_static_from_evaluated_object(PyObject *, PyObject *args, PyObject *kwds)
static PyObject * BPy_GeometrySet_get_name(BPy_GeometrySet *self, void *)
static PyObject * BPy_GeometrySet_get_mesh_base(BPy_GeometrySet *self, void *)
static PyObject * BPy_GeometrySet_get_instances_pointcloud(BPy_GeometrySet *self)
static PyObject * BPy_GeometrySet_get_volume(BPy_GeometrySet *self, void *)
PyTypeObject bpy_geometry_set_Type
static PyObject * BPy_GeometrySet_get_curves(BPy_GeometrySet *self, void *)
static PyObject * BPy_GeometrySet_get_grease_pencil(BPy_GeometrySet *self, void *)
static PyObject * BPy_GeometrySet_get_mesh(BPy_GeometrySet *self, void *)
static PyGetSetDef BPy_GeometrySet_getseters[]
static PyObject * BPy_GeometrySet_repr(BPy_GeometrySet *self)
static PyMethodDef BPy_GeometrySet_methods[]
static PyObject * BPy_GeometrySet_get_instance_references(BPy_GeometrySet *self)
static int BPy_GeometrySet_set_name(BPy_GeometrySet *self, PyObject *value, void *)
static BPy_GeometrySet * python_object_from_geometry_set(GeometrySet geometry={})
constexpr int64_t size() const
constexpr IndexRange index_range() const
GeometrySet & geometry_set()
Collection & collection() const
int add_new_reference(const InstanceReference &reference)
void add_instance(int instance_handle, const float4x4 &transform)
Span< InstanceReference > references() const
bke::AttributeAccessor attributes() const
int instances_num() const
PyObject * pyrna_id_CreatePyObject(ID *id)
bool pyrna_id_FromPyObject(PyObject *obj, ID **id)
void gather_attributes(AttributeAccessor src_attributes, AttrDomain src_domain, AttrDomain dst_domain, const AttributeFilter &attribute_filter, const IndexMask &selection, MutableAttributeAccessor dst_attributes)
GeometrySet object_get_evaluated_geometry_set(const Object &object, bool apply_subdiv=true)
PyObject * PyC_UnicodeFromStdStr(const std::string &str)
bool RNA_enum_name_from_value(const EnumPropertyItem *item, int value, const char **r_name)
const EnumPropertyItem rna_enum_object_type_items[]
PyObject_HEAD GeometrySet geometry
PointCloud * instances_pointcloud
struct Collection * instance_collection
static MatBase identity()