[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31297] branches/soc-2010-nicolasbishop: = = Ptex ==
Nicholas Bishop
nicholasbishop at gmail.com
Thu Aug 12 19:37:36 CEST 2010
Revision: 31297
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31297
Author: nicholasbishop
Date: 2010-08-12 19:37:36 +0200 (Thu, 12 Aug 2010)
Log Message:
-----------
== Ptex ==
Controls for setting local ptex resolution
* Fixed various problems preventing the old paint mask mode from showing correctly, repurposed it for editing ptex resolution
* Added an operator that resizes a ptex face (uses bilinear interpolation)
* Added a new ptex panel that only shows in paint mask mode
** Two buttons, Half and Double, that cut the U/V resolutions in half or double them, for all selected faces
** For more precise control, the U and V resolutions can be individually selected for a single face
** For triangles, the resolution of individual subfaces can be set
** Lastly, the resolution of the active face is shown (one resolution for each subface)
** The UI is not good, but the underlying code is there at least.
Modified Paths:
--------------
branches/soc-2010-nicolasbishop/release/scripts/ui/space_view3d_toolbar.py
branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/cdderivedmesh.c
branches/soc-2010-nicolasbishop/source/blender/blenloader/intern/readfile.c
branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_intern.h
branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_ops.c
branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c
branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/ptex.c
branches/soc-2010-nicolasbishop/source/blender/makesdna/DNA_scene_types.h
branches/soc-2010-nicolasbishop/source/blender/makesrna/intern/rna_mesh.c
branches/soc-2010-nicolasbishop/source/blender/makesrna/intern/rna_scene.c
Modified: branches/soc-2010-nicolasbishop/release/scripts/ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2010-nicolasbishop/release/scripts/ui/space_view3d_toolbar.py 2010-08-12 17:13:47 UTC (rev 31296)
+++ branches/soc-2010-nicolasbishop/release/scripts/ui/space_view3d_toolbar.py 2010-08-12 17:37:36 UTC (rev 31297)
@@ -478,7 +478,7 @@
if context.sculpt_object:
return ts.sculpt
- elif context.vertex_paint_object:
+ elif context.vertex_paint_object and (not context.vertex_paint_object.data.use_paint_mask):
return ts.vertex_paint
elif context.weight_paint_object:
return ts.weight_paint
@@ -496,7 +496,7 @@
@classmethod
def poll(cls, context):
- return context.sculpt_object or context.vertex_paint_object
+ return cls.paint_settings(context) and (context.sculpt_object or context.vertex_paint_object)
def draw(self, context):
layout = self.layout
@@ -997,7 +997,7 @@
def draw(self, context):
layout = self.layout
- settings = cls.paint_settings(context)
+ settings = self.paint_settings(context)
brush = settings.brush
layout.template_curve_mapping(brush, "curve", brush=True)
@@ -1054,7 +1054,7 @@
@classmethod
def poll(cls, context):
- return (context.sculpt_object or context.vertex_paint_object)
+ return cls.paint_settings(context) and (context.sculpt_object or context.vertex_paint_object)
def draw(self, context):
@@ -1093,7 +1093,7 @@
@classmethod
def poll(cls, context):
- return (context.sculpt_object and context.tool_settings.sculpt) or (context.vertex_paint_object and context.tool_settings.vertex_paint) or (context.weight_paint_object and context.tool_settings.weight_paint) or (context.texture_paint_object and context.tool_settings.image_paint)
+ return cls.paint_settings(context) and ((context.sculpt_object and context.tool_settings.sculpt) or (context.vertex_paint_object and context.tool_settings.vertex_paint) or (context.weight_paint_object and context.tool_settings.weight_paint) or (context.texture_paint_object and context.tool_settings.image_paint))
def draw(self, context):
layout = self.layout
@@ -1178,10 +1178,14 @@
# ********** default tools for vertexpaint ****************
-class VIEW3D_PT_tools_vertexpaint(View3DPanel, bpy.types.Panel):
- bl_context = "vertexpaint"
+class VIEW3D_PT_tools_vertexpaint(PaintPanel, bpy.types.Panel):
bl_label = "Options"
+ @classmethod
+ def poll(cls, context):
+ settings = cls.paint_settings(context)
+ return settings and context.vertex_paint_object
+
def draw(self, context):
layout = self.layout
@@ -1394,8 +1398,7 @@
@classmethod
def poll(cls, context):
settings = cls.paint_settings(context)
- #return context.vertex_paint_object or context.texture_paint_object
- return context.vertex_paint_object
+ return settings and context.vertex_paint_object
def draw(self, context):
layout = self.layout
@@ -1407,6 +1410,60 @@
layout.prop(overlay, "transparency_color")
layout.prop(overlay, "transparency_tolerance")
+class VIEW3D_PT_ptex_edit(View3DPanel, bpy.types.Panel):
+ bl_label = "Ptex"
+ bl_default_closed = False
+
+ @classmethod
+ def poll(cls, context):
+ ob = context.vertex_paint_object
+ return ob and ob.data.use_paint_mask
+
+ def draw(self, context):
+ layout = self.layout
+
+ mesh = context.active_object.data
+ active_ptex = mesh.active_ptex_index
+ active_face = mesh.faces.active
+
+ if active_ptex != -1 and active_face != -1:
+ ptex_layer = mesh.ptex_layers[active_ptex]
+ ptex = ptex_layer.data[active_face]
+ ts = context.tool_settings
+
+ layout.operator("ptex.face_resolution_set", text="Double Selected").operation = 'DOUBLE'
+ layout.operator("ptex.face_resolution_set", text="Half Selected").operation = 'HALF'
+
+ layout.separator()
+
+ prop = layout.operator("ptex.face_resolution_set")
+ prop.operation = 'NUMERIC'
+ prop.only_active = True
+ if ptex.subfaces != 1:
+ layout.prop(ts, "ptex_subface")
+ layout.prop(ts, "ptex_u_resolution", text="U")
+ layout.prop(ts, "ptex_v_resolution", text="V")
+
+ # display active face's resolution
+
+ box = layout.box()
+
+ if ptex.subfaces == 1:
+ box.label("Quad Resolution:")
+ else:
+ box.label("Subface Resolution:")
+
+ def reslbl(prefix, res):
+ box.label(text=prefix + str(res[0]) + " x " + str(res[1]))
+
+ if ptex.subfaces == 1:
+ reslbl("", ptex.resolution1)
+ else:
+ reslbl("1: ", ptex.resolution1)
+ reslbl("2: ", ptex.resolution2)
+ reslbl("3: ", ptex.resolution3)
+
+
def register():
pass
Modified: branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/cdderivedmesh.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/cdderivedmesh.c 2010-08-12 17:13:47 UTC (rev 31296)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/cdderivedmesh.c 2010-08-12 17:37:36 UTC (rev 31297)
@@ -192,8 +192,9 @@
Mesh *me= (ob)? ob->data: NULL;
if(ob->paint->sculpt && ob->paint->sculpt->modifiers_active) return 0;
+ if(paint_facesel_test(ob)) return 0;
- return (cddm->mvert == me->mvert) || ob->paint->sculpt->kb;
+ return (cddm->mvert == me->mvert) || (ob->paint->sculpt && ob->paint->sculpt->kb);
}
static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm)
Modified: branches/soc-2010-nicolasbishop/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenloader/intern/readfile.c 2010-08-12 17:13:47 UTC (rev 31296)
+++ branches/soc-2010-nicolasbishop/source/blender/blenloader/intern/readfile.c 2010-08-12 17:37:36 UTC (rev 31297)
@@ -4180,6 +4180,8 @@
if(ts->paint_overlay.img)
ts->paint_overlay.img = newlibadr_us(fd, sce->id.lib, ts->paint_overlay.img);
ts->paint_overlay.gltex = 0;
+ if(!ts->ptex_ures) ts->ptex_ures = 128;
+ if(!ts->ptex_vres) ts->ptex_vres = 128;
}
sce->toolsettings->skgen_template = newlibadr(fd, sce->id.lib, sce->toolsettings->skgen_template);
Modified: branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_intern.h 2010-08-12 17:13:47 UTC (rev 31296)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_intern.h 2010-08-12 17:37:36 UTC (rev 31297)
@@ -247,6 +247,7 @@
/* ptex.c */
void PTEX_OT_layer_add(struct wmOperatorType *ot);
void PTEX_OT_open(struct wmOperatorType *ot);
+void PTEX_OT_face_resolution_set(struct wmOperatorType *ot);
/* paint_overlay.c */
int paint_sample_overlay(PaintStroke *stroke, float col[3], float co[2]);
Modified: branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_ops.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_ops.c 2010-08-12 17:13:47 UTC (rev 31296)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_ops.c 2010-08-12 17:37:36 UTC (rev 31297)
@@ -221,6 +221,7 @@
/* ptex */
WM_operatortype_append(PTEX_OT_layer_add);
WM_operatortype_append(PTEX_OT_open);
+ WM_operatortype_append(PTEX_OT_face_resolution_set);
/* face-select */
WM_operatortype_append(PAINT_OT_face_select_linked);
Modified: branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c 2010-08-12 17:13:47 UTC (rev 31296)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c 2010-08-12 17:37:36 UTC (rev 31297)
@@ -98,8 +98,10 @@
{
if(vertex_paint_mode_poll(C) &&
paint_brush(&CTX_data_tool_settings(C)->vpaint->paint)) {
+ Object *ob = CTX_data_active_object(C);
ScrArea *sa= CTX_wm_area(C);
- if(sa->spacetype==SPACE_VIEW3D) {
+ if(!(get_mesh(ob)->editflag & ME_EDIT_PAINT_MASK) &&
+ sa->spacetype==SPACE_VIEW3D) {
ARegion *ar= CTX_wm_region(C);
if(ar->regiontype==RGN_TYPE_WINDOW)
return 1;
Modified: branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/ptex.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/ptex.c 2010-08-12 17:13:47 UTC (rev 31296)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/ptex.c 2010-08-12 17:37:36 UTC (rev 31297)
@@ -3,6 +3,7 @@
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
+#include "DNA_scene_types.h"
#include "DNA_space_types.h"
#include "RNA_access.h"
@@ -11,6 +12,7 @@
#include "BKE_context.h"
#include "BKE_customdata.h"
#include "BKE_DerivedMesh.h"
+#include "BKE_mesh.h"
#include "BKE_report.h"
#include "BKE_subsurf.h"
@@ -341,3 +343,223 @@
/* properties */
WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH);
}
+
+
+
+static void ptex_elem_to_floats_mul_add(MPtex *pt, void *data, float *out, float fac)
+{
+ int i;
+
+ switch(pt->type) {
+ case PTEX_DT_UINT8:
+ for(i = 0; i < pt->channels; ++i)
+ out[i] += (((unsigned char*)data)[i] / 255.0) * fac;
+ break;
+ case PTEX_DT_UINT16:
+ for(i = 0; i < pt->channels; ++i)
+ out[i] += (((unsigned char*)data)[i] / 65535.0) * fac;
+ break;
+ case PTEX_DT_FLOAT:
+ for(i = 0; i < pt->channels; ++i)
+ out[i] += ((float*)data)[i] * fac;
+ break;
+ default:
+ break;
+ }
+}
+
+static void ptex_elem_from_floats(MPtex *pt, void *data, float *in)
+{
+ int i;
+
+ switch(pt->type) {
+ case PTEX_DT_UINT8:
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list