Blender  V3.3
Classes | Typedefs | Enumerations | Functions
draw_cache_impl_particles.c File Reference

Particle API for render engines. More...

#include "DRW_render.h"
#include "MEM_guardedalloc.h"
#include "BLI_alloca.h"
#include "BLI_ghash.h"
#include "BLI_math_vector.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "DNA_customdata_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "DNA_particle_types.h"
#include "BKE_customdata.h"
#include "BKE_mesh.h"
#include "BKE_mesh_legacy_convert.h"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
#include "ED_particle.h"
#include "GPU_batch.h"
#include "GPU_material.h"
#include "DEG_depsgraph_query.h"
#include "draw_cache_impl.h"
#include "draw_hair_private.h"

Go to the source code of this file.

Classes

struct  ParticlePointCache
 
struct  ParticleBatchCache
 
struct  HairAttributeID
 
struct  EditStrandData
 
struct  ParticleDrawSource
 

Typedefs

typedef struct ParticlePointCache ParticlePointCache
 
typedef struct ParticleBatchCache ParticleBatchCache
 
typedef struct HairAttributeID HairAttributeID
 
typedef struct EditStrandData EditStrandData
 
typedef enum ParticleSource ParticleSource
 
typedef struct ParticleDrawSource ParticleDrawSource
 

Enumerations

enum  ParticleSource { PARTICLE_SOURCE_PARENT , PARTICLE_SOURCE_CHILDREN }
 

Functions

static void particle_batch_cache_clear (ParticleSystem *psys)
 
static GPUVertFormatedit_points_vert_format_get (uint *r_pos_id, uint *r_color_id)
 
static bool particle_batch_cache_valid (ParticleSystem *psys)
 
static void particle_batch_cache_init (ParticleSystem *psys)
 
static ParticleBatchCacheparticle_batch_cache_get (ParticleSystem *psys)
 
void DRW_particle_batch_cache_dirty_tag (ParticleSystem *psys, int mode)
 
static void particle_batch_cache_clear_point (ParticlePointCache *point_cache)
 
static void particle_batch_cache_clear_hair (ParticleHairCache *hair_cache)
 
static void particle_batch_cache_free_hair (ParticleHairCache *hair)
 
void DRW_particle_batch_cache_free (ParticleSystem *psys)
 
static void count_cache_segment_keys (ParticleCacheKey **pathcache, const int num_path_cache_keys, ParticleHairCache *hair_cache)
 
static void ensure_seg_pt_count (PTCacheEdit *edit, ParticleSystem *psys, ParticleHairCache *hair_cache)
 
static void particle_pack_mcol (MCol *mcol, ushort r_scol[3])
 
static void particle_calculate_parent_uvs (ParticleSystem *psys, ParticleSystemModifierData *psmd, const int num_uv_layers, const int parent_index, const MTFace **mtfaces, float(*r_uv)[2])
 
static void particle_calculate_parent_mcol (ParticleSystem *psys, ParticleSystemModifierData *psmd, const int num_col_layers, const int parent_index, const MCol **mcols, MCol *r_mcol)
 
static void particle_interpolate_children_uvs (ParticleSystem *psys, ParticleSystemModifierData *psmd, const int num_uv_layers, const int child_index, const MTFace **mtfaces, float(*r_uv)[2])
 
static void particle_interpolate_children_mcol (ParticleSystem *psys, ParticleSystemModifierData *psmd, const int num_col_layers, const int child_index, const MCol **mcols, MCol *r_mcol)
 
static void particle_calculate_uvs (ParticleSystem *psys, ParticleSystemModifierData *psmd, const bool is_simple, const int num_uv_layers, const int parent_index, const int child_index, const MTFace **mtfaces, float(**r_parent_uvs)[2], float(**r_uv)[2])
 
static void particle_calculate_mcol (ParticleSystem *psys, ParticleSystemModifierData *psmd, const bool is_simple, const int num_col_layers, const int parent_index, const int child_index, const MCol **mcols, MCol **r_parent_mcol, MCol **r_mcol)
 
static int particle_batch_cache_fill_segments (ParticleSystem *psys, ParticleSystemModifierData *psmd, ParticleCacheKey **path_cache, const ParticleSource particle_source, const int global_offset, const int start_index, const int num_path_keys, const int num_uv_layers, const int num_col_layers, const MTFace **mtfaces, const MCol **mcols, uint *uv_id, uint *col_id, float(***r_parent_uvs)[2], MCol ***r_parent_mcol, GPUIndexBufBuilder *elb, HairAttributeID *attr_id, ParticleHairCache *hair_cache)
 
