Blender V5.0
object_dupli.cc File Reference
#include <climits>
#include <cstddef>
#include <cstdlib>
#include <iostream>
#include <fmt/format.h>
#include "MEM_guardedalloc.h"
#include "BLI_listbase.h"
#include "BLI_math_vector.h"
#include "BLI_string_utf8.h"
#include "BLI_array.hh"
#include "BLI_hash.h"
#include "BLI_math_geom.h"
#include "BLI_math_matrix.h"
#include "BLI_math_rotation.h"
#include "BLI_math_vector.hh"
#include "BLI_rand.h"
#include "BLI_set.hh"
#include "BLI_span.hh"
#include "BLI_string_ref.hh"
#include "BLI_vector_list.hh"
#include "DNA_collection_types.h"
#include "DNA_curves_types.h"
#include "DNA_grease_pencil_types.h"
#include "DNA_mesh_types.h"
#include "DNA_modifier_types.h"
#include "DNA_pointcloud_types.h"
#include "DNA_scene_types.h"
#include "DNA_volume_types.h"
#include "DNA_world_types.h"
#include "BKE_collection.hh"
#include "BKE_duplilist.hh"
#include "BKE_editmesh.hh"
#include "BKE_editmesh_cache.hh"
#include "BKE_geometry_set.hh"
#include "BKE_geometry_set_instances.hh"
#include "BKE_global.hh"
#include "BKE_idprop.hh"
#include "BKE_instances.hh"
#include "BKE_main.hh"
#include "BKE_mesh.hh"
#include "BKE_object.hh"
#include "BKE_object_types.hh"
#include "BKE_particle.h"
#include "BKE_vfont.hh"
#include "DEG_depsgraph.hh"
#include "DEG_depsgraph_query.hh"
#include "NOD_geometry_nodes_log.hh"
#include "RNA_access.hh"
#include "RNA_path.hh"
#include "RNA_prototypes.hh"
#include "MOD_nodes.hh"

Go to the source code of this file.

Classes

struct  DupliContext
struct  DupliGenerator
struct  VertexDupliData_Params
struct  VertexDupliData_Mesh
struct  VertexDupliData_EditMesh
struct  FaceDupliData_Params
struct  FaceDupliData_Mesh
struct  FaceDupliData_EditMesh
class  VectorList< T, CapacityStart, CapacityMax >
struct  GeometrySet
class  InstanceReference
class  Instances

Typedefs

using float2
using float3
using float4x4

Functions

Internal Data Access Utilities
static const Meshmesh_data_from_duplicator_object (Object *ob, BMEditMesh **r_em, Span< float3 > *r_vert_coords, Span< float3 > *r_vert_normals)
Dupli-Container Implementation
void object_duplilist (Depsgraph *depsgraph, Scene *sce, Object *ob, Set< const Object * > *include_objects, DupliList &r_duplilist)
void object_duplilist_preview (Depsgraph *depsgraph, Scene *sce, Object *ob_eval, const ViewerPath *viewer_path, DupliList &r_duplilist)
blender::bke::Instances object_duplilist_legacy_instances (Depsgraph &depsgraph, Scene &scene, Object &ob)
Uniform attribute lookup
static bool find_geonode_attribute_rgba (const DupliObject *dupli, const char *name, float r_value[4])
static bool find_property_rgba (PointerRNA *id_ptr, const char *name, float r_data[4])
static bool find_property_rgba (const ID *id, const char *name, float r_data[4])
bool BKE_object_dupli_find_rgba_attribute (const Object *ob, const DupliObject *dupli, const Object *dupli_parent, const char *name, float r_value[4])
bool BKE_view_layer_find_rgba_attribute (const Scene *scene, const ViewLayer *layer, const char *name, float r_value[4])

Internal Child Duplicates (Used by Other Functions)

