Blender V4.3
BKE_pointcache.h File Reference
#include "BLI_function_ref.hh"
#include "DNA_boid_types.h"
#include "DNA_pointcache_types.h"
#include <stdio.h>

Go to the source code of this file.

Classes

struct  PTCacheData
 
struct  PTCacheFile
 
struct  PTCacheID
 
struct  PTCacheBaker
 
struct  PTCacheEditKey
 
struct  PTCacheEditPoint
 
struct  PTCacheUndo
 
struct  PTCacheEdit
 

Macros

#define PTCACHE_CLEAR_ALL   0
 
#define PTCACHE_CLEAR_FRAME   1
 
#define PTCACHE_CLEAR_BEFORE   2
 
#define PTCACHE_CLEAR_AFTER   3
 
#define PTCACHE_RESET_DEPSGRAPH   0
 
#define PTCACHE_RESET_BAKED   1
 
#define PTCACHE_RESET_OUTDATED   2
 
#define PTCACHE_EXT   ".bphys"
 
#define PTCACHE_PATH   "blendcache_"
 
#define PTCACHE_FILE_READ   0
 
#define PTCACHE_FILE_WRITE   1
 
#define PTCACHE_FILE_UPDATE   2
 
#define PTCACHE_TYPE_SOFTBODY   0
 
#define PTCACHE_TYPE_PARTICLES   1
 
#define PTCACHE_TYPE_CLOTH   2
 
#define PTCACHE_TYPE_SMOKE_DOMAIN   3
 
#define PTCACHE_TYPE_SMOKE_HIGHRES   4
 
#define PTCACHE_TYPE_DYNAMICPAINT   5
 
#define PTCACHE_TYPE_RIGIDBODY   6
 
#define PTCACHE_TYPEFLAG_COMPRESS   (1 << 16)
 
#define PTCACHE_TYPEFLAG_EXTRADATA   (1 << 17)
 
#define PTCACHE_TYPEFLAG_TYPEMASK   0x0000FFFF
 
#define PTCACHE_TYPEFLAG_FLAGMASK   0xFFFF0000
 
#define PTCACHE_READ_EXACT   1
 
#define PTCACHE_READ_INTERPOLATED   2
 
#define PTCACHE_READ_OLD   3
 
#define PTCACHE_VEL_PER_SEC   1
 
#define PEK_SELECT   1
 
#define PEK_TAG   2
 
#define PEK_HIDE   4
 
#define PEK_USE_WCO   8
 
#define PEP_TAG   1
 
#define PEP_EDIT_RECALC   2
 
#define PEP_TRANSFORM   4
 
#define PEP_HIDE   8
 

Typedefs

typedef struct PTCacheData PTCacheData
 
typedef struct PTCacheFile PTCacheFile
 
typedef struct PTCacheID PTCacheID
 
typedef struct PTCacheBaker PTCacheBaker
 
typedef struct PTCacheEditKey PTCacheEditKey
 
typedef struct PTCacheEditPoint PTCacheEditPoint
 
typedef struct PTCacheUndo PTCacheUndo
 
typedef struct PTCacheEdit PTCacheEdit
 
using PointCacheIdFn = blender::FunctionRef<bool(PTCacheID &pid, ModifierData *md)>
 

Enumerations

enum  { PTCACHE_FILE_PTCACHE = 0 }
 
enum  { PT_CACHE_EDIT_UPDATE_PARTICLE_FROM_EVAL = (1 << 0) }
 

Functions

void BKE_ptcache_make_particle_key (struct ParticleKey *key, int index, void **data, float time)
 
void BKE_ptcache_id_from_softbody (PTCacheID *pid, struct Object *ob, struct SoftBody *sb)
 
void BKE_ptcache_id_from_particles (PTCacheID *pid, struct Object *ob, struct ParticleSystem *psys)
 
void BKE_ptcache_id_from_cloth (PTCacheID *pid, struct Object *ob, struct ClothModifierData *clmd)
 
void BKE_ptcache_id_from_smoke (PTCacheID *pid, struct Object *ob, struct FluidModifierData *fmd)
 
void BKE_ptcache_id_from_dynamicpaint (PTCacheID *pid, struct Object *ob, struct DynamicPaintSurface *surface)
 
