[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31465] branches/soc-2010-nicolasbishop: = = Ptex ==
Nicholas Bishop
nicholasbishop at gmail.com
Thu Aug 19 23:11:48 CEST 2010
Revision: 31465
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31465
Author: nicholasbishop
Date: 2010-08-19 23:11:48 +0200 (Thu, 19 Aug 2010)
Log Message:
-----------
== Ptex ==
Brought back ptex resolution editing
Improvements:
* For nonquads, subfaces can now be directly selected, so there's no need to display multiple resolutions for triangles
* Display and selection use the same pbvh as for painting, so for example subsurf shows correctly
Modified Paths:
--------------
branches/soc-2010-nicolasbishop/release/scripts/ui/space_view3d_toolbar.py
branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/ptex.c
branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.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_ptex.c
branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_stroke.c
branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_utils.c
branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c
branches/soc-2010-nicolasbishop/source/blender/editors/space_view3d/drawobject.c
branches/soc-2010-nicolasbishop/source/blender/editors/space_view3d/view3d_header.c
branches/soc-2010-nicolasbishop/source/blender/gpu/intern/gpu_buffers.c
branches/soc-2010-nicolasbishop/source/blender/makesdna/DNA_mesh_types.h
branches/soc-2010-nicolasbishop/source/blender/makesdna/DNA_meshdata_types.h
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-19 20:03:24 UTC (rev 31464)
+++ branches/soc-2010-nicolasbishop/release/scripts/ui/space_view3d_toolbar.py 2010-08-19 21:11:48 UTC (rev 31465)
@@ -478,7 +478,7 @@
if context.sculpt_object:
return ts.sculpt
- elif context.vertex_paint_object and (not context.vertex_paint_object.data.use_paint_mask):
+ elif context.vertex_paint_object and (not context.vertex_paint_object.data.ptex_edit_mode):
return ts.vertex_paint
elif context.weight_paint_object:
return ts.weight_paint
@@ -1418,53 +1418,48 @@
@classmethod
def poll(cls, context):
ob = context.vertex_paint_object
- return ob and ob.data.use_paint_mask
+ return ob and ob.data.ptex_edit_mode
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]
+ if active_ptex != -1:
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
+ active_face = mesh.faces.active
+ active_subface = mesh.faces.active_subface
- box = layout.box()
+ # display active [sub]face's resolution
+ if active_face >= 0 and active_subface >= 0:
+ box = layout.box()
- if len(ptex.subfaces) == 1:
- box.label("Quad Resolution:")
- else:
- box.label("Subface Resolution:")
+ box.label("Current Resolution:")
- def reslbl(prefix, res):
- box.label(text=prefix + str(res[0]) + " x " + str(res[1]))
+ ptex_layer = mesh.ptex_layers[active_ptex]
+ ptex = ptex_layer.data[active_face]
+ subface = ptex.subfaces[active_subface]
- if ptex.subfaces == 1:
- reslbl("", ptex.subfaces[0].resolution)
- else:
- reslbl("1: ", ptex.subfaces[0].resolution)
- reslbl("2: ", ptex.subfaces[1].resolution)
- reslbl("3: ", ptex.subfaces[2].resolution)
-
+ ures = subface.resolution[0];
+ vres = subface.resolution[1];
+ if len(ptex.subfaces) == 4:
+ ures *= 2
+ vres *= 2
+ box.label(str(ures) + " x " + str(vres))
+
+
+
def register():
pass
Modified: branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/ptex.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/ptex.c 2010-08-19 20:03:24 UTC (rev 31464)
+++ branches/soc-2010-nicolasbishop/source/blender/blenkernel/intern/ptex.c 2010-08-19 21:11:48 UTC (rev 31465)
@@ -18,7 +18,7 @@
smd.subdivType = ME_SIMPLE_SUBSURF;
GRIDELEM_KEY_INIT(&gridkey, 1, 0, 0, 1);
ccgdm = subsurf_make_derived_from_derived(dm, &smd, &gridkey,
- 0, NULL, 1, 0);
+ 0, NULL, 0, 0);
return ccgdm;
}
Modified: branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c 2010-08-19 20:03:24 UTC (rev 31464)
+++ branches/soc-2010-nicolasbishop/source/blender/blenlib/intern/pbvh.c 2010-08-19 21:11:48 UTC (rev 31465)
@@ -1604,9 +1604,9 @@
dist);
}
- if(lhit && hit_index) {
- *hit_index = i;
- *grid_hit_index = y*gridsize + x;
+ if(lhit) {
+ if(hit_index) *hit_index = i;
+ if(grid_hit_index) *grid_hit_index = y*gridsize + x;
}
hit |= lhit;
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-19 20:03:24 UTC (rev 31464)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_intern.h 2010-08-19 21:11:48 UTC (rev 31465)
@@ -189,6 +189,10 @@
float pixel_radius, float radius3d,
float special_rotation, float tex_mouse[2]);
+int paint_util_raycast(struct ViewContext *vc,
+ BLI_pbvh_HitOccludedCallback hit_cb, void *mode_data,
+ float out[3], float mouse[2], int original);
+
/* stroke operator */
typedef enum wmBrushStrokeMode {
WM_BRUSHSTROKE_NORMAL,
@@ -247,10 +251,12 @@
const char *pbvh_undo_node_mptex_name(PBVHUndoNode *unode);
void *pbvh_undo_node_mptex_data(PBVHUndoNode *unode, int ndx);
-/* ptex.c */
+/* paint_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);
+void PTEX_OT_subface_select(struct wmOperatorType *ot);
+void PTEX_OT_select_all(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-19 20:03:24 UTC (rev 31464)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_ops.c 2010-08-19 21:11:48 UTC (rev 31465)
@@ -222,6 +222,8 @@
WM_operatortype_append(PTEX_OT_layer_add);
WM_operatortype_append(PTEX_OT_open);
WM_operatortype_append(PTEX_OT_face_resolution_set);
+ WM_operatortype_append(PTEX_OT_subface_select);
+ WM_operatortype_append(PTEX_OT_select_all);
/* face-select */
WM_operatortype_append(PAINT_OT_face_select_linked);
@@ -426,6 +428,11 @@
WM_keymap_verify_item(keymap, "PAINT_OT_vertex_paint", LEFTMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "PAINT_OT_sample_color", RIGHTMOUSE, KM_PRESS, 0, 0);
+ WM_keymap_add_item(keymap, "PTEX_OT_subface_select", RIGHTMOUSE, KM_PRESS, 0, 0);
+ kmi = WM_keymap_add_item(keymap, "PTEX_OT_subface_select", RIGHTMOUSE, KM_PRESS, KM_SHIFT, 0);
+ RNA_boolean_set(kmi->ptr, "extend", 1);
+ WM_keymap_add_item(keymap, "PTEX_OT_select_all", AKEY, KM_PRESS, 0, 0);
+
WM_keymap_add_item(keymap,
"PAINT_OT_vertex_color_set",KKEY, KM_PRESS, KM_SHIFT, 0);
Modified: branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_ptex.c
===================================================================
--- branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_ptex.c 2010-08-19 20:03:24 UTC (rev 31464)
+++ branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_ptex.c 2010-08-19 21:11:48 UTC (rev 31465)
@@ -3,6 +3,7 @@
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_space_types.h"
@@ -12,7 +13,9 @@
#include "BKE_context.h"
#include "BKE_customdata.h"
#include "BKE_DerivedMesh.h"
+#include "BKE_dmgrid.h"
#include "BKE_mesh.h"
+#include "BKE_paint.h"
#include "BKE_report.h"
#include "BKE_subsurf.h"
@@ -21,6 +24,10 @@
#include "WM_api.h"
#include "WM_types.h"
+#include "ED_screen.h"
+#include "ED_view3d.h"
+
+#include "paint_intern.h"
#include "ptex.h"
#include <assert.h>
@@ -462,10 +469,12 @@
}
/* get interpolated value for one texel */
-static void ptex_bilinear_interp(MPtex *pt, void *out, char *input_start, int layersize,
- int offset, float x, float y, float *tmp)
+static void ptex_bilinear_interp(MPtex *pt, MPtexSubface *subface,
+ void *out, int layersize,
+ float x, float y, float *tmp)
{
- int rowlen = pt->subfaces[offset].res[0];
+ char *input_start = subface->data;
+ int rowlen = subface->res[0];
int xi = (int)x;
int yi = (int)y;
int xt = xi+1, yt = yi+1;
@@ -474,9 +483,9 @@
float u = 1 - s;
float v = 1 - t;
- if(xt == pt->subfaces[offset].res[0])
+ if(xt == subface->res[0])
--xt;
- if(yt == pt->subfaces[offset].res[1])
+ if(yt == subface->res[1])
--yt;
memset(tmp, 0, sizeof(float)*pt->channels);
@@ -487,20 +496,38 @@
ptex_elem_from_floats(pt, out, tmp);
}
-/* interpolate from one subface to another */
-static void ptex_subface_scale(MPtex *pt, char *new_data, char *old_data, float *tmp,
- int offset, int layersize, int ures, int vres)
+/* interpolate subface to new resolution */
+static void ptex_subface_scale(MPtex *pt, MPtexSubface *subface,
+ int ures, int vres)
{
float ui, vi, ui_step, vi_step;
- int u, v;
+ float *tmp;
+ char *new_data, *new_data_start;
+ int u, v, layersize;
- ui_step = (float)pt->subfaces[offset].res[0] / ures;
- vi_step = (float)pt->subfaces[offset].res[1] / vres;
+ layersize = pt->channels * ptex_data_size(pt->type);
+
+ new_data_start = new_data =
+ MEM_callocN(layersize * ures * vres, "ptex_subface_scale.new_data");
+
+ /* tmp buffer used in interpolation */
+ tmp = MEM_callocN(sizeof(float) * pt->channels, "ptex_subface_scale.tmp");
+
+ ui_step = subface->res[0] / (float)ures;
+ vi_step = subface->res[1] / (float)vres;
for(v = 0, vi = 0; v < vres; ++v, vi += vi_step) {
for(u = 0, ui = 0; u < ures; ++u, ui += ui_step, new_data += layersize) {
- ptex_bilinear_interp(pt, new_data, old_data, layersize, offset, ui, vi, tmp);
+ ptex_bilinear_interp(pt, subface, new_data, layersize, ui, vi, tmp);
}
}
+
+ MEM_freeN(subface->data);
+ subface->data = new_data_start;
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list