RNA: multidimensional & dyanmic array changes
* Disable setting array length of dynamic array for now, this was not implemented correct, and it's not really needed now. * Allow all dimensions to be dynamic size, not just the first. * Change storage of multidimensional to be simpler. * Rename API functions to be more compact. * Fix some bugs in the implementation. * RenderLayer.rect and RenderPass.rect use a multidimensional dynamic array now.
This commit is contained in:
@@ -423,14 +423,11 @@ static int rna_CustomDataData_numverts(PointerRNA *ptr, int type)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rna_MeshTextureFace_uv_get_length(PointerRNA *ptr)
|
||||
static int rna_MeshTextureFace_uv_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
|
||||
{
|
||||
return rna_CustomDataData_numverts(ptr, CD_MTFACE) * 2;
|
||||
}
|
||||
|
||||
static int rna_MeshTextureFace_uv_set_length(PointerRNA *ptr, int length)
|
||||
{
|
||||
return length == rna_MeshTextureFace_uv_get_length(ptr);
|
||||
length[0]= rna_CustomDataData_numverts(ptr, CD_MTFACE);
|
||||
length[1]= 2;
|
||||
return length[0]*length[1];
|
||||
}
|
||||
|
||||
static void rna_MeshTextureFace_uv_get(PointerRNA *ptr, float *values)
|
||||
@@ -711,35 +708,22 @@ static void rna_TextureFace_image_set(PointerRNA *ptr, PointerRNA value)
|
||||
tf->tpage= (struct Image*)id;
|
||||
}
|
||||
|
||||
static int rna_MeshFace_verts_get_length(PointerRNA *ptr)
|
||||
static int rna_MeshFace_verts_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
|
||||
{
|
||||
MFace *face= (MFace*)ptr->data;
|
||||
if(face)
|
||||
return face->v4 ? 4 : 3;
|
||||
else
|
||||
return 4; // XXX rna_raw_access wants the length of a dummy face. this needs fixing. - Campbell
|
||||
}
|
||||
|
||||
static int rna_MeshFace_verts_set_length(PointerRNA *ptr, int length)
|
||||
{
|
||||
MFace *face= (MFace*)ptr->data;
|
||||
if (length == 3) {
|
||||
face->v4= 0;
|
||||
}
|
||||
else if(length == 4) {
|
||||
face->v4= 1;
|
||||
}
|
||||
if(face)
|
||||
length[0]= (face->v4)? 4: 3;
|
||||
else
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
length[0]= 4; // XXX rna_raw_access wants the length of a dummy face. this needs fixing. - Campbell
|
||||
|
||||
return length[0];
|
||||
}
|
||||
|
||||
static void rna_MeshFace_verts_get(PointerRNA *ptr, int *values)
|
||||
{
|
||||
MFace *face= (MFace*)ptr->data;
|
||||
int verts[4] = {face->v1, face->v2, face->v3, face->v4};
|
||||
memcpy(values, verts, (face->v4 ? 4 : 3) * sizeof(int));
|
||||
memcpy(values, &face->v1, (face->v4 ? 4 : 3) * sizeof(int));
|
||||
}
|
||||
|
||||
static void rna_MeshFace_verts_set(PointerRNA *ptr, const int *values)
|
||||
@@ -982,19 +966,11 @@ static void rna_def_mface(BlenderRNA *brna)
|
||||
RNA_def_struct_path_func(srna, "rna_MeshFace_path");
|
||||
RNA_def_struct_ui_icon(srna, ICON_FACESEL);
|
||||
|
||||
/*
|
||||
// XXX allows creating invalid meshes
|
||||
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_ui_text(prop, "Vertices", "Vertex indices");
|
||||
*/
|
||||
|
||||
// XXX allows creating invalid meshes
|
||||
prop= RNA_def_property(srna, "verts", PROP_INT, PROP_UNSIGNED);
|
||||
RNA_def_property_array(prop, 4);
|
||||
RNA_def_property_flag(prop, PROP_DYNAMIC);
|
||||
RNA_def_property_dynamic_array_funcs(prop, "rna_MeshFace_verts_get_length", "rna_MeshFace_verts_set_length");
|
||||
RNA_def_property_dynamic_array_funcs(prop, "rna_MeshFace_verts_get_length");
|
||||
RNA_def_property_int_funcs(prop, "rna_MeshFace_verts_get", "rna_MeshFace_verts_set", NULL);
|
||||
RNA_def_property_ui_text(prop, "Vertices", "Vertex indices");
|
||||
|
||||
@@ -1037,7 +1013,7 @@ static void rna_def_mtface(BlenderRNA *brna)
|
||||
{TF_ALPHA, "ALPHA", 0, "Alpha", "Render polygon transparent, depending on alpha channel of the texture"},
|
||||
{TF_CLIP, "CLIPALPHA", 0, "Clip Alpha", "Use the images alpha values clipped with no blending (binary alpha)"},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
unsigned short uv_dim[1]= {2};
|
||||
int uv_dim[]= {4, 2};
|
||||
|
||||
srna= RNA_def_struct(brna, "MeshTextureFaceLayer", NULL);
|
||||
RNA_def_struct_ui_text(srna, "Mesh Texture Face Layer", "Layer of texture faces in a Mesh datablock.");
|
||||
@@ -1183,9 +1159,9 @@ static void rna_def_mtface(BlenderRNA *brna)
|
||||
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
|
||||
|
||||
prop= RNA_def_property(srna, "uv", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_multidimensional_array(prop, 4 * 2, 2, uv_dim);
|
||||
RNA_def_property_multi_array(prop, 2, uv_dim);
|
||||
RNA_def_property_flag(prop, PROP_DYNAMIC);
|
||||
RNA_def_property_dynamic_array_funcs(prop, "rna_MeshTextureFace_uv_get_length", "rna_MeshTextureFace_uv_set_length");
|
||||
RNA_def_property_dynamic_array_funcs(prop, "rna_MeshTextureFace_uv_get_length");
|
||||
RNA_def_property_float_funcs(prop, "rna_MeshTextureFace_uv_get", "rna_MeshTextureFace_uv_set", NULL);
|
||||
RNA_def_property_ui_text(prop, "UV", "");
|
||||
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
|
||||
|
||||
Reference in New Issue
Block a user