void BKE_ptcache_id_from_rigidbody (PTCacheID *pid, struct Object *ob, struct RigidBodyWorld *rbw)
 
PTCacheID BKE_ptcache_id_find (struct Object *ob, struct Scene *scene, struct PointCache *cache)
 
void BKE_ptcache_ids_from_object (struct ListBase *lb, struct Object *ob, struct Scene *scene, int duplis)
 
void BKE_ptcache_foreach_object_cache (struct Object &ob, struct Scene &scene, bool duplis, PointCacheIdFn fn)
 
bool BKE_ptcache_object_has (struct Scene *scene, struct Object *ob, int duplis)
 
void BKE_ptcache_id_clear (PTCacheID *pid, int mode, unsigned int cfra)
 
bool BKE_ptcache_id_exist (PTCacheID *pid, int cfra)
 
int BKE_ptcache_id_reset (struct Scene *scene, PTCacheID *pid, int mode)
 
void BKE_ptcache_id_time (PTCacheID *pid, struct Scene *scene, float cfra, int *startframe, int *endframe, float *timescale)
 
int BKE_ptcache_object_reset (struct Scene *scene, struct Object *ob, int mode)
 
void BKE_ptcache_update_info (PTCacheID *pid)
 
int BKE_ptcache_data_size (int data_type)
 
int BKE_ptcache_mem_index_find (struct PTCacheMem *pm, unsigned int index)
 
void BKE_ptcache_mem_pointers_init (struct PTCacheMem *pm, void *cur[BPHYS_TOT_DATA])
 
void BKE_ptcache_mem_pointers_incr (void *cur[BPHYS_TOT_DATA])
 
int BKE_ptcache_mem_pointers_seek (int point_index, struct PTCacheMem *pm, void *cur[BPHYS_TOT_DATA])
 
int BKE_ptcache_read (PTCacheID *pid, float cfra, bool no_extrapolate_old)
 
int BKE_ptcache_write (PTCacheID *pid, unsigned int cfra)
 
struct PointCacheBKE_ptcache_add (struct ListBase *ptcaches)
 
void BKE_ptcache_free_mem (struct ListBase *mem_cache)
 
void BKE_ptcache_free (struct PointCache *cache)
 
void BKE_ptcache_free_list (struct ListBase *ptcaches)
 
struct PointCacheBKE_ptcache_copy_list (struct ListBase *ptcaches_new, const struct ListBase *ptcaches_old, int flag)
 
void BKE_ptcache_quick_cache_all (struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer)
 
void BKE_ptcache_bake (struct PTCacheBaker *baker)
 
void BKE_ptcache_disk_to_mem (struct PTCacheID *pid)
 
void BKE_ptcache_mem_to_disk (struct PTCacheID *pid)
 
void BKE_ptcache_toggle_disk_cache (struct PTCacheID *pid)
 
void BKE_ptcache_disk_cache_rename (struct PTCacheID *pid, const char *name_src, const char *name_dst)
 
void BKE_ptcache_load_external (struct PTCacheID *pid)
 
void BKE_ptcache_validate (struct PointCache *cache, int framenr)
 
void BKE_ptcache_invalidate (struct PointCache *cache)
 
void BKE_ptcache_blend_write (struct BlendWriter *writer, struct ListBase *ptcaches)
 
void BKE_ptcache_blend_read_data (struct BlendDataReader *reader, struct ListBase *ptcaches, struct PointCache **ocache, int force_disk)
 

Macro Definition Documentation

◆ PEK_HIDE

#define PEK_HIDE   4

Definition at line 191 of file BKE_pointcache.h.

Referenced by brush_puff(), createTransParticleVerts(), and PE_hide_keys_time().

◆ PEK_SELECT

◆ PEK_TAG

◆ PEK_USE_WCO

◆ PEP_EDIT_RECALC

◆ PEP_HIDE

◆ PEP_TAG

◆ PEP_TRANSFORM

#define PEP_TRANSFORM   4

Definition at line 209 of file BKE_pointcache.h.

Referenced by createTransParticleVerts(), and flushTransParticles().

◆ PTCACHE_CLEAR_AFTER

#define PTCACHE_CLEAR_AFTER   3

