diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-12-27 14:11:07 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-12-27 14:11:07 +0400 |
commit | fd134927dd23047237c6e490c09454487ba19a4a (patch) | |
tree | bd0d63f66af304da5d8b62aca4c5f6a0c0cfe2d4 /source/blender/makesdna | |
parent | 0c8cde2bb6bf5f38b4f567342ca371ec164f211c (diff) | |
parent | a0e62e77d75f0732ef877401f4ed9b1861ff9126 (diff) |
Merging r42800 through r42895 from trunk into soc-2011-tomato
Diffstat (limited to 'source/blender/makesdna')
-rw-r--r-- | source/blender/makesdna/DNA_defs.h | 3 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_genfile.h | 21 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_mesh_types.h | 3 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_object_types.h | 4 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_scene_types.h | 5 | ||||
-rw-r--r-- | source/blender/makesdna/intern/dna_genfile.c | 168 | ||||
-rw-r--r-- | source/blender/makesdna/intern/makesdna.c | 23 |
7 files changed, 151 insertions, 76 deletions
diff --git a/source/blender/makesdna/DNA_defs.h b/source/blender/makesdna/DNA_defs.h index 88401d3d2d4..25d95419605 100644 --- a/source/blender/makesdna/DNA_defs.h +++ b/source/blender/makesdna/DNA_defs.h @@ -42,4 +42,7 @@ # endif #endif +/* hrmf, we need a better include then this */ +#include "../blenloader/BLO_sys_types.h" /* needed for int64_t only! */ + #endif /* DNA_DEFS_H */ diff --git a/source/blender/makesdna/DNA_genfile.h b/source/blender/makesdna/DNA_genfile.h index 4f8b2343a9f..be13c8bba4f 100644 --- a/source/blender/makesdna/DNA_genfile.h +++ b/source/blender/makesdna/DNA_genfile.h @@ -38,6 +38,24 @@ struct SDNA; extern unsigned char DNAstr[]; /* DNA.c */ extern int DNAlen; +typedef enum eSDNA_Type { + SDNA_TYPE_CHAR = 0, + SDNA_TYPE_UCHAR = 1, + SDNA_TYPE_SHORT = 2, + SDNA_TYPE_USHORT = 3, + SDNA_TYPE_INT = 4, + SDNA_TYPE_LONG = 5, + SDNA_TYPE_ULONG = 6, + SDNA_TYPE_FLOAT = 7, + SDNA_TYPE_DOUBLE = 8, + SDNA_TYPE_INT64 = 9, + SDNA_TYPE_UINT64 = 10 + /* ,SDNA_TYPE_VOID = 11 */ /* nothing uses yet */ +} eSDNA_Type; + +/* define so switch statements don't complain */ +#define SDNA_TYPE_VOID 11 + struct SDNA *DNA_sdna_from_data(void *data, int datalen, int do_endian_swap); void DNA_sdna_free(struct SDNA *sdna); @@ -49,6 +67,7 @@ void *DNA_struct_reconstruct(struct SDNA *newsdna, struct SDNA *oldsdna, char *c int DNA_elem_array_size(const char *astr, int len); int DNA_elem_offset(struct SDNA *sdna, const char *stype, const char *vartype, const char *name); -#endif +int DNA_elem_type_size(const eSDNA_Type elem_nr); +#endif diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index 7d57e2c295c..f8062aeccc7 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -162,6 +162,9 @@ typedef struct TFace { #define ME_DRAWEXTRA_FACEAREA (1 << 11) #define ME_DRAWEXTRA_FACEANG (1 << 12) +/* debug only option */ +#define ME_DRAWEXTRA_INDICES (1 << 13) + /* old global flags: #define G_DRAWEDGES (1 << 18) #define G_DRAWFACES (1 << 7) diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 8707ae038c3..46b971e8e0d 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -250,8 +250,8 @@ typedef struct Object { struct FluidsimSettings *fluidsimSettings; /* if fluidsim enabled, store additional settings */ struct DerivedMesh *derivedDeform, *derivedFinal; - unsigned int lastDataMask; /* the custom data layer mask that was last used to calculate derivedDeform and derivedFinal */ - unsigned int customdata_mask; /* (extra) custom data layer mask to use for creating derivedmesh, set by depsgraph */ + uint64_t lastDataMask; /* the custom data layer mask that was last used to calculate derivedDeform and derivedFinal */ + uint64_t customdata_mask; /* (extra) custom data layer mask to use for creating derivedmesh, set by depsgraph */ unsigned int state; /* bit masks of game controllers that are active */ unsigned int init_state; /* bit masks of initial state as recorded by the users */ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 345e78d70c9..64b5bda3fc8 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -915,8 +915,6 @@ typedef struct Scene { unsigned int lay; /* bitflags for layer visibility */ int layact; /* active layer */ unsigned int lay_updated; /* runtime flag, has layer ever been updated since load? */ - unsigned int customdata_mask; /* XXX. runtime flag for drawing, actually belongs in the window, only used by object_handle_update() */ - unsigned int customdata_mask_modal; /* XXX. same as above but for temp operator use (gl renders) */ short flag; /* various settings */ @@ -971,6 +969,9 @@ typedef struct Scene { /* Movie Tracking */ struct MovieClip *clip; /* active movie clip */ + + uint64_t customdata_mask; /* XXX. runtime flag for drawing, actually belongs in the window, only used by object_handle_update() */ + uint64_t customdata_mask_modal; /* XXX. same as above but for temp operator use (gl renders) */ } Scene; diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index 0dba78ff97e..5b115a404ce 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -491,7 +491,7 @@ static void init_structDNA(SDNA *sdna, int do_endian_swap) for(nr=0; nr<sdna->nr_structs; nr++) { sp= sdna->structs[nr]; if(strcmp(sdna->types[sp[0]], "ClothSimSettings") == 0) - sp[10]= 9; + sp[10]= SDNA_TYPE_VOID; } } @@ -655,92 +655,92 @@ char *DNA_struct_get_compareflags(SDNA *sdna, SDNA *newsdna) return compflags; } -static void cast_elem(char *ctype, char *otype, const char *name, char *curdata, char *olddata) +static eSDNA_Type sdna_type_nr(const char *dna_type) +{ + if ((strcmp(dna_type, "char")==0) || (strcmp(dna_type, "const char")==0)) return SDNA_TYPE_CHAR; + else if((strcmp(dna_type, "uchar")==0) || (strcmp(dna_type, "unsigned char")==0)) return SDNA_TYPE_UCHAR; + else if( strcmp(dna_type, "short")==0) return SDNA_TYPE_SHORT; + else if((strcmp(dna_type, "ushort")==0)||(strcmp(dna_type, "unsigned short")==0)) return SDNA_TYPE_USHORT; + else if( strcmp(dna_type, "int")==0) return SDNA_TYPE_INT; + else if( strcmp(dna_type, "long")==0) return SDNA_TYPE_LONG; + else if((strcmp(dna_type, "ulong")==0)||(strcmp(dna_type, "unsigned long")==0)) return SDNA_TYPE_ULONG; + else if( strcmp(dna_type, "float")==0) return SDNA_TYPE_FLOAT; + else if( strcmp(dna_type, "double")==0) return SDNA_TYPE_DOUBLE; + else if( strcmp(dna_type, "int64_t")==0) return SDNA_TYPE_INT64; + else if( strcmp(dna_type, "uint64_t")==0) return SDNA_TYPE_UINT64; + else return -1; /* invalid! */ +} + +static void cast_elem(const char *ctype, const char *otype, const char *name, char *curdata, char *olddata) { double val = 0.0; - int arrlen, curlen=1, oldlen=1, ctypenr, otypenr; - + int arrlen, curlen=1, oldlen=1; + + eSDNA_Type ctypenr, otypenr; + arrlen= DNA_elem_array_size(name, strlen(name)); - - /* define otypenr */ - if(strcmp(otype, "char")==0 || (strcmp(otype, "const char")==0)) otypenr= 0; - else if((strcmp(otype, "uchar")==0) || (strcmp(otype, "unsigned char")==0)) otypenr= 1; - else if(strcmp(otype, "short")==0) otypenr= 2; - else if((strcmp(otype, "ushort")==0)||(strcmp(otype, "unsigned short")==0)) otypenr= 3; - else if(strcmp(otype, "int")==0) otypenr= 4; - else if(strcmp(otype, "long")==0) otypenr= 5; - else if((strcmp(otype, "ulong")==0)||(strcmp(otype, "unsigned long")==0)) otypenr= 6; - else if(strcmp(otype, "float")==0) otypenr= 7; - else if(strcmp(otype, "double")==0) otypenr= 8; - else return; - - /* define ctypenr */ - if(strcmp(ctype, "char")==0) ctypenr= 0; - else if(strcmp(ctype, "const char")==0) ctypenr= 0; - else if((strcmp(ctype, "uchar")==0)||(strcmp(ctype, "unsigned char")==0)) ctypenr= 1; - else if(strcmp(ctype, "short")==0) ctypenr= 2; - else if((strcmp(ctype, "ushort")==0)||(strcmp(ctype, "unsigned short")==0)) ctypenr= 3; - else if(strcmp(ctype, "int")==0) ctypenr= 4; - else if(strcmp(ctype, "long")==0) ctypenr= 5; - else if((strcmp(ctype, "ulong")==0)||(strcmp(ctype, "unsigned long")==0)) ctypenr= 6; - else if(strcmp(ctype, "float")==0) ctypenr= 7; - else if(strcmp(ctype, "double")==0) ctypenr= 8; - else return; + + if ( (otypenr= sdna_type_nr(otype)) == -1 || + (ctypenr= sdna_type_nr(ctype)) == -1 ) + { + return; + } /* define lengths */ - if(otypenr < 2) oldlen= 1; - else if(otypenr < 4) oldlen= 2; - else if(otypenr < 8) oldlen= 4; - else oldlen= 8; - - if(ctypenr < 2) curlen= 1; - else if(ctypenr < 4) curlen= 2; - else if(ctypenr < 8) curlen= 4; - else curlen= 8; - + oldlen= DNA_elem_type_size(otypenr); + curlen= DNA_elem_type_size(ctypenr); + while(arrlen>0) { switch(otypenr) { - case 0: + case SDNA_TYPE_CHAR: val= *olddata; break; - case 1: + case SDNA_TYPE_UCHAR: val= *( (unsigned char *)olddata); break; - case 2: + case SDNA_TYPE_SHORT: val= *( (short *)olddata); break; - case 3: + case SDNA_TYPE_USHORT: val= *( (unsigned short *)olddata); break; - case 4: + case SDNA_TYPE_INT: val= *( (int *)olddata); break; - case 5: + case SDNA_TYPE_LONG: val= *( (int *)olddata); break; - case 6: + case SDNA_TYPE_ULONG: val= *( (unsigned int *)olddata); break; - case 7: + case SDNA_TYPE_FLOAT: val= *( (float *)olddata); break; - case 8: + case SDNA_TYPE_DOUBLE: val= *( (double *)olddata); break; + case SDNA_TYPE_INT64: + val= *( (int64_t *)olddata); break; + case SDNA_TYPE_UINT64: + val= *( (uint64_t *)olddata); break; } switch(ctypenr) { - case 0: + case SDNA_TYPE_CHAR: *curdata= val; break; - case 1: + case SDNA_TYPE_UCHAR: *( (unsigned char *)curdata)= val; break; - case 2: + case SDNA_TYPE_SHORT: *( (short *)curdata)= val; break; - case 3: + case SDNA_TYPE_USHORT: *( (unsigned short *)curdata)= val; break; - case 4: + case SDNA_TYPE_INT: *( (int *)curdata)= val; break; - case 5: + case SDNA_TYPE_LONG: *( (int *)curdata)= val; break; - case 6: + case SDNA_TYPE_ULONG: *( (unsigned int *)curdata)= val; break; - case 7: + case SDNA_TYPE_FLOAT: if(otypenr<2) val/= 255; *( (float *)curdata)= val; break; - case 8: + case SDNA_TYPE_DOUBLE: if(otypenr<2) val/= 255; *( (double *)curdata)= val; break; + case SDNA_TYPE_INT64: + *( (int64_t *)curdata)= val; break; + case SDNA_TYPE_UINT64: + *( (uint64_t *)curdata)= val; break; } olddata+= oldlen; @@ -838,7 +838,8 @@ static char *find_elem(SDNA *sdna, const char *type, const char *name, short *ol return NULL; } -static void reconstruct_elem(SDNA *newsdna, SDNA *oldsdna, char *type, const char *name, char *curdata, short *old, char *olddata) +static void reconstruct_elem(SDNA *newsdna, SDNA *oldsdna, + char *type, const char *name, char *curdata, short *old, char *olddata) { /* rules: test for NAME: - name equal: @@ -912,7 +913,8 @@ static void reconstruct_elem(SDNA *newsdna, SDNA *oldsdna, char *type, const cha } } -static void reconstruct_struct(SDNA *newsdna, SDNA *oldsdna, char *compflags, int oldSDNAnr, char *data, int curSDNAnr, char *cur) +static void reconstruct_struct(SDNA *newsdna, SDNA *oldsdna, + char *compflags, int oldSDNAnr, char *data, int curSDNAnr, char *cur) { /* Recursive! * Per element from cur_struct, read data from old_struct. @@ -1054,7 +1056,9 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data) } else { - if( spc[0]==2 || spc[0]==3 ) { /* short-ushort */ + if ( spc[0]==SDNA_TYPE_SHORT || + spc[0]==SDNA_TYPE_USHORT ) + { /* exception: variable called blocktype/ipowin: derived from ID_ */ skip= 0; @@ -1076,7 +1080,11 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data) } } } - else if(spc[0]>3 && spc[0]<8) { /* int-long-ulong-float */ + else if ( (spc[0]==SDNA_TYPE_INT || + spc[0]==SDNA_TYPE_LONG || + spc[0]==SDNA_TYPE_ULONG || + spc[0]==SDNA_TYPE_FLOAT)) + { mul= DNA_elem_array_size(name, strlen(name)); cpo= cur; @@ -1090,6 +1098,20 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data) cpo+= 4; } } + else if ( (spc[0]==SDNA_TYPE_INT64) || + (spc[0]==SDNA_TYPE_UINT64)) + { + mul= DNA_elem_array_size(name, strlen(name)); + cpo= cur; + while(mul--) { + cval= cpo[0]; cpo[0]= cpo[7]; cpo[7]= cval; + cval= cpo[1]; cpo[1]= cpo[6]; cpo[6]= cval; + cval= cpo[2]; cpo[2]= cpo[5]; cpo[5]= cval; + cval= cpo[3]; cpo[3]= cpo[4]; cpo[4]= cval; + + cpo+= 8; + } + } } } cur+= elen; @@ -1138,3 +1160,27 @@ int DNA_elem_offset(SDNA *sdna, const char *stype, const char *vartype, const ch return (int)((intptr_t)cp); } +int DNA_elem_type_size(const eSDNA_Type elem_nr) +{ + /* should containt all enum types */ + switch (elem_nr) { + case SDNA_TYPE_CHAR: + case SDNA_TYPE_UCHAR: + return 1; + case SDNA_TYPE_SHORT: + case SDNA_TYPE_USHORT: + return 2; + case SDNA_TYPE_INT: + case SDNA_TYPE_LONG: + case SDNA_TYPE_ULONG: + case SDNA_TYPE_FLOAT: + return 4; + case SDNA_TYPE_DOUBLE: + case SDNA_TYPE_INT64: + case SDNA_TYPE_UINT64: + return 8; + } + + /* weak */ + return 8; +} diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index 11ab9b1efcf..2fa52776453 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -928,16 +928,19 @@ static int make_structDNA(char *baseDirectory, FILE *file) /* insertion of all known types */ /* watch it: uint is not allowed! use in structs an unsigned int */ - add_type("char", 1); /* 0 */ - add_type("uchar", 1); /* 1 */ - add_type("short", 2); /* 2 */ - add_type("ushort", 2); /* 3 */ - add_type("int", 4); /* 4 */ - 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 */ - add_type("void", 0); /* 9 */ + /* watch it: sizes must match DNA_elem_type_size() */ + add_type("char", 1); /* SDNA_TYPE_CHAR */ + add_type("uchar", 1); /* SDNA_TYPE_UCHAR */ + add_type("short", 2); /* SDNA_TYPE_SHORT */ + add_type("ushort", 2); /* SDNA_TYPE_USHORT */ + add_type("int", 4); /* SDNA_TYPE_INT */ + add_type("long", 4); /* SDNA_TYPE_LONG */ /* should it be 8 on 64 bits? */ + add_type("ulong", 4); /* SDNA_TYPE_ULONG */ + add_type("float", 4); /* SDNA_TYPE_FLOAT */ + add_type("double", 8); /* SDNA_TYPE_DOUBLE */ + add_type("int64_t", 8); /* SDNA_TYPE_INT64 */ + add_type("uint64_t", 8); /* SDNA_TYPE_UINT64 */ + add_type("void", 0); /* SDNA_TYPE_VOID */ // the defines above shouldn't be output in the padding file... firststruct = nr_types; |