Revision: 44720
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44720
Author: campbellbarton
Date: 2012-03-07 21:58:58 +0000 (Wed, 07 Mar 2012)
Log Message:
-----------
edits to rna/tessface UV layer needed to get OBJ import/export functional.
add the function to create new UV layers, this only works when there are no
polygon layers already created (to prevent confusion since scripts with polygon
layers should be adding MTexPoly and MLoopUV layers)
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/intern/mesh.c
trunk/blender/source/blender/makesrna/intern/rna_mesh.c
Modified: trunk/blender/source/blender/blenkernel/intern/mesh.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/mesh.c 2012-03-07
20:56:25 UTC (rev 44719)
+++ trunk/blender/source/blender/blenkernel/intern/mesh.c 2012-03-07
21:58:58 UTC (rev 44720)
@@ -1904,6 +1904,12 @@
int numTex, numCol;
int i, j, totloop;
+ /* just incase some of these layers are filled in (can happen with
python created meshes) */
+ CustomData_free(&mesh->ldata, mesh->totloop);
+ CustomData_free(&mesh->pdata, mesh->totpoly);
+ memset(&mesh->ldata, 0, sizeof(mesh->ldata));
+ memset(&mesh->pdata, 0, sizeof(mesh->pdata));
+
mesh->totpoly = mesh->totface;
mesh->mpoly = MEM_callocN(sizeof(MPoly)*mesh->totpoly, "mpoly
converted");
CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_ASSIGN, mesh->mpoly,
mesh->totpoly);
Modified: trunk/blender/source/blender/makesrna/intern/rna_mesh.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_mesh.c 2012-03-07
20:56:25 UTC (rev 44719)
+++ trunk/blender/source/blender/makesrna/intern/rna_mesh.c 2012-03-07
21:58:58 UTC (rev 44720)
@@ -61,6 +61,7 @@
#include "BKE_main.h"
#include "BKE_mesh.h"
#include "BKE_tessmesh.h"
+#include "BKE_report.h"
#include "ED_mesh.h" /* XXX Bad level call */
@@ -833,7 +834,7 @@
return CustomData_number_of_layers(rna_mesh_pdata(ptr), CD_PROP_STR);
}
-static void rna_TextureFace_image_set(PointerRNA *ptr, PointerRNA value)
+static void rna_TexturePoly_image_set(PointerRNA *ptr, PointerRNA value)
{
MTexPoly *tf = (MTexPoly*)ptr->data;
ID *id = value.data;
@@ -847,9 +848,28 @@
id_lib_extern(id);
}
- tf->tpage = (struct Image*)id;
+ tf->tpage = (struct Image *)id;
}
+/* while this is supposed to be readonly,
+ * keep it to support importers that only make tessfaces */
+static void rna_TextureFace_image_set(PointerRNA *ptr, PointerRNA value)
+{
+ MTFace *tf = (MTFace*)ptr->data;
+ ID *id = value.data;
+
+ if (id) {
+ /* special exception here, individual faces don't count
+ * as reference, but we do ensure the refcount is not zero */
+ if(id->us == 0)
+ id_us_plus(id);
+ else
+ id_lib_extern(id);
+ }
+
+ tf->tpage = (struct Image *)id;
+}
+
static void rna_Mesh_auto_smooth_angle_set(PointerRNA *ptr, float value)
{
Mesh *me = rna_mesh(ptr);
@@ -1219,6 +1239,38 @@
return ptr;
}
+/* while this is supposed to be readonly,
+ * keep it to support importers that only make tessfaces */
+
+static PointerRNA rna_Mesh_uv_tessface_texture_new(struct Mesh *me, struct
bContext *C, ReportList *reports,
+ const char *name)
+{
+ PointerRNA ptr;
+ CustomData *fdata;
+ CustomDataLayer *cdl= NULL;
+ int index;
+
+ if (me->edit_btmesh) {
+ BKE_report(reports, RPT_ERROR, "Can't add tessface uv's in
editmode");
+ return PointerRNA_NULL;
+ }
+
+ if (me->mpoly) {
+ BKE_report(reports, RPT_ERROR, "Can't add tessface uv's when
MPoly's exist");
+ return PointerRNA_NULL;
+ }
+
+ index = ED_mesh_uv_texture_add(C, me, name, FALSE);
+
+ if(index != -1) {
+ fdata= rna_mesh_fdata_helper(me);
+ cdl= &fdata->layers[CustomData_get_layer_index_n(fdata,
CD_MTFACE, index)];
+ }
+
+ RNA_pointer_create(&me->id, &RNA_MeshTextureFaceLayer, cdl, &ptr);
+ return ptr;
+}
+
#else
static void rna_def_mvert_group(BlenderRNA *brna)
@@ -1605,6 +1657,7 @@
prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "tpage");
RNA_def_property_pointer_funcs(prop, NULL, "rna_TextureFace_image_set",
NULL, NULL);
+ RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Image", "");
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
@@ -1712,7 +1765,7 @@
prop = RNA_def_property(srna, "image", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "tpage");
- RNA_def_property_pointer_funcs(prop, NULL, "rna_TextureFace_image_set",
NULL, NULL);
+ RNA_def_property_pointer_funcs(prop, NULL, "rna_TexturePoly_image_set",
NULL, NULL);
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Image", "");
RNA_def_property_update(prop, 0, "rna_Mesh_update_data");
@@ -2304,14 +2357,24 @@
StructRNA *srna;
PropertyRNA *prop;
- /* FunctionRNA *func; */
- /* PropertyRNA *parm; */
+ FunctionRNA *func;
+ PropertyRNA *parm;
RNA_def_property_srna(cprop, "TessfaceUVTextures");
srna = RNA_def_struct(brna, "TessfaceUVTextures", NULL);
RNA_def_struct_sdna(srna, "Mesh");
RNA_def_struct_ui_text(srna, "UV Maps", "Collection of UV maps for
tessellated faces");
+ /* eventually deprecate this */
+ func= RNA_def_function(srna, "new", "rna_Mesh_uv_tessface_texture_new");
+ RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
+ RNA_def_function_ui_description(func, "Add a UV tessface-texture layer
to Mesh (only for meshes with no polygons)");
+ RNA_def_string(func, "name", "UVMap", 0, "", "UV map name");
+ parm= RNA_def_pointer(func, "layer", "MeshTextureFaceLayer", "", "The
newly created layer");
+ RNA_def_property_flag(parm, PROP_RNAPTR);
+ RNA_def_function_return(func, parm);
+
+
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_UNSIGNED);
RNA_def_property_struct_type(prop, "MeshTextureFaceLayer");
RNA_def_property_pointer_funcs(prop,
"rna_Mesh_tessface_uv_texture_active_get",
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs