Revision: 22366
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22366
Author:   campbellbarton
Date:     2009-08-11 13:50:40 +0200 (Tue, 11 Aug 2009)

Log Message:
-----------
fix for using subtype units that are not defined as a part of types. eg.
 prop= RNA_def_property(srna, "cursor_location", PROP_FLOAT, 
PROP_XYZ|PROP_UNIT_LENGTH);

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/makesrna/RNA_types.h
    branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c

Modified: branches/blender2.5/blender/source/blender/makesrna/RNA_types.h
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/RNA_types.h     
2009-08-11 11:44:45 UTC (rev 22365)
+++ branches/blender2.5/blender/source/blender/makesrna/RNA_types.h     
2009-08-11 11:50:40 UTC (rev 22366)
@@ -66,6 +66,7 @@
        PROP_COLLECTION = 6
 } PropertyType;
 
+/* also update rna_property_subtype_unit when you change this */
 typedef enum PropertyUnit {
        PROP_UNIT_NONE = (0<<16),
        PROP_UNIT_LENGTH = (1<<16),                     /* m */

Modified: branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c       
2009-08-11 11:44:45 UTC (rev 22365)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/makesrna.c       
2009-08-11 11:50:40 UTC (rev 22366)
@@ -1388,6 +1388,30 @@
                case PROP_XYZ: return "PROP_XYZ";
                case PROP_RGB: return "PROP_RGB";
                case PROP_NEVER_NULL: return "PROP_NEVER_NULL";
+               default: {
+                       /* incase we dont have a type preset that includes the 
subtype */
+                       if(RNA_SUBTYPE_UNIT(type)) {
+                               return rna_property_subtypename(type & 
~RNA_SUBTYPE_UNIT(type));
+                       }
+                       else {
+                               return "PROP_SUBTYPE_UNKNOWN";
+                       }
+               }
+       }
+}
+
+static const char *rna_property_subtype_unit(PropertyType type)
+{
+       switch(RNA_SUBTYPE_UNIT(type)) {
+               case PROP_UNIT_NONE:            return "PROP_UNIT_NONE";
+               case PROP_UNIT_LENGTH:          return "PROP_UNIT_LENGTH";
+               case PROP_UNIT_AREA:            return "PROP_UNIT_AREA";
+               case PROP_UNIT_VOLUME:          return "PROP_UNIT_VOLUME";
+               case PROP_UNIT_MASS:            return "PROP_UNIT_MASS";
+               case PROP_UNIT_ROTATION:        return "PROP_UNIT_ROTATION";
+               case PROP_UNIT_TIME:            return "PROP_UNIT_TIME";
+               case PROP_UNIT_VELOCITY:        return "PROP_UNIT_VELOCITY";
+               case PROP_UNIT_ACCELERATION:return "PROP_UNIT_ACCELERATION";
                default: return "PROP_UNKNOWN";
        }
 }
@@ -1693,7 +1717,7 @@
        rna_print_c_string(f, prop->name); fprintf(f, ",\n\t");
        rna_print_c_string(f, prop->description); fprintf(f, ",\n\t");
        fprintf(f, "%d,\n", prop->icon);
-       fprintf(f, "\t%s, %s, %d,\n", rna_property_typename(prop->type), 
rna_property_subtypename(prop->subtype), prop->arraylength);
+       fprintf(f, "\t%s, %s|%s, %d,\n", rna_property_typename(prop->type), 
rna_property_subtypename(prop->subtype), 
rna_property_subtype_unit(prop->subtype), prop->arraylength);
        fprintf(f, "\t%s, %d, %s,\n", rna_function_string(prop->update), 
prop->noteflag, rna_function_string(prop->editable));
 
        if(prop->flag & PROP_RAW_ACCESS) rna_set_raw_offset(f, srna, prop);


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to