Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/pointcache.c
| Show All 28 Lines | |||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include <string.h> | #include <string.h> | ||||
| #include <sys/stat.h> | #include <sys/stat.h> | ||||
| #include <sys/types.h> | #include <sys/types.h> | ||||
| #include "CLG_log.h" | |||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "DNA_ID.h" | #include "DNA_ID.h" | ||||
| #include "DNA_collection_types.h" | #include "DNA_collection_types.h" | ||||
| #include "DNA_dynamicpaint_types.h" | #include "DNA_dynamicpaint_types.h" | ||||
| #include "DNA_modifier_types.h" | #include "DNA_modifier_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_object_force_types.h" | #include "DNA_object_force_types.h" | ||||
| ▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | |||||
| #define PTCACHE_DATA_TO(data, type, index, to) \ | #define PTCACHE_DATA_TO(data, type, index, to) \ | ||||
| if (data[type]) { \ | if (data[type]) { \ | ||||
| memcpy(to, (char *)(data)[type] + ((index) ? (index) * ptcache_data_size[type] : 0), ptcache_data_size[type]); \ | memcpy(to, (char *)(data)[type] + ((index) ? (index) * ptcache_data_size[type] : 0), ptcache_data_size[type]); \ | ||||
| } (void)0 | } (void)0 | ||||
| /* could be made into a pointcache option */ | /* could be made into a pointcache option */ | ||||
| #define DURIAN_POINTCACHE_LIB_OK 1 | #define DURIAN_POINTCACHE_LIB_OK 1 | ||||
| static CLG_LogRef LOG = {"bke.pointcache"}; | |||||
| static int ptcache_data_size[] = { | static int ptcache_data_size[] = { | ||||
| sizeof(unsigned int), // BPHYS_DATA_INDEX | sizeof(unsigned int), // BPHYS_DATA_INDEX | ||||
| 3 * sizeof(float), // BPHYS_DATA_LOCATION | 3 * sizeof(float), // BPHYS_DATA_LOCATION | ||||
| 3 * sizeof(float), // BPHYS_DATA_VELOCITY | 3 * sizeof(float), // BPHYS_DATA_VELOCITY | ||||
| 4 * sizeof(float), // BPHYS_DATA_ROTATION | 4 * sizeof(float), // BPHYS_DATA_ROTATION | ||||
| 3 * sizeof(float), // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST | 3 * sizeof(float), // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST | ||||
| sizeof(float), // BPHYS_DATA_SIZE | sizeof(float), // BPHYS_DATA_SIZE | ||||
| 3 * sizeof(float), // BPHYS_DATA_TIMES | 3 * sizeof(float), // BPHYS_DATA_TIMES | ||||
| ▲ Show 20 Lines • Show All 1,104 Lines • ▼ Show 20 Lines | |||||
| static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v) | static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v) | ||||
| { | { | ||||
| DynamicPaintSurface *surface = (DynamicPaintSurface*)dp_v; | DynamicPaintSurface *surface = (DynamicPaintSurface*)dp_v; | ||||
| char version[4]; | char version[4]; | ||||
| /* version header */ | /* version header */ | ||||
| ptcache_file_read(pf, version, 1, sizeof(char) * 4); | ptcache_file_read(pf, version, 1, sizeof(char) * 4); | ||||
| if (!STREQLEN(version, DPAINT_CACHE_VERSION, 4)) { | if (!STREQLEN(version, DPAINT_CACHE_VERSION, 4)) { | ||||
| printf("Dynamic Paint: Invalid cache version: '%c%c%c%c'!\n", UNPACK4(version)); | CLOG_ERROR(&LOG, "Dynamic Paint: Invalid cache version: '%c%c%c%c'!", UNPACK4(version)); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && surface->data) { | if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && surface->data) { | ||||
| unsigned int data_len; | unsigned int data_len; | ||||
| int surface_type; | int surface_type; | ||||
| /* cache type */ | /* cache type */ | ||||
| ▲ Show 20 Lines • Show All 1,219 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| PTCacheFile *pf = NULL; | PTCacheFile *pf = NULL; | ||||
| unsigned int i, error = 0; | unsigned int i, error = 0; | ||||
| BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, pm->frame); | BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, pm->frame); | ||||
| pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, pm->frame); | pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, pm->frame); | ||||
| if (pf==NULL) { | if (pf == NULL) { | ||||
| if (G.debug & G_DEBUG) | if (G.debug & G_DEBUG) | ||||
| printf("Error opening disk cache file for writing\n"); | printf("Error opening disk cache file for writing\n"); | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| pf->data_types = pm->data_types; | pf->data_types = pm->data_types; | ||||
| pf->totpoint = pm->totpoint; | pf->totpoint = pm->totpoint; | ||||
| pf->type = pid->type; | pf->type = pid->type; | ||||
| ▲ Show 20 Lines • Show All 1,700 Lines • Show Last 20 Lines | |||||