using MakeChildDuplisFunc = void (*)(const DupliContext *ctx, void *userdata, Object *child)
static bool is_child (const Object *ob, const Object *parent)
static void make_child_duplis (const DupliContext *ctx, void *userdata, MakeChildDuplisFunc make_child_duplis_cb)

Internal Duplicate Context

static constexpr short GEOMETRY_SET_DUPLI_GENERATOR_TYPE = 1
static const DupliGeneratorget_dupli_generator (const DupliContext *ctx)
static void init_context (DupliContext *r_ctx, Depsgraph *depsgraph, Scene *scene, Object *ob, const float space_mat[4][4], blender::Set< const Object * > *include_objects, Vector< Object * > &instance_stack, Vector< short > &dupli_gen_type_stack, DupliList &duplilist)
static bool copy_dupli_context (DupliContext *r_ctx, const DupliContext *ctx, Object *ob, const float mat[4][4], int index, const GeometrySet *geometry=nullptr, int64_t instance_index=0)
static DupliObjectmake_dupli (const DupliContext *ctx, Object *ob, const ID *object_data, const float mat[4][4], int index, const GeometrySet *geometry=nullptr, int64_t instance_index=0)
static DupliObjectmake_dupli (const DupliContext *ctx, Object *ob, const float mat[4][4], int index, const GeometrySet *geometry=nullptr, int64_t instance_index=0)
static void make_recursive_duplis (const DupliContext *ctx, Object *ob, const float space_mat[4][4], int index, const GeometrySet *geometry=nullptr, int64_t instance_index=0)

