36#include "RNA_prototypes.hh"
57 BPy_GeometrySet *self =
reinterpret_cast<BPy_GeometrySet *
>(
59 if (self ==
nullptr) {
63 self->instances_pointcloud =
nullptr;
67 self->geometry.ensure_no_shared_components();
73 static const char *kwlist[] = {
nullptr};
74 if (!PyArg_ParseTupleAndKeywords(args, kwds,
"",
const_cast<char **
>(kwlist))) {
86 Py_TYPE(self)->tp_free(
reinterpret_cast<PyObject *
>(self));
91 bpy_geometry_set_from_evaluated_object_doc,
92 ".. staticmethod:: from_evaluated_object(evaluated_object)\n"
94 " Create a geometry set from the evaluated geometry of an evaluated object.\n"
95 " Typically, it's more convenient to use :func:`bpy.types.Object.evaluated_geometry`.\n"
97 " :param evaluated_object: The evaluated object to create a geometry set from.\n"
98 " :type evaluated_object: bpy.types.Object\n");
103 static const char *kwlist[] = {
"evaluated_object",
nullptr};
104 PyObject *py_evaluated_object;
105 if (!PyArg_ParseTupleAndKeywords(args,
108 ":from_evaluated_object",
109 const_cast<char **
>(kwlist),
110 &py_evaluated_object))
114 ID *evaluated_object_id =
nullptr;
117 PyExc_TypeError,
"Expected an Object, not %.200s", Py_TYPE(py_evaluated_object)->tp_name);
122 PyErr_Format(PyExc_TypeError,
123 "Expected an Object, not %.200s",
127 Object *evaluated_object =
reinterpret_cast<Object *
>(evaluated_object_id);
129 PyErr_SetString(PyExc_TypeError,
"Expected an evaluated object");
133 if (!valid_object_type) {
134 const char *ob_type_name =
"<unknown>";
136 PyErr_Format(PyExc_TypeError,
"Expected a geometry object, not %.200s", ob_type_name);
140 PyErr_SetString(PyExc_TypeError,
141 "Object geometry is not yet evaluated, is the depsgraph evaluated?");
146 PyErr_SetString(PyExc_TypeError,
"Object is not owned by a depsgraph");
150 const bool is_instance_collection = evaluated_object->
type ==
OB_EMPTY &&
153 if (is_instance_collection) {
159 geometry.replace_instances(instances);
174 std::stringstream ss;
176 std::string
str = ss.str();
182 bpy_geometry_set_get_instances_pointcloud_doc,
183 ".. method:: instances_pointcloud()\n"
185 " Get a pointcloud that encodes information about the instances of the geometry.\n"
186 " The returned pointcloud should not be modified.\n"
187 " There is a point per instance and per-instance data is stored in point attributes.\n"
188 " The local transforms are stored in the ``instance_transform`` attribute.\n"
189 " The data instanced by each point is referenced by the ``.reference_index`` attribute,\n"
190 " indexing into the list returned by :func:`bpy.types.GeometrySet.instance_references`.\n"
192 " :rtype: bpy.types.PointCloud\n");
208 pointcloud->attributes_for_write());
216 bpy_geometry_set_get_instance_references_doc,
217 ".. method:: instance_references()\n"
219 " This returns a list of geometries that is indexed by the ``.reference_index``\n"
220 " attribute of the pointcloud returned by \n"
221 " :func:`bpy.types.GeometrySet.instances_pointcloud`.\n"
222 " It may contain other geometry sets, objects, collections and None values.\n"
224 " :rtype: list[None | bpy.types.Object | bpy.types.Collection | bpy.types.GeometrySet]\n");
229 return PyList_New(0);
232 PyObject *py_references = PyList_New(references.
size());
235 switch (reference.
type()) {
237 PyList_SET_ITEM(py_references, i, Py_NewRef(Py_None));
257 return py_references;
262 bpy_geometry_set_name_doc,
263 "The name of the geometry set. It can be used for debugging purposes and is not unique.\n"
273 if (!PyUnicode_Check(value)) {
274 PyErr_SetString(PyExc_TypeError,
"expected a string");
277 const char *name = PyUnicode_AsUTF8(value);
284 bpy_geometry_set_mesh_doc,
285 "The mesh data-block in the geometry set.\n"
287 ":type: :class:`bpy.types.Mesh`\n");
300 bpy_geometry_set_mesh_base_doc,
301 "The mesh data-block in the geometry set without final subdivision.\n"
303 ":type: :class:`bpy.types.Mesh`\n");
312 bpy_geometry_set_pointcloud_doc,
313 "The point cloud data-block in the geometry set.\n"
315 ":type: :class:`bpy.types.PointCloud`\n");
324 bpy_geometry_set_curves_doc,
325 "The curves data-block in the geometry set.\n"
327 ":type: :class:`bpy.types.Curves`\n");
335 bpy_geometry_set_volume_doc,
336 "The volume data-block in the geometry set.\n"
338 ":type: :class:`bpy.types.Volume`\n");
346 bpy_geometry_set_grease_pencil_doc,
347 "The Grease Pencil data-block in the geometry set.\n"
349 ":type: :class:`bpy.types.GreasePencil`\n");
361 bpy_geometry_set_name_doc,
368 bpy_geometry_set_mesh_doc,
375 bpy_geometry_set_mesh_base_doc,
382 bpy_geometry_set_pointcloud_doc,
389 bpy_geometry_set_curves_doc,
396 bpy_geometry_set_volume_doc,
403 bpy_geometry_set_grease_pencil_doc,
412# pragma clang diagnostic push
413# pragma clang diagnostic ignored "-Wcast-function-type"
415# pragma GCC diagnostic push
416# pragma GCC diagnostic ignored "-Wcast-function-type"
421 {
"from_evaluated_object",
423 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
424 bpy_geometry_set_from_evaluated_object_doc},
425 {
"instances_pointcloud",
428 bpy_geometry_set_get_instances_pointcloud_doc},
429 {
"instance_references",
432 bpy_geometry_set_get_instance_references_doc},
433 {
nullptr,
nullptr, 0,
nullptr},
438# pragma clang diagnostic pop
440# pragma GCC diagnostic pop
446 bpy_geometry_set_doc,
447 "Stores potentially multiple geometry components of different types.\n"
448 "For example, it might contain a mesh, curves and nested instances.\n");
450 PyVarObject_HEAD_INIT(
nullptr, 0)
469 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
470 bpy_geometry_set_doc,
General operations for point clouds.
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.
constexpr int64_t size() const
constexpr IndexRange index_range() const
GeometrySet & geometry_set()
Collection & collection() const
MutableSpan< int > reference_handles_for_write()
Span< InstanceReference > references() const
int add_new_reference(InstanceReference reference)
bke::AttributeAccessor attributes() const
int instances_num() const
MutableSpan< float4x4 > transforms_for_write()
constexpr T & first() const
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)
VArray< float3 > instance_position_varray(const Instances &instances)
const char * BKE_idtype_idcode_to_name(short idcode)
static PyObject * BPy_GeometrySet_get_instances_pointcloud(BPy_GeometrySet *self)
static int BPy_GeometrySet_set_name(BPy_GeometrySet *self, PyObject *value, void *)
const EnumPropertyItem rna_enum_object_type_items[]
static PyObject * BPy_GeometrySet_get_curves(BPy_GeometrySet *self, void *)
PyObject * pyrna_id_CreatePyObject(ID *id)
PyDoc_STRVAR(bpy_bm_new_doc, ".. function:: new(*, use_operators=True)\n" "\n" " :param use_operators: Support calling operators in :mod:`bmesh.ops` (uses some " "extra memory per vert/edge/face).\n" " :type use_operators: bool\n" " :return: Return a new, empty BMesh.\n" " :rtype: :class:`bmesh.types.BMesh`\n")
static PyObject * BPy_GeometrySet_get_pointcloud(BPy_GeometrySet *self, void *)
static PyObject * BPy_GeometrySet_repr(BPy_GeometrySet *self)
Depsgraph * DEG_get_depsgraph_by_id(const ID &id)
PyObject * BPyInit_geometry_set_type()
bool RNA_enum_name_from_value(const EnumPropertyItem *item, int value, const char **r_name)
static void BPy_GeometrySet_dealloc(BPy_GeometrySet *self)
bool pyrna_id_FromPyObject(PyObject *obj, ID **id)
static BPy_GeometrySet * BPy_GeometrySet_static_from_evaluated_object(PyObject *, PyObject *args, PyObject *kwds)
void BKE_id_free(Main *bmain, void *idv)
bke::Instances object_duplilist_legacy_instances(Depsgraph &depsgraph, Object &ob)
static PyObject * BPy_GeometrySet_get_instance_references(BPy_GeometrySet *self)
static PyObject * BPy_GeometrySet_get_mesh(BPy_GeometrySet *self, void *)
static PyGetSetDef BPy_GeometrySet_getseters[]
static BPy_GeometrySet * python_object_from_geometry_set(GeometrySet geometry={})
static PyObject * BPy_GeometrySet_get_mesh_base(BPy_GeometrySet *self, void *)
ID_Type GS(const char *name)
bool DEG_object_has_geometry_component(Object *object)
PyTypeObject bpy_geometry_set_Type
PyObject * PyC_UnicodeFromStdStr(const std::string &str)
static PyObject * BPy_GeometrySet_new(PyTypeObject *, PyObject *args, PyObject *kwds)
PointCloud * BKE_pointcloud_new_nomain(PointCloudType type, int totpoint)
static PyMethodDef BPy_GeometrySet_methods[]
static PyObject * BPy_GeometrySet_get_grease_pencil(BPy_GeometrySet *self, void *)
static PyObject * BPy_GeometrySet_get_volume(BPy_GeometrySet *self, void *)
bool DEG_is_evaluated(const T *id)
bool DEG_object_geometry_is_evaluated(const Object &object)
Mesh * BKE_mesh_wrapper_ensure_subdivision(Mesh *mesh)
static PyObject * BPy_GeometrySet_get_name(BPy_GeometrySet *self, void *)
PyObject_HEAD GeometrySet geometry
PointCloud * instances_pointcloud
static MatBase identity()
struct Collection * instance_collection
StringRefNull name() const
void set_name(std::string name)
PointCloud * get_pointcloud_for_write()
Curves * get_curves_for_write()
const Instances * get_instances() const
GreasePencil * get_grease_pencil_for_write()
Volume * get_volume_for_write()
Mesh * get_mesh_for_write()