◆ PTCACHE_CLEAR_ALL

◆ PTCACHE_CLEAR_BEFORE

#define PTCACHE_CLEAR_BEFORE   2

Definition at line 26 of file BKE_pointcache.h.

Referenced by BKE_ptcache_id_clear().

◆ PTCACHE_CLEAR_FRAME

#define PTCACHE_CLEAR_FRAME   1

◆ PTCACHE_EXT

#define PTCACHE_EXT   ".bphys"

Definition at line 36 of file BKE_pointcache.h.

Referenced by ptcache_file_extension().

◆ PTCACHE_FILE_READ

#define PTCACHE_FILE_READ   0

◆ PTCACHE_FILE_UPDATE

#define PTCACHE_FILE_UPDATE   2

Definition at line 42 of file BKE_pointcache.h.

Referenced by ptcache_file_open().

◆ PTCACHE_FILE_WRITE

#define PTCACHE_FILE_WRITE   1

◆ PTCACHE_PATH

#define PTCACHE_PATH   "blendcache_"

Definition at line 37 of file BKE_pointcache.h.

Referenced by ptcache_path().

◆ PTCACHE_READ_EXACT

#define PTCACHE_READ_EXACT   1

Definition at line 61 of file BKE_pointcache.h.

Referenced by BKE_ptcache_read(), clothModifier_do(), sbObjectStep(), and system_step().

◆ PTCACHE_READ_INTERPOLATED

#define PTCACHE_READ_INTERPOLATED   2

Definition at line 62 of file BKE_pointcache.h.

Referenced by BKE_ptcache_read(), clothModifier_do(), sbObjectStep(), and system_step().

◆ PTCACHE_READ_OLD

#define PTCACHE_READ_OLD   3

Definition at line 63 of file BKE_pointcache.h.

Referenced by BKE_ptcache_read(), clothModifier_do(), sbObjectStep(), and system_step().

◆ PTCACHE_RESET_BAKED

#define PTCACHE_RESET_BAKED   1

Definition at line 31 of file BKE_pointcache.h.

Referenced by BKE_ptcache_id_reset().

◆ PTCACHE_RESET_DEPSGRAPH

#define PTCACHE_RESET_DEPSGRAPH   0

Definition at line 30 of file BKE_pointcache.h.

Referenced by BKE_object_eval_ptcache_reset(), and BKE_ptcache_id_reset().

◆ PTCACHE_RESET_OUTDATED

◆ PTCACHE_TYPE_CLOTH

◆ PTCACHE_TYPE_DYNAMICPAINT

◆ PTCACHE_TYPE_PARTICLES

◆ PTCACHE_TYPE_RIGIDBODY

◆ PTCACHE_TYPE_SMOKE_DOMAIN

◆ PTCACHE_TYPE_SMOKE_HIGHRES

#define PTCACHE_TYPE_SMOKE_HIGHRES   4

◆ PTCACHE_TYPE_SOFTBODY

◆ PTCACHE_TYPEFLAG_COMPRESS

#define PTCACHE_TYPEFLAG_COMPRESS   (1 << 16)

Definition at line 54 of file BKE_pointcache.h.

Referenced by ptcache_disk_frame_to_mem(), and ptcache_mem_frame_to_disk().

◆ PTCACHE_TYPEFLAG_EXTRADATA

#define PTCACHE_TYPEFLAG_EXTRADATA   (1 << 17)

Definition at line 55 of file BKE_pointcache.h.

Referenced by ptcache_disk_frame_to_mem(), and ptcache_mem_frame_to_disk().

◆ PTCACHE_TYPEFLAG_FLAGMASK

#define PTCACHE_TYPEFLAG_FLAGMASK   0xFFFF0000

Definition at line 58 of file BKE_pointcache.h.

Referenced by ptcache_file_header_begin_read().

◆ PTCACHE_TYPEFLAG_TYPEMASK

#define PTCACHE_TYPEFLAG_TYPEMASK   0x0000FFFF

Definition at line 57 of file BKE_pointcache.h.

Referenced by ptcache_file_header_begin_read().

◆ PTCACHE_VEL_PER_SEC

#define PTCACHE_VEL_PER_SEC   1

