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
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2006-11-26 15:23:21 +0300
committerTon Roosendaal <ton@blender.org>2006-11-26 15:23:21 +0300
commitced3b0fd6f4740a5fa9eba3f78b490a4a5467168 (patch)
treebabb99ffbc344b3b1665a389224bf70db0f13724 /source/blender/makesdna
parent6ede6352edf5c83e963e827d0de6ce92f48d9442 (diff)
SculptMode fix:
DNA definition of Sculpt structs in Scene were not properly aligned, causing memory errors on quit ("Memoryblock reconstruct: end corrupt"). More testing reveiled padding errors in two other DNA_ includes, for sound and gamelogic. Both potentially crashers... and caused by commenting out struct members with a C++ comment, that seems to not work... I've revived the DNA padding test method, which saves out a simple C file you can compile to see where padding issues are. This now works as follows: - change line 991 in makesdna.c to become (1) (true). - recompile makesdna.c - you now have a padding.c in the same dir as makesdna.c - compile it, command line: "gcc -o padding padding.c" - now run it (./padding), and it will print out errors, if there are. For me, the DNA files are now 100% padding free. Might be interesting to check it in 64 bits though!
Diffstat (limited to 'source/blender/makesdna')
-rw-r--r--source/blender/makesdna/DNA_actuator_types.h2
-rw-r--r--source/blender/makesdna/DNA_scene_types.h12
-rw-r--r--source/blender/makesdna/DNA_sound_types.h2
-rw-r--r--source/blender/makesdna/intern/makesdna.c15
4 files changed, 15 insertions, 16 deletions
diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h
index 410ca665731..0531e70bb97 100644
--- a/source/blender/makesdna/DNA_actuator_types.h
+++ b/source/blender/makesdna/DNA_actuator_types.h
@@ -104,8 +104,6 @@ typedef struct bObjectActuator {
float loc[3], rot[3];
float dloc[3], drot[3];
float linearvelocity[3], angularvelocity[3];
-// float addedlinearvelocity[3];
-// char anotherpad[4];
} bObjectActuator;
typedef struct bIpoActuator {
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index ee7625379d9..18a22fbf35e 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -367,12 +367,14 @@ typedef struct BrushData
short size;
char strength, dir; /* Not used for smooth brush */
char airbrush;
- char pad[7];
+ char pad[3];
} BrushData;
struct PropsetData;
struct RenderInfo;
struct SculptUndo;
+
+/* DNA WARNING: use of doubles forces SculptData internal alignment to 8 (only in gcc?) */
typedef struct SculptData
{
/* Cache of the OpenGL matrices */
@@ -396,10 +398,10 @@ typedef struct SculptData
struct PropsetData *propset;
- struct SculptUndo *undo;
+ struct SculptUndo *undo, *padp; /* pointer pad! */
/* For rotating around a pivot point */
- vec3f pivot;
+ vec3f pivot, padv; /* vec3f is 12 bytes */
/* Settings for each brush */
BrushData drawbrush, smoothbrush, pinchbrush, inflatebrush, grabbrush, layerbrush;
@@ -417,11 +419,11 @@ typedef struct SculptData
short texscale;
short texact, texnr;
short spacing;
- char pad[2];
+ char pad;
char texrept;
char texfade;
- char averaging, pad2[3];
+ char averaging;
} SculptData;
#define SCULPTREPT_DRAG 1
diff --git a/source/blender/makesdna/DNA_sound_types.h b/source/blender/makesdna/DNA_sound_types.h
index 1ec788976df..27b9c373484 100644
--- a/source/blender/makesdna/DNA_sound_types.h
+++ b/source/blender/makesdna/DNA_sound_types.h
@@ -103,8 +103,6 @@ typedef struct bSound {
float distance;
int flags;
int streamlen;
-// unsigned int loopstart;
-// unsigned int loopend;
char channels;
char highprio;
char pad[10];
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index 79e839a172f..1061581d7c5 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -141,7 +141,7 @@ int nr_structs=0;
char **names, *namedata; /* at adress names[a] is string a */
char **types, *typedata; /* at adress types[a] is string a */
short *typelens; /* at typelens[a] is de length of type a */
-short *alphalens; /* contains sizes as they are calculated on the alpha */
+short *alphalens; /* contains sizes as they are calculated on the DEC Alpha (64 bits) */
short **structs, *structdata; /* at sp= structs[a] is the first adress of a struct definition
sp[0] is type number
sp[1] is amount of elements
@@ -870,7 +870,7 @@ int make_structDNA(char *baseDirectory, FILE *file)
add_type("short", 2); /* 2 */
add_type("ushort", 2); /* 3 */
add_type("int", 4); /* 4 */
- add_type("long", 4); /* 5 */
+ add_type("long", 4); /* 5 */ /* should it be 8 on 64 bits? */
add_type("ulong", 4); /* 6 */
add_type("float", 4); /* 7 */
add_type("double", 8); /* 8 */
@@ -988,7 +988,6 @@ int make_structDNA(char *baseDirectory, FILE *file)
dna_write(file, structs[0], len);
/* a simple dna padding test */
-
if (0) {
FILE *fp;
int a;
@@ -999,16 +998,18 @@ int make_structDNA(char *baseDirectory, FILE *file)
// add all include files defined in the global array
for (i = 0; strlen(includefiles[i]); i++) {
- fprintf(fp, "#include \"%s\"\n", includefiles[i]);
+ fprintf(fp, "#include \"%s%s\"\n", baseDirectory, includefiles[i]);
}
fprintf(fp, "main(){\n");
sp = typelens;
sp += firststruct;
for(a=firststruct; a<nr_types; a++, sp++) {
- fprintf(fp, "\tprintf(\" ");
- fprintf(fp, "%%d %s %d ", types[a], *sp);
- fprintf(fp, "\\n\", sizeof(struct %s) - %d);\n", types[a], *sp);
+ if(*sp) {
+ fprintf(fp, "\tif(sizeof(struct %s) - %d) printf(\"ALIGN ERROR:", types[a], *sp);
+ fprintf(fp, "%%d %s %d ", types[a], *sp);
+ fprintf(fp, "\\n\", sizeof(struct %s) - %d);\n", types[a], *sp);
+ }
}
fprintf(fp, "}\n");
fclose(fp);