84#define PTCACHE_DATA_FROM(data, type, from) \
86 memcpy(data[type], from, ptcache_data_size[type]); \
90#define PTCACHE_DATA_TO(data, type, index, to) \
93 (char *)(data)[type] + ((index) ? (index) * ptcache_data_size[type] : 0), \
94 ptcache_data_size[type]); \
99#define DURIAN_POINTCACHE_LIB_OK 1
144 if (!error && !fread(&
pf->totpoint,
sizeof(
uint), 1,
pf->fp)) {
148 if (!error && !fread(&
pf->data_types,
sizeof(
uint), 1,
pf->fp)) {
157 if (!fwrite(&
pf->totpoint,
sizeof(
uint), 1,
pf->fp)) {
161 if (!fwrite(&
pf->data_types,
sizeof(
uint), 1,
pf->fp)) {
172 PTCacheExtra *extra = MEM_new<PTCacheExtra>(
"Point cache: extra data descriptor");
196 int index,
void *soft_v,
void **
data,
float ,
const float *old_data)
202 memcpy(bp->
pos,
data,
sizeof(
float[3]));
203 memcpy(bp->
vec,
data + 3,
sizeof(
float[3]));
216 const float *old_data)
223 if (cfra1 == cfra2) {
231 memcpy(keys[2].co, old_data,
sizeof(
float[3]));
232 memcpy(keys[2].vel, old_data + 3,
sizeof(
float[3]));
238 dfra = cfra2 - cfra1;
292 if (cfra < pa->time -
step) {
298 const int pa_sfra = int(pa->
time) -
step;
300 if (!(cfra >= pa_sfra && cfra <= pa_efra)) {
327 int index,
void *psys_v,
void **
data,
float cfra,
const float *old_data)
334 if (index < 0 || index >= psys->
totpart) {
354 if (cfra < pa->time) {
400 const float *old_data)
407 if (index < 0 || index >= psys->
totpart) {
418 if (!(cfra1 >= pa_sfra && cfra1 <= pa_efra)) {
422 cfra = std::min(cfra, pa->
dietime);
423 cfra1 = std::min(cfra1, pa->
dietime);
424 cfra2 = std::min(cfra2, pa->
dietime);
426 if (cfra1 == cfra2) {
432 keys[2] = *
reinterpret_cast<const ParticleKey *
>(old_data);
440 if (keys[1].time > keys[2].time) {
442 mul_v3_fl(keys[2].vel, (keys[1].time - keys[2].time) * timestep);
446 mul_v3_fl(keys[2].vel, (keys[2].time - keys[1].time) * timestep);
455 if (cfra > pa->
time) {
456 cfra1 = std::max(cfra1, pa->
time);
459 dfra = cfra2 - cfra1;
498 for (p = 0; p < psys->
totpart; p++, pa++) {
499 const int pa_sfra = int(pa->
time) -
step;
500 totwrite += (cfra >= pa_sfra);
504 for (p = 0; p < psys->
totpart; p++, pa++) {
506 const int pa_sfra = int(pa->
time) -
step;
508 totwrite += (cfra >= pa_sfra) && (cfra <= pa_efra);
533 for (; extra; extra = extra->
next) {
534 switch (extra->
type) {
575 int index,
void *cloth_v,
void **
data,
float ,
const float *old_data)
582 memcpy(vert->x,
data,
sizeof(
float[3]));
583 memcpy(vert->xconst,
data + 3,
sizeof(
float[3]));
584 memcpy(vert->v,
data + 6,
sizeof(
float[3]));
598 const float *old_data)
606 if (cfra1 == cfra2) {
614 memcpy(keys[2].co, old_data,
sizeof(
float[3]));
615 memcpy(keys[2].vel, old_data + 6,
sizeof(
float[3]));
621 dfra = cfra2 - cfra1;
653 for (; extra; extra = extra->
next) {
654 switch (extra->
type) {
681 id_cast<Object *>(
const_cast<ID *
>(owner_id)), &clmd->
modifier,
"%s", message);
689 if (!surface->
data) {
703#define DPAINT_CACHE_VERSION "1.01"
717 const int surface_type = int(surface->
type);
725 in_stride =
sizeof(
float);
761 if (surface_type != surface->
type) {
770 data_len =
sizeof(
float);
784 CLOG_ERROR(&
LOG,
"Dynamic Paint: Unable to read the compressed cache data");
817 int index,
void *rb_v,
void **
data,
float ,
const float *old_data)
832 memcpy(rbo->
pos,
data,
sizeof(
float[3]));
833 memcpy(rbo->
orn,
data + 3,
sizeof(
float[4]));
848 const float *old_data)
864 float pos[3], orn[4];
867 memcpy(pos,
data,
sizeof(
float[3]));
868 memcpy(orn,
data + 3,
sizeof(
float[4]));
875 const float t = (cfra - cfra1) / (cfra2 - cfra1);
1094 pid->
owner_id = ob !=
nullptr ? &ob->
id :
nullptr;
1131 ListBaseT<PTCacheID> pidlist;
1135 if (pid.cache == cache) {
1141 pidlist.free_no_destruct();
1160 for (
ParticleSystem *psys =
object->particlesystem.first(); psys !=
nullptr; psys = psys->next) {
1161 if (psys->part ==
nullptr) {
1179 if (!callback(pid,
nullptr)) {
1192 if (!callback(pid, md)) {
1200 if (!callback(pid, md)) {
1209 for (; surface; surface = surface->
next) {
1211 if (!callback(pid, md)) {
1229 if (
object !=
nullptr) {
1231 if (
object->soft !=
nullptr) {
1233 if (!callback(pid,
nullptr)) {
1248 if (scene !=
nullptr && (duplis-- > 0) && (
object->instance_collection !=
nullptr)) {
1250 if (current_object ==
object) {
1260 if (scene !=
nullptr && (
object ==
nullptr ||
object->rigidbody_object !=
nullptr) &&
1264 if (!callback(pid,
nullptr)) {
1273 lb->first_ = lb->last_ =
nullptr;
1289 bool has_point_cache =
false;
1291 has_point_cache =
true;
1294 return has_point_cache;
1313 const int frame_len = 6;
1314 const int ext_len = frame_len + strlen(ext);
1318 if (
len > ext_len) {
1335#define MAX_PTCACHE_PATH FILE_MAX
1336#define MAX_PTCACHE_FILE (FILE_MAX * 2)
1355 if ((blendfile_path[0] !=
'\0') || lib) {
1378 const size_t filepath_len,
1379 const bool use_frame_number,
1382 size_t len = filepath_len;
1384 filename_ext = filepath + filepath_len;
1385 *filename_ext =
'\0';
1395 if (use_frame_number) {
1443 if (blendfile_path[0] ==
'\0') {
1456 while (
'\0' != *idname) {
1486#ifndef DURIAN_POINTCACHE_LIB_OK
1494 if (blendfile_path[0] ==
'\0') {
1517 pf = MEM_new<PTCacheFile>(
"PTCacheFile");
1534 const size_t items_num,
1535 const size_t item_size)
1537 const size_t out_len = items_num * item_size;
1539 uchar compressed_val = 0;
1549 if (!
ELEM(compressed,
1563 return out_len == 0;
1566 if (
in ==
nullptr) {
1576 const bool decompressed = ZSTD_decompress(
result, out_len,
in, in_len) == out_len;
1578 return decompressed;
1583 const bool decompressed = decomp_result &&
1584 ZSTD_decompress(decomp_result, out_len,
in, in_len) == out_len;
1588 MEM_SAFE_DELETE(decomp_result);
1591 return decompressed;
1601 const size_t data_size = items_num * item_size;
1602 size_t out_len = ZSTD_compressBound(data_size);
1608 static_cast<const uint8_t *
>(
data), filtered.
data(), items_num, item_size);
1611 const int zstd_level = 3;
1612 size_t res = ZSTD_compress(
out.data(), out_len, filtered.
data(), data_size, zstd_level);
1617 const uchar compression_val = compression;
1619 uint size = out_len;
1627 return (fread(f, item_size, items_num,
pf->fp) == items_num);
1634 return (fwrite(
data, item_size, items_num,
pf->fp) == items_num);
1644 if (fread(bphysics,
sizeof(
char), 8,
pf->fp) != 8) {
1648 if (!error && !
STREQLEN(bphysics,
"BPHYSICS", 8)) {
1652 if (!error && !fread(&typeflag,
sizeof(
uint), 1,
pf->fp)) {
1668 const char *bphysics =
"BPHYSICS";
1669 uint typeflag =
pf->type +
pf->flag;
1671 if (fwrite(bphysics,
sizeof(
char), 8,
pf->fp) != 8) {
1675 if (!fwrite(&typeflag,
sizeof(
uint), 1,
pf->fp)) {
1691 int data_types =
pf->data_types;
1713 if (index < *data || index > *(
data + high)) {
1722 while (low <= high) {
1723 mid = (low + high) / 2;
1739 return (index < pm->totpoint ?
index : -1);
1748 cur[i] = ((data_types & (1 << i)) ? pm->
data[i] :
nullptr);
1775 cur[i] = (data_types & (1 << i)) ?
1787 if (data_types & (1 << i)) {
1788 pm->
data[i] = zero_init ?
1792 if (pm->
data[i] ==
nullptr) {
1817 for (; extra; extra = extra->
next) {
1836 return sizeof(
float[6]);
1842 return sizeof(
float[9]);
1851 int cfra1 = frame, cfra2 = frame + 1;
1857 if (cfra1 < pid->cache->startframe) {
1869 if (cfra1 && !cfra2) {
1886 if (pm2->
frame < frame) {
1897 *r_fra2 = pm->
frame;
1900 *r_fra1 = pm->
frame;
1901 *r_fra2 = pm2->
frame;
1930 if (
pf ==
nullptr) {
1943 pm = MEM_new<PTCacheMem>(
"Pointcache mem");
1954 if (
pf->data_types & (1 << i)) {
1984 if (
data ==
nullptr) {
1989 PTCacheExtra *extra = MEM_new<PTCacheExtra>(
"Pointcache extradata");
2016 printf(
"Error reading from disk cache\n");
2031 if (
pf ==
nullptr) {
2033 printf(
"Error opening disk cache file for writing\n");
2064 for (; extra; extra = extra->
next) {
2065 if (extra->
data ==
nullptr || extra->
totdata == 0) {
2096 if (
pf ==
nullptr) {
2098 printf(
"Error opening disk cache file for reading\n");
2107 else if (
pf->type != pid->
type) {
2148 while (pm && pm->
frame != cfra) {
2160 if (totpoint != pid_totpoint) {
2162 totpoint = std::min(totpoint, pid_totpoint);
2174 for (i = 0; i < totpoint; i++) {
2210 while (pm && pm->
frame != cfra2) {
2222 if (totpoint != pid_totpoint) {
2224 totpoint = std::min(totpoint, pid_totpoint);
2236 for (i = 0; i < totpoint; i++) {
2242 *
index, pid->
calldata, cur, cfra,
float(cfra1),
float(cfra2),
nullptr);
2262 int cfrai = int(
floor(cfra)), cfra1 = 0, cfra2 = 0;
2285 if (cfra1 == 0 && cfra2 == 0) {
2290 if (no_extrapolate_old) {
2291 if (cfra1 == 0 && cfra2 && cfra2 <= pid->cache->simframe) {
2294 if (cfra1 && cfra1 == cfra2) {
2300 if (cfra1 && cfra1 == cfra2) {
2346 if (cfra <= pid->cache->last_exact) {
2364 if (
pf ==
nullptr) {
2366 printf(
"Error opening disk cache file for writing\n");
2372 pf->totpoint = totpoint;
2387 printf(
"Error writing to disk cache\n");
2400 pm = MEM_new<PTCacheMem>(
"Pointcache mem");
2429 for (i = 0; i < totpoint; i++) {
2473 int ofra = 0, efra = cache->
endframe;
2505 if (pm ==
nullptr) {
2513 if (efra >= cache->
startframe && cfra > efra) {
2534 int overwrite = 0, error = 0;
2600#ifndef DURIAN_POINTCACHE_LIB_OK
2616 if (dir ==
nullptr) {
2624 if (
len <
sizeof(filepath) - 2) {
2631 while ((de =
readdir(dir)) !=
nullptr) {
2632 if (strstr(de->
d_name, ext)) {
2671 for (; pm; pm = pm->
next) {
2711 for (; pm; pm = pm->
next) {
2712 if (pm->
frame == cfra) {
2734 if (cfra < pid->cache->startframe || cfra > pid->
cache->
endframe) {
2752 for (; pm; pm = pm->
next) {
2753 if (pm->
frame == cfra) {
2760 PTCacheID *pid,
Scene *scene,
float cfra,
int *startframe,
int *endframe,
float *timescale)
2765 float time, nexttime;
2785 *timescale = std::max(nexttime - time, 0.0f);
2788 if (startframe && endframe) {
2808 "cached frames array");
2824 if (dir ==
nullptr) {
2830 while ((de =
readdir(dir)) !=
nullptr) {
2831 if (strstr(de->
d_name, ext)) {
2836 if ((frame != -1) && (frame >= sta && frame <= end)) {
2859 int reset, clear, after;
2914 return (
reset || clear || after);
2936 else if (psys.
clmd) {
2948 if (skip == 0 && psys.
part) {
2964 for (; surface; surface = surface->
next) {
3004 cache = MEM_new<PointCache>(
"PointCache");
3020 for (; pm; pm = pm->
next) {
3024 mem_cache->free_no_destruct();
3049 ncache = MEM_dupalloc(cache);
3053 if (copy_data ==
false) {
3081 ncache->
edit =
nullptr;
3087 const ListBaseT<PointCache> *ptcaches_old,
3092 ptcaches_new->clear_no_delete();
3094 for (; cache; cache = cache->
next) {
3098 return ptcaches_new->first();
3110 memset(&baker, 0,
sizeof(baker));
3111 baker.
bmain = bmain;
3112 baker.
scene = scene;
3125 if (dtime > 3600.0) {
3130 int(dtime / 60) % 60,
3134 BLI_snprintf(
str, str_maxncpy,
"%im %is",
int(dtime / 60) % 60,
int(dtime) % 60);
3147 Depsgraph *depsgraph = baker->
depsgraph;
3150 ListBaseT<PTCacheID> pidlist;
3154 int cfrao = scene->
r.
cfra;
3179 ListBaseT<PTCacheID> pidlist2;
3196 pidlist2.free_no_destruct();
3210 endframe = std::min(endframe, cache->
endframe);
3221 for (pid = pidlist.first(); pid; pid = pid->
next) {
3250 startframe = std::min(startframe, cache->
startframe);
3256 endframe = std::max(endframe, cache->
endframe);
3263 pidlist.free_no_destruct();
3267 scene->
r.
cfra = startframe;
3272 bool use_timer =
false;
3273 double stime, ptime, ctime, fetd;
3274 char run[32], cur[32], etd[32];
3279 for (
int fr = scene->
r.
cfra; fr <= endframe; fr += baker->quick_step, scene->
r.
cfra = fr) {
3283 float progress = (
float(scene->
r.
cfra - startframe) /
float(endframe - startframe));
3288 printf(
"bake: frame %d :: %d\n", scene->
r.
cfra, endframe);
3293 fetd = (ctime - ptime) * (endframe - scene->
r.
cfra) / baker->
quick_step;
3295 if (use_timer || fetd > 60.0) {
3302 printf(
"Baked for %s, current frame: %i/%i (%.3fs), ETC: %s\r",
3304 scene->
r.
cfra - startframe + 1,
3305 endframe - startframe + 1,
3314 if (cancel ||
G.is_break) {
3324 printf(
"\nBake %s %s (%i frames simulated).\n",
3325 (cancel ?
"canceled after" :
"finished in"),
3327 scene->
r.
cfra - startframe);
3398 pidlist.free_no_destruct();
3403 scene->
r.
cfra = cfrao;
3428 cache->
flag |= baked;
3430 for (cfra = sfra; cfra <= efra; cfra++) {
3451 cache->
flag |= baked;
3453 for (; pm; pm = pm->
next) {
3471 if (blendfile_path[0] ==
'\0') {
3474 printf(
"File must be saved before using disk cache!\n");
3524 if (
STREQ(name_src, name_dst)) {
3538 if (dir ==
nullptr) {
3548 while ((de =
readdir(dir)) !=
nullptr) {
3549 if (strstr(de->
d_name, ext)) {
3592 if (dir ==
nullptr) {
3598 if (cache->
index >= 0) {
3605 while ((de =
readdir(dir)) !=
nullptr) {
3606 if (strstr(de->
d_name, ext)) {
3613 start = std::min(start, frame);
3614 end = std::max(end, frame);
3691 for (; cfra <= cache->
endframe; cfra++) {
3701 else if (totframes && cache->
totpoint) {
3724 for (; cfra <= cache->
endframe; cfra++) {
3737 long long int bytes = 0.0f;
3740 for (; pm; pm = pm->
next) {
3762 SNPRINTF_UTF8(mem_info,
RPT_(
"%s frames in memory (%s)"), formatted_tot, formatted_mem);
3825 else if (extra.
data) {
3838 if (pm->
data[i] ==
nullptr) {
3855 reinterpret_cast<float **
>(&pm->
data[i]),
3875 else if (extra.
data) {
3876 extra.
data =
nullptr;
3895 cache->
edit =
nullptr;
3902 ListBaseT<PointCache> *ptcaches,
3906 if (ptcaches->first()) {
3924 (*ocache)->step = 1;
3927 ptcaches->first_ = ptcaches->last_ = *ocache;
#define FOREACH_COLLECTION_OBJECT_RECURSIVE_END
#define FOREACH_COLLECTION_OBJECT_RECURSIVE_BEGIN(_collection, _object)
General operations, lookup, etc. for blender objects.
#define PSYS_RESET_DEPSGRAPH
#define PTCACHE_TYPEFLAG_TYPEMASK
#define PTCACHE_FILE_READ
#define PTCACHE_TYPE_SMOKE_HIGHRES
#define PTCACHE_VEL_PER_SEC
#define PTCACHE_FILE_WRITE
#define PTCACHE_CLEAR_BEFORE
#define PTCACHE_CLEAR_AFTER
#define PTCACHE_TYPE_CLOTH
#define PTCACHE_TYPE_DYNAMICPAINT
#define PTCACHE_CLEAR_ALL
#define PTCACHE_READ_INTERPOLATED
#define PTCACHE_TYPE_PARTICLES
#define PTCACHE_TYPEFLAG_FLAGMASK
#define PTCACHE_TYPE_SOFTBODY
#define PTCACHE_TYPEFLAG_COMPRESS
#define PTCACHE_FILE_UPDATE
#define PTCACHE_CLEAR_FRAME
#define PTCACHE_TYPE_SMOKE_DOMAIN
#define PTCACHE_RESET_OUTDATED
#define PTCACHE_TYPE_RIGIDBODY
#define PTCACHE_RESET_DEPSGRAPH
#define PTCACHE_RESET_BAKED
#define PTCACHE_READ_EXACT
#define PTCACHE_TYPEFLAG_EXTRADATA
#define SETLOOPER_VIEW_LAYER(_bmain, _sce_basis, _view_layer, _sce_iter, _base)
File and directory operations.
#define BLI_path_join(...)
#define BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE
#define SNPRINTF(dst, format,...)
#define BLI_STR_FORMAT_INT32_GROUPED_SIZE
#define SNPRINTF_UTF8(dst, format,...)
#define STRNCPY_UTF8(dst, src)
Platform independent time functions.
Compatibility-like things for windows.
struct dirent * readdir(DIR *dp)
const char * dirname(char *path)
DIR * opendir(const char *path)
#define BLO_read_struct_nonnull(reader, struct_name, ptr_p)
#define BLO_read_struct_list(reader, struct_name, list)
#define CLOG_ERROR(clg_ref,...)
ID and Library types, which are fundamental for SDNA.
Object is a sort of wrapper for general info.
Types and defines for representing Rigid Body entities.
Read Blender memory allocation and freeing.
Rigid Body API for interfacing with external Physics Engines.
#define BLI_assert_unreachable()
#define STREQLEN(a, b, n)
#define pf(_x, _i)
Prefetch 64.
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
std::string filename(const std::string_view &str, size_t pos)
void BLI_str_format_byte_unit(char dst[BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE], long long int bytes, bool base_10) ATTR_NONNULL(1)
int BKE_object_insert_ptcache(Object *ob)
bool bool BLI_path_extension_strip(char *path) ATTR_NONNULL(1)
void * MEM_new_uninitialized(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
int BKE_ptcache_read(PTCacheID *pid, float cfra, bool no_extrapolate_old)
static void ptcache_extra_free(PTCacheMem *pm)
static bool ptcache_file_read(PTCacheFile *pf, void *f, size_t items_num, size_t item_size)
void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra)
void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph)
static void ptcache_softbody_error(const ID *, void *, const char *)
static int ptcache_write(PTCacheID *pid, int cfra, int overwrite)
static bool foreach_object_particle_ptcache(Object *object, PointCacheIdFn callback)
size_t BLI_snprintf(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
static int ptcache_basic_header_write(PTCacheFile *pf)
char * STRNCPY(char(&dst)[N], const char *src)
void BKE_modifier_set_error(const Object *ob, ModifierData *md, const char *format,...) ATTR_PRINTF_FORMAT(3
static int ptcache_frame_from_filename(const char *filename, const char *ext)
static bool ptcache_data_alloc(PTCacheMem *pm, const bool zero_init)
int BKE_ptcache_path(PTCacheID *pid, char *dirname)
static int ptcache_dynamicpaint_totpoint(void *sd, int)
static void ptcache_cloth_extra_write(void *cloth_v, PTCacheMem *pm, int)
static void direct_link_pointcache(BlendDataReader *reader, PointCache *cache)
static void ptcache_dynamicpaint_error(const ID *, void *, const char *)
static int ptcache_particle_totwrite(void *psys_v, int cfra)
int BKE_ptcache_object_reset(struct Scene *scene, struct Object *ob, int mode)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
static int ptcache_rigidbody_write(int index, void *rb_v, void **data, int)
bool BLI_path_abs(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
static bool ptcache_file_compressed_read(PTCacheFile *pf, uchar *result, size_t items_num, size_t item_size)
static int ptcache_dynamicpaint_write(PTCacheFile *pf, void *dp_v)
static int ptcache_interpolate(PTCacheID *pid, float cfra, int cfra1, int cfra2)
void dynamicPaint_clearSurface(const struct Scene *scene, struct DynamicPaintSurface *surface)
static int ptcache_write_needed(PTCacheID *pid, int cfra, int *overwrite)
static void ptcache_particle_read(int index, void *psys_v, void **data, float cfra, const float *old_data)
void sbFreeSimulation(struct SoftBody *sb)
void BKE_ptcache_disk_to_mem(struct PTCacheID *pid)
void vec_to_quat(float q[4], const float vec[3], short axis, short upflag)
int BKE_ptcache_id_reset(struct Scene *scene, PTCacheID *pid, int mode)
bool BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
FILE * BLI_fopen(const char *filepath, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
int BKE_ptcache_mem_index_find(struct PTCacheMem *pm, unsigned int index)
void cloth_free_modifier(ClothModifierData *clmd)
float BKE_scene_frame_to_ctime(const Scene *scene, int frame)
static const char * ptcache_file_extension(const PTCacheID *pid)
static int ptcache_write_stream(PTCacheID *pid, int cfra, int totpoint)
@ PTCACHE_SIMULATION_VALID
@ PTCACHE_FLAG_INFO_DIRTY
@ eModifierType_DynamicPaint
int BLI_fseek(FILE *stream, int64_t offset, int whence)
void BKE_ptcache_load_external(struct PTCacheID *pid)
static void ptcache_cloth_error(const ID *owner_id, void *cloth_v, const char *message)
void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct FluidModifierData *fmd)
bool BKE_ptcache_id_exist(PTCacheID *pid, int cfra)
const char * BKE_main_blendfile_path_from_global()
static void ptcache_particle_error(const ID *, void *, const char *)
bool BKE_ptcache_object_has(struct Scene *scene, struct Object *ob, int duplis)
void BKE_ptcache_id_from_cloth(PTCacheID *pid, struct Object *ob, struct ClothModifierData *clmd)
void MEM_delete_void(void *vmemh)
const char * BKE_tempdir_session() ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
size_t BLI_snprintf_rlen(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
void BKE_object_delete_ptcache(Object *ob, int index)
void BKE_ptcache_id_from_rigidbody(PTCacheID *pid, struct Object *ob, struct RigidBodyWorld *rbw)
MINLINE void mul_v3_fl(float r[3], float f)
static int ptcache_particle_totpoint(void *psys_v, int)
void filter_transpose_delta(const uint8_t *src, uint8_t *dst, size_t items_num, size_t item_size)
static void ptcache_rigidbody_interpolate(int index, void *rb_v, void **data, float cfra, float cfra1, float cfra2, const float *old_data)
@ FLUID_DOMAIN_CACHE_REPLAY
void * BLI_pophead(ListBase *listbase) ATTR_NONNULL(1)
void BKE_ptcache_free(struct PointCache *cache)
static void ptcache_mem_clear(PTCacheMem *pm)
static bool ptcache_file_write(PTCacheFile *pf, const void *data, size_t items_num, size_t item_size)
void BKE_ptcache_blend_read_data(struct BlendDataReader *reader, ListBaseT< PointCache > *ptcaches, struct PointCache **ocache, int force_disk)
void BIK_clear_cache(struct bPose *pose)
static void ptcache_particle_extra_write(void *psys_v, PTCacheMem *pm, int)
static void ptcache_rigidbody_read(int index, void *rb_v, void **data, float, const float *old_data)
static int ptcache_file_header_begin_read(PTCacheFile *pf)
void BKE_ptcache_quick_cache_all(struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer)
static void ptcache_cloth_read(int index, void *cloth_v, void **data, float, const float *old_data)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
void BKE_ptcache_mem_pointers_incr(void *cur[BPHYS_TOT_DATA])
void * MEM_dupalloc_void(const void *vmemh) ATTR_WARN_UNUSED_RESULT
static int ptcache_basic_header_read(PTCacheFile *pf)
static int ptcache_read_stream(PTCacheID *pid, int cfra)
int BKE_ptcache_write(PTCacheID *pid, unsigned int cfra)
static void ptcache_cloth_extra_read(void *cloth_v, PTCacheMem *pm, float)
static int ptcache_rigidbody_totpoint(void *rb_v, int)
BMesh const char void * data
static bool ptcache_file_compressed_write(PTCacheFile *pf, const void *data, size_t items_num, size_t item_size)
void interp_qt_qtqt(float q[4], const float a[4], const float b[4], float t)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
int BLI_delete(const char *path, bool dir, bool recursive) ATTR_NONNULL()
char char size_t BLI_strncpy_rlen(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
void BLI_freelinkN(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
static void ptcache_data_free(PTCacheMem *pm)
@ MOD_DPAINT_SURFACE_F_IMAGESEQ
void BKE_ptcache_bake(struct PTCacheBaker *baker)
static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v)
void BKE_ptcache_id_time(PTCacheID *pid, struct Scene *scene, float cfra, int *startframe, int *endframe, float *timescale)
static int ptcache_filepath(PTCacheID *pid, char filepath[MAX_PTCACHE_FILE], int cfra, const bool do_path, const bool do_ext)
static PointCache * ptcache_copy(PointCache *cache, const bool copy_data)
int BLI_rename_overwrite(const char *from, const char *to) ATTR_NONNULL()
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
static size_t ptcache_filepath_ext_append(PTCacheID *pid, char filepath[MAX_PTCACHE_FILE], const size_t filepath_len, const bool use_frame_number, const int cfra)
void BKE_ptcache_ids_from_object(ListBaseT< PTCacheID > *lb, struct Object *ob, struct Scene *scene, int duplis)
static void ptcache_softbody_interpolate(int index, void *soft_v, void **data, float cfra, float cfra1, float cfra2, const float *old_data)
ATTR_WARN_UNUSED_RESULT const size_t num
static int ptcache_softbody_write(int index, void *soft_v, void **data, int)
static int ptcache_cloth_totpoint(void *cloth_v, int)
int BLI_path_slash_ensure(char *path, size_t path_maxncpy) ATTR_NONNULL(1)
void BKE_ptcache_id_from_dynamicpaint(PTCacheID *pid, struct Object *ob, struct DynamicPaintSurface *surface)
MINLINE void zero_v3(float r[3])
static bool foreach_object_modifier_ptcache(Object *object, PointCacheIdFn callback)
static void ptcache_rigidbody_error(const ID *, void *, const char *)
static PTCacheFile * ptcache_file_open(PTCacheID *pid, int mode, int cfra)
bool BLO_read_array(BlendDataReader *reader, T **ptr_p, const SizeT array_size, const int elems=1)
static int ptcache_data_size[]
void BKE_ptcache_make_particle_key(struct ParticleKey *key, int index, void **data, float time)
size_t BLI_str_format_int_grouped(char dst[BLI_STR_FORMAT_INT32_GROUPED_SIZE], int num) ATTR_NONNULL(1)
void BLO_read_array_and_validate_size(BlendDataReader *reader, T **ptr_p, SizeT *array_size, const int elems=1)
void BKE_ptcache_validate(struct PointCache *cache, int framenr)
void BKE_ptcache_foreach_object_cache(struct Object &ob, struct Scene &scene, bool duplis, PointCacheIdFn fn)
static bool ptcache_file_points_read(PTCacheFile *pf, PTCacheMem *pm)
void BKE_ptcache_free_mem(ListBaseT< PTCacheMem > *mem_cache)
void BKE_ptcache_id_from_particles(PTCacheID *pid, struct Object *ob, struct ParticleSystem *psys)
static void ptcache_find_frames_around(PTCacheID *pid, uint frame, int *r_fra1, int *r_fra2)
constexpr int MAX_DUPLI_RECUR
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
void void void BLI_path_split_file_part(const char *filepath, char *file, size_t file_maxncpy) ATTR_NONNULL(1
void BKE_ptcache_free_list(ListBaseT< PointCache > *ptcaches)
static int ptcache_read(PTCacheID *pid, int cfra)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
static bool foreach_object_ptcache(Scene *scene, Object *object, int duplis, PointCacheIdFn callback)
float BKE_scene_ctime_get(const Scene *scene)
bool BLI_path_is_rel(const char *path) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT
static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm)
static void ptcache_file_pointers_init(PTCacheFile *pf)
void BKE_ptcache_mem_to_disk(struct PTCacheID *pid)
ID_Type GS(const char *name)
static int ptcache_softbody_totpoint(void *soft_v, int)
static void ptcache_particle_interpolate(int index, void *psys_v, void **data, float cfra, float cfra1, float cfra2, const float *old_data)
struct PointCache * BKE_ptcache_add(ListBaseT< PointCache > *ptcaches)
static void ptcache_add_extra_data(PTCacheMem *pm, ePointCache_ExtraDataType type, uint count, void *data)
struct PointCache * BKE_ptcache_copy_list(ListBaseT< PointCache > *ptcaches_new, const ListBaseT< PointCache > *ptcaches_old, int flag)
double BLI_time_now_seconds()
void BKE_ptcache_blend_write(struct BlendWriter *writer, ListBaseT< PointCache > *ptcaches)
static void ptcache_file_close(PTCacheFile *pf)
PTCacheID BKE_ptcache_id_find(struct Object *ob, struct Scene *scene, struct PointCache *cache)
static int ptcache_extra_datasize[]
void psys_reset(struct ParticleSystem *psys, int mode)
static PTCacheMem * ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra)
void psys_get_pointcache_start_end(struct Scene *scene, ParticleSystem *psys, int *sfra, int *efra)
void BKE_ptcache_update_info(PTCacheID *pid)
void BKE_ptcache_id_from_softbody(PTCacheID *pid, struct Object *ob, struct SoftBody *sb)
void BKE_ptcache_disk_cache_rename(struct PTCacheID *pid, const char *name_src, const char *name_dst)
int BKE_ptcache_data_size(int data_type)
static int ptcache_cloth_write(int index, void *cloth_v, void **data, int)
static int ptcache_particle_write(int index, void *psys_v, void **data, int cfra)
int BKE_ptcache_mem_pointers_seek(int point_index, struct PTCacheMem *pm, void *cur[BPHYS_TOT_DATA])
@ SPH_VISCOELASTIC_SPRINGS
void BKE_ptcache_toggle_disk_cache(struct PTCacheID *pid)
static void ptcache_particle_extra_read(void *psys_v, PTCacheMem *pm, float)
void unfilter_transpose_delta(const uint8_t *src, uint8_t *dst, size_t items_num, size_t item_size)
@ BPHYS_DATA_DYNAMICPAINT
void psys_interpolate_particle(short type, struct ParticleKey keys[4], float dt, struct ParticleKey *result, bool velocity)
@ PTCACHE_COMPRESS_ZSTD_FAST_DEPRECATED
@ PTCACHE_COMPRESS_ZSTD_SLOW_DEPRECATED
@ PTCACHE_COMPRESS_ZSTD_FILTERED
void BKE_ptcache_invalidate(struct PointCache *cache)
struct ParticleSystem * psys_eval_get(struct Depsgraph *depsgraph, struct Object *object, struct ParticleSystem *psys)
static void ptcache_softbody_read(int index, void *soft_v, void **data, float, const float *old_data)
bool BLI_file_ensure_parent_dir_exists(const char *filepath) ATTR_NONNULL(1)
static int ptcache_file_header_begin_write(PTCacheFile *pf)
MINLINE bool is_zero_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
@ MOD_DPAINT_SURFACE_T_PAINT
@ MOD_DPAINT_SURFACE_T_WAVE
@ MOD_DPAINT_SURFACE_T_WEIGHT
@ MOD_DPAINT_SURFACE_T_DISPLACE
static int ptcache_old_elemsize(PTCacheID *pid)
void BKE_ptcache_mem_pointers_init(struct PTCacheMem *pm, void *cur[BPHYS_TOT_DATA])
ePointCache_ExtraDataType
@ BPHYS_EXTRA_CLOTH_ACCELERATION
@ BPHYS_EXTRA_FLUID_SPRINGS
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
static void ptcache_cloth_interpolate(int index, void *cloth_v, void **data, float cfra, float cfra1, float cfra2, const float *old_data)
static void ptcache_dt_to_str(char *str, size_t str_maxncpy, double dtime)
static void direct_link_pointcache_mem(BlendDataReader *reader, PTCacheMem *pm)
FunctionRef< bool(PTCacheID &pid, ModifierData *md)> PointCacheIdFn
#define PTCACHE_DATA_FROM(data, type, from)
#define PTCACHE_DATA_TO(data, type, index, to)
#define DPAINT_CACHE_VERSION
void RB_body_get_orientation(rbRigidBody *object, float v_out[4])
void RB_body_get_position(rbRigidBody *object, float v_out[3])
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
void write_struct_array_cast(const int64_t array_size, const void *data, BlendStructWriterTypedFn< T > fn=nullptr)
void write_float_array(int64_t num, const float *data)
void write_uint32_array(int64_t num, const uint32_t *data)
void write_struct(const T *data, BlendStructWriterTypedFn< T > fn=nullptr)
struct Cloth * clothObject
struct ClothHairData * hairdata
struct PointCache * point_cache
struct ListBaseT< PointCache > ptcaches
ListBaseT< DynamicPaintSurface > surfaces
struct DynamicPaintCanvasSettings * canvas
ListBaseT< PointCache > ptcaches
eDynamicPaint_SurfaceFormat format
struct PaintSurfaceData * data
eDynamicPaint_SurfaceType type
struct PointCache * pointcache
struct DynamicPaintSurface * next
struct ListBaseT< PointCache > ptcaches[2]
struct PointCache * point_cache[2]
eFluidDomain_CacheType cache_type
struct FluidDomainSettings * domain
bke::library::LibraryRuntime * runtime
ListBaseT< ModifierData > modifiers
ListBaseT< struct ParticleSystem > particlesystem
struct RigidBodyOb * rigidbody_object
struct RigidBodyCon * rigidbody_constraint
struct Depsgraph * depsgraph
void(*) update_progress(void *data, float progress, int *cancel)
struct ViewLayer * view_layer
int(*) totwrite(void *calldata, int cfra)
void(*) read_extra_data(void *calldata, struct PTCacheMem *pm, float cfra)
int(*) read_stream(PTCacheFile *pf, void *calldata)
void(*) write_extra_data(void *calldata, struct PTCacheMem *pm, int cfra)
struct PointCache * cache
void(*) interpolate_point(int index, void *calldata, void **data, float cfra, float cfra1, float cfra2, const float *old_data)
void(*) interpolate_extra_data(void *calldata, struct PTCacheMem *pm, float cfra, float cfra1, float cfra2)
unsigned int default_step
struct PointCache ** cache_ptr
int(*) write_header(PTCacheFile *pf)
void(*) error(const struct ID *owner_id, void *calldata, const char *message)
int(*) read_header(PTCacheFile *pf)
int(*) totpoint(void *calldata, int cfra)
void(*) read_point(int index, void *calldata, void **data, float cfra, const float *old_data)
int(*) write_point(int index, void *calldata, void **data, int cfra)
ListBaseT< PointCache > * ptcaches
int(*) write_stream(PTCacheFile *pf, void *calldata)
ListBaseT< PTCacheExtra > extradata
struct SPHFluidSettings * fluid
eParticleRotationMode rotmode
eParticlePhysicsType phystype
eParticleAngularVelocityMode avemode
unsigned int particle_index[2]
struct ClothModifierData * clmd
ListBaseT< PointCache > ptcaches
struct PointCache * pointcache
ParticleSpring * fluid_springs
ListBaseT< PTCacheMem > mem_cache
void(*) free_edit(struct PTCacheEdit *edit)
struct PTCacheEdit * edit
struct RigidBodyOb_Shared * shared
struct PointCache * pointcache
ListBaseT< PointCache > ptcaches
struct RigidBodyWorld_Shared * shared
struct PhysicsSettings physics_settings
struct RigidBodyWorld * rigidbody_world
ListBaseT< PointCache > ptcaches
struct PointCache * pointcache
struct SoftBody_Shared * shared
struct BodyPoint * bpoint