Definition at line 106 of file BKE_pointcache.h.

Referenced by BKE_ptcache_id_from_particles(), and update_velocities().

Typedef Documentation

◆ PointCacheIdFn

Definition at line 293 of file BKE_pointcache.h.

◆ PTCacheBaker

typedef struct PTCacheBaker PTCacheBaker

◆ PTCacheData

typedef struct PTCacheData PTCacheData

◆ PTCacheEdit

typedef struct PTCacheEdit PTCacheEdit

◆ PTCacheEditKey

typedef struct PTCacheEditKey PTCacheEditKey

◆ PTCacheEditPoint

typedef struct PTCacheEditPoint PTCacheEditPoint

◆ PTCacheFile

typedef struct PTCacheFile PTCacheFile

◆ PTCacheID

typedef struct PTCacheID PTCacheID

◆ PTCacheUndo

typedef struct PTCacheUndo PTCacheUndo

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
PTCACHE_FILE_PTCACHE 

Definition at line 108 of file BKE_pointcache.h.

◆ anonymous enum

anonymous enum
Enumerator
PT_CACHE_EDIT_UPDATE_PARTICLE_FROM_EVAL 

Definition at line 235 of file BKE_pointcache.h.

Function Documentation

◆ BKE_ptcache_add()

◆ BKE_ptcache_bake()

void BKE_ptcache_bake ( struct PTCacheBaker * baker)

Bake cache or simulate to current frame with settings defined in the baker. if bake is not given run simulations to current frame.

Definition at line 3161 of file pointcache.cc.

References PTCacheBaker::anim_init, PTCacheBaker::bake, PTCacheBaker::bake_job, BKE_ptcache_id_clear(), BKE_ptcache_id_from_particles(), BKE_ptcache_ids_from_object(), BKE_ptcache_write(), BKE_scene_graph_update_for_newframe(), BLI_assert, BLI_freelistN(), BLI_time_now_seconds(), PTCacheID::cache, PTCacheID::calldata, DEG_get_evaluated_object(), depsgraph, PTCacheBaker::depsgraph, PointCache::endframe, ListBase::first, PointCache::flag, float, G, GS, ID_OB, PointCache::last_exact, LISTBASE_FOREACH, MAX_DUPLI_RECUR, MAXFRAME, ID::name, PTCacheID::next, Base::object, PTCacheID::owner_id, ParticleSystem::part, PART_EMITTER, PART_HAIR, PART_PHYS_KEYED, ParticleSettings::phystype, PTCacheBaker::pid, printf, psys_eval_get(), psys_get_pointcache_start_end(), PTCACHE_BAKED, PTCACHE_BAKING, PTCACHE_CLEAR_ALL, PTCACHE_DISK_CACHE, ptcache_dt_to_str(), PTCACHE_OUTDATED, PTCACHE_REDO_NEEDED, PTCACHE_SIMULATION_VALID, PTCACHE_TYPE_PARTICLES, PTCACHE_TYPE_RIGIDBODY, PTCACHE_TYPE_SMOKE_DOMAIN, PTCACHE_TYPE_SMOKE_HIGHRES, PTCacheBaker::quick_step, PTCacheBaker::render, PTCacheBaker::scene, SETLOOPER_VIEW_LAYER, PointCache::startframe, ParticleSettings::type, PTCacheID::type, PTCacheBaker::update_progress, and PTCacheBaker::view_layer.

Referenced by BKE_ptcache_quick_cache_all(), ptcache_bake_exec(), ptcache_job_startjob(), and update_physics_cache().

◆ BKE_ptcache_blend_read_data()

void BKE_ptcache_blend_read_data ( struct BlendDataReader * reader,
struct ListBase * ptcaches,
struct PointCache ** ocache,
int force_disk )

◆ BKE_ptcache_blend_write()

◆ BKE_ptcache_copy_list()

struct PointCache * BKE_ptcache_copy_list ( struct ListBase * ptcaches_new,
const struct ListBase * ptcaches_old,
int flag )

◆ BKE_ptcache_data_size()

int BKE_ptcache_data_size ( int data_type)

Size of cache data type.

Definition at line 1706 of file pointcache.cc.

References ptcache_data_size.

