From ebfafc77ebf8c4059a281bd9b12b879253c85549 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 17 Jan 2012 17:14:23 +0000 Subject: fix for error in merge 43462 --- source/blender/editors/sculpt_paint/sculpt_uv.c | 2 -- source/blender/editors/uvedit/uvedit_smart_stitch.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'source') diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index 229ef10159e..4023797b11a 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -634,14 +634,12 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent /* Allocate initial selection for grab tool */ if(ts->uv_sculpt_tool == UV_SCULPT_TOOL_GRAB){ float radius, radius_root; - unsigned int tool; UvSculptData *sculptdata = (UvSculptData *)op->customdata; SpaceImage *sima; int width, height; float aspectRatio; float alpha, zoomx, zoomy; Brush *brush = paint_brush(sculptdata->uvsculpt); - tool = CTX_data_scene(C)->toolsettings->uv_sculpt_tool; alpha = brush_alpha(scene, brush); diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index 6a9dda3e1f8..38c8f5bc69c 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -1097,7 +1097,7 @@ static int stitch_init(bContext *C, wmOperator *op) state->selection_size = 0; /* Load old selection if redoing operator with different settings */ - if(RNA_property_is_set(op->ptr, "selection")){ + if(RNA_struct_property_is_set(op->ptr, "selection")){ int faceIndex, elementIndex; UvElement *element; -- cgit v1.2.3 From c64ab6c2bf2bb931249db9fe4712760760fbdcd6 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 17 Jan 2012 17:26:58 +0000 Subject: Whitespace tabs vs. spaces consistency changes --- source/blender/blenkernel/BKE_text.h | 12 ++++++------ source/blender/blenkernel/intern/text.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index ffea8e0c8e2..f0c054560c4 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -46,8 +46,8 @@ void free_text (struct Text *text); void txt_set_undostate (int u); int txt_get_undostate (void); struct Text* add_empty_text (const char *name); -int txt_extended_ascii_as_utf8(char **str); -int reopen_text (struct Text *text); +int txt_extended_ascii_as_utf8(char **str); +int reopen_text (struct Text *text); struct Text* add_text (const char *file, const char *relpath); struct Text* copy_text (struct Text *ta); void unlink_text (struct Main *bmain, struct Text *text); @@ -60,8 +60,8 @@ void txt_order_cursors (struct Text *text); int txt_find_string (struct Text *text, const char *findstr, int wrap, int match_case); int txt_has_sel (struct Text *text); int txt_get_span (struct TextLine *from, struct TextLine *to); -int txt_utf8_offset_to_index(char *str, int offset); -int txt_utf8_index_to_offset(char *str, int index); +int txt_utf8_offset_to_index(char *str, int offset); +int txt_utf8_index_to_offset(char *str, int index); void txt_move_up (struct Text *text, short sel); void txt_move_down (struct Text *text, short sel); void txt_move_left (struct Text *text, short sel); @@ -162,8 +162,8 @@ int text_check_whitespace(char ch); * by 4 character length ID + the text * block itself + the 4 character length * ID (repeat) and opcode (repeat)) */ -#define UNDO_DBLOCK 027 /* Delete block */ -#define UNDO_IBLOCK 030 /* Insert block */ +#define UNDO_DBLOCK 027 /* Delete block */ +#define UNDO_IBLOCK 030 /* Insert block */ /* Misc */ #define UNDO_SWAP 031 /* Swap cursors */ diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index bc86a53c35e..40d439169a3 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -226,7 +226,7 @@ int txt_extended_ascii_as_utf8(char **str) while ((*str)[i]) { if((bad_char= BLI_utf8_invalid_byte(*str+i, length)) == -1) - break; + break; added++; i+= bad_char + 1; -- cgit v1.2.3 From 2019f636b059fde75f459e646c8b0253a5c8189d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 17 Jan 2012 18:01:16 +0000 Subject: misc small changes and bmesh support for testing script --- source/blender/editors/sculpt_paint/paint_image.c | 13 ++- source/blender/makesrna/intern/rna_userdef.c | 2 +- source/tests/bl_mesh_modifiers.py | 112 ++++++++++++++++++---- 3 files changed, 101 insertions(+), 26 deletions(-) (limited to 'source') diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index fea827ed00b..a5b79d0c974 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -4650,7 +4650,8 @@ static int uv_sculpt_brush_poll(bContext *C) int ret; Object *obedit = CTX_data_edit_object(C); SpaceImage *sima= CTX_wm_space_image(C); - ToolSettings *toolsettings = CTX_data_scene(C)->toolsettings; + Scene *scene = CTX_data_scene(C); + ToolSettings *toolsettings = scene->toolsettings; if(!uv_sculpt_brush(C) || !obedit || obedit->type != OB_MESH) return 0; @@ -5162,7 +5163,7 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata) float pixel_size; float alpha= 0.5f; - ts = CTX_data_scene(C)->toolsettings; + ts = scene->toolsettings; if(use_zoom && !ts->use_uv_sculpt){ pixel_size = MAX2(size * zoomx, size * zoomy); @@ -5202,14 +5203,16 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata) static void toggle_paint_cursor(bContext *C, int enable) { - ToolSettings *settings= CTX_data_scene(C)->toolsettings; + wmWindowManager *wm= CTX_wm_manager(C); + Scene *scene = CTX_data_scene(C); + ToolSettings *settings= scene->toolsettings; if(settings->imapaint.paintcursor && !enable) { - WM_paint_cursor_end(CTX_wm_manager(C), settings->imapaint.paintcursor); + WM_paint_cursor_end(wm, settings->imapaint.paintcursor); settings->imapaint.paintcursor = NULL; } else if(enable) - settings->imapaint.paintcursor= WM_paint_cursor_activate(CTX_wm_manager(C), image_paint_poll, brush_drawcursor, NULL); + settings->imapaint.paintcursor= WM_paint_cursor_activate(wm, image_paint_poll, brush_drawcursor, NULL); } /* enable the paint cursor if it isn't already. diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 9de6f73dbe7..24486c227b7 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -2945,7 +2945,7 @@ static void rna_def_userdef_system(BlenderRNA *brna) prop= RNA_def_property(srna, "use_16bit_textures", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "use_16bit_textures", 1); - RNA_def_property_ui_text(prop, "16 Bit Float Textures", "Use 16 bit per component texture for float images."); + RNA_def_property_ui_text(prop, "16 Bit Float Textures", "Use 16 bit per component texture for float images"); RNA_def_property_update(prop, 0, "rna_userdef_gl_use_16bit_textures"); prop= RNA_def_property(srna, "use_vertex_buffer_objects", PROP_BOOLEAN, PROP_NONE); diff --git a/source/tests/bl_mesh_modifiers.py b/source/tests/bl_mesh_modifiers.py index 6a4e46a1832..789a4037659 100644 --- a/source/tests/bl_mesh_modifiers.py +++ b/source/tests/bl_mesh_modifiers.py @@ -31,11 +31,12 @@ import math USE_QUICK_RENDER = False - +IS_BMESH = hasattr(__import__("bpy").types, "LoopColors") # ----------------------------------------------------------------------------- # utility funcs + def render_gl(context, filepath, shade): def ctx_viewport_shade(context, shade): @@ -61,15 +62,16 @@ def render_gl(context, filepath, shade): ctx_viewport_shade(context, shade) + #~ # stop to inspect! + #~ if filepath == "test_cube_shell_solidify_subsurf_wp_wire": + #~ assert(0) + #~ else: + #~ return + bpy.ops.render.opengl(write_still=True, view_context=True) - # stop to inspect! - #~ if filepath == "test_cube_like_subsurf_single_wp_wire": - #~ assert(0) - - def render_gl_all_modes(context, obj, filepath=""): assert(obj != None) @@ -201,8 +203,12 @@ def defaults_object(obj): mesh.show_normal_vertex = True # lame! - for face in mesh.faces: - face.use_smooth = True + if IS_BMESH: + for poly in mesh.polygons: + poly.use_smooth = True + else: + for face in mesh.faces: + face.use_smooth = True def defaults_modifier(mod): @@ -213,6 +219,18 @@ def defaults_modifier(mod): # ----------------------------------------------------------------------------- # models (utils) + +if IS_BMESH: + def mesh_bmesh_poly_elems(poly, elems): + vert_start = poly.loop_start + vert_total = poly.loop_total + return elems[vert_start:vert_start + vert_total] + + def mesh_bmesh_poly_vertices(poly): + return [loop.vertex_index + for loop in mesh_bmesh_poly_elems(poly, poly.id_data.loops)] + + def mesh_bounds(mesh): xmin = ymin = zmin = +100000000.0 xmax = ymax = zmax = -100000000.0 @@ -231,23 +249,67 @@ def mesh_bounds(mesh): def mesh_uv_add(obj): + + uvs = ((0.0, 0.0), + (0.0, 1.0), + (1.0, 1.0), + (1.0, 0.0)) + uv_lay = obj.data.uv_textures.new() - for uv in uv_lay.data: - uv.uv1 = 0.0, 0.0 - uv.uv2 = 0.0, 1.0 - uv.uv3 = 1.0, 1.0 - uv.uv4 = 1.0, 0.0 + + if IS_BMESH: + # XXX, odd that we need to do this. until uvs and texface + # are separated we will need to keep it + uv_loops = obj.data.uv_loop_layers[-1] + uv_list = uv_loops.data[:] + for poly in obj.data.polygons: + poly_uvs = mesh_bmesh_poly_elems(poly, uv_list) + for i, c in enumerate(poly_uvs): + c.uv = uvs[i % 4] + else: + for uv in uv_lay.data: + uv.uv1 = uvs[0] + uv.uv2 = uvs[1] + uv.uv3 = uvs[2] + uv.uv4 = uvs[3] return uv_lay def mesh_vcol_add(obj, mode=0): + + colors = ((0.0, 0.0, 0.0), # black + (1.0, 0.0, 0.0), # red + (0.0, 1.0, 0.0), # green + (0.0, 0.0, 1.0), # blue + (1.0, 1.0, 0.0), # yellow + (0.0, 1.0, 1.0), # cyan + (1.0, 0.0, 1.0), # magenta + (1.0, 1.0, 1.0), # white + ) + + def colors_get(i): + return colors[i % len(colors)] + vcol_lay = obj.data.vertex_colors.new() - for col in vcol_lay.data: - col.color1 = 1.0, 0.0, 0.0 - col.color2 = 0.0, 1.0, 0.0 - col.color3 = 0.0, 0.0, 1.0 - col.color4 = 0.0, 0.0, 0.0 + + mesh = obj.data + + if IS_BMESH: + col_list = vcol_lay.data[:] + for poly in mesh.polygons: + face_verts = mesh_bmesh_poly_vertices(poly) + poly_cols = mesh_bmesh_poly_elems(poly, col_list) + for i, c in enumerate(poly_cols): + c.color = colors[i % 4] + else: + for i, col in enumerate(vcol_lay.data): + face_verts = mesh.faces[i].vertices + col.color1 = colors_get(face_verts[0]) + col.color2 = colors_get(face_verts[1]) + col.color3 = colors_get(face_verts[2]) + if len(face_verts) == 4: + col.color4 = colors_get(face_verts[3]) return vcol_lay @@ -364,13 +426,19 @@ def modifier_hook_add(scene, obj, use_vgroup=True): # no nice way to add hooks from py api yet # assume object mode, hook first face! mesh = obj.data - + if use_vgroup: for v in mesh.vertices: v.select = True else: for v in mesh.vertices: v.select = False + + if IS_BMESH: + face_verts = mesh_bmesh_poly_vertices(mesh.polygons[0]) + else: + face_verts = mesh.faces[0].vertices[:] + for i in mesh.faces[0].vertices: mesh.vertices[i].select = True @@ -406,7 +474,11 @@ def modifier_build_add(scene, obj): defaults_modifier(mod) # ensure we display some faces - totface = len(obj.data.faces) + if IS_BMESH: + totface = len(obj.data.polygons) + else: + totface = len(obj.data.faces) + mod.frame_start = totface // 2 mod.frame_duration = totface -- cgit v1.2.3