1 /* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License 4 * as published by the Free Software Foundation; either version 2 5 * of the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software Foundation, 14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 */ 16 17 /** \file 18 * \ingroup DNA 19 */ 20 21 #pragma once 22 23 #include "DNA_listBase.h" 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 /** 30 * Point cache file data types: 31 * - Used as `(1 << flag)` so poke jahka if you reach the limit of 15. 32 * - To add new data types update: 33 * - #BKE_ptcache_data_size() 34 * - #ptcache_file_pointers_init() 35 */ 36 #define BPHYS_DATA_INDEX 0 37 #define BPHYS_DATA_LOCATION 1 38 #define BPHYS_DATA_SMOKE_LOW 1 39 #define BPHYS_DATA_VELOCITY 2 40 #define BPHYS_DATA_SMOKE_HIGH 2 41 #define BPHYS_DATA_ROTATION 3 42 #define BPHYS_DATA_DYNAMICPAINT 3 43 #define BPHYS_DATA_AVELOCITY 4 /* used for particles */ 44 #define BPHYS_DATA_XCONST 4 /* used for cloth */ 45 #define BPHYS_DATA_SIZE 5 46 #define BPHYS_DATA_TIMES 6 47 #define BPHYS_DATA_BOIDS 7 48 49 #define BPHYS_TOT_DATA 8 50 51 #define BPHYS_EXTRA_FLUID_SPRINGS 1 52 #define BPHYS_EXTRA_CLOTH_ACCELERATION 2 53 54 typedef struct PTCacheExtra { 55 struct PTCacheExtra *next, *prev; 56 unsigned int type, totdata; 57 void *data; 58 } PTCacheExtra; 59 60 typedef struct PTCacheMem { 61 struct PTCacheMem *next, *prev; 62 unsigned int frame, totpoint; 63 unsigned int data_types, flag; 64 65 /** BPHYS_TOT_DATA. */ 66 void *data[8]; 67 68 struct ListBase extradata; 69 } PTCacheMem; 70 71 typedef struct PointCache { 72 struct PointCache *next, *prev; 73 /** Generic flag. */ 74 int flag; 75 76 /** 77 * The number of frames between cached frames. 78 * This should probably be an upper bound for a per point adaptive step in the future, 79 * but for now it's the same for all points. Without adaptivity this can effect the perceived 80 * simulation quite a bit though. If for example particles are colliding with a horizontal 81 * plane (with high damping) they quickly come to a stop on the plane, however there are still 82 * forces acting on the particle (gravity and collisions), so the particle velocity isn't 83 * necessarily zero for the whole duration of the frame even if the particle seems stationary. 84 * If all simulation frames aren't cached (step > 1) these velocities are interpolated into 85 * movement for the non-cached frames. 86 * The result will look like the point is oscillating around the collision location. 87 * So for now cache step should be set to 1 for accurate reproduction of collisions. 88 */ 89 int step; 90 91 /** Current frame of simulation (only if SIMULATION_VALID). */ 92 int simframe; 93 /** Simulation start frame. */ 94 int startframe; 95 /** Simulation end frame. */ 96 int endframe; 97 /** Frame being edited (runtime only). */ 98 int editframe; 99 /** Last exact frame that's cached. */ 100 int last_exact; 101 /** Used for editing cache - what is the last baked frame. */ 102 int last_valid; 103 char _pad[4]; 104 105 /* for external cache files */ 106 /** Number of cached points. */ 107 int totpoint; 108 /** Modifier stack index. */ 109 int index; 110 short compression, rt; 111 112 char name[64]; 113 char prev_name[64]; 114 char info[128]; 115 /** File path, 1024 = FILE_MAX. */ 116 char path[1024]; 117 118 /** 119 * Array of length `endframe - startframe + 1` with flags to indicate cached frames. 120 * Can be later used for other per frame flags too if needed. 121 */ 122 char *cached_frames; 123 int cached_frames_len; 124 char _pad1[4]; 125 126 struct ListBase mem_cache; 127 128 struct PTCacheEdit *edit; 129 /** Free callback. */ 130 void (*free_edit)(struct PTCacheEdit *edit); 131 } PointCache; 132 133 /* pointcache->flag */ 134 #define PTCACHE_BAKED (1 << 0) 135 #define PTCACHE_OUTDATED (1 << 1) 136 #define PTCACHE_SIMULATION_VALID (1 << 2) 137 #define PTCACHE_BAKING (1 << 3) 138 //#define PTCACHE_BAKE_EDIT (1 << 4) 139 //#define PTCACHE_BAKE_EDIT_ACTIVE (1 << 5) 140 #define PTCACHE_DISK_CACHE (1 << 6) 141 ///* removed since 2.64 - T30974, could be added back in a more useful way */ 142 //#define PTCACHE_QUICK_CACHE (1 << 7) 143 #define PTCACHE_FRAMES_SKIPPED (1 << 8) 144 #define PTCACHE_EXTERNAL (1 << 9) 145 #define PTCACHE_READ_INFO (1 << 10) 146 /** don't use the filename of the blendfile the data is linked from (write a local cache) */ 147 #define PTCACHE_IGNORE_LIBPATH (1 << 11) 148 /** 149 * High resolution cache is saved for smoke for backwards compatibility, 150 * so set this flag to know it's a "fake" cache. 151 */ 152 #define PTCACHE_FAKE_SMOKE (1 << 12) 153 #define PTCACHE_IGNORE_CLEAR (1 << 13) 154 155 #define PTCACHE_FLAG_INFO_DIRTY (1 << 14) 156 157 /* PTCACHE_OUTDATED + PTCACHE_FRAMES_SKIPPED */ 158 #define PTCACHE_REDO_NEEDED 258 159 160 #define PTCACHE_COMPRESS_NO 0 161 #define PTCACHE_COMPRESS_LZO 1 162 #define PTCACHE_COMPRESS_LZMA 2 163 164 #ifdef __cplusplus 165 } 166 #endif 167