[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42837] trunk/blender/source/blender/ makesdna: add DNA support for int64_t.

Campbell Barton ideasman42 at gmail.com
Fri Dec 23 05:40:22 CET 2011


Revision: 42837
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42837
Author:   campbellbarton
Date:     2011-12-23 04:40:07 +0000 (Fri, 23 Dec 2011)
Log Message:
-----------
add DNA support for int64_t. nothing uses this currently.

Modified Paths:
--------------
    trunk/blender/source/blender/makesdna/DNA_genfile.h
    trunk/blender/source/blender/makesdna/intern/dna_genfile.c
    trunk/blender/source/blender/makesdna/intern/makesdna.c

Modified: trunk/blender/source/blender/makesdna/DNA_genfile.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_genfile.h	2011-12-23 00:51:54 UTC (rev 42836)
+++ trunk/blender/source/blender/makesdna/DNA_genfile.h	2011-12-23 04:40:07 UTC (rev 42837)
@@ -47,10 +47,14 @@
 	SDNA_TYPE_LONG     = 5,
 	SDNA_TYPE_ULONG    = 6,
 	SDNA_TYPE_FLOAT    = 7,
-	SDNA_TYPE_DOUBLE   = 8
-	/* ,SDNA_TYPE_VOID     = 9 */ /* nothing uses yet */
+	SDNA_TYPE_DOUBLE   = 8,
+	SDNA_TYPE_INT64    = 9
+	/* ,SDNA_TYPE_VOID     = 10 */ /* nothing uses yet */
 } eSDNA_Type;
 
+/* define so switch statements don't complain */
+#define SDNA_TYPE_VOID 10
+
 struct SDNA *DNA_sdna_from_data(void *data, int datalen, int do_endian_swap);
 void DNA_sdna_free(struct SDNA *sdna);
 

Modified: trunk/blender/source/blender/makesdna/intern/dna_genfile.c
===================================================================
--- trunk/blender/source/blender/makesdna/intern/dna_genfile.c	2011-12-23 00:51:54 UTC (rev 42836)
+++ trunk/blender/source/blender/makesdna/intern/dna_genfile.c	2011-12-23 04:40:07 UTC (rev 42837)
@@ -491,7 +491,7 @@
 			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;
 			}
 		}
 
@@ -666,6 +666,7 @@
 	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                                                                                  return -1; /* invalid! */
 }
 
@@ -708,6 +709,8 @@
 			val= *( (float *)olddata); break;
 		case SDNA_TYPE_DOUBLE:
 			val= *( (double *)olddata); break;
+		case SDNA_TYPE_INT64:
+			val= *( (int64_t *)olddata); break;
 		}
 		
 		switch(ctypenr) {
@@ -731,6 +734,8 @@
 		case SDNA_TYPE_DOUBLE:
 			if(otypenr<2) val/= 255;
 			*( (double *)curdata)= val; break;
+		case SDNA_TYPE_INT64:
+			*( (int64_t *)curdata)= val; break;
 		}
 
 		olddata+= oldlen;
@@ -1088,6 +1093,18 @@
 						cpo+= 4;
 					}
 				}
+				else if ( (spc[0]==SDNA_TYPE_INT64)) {
+					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;
@@ -1152,6 +1169,7 @@
 		case SDNA_TYPE_FLOAT:
 			return 4;
 		case SDNA_TYPE_DOUBLE:
+		case SDNA_TYPE_INT64:
 			return 8;
 	}
 

Modified: trunk/blender/source/blender/makesdna/intern/makesdna.c
===================================================================
--- trunk/blender/source/blender/makesdna/intern/makesdna.c	2011-12-23 00:51:54 UTC (rev 42836)
+++ trunk/blender/source/blender/makesdna/intern/makesdna.c	2011-12-23 04:40:07 UTC (rev 42837)
@@ -938,6 +938,7 @@
 	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("void", 0);	/* SDNA_TYPE_VOID */
 
 	// the defines above shouldn't be output in the padding file...




More information about the Bf-blender-cvs mailing list