* Wrap most user editable data in DNA_mesh_types.h and DNA_meshdata_types.h.
  Still needs to be improved in some areas though, especially how to deal
  with data layers (expose per element or as array, or both?), and data in
  face corners (bmesh type data structures are more logical here).

Tweaks to RNA defining to make some cases easier:
* Added range callback function for int/float.
* Added 'skip' callback for listbase and array iterators to skip items in
  the collection.
* Extra error print when calling wrong define_property_*_sdna functions.
* Also made button code respect non_editable flag, is quick change though,
  need to add support for properly graying out etc.
This commit is contained in:
Brecht Van Lommel 2008-11-24 12:12:24 +00:00
parent 10c58adba9
commit b863bf98e5
14 changed files with 1215 additions and 153 deletions

View File

@ -1138,30 +1138,32 @@ void ui_set_but_val(uiBut *but, double value)
if(but->rnaprop) {
prop= but->rnaprop;
switch(RNA_property_type(prop, &but->rnapoin)) {
case PROP_BOOLEAN:
if(RNA_property_array_length(prop, &but->rnapoin))
RNA_property_boolean_set_array(prop, &but->rnapoin, but->rnaindex, value);
else
RNA_property_boolean_set(prop, &but->rnapoin, value);
break;
case PROP_INT:
if(RNA_property_array_length(prop, &but->rnapoin))
RNA_property_int_set_array(prop, &but->rnapoin, but->rnaindex, value);
else
RNA_property_int_set(prop, &but->rnapoin, value);
break;
case PROP_FLOAT:
if(RNA_property_array_length(prop, &but->rnapoin))
RNA_property_float_set_array(prop, &but->rnapoin, but->rnaindex, value);
else
RNA_property_float_set(prop, &but->rnapoin, value);
break;
case PROP_ENUM:
RNA_property_enum_set(prop, &but->rnapoin, value);
break;
default:
break;
if(RNA_property_editable(prop, &but->rnapoin)) {
switch(RNA_property_type(prop, &but->rnapoin)) {
case PROP_BOOLEAN:
if(RNA_property_array_length(prop, &but->rnapoin))
RNA_property_boolean_set_array(prop, &but->rnapoin, but->rnaindex, value);
else
RNA_property_boolean_set(prop, &but->rnapoin, value);
break;
case PROP_INT:
if(RNA_property_array_length(prop, &but->rnapoin))
RNA_property_int_set_array(prop, &but->rnapoin, but->rnaindex, value);
else
RNA_property_int_set(prop, &but->rnapoin, value);
break;
case PROP_FLOAT:
if(RNA_property_array_length(prop, &but->rnapoin))
RNA_property_float_set_array(prop, &but->rnapoin, but->rnaindex, value);
else
RNA_property_float_set(prop, &but->rnapoin, value);
break;
case PROP_ENUM:
RNA_property_enum_set(prop, &but->rnapoin, value);
break;
default:
break;
}
}
}
else if(but->pointype==0);

View File

@ -907,7 +907,10 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event)
void ED_SCR_OT_area_split(wmOperatorType *ot)
{
PropertyRNA *prop;
static EnumPropertyItem prop_direction_items[] = {{'h', "HORIZONTAL", "Horizontal"}, {'v', "VERTICAL", "Vertical"}, {0, NULL, NULL}};
static EnumPropertyItem prop_direction_items[] = {
{'h', "HORIZONTAL", "Horizontal", ""},
{'v', "VERTICAL", "Vertical", ""},
{0, NULL, NULL, NULL}};
ot->name = "Split area";
ot->idname = "ED_SCR_OT_area_split";

View File

@ -78,10 +78,10 @@ void RNA_def_property_string_default(PropertyRNA *prop, const char *value);
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description);
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision);
void RNA_def_property_funcs(PropertyRNA *prop, const char *notify);
void RNA_def_property_funcs(PropertyRNA *prop, const char *notify, const char *editable);
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set);
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set);
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set);
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range);
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range);
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set);
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set);
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *type, const char *set);

View File

@ -113,6 +113,7 @@ typedef struct EnumPropertyItem {
int value;
const char *identifier;
const char *name;
const char *description;
} EnumPropertyItem;
struct PropertyRNA;

View File

