Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2010-12-01 18:58:45 +0300
committerTon Roosendaal <ton@blender.org>2010-12-01 18:58:45 +0300
commitf4205498a9854a5487a6b3531798690470f4bdcd (patch)
tree82c6b7c45619a46b80ece1ea07458833e65c5b57 /source
parent6090b1c5a729df9e091d8e368c9d6a3687a27836 (diff)
Bugfix #24890
Particle cache reading: crash when loading .blend on a different endian system, code was dumping arrays in .blend without DNA. General warning for devs: avoid generic write_data and dynamic arrays in DNA.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenloader/intern/readfile.c19
-rw-r--r--source/blender/makesdna/DNA_boid_types.h4
2 files changed, 21 insertions, 2 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index bcb09ca52c8..7861e771f8b 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -2931,9 +2931,24 @@ static void direct_link_pointcache(FileData *fd, PointCache *cache)
if(pm->index_array)
pm->index_array = newdataadr(fd, pm->index_array);
+ /* writedata saved array of ints */
+ if(pm->index_array && (fd->flags & FD_FLAGS_SWITCH_ENDIAN)) {
+ for(i=0; i<pm->totpoint; i++)
+ SWITCH_INT(pm->index_array[i]);
+ }
+
for(i=0; i<BPHYS_TOT_DATA; i++) {
- if(pm->data[i] && pm->data_types & (1<<i))
- pm->data[i] = newdataadr(fd, pm->data[i]);
+ pm->data[i] = newdataadr(fd, pm->data[i]);
+
+ /* XXX the cache saves structs and data without DNA */
+ if(pm->data[i] && (fd->flags & FD_FLAGS_SWITCH_ENDIAN)) {
+ int j, tot= (BKE_ptcache_data_size (i) * pm->totpoint)/4; /* data_size returns bytes */
+ int *poin= pm->data[i];
+
+ /* XXX fails for boid struct, it has 2 shorts */
+ for(j= 0; j<tot; j++)
+ SWITCH_INT(poin[j]);
+ }
}
}
}
diff --git a/source/blender/makesdna/DNA_boid_types.h b/source/blender/makesdna/DNA_boid_types.h
index c4324612aff..cabdb748a60 100644
--- a/source/blender/makesdna/DNA_boid_types.h
+++ b/source/blender/makesdna/DNA_boid_types.h
@@ -104,6 +104,10 @@ typedef enum BoidMode {
eBoidMode_Liftoff,
NUM_BOID_MODES
} BoidMode;
+
+
+/* XXX WARNING!!! */
+/* BoidData is NOT in DNA, it gets saved via write_data. Do not change struct */
typedef struct BoidData {
float health, acc[3];
short state_id, mode;