Dupli-Collection Implementation (#OB_DUPLICOLLECTION)

static const DupliGenerator gen_dupli_collection
static void make_duplis_collection (const DupliContext *ctx)

Dupli-Vertices Implementation (#OB_DUPLIVERTS for Geometry)

static const DupliGenerator gen_dupli_verts
static void get_duplivert_transform (const float3 &co, const float3 &no, const bool use_rotation, const short axis, const short upflag, float r_mat[4][4])
static DupliObjectvertex_dupli (const DupliContext *ctx, Object *inst_ob, const float child_imat[4][4], int index, const float3 &co, const float3 &no, const bool use_rotation)
static void make_child_duplis_verts_from_mesh (const DupliContext *ctx, void *userdata, Object *inst_ob)
static void make_child_duplis_verts_from_editmesh (const DupliContext *ctx, void *userdata, Object *inst_ob)
static void make_duplis_verts (const DupliContext *ctx)

Dupli-Vertices Implementation (#OB_DUPLIVERTS for 3D Text)

static const DupliGenerator gen_dupli_verts_font
static Objectfind_family_object (Main *bmain, const char *family, size_t family_len, uint ch, GHash *family_gh)
static void make_duplis_font (const DupliContext *ctx)

Instances Geometry Component Implementation

static const DupliGenerator gen_dupli_geometry_set
static void make_duplis_geometry_set_impl (const DupliContext *ctx, const GeometrySet &geometry_set, const float parent_transform[4][4], bool geometry_set_is_instance, bool use_new_curves_type)
static void make_duplis_geometry_set (const DupliContext *ctx)

Dupli-Faces Implementation (#OB_DUPLIFACES)

static const DupliGenerator gen_dupli_faces
static void get_dupliface_transform_from_coords (Span< float3 > coords, const bool use_scale, const float scale_fac, float r_mat[4][4])
static DupliObjectface_dupli (const DupliContext *ctx, Object *inst_ob, const float child_imat[4][4], const int index, const bool use_scale, const float scale_fac, Span< float3 > coords)
static DupliObjectface_dupli_from_mesh (const DupliContext *ctx, Object *inst_ob, const float child_imat[4][4], const int index, const bool use_scale, const float scale_fac, const Span< int > face_verts, const Span< float3 > vert_positions)
static DupliObjectface_dupli_from_editmesh (const DupliContext *ctx, Object *inst_ob, const float child_imat[4][4], const int index, const bool use_scale, const float scale_fac, BMFace *f, const Span< float3 > vert_positions_deform)
static void make_child_duplis_faces_from_mesh (const DupliContext *ctx, void *userdata, Object *inst_ob)
static void make_child_duplis_faces_from_editmesh (const DupliContext *ctx, void *userdata, Object *inst_ob)
static void make_duplis_faces (const DupliContext *ctx)

Dupli-Particles Implementation (#OB_DUPLIPARTS)

static const DupliGenerator gen_dupli_particles
static void make_duplis_particle_system (const DupliContext *ctx, ParticleSystem *psys)
static void make_duplis_particles (const DupliContext *ctx)

Typedef Documentation

◆ float2

Definition at line 618 of file BLI_math_vector_types.hh.

◆ float3

Definition at line 619 of file BLI_math_vector_types.hh.

◆ float4x4

Definition at line 1012 of file BLI_math_matrix_types.hh.

◆ MakeChildDuplisFunc

using MakeChildDuplisFunc = void (*)(const DupliContext *ctx, void *userdata, Object *child)

Definition at line 398 of file object_dupli.cc.

Function Documentation

◆ BKE_object_dupli_find_rgba_attribute()

bool BKE_object_dupli_find_rgba_attribute ( const Object * ob,
const DupliObject * dupli,
const Object * dupli_parent,
const char * name,
float r_value[4] )

Look up the RGBA value of a uniform shader attribute.

Returns
true if the attribute was found; if not, r_value is also set to zero.

Definition at line 2075 of file object_dupli.cc.

References copy_v4_fl(), Object::data, find_geonode_attribute_rgba(), find_property_rgba(), Object::id, ParticleSettings::id, name, ParticleSystem::part, and DupliObject::particle_system.

Referenced by blender::draw::ObjectRef::find_rgba_attribute(), and lookup_instance_property().

◆ BKE_view_layer_find_rgba_attribute()

bool BKE_view_layer_find_rgba_attribute ( const Scene * scene,
const ViewLayer * layer,
const char * name,
float r_value[4] )

Look up the RGBA value of a view layer/scene/world shader attribute.

Returns
true if the attribute was found; if not, r_value is also set to zero.

Definition at line 2116 of file object_dupli.cc.

References copy_v4_fl(), find_property_rgba(), Scene::id, World::id, name, RNA_pointer_create_discrete(), and Scene::world.

Referenced by LayerAttribute::sync().

◆ copy_dupli_context()

◆ face_dupli()

DupliObject * face_dupli ( const DupliContext * ctx,
Object * inst_ob,
const float child_imat[4][4],
const int index,
const bool use_scale,
const float scale_fac,
Span< float3 > coords )
static

◆ face_dupli_from_editmesh()

DupliObject * face_dupli_from_editmesh ( const DupliContext * ctx,
Object * inst_ob,
const float child_imat[4][4],
const int index,
const bool use_scale,
const float scale_fac,
BMFace * f,
const Span< float3 > vert_positions_deform )
static

◆ face_dupli_from_mesh()

DupliObject * face_dupli_from_mesh ( const DupliContext * ctx,
Object * inst_ob,
const float child_imat[4][4],
const int index,
const bool use_scale,
const float scale_fac,
const Span< int > face_verts,
const Span< float3 > vert_positions )
static

Definition at line 1202 of file object_dupli.cc.

References face_dupli(), i, and blender::Span< T >::size().

Referenced by make_child_duplis_faces_from_mesh().

◆ find_family_object()

Object * find_family_object ( Main * bmain,
const char * family,
size_t family_len,
uint ch,
GHash * family_gh )
static

◆ find_geonode_attribute_rgba()

bool find_geonode_attribute_rgba ( const DupliObject * dupli,
const char * name,
float r_value[4] )
static

◆ find_property_rgba() [1/2]

bool find_property_rgba ( const ID * id,
const char * name,
float r_data[4] )
static

Definition at line 2069 of file object_dupli.cc.

References find_property_rgba(), name, ptr, and RNA_id_pointer_create().

◆ find_property_rgba() [2/2]

◆ get_dupli_generator()

◆ get_dupliface_transform_from_coords()

void get_dupliface_transform_from_coords ( Span< float3 > coords,
const bool use_scale,
const float scale_fac,
float r_mat[4][4] )
static

◆ get_duplivert_transform()

void get_duplivert_transform ( const float3 & co,
const float3 & no,
const bool use_rotation,
const short axis,
const short upflag,
float r_mat[4][4] )
static
Parameters
noThe direction, currently this is copied from a short[3] normal without division. Can be null when use_rotation is false.

Definition at line 630 of file object_dupli.cc.

References loc_quat_size_to_mat4(), negate_v3_v3(), size(), unit_qt(), and vec_to_quat().

Referenced by vertex_dupli().

◆ init_context()

◆ is_child()

bool is_child ( const Object * ob,
const Object * parent )
static

◆ make_child_duplis()

◆ make_child_duplis_faces_from_editmesh()

◆ make_child_duplis_faces_from_mesh()

◆ make_child_duplis_verts_from_editmesh()

◆ make_child_duplis_verts_from_mesh()

◆ make_dupli() [1/2]

DupliObject * make_dupli ( const DupliContext * ctx,
Object * ob,
const float mat[4][4],
int index,
const GeometrySet * geometry = nullptr,
int64_t instance_index = 0 )
static

Definition at line 346 of file object_dupli.cc.

References Object::data, and make_dupli().

◆ make_dupli() [2/2]

◆ make_duplis_collection()

◆ make_duplis_faces()

◆ make_duplis_font()

◆ make_duplis_geometry_set()

void make_duplis_geometry_set ( const DupliContext * ctx)
static

◆ make_duplis_geometry_set_impl()

void make_duplis_geometry_set_impl ( const DupliContext * ctx,
const GeometrySet & geometry_set,
const float parent_transform[4][4],
bool geometry_set_is_instance,
bool use_new_curves_type )
static

◆ make_duplis_particle_system()

void make_duplis_particle_system ( const DupliContext * ctx,
ParticleSystem * psys )
static

Definition at line 1391 of file object_dupli.cc.

References add_v3_v3v3(), b, BKE_collection_object_cache_get(), BLI_findptr(), BLI_listbase_is_empty(), BLI_rng_free(), BLI_rng_get_int(), BLI_rng_new_srandom(), ParticleSystem::child, ParticleSystem::childcache, ParticleCacheKey::co, copy_m4_m4(), copy_v3_v3(), DAG_EVAL_RENDER, DEG_get_ctime(), DEG_get_mode(), DupliContext::depsgraph, ParticleSimulationData::depsgraph, ParticleSettings::draw, ParticleSettings::draw_as, ELEM, ParticleData::flag, ParticleSystem::flag, FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN, FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END, ParticleSettings::instance_collection, ParticleSettings::instance_object, Collection::instance_offset, ParticleSettings::instance_weights, invert_m4(), invert_m4_m4(), LISTBASE_FOREACH, make_dupli(), mat4_to_size(), MEM_calloc_arrayN(), MEM_freeN(), mul_m4_m4m4(), mul_mat3_m4_fl(), mul_v3_fl(), normalize_qt_qt(), ParticleData::num, ParticleSimulationData::ob, DupliContext::object, offsetof, DupliObject::orco, PARS_NO_DISP, PARS_UNEXIST, ParticleSystem::part, PART_DRAW_COUNT_GR, PART_DRAW_GLOBAL_OB, PART_DRAW_GR, PART_DRAW_NO_SCALE_OB, PART_DRAW_OB, PART_DRAW_PARENT, PART_DRAW_RAND_GR, PART_DRAW_REND, PART_DRAW_ROTATE_OB, PART_DRAW_WHOLE_GR, PART_HAIR, DupliObject::particle_system, ParticleSystem::particles, ParticleSystem::pathcache, ParticleSimulationData::psmd, ParticleSimulationData::psys, psys_check_enabled(), psys_find_group_weights(), psys_get_child_size(), psys_get_dupli_path_transform(), psys_get_dupli_texture(), psys_get_modifier(), psys_get_particle_state(), PSYS_HAIR_DONE, psys_sim_data_free(), psys_sim_data_init(), ptr, quat_to_mat4(), ParticleSettings::ren_as, Object::runtime, blender::math::scale(), DupliContext::scene, ParticleSimulationData::scene, ParticleSystem::seed, ParticleCacheKey::segments, ParticleData::size, size(), size_to_mat4(), state, sub_v3_v3(), ParticleSystem::totcached, ParticleSystem::totchild, ParticleSystem::totchildcache, ParticleSystem::totpart, Object::trackflag, ParticleSettings::type, Object::upflag, DupliObject::uv, vec_to_quat(), and zero_v3().

Referenced by make_duplis_particles().

◆ make_duplis_particles()

void make_duplis_particles ( const DupliContext * ctx)
static

◆ make_duplis_verts()

◆ make_recursive_duplis()

void make_recursive_duplis ( const DupliContext * ctx,
Object * ob,
const float space_mat[4][4],
int index,
const GeometrySet * geometry = nullptr,
int64_t instance_index = 0 )
static

◆ mesh_data_from_duplicator_object()

◆ object_duplilist()

◆ object_duplilist_legacy_instances()

blender::bke::Instances object_duplilist_legacy_instances ( Depsgraph & depsgraph,
Scene & scene,
Object & ob )

◆ object_duplilist_preview()

◆ vertex_dupli()

DupliObject * vertex_dupli ( const DupliContext * ctx,
Object * inst_ob,
const float child_imat[4][4],
int index,
const float3 & co,
const float3 & no,
const bool use_rotation )
static

Variable Documentation

◆ gen_dupli_collection

const DupliGenerator gen_dupli_collection
static
Initial value:
= {
@ OB_DUPLICOLLECTION
static void make_duplis_collection(const DupliContext *ctx)

Definition at line 575 of file object_dupli.cc.

Referenced by get_dupli_generator().

◆ gen_dupli_faces

const DupliGenerator gen_dupli_faces
static
Initial value:
= {
}
@ OB_DUPLIFACES
static void make_duplis_faces(const DupliContext *ctx)

Definition at line 1380 of file object_dupli.cc.

Referenced by get_dupli_generator().

◆ gen_dupli_geometry_set

const DupliGenerator gen_dupli_geometry_set
static
Initial value:
= {
}
static constexpr short GEOMETRY_SET_DUPLI_GENERATOR_TYPE
static void make_duplis_geometry_set(const DupliContext *ctx)

Definition at line 1085 of file object_dupli.cc.

Referenced by get_dupli_generator(), and object_duplilist_legacy_instances().

◆ gen_dupli_particles

const DupliGenerator gen_dupli_particles
static
Initial value:
= {
}
@ OB_DUPLIPARTS
static void make_duplis_particles(const DupliContext *ctx)

Definition at line 1733 of file object_dupli.cc.

Referenced by get_dupli_generator(), and object_duplilist_legacy_instances().

◆ gen_dupli_verts

const DupliGenerator gen_dupli_verts
static
Initial value:
= {
@ OB_DUPLIVERTS
static void make_duplis_verts(const DupliContext *ctx)

Definition at line 788 of file object_dupli.cc.

Referenced by get_dupli_generator().

◆ gen_dupli_verts_font

const DupliGenerator gen_dupli_verts_font
static
Initial value:
= {
static void make_duplis_font(const DupliContext *ctx)

Definition at line 914 of file object_dupli.cc.

Referenced by get_dupli_generator().

◆ GEOMETRY_SET_DUPLI_GENERATOR_TYPE

short GEOMETRY_SET_DUPLI_GENERATOR_TYPE = 1
staticconstexpr