@ -291,7 +291,7 @@ static char *rna_def_property_length_func(FILE *f, StructRNA *srna, PropertyRNA
fprintf(f, "}\n\n");
}
else if(prop->type == PROP_COLLECTION) {
if(prop->type == PROP_COLLECTION && !dp->dnalengthname) {
if(prop->type == PROP_COLLECTION && (!dp->dnalengthname || !dp->dnaname)) {
fprintf(stderr, "rna_def_property_length_func: %s.%s has no valid dna info.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
return NULL;
@ -302,7 +302,7 @@ static char *rna_def_property_length_func(FILE *f, StructRNA *srna, PropertyRNA
fprintf(f, "static int %s(PointerRNA *ptr)\n", func);
fprintf(f, "{\n");
fprintf(f, " %s *data= (%s*)ptr->data;\n", dp->dnastructname, dp->dnastructname);
fprintf(f, " return data->%s;\n", dp->dnalengthname);
fprintf(f, " return (data->%s == NULL)? 0: data->%s;\n", dp->dnaname, dp->dnalengthname);
fprintf(f, "}\n\n");
}
@ -328,14 +328,14 @@ static char *rna_def_property_begin_func(FILE *f, StructRNA *srna, PropertyRNA *
fprintf(f, "static void %s(CollectionPropertyIterator *iter, PointerRNA *ptr)\n", func);
fprintf(f, "{\n");
fprintf(f, " %s *data= (%s*)ptr->data;\n", dp->dnastructname, dp->dnastructname);
fprintf(f, " rna_iterator_array_begin(iter, data->%s, sizeof(data->%s[0]), data->%s);\n", dp->dnaname, dp->dnaname, dp->dnalengthname);
fprintf(f, " rna_iterator_array_begin(iter, data->%s, sizeof(data->%s[0]), data->%s, NULL);\n", dp->dnaname, dp->dnaname, dp->dnalengthname);
fprintf(f, "}\n\n");
}
else {
fprintf(f, "static void %s(CollectionPropertyIterator *iter, PointerRNA *ptr)\n", func);
fprintf(f, "{\n");
fprintf(f, " %s *data= (%s*)ptr->data;\n", dp->dnastructname, dp->dnastructname);
fprintf(f, " rna_iterator_listbase_begin(iter, &data->%s);\n", dp->dnaname);
fprintf(f, " rna_iterator_listbase_begin(iter, &data->%s, NULL);\n", dp->dnaname);
fprintf(f, "}\n\n");
}
@ -586,7 +586,8 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f)
for(i=0; i<eprop->totitem; i++) {
fprintf(f, "{%d, ", eprop->item[i].value);
rna_print_c_string(f, eprop->item[i].identifier); fprintf(f, ", ");
rna_print_c_string(f, eprop->item[i].name); fprintf(f, "}");
rna_print_c_string(f, eprop->item[i].name); fprintf(f, ", ");
rna_print_c_string(f, eprop->item[i].description); fprintf(f, "}");
if(i != eprop->totitem-1)
fprintf(f, ", ");
}
@ -675,7 +676,7 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f)
rna_print_c_string(f, prop->name); fprintf(f, ",\n\t");
rna_print_c_string(f, prop->description); fprintf(f, ",\n");
fprintf(f, "\t%s, %s, %d,\n", rna_property_typename(prop->type), rna_property_subtypename(prop->subtype), prop->arraylength);
fprintf(f, "\t%s},\n", rna_function_string(prop->notify));
fprintf(f, "\t%s, %s},\n", rna_function_string(prop->notify), rna_function_string(prop->editable));
switch(prop->type) {
case PROP_BOOLEAN: {
@ -687,14 +688,14 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f)
}
case PROP_INT: {
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
fprintf(f, "\t%s, %s, %s, %s, %d, %d, %d, %d, %d,\n\t%d, ", rna_function_string(iprop->get), rna_function_string(iprop->set), rna_function_string(iprop->getarray), rna_function_string(iprop->setarray), iprop->softmin, iprop->softmax, iprop->hardmin, iprop->hardmax, iprop->step, iprop->defaultvalue);
fprintf(f, "\t%s, %s, %s, %s, %s, %d, %d, %d, %d, %d,\n\t%d, ", rna_function_string(iprop->get), rna_function_string(iprop->set), rna_function_string(iprop->getarray), rna_function_string(iprop->setarray), rna_function_string(iprop->range), iprop->softmin, iprop->softmax, iprop->hardmin, iprop->hardmax, iprop->step, iprop->defaultvalue);
if(prop->arraylength) fprintf(f, "rna_%s_%s_default\n", srna->identifier, prop->identifier);
else fprintf(f, "NULL\n");
break;
}
case PROP_FLOAT: {
FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop;
fprintf(f, "\t%s, %s, %s, %s, ", rna_function_string(fprop->get), rna_function_string(fprop->set), rna_function_string(fprop->getarray), rna_function_string(fprop->setarray));
fprintf(f, "\t%s, %s, %s, %s, %s, ", rna_function_string(fprop->get), rna_function_string(fprop->set), rna_function_string(fprop->getarray), rna_function_string(fprop->setarray), rna_function_string(fprop->range));
rna_float_print(f, fprop->softmin); fprintf(f, ", ");
rna_float_print(f, fprop->softmax); fprintf(f, ", ");
rna_float_print(f, fprop->hardmin); fprintf(f, ", ");

View File

@ -291,19 +291,33 @@ void RNA_property_int_range(PropertyRNA *prop, PointerRNA *ptr, int *hardmin, in
rna_idproperty_check(&prop, ptr);
iprop= (IntPropertyRNA*)prop;
*hardmin= iprop->hardmin;
*hardmax= iprop->hardmax;
if(iprop->range) {
iprop->range(ptr, hardmin, hardmax);
}
else {
*hardmin= iprop->hardmin;
*hardmax= iprop->hardmax;
}
}
void RNA_property_int_ui_range(PropertyRNA *prop, PointerRNA *ptr, int *softmin, int *softmax, int *step)
{
IntPropertyRNA *iprop;
int hardmin, hardmax;
rna_idproperty_check(&prop, ptr);
iprop= (IntPropertyRNA*)prop;
*softmin= iprop->softmin;
*softmax= iprop->softmax;
if(iprop->range) {
iprop->range(ptr, &hardmin, &hardmax);
*softmin= MAX2(iprop->softmin, hardmin);
*softmax= MIN2(iprop->softmax, hardmax);
}
else {
*softmin= iprop->softmin;
*softmax= iprop->softmax;
}
*step= iprop->step;
}
@ -314,19 +328,33 @@ void RNA_property_float_range(PropertyRNA *prop, PointerRNA *ptr, float *hardmin
rna_idproperty_check(&prop, ptr);
fprop= (FloatPropertyRNA*)prop;
*hardmin= fprop->hardmin;
*hardmax= fprop->hardmax;
if(fprop->range) {
fprop->range(ptr, hardmin, hardmax);
}
else {
*hardmin= fprop->hardmin;
*hardmax= fprop->hardmax;
}
}
void RNA_property_float_ui_range(PropertyRNA *prop, PointerRNA *ptr, float *softmin, float *softmax, float *step, float *precision)
{
FloatPropertyRNA *fprop;
float hardmin, hardmax;
rna_idproperty_check(&prop, ptr);
fprop= (FloatPropertyRNA*)prop;
*softmin= fprop->softmin;
*softmax= fprop->softmax;
if(fprop->range) {
fprop->range(ptr, &hardmin, &hardmax);
*softmin= MAX2(fprop->softmin, hardmin);
*softmax= MIN2(fprop->softmax, hardmax);
}
else {
*softmin= fprop->softmin;
*softmax= fprop->softmax;
}
*step= fprop->step;
*precision= fprop->precision;
}
@ -375,16 +403,30 @@ const char *RNA_property_ui_description(PropertyRNA *prop, PointerRNA *ptr)
int RNA_property_editable(PropertyRNA *prop, PointerRNA *ptr)
{
int flag;
rna_idproperty_check(&prop, ptr);
return !(prop->flag & PROP_NOT_EDITABLE);
if(prop->editable)
flag= prop->editable(ptr);
else
flag= prop->flag;
return !(flag & PROP_NOT_EDITABLE);
}
int RNA_property_evaluated(PropertyRNA *prop, PointerRNA *ptr)
{
int flag;
rna_idproperty_check(&prop, ptr);
return (prop->flag & PROP_EVALUATED);
if(prop->editable)
flag= prop->editable(ptr);
else
flag= prop->flag;
return (flag & PROP_EVALUATED);
}
void RNA_property_notify(PropertyRNA *prop, struct bContext *C, PointerRNA *ptr)
@ -961,23 +1003,35 @@ int RNA_property_collection_lookup_string(PropertyRNA *prop, PointerRNA *ptr, co
/* Standard iterator functions */
void rna_iterator_listbase_begin(CollectionPropertyIterator *iter, ListBase *lb)
void rna_iterator_listbase_begin(CollectionPropertyIterator *iter, ListBase *lb, IteratorSkipFunc skip)
{
ListBaseIterator *internal;
internal= MEM_callocN(sizeof(ListBaseIterator), "ListBaseIterator");
internal->link= lb->first;
internal->skip= skip;
iter->internal= internal;
iter->valid= (internal->link != NULL);
if(skip && iter->valid && skip(iter, internal->link))
rna_iterator_listbase_next(iter);
}
void rna_iterator_listbase_next(CollectionPropertyIterator *iter)
{
ListBaseIterator *internal= iter->internal;
internal->link= internal->link->next;
iter->valid= (internal->link != NULL);
if(internal->skip) {
do {
internal->link= internal->link->next;
iter->valid= (internal->link != NULL);
} while(iter->valid && internal->skip(iter, internal->link));
}
else {
internal->link= internal->link->next;
iter->valid= (internal->link != NULL);
}
}
void *rna_iterator_listbase_get(CollectionPropertyIterator *iter)
@ -992,25 +1046,40 @@ void rna_iterator_listbase_end(CollectionPropertyIterator *iter)
MEM_freeN(iter->internal);
}
void rna_iterator_array_begin(CollectionPropertyIterator *iter, void *ptr, int itemsize, int length)
void rna_iterator_array_begin(CollectionPropertyIterator *iter, void *ptr, int itemsize, int length, IteratorSkipFunc skip)
{
ArrayIterator *internal;
if(ptr == NULL)
length= 0;
internal= MEM_callocN(sizeof(ArrayIterator), "ArrayIterator");
internal->ptr= ptr;
internal->endptr= ((char*)ptr)+length*itemsize;
internal->itemsize= itemsize;
internal->skip= skip;
iter->internal= internal;
iter->valid= (internal->ptr != internal->endptr);
if(skip && iter->valid && skip(iter, internal->ptr))
rna_iterator_array_next(iter);
}
void rna_iterator_array_next(CollectionPropertyIterator *iter)
{
ArrayIterator *internal= iter->internal;
internal->ptr += internal->itemsize;
iter->valid= (internal->ptr != internal->endptr);
if(internal->skip) {
do {
internal->ptr += internal->itemsize;
iter->valid= (internal->ptr != internal->endptr);
} while(iter->valid && internal->skip(iter, internal->ptr));
}
else {
internal->ptr += internal->itemsize;
iter->valid= (internal->ptr != internal->endptr);
}
}
void *rna_iterator_array_get(CollectionPropertyIterator *iter)

View File

@ -264,6 +264,7 @@ StructRNA *RNA_def_struct(BlenderRNA *brna, const char *identifier, const char *
}
srna= MEM_callocN(sizeof(StructRNA), "StructRNA");
DefRNA.laststruct= srna;
/* copy from struct to derive stuff, a bit clumsy since we can't
* use MEM_dupallocN, data structs may not be alloced but builtin */
@ -872,12 +873,19 @@ static PropertyDefRNA *rna_def_property_sdna(PropertyRNA *prop, const char *stru
void RNA_def_property_boolean_sdna(PropertyRNA *prop, const char *structname, const char *propname, int bit)
{
PropertyDefRNA *dp;
StructRNA *srna= DefRNA.laststruct;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
return;
}
if(prop->type != PROP_BOOLEAN) {
fprintf(stderr, "RNA_def_property_boolean_sdna: %s.%s, type is not boolean.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
return;
}
if((dp=rna_def_property_sdna(prop, structname, propname)))
dp->booleanbit= bit;
}
@ -886,12 +894,19 @@ void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const
{
PropertyDefRNA *dp;
IntPropertyRNA *iprop= (IntPropertyRNA*)prop;
StructRNA *srna= DefRNA.laststruct;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
return;
}
if(prop->type != PROP_INT) {
fprintf(stderr, "RNA_def_property_int_sdna: %s.%s, type is not int.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
return;
}
if((dp= rna_def_property_sdna(prop, structname, propname))) {
/* SDNA doesn't pass us unsigned unfortunately .. */
if(strcmp(dp->dnatype, "char") == 0) {
@ -917,18 +932,38 @@ void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const
void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname)
{
StructRNA *srna= DefRNA.laststruct;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
return;
}
if(prop->type != PROP_FLOAT) {
fprintf(stderr, "RNA_def_property_float_sdna: %s.%s, type is not float.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
return;
}
rna_def_property_sdna(prop, structname, propname);
}
void RNA_def_property_enum_sdna(PropertyRNA *prop, const char *structname, const char *propname)
{
PropertyDefRNA *dp;
StructRNA *srna= DefRNA.laststruct;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
return;
}
if(prop->type != PROP_ENUM) {
fprintf(stderr, "RNA_def_property_enum_sdna: %s.%s, type is not enum.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
return;
}
if((dp=rna_def_property_sdna(prop, structname, propname))) {
if(prop->arraylength) {
prop->arraylength= 0;
@ -944,12 +979,19 @@ void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, con
{
PropertyDefRNA *dp;
StringPropertyRNA *sprop= (StringPropertyRNA*)prop;
StructRNA *srna= DefRNA.laststruct;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
return;
}
if(prop->type != PROP_STRING) {
fprintf(stderr, "RNA_def_property_string_sdna: %s.%s, type is not string.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
return;
}
if((dp=rna_def_property_sdna(prop, structname, propname))) {
if(prop->arraylength) {
sprop->maxlength= prop->arraylength;
@ -961,12 +1003,19 @@ void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, con
void RNA_def_property_pointer_sdna(PropertyRNA *prop, const char *structname, const char *propname)
{
PropertyDefRNA *dp;
StructRNA *srna= DefRNA.laststruct;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
return;
}
if(prop->type != PROP_POINTER) {
fprintf(stderr, "RNA_def_property_pointer_sdna: %s.%s, type is not pointer.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
return;
}
if((dp=rna_def_property_sdna(prop, structname, propname))) {
if(prop->arraylength) {
prop->arraylength= 0;
@ -982,12 +1031,19 @@ void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname,
{
PropertyDefRNA *dp;
CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop;
StructRNA *srna= DefRNA.laststruct;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_sdna: only during preprocessing.\n");
return;
}
if(prop->type != PROP_COLLECTION) {
fprintf(stderr, "RNA_def_property_collection_sdna: %s.%s, type is not collection.\n", srna->identifier, prop->identifier);
DefRNA.error= 1;
return;
}
if((dp=rna_def_property_sdna(prop, structname, propname))) {
if(prop->arraylength) {
prop->arraylength= 0;
@ -1031,7 +1087,7 @@ void RNA_def_property_collection_sdna(PropertyRNA *prop, const char *structname,
/* Functions */
void RNA_def_property_funcs(PropertyRNA *prop, const char *notify)
void RNA_def_property_funcs(PropertyRNA *prop, const char *notify, const char *editable)
{
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_funcs: only during preprocessing.\n");
@ -1039,11 +1095,12 @@ void RNA_def_property_funcs(PropertyRNA *prop, const char *notify)
}
if(notify) prop->notify= (NotifyFunc)notify;
if(editable) prop->editable= (EditableFunc)editable;
}
void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const char *set)
{
StructRNA *srna;
StructRNA *srna= DefRNA.laststruct;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
@ -1071,9 +1128,9 @@ void RNA_def_property_boolean_funcs(PropertyRNA *prop, const char *get, const ch
}
}
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set)
void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
{
StructRNA *srna;
StructRNA *srna= DefRNA.laststruct;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
@ -1092,6 +1149,7 @@ void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *
if(get) iprop->get= (PropIntGetFunc)get;
if(set) iprop->set= (PropIntSetFunc)set;
}
if(range) iprop->range= (PropIntRangeFunc)range;
break;
}
default:
@ -1101,9 +1159,9 @@ void RNA_def_property_int_funcs(PropertyRNA *prop, const char *get, const char *
}
}
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set)
void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char *set, const char *range)
{
StructRNA *srna;
StructRNA *srna= DefRNA.laststruct;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
@ -1122,6 +1180,7 @@ void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char
if(get) fprop->get= (PropFloatGetFunc)get;
if(set) fprop->set= (PropFloatSetFunc)set;
}
if(range) fprop->range= (PropFloatRangeFunc)range;
break;
}
default:
@ -1133,7 +1192,7 @@ void RNA_def_property_float_funcs(PropertyRNA *prop, const char *get, const char
void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char *set)
{
StructRNA *srna;
StructRNA *srna= DefRNA.laststruct;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
@ -1157,7 +1216,7 @@ void RNA_def_property_enum_funcs(PropertyRNA *prop, const char *get, const char
void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const char *length, const char *set)
{
StructRNA *srna;
StructRNA *srna= DefRNA.laststruct;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
@ -1182,7 +1241,7 @@ void RNA_def_property_string_funcs(PropertyRNA *prop, const char *get, const cha
void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const char *type, const char *set)
{
StructRNA *srna;
StructRNA *srna= DefRNA.laststruct;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");
@ -1207,7 +1266,7 @@ void RNA_def_property_pointer_funcs(PropertyRNA *prop, const char *get, const ch
void RNA_def_property_collection_funcs(PropertyRNA *prop, const char *begin, const char *next, const char *end, const char *get, const char *type, const char *length, const char *lookupint, const char *lookupstring)
{
StructRNA *srna;
StructRNA *srna= DefRNA.laststruct;
if(!DefRNA.preprocess) {
fprintf(stderr, "RNA_def_property_*_funcs: only during preprocessing.\n");

View File

@ -123,12 +123,15 @@ void *rna_builtin_type_get(struct PointerRNA *ptr);
/* Iterators */
typedef int (*IteratorSkipFunc)(struct CollectionPropertyIterator *iter, void *data);
typedef struct ListBaseIterator {
Link *link;
int flag;
IteratorSkipFunc skip;
} ListBaseIterator;
void rna_iterator_listbase_begin(struct CollectionPropertyIterator *iter, struct ListBase *lb);
void rna_iterator_listbase_begin(struct CollectionPropertyIterator *iter, struct ListBase *lb, IteratorSkipFunc skip);
void rna_iterator_listbase_next(struct CollectionPropertyIterator *iter);
void *rna_iterator_listbase_get(struct CollectionPropertyIterator *iter);
void rna_iterator_listbase_end(struct CollectionPropertyIterator *iter);
@ -137,9 +140,10 @@ typedef struct ArrayIterator {
char *ptr;
char *endptr;
int itemsize;
IteratorSkipFunc skip;
} ArrayIterator;
void rna_iterator_array_begin(struct CollectionPropertyIterator *iter, void *ptr, int itemsize, int length);
void rna_iterator_array_begin(struct CollectionPropertyIterator *iter, void *ptr, int itemsize, int length, IteratorSkipFunc skip);
void rna_iterator_array_next(struct CollectionPropertyIterator *iter);
void *rna_iterator_array_get(struct CollectionPropertyIterator *iter);
void rna_iterator_array_end(struct CollectionPropertyIterator *iter);

View File

@ -37,6 +37,7 @@ struct bContext;
/* Function Callbacks */
typedef void (*NotifyFunc)(struct bContext *C, struct PointerRNA *ptr);
typedef int (*EditableFunc)(struct PointerRNA *ptr);
typedef struct StructRNA *(*StructRefineFunc)(struct PointerRNA *ptr);
typedef int (*PropBooleanGetFunc)(struct PointerRNA *ptr);
@ -47,10 +48,12 @@ typedef int (*PropIntGetFunc)(struct PointerRNA *ptr);
typedef void (*PropIntSetFunc)(struct PointerRNA *ptr, int value);
typedef int (*PropIntArrayGetFunc)(struct PointerRNA *ptr, int index);
typedef void (*PropIntArraySetFunc)(struct PointerRNA *ptr, int index, int value);
typedef void (*PropIntRangeFunc)(struct PointerRNA *ptr, int *min, int *max);
typedef float (*PropFloatGetFunc)(struct PointerRNA *ptr);
typedef void (*PropFloatSetFunc)(struct PointerRNA *ptr, float value);
typedef float (*PropFloatArrayGetFunc)(struct PointerRNA *ptr, int index);
typedef void (*PropFloatArraySetFunc)(struct PointerRNA *ptr, int index, float value);
typedef void (*PropFloatRangeFunc)(struct PointerRNA *ptr, float *min, float *max);
typedef void (*PropStringGetFunc)(struct PointerRNA *ptr, char *value);
typedef int (*PropStringLengthFunc)(struct PointerRNA *ptr);
typedef void (*PropStringSetFunc)(struct PointerRNA *ptr, const char *value);
@ -93,6 +96,9 @@ struct PropertyRNA {
/* callback for notifys on change */
NotifyFunc notify;
/* callback for testing if editable/evaluated */
EditableFunc editable;
};
/* Property Types */
@ -119,6 +125,8 @@ typedef struct IntPropertyRNA {
PropIntArrayGetFunc getarray;
PropIntArraySetFunc setarray;
PropIntRangeFunc range;
int softmin, softmax;
int hardmin, hardmax;
int step;
@ -136,6 +144,8 @@ typedef struct FloatPropertyRNA {
PropFloatArrayGetFunc getarray;
PropFloatArraySetFunc setarray;
PropFloatRangeFunc range;
float softmin, softmax;
float hardmin, hardmax;
float step;

View File

@ -39,7 +39,13 @@ void RNA_def_lamp(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
static EnumPropertyItem prop_type_items[] = {{LA_LOCAL, "LOCAL", "Local"}, {LA_SUN, "SUN", "Sun"}, {LA_SPOT, "SPOT", "Spot"}, {LA_HEMI, "HEMI", "Hemi"}, {LA_AREA, "AREA", "Area"}, {0, NULL, NULL}};
static EnumPropertyItem prop_type_items[] = {
{LA_LOCAL, "LOCAL", "Local", ""},
{LA_SUN, "SUN", "Sun", ""},
{LA_SPOT, "SPOT", "Spot", ""},
{LA_HEMI, "HEMI", "Hemi", ""},
{LA_AREA, "AREA", "Area", ""},
{0, NULL, NULL, NULL}};
srna= RNA_def_struct(brna, "Lamp", "ID", "Lamp");

View File

@ -37,70 +37,70 @@
static void rna_Main_scene_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->scene);
rna_iterator_listbase_begin(iter, &bmain->scene, NULL);
}
static void rna_Main_object_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->object);
rna_iterator_listbase_begin(iter, &bmain->object, NULL);
}
static void rna_Main_lamp_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->lamp);
rna_iterator_listbase_begin(iter, &bmain->lamp, NULL);
}
#if 0
static void rna_Main_library_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->library);
rna_iterator_listbase_begin(iter, &bmain->library, NULL);
}
#endif
static void rna_Main_mesh_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->mesh);
rna_iterator_listbase_begin(iter, &bmain->mesh, NULL);
}
#if 0
static void rna_Main_curve_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->curve);
rna_iterator_listbase_begin(iter, &bmain->curve, NULL);
}
static void rna_Main_mball_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->mball);
rna_iterator_listbase_begin(iter, &bmain->mball, NULL);
}
static void rna_Main_mat_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->mat);
rna_iterator_listbase_begin(iter, &bmain->mat, NULL);
}
static void rna_Main_tex_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->tex);
rna_iterator_listbase_begin(iter, &bmain->tex, NULL);
}
static void rna_Main_image_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->image);
rna_iterator_listbase_begin(iter, &bmain->image, NULL);
}
static void rna_Main_latt_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->latt);
rna_iterator_listbase_begin(iter, &bmain->latt, NULL);
}
@ -108,98 +108,98 @@ static void rna_Main_latt_begin(CollectionPropertyIterator *iter, PointerRNA *pt
static void rna_Main_camera_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->camera);
rna_iterator_listbase_begin(iter, &bmain->camera, NULL);
}
static void rna_Main_ipo_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->ipo);
rna_iterator_listbase_begin(iter, &bmain->ipo, NULL);
}
static void rna_Main_key_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->key);
rna_iterator_listbase_begin(iter, &bmain->key, NULL);
}
static void rna_Main_world_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->world);
rna_iterator_listbase_begin(iter, &bmain->world, NULL);
}
static void rna_Main_screen_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->screen);
rna_iterator_listbase_begin(iter, &bmain->screen, NULL);
}
static void rna_Main_script_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->script);
rna_iterator_listbase_begin(iter, &bmain->script, NULL);
}
static void rna_Main_vfont_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->vfont);
rna_iterator_listbase_begin(iter, &bmain->vfont, NULL);
}
static void rna_Main_text_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->text);
rna_iterator_listbase_begin(iter, &bmain->text, NULL);
}
static void rna_Main_sound_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->sound);
rna_iterator_listbase_begin(iter, &bmain->sound, NULL);
}
static void rna_Main_group_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->group);
rna_iterator_listbase_begin(iter, &bmain->group, NULL);
}
static void rna_Main_armature_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->armature);
rna_iterator_listbase_begin(iter, &bmain->armature, NULL);
}
static void rna_Main_action_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->action);
rna_iterator_listbase_begin(iter, &bmain->action, NULL);
}
static void rna_Main_nodetree_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->nodetree);
rna_iterator_listbase_begin(iter, &bmain->nodetree, NULL);
}
static void rna_Main_brush_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->brush);
rna_iterator_listbase_begin(iter, &bmain->brush, NULL);
}
static void rna_Main_particle_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->particle);
rna_iterator_listbase_begin(iter, &bmain->particle, NULL);
}
#endif
static void rna_Main_wm_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Main *bmain= (Main*)ptr->data;
rna_iterator_listbase_begin(iter, &bmain->wm);
rna_iterator_listbase_begin(iter, &bmain->wm, NULL);
}
#else