static void particle_batch_cache_fill_segments_proc_pos (ParticleCacheKey **path_cache, const int num_path_keys, GPUVertBufRaw *attr_step, GPUVertBufRaw *length_step)
 
static float particle_key_weight (const ParticleData *particle, int strand, float t)
 
static int particle_batch_cache_fill_segments_edit (const PTCacheEdit *UNUSED(edit), const ParticleData *particle, ParticleCacheKey **path_cache, const int start_index, const int num_path_keys, GPUIndexBufBuilder *elb, GPUVertBufRaw *attr_step)
 
static int particle_batch_cache_fill_segments_indices (ParticleCacheKey **path_cache, const int start_index, const int num_path_keys, const int res, GPUIndexBufBuilder *elb)
 
static int particle_batch_cache_fill_strands_data (ParticleSystem *psys, ParticleSystemModifierData *psmd, ParticleCacheKey **path_cache, const ParticleSource particle_source, const int start_index, const int num_path_keys, GPUVertBufRaw *data_step, GPUVertBufRaw *seg_step, float(***r_parent_uvs)[2], GPUVertBufRaw *uv_step, const MTFace **mtfaces, int num_uv_layers, MCol ***r_parent_mcol, GPUVertBufRaw *col_step, const MCol **mcols, int num_col_layers)
 
static void particle_batch_cache_ensure_procedural_final_points (ParticleHairCache *cache, int subdiv)
 
static void particle_batch_cache_ensure_procedural_strand_data (PTCacheEdit *edit, ParticleSystem *psys, ModifierData *md, ParticleHairCache *cache)
 
static void particle_batch_cache_ensure_procedural_indices (PTCacheEdit *edit, ParticleSystem *psys, ParticleHairCache *cache, int thickness_res, int subdiv)
 
static void particle_batch_cache_ensure_procedural_pos (PTCacheEdit *edit, ParticleSystem *psys, ParticleHairCache *cache, GPUMaterial *gpu_material)
 
static void particle_batch_cache_ensure_pos_and_seg (PTCacheEdit *edit, ParticleSystem *psys, ModifierData *md, ParticleHairCache *hair_cache)
 
static void particle_batch_cache_ensure_pos (Object *object, ParticleSystem *psys, ParticlePointCache *point_cache)
 
static void drw_particle_update_ptcache_edit (Object *object_eval, ParticleSystem *psys, PTCacheEdit *edit)
 
static void drw_particle_update_ptcache (Object *object_eval, ParticleSystem *psys)
 
static void drw_particle_get_hair_source (Object *object, ParticleSystem *psys, ModifierData *md, PTCacheEdit *edit, ParticleDrawSource *r_draw_source)
 
GPUBatchDRW_particles_batch_cache_get_hair (Object *object, ParticleSystem *psys, ModifierData *md)
 
GPUBatchDRW_particles_batch_cache_get_dots (Object *object, ParticleSystem *psys)
 
static void particle_batch_cache_ensure_edit_pos_and_seg (PTCacheEdit *edit, ParticleSystem *psys, ModifierData *UNUSED(md), ParticleHairCache *hair_cache, bool use_weight)
 
GPUBatchDRW_particles_batch_cache_get_edit_strands (Object *object, ParticleSystem *psys, PTCacheEdit *edit, bool use_weight)
 
static void ensure_edit_inner_points_count (const PTCacheEdit *edit, ParticleBatchCache *cache)
 
static void particle_batch_cache_ensure_edit_inner_pos (PTCacheEdit *edit, ParticleBatchCache *cache)
 
GPUBatchDRW_particles_batch_cache_get_edit_inner_points (Object *object, ParticleSystem *psys, PTCacheEdit *edit)
 
static void ensure_edit_tip_points_count (const PTCacheEdit *edit, ParticleBatchCache *cache)
 
static void particle_batch_cache_ensure_edit_tip_pos (PTCacheEdit *edit, ParticleBatchCache *cache)
 
GPUBatchDRW_particles_batch_cache_get_edit_tip_points (Object *object, ParticleSystem *psys, PTCacheEdit *edit)
 
bool particles_ensure_procedural_data (Object *object, ParticleSystem *psys, ModifierData *md, ParticleHairCache **r_hair_cache, GPUMaterial *gpu_material, int subdiv, int thickness_res)
 

