diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_mesh.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh.c | 85 |
1 files changed, 58 insertions, 27 deletions
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index db5a2062359..6760000c702 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -46,7 +46,7 @@ #include "BKE_depsgraph.h" #include "BKE_main.h" #include "BKE_mesh.h" -#include "BKE_utildefines.h" + #include "ED_mesh.h" /* XXX Bad level call */ @@ -59,7 +59,7 @@ static void rna_Mesh_update_data(Main *bmain, Scene *scene, PointerRNA *ptr) /* cheating way for importers to avoid slow updates */ if(id->us > 0) { - DAG_id_flush_update(id, OB_RECALC_DATA); + DAG_id_tag_update(id, 0); WM_main_add_notifier(NC_GEOM|ND_DATA, id); } } @@ -229,6 +229,15 @@ static void rna_MeshColor_color4_set(PointerRNA *ptr, const float *values) (&mcol[3].r)[0]= (char)(CLAMPIS(values[2]*255.0f, 0, 255)); } +static void rna_Mesh_texspace_set(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + Mesh *me= (Mesh*)ptr->data; + + if (me->texflag & AUTOSPACE) + tex_space_mesh(me); +} + + static int rna_Mesh_texspace_editable(PointerRNA *ptr) { Mesh *me= (Mesh*)ptr->data; @@ -952,27 +961,46 @@ static char *rna_VertexGroupElement_path(PointerRNA *ptr) MDeformVert *dvert; int a, b; - for(a=0, dvert=me->dvert; a<me->totvert; a++, dvert++) - for(b=0; b<dvert->totweight; b++) + /* sanity check: make sure that mesh pointer is valid */ + if (me == NULL) + return NULL; + else if (GS(me->id.name) != ID_ME) { + /* if object pointer, try to resolve the object's data to mesh pointer */ + if (GS(me->id.name) == ID_OB) { + Object *ob = (Object *)me; + + if (ob->type == OB_MESH) + me = (Mesh *)ob->data; + else + return NULL; /* nothing can be done */ + } + else + return NULL; /* nothing can be done */ + } + + for(a=0, dvert=me->dvert; a<me->totvert; a++, dvert++) { + for(b=0; b<dvert->totweight; b++) { if(dw == &dvert->dw[b]) - return BLI_sprintfN("verts[%d].groups[%d]", a, b); + return BLI_sprintfN("vertices[%d].groups[%d]", a, b); + } + } return NULL; } static char *rna_MeshFace_path(PointerRNA *ptr) { - return BLI_sprintfN("faces[%d]", (MFace*)ptr->data - ((Mesh*)ptr->id.data)->mface); + return BLI_sprintfN("faces[%d]", (int)((MFace*)ptr->data - ((Mesh*)ptr->id.data)->mface)); } static char *rna_MeshEdge_path(PointerRNA *ptr) { - return BLI_sprintfN("edges[%d]", (MEdge*)ptr->data - ((Mesh*)ptr->id.data)->medge); + return BLI_sprintfN("edges[%d]", (int)((MEdge*)ptr->data - ((Mesh*)ptr->id.data)->medge)); } static char *rna_MeshVertex_path(PointerRNA *ptr) { - return BLI_sprintfN("verts[%d]", (MVert*)ptr->data - ((Mesh*)ptr->id.data)->mvert); + return BLI_sprintfN("vertices[%d]", (int)((MVert*)ptr->data - ((Mesh*)ptr->id.data)->mvert)); } static char *rna_MeshTextureFaceLayer_path(PointerRNA *ptr) @@ -1015,7 +1043,7 @@ static char *rna_MeshColor_path(PointerRNA *ptr) static char *rna_MeshSticky_path(PointerRNA *ptr) { - return BLI_sprintfN("sticky[%d]", (MSticky*)ptr->data - ((Mesh*)ptr->id.data)->msticky); + return BLI_sprintfN("sticky[%d]", (int)((MSticky*)ptr->data - ((Mesh*)ptr->id.data)->msticky)); } static char *rna_MeshIntPropertyLayer_path(PointerRNA *ptr) @@ -1064,7 +1092,7 @@ static int rna_Mesh_tot_face_get(PointerRNA *ptr) return me->edit_mesh ? me->edit_mesh->totfacesel : 0; } -static CustomDataLayer *rna_Mesh_vertex_color_new(struct Mesh *me, struct bContext *C, char *name) +static CustomDataLayer *rna_Mesh_vertex_color_new(struct Mesh *me, struct bContext *C, const char *name) { CustomData *fdata; CustomDataLayer *cdl= NULL; @@ -1078,13 +1106,13 @@ static CustomDataLayer *rna_Mesh_vertex_color_new(struct Mesh *me, struct bConte return cdl; } -static CustomDataLayer *rna_Mesh_uv_texture_new(struct Mesh *me, struct bContext *C, char *name) +static CustomDataLayer *rna_Mesh_uv_texture_new(struct Mesh *me, struct bContext *C, const char *name) { CustomData *fdata; CustomDataLayer *cdl= NULL; int index; - if(ED_mesh_uv_texture_add(C, NULL, NULL, me, name, FALSE)) { + if(ED_mesh_uv_texture_add(C, me, name, FALSE)) { fdata= rna_mesh_fdata(me); index= CustomData_get_named_layer_index(fdata, CD_MTFACE, name); cdl= (index == -1)? NULL: &fdata->layers[index]; @@ -1135,7 +1163,9 @@ static void rna_def_mvert(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Mesh_update_data"); prop= RNA_def_property(srna, "normal", PROP_FLOAT, PROP_DIRECTION); - RNA_def_property_float_sdna(prop, NULL, "no"); + // RNA_def_property_float_sdna(prop, NULL, "no"); + RNA_def_property_array(prop, 3); + RNA_def_property_range(prop, -1.0f, 1.0f); RNA_def_property_float_funcs(prop, "rna_MeshVertex_normal_get", "rna_MeshVertex_normal_set", NULL); RNA_def_property_ui_text(prop, "Normal", "Vertex Normal"); @@ -1300,7 +1330,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}}; - int uv_dim[]= {4, 2}; + const 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"); @@ -1639,7 +1669,7 @@ static void rna_def_mesh_vertices(BlenderRNA *brna, PropertyRNA *cprop) // PropertyRNA *prop; FunctionRNA *func; - PropertyRNA *parm; +// PropertyRNA *parm; RNA_def_property_srna(cprop, "MeshVertices"); srna= RNA_def_struct(brna, "MeshVertices", NULL); @@ -1648,7 +1678,7 @@ static void rna_def_mesh_vertices(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "add", "ED_mesh_vertices_add"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - parm= RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices to add.", 0, INT_MAX); + RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices to add.", 0, INT_MAX); } /* mesh.edges */ @@ -1658,7 +1688,7 @@ static void rna_def_mesh_edges(BlenderRNA *brna, PropertyRNA *cprop) // PropertyRNA *prop; FunctionRNA *func; - PropertyRNA *parm; +// PropertyRNA *parm; RNA_def_property_srna(cprop, "MeshEdges"); srna= RNA_def_struct(brna, "MeshEdges", NULL); @@ -1667,7 +1697,7 @@ static void rna_def_mesh_edges(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "add", "ED_mesh_edges_add"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - parm= RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices to add.", 0, INT_MAX); + RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices to add.", 0, INT_MAX); } /* mesh.faces */ @@ -1677,7 +1707,7 @@ static void rna_def_mesh_faces(BlenderRNA *brna, PropertyRNA *cprop) PropertyRNA *prop; FunctionRNA *func; - PropertyRNA *parm; + /*PropertyRNA *parm;*/ RNA_def_property_srna(cprop, "MeshFaces"); srna= RNA_def_struct(brna, "MeshFaces", NULL); @@ -1696,7 +1726,7 @@ static void rna_def_mesh_faces(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "add", "ED_mesh_faces_add"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - parm= RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices to add.", 0, INT_MAX); + RNA_def_int(func, "count", 0, 0, INT_MAX, "Count", "Number of vertices to add.", 0, INT_MAX); } /* mesh.vertex_colors */ @@ -1716,7 +1746,7 @@ static void rna_def_vertex_colors(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "new", "rna_Mesh_vertex_color_new"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Add a vertex color layer to Mesh."); - parm= RNA_def_string(func, "name", "UVTex", 0, "", "UV Texture name."); + RNA_def_string(func, "name", "Col", 0, "", "Vertex color name."); parm= RNA_def_pointer(func, "layer", "MeshColorLayer", "", "The newly created layer."); RNA_def_function_return(func, parm); @@ -1757,7 +1787,7 @@ static void rna_def_uv_textures(BlenderRNA *brna, PropertyRNA *cprop) func= RNA_def_function(srna, "new", "rna_Mesh_uv_texture_new"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); RNA_def_function_ui_description(func, "Add a UV texture layer to Mesh."); - parm= RNA_def_string(func, "name", "UVTex", 0, "", "UV Texture name."); + RNA_def_string(func, "name", "UVTex", 0, "", "UV Texture name."); parm= RNA_def_pointer(func, "layer", "MeshTextureFaceLayer", "", "The newly created layer."); RNA_def_function_return(func, parm); @@ -1901,6 +1931,7 @@ static void rna_def_mesh(BlenderRNA *brna) prop= RNA_def_property(srna, "use_auto_texspace", 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"); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Mesh_texspace_set"); prop= RNA_def_property(srna, "texspace_location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_array(prop, 3); @@ -1978,17 +2009,17 @@ static void rna_def_mesh(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); prop= RNA_def_property(srna, "show_extra_edge_length", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_EDGELEN); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWEXTRA_EDGELEN); RNA_def_property_ui_text(prop, "Edge Length", "Displays selected edge lengths, Using global values when set in the transform panel"); RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); - prop= RNA_def_property(srna, "show_extra_edge_angle", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_EDGEANG); - RNA_def_property_ui_text(prop, "Edge Angles", "Displays the angles in the selected edges in degrees, Using global values when set in the transform panel"); + prop= RNA_def_property(srna, "show_extra_face_angle", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWEXTRA_FACEANG); + RNA_def_property_ui_text(prop, "Faces Angles", "Displays the angles in the selected edges in degrees, Using global values when set in the transform panel"); RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); prop= RNA_def_property(srna, "show_extra_face_area", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_FACEAREA); + RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAWEXTRA_FACEAREA); RNA_def_property_ui_text(prop, "Face Area", "Displays the area of selected faces, Using global values when set in the transform panel"); RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); |