Commit: 263814dbf6aa0523cf599f22ed10faeb8924b11c
Author: Nicholas Bishop
Date:   Tue Feb 10 12:36:55 2015 +0100
Branches: cycles-ptex-49
https://developer.blender.org/rB263814dbf6aa0523cf599f22ed10faeb8924b11c

Add very simple UI for setting initial Ptex resolution

===================================================================

M       release/scripts/startup/bl_ui/properties_data_mesh.py
M       source/blender/editors/mesh/mesh_data.c
M       source/blender/makesdna/DNA_scene_types.h
M       source/blender/makesrna/intern/rna_scene.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py 
b/release/scripts/startup/bl_ui/properties_data_mesh.py
index 6893259..2de15a8 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -196,6 +196,7 @@ class DATA_PT_ptex(MeshButtonsPanel, Panel):
     def draw(self, context):
         layout = self.layout
 
+        pts = context.tool_settings.ptex_tool_settings
         me = context.mesh
 
         row = layout.row()
@@ -207,6 +208,8 @@ class DATA_PT_ptex(MeshButtonsPanel, Panel):
         col.operator("mesh.ptex_add", icon='ZOOMIN', text="")
         col.operator("mesh.ptex_remove", icon='ZOOMOUT', text="")
 
+        layout.prop(pts, "resolution")
+
         layout.operator("mesh.ptex_res_change",
                         text='Halve Resolution').mode = 'HALVE'
         layout.operator("mesh.ptex_res_change",
diff --git a/source/blender/editors/mesh/mesh_data.c 
b/source/blender/editors/mesh/mesh_data.c
index 8fb8748..90dcff7 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -720,16 +720,20 @@ void MESH_OT_vertex_color_remove(wmOperatorType *ot)
 
 /*** ptex operator ***/
 
-static int mesh_ptex_add(Mesh *me, const char *name, const bool active_set)
+static int mesh_ptex_add(const PtexToolSettings *pts, Mesh *me,
+                                                const char *name, const bool 
active_set)
 {
        int layernum = 0;
 
        if (me->edit_btmesh) {
                /* TODO */
                assert(!me->edit_btmesh);
+               return -1;
        }
        else {
                MLoopPtex *layer_data;
+               const MPtexLogRes logres = {pts->u_logres, pts->u_logres};
+               int i;
 
                layernum = CustomData_number_of_layers(&me->ldata, 
CD_LOOP_PTEX);
 
@@ -740,9 +744,7 @@ static int mesh_ptex_add(Mesh *me, const char *name, const 
bool active_set)
 
                {
                        // TODO
-                       int i;
                        MPtexTexelInfo texel_info = {4, MPTEX_DATA_TYPE_UINT8};
-                       MPtexLogRes logres = {5, 5};
                        for (i = 0; i < me->totloop; i++) {
                                BKE_loop_ptex_init(&layer_data[i], texel_info, 
logres);
                        }
@@ -764,9 +766,11 @@ static int mesh_ptex_add(Mesh *me, const char *name, const 
bool active_set)
 static int mesh_ptex_add_exec(bContext *C, wmOperator *UNUSED(op))
 {
        Object *ob = ED_object_context(C);
+       Scene *scene = CTX_data_scene(C);
+       PtexToolSettings *pts = &scene->toolsettings->ptex_tool_settings;
        Mesh *me = ob->data;
 
-       if (mesh_ptex_add(me, NULL, true) == -1)
+       if (mesh_ptex_add(pts, me, NULL, true) == -1)
                return OPERATOR_CANCELLED;
 
        return OPERATOR_FINISHED;
diff --git a/source/blender/makesdna/DNA_scene_types.h 
b/source/blender/makesdna/DNA_scene_types.h
index 9ac5066..24d3dfb 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1066,6 +1066,13 @@ typedef struct MeshStatVis {
        float sharp_min, sharp_max;
 } MeshStatVis;
 
+typedef struct PtexToolSettings {
+       /* TODO(nicholasbishop): for now just expose one resolution
+        * setting and use for both U and V resolution */
+       int u_logres;
+
+       int pad;
+} PtexToolSettings;
 
 /* *************************************************************** */
 /* Tool Settings */
@@ -1184,6 +1191,8 @@ typedef struct ToolSettings {
        struct UnifiedPaintSettings unified_paint_settings;
 
        struct MeshStatVis statvis;
+
+       struct PtexToolSettings ptex_tool_settings;
 } ToolSettings;
 
 /* *************************************************************** */
diff --git a/source/blender/makesrna/intern/rna_scene.c 
b/source/blender/makesrna/intern/rna_scene.c
index 1c133db..cd1bb09 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2120,6 +2120,12 @@ static void rna_def_tool_settings(BlenderRNA  *brna)
        RNA_def_property_flag(prop, PROP_NEVER_NULL);
        RNA_def_property_struct_type(prop, "MeshStatVis");
        RNA_def_property_ui_text(prop, "Mesh Statistics Visualization", NULL);
+
+       /* Ptex */
+       prop = RNA_def_property(srna, "ptex_tool_settings", PROP_POINTER, 
PROP_NONE);
+       RNA_def_property_flag(prop, PROP_NEVER_NULL);
+       RNA_def_property_struct_type(prop, "PtexToolSettings");
+       RNA_def_property_ui_text(prop, "Ptex Tool Settings", NULL);
 }
 
 static void rna_def_unified_paint_settings(BlenderRNA  *brna)
@@ -2318,6 +2324,35 @@ static void rna_def_statvis(BlenderRNA  *brna)
        RNA_def_property_update(prop, 0, "rna_EditMesh_update");
 }
 
+static void rna_def_ptex_tool_settings(BlenderRNA  *brna)
+{
+       StructRNA *srna;
+       PropertyRNA *prop;
+
+       static EnumPropertyItem stat_type[] = {
+               {0, "LOGRES_0", 0, "1x1", ""},
+               {1, "LOGRES_1", 0, "2x2", ""},
+               {2, "LOGRES_2", 0, "4x4", ""},
+               {3, "LOGRES_3", 0, "8x8", ""},
+               {4, "LOGRES_4", 0, "16x16", ""},
+               {5, "LOGRES_5", 0, "32x32", ""},
+               {6, "LOGRES_6", 0, "64x64", ""},
+               {7, "LOGRES_7", 0, "128x128", ""},
+               {8, "LOGRES_8", 0, "256x256", ""},
+               {9, "LOGRES_9", 0, "512x512", ""},
+               {0, NULL, 0, NULL, NULL}};
+
+       srna = RNA_def_struct(brna, "PtexToolSettings", NULL);
+       RNA_def_struct_ui_text(srna, "Ptex Tool Settings", "");
+
+       prop = RNA_def_property(srna, "resolution", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_sdna(prop, NULL, "u_logres");
+       RNA_def_property_enum_items(prop, stat_type);
+       RNA_def_property_ui_text(prop, "Face Resolution",
+                                                        "Per-face resolution 
for new layers");
+       RNA_def_property_update(prop, 0, "rna_EditMesh_update");
+}
+
 static void rna_def_unit_settings(BlenderRNA  *brna)
 {
        StructRNA *srna;
@@ -5852,6 +5887,7 @@ void RNA_def_scene(BlenderRNA *brna)
        rna_def_tool_settings(brna);
        rna_def_unified_paint_settings(brna);
        rna_def_statvis(brna);
+       rna_def_ptex_tool_settings(brna);
        rna_def_unit_settings(brna);
        rna_def_scene_image_format_data(brna);
        rna_def_scene_game_data(brna);

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

Reply via email to