Detailed Description

Particle API for render engines.

Definition in file draw_cache_impl_particles.c.

Typedef Documentation

◆ EditStrandData

◆ HairAttributeID

◆ ParticleBatchCache

◆ ParticleDrawSource

◆ ParticlePointCache

◆ ParticleSource

Enumeration Type Documentation

◆ ParticleSource

Enumerator
PARTICLE_SOURCE_PARENT 
PARTICLE_SOURCE_CHILDREN 

Definition at line 490 of file draw_cache_impl_particles.c.

Function Documentation

◆ count_cache_segment_keys()

static void count_cache_segment_keys ( ParticleCacheKey **  pathcache,
const int  num_path_cache_keys,
ParticleHairCache hair_cache 
)
static

◆ DRW_particle_batch_cache_dirty_tag()

void DRW_particle_batch_cache_dirty_tag ( ParticleSystem psys,
int  mode 
)

◆ DRW_particle_batch_cache_free()

void DRW_particle_batch_cache_free ( ParticleSystem psys)

◆ drw_particle_get_hair_source()

static void drw_particle_get_hair_source ( Object object,
ParticleSystem psys,
ModifierData md,
PTCacheEdit edit,
ParticleDrawSource r_draw_source 
)
static

◆ drw_particle_update_ptcache()

static void drw_particle_update_ptcache ( Object object_eval,
ParticleSystem psys 
)
static

◆ drw_particle_update_ptcache_edit()

static void drw_particle_update_ptcache_edit ( Object object_eval,
ParticleSystem psys,
PTCacheEdit edit 
)
static

◆ DRW_particles_batch_cache_get_dots()

GPUBatch* DRW_particles_batch_cache_get_dots ( Object object,
ParticleSystem psys 
)

◆ DRW_particles_batch_cache_get_edit_inner_points()

GPUBatch* DRW_particles_batch_cache_get_edit_inner_points ( Object object,
ParticleSystem psys,
PTCacheEdit edit 
)

◆ DRW_particles_batch_cache_get_edit_strands()

GPUBatch* DRW_particles_batch_cache_get_edit_strands ( Object object,
ParticleSystem psys,
PTCacheEdit edit,
bool  use_weight 
)

◆ DRW_particles_batch_cache_get_edit_tip_points()

GPUBatch* DRW_particles_batch_cache_get_edit_tip_points ( Object object,
ParticleSystem psys,
PTCacheEdit edit 
)

◆ DRW_particles_batch_cache_get_hair()

GPUBatch* DRW_particles_batch_cache_get_hair ( Object object,
ParticleSystem psys,
ModifierData md 
)

◆ edit_points_vert_format_get()

static GPUVertFormat* edit_points_vert_format_get ( uint r_pos_id,
uint r_color_id 
)
static

◆ ensure_edit_inner_points_count()

static void ensure_edit_inner_points_count ( const PTCacheEdit edit,
ParticleBatchCache cache 
)
static

◆ ensure_edit_tip_points_count()

static void ensure_edit_tip_points_count ( const PTCacheEdit edit,
ParticleBatchCache cache 
)
static

◆ ensure_seg_pt_count()

static void ensure_seg_pt_count ( PTCacheEdit edit,
ParticleSystem psys,
ParticleHairCache hair_cache 
)
static

◆ particle_batch_cache_clear()

static void particle_batch_cache_clear ( ParticleSystem psys)
static

◆ particle_batch_cache_clear_hair()

static void particle_batch_cache_clear_hair ( ParticleHairCache hair_cache)
static

◆ particle_batch_cache_clear_point()

static void particle_batch_cache_clear_point ( ParticlePointCache point_cache)
static

◆ particle_batch_cache_ensure_edit_inner_pos()

static void particle_batch_cache_ensure_edit_inner_pos ( PTCacheEdit edit,
ParticleBatchCache cache 
)
static

◆ particle_batch_cache_ensure_edit_pos_and_seg()

static void particle_batch_cache_ensure_edit_pos_and_seg ( PTCacheEdit edit,
ParticleSystem psys,
ModifierData UNUSEDmd,
ParticleHairCache hair_cache,
bool  use_weight 
)
static

◆ particle_batch_cache_ensure_edit_tip_pos()

static void particle_batch_cache_ensure_edit_tip_pos ( PTCacheEdit edit,
ParticleBatchCache cache 
)
static