Referenced by BKE_ptcache_blend_write(), and direct_link_pointcache_mem().

◆ BKE_ptcache_disk_cache_rename()

void BKE_ptcache_disk_cache_rename ( struct PTCacheID * pid,
const char * name_src,
const char * name_dst )

◆ BKE_ptcache_disk_to_mem()

◆ BKE_ptcache_foreach_object_cache()

void BKE_ptcache_foreach_object_cache ( struct Object & ob,
struct Scene & scene,
bool duplis,
PointCacheIdFn fn )

◆ BKE_ptcache_free()

◆ BKE_ptcache_free_list()

◆ BKE_ptcache_free_mem()

void BKE_ptcache_free_mem ( struct ListBase * mem_cache)

◆ BKE_ptcache_id_clear()

◆ BKE_ptcache_id_exist()

◆ BKE_ptcache_id_find()

PTCacheID BKE_ptcache_id_find ( struct Object * ob,
struct Scene * scene,
struct PointCache * cache )
Parameters
obOptional, may be NULL.
sceneOptional may be NULL.

Definition at line 1094 of file pointcache.cc.

References BKE_ptcache_ids_from_object(), BLI_freelistN(), LISTBASE_FOREACH, MAX_DUPLI_RECUR, and result.

Referenced by ptcache_add_new_exec(), ptcache_baker_create(), and ptcache_remove_exec().

◆ BKE_ptcache_id_from_cloth()

◆ BKE_ptcache_id_from_dynamicpaint()

◆ BKE_ptcache_id_from_particles()

void BKE_ptcache_id_from_particles ( PTCacheID * pid,
struct Object * ob,
struct ParticleSystem * psys )

Definition at line 900 of file pointcache.cc.

References ParticleSettings::avefac, ParticleSettings::avemode, BPHYS_DATA_AVELOCITY, BPHYS_DATA_BOIDS, BPHYS_DATA_INDEX, BPHYS_DATA_LOCATION, BPHYS_DATA_ROTATION, BPHYS_DATA_TIMES, BPHYS_DATA_VELOCITY, PTCacheID::cache, PTCacheID::cache_ptr, PTCacheID::calldata, PTCacheID::data_types, PTCacheID::default_step, PTCacheID::error, PTCacheID::file_type, ParticleSettings::flag, PTCacheID::flag, SPHFluidSettings::flag, ParticleSettings::fluid, Object::id, PointCache::index, PTCacheID::info_types, PTCacheID::interpolate_extra_data, PTCacheID::interpolate_point, PTCacheID::max_step, PTCacheID::owner_id, ParticleSystem::part, PART_AVE_RAND, PART_HAIR, PART_PHYS_BOIDS, PART_PHYS_FLUID, PART_ROT_VEL, PART_ROTATIONS, ParticleSettings::phystype, ParticleSystem::pointcache, ptcache_basic_header_read(), ptcache_basic_header_write(), PTCACHE_FILE_PTCACHE, ptcache_particle_error(), ptcache_particle_extra_read(), ptcache_particle_extra_write(), ptcache_particle_interpolate(), ptcache_particle_read(), ptcache_particle_totpoint(), ptcache_particle_totwrite(), ptcache_particle_write(), PTCACHE_TYPE_PARTICLES, PTCACHE_VEL_PER_SEC, ParticleSystem::ptcaches, PTCacheID::ptcaches, PTCacheID::read_extra_data, PTCacheID::read_header, PTCacheID::read_point, PTCacheID::read_stream, ParticleSettings::rotmode, SPH_VISCOELASTIC_SPRINGS, PTCacheID::stack_index, PTCacheID::totpoint, PTCacheID::totwrite, ParticleSettings::type, PTCacheID::type, PTCacheID::write_extra_data, PTCacheID::write_header, PTCacheID::write_point, and PTCacheID::write_stream.

Referenced by BKE_ptcache_bake(), BKE_ptcache_object_reset(), foreach_object_particle_ptcache(), free_hair(), psys_changed_type(), psys_make_temp_pointcache(), psys_prepare_physics(), and system_step().

◆ BKE_ptcache_id_from_rigidbody()

◆ BKE_ptcache_id_from_smoke()

void BKE_ptcache_id_from_smoke ( PTCacheID * pid,
struct Object * ob,
struct FluidModifierData * fmd )