View File

@ -29,31 +29,935 @@
#include "rna_internal.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "BKE_customdata.h"
#ifdef RNA_RUNTIME
/*static float rna_MVert_no_get(PointerRNA *ptr, int index)
{
MVert *mvert= (MVert*)ptr->data;
return mvert->no[index]/32767.0f;
}*/
static float rna_MVert_bevel_weight_get(PointerRNA *ptr)
{
MVert *mvert= (MVert*)ptr->data;
return mvert->bweight/255.0f;
}
static void rna_MVert_bevel_weight_set(PointerRNA *ptr, float value)
{
MVert *mvert= (MVert*)ptr->data;
mvert->bweight= (char)(CLAMPIS(value*255.0f, 0, 255));
}
static float rna_MEdge_bevel_weight_get(PointerRNA *ptr)
{
MEdge *medge= (MEdge*)ptr->data;
return medge->bweight/255.0f;
}
static void rna_MEdge_bevel_weight_set(PointerRNA *ptr, float value)
{
MEdge *medge= (MEdge*)ptr->data;
medge->bweight= (char)(CLAMPIS(value*255.0f, 0, 255));
}
static float rna_MEdge_crease_get(PointerRNA *ptr)
{
MEdge *medge= (MEdge*)ptr->data;
return medge->crease/255.0f;
}
static void rna_MEdge_crease_set(PointerRNA *ptr, float value)
{
MEdge *medge= (MEdge*)ptr->data;
medge->crease= (char)(CLAMPIS(value*255.0f, 0, 255));
}
static float rna_MCol_color1_get(PointerRNA *ptr, int index)
{
MCol *mcol= (MCol*)ptr->data;
return (&mcol[0].r)[index]/255.0f;
}
static void rna_MCol_color1_set(PointerRNA *ptr, int index, float value)
{
MCol *mcol= (MCol*)ptr->data;
(&mcol[0].r)[index]= (char)(CLAMPIS(value*255.0f, 0, 255));
}
static float rna_MCol_color2_get(PointerRNA *ptr, int index)
{
MCol *mcol= (MCol*)ptr->data;
return (&mcol[1].r)[index]/255.0f;
}
static void rna_MCol_color2_set(PointerRNA *ptr, int index, float value)
{
MCol *mcol= (MCol*)ptr->data;
(&mcol[1].r)[index]= (char)(CLAMPIS(value*255.0f, 0, 255));
}
static float rna_MCol_color3_get(PointerRNA *ptr, int index)
{
MCol *mcol= (MCol*)ptr->data;
return (&mcol[2].r)[index]/255.0f;
}
static void rna_MCol_color3_set(PointerRNA *ptr, int index, float value)
{
MCol *mcol= (MCol*)ptr->data;
(&mcol[2].r)[index]= (char)(CLAMPIS(value*255.0f, 0, 255));
}
static float rna_MCol_color4_get(PointerRNA *ptr, int index)
{
MCol *mcol= (MCol*)ptr->data;
return (&mcol[2].r)[index]/255.0f;
}
static void rna_MCol_color4_set(PointerRNA *ptr, int index, float value)
{
MCol *mcol= (MCol*)ptr->data;
(&mcol[3].r)[index]= (char)(CLAMPIS(value*255.0f, 0, 255));
}
static int rna_Mesh_texspace_editable(PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->data;
return (me->texflag & AUTOSPACE)? PROP_NOT_EDITABLE: 0;
}
static void rna_MVert_groups_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->id.data;
if(me->dvert) {
MVert *mvert= (MVert*)ptr->data;
MDeformVert *dvert= me->dvert + (mvert-me->mvert);
rna_iterator_array_begin(iter, (void*)dvert->dw, sizeof(MDeformWeight), dvert->totweight, NULL);
}
else
rna_iterator_array_begin(iter, NULL, 0, 0, NULL);
}
static void rna_MMultires_level_range(PointerRNA *ptr, int *min, int *max)
{
Multires *mr= (Multires*)ptr->data;
*min= 1;
*max= mr->level_count;
}
static void rna_MFace_mat_index_range(PointerRNA *ptr, int *min, int *max)
{
Mesh *me= (Mesh*)ptr->id.data;
*min= 0;
*max= me->totcol-1;
}
static int rna_CustomDataLayer_length(PointerRNA *ptr, int type)
{
Mesh *me= (Mesh*)ptr->id.data;
CustomDataLayer *layer;
int i, length= 0;
for(layer=me->fdata.layers, i=0; i<me->fdata.totlayer; layer++, i++)
if(layer->type == type)
length++;
return length;
}
static int rna_CustomDataLayer_active_get(PointerRNA *ptr, int type, int render)
{
Mesh *me= (Mesh*)ptr->id.data;
int n= ((CustomDataLayer*)ptr->data) - me->fdata.layers;
if(render) return (n == CustomData_get_render_layer_index(&me->fdata, type));
else return (n == CustomData_get_active_layer_index(&me->fdata, type));
}
static void rna_CustomDataLayer_active_set(PointerRNA *ptr, int value, int type, int render)
{
Mesh *me= (Mesh*)ptr->id.data;
int n= ((CustomDataLayer*)ptr->data) - me->fdata.layers;
if(value == 0)
return;
if(render) CustomData_set_layer_render_index(&me->fdata, type, n);
else CustomData_set_layer_active_index(&me->fdata, type, n);
}
static int rna_uv_layer_check(CollectionPropertyIterator *iter, void *data)
{
CustomDataLayer *layer= (CustomDataLayer*)data;
return (layer->type != CD_MTFACE);
}
static void rna_Mesh_uv_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->data;
rna_iterator_array_begin(iter, (void*)me->fdata.layers, sizeof(CustomDataLayer), me->fdata.totlayer, rna_uv_layer_check);
}
static int rna_Mesh_uv_layers_length(PointerRNA *ptr)
{
return rna_CustomDataLayer_length(ptr, CD_MTFACE);
}
static float rna_MTFace_uv1_get(PointerRNA *ptr, int index)
{
MTFace *mtface= (MTFace*)ptr->data;
return mtface->uv[0][index];
}
static void rna_MTFace_uv1_set(PointerRNA *ptr, int index, float value)
{
MTFace *mtface= (MTFace*)ptr->data;
mtface->uv[0][index]= value;
}
static float rna_MTFace_uv2_get(PointerRNA *ptr, int index)
{
MTFace *mtface= (MTFace*)ptr->data;
return mtface->uv[1][index];
}
static void rna_MTFace_uv2_set(PointerRNA *ptr, int index, float value)
{
MTFace *mtface= (MTFace*)ptr->data;
mtface->uv[1][index]= value;
}
static float rna_MTFace_uv3_get(PointerRNA *ptr, int index)
{
MTFace *mtface= (MTFace*)ptr->data;
return mtface->uv[2][index];
}
static void rna_MTFace_uv3_set(PointerRNA *ptr, int index, float value)
{
MTFace *mtface= (MTFace*)ptr->data;
mtface->uv[2][index]= value;
}
static float rna_MTFace_uv4_get(PointerRNA *ptr, int index)
{
MTFace *mtface= (MTFace*)ptr->data;
return mtface->uv[3][index];
}
static void rna_MTFace_uv4_set(PointerRNA *ptr, int index, float value)
{
MTFace *mtface= (MTFace*)ptr->data;
mtface->uv[3][index]= value;
}
static void rna_MTFaceLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->id.data;
CustomDataLayer *layer= (CustomDataLayer*)ptr->data;
rna_iterator_array_begin(iter, layer->data, sizeof(MTFace), me->totface, NULL);
}
static int rna_MTFaceLayer_data_length(PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->id.data;
return me->totface;
}
static int rna_MTFaceLayer_active_render_get(PointerRNA *ptr)
{
return rna_CustomDataLayer_active_get(ptr, CD_MTFACE, 1);
}
static int rna_MTFaceLayer_active_get(PointerRNA *ptr)
{
return rna_CustomDataLayer_active_get(ptr, CD_MTFACE, 0);
}
static void rna_MTFaceLayer_active_render_set(PointerRNA *ptr, int value)
{
rna_CustomDataLayer_active_set(ptr, value, CD_MTFACE, 1);
}
static void rna_MTFaceLayer_active_set(PointerRNA *ptr, int value)
{
rna_CustomDataLayer_active_set(ptr, value, CD_MTFACE, 0);
}
static int rna_vcol_layer_check(CollectionPropertyIterator *iter, void *data)
{
CustomDataLayer *layer= (CustomDataLayer*)data;
return (layer->type != CD_MCOL);
}
static void rna_Mesh_vcol_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->data;
rna_iterator_array_begin(iter, (void*)me->fdata.layers, sizeof(CustomDataLayer), me->fdata.totlayer, rna_vcol_layer_check);
}
static int rna_Mesh_vcol_layers_length(PointerRNA *ptr)
{
return rna_CustomDataLayer_length(ptr, CD_MCOL);
}
static void rna_MColLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->id.data;
CustomDataLayer *layer= (CustomDataLayer*)ptr->data;
rna_iterator_array_begin(iter, layer->data, sizeof(MCol)*4, me->totface, NULL);
}
static int rna_MColLayer_data_length(PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->id.data;
return me->totface;
}
static int rna_MColLayer_active_render_get(PointerRNA *ptr)
{
return rna_CustomDataLayer_active_get(ptr, CD_MCOL, 1);
}
static int rna_MColLayer_active_get(PointerRNA *ptr)
{
return rna_CustomDataLayer_active_get(ptr, CD_MCOL, 0);
}
static void rna_MColLayer_active_render_set(PointerRNA *ptr, int value)
{
rna_CustomDataLayer_active_set(ptr, value, CD_MCOL, 1);
}
static void rna_MColLayer_active_set(PointerRNA *ptr, int value)
{
rna_CustomDataLayer_active_set(ptr, value, CD_MCOL, 0);
}
static void rna_MFloatPropertyLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->id.data;
CustomDataLayer *layer= (CustomDataLayer*)ptr->data;
rna_iterator_array_begin(iter, layer->data, sizeof(MFloatProperty), me->totface, NULL);
}
static int rna_MFloatPropertyLayer_data_length(PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->id.data;
return me->totface;
}
static int rna_float_layer_check(CollectionPropertyIterator *iter, void *data)
{
CustomDataLayer *layer= (CustomDataLayer*)data;
return (layer->type != CD_PROP_FLT);
}
static void rna_Mesh_float_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->data;
rna_iterator_array_begin(iter, (void*)me->fdata.layers, sizeof(CustomDataLayer), me->fdata.totlayer, rna_float_layer_check);
}
static int rna_Mesh_float_layers_length(PointerRNA *ptr)
{
return rna_CustomDataLayer_length(ptr, CD_PROP_FLT);
}
static int rna_int_layer_check(CollectionPropertyIterator *iter, void *data)
{
CustomDataLayer *layer= (CustomDataLayer*)data;
return (layer->type != CD_PROP_INT);
}
static void rna_MIntPropertyLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->id.data;
CustomDataLayer *layer= (CustomDataLayer*)ptr->data;
rna_iterator_array_begin(iter, layer->data, sizeof(MIntProperty), me->totface, NULL);
}
static int rna_MIntPropertyLayer_data_length(PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->id.data;
return me->totface;
}
static void rna_Mesh_int_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->data;
rna_iterator_array_begin(iter, (void*)me->fdata.layers, sizeof(CustomDataLayer), me->fdata.totlayer, rna_int_layer_check);
}
static int rna_Mesh_int_layers_length(PointerRNA *ptr)
{
return rna_CustomDataLayer_length(ptr, CD_PROP_INT);
}
static int rna_string_layer_check(CollectionPropertyIterator *iter, void *data)
{
CustomDataLayer *layer= (CustomDataLayer*)data;
return (layer->type != CD_PROP_STR);
}
static void rna_MStringPropertyLayer_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->id.data;
CustomDataLayer *layer= (CustomDataLayer*)ptr->data;
rna_iterator_array_begin(iter, layer->data, sizeof(MStringProperty), me->totface, NULL);
}
static int rna_MStringPropertyLayer_data_length(PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->id.data;
return me->totface;
}
static void rna_Mesh_string_layers_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
Mesh *me= (Mesh*)ptr->data;
rna_iterator_array_begin(iter, (void*)me->fdata.layers, sizeof(CustomDataLayer), me->fdata.totlayer, rna_string_layer_check);
}
static int rna_Mesh_string_layers_length(PointerRNA *ptr)
{
return rna_CustomDataLayer_length(ptr, CD_PROP_STR);
}
#else
void RNA_def_mesh(BlenderRNA *brna)
static void rna_def_mvert_group(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna= RNA_def_struct(brna, "MVertGroup", NULL, "Mesh Vertex Group");
RNA_def_struct_sdna(srna, "MDeformWeight");
/* XXX how to point to actual group? */
prop= RNA_def_property(srna, "group", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "def_nr");
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_ui_text(prop, "Group Index", "");
prop= RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Weight", "Vertex Weight");
}
static void rna_def_mvert(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna= RNA_def_struct(brna, "MVert", NULL, "Mesh Vertex");
prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_VECTOR);
RNA_def_property_ui_text(prop, "Location", "Vertex Location");
/*prop= RNA_def_property(srna, "no", PROP_FLOAT, PROP_VECTOR);
RNA_def_property_float_funcs(prop, "rna_MVert_no_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Normal", "Vertex Normal");
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);*/
prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT);
RNA_def_property_ui_text(prop, "Selected", "");
prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_HIDE);
RNA_def_property_ui_text(prop, "Hidden", "");
prop= RNA_def_property(srna, "bevel_weight", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_funcs(prop, "rna_MVert_bevel_weight_get", "rna_MVert_bevel_weight_set", NULL);
RNA_def_property_ui_text(prop, "Bevel Weight", "Weight used by the Bevel modifier 'Only Vertices' option");
prop= RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_funcs(prop, "rna_MVert_groups_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, 0, 0, 0);
RNA_def_property_struct_type(prop, "MVertGroup");
RNA_def_property_ui_text(prop, "Groups", "Weights for the vertex groups this vertex is member of");
}
static void rna_def_medge(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna= RNA_def_struct(brna, "MEdge", NULL, "Mesh Edge");
prop= RNA_def_property(srna, "verts", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "v1");
RNA_def_property_array(prop, 2);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_ui_text(prop, "Vertices", "Vertex indices");
prop= RNA_def_property(srna, "crease", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_funcs(prop, "rna_MEdge_crease_get", "rna_MEdge_crease_set", NULL);
RNA_def_property_ui_text(prop, "Crease", "Weight used by the Subsurf modifier for creasing");
prop= RNA_def_property(srna, "bevel_weight", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_funcs(prop, "rna_MEdge_bevel_weight_get", "rna_MEdge_bevel_weight_set", NULL);
RNA_def_property_ui_text(prop, "Bevel Weight", "Weight used by the Bevel modifier");
prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT);
RNA_def_property_ui_text(prop, "Selected", "");
prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_HIDE);
RNA_def_property_ui_text(prop, "Hidden", "");
prop= RNA_def_property(srna, "seam", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_SEAM);
RNA_def_property_ui_text(prop, "Seam", "Seam edge for UV unwrapping");
prop= RNA_def_property(srna, "sharp", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_SHARP);
RNA_def_property_ui_text(prop, "Sharp", "Sharp edge for the EdgeSplit modifier");
}
static void rna_def_mface(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna= RNA_def_struct(brna, "MFace", NULL, "Mesh Face");
prop= RNA_def_property(srna, "verts", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "v1");
RNA_def_property_array(prop, 4);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_ui_text(prop, "Vertices", "Vertex indices");
prop= RNA_def_property(srna, "mat_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_sdna(prop, NULL, "mat_nr");
RNA_def_property_ui_text(prop, "Material Index", "");
RNA_def_property_range(prop, 0, MAXMAT-1);
RNA_def_property_int_funcs(prop, NULL, NULL, "rna_MFace_mat_index_range");
prop= RNA_def_property(srna, "selected", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_FACE_SEL);
RNA_def_property_ui_text(prop, "Selected", "");
prop= RNA_def_property(srna, "hidden", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_HIDE);
RNA_def_property_ui_text(prop, "Hidden", "");
prop= RNA_def_property(srna, "smooth", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_SMOOTH);
RNA_def_property_ui_text(prop, "Smooth", "");
}
static void rna_def_mtface(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
static const EnumPropertyItem transp_items[]= {
{TF_SOLID, "OPAQUE", "Opaque", "Render color of textured face as color"},
{TF_ADD, "ADD", "Add", "Render face transparent and add color of face"},
{TF_ALPHA, "ALPHA", "Alpha", "Render polygon transparent, depending on alpha channel of the texture"},
{TF_CLIP, "CLIPALPHA", "Clip Alpha", "Use the images alpha values clipped with no blending (binary alpha)"},
{0, NULL, NULL, NULL}};
srna= RNA_def_struct(brna, "MTFace", NULL, "Mesh Texture Face");
/* prop= RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "tpage");
RNA_def_property_ui_text(prop, "Image", ""); */
prop= RNA_def_property(srna, "tex", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", TF_TEX);
RNA_def_property_ui_text(prop, "Tex", "Render face with texture");
prop= RNA_def_property(srna, "tiles", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", TF_TILES);
RNA_def_property_ui_text(prop, "Tiles", "Use tilemode for face");
prop= RNA_def_property(srna, "light", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", TF_LIGHT);
RNA_def_property_ui_text(prop, "Light", "Use light for face");
prop= RNA_def_property(srna, "invisible", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", TF_INVISIBLE);
RNA_def_property_ui_text(prop, "Invisible", "Make face invisible");
prop= RNA_def_property(srna, "collision", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", TF_DYNAMIC);
RNA_def_property_ui_text(prop, "Collision", "Use face for collision and ray-sensor detection");
prop= RNA_def_property(srna, "shared", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", TF_SHAREDCOL);
RNA_def_property_ui_text(prop, "Shared", "Blend vertex colors across face when vertices are shared");
prop= RNA_def_property(srna, "twoside", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", TF_TWOSIDE);
RNA_def_property_ui_text(prop, "Twoside", "Render face twosided");
prop= RNA_def_property(srna, "obcolor", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", TF_OBCOL);
RNA_def_property_ui_text(prop, "ObColor", "Use ObColor instead of vertex colors");
prop= RNA_def_property(srna, "halo", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", TF_BILLBOARD);
RNA_def_property_ui_text(prop, "Halo", "Screen aligned billboard");
prop= RNA_def_property(srna, "billboard", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", TF_BILLBOARD2);
RNA_def_property_ui_text(prop, "Billboard", "Billboard with Z-axis constraint");
prop= RNA_def_property(srna, "shadow", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", TF_SHADOW);
RNA_def_property_ui_text(prop, "Shadow", "Face is used for shadow");
prop= RNA_def_property(srna, "text", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", TF_BMFONT);
RNA_def_property_ui_text(prop, "Text", "Enable bitmap text on face");
prop= RNA_def_property(srna, "alphasort", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "mode", TF_ALPHASORT);
RNA_def_property_ui_text(prop, "Alpha Sort", "Enable sorting of faces for correct alpha drawing (slow, use Clip Alpha instead when possible)");
prop= RNA_def_property(srna, "transp", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, transp_items);
RNA_def_property_ui_text(prop, "Transparency", "Transparency blending mode");
prop= RNA_def_property(srna, "uv_selected", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", TF_SEL1);
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "UV Selected", "");
prop= RNA_def_property(srna, "uv_pinned", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "unwrap", TF_PIN1);
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "UV Pinned", "");
prop= RNA_def_property(srna, "uv1", PROP_FLOAT, PROP_VECTOR);
RNA_def_property_array(prop, 2);
RNA_def_property_float_funcs(prop, "rna_MTFace_uv1_get", "rna_MTFace_uv1_set", NULL);
RNA_def_property_ui_text(prop, "UV 1", "");
prop= RNA_def_property(srna, "uv2", PROP_FLOAT, PROP_VECTOR);
RNA_def_property_array(prop, 2);
RNA_def_property_float_funcs(prop, "rna_MTFace_uv2_get", "rna_MTFace_uv2_set", NULL);
RNA_def_property_ui_text(prop, "UV 2", "");
prop= RNA_def_property(srna, "uv3", PROP_FLOAT, PROP_VECTOR);
RNA_def_property_array(prop, 2);
RNA_def_property_float_funcs(prop, "rna_MTFace_uv3_get", "rna_MTFace_uv3_set", NULL);
RNA_def_property_ui_text(prop, "UV 3", "");
prop= RNA_def_property(srna, "uv4", PROP_FLOAT, PROP_VECTOR);
RNA_def_property_array(prop, 2);
RNA_def_property_float_funcs(prop, "rna_MTFace_uv4_get", "rna_MTFace_uv4_set", NULL);
RNA_def_property_ui_text(prop, "UV 4", "");
srna= RNA_def_struct(brna, "MTFaceLayer", NULL, "Mesh Texture Face Layer");
RNA_def_struct_sdna(srna, "CustomDataLayer");
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_struct_name_property(srna, prop);
RNA_def_property_ui_text(prop, "Name", "");
prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_MTFaceLayer_active_get", "rna_MTFaceLayer_active_set");
RNA_def_property_ui_text(prop, "Active", "Sets the layer as active for display and editing");
prop= RNA_def_property(srna, "active_render", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "active_rnd", 0);
RNA_def_property_boolean_funcs(prop, "rna_MTFaceLayer_active_render_get", "rna_MTFaceLayer_active_render_set");
RNA_def_property_ui_text(prop, "Active Render", "Sets the layer as active for rendering");
prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "MTFace");
RNA_def_property_ui_text(prop, "Data", "");
RNA_def_property_collection_funcs(prop, "rna_MTFaceLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, "rna_MTFaceLayer_data_length", 0, 0);
}
static void rna_def_msticky(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna= RNA_def_struct(brna, "MSticky", NULL, "Mesh Vertex Sticky Texture Coordinate");
prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_VECTOR);
RNA_def_property_ui_text(prop, "Location", "Sticky texture coordinate location");
}
static void rna_def_mcol(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna= RNA_def_struct(brna, "MCol", NULL, "Mesh Vertex Color");
prop= RNA_def_property(srna, "color1", PROP_FLOAT, PROP_COLOR);
RNA_def_property_array(prop, 3);
RNA_def_property_float_funcs(prop, "rna_MCol_color1_get", "rna_MCol_color1_set", NULL);
RNA_def_property_ui_text(prop, "Color 1", "");
prop= RNA_def_property(srna, "color2", PROP_FLOAT, PROP_COLOR);
RNA_def_property_array(prop, 3);
RNA_def_property_float_funcs(prop, "rna_MCol_color2_get", "rna_MCol_color2_set", NULL);
RNA_def_property_ui_text(prop, "Color 2", "");
prop= RNA_def_property(srna, "color3", PROP_FLOAT, PROP_COLOR);
RNA_def_property_array(prop, 3);
RNA_def_property_float_funcs(prop, "rna_MCol_color3_get", "rna_MCol_color3_set", NULL);
RNA_def_property_ui_text(prop, "Color 3", "");
prop= RNA_def_property(srna, "color4", PROP_FLOAT, PROP_COLOR);
RNA_def_property_array(prop, 3);
RNA_def_property_float_funcs(prop, "rna_MCol_color4_get", "rna_MCol_color4_set", NULL);
RNA_def_property_ui_text(prop, "Color 4", "");
srna= RNA_def_struct(brna, "MColLayer", NULL, "Mesh Texture Face Layer");
RNA_def_struct_sdna(srna, "CustomDataLayer");
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_struct_name_property(srna, prop);
RNA_def_property_ui_text(prop, "Name", "");
prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_MColLayer_active_get", "rna_MColLayer_active_set");
RNA_def_property_ui_text(prop, "Active", "Sets the layer as active for display and editing");
prop= RNA_def_property(srna, "active_render", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "active_rnd", 0);
RNA_def_property_boolean_funcs(prop, "rna_MColLayer_active_render_get", "rna_MColLayer_active_render_set");
RNA_def_property_ui_text(prop, "Active Render", "Sets the layer as active for rendering");
prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "MCol");
RNA_def_property_ui_text(prop, "Data", "");
RNA_def_property_collection_funcs(prop, "rna_MColLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, "rna_MColLayer_data_length", 0, 0);
}
static void rna_def_mproperties(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
/* Float */
srna= RNA_def_struct(brna, "MFloatProperty", NULL, "Mesh Float Property");
prop= RNA_def_property(srna, "value", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "f");
RNA_def_property_ui_text(prop, "Value", "");
srna= RNA_def_struct(brna, "MFloatPropertyLayer", NULL, "Mesh Float Property Layer");
RNA_def_struct_sdna(srna, "CustomDataLayer");
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_struct_name_property(srna, prop);
RNA_def_property_ui_text(prop, "Name", "");
prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "MFloatProperty");
RNA_def_property_ui_text(prop, "Data", "");
RNA_def_property_collection_funcs(prop, "rna_MFloatPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, "rna_MFloatPropertyLayer_data_length", 0, 0);
/* Int */
srna= RNA_def_struct(brna, "MIntProperty", NULL, "Mesh Int Property");
prop= RNA_def_property(srna, "value", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "i");
RNA_def_property_ui_text(prop, "Value", "");
srna= RNA_def_struct(brna, "MIntPropertyLayer", NULL, "Mesh Int Property Layer");
RNA_def_struct_sdna(srna, "CustomDataLayer");
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_struct_name_property(srna, prop);
RNA_def_property_ui_text(prop, "Name", "");
prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "MIntProperty");
RNA_def_property_ui_text(prop, "Data", "");
RNA_def_property_collection_funcs(prop, "rna_MIntPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, "rna_MIntPropertyLayer_data_length", 0, 0);
/* String */
srna= RNA_def_struct(brna, "MStringProperty", NULL, "Mesh String Property");
prop= RNA_def_property(srna, "value", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "s");
RNA_def_property_ui_text(prop, "Value", "");
srna= RNA_def_struct(brna, "MStringPropertyLayer", NULL, "Mesh String Property Layer");
RNA_def_struct_sdna(srna, "CustomDataLayer");
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
RNA_def_struct_name_property(srna, prop);
RNA_def_property_ui_text(prop, "Name", "");
prop= RNA_def_property(srna, "data", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "MStringProperty");
RNA_def_property_ui_text(prop, "Data", "");
RNA_def_property_collection_funcs(prop, "rna_MStringPropertyLayer_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", 0, "rna_MStringPropertyLayer_data_length", 0, 0);
}
static void rna_def_mmultires(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna= RNA_def_struct(brna, "MMultires", NULL, "Mesh Multires");
RNA_def_struct_sdna(srna, "Multires");
prop= RNA_def_property(srna, "level", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "newlvl");
RNA_def_property_int_funcs(prop, NULL, NULL, "rna_MMultires_level_range");
RNA_def_property_ui_text(prop, "Level", "");
prop= RNA_def_property(srna, "edge_level", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "edgelvl");
RNA_def_property_int_funcs(prop, NULL, NULL, "rna_MMultires_level_range");
RNA_def_property_ui_text(prop, "Edge Level", "");
prop= RNA_def_property(srna, "pin_level", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "pinlvl");
RNA_def_property_int_funcs(prop, NULL, NULL, "rna_MMultires_level_range");
RNA_def_property_ui_text(prop, "Pin Level", "Set level to apply modifiers to during render");
prop= RNA_def_property(srna, "render_level", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "renderlvl");
RNA_def_property_int_funcs(prop, NULL, NULL, "rna_MMultires_level_range");
RNA_def_property_ui_text(prop, "Render Level", "Set level to render");
}
static void rna_def_mesh(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
/* mesh */
srna= RNA_def_struct(brna, "Mesh", "ID", "Mesh");
prop= RNA_def_property(srna, "verts", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "mvert", "totvert");
RNA_def_property_struct_type(prop, "MVert");
RNA_def_property_ui_text(prop, "Vertices", "Vertices of the mesh.");
RNA_def_property_ui_text(prop, "Vertices", "Vertices of the mesh");
/* vertex */
srna= RNA_def_struct(brna, "MVert", NULL, "Mesh Vertex");
prop= RNA_def_property(srna, "edges", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "medge", "totedge");
RNA_def_property_struct_type(prop, "MEdge");
RNA_def_property_ui_text(prop, "Edges", "Edges of the mesh");
prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_VECTOR);
RNA_def_property_ui_text(prop, "Location", "Location of the vertex.");
prop= RNA_def_property(srna, "faces", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "mface", "totface");
RNA_def_property_struct_type(prop, "MFace");
RNA_def_property_ui_text(prop, "Faces", "Faces of the mesh");
prop= RNA_def_property(srna, "sticky", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "msticky", "totvert");
RNA_def_property_struct_type(prop, "MSticky");
RNA_def_property_ui_text(prop, "Sticky", "Sticky texture coordinates");
prop= RNA_def_property(srna, "uv_layers", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
RNA_def_property_collection_funcs(prop, "rna_Mesh_uv_layers_begin", 0, 0, 0, 0, "rna_Mesh_uv_layers_length", 0, 0);
RNA_def_property_struct_type(prop, "MTFaceLayer");
RNA_def_property_ui_text(prop, "UV Layers", "");
prop= RNA_def_property(srna, "vcol_layers", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
RNA_def_property_collection_funcs(prop, "rna_Mesh_vcol_layers_begin", 0, 0, 0, 0, "rna_Mesh_vcol_layers_length", 0, 0);
RNA_def_property_struct_type(prop, "MColLayer");
RNA_def_property_ui_text(prop, "Vertex Color Layers", "");
prop= RNA_def_property(srna, "float_layers", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
RNA_def_property_collection_funcs(prop, "rna_Mesh_float_layers_begin", 0, 0, 0, 0, "rna_Mesh_float_layers_length", 0, 0);
RNA_def_property_struct_type(prop, "MFloatPropertyLayer");
RNA_def_property_ui_text(prop, "Float Property Layers", "");
prop= RNA_def_property(srna, "int_layers", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
RNA_def_property_collection_funcs(prop, "rna_Mesh_int_layers_begin", 0, 0, 0, 0, "rna_Mesh_int_layers_length", 0, 0);
RNA_def_property_struct_type(prop, "MIntPropertyLayer");
RNA_def_property_ui_text(prop, "Int Property Layers", "");
prop= RNA_def_property(srna, "string_layers", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "fdata.layers", "fdata.totlayer");
RNA_def_property_collection_funcs(prop, "rna_Mesh_string_layers_begin", 0, 0, 0, 0, "rna_Mesh_string_layers_length", 0, 0);
RNA_def_property_struct_type(prop, "MStringPropertyLayer");
RNA_def_property_ui_text(prop, "String Property Layers", "");
prop= RNA_def_property(srna, "autosmooth", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_AUTOSMOOTH);
RNA_def_property_ui_text(prop, "Auto Smooth", "Treats all set-smoothed faces with angles less than the specified angle as 'smooth' during render");
prop= RNA_def_property(srna, "autosmooth_angle", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "smoothresh");
RNA_def_property_range(prop, 1, 80);
RNA_def_property_ui_text(prop, "Auto Smooth Angle", "Defines maximum angle between face normals that 'Auto Smooth' will operate on");
prop= RNA_def_property(srna, "novnormalflip", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_NOPUNOFLIP);
RNA_def_property_ui_text(prop, "No Vertex Normal Flip", "Disables flipping of vertexnormals during render");
prop= RNA_def_property(srna, "twosided", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_TWOSIDED);
RNA_def_property_ui_text(prop, "Double Sided", "Render/display the mesh with double or single sided lighting");
prop= RNA_def_property(srna, "autotexspace", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "texflag", AUTOSPACE);
RNA_def_property_ui_text(prop, "Auto Texture Space", "Adjusts active object's texture space automatically when transforming object");
prop= RNA_def_property(srna, "texspace_loc", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "loc");
RNA_def_property_ui_text(prop, "Texure Space Location", "Texture space location");
RNA_def_property_funcs(prop, NULL, "rna_Mesh_texspace_editable");
prop= RNA_def_property(srna, "texspace_size", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "size");
RNA_def_property_ui_text(prop, "Texture Space Size", "Texture space size");
RNA_def_property_funcs(prop, NULL, "rna_Mesh_texspace_editable");
/* not supported yet
prop= RNA_def_property(srna, "texspace_rot", PROP_FLOAT, PROP_NONE);
RNA_def_property_float(prop, NULL, "rot");
RNA_def_property_ui_text(prop, "Texture Space Rotation", "Texture space rotation");
RNA_def_property_funcs(prop, NULL, "rna_Mesh_texspace_editable");*/
prop= RNA_def_property(srna, "texco_mesh", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "texcomesh");
RNA_def_property_ui_text(prop, "Texture Space Mesh", "Derive texture coordinates from another mesh");
prop= RNA_def_property(srna, "multires", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "mr");
RNA_def_property_ui_text(prop, "Multires", "");
/*prop= RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
RNA_def_property_struct_type(prop, "Material");
RNA_def_property_ui_text(prop, "Materials", "");*/
/*prop= RNA_def_property(srna, "key", PROP_POINTER, PROP_NONE);
RNA_def_property_ui_text(prop, "Key", "");*/
}
void RNA_def_mesh(BlenderRNA *brna)
{
rna_def_mesh(brna);
rna_def_mvert(brna);
rna_def_mvert_group(brna);
rna_def_medge(brna);
rna_def_mface(brna);
rna_def_mtface(brna);
rna_def_msticky(brna);
rna_def_mcol(brna);
rna_def_mproperties(brna);
rna_def_mmultires(brna);
}
#endif

View File

@ -57,10 +57,9 @@ static void *rna_Struct_name_property_get(PointerRNA *ptr)
return ((StructRNA*)ptr->data)->nameproperty;
}
static int rna_idproperty_known(CollectionPropertyIterator *iter)
static int rna_idproperty_known(CollectionPropertyIterator *iter, void *data)
{
ListBaseIterator *internal= iter->internal;
IDProperty *idprop= (IDProperty*)internal->link;
IDProperty *idprop= (IDProperty*)data;
PropertyRNA *prop;
for(prop= iter->parent.type->properties.first; prop; prop=prop->next)
@ -70,6 +69,12 @@ static int rna_idproperty_known(CollectionPropertyIterator *iter)
return 0;
}
static int rna_property_builtin(CollectionPropertyIterator *iter, void *data)
{
PropertyRNA *prop= (PropertyRNA*)data;
return (prop->flag & PROP_BUILTIN);
}
static void rna_Struct_properties_next(CollectionPropertyIterator *iter)
{
ListBaseIterator *internal= iter->internal;
@ -77,15 +82,11 @@ static void rna_Struct_properties_next(CollectionPropertyIterator *iter)
if(internal->flag) {
/* id properties */
do {
rna_iterator_listbase_next(iter);
} while(iter->valid && rna_idproperty_known(iter));
rna_iterator_listbase_next(iter);
}
else {
/* regular properties */
do {
rna_iterator_listbase_next(iter);
} while(iter->valid && (((PropertyRNA*)internal->link)->flag & PROP_BUILTIN));
rna_iterator_listbase_next(iter);
/* try id properties */
if(!iter->valid) {
@ -93,12 +94,9 @@ static void rna_Struct_properties_next(CollectionPropertyIterator *iter)
if(group) {
rna_iterator_listbase_end(iter);
rna_iterator_listbase_begin(iter, &group->data.group);
rna_iterator_listbase_begin(iter, &group->data.group, rna_idproperty_known);
internal= iter->internal;
internal->flag= 1;
if(iter->valid && rna_idproperty_known(iter))
rna_Struct_properties_next(iter);
}
}
}
@ -106,13 +104,7 @@ static void rna_Struct_properties_next(CollectionPropertyIterator *iter)
static void rna_Struct_properties_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
{
ListBaseIterator *internal;
rna_iterator_listbase_begin(iter, &((StructRNA*)ptr->data)->properties);
internal= iter->internal;
if(iter->valid && (((PropertyRNA*)internal->link)->flag & PROP_BUILTIN))
rna_Struct_properties_next(iter);
rna_iterator_listbase_begin(iter, &((StructRNA*)ptr->data)->properties, rna_property_builtin);
}
static void *rna_Struct_properties_get(CollectionPropertyIterator *iter)
@ -334,7 +326,7 @@ static void rna_EnumProperty_items_begin(CollectionPropertyIterator *iter, Point
rna_idproperty_check(&prop, ptr);
eprop= (EnumPropertyRNA*)prop;
rna_iterator_array_begin(iter, (void*)eprop->item, sizeof(eprop->item[0]), eprop->totitem);
rna_iterator_array_begin(iter, (void*)eprop->item, sizeof(eprop->item[0]), eprop->totitem, NULL);
}
static void rna_EnumPropertyItem_identifier_get(PointerRNA *ptr, char *value)
@ -414,23 +406,23 @@ static void rna_def_property(BlenderRNA *brna)
StructRNA *srna;
PropertyRNA *prop;
static EnumPropertyItem type_items[] = {
{PROP_BOOLEAN, "BOOLEAN", "Boolean"},
{PROP_INT, "INT", "Integer"},
{PROP_FLOAT, "FLOAT", "Float"},
{PROP_STRING, "STRING", "String"},
{PROP_ENUM, "ENUM", "Enumeration"},
{PROP_POINTER, "POINTER", "Pointer"},
{PROP_COLLECTION, "COLLECTION", "Collection"},
{0, NULL, NULL}};
{PROP_BOOLEAN, "BOOLEAN", "Boolean", ""},
{PROP_INT, "INT", "Integer", ""},
{PROP_FLOAT, "FLOAT", "Float", ""},
{PROP_STRING, "STRING", "String", ""},
{PROP_ENUM, "ENUM", "Enumeration", ""},
{PROP_POINTER, "POINTER", "Pointer", ""},
{PROP_COLLECTION, "COLLECTION", "Collection", ""},
{0, NULL, NULL, NULL}};
static EnumPropertyItem subtype_items[] = {
{PROP_NONE, "NONE", "None"},
{PROP_UNSIGNED, "UNSIGNED", "Unsigned Number"},
{PROP_FILEPATH, "FILEPATH", "File Path"},
{PROP_COLOR, "COLOR", "Color"},
{PROP_VECTOR, "VECTOR", "Vector"},
{PROP_MATRIX, "MATRIX", "Matrix"},
{PROP_ROTATION, "ROTATION", "Rotation"},
{0, NULL, NULL}};
{PROP_NONE, "NONE", "None", ""},
{PROP_UNSIGNED, "UNSIGNED", "Unsigned Number", ""},
{PROP_FILEPATH, "FILEPATH", "File Path", ""},
{PROP_COLOR, "COLOR", "Color", ""},
{PROP_VECTOR, "VECTOR", "Vector", ""},
{PROP_MATRIX, "MATRIX", "Matrix", ""},
{PROP_ROTATION, "ROTATION", "Rotation", ""},
{0, NULL, NULL, NULL}};
srna= RNA_def_struct(brna, "Property", NULL, "Property Definition");
RNA_def_struct_funcs(srna, NULL, "rna_Property_refine");
@ -470,7 +462,7 @@ static void rna_def_number_property(StructRNA *srna, PropertyType type)
prop= RNA_def_property(srna, "array_length", PROP_INT, PROP_UNSIGNED);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_int_funcs(prop, "rna_Property_array_length_get", NULL);
RNA_def_property_int_funcs(prop, "rna_Property_array_length_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Array Length", "Maximum length of the array, 0 means unlimited.");
if(type == PROP_BOOLEAN)
@ -478,38 +470,38 @@ static void rna_def_number_property(StructRNA *srna, PropertyType type)
prop= RNA_def_property(srna, "hard_min", type, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
if(type == PROP_INT) RNA_def_property_int_funcs(prop, "rna_IntProperty_hard_min_get", NULL);
else RNA_def_property_float_funcs(prop, "rna_FloatProperty_hard_min_get", NULL);
if(type == PROP_INT) RNA_def_property_int_funcs(prop, "rna_IntProperty_hard_min_get", NULL, NULL);
else RNA_def_property_float_funcs(prop, "rna_FloatProperty_hard_min_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Hard Minimum", "Minimum value used by buttons.");
prop= RNA_def_property(srna, "hard_max", type, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
if(type == PROP_INT) RNA_def_property_int_funcs(prop, "rna_IntProperty_hard_max_get", NULL);
else RNA_def_property_float_funcs(prop, "rna_FloatProperty_hard_max_get", NULL);
if(type == PROP_INT) RNA_def_property_int_funcs(prop, "rna_IntProperty_hard_max_get", NULL, NULL);
else RNA_def_property_float_funcs(prop, "rna_FloatProperty_hard_max_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Hard Maximum", "Maximum value used by buttons.");
prop= RNA_def_property(srna, "soft_min", type, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
if(type == PROP_INT) RNA_def_property_int_funcs(prop, "rna_IntProperty_soft_min_get", NULL);
else RNA_def_property_float_funcs(prop, "rna_FloatProperty_soft_min_get", NULL);
if(type == PROP_INT) RNA_def_property_int_funcs(prop, "rna_IntProperty_soft_min_get", NULL, NULL);
else RNA_def_property_float_funcs(prop, "rna_FloatProperty_soft_min_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Soft Minimum", "Minimum value used by buttons.");
prop= RNA_def_property(srna, "soft_max", type, PROP_NONE);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
if(type == PROP_INT) RNA_def_property_int_funcs(prop, "rna_IntProperty_soft_max_get", NULL);
else RNA_def_property_float_funcs(prop, "rna_FloatProperty_soft_max_get", NULL);
if(type == PROP_INT) RNA_def_property_int_funcs(prop, "rna_IntProperty_soft_max_get", NULL, NULL);
else RNA_def_property_float_funcs(prop, "rna_FloatProperty_soft_max_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Soft Maximum", "Maximum value used by buttons.");
prop= RNA_def_property(srna, "step", type, PROP_UNSIGNED);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
if(type == PROP_INT) RNA_def_property_int_funcs(prop, "rna_IntProperty_step_get", NULL);
else RNA_def_property_float_funcs(prop, "rna_FloatProperty_step_get", NULL);
if(type == PROP_INT) RNA_def_property_int_funcs(prop, "rna_IntProperty_step_get", NULL, NULL);
else RNA_def_property_float_funcs(prop, "rna_FloatProperty_step_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Step", "Step size used by number buttons, for floats 1/100th of the step size.");
if(type == PROP_FLOAT) {
prop= RNA_def_property(srna, "precision", PROP_INT, PROP_UNSIGNED);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_int_funcs(prop, "rna_FloatProperty_precision_get", NULL);
RNA_def_property_int_funcs(prop, "rna_FloatProperty_precision_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Precision", "Number of digits after the dot used by buttons.");
}
}
@ -520,7 +512,7 @@ static void rna_def_string_property(StructRNA *srna)
prop= RNA_def_property(srna, "max_length", PROP_INT, PROP_UNSIGNED);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_int_funcs(prop, "rna_StringProperty_max_length_get", NULL);
RNA_def_property_int_funcs(prop, "rna_StringProperty_max_length_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Maximum Length", "Maximum length of the string, 0 means unlimited.");
}
@ -549,7 +541,7 @@ static void rna_def_enum_property(BlenderRNA *brna, StructRNA *srna)
prop= RNA_def_property(srna, "value", PROP_INT, PROP_UNSIGNED);
RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
RNA_def_property_int_funcs(prop, "rna_EnumPropertyItem_value_get", NULL);
RNA_def_property_int_funcs(prop, "rna_EnumPropertyItem_value_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Value", "Value of the item.");
}

View File

@ -61,8 +61,19 @@ void RNA_def_scene(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
static EnumPropertyItem prop_mode_items[] = {{PROP_SMOOTH, "SMOOTH", "Smooth"}, {PROP_SPHERE, "SPHERE", "Sphere"}, {PROP_ROOT, "ROOT", "Root"}, {PROP_SHARP, "SHARP", "Sharp"}, {PROP_LIN, "LINEAR", "Linear"}, {PROP_CONST, "CONSTANT", "Constant"}, {PROP_RANDOM, "RANDOM", "Random"}, {0, NULL, NULL}};
static EnumPropertyItem unwrapper_items[] = {{0, "CONFORMAL", "Conformal"}, {1, "ANGLEBASED", "Angle Based"}, {0, NULL, NULL}};
static EnumPropertyItem prop_mode_items[] ={
{PROP_SMOOTH, "SMOOTH", "Smooth", ""},
{PROP_SPHERE, "SPHERE", "Sphere", ""},
{PROP_ROOT, "ROOT", "Root", ""},
{PROP_SHARP, "SHARP", "Sharp", ""},
{PROP_LIN, "LINEAR", "Linear", ""},
{PROP_CONST, "CONSTANT", "Constant", ""},
{PROP_RANDOM, "RANDOM", "Random", ""},
{0, NULL, NULL, NULL}};
static EnumPropertyItem unwrapper_items[] = {
{0, "CONFORMAL", "Conformal", ""},
{1, "ANGLEBASED", "Angle Based", ""},
{0, NULL, NULL, NULL}};
srna= RNA_def_struct(brna, "Scene", "ID", "Scene");
@ -100,7 +111,7 @@ void RNA_def_scene(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Stamp Note", "User define note for the render stamping.");
prop= RNA_def_property(srna, "unwrapper", PROP_ENUM, PROP_NONE);
RNA_def_property_string_sdna(prop, NULL, "toolsettings->unwrapper");
RNA_def_property_enum_sdna(prop, NULL, "toolsettings->unwrapper");
RNA_def_property_enum_items(prop, unwrapper_items);
RNA_def_property_ui_text(prop, "Unwrapper", "Unwrap algorithm used by the Unwrap tool.");
}