◆ particle_batch_cache_ensure_pos()

static void particle_batch_cache_ensure_pos ( Object object,
ParticleSystem psys,
ParticlePointCache point_cache 
)
static

◆ particle_batch_cache_ensure_pos_and_seg()

static void particle_batch_cache_ensure_pos_and_seg ( PTCacheEdit edit,
ParticleSystem psys,
ModifierData md,
ParticleHairCache hair_cache 
)
static

◆ particle_batch_cache_ensure_procedural_final_points()

static void particle_batch_cache_ensure_procedural_final_points ( ParticleHairCache cache,
int  subdiv 
)
static

◆ particle_batch_cache_ensure_procedural_indices()

static void particle_batch_cache_ensure_procedural_indices ( PTCacheEdit edit,
ParticleSystem psys,
ParticleHairCache cache,
int  thickness_res,
int  subdiv 
)
static

◆ particle_batch_cache_ensure_procedural_pos()

static void particle_batch_cache_ensure_procedural_pos ( PTCacheEdit edit,
ParticleSystem psys,
ParticleHairCache cache,
GPUMaterial gpu_material 
)
static

◆ particle_batch_cache_ensure_procedural_strand_data()

static void particle_batch_cache_ensure_procedural_strand_data ( PTCacheEdit edit,
ParticleSystem psys,
ModifierData md,
ParticleHairCache cache 
)
static

Definition at line 825 of file draw_cache_impl_particles.c.

References BKE_mesh_tessface_ensure(), BLI_array_alloca, BLI_snprintf(), BLI_strncpy(), CD_MCOL, CD_MLOOPUV, CD_MTFACE, CD_PROP_BYTE_COLOR, ParticleSystem::childcache, ParticleHairCache::col_layer_names, ParticleHairCache::col_tex, CustomData_get_active_layer(), CustomData_get_layer_n(), CustomData_get_layer_name(), CustomData_get_render_layer(), CustomData_has_layer(), CustomData_number_of_layers(), ParticleSettings::disp, ParticleSettings::draw, Mesh::fdata, float(), GPU_COMP_F32, GPU_COMP_U16, GPU_COMP_U32, GPU_FETCH_FLOAT, GPU_FETCH_INT, GPU_FETCH_INT_TO_FLOAT_UNIT, GPU_MAX_SAFE_ATTR_NAME, GPU_texture_create_from_vertbuf(), GPU_vertbuf_attr_get_raw_data(), GPU_vertbuf_create_with_format, GPU_vertbuf_data_alloc(), GPU_vertbuf_use(), GPU_vertformat_attr_add(), GPU_vertformat_safe_attr_name(), Mesh::ldata, MAX_LAYER_NAME_LEN, MAX_MTFACE, MEM_calloc_arrayN, MEM_freeN, MEM_SAFE_FREE, ParticleSystemModifierData::mesh_final, NULL, ParticleHairCache::num_col_layers, ParticleHairCache::num_uv_layers, ParticleSystem::part, PART_DRAW_PARENT, particle_batch_cache_fill_strands_data(), PARTICLE_SOURCE_CHILDREN, PARTICLE_SOURCE_PARENT, PTCacheEdit::pathcache, ParticleSystem::pathcache, ParticleHairCache::proc_col_buf, ParticleHairCache::proc_strand_buf, ParticleHairCache::proc_strand_seg_buf, ParticleHairCache::proc_uv_buf, ParticleHairCache::strand_seg_tex, ParticleHairCache::strand_tex, ParticleHairCache::strands_len, PTCacheEdit::totcached, ParticleSystem::totchild, ParticleSystem::totpart, ParticleHairCache::uv_layer_names, and ParticleHairCache::uv_tex.

Referenced by particles_ensure_procedural_data().

◆ particle_batch_cache_fill_segments()

static int particle_batch_cache_fill_segments ( ParticleSystem psys,
ParticleSystemModifierData psmd,
ParticleCacheKey **  path_cache,
const ParticleSource  particle_source,
const int  global_offset,
const int  start_index,
const int  num_path_keys,
const int  num_uv_layers,
const int  num_col_layers,
const MTFace **  mtfaces,
const MCol **  mcols,
uint uv_id,
uint col_id,
float(***)  r_parent_uvs[2],
MCol ***  r_parent_mcol,
GPUIndexBufBuilder elb,
HairAttributeID attr_id,
ParticleHairCache hair_cache 
)
static