The fluid modifier does not actually use this anymore, but some parts of Blender expect that it still has a point cache currently. For example, the fluid modifier uses DEG_add_collision_relations, which internally creates relations with the point cache.

Definition at line 1001 of file pointcache.cc.

References PTCacheID::cache, PTCacheID::cache_ptr, PTCacheID::calldata, FluidModifierData::domain, Object::id, PointCache::index, PTCacheID::owner_id, FluidDomainSettings::point_cache, PTCACHE_TYPE_SMOKE_DOMAIN, FluidDomainSettings::ptcaches, PTCacheID::ptcaches, PTCacheID::stack_index, and PTCacheID::type.

Referenced by BKE_ptcache_object_reset(), and foreach_object_modifier_ptcache().

◆ BKE_ptcache_id_from_softbody()

◆ BKE_ptcache_id_reset()

◆ BKE_ptcache_id_time()

◆ BKE_ptcache_ids_from_object()

◆ BKE_ptcache_invalidate()

void BKE_ptcache_invalidate ( struct PointCache * cache)

Set correct flags after unsuccessful simulation step.

Definition at line 3796 of file pointcache.cc.

References PointCache::flag, PointCache::last_exact, PointCache::simframe, and PointCache::startframe.

Referenced by BKE_ptcache_id_reset(), clothModifier_do(), do_init_cloth(), psys_reset(), sbObjectStep(), and system_step().

◆ BKE_ptcache_load_external()

◆ BKE_ptcache_make_particle_key()

◆ BKE_ptcache_mem_index_find()

int BKE_ptcache_mem_index_find ( struct PTCacheMem * pm,
unsigned int index )

Is point with index in memory cache? Check to see if point number "index" is in pm (uses binary search for index data).

Definition at line 1729 of file pointcache.cc.

References BPHYS_DATA_INDEX, data, PTCacheMem::data, and PTCacheMem::totpoint.

Referenced by BKE_ptcache_mem_pointers_seek(), get_pointcache_keys_for_time(), get_pointcache_times_for_particle(), and psys_get_dietime_from_cache().

◆ BKE_ptcache_mem_pointers_incr()

void BKE_ptcache_mem_pointers_incr ( void * cur[BPHYS_TOT_DATA])

◆ BKE_ptcache_mem_pointers_init()

void BKE_ptcache_mem_pointers_init ( struct PTCacheMem * pm,
void * cur[BPHYS_TOT_DATA] )

◆ BKE_ptcache_mem_pointers_seek()

int BKE_ptcache_mem_pointers_seek ( int point_index,
struct PTCacheMem * pm,
void * cur[BPHYS_TOT_DATA] )

◆ BKE_ptcache_mem_to_disk()

void BKE_ptcache_mem_to_disk ( struct PTCacheID * pid)

◆ BKE_ptcache_object_has()

bool BKE_ptcache_object_has ( struct Scene * scene,
struct Object * ob,
int duplis )

◆ BKE_ptcache_object_reset()

◆ BKE_ptcache_quick_cache_all()

void BKE_ptcache_quick_cache_all ( struct Main * bmain,
struct Scene * scene,
struct ViewLayer * view_layer )

Bakes cache with cache_step sized jumps in time, not accurate but very fast.

Definition at line 3125 of file pointcache.cc.

References PTCacheBaker::anim_init, PTCacheBaker::bake, BKE_ptcache_bake(), PTCacheBaker::bmain, PTCacheBaker::quick_step, PTCacheBaker::render, PTCacheBaker::scene, scene, and PTCacheBaker::view_layer.

◆ BKE_ptcache_read()

◆ BKE_ptcache_toggle_disk_cache()

◆ BKE_ptcache_update_info()

◆ BKE_ptcache_validate()

void BKE_ptcache_validate ( struct PointCache * cache,
int framenr )

Set correct flags after successful simulation step.

Definition at line 3789 of file pointcache.cc.

References PointCache::flag, PTCACHE_SIMULATION_VALID, and PointCache::simframe.

Referenced by clothModifier_do(), dynamicPaint_frameUpdate(), sbObjectStep(), and system_step().

◆ BKE_ptcache_write()