Blender V4.3
object_dupli.cc File Reference
#include <climits>
#include <cstddef>
#include <cstdlib>
#include "MEM_guardedalloc.h"
#include "BLI_listbase.h"
#include "BLI_math_vector.h"
#include "BLI_string_utf8.h"
#include "BLI_array.hh"
#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_span.hh"
#include "BLI_vector.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 "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 "BLI_hash.h"
#include "DNA_world_types.h"
#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
 

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
ListBaseobject_duplilist (Depsgraph *depsgraph, Scene *sce, Object *ob)
 
ListBaseobject_duplilist_preview (Depsgraph *depsgraph, Scene *sce, Object *ob_eval, const ViewerPath *viewer_path)
 
void free_object_duplilist (ListBase *lb)
 
Uniform attribute lookup
static bool find_geonode_attribute_rgba (const DupliObject *dupli, const char *name, float r_value[4])
 
static bool find_rna_property_rgba (PointerRNA *id_ptr, const char *name, float r_data[4])
 
static bool find_rna_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], Vector< Object * > &instance_stack, Vector< short > &dupli_gen_type_stack)
 
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

◆ MakeChildDuplisFunc

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

Definition at line 362 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 1942 of file object_dupli.cc.

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

Referenced by drw_uniform_attribute_lookup(), 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 1983 of file object_dupli.cc.

References copy_v4_fl(), find_rna_property_rgba(), and RNA_pointer_create().

Referenced by drw_ensure_layer_attribute_buffer().

◆ copy_dupli_context()

◆ face_dupli()

static 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()

static 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()

static 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 1158 of file object_dupli.cc.

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

Referenced by make_child_duplis_faces_from_mesh().

◆ find_family_object()

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

◆ find_geonode_attribute_rgba()

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

◆ find_rna_property_rgba() [1/2]

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

Definition at line 1936 of file object_dupli.cc.

References find_rna_property_rgba(), ptr, and RNA_id_pointer_create().

◆ find_rna_property_rgba() [2/2]

◆ free_object_duplilist()

◆ get_dupli_generator()

◆ get_dupliface_transform_from_coords()

static 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()

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
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 584 of file object_dupli.cc.

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

Referenced by vertex_dupli().

◆ init_context()

◆ is_child()

static 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]

static 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 310 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()

static void make_duplis_geometry_set ( const DupliContext * ctx)
static

◆ make_duplis_geometry_set_impl()

◆ make_duplis_particle_system()

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

Definition at line 1347 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, ELEM, ParticleData::flag, ParticleSystem::flag, FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN, FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END, invert_m4(), invert_m4_m4(), LISTBASE_FOREACH, make_dupli(), mat4_to_size(), MEM_callocN, 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(), Object::runtime, DupliContext::scene, ParticleSimulationData::scene, scene, ParticleSystem::seed, ParticleCacheKey::segments, ParticleData::size, size_to_mat4(), state, sub_v3_v3(), ParticleSystem::totcached, ParticleSystem::totchild, ParticleSystem::totchildcache, ParticleSystem::totpart, Object::trackflag, Object::upflag, DupliObject::uv, vec_to_quat(), and zero_v3().

Referenced by make_duplis_particles().

◆ make_duplis_particles()

static void make_duplis_particles ( const DupliContext * ctx)
static

◆ make_duplis_verts()

◆ make_recursive_duplis()

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 )
static

◆ mesh_data_from_duplicator_object()

◆ object_duplilist()

◆ object_duplilist_preview()

◆ vertex_dupli()

static 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 529 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 1336 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 1041 of file object_dupli.cc.

Referenced by get_dupli_generator().

◆ gen_dupli_particles

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

Definition at line 1690 of file object_dupli.cc.

Referenced by get_dupli_generator().

◆ gen_dupli_verts

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

Definition at line 742 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 870 of file object_dupli.cc.

Referenced by get_dupli_generator().

◆ GEOMETRY_SET_DUPLI_GENERATOR_TYPE

short GEOMETRY_SET_DUPLI_GENERATOR_TYPE = 1
staticconstexpr