◆ particle_batch_cache_fill_segments_edit()

static int particle_batch_cache_fill_segments_edit ( const PTCacheEdit UNUSEDedit,
const ParticleData particle,
ParticleCacheKey **  path_cache,
const int  start_index,
const int  num_path_keys,
GPUIndexBufBuilder elb,
GPUVertBufRaw attr_step 
)
static

◆ particle_batch_cache_fill_segments_indices()

static int particle_batch_cache_fill_segments_indices ( ParticleCacheKey **  path_cache,
const int  start_index,
const int  num_path_keys,
const int  res,
GPUIndexBufBuilder elb 
)
static

◆ particle_batch_cache_fill_segments_proc_pos()

static void particle_batch_cache_fill_segments_proc_pos ( ParticleCacheKey **  path_cache,
const int  num_path_keys,
GPUVertBufRaw attr_step,
GPUVertBufRaw length_step 
)
static

◆ particle_batch_cache_fill_strands_data()

static int particle_batch_cache_fill_strands_data ( ParticleSystem psys,
ParticleSystemModifierData psmd,
ParticleCacheKey **  path_cache,
const ParticleSource  particle_source,
const int  start_index,
const int  num_path_keys,
GPUVertBufRaw data_step,
GPUVertBufRaw seg_step,
float(***)  r_parent_uvs[2],
GPUVertBufRaw uv_step,
const MTFace **  mtfaces,
int  num_uv_layers,
MCol ***  r_parent_mcol,
GPUVertBufRaw col_step,
const MCol **  mcols,
int  num_col_layers 
)
static

◆ particle_batch_cache_free_hair()

static void particle_batch_cache_free_hair ( ParticleHairCache hair)
static

◆ particle_batch_cache_get()

static ParticleBatchCache* particle_batch_cache_get ( ParticleSystem psys)
static

◆ particle_batch_cache_init()

static void particle_batch_cache_init ( ParticleSystem psys)
static

◆ particle_batch_cache_valid()

static bool particle_batch_cache_valid ( ParticleSystem psys)
static

◆ particle_calculate_mcol()

static void particle_calculate_mcol ( ParticleSystem psys,
ParticleSystemModifierData psmd,
const bool  is_simple,
const int  num_col_layers,
const int  parent_index,
const int  child_index,
const MCol **  mcols,
MCol **  r_parent_mcol,
MCol **  r_mcol 
)
static

◆ particle_calculate_parent_mcol()

static void particle_calculate_parent_mcol ( ParticleSystem psys,
ParticleSystemModifierData psmd,
const int  num_col_layers,
const int  parent_index,
const MCol **  mcols,
MCol r_mcol 
)
static

◆ particle_calculate_parent_uvs()

static void particle_calculate_parent_uvs ( ParticleSystem psys,
ParticleSystemModifierData psmd,
const int  num_uv_layers,
const int  parent_index,
const MTFace **  mtfaces,
float(*)  r_uv[2] 
)
static

◆ particle_calculate_uvs()

static void particle_calculate_uvs ( ParticleSystem psys,
ParticleSystemModifierData psmd,
const bool  is_simple,
const int  num_uv_layers,
const int  parent_index,
const int  child_index,
const MTFace **  mtfaces,
float(**)  r_parent_uvs[2],
float(**)  r_uv[2] 
)
static

◆ particle_interpolate_children_mcol()

static void particle_interpolate_children_mcol ( ParticleSystem psys,
ParticleSystemModifierData psmd,
const int  num_col_layers,
const int  child_index,
const MCol **  mcols,
MCol r_mcol 
)
static

◆ particle_interpolate_children_uvs()

static void particle_interpolate_children_uvs ( ParticleSystem psys,
ParticleSystemModifierData psmd,
const int  num_uv_layers,
const int  child_index,
const MTFace **  mtfaces,
float(*)  r_uv[2] 
)
static

◆ particle_key_weight()

static float particle_key_weight ( const ParticleData particle,
int  strand,
float  t 
)
static

◆ particle_pack_mcol()

static void particle_pack_mcol ( MCol mcol,
ushort  r_scol[3] 
)
static

◆ particles_ensure_procedural_data()

bool particles_ensure_procedural_data ( struct Object object,
struct ParticleSystem psys,
struct ModifierData md,
struct ParticleHairCache **  r_hair_cache,
struct GPUMaterial gpu_material,
int  subdiv,
int  thickness_res 
)