diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2010-07-27 04:03:02 +0400 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2010-07-27 04:03:02 +0400 |
commit | 4635e0f3e2851ce3a4dab30ad2e63fe05fa4506e (patch) | |
tree | 79df379c8e58d83abd5056e54f49dd1059652e7f | |
parent | 3d0afea083a6267d9b29a111f9cdf8eea594abe9 (diff) | |
parent | c0898bbf48ecf7c9260489d93c37f6f4fbd7b71d (diff) |
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r30722:30764
65 files changed, 808 insertions, 695 deletions
@@ -45,7 +45,7 @@ MAKEFLAGS=-I$(NANBLENDERHOME)/build_files/make --no-print-directory SOURCEDIR = ifeq ($(FREE_WINDOWS),true) - DIRS ?= dlltool extern intern source po + DIRS ?= $(NANBLENDERHOME)/build_files/make/dlltool extern intern source po else DIRS ?= extern intern source po endif diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index 7f5ce4767e3..1c2fccec322 100644 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -529,13 +529,13 @@ def AppIt(target=None, source=None, env=None): # print cmd commands.getoutput(cmd) cmd = installdir + '/%s.app/Contents/MacOS/%s'%(binary,VERSION) - shutil.copy(bldroot + '/bin/.blender/.bfont.ttf', cmd) - shutil.copy(bldroot + '/bin/.blender/.Blanguages', cmd) - cmd = 'cp -R %s/bin/%s/locale %s/%s.app/Contents/Resources/'%(bldroot,VERSION,installdir,binary) + shutil.copy(bldroot + '/release/bin/.blender/.bfont.ttf', cmd) + shutil.copy(bldroot + '/release/bin/.blender/.Blanguages', cmd) + cmd = 'cp -R %s/release/bin/%s/locale %s/%s.app/Contents/Resources/'%(bldroot,VERSION,installdir,binary) commands.getoutput(cmd) - cmd = 'cp -R %s/bin/%s/locale %s/%s.app/Contents/MacOS/%s/'%(bldroot,VERSION,installdir,binary,VERSION) + cmd = 'cp -R %s/release/bin/%s/locale %s/%s.app/Contents/MacOS/%s/'%(bldroot,VERSION,installdir,binary,VERSION) commands.getoutput(cmd) - cmd = 'cp %s/bin/%s/.Blanguages %s/%s.app/Contents/Resources/'%(bldroot,VERSION,installdir,binary) + cmd = 'cp %s/release/bin/%s/.Blanguages %s/%s.app/Contents/Resources/'%(bldroot,VERSION,installdir,binary) commands.getoutput(cmd) cmd = 'mkdir %s/%s.app/Contents/MacOS/%s/python/'%(installdir,binary, VERSION) commands.getoutput(cmd) diff --git a/po/Makefile b/po/Makefile index b656a00fb38..bbd1caa68ad 100644 --- a/po/Makefile +++ b/po/Makefile @@ -51,7 +51,7 @@ $(DIR)%/LC_MESSAGES/blender.mo: %.po mkdir -p $(@D) msgfmt -o $@ $< ifeq ($(BF_VERIFY_MO_FILES), true) - @cmp $@ $(NANBLENDERHOME)/bin/.blender/locale/$(basename $<)/LC_MESSAGES/blender.mo \ + @cmp $@ $(NANBLENDERHOME)/release/bin/.blender/locale/$(basename $<)/LC_MESSAGES/blender.mo \ || ( echo Mismatch between generated and commited $(basename $<).mo catalog && \ rm -f $@ && false ) endif diff --git a/release/Makefile b/release/Makefile index 809ac548724..e6d904ea13c 100644 --- a/release/Makefile +++ b/release/Makefile @@ -114,8 +114,8 @@ install: package ifneq ($(OS), darwin) @[ ! -d $(OCGDIR)/bin/.blender ] || \ cp -r $(OCGDIR)/bin/.blender $(DISTDIR) - @cp $(NANBLENDERHOME)/bin/.blender/.Blanguages $(CONFDIR) - @cp $(NANBLENDERHOME)/bin/.blender/.bfont.ttf $(CONFDIR) + @cp $(NANBLENDERHOME)/release/bin/.blender/.Blanguages $(CONFDIR) + @cp $(NANBLENDERHOME)/release/bin/.blender/.bfont.ttf $(CONFDIR) endif @echo "----> Copy blender$(EXT0) executable" ifeq ($(TYPE),-static) diff --git a/bin/.blender/.Blanguages b/release/bin/.blender/.Blanguages index 9f3b3ef80dc..9f3b3ef80dc 100644 --- a/bin/.blender/.Blanguages +++ b/release/bin/.blender/.Blanguages diff --git a/bin/.blender/.bfont.ttf b/release/bin/.blender/.bfont.ttf Binary files differindex 58cd6b5e61e..58cd6b5e61e 100644 --- a/bin/.blender/.bfont.ttf +++ b/release/bin/.blender/.bfont.ttf diff --git a/bin/blender-thumbnailer.py b/release/bin/blender-thumbnailer.py index 27d6259d172..27d6259d172 100755 --- a/bin/blender-thumbnailer.py +++ b/release/bin/blender-thumbnailer.py diff --git a/release/scripts/io/export_3ds.py b/release/scripts/io/export_3ds.py index 6b776c77a7a..910d462a9f9 100644 --- a/release/scripts/io/export_3ds.py +++ b/release/scripts/io/export_3ds.py @@ -941,7 +941,8 @@ def save_3ds(filename, context): sce = context.scene # sce= bpy.data.scenes.active - bpy.ops.object.mode_set(mode='OBJECT') + if context.object: + bpy.ops.object.mode_set(mode='OBJECT') # Initialize the main chunk (primary): primary = _3ds_chunk(PRIMARY) diff --git a/release/scripts/io/export_fbx.py b/release/scripts/io/export_fbx.py index b68d6fafafa..72b03a110bd 100644 --- a/release/scripts/io/export_fbx.py +++ b/release/scripts/io/export_fbx.py @@ -305,7 +305,8 @@ def write(filename, batch_objects = None, \ BATCH_OWN_DIR = False ): - bpy.ops.object.mode_set(mode='OBJECT') + if bpy.context.object: + bpy.ops.object.mode_set(mode='OBJECT') # ----------------- Batch support! if BATCH_ENABLE: diff --git a/release/scripts/io/export_obj.py b/release/scripts/io/export_obj.py index 6b47f6ddb54..ed4f9d398eb 100644 --- a/release/scripts/io/export_obj.py +++ b/release/scripts/io/export_obj.py @@ -823,7 +823,8 @@ def do_export(filepath, context, orig_scene = context.scene # Exit edit mode before exporting, so current object states are exported properly. - bpy.ops.object.mode_set(mode='OBJECT') + if context.object: + bpy.ops.object.mode_set(mode='OBJECT') # if EXPORT_ALL_SCENES: # export_scenes = bpy.data.scenes diff --git a/release/scripts/io/export_ply.py b/release/scripts/io/export_ply.py index 0b936bdceb2..07865e4f65a 100644 --- a/release/scripts/io/export_ply.py +++ b/release/scripts/io/export_ply.py @@ -99,7 +99,8 @@ def write(filename, scene, ob, \ Window.WaitCursor(1) """ - bpy.ops.object.mode_set(mode='OBJECT') + if scene.objects.active: + bpy.ops.object.mode_set(mode='OBJECT') #mesh = BPyMesh.getMeshFromObject(ob, None, EXPORT_APPLY_MODIFIERS, False, scn) # XXX if EXPORT_APPLY_MODIFIERS: diff --git a/release/scripts/io/export_x3d.py b/release/scripts/io/export_x3d.py index 1bad80f6d8e..7f5dd57171c 100644 --- a/release/scripts/io/export_x3d.py +++ b/release/scripts/io/export_x3d.py @@ -1156,8 +1156,9 @@ def x3d_export(filename, scene = context.scene world = scene.world - - bpy.ops.object.mode_set(mode='OBJECT') + + if scene.objects.active: + bpy.ops.object.mode_set(mode='OBJECT') # XXX these are global textures while .Get() returned only scene's? alltextures = bpy.data.textures diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py index 404013fb79a..be52986bbad 100644 --- a/release/scripts/modules/bpy/utils.py +++ b/release/scripts/modules/bpy/utils.py @@ -210,7 +210,7 @@ def load_scripts(reload_scripts=False, refresh_scripts=False): print("gc.collect() -> %d" % gc.collect()) if _bpy.app.debug: - print("Time %.4f" % (time.time() - t_main)) + print("Python Script Load Time %.4f" % (time.time() - t_main)) def expandpath(path): diff --git a/release/scripts/ui/space_userpref.py b/release/scripts/ui/space_userpref.py index b3629b03c22..5bbf3e6d98d 100644 --- a/release/scripts/ui/space_userpref.py +++ b/release/scripts/ui/space_userpref.py @@ -829,14 +829,23 @@ class USERPREF_PT_addons(bpy.types.Panel): @staticmethod def _addon_list(): import sys + import time + modules = [] loaded_modules = set() paths = bpy.utils.script_paths("addons") + + if bpy.app.debug: + t_main = time.time() + # sys.path.insert(0, None) for path in paths: # sys.path[0] = path modules.extend(bpy.utils.modules_from_path(path, loaded_modules)) + if bpy.app.debug: + print("Addon Script Load Time %.4f" % (time.time() - t_main)) + # del sys.path[0] return modules diff --git a/release/scripts/ui/space_view3d_toolbar.py b/release/scripts/ui/space_view3d_toolbar.py index 386e1032343..8829fb3ad4f 100644 --- a/release/scripts/ui/space_view3d_toolbar.py +++ b/release/scripts/ui/space_view3d_toolbar.py @@ -676,29 +676,9 @@ class VIEW3D_PT_tools_brush(PaintPanel): row= col.row() row.prop(brush, "use_frontface", text="Front Faces Only") - #if brush.sculpt_tool in ('DRAW', 'CREASE', 'BLOB', 'LAYER', 'CLAY', 'CLAY_TUBES'): - if brush.sculpt_tool in ('DRAW', 'CREASE', 'BLOB', 'LAYER', 'CLAY'): - col.separator() - col.row().prop(brush, "direction", expand=True) - elif brush.sculpt_tool in ('FLATTEN'): - col.separator() - col.row().prop(brush, "flatten_contrast", expand=True) - elif brush.sculpt_tool in ('FILL'): - col.separator() - col.row().prop(brush, "fill_deepen", expand=True) - elif brush.sculpt_tool in ('SCRAPE'): - col.separator() - col.row().prop(brush, "scrape_peaks", expand=True) - elif brush.sculpt_tool in ('INFLATE'): - col.separator() - col.row().prop(brush, "inflate_deflate", expand=True) - elif brush.sculpt_tool in ('PINCH'): - col.separator() - col.row().prop(brush, "pinch_magnify", expand=True) - - + col.separator() + col.row().prop(brush, "direction", expand=True) - #if brush.sculpt_tool in ('DRAW', 'CREASE', 'BLOB', 'INFLATE', 'LAYER', 'CLAY', 'CLAY_TUBES'): if brush.sculpt_tool in ('DRAW', 'CREASE', 'BLOB', 'INFLATE', 'LAYER', 'CLAY'): col.separator() @@ -1141,16 +1121,14 @@ class VIEW3D_PT_tools_brush_appearance(PaintPanel): else: col.prop(brush, "add_col", text="Color") - col.separator() - col = layout.column() col.label(text="Icon:") row = col.row(align=True) - row.prop(brush, "icon", text="") - - row = col.row(align=True) - row.prop(brush, "icon_filepath", text="") + row.prop(brush, "use_custom_icon") + if brush.use_custom_icon: + row = col.row(align=True) + row.prop(brush, "icon_filepath", text="") # ********** default tools for weightpaint **************** diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index 5f1765b254b..bce6a5b2c02 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -61,6 +61,7 @@ void paint_brush_slot_remove(struct Paint *p); int paint_facesel_test(struct Object *ob); void paint_refresh_mask_display(struct Object *ob); +int paint_has_brush(struct Paint *p, struct Brush *brush); typedef struct SculptSession { /* Mesh data (not copied) can come either directly from a Mesh, or from a MultiresDM */ diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 23a221cadf4..a032f7ecca6 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -862,7 +862,6 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl float startdistance, spacing, step, paintpos[2], dmousepos[2], finalpos[2]; float t, len, press; const int radius= brush_size(brush); - const int diameter= 2*radius; /* compute brush spacing adapted to brush radius, spacing may depend on pressure, so update it */ diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 171276d118e..aae70c055d0 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1127,10 +1127,9 @@ static void kinematic_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstra else { float vec[3]; /* move grabtarget into world space */ - VECCOPY(vec, data->grabtarget); - mul_m4_v3(ob->obmat, vec); + mul_v3_m4v3(vec, ob->obmat, data->grabtarget); copy_m4_m4(ct->matrix, ob->obmat); - VECCOPY(ct->matrix[3], vec); + copy_v3_v3(ct->matrix[3], vec); } } else diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index ca659faa972..1cb28fe56d8 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1326,7 +1326,6 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba ModifierData *preTesselatePoint; Curve *cu= ob->data; ListBase *nurb= BKE_curve_nurbs(cu); - DispList *dl; int required_mode = 0, totvert = 0; int editmode = (!forRender && cu->editnurb); DerivedMesh *dm= NULL, *ndm; diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index e9283ea867e..5f55814341b 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -433,9 +433,8 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect if(!colls) return visibility; - - VECCOPY(norm, efd->vec_to_point); - negate_v3(norm); + + negate_v3_v3(norm, efd->vec_to_point); len = normalize_v3(norm); // check all collision objects diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index a99f2599f66..7ebd0c3f457 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -1194,18 +1194,14 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) ascii = mem[i]; info = &(custrinfo[i]); if (cu->sepchar == (i+1)) { - float vecyo[3]; + float vecyo[3]= {ct->xof, ct->yof, 0.0f}; mem[0] = ascii; mem[1] = 0; custrinfo[0]= *info; cu->pos = 1; cu->len = 1; - vecyo[0] = ct->xof; - vecyo[1] = ct->yof; - vecyo[2] = 0; - mul_m4_v3(ob->obmat, vecyo); - VECCOPY(ob->loc, vecyo); + mul_v3_m4v3(ob->loc, ob->obmat, vecyo); outta = 1; cu->sepchar = 0; } diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index c1e00e091e8..78306705d6b 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -178,7 +178,7 @@ void BKE_previewimg_free_id(ID *id) Image *img = (Image*)id; BKE_previewimg_free(&img->preview); } else if (GS(id->name) == ID_BR) { - Brush *br = (Brush*)br; + Brush *br = (Brush*)id; BKE_previewimg_free(&br->preview); } } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 3b9afdae247..2cb26bd04d0 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2301,11 +2301,9 @@ void minmax_object(Object *ob, float *min, float *max) if(ob->pose) { bPoseChannel *pchan; for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - VECCOPY(vec, pchan->pose_head); - mul_m4_v3(ob->obmat, vec); + mul_v3_m4v3(vec, ob->obmat, pchan->pose_head); DO_MINMAX(vec, min, max); - VECCOPY(vec, pchan->pose_tail); - mul_m4_v3(ob->obmat, vec); + mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail); DO_MINMAX(vec, min, max); } break; diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 37b2017cc21..2b75826aea2 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -253,3 +253,15 @@ void free_paintsession(Object *ob) ob->paint = NULL; } } + +int paint_has_brush(Paint *p, Brush *brush) +{ + int i; + + for (i= 0; i < p->brush_count; i++) { + if (strcmp(brush->id.name+2, p->brushes[i]->id.name+2) == 0) + return 1; + } + + return 0; +} diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index a38fc921bea..366d2e37d78 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -727,7 +727,7 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData pa->foffset=0.0; else switch(distr){ case PART_DISTR_JIT: - pa->foffset*= ctx->jit[2*(int)ctx->jitoff[i]]; + pa->foffset*= ctx->jit[p%(2*ctx->jitlevel)]; break; case PART_DISTR_RAND: pa->foffset*=BLI_frand(); diff --git a/source/blender/blenlib/BLI_math_rotation.h b/source/blender/blenlib/BLI_math_rotation.h index 388a9176d53..f3da20f91c2 100644 --- a/source/blender/blenlib/BLI_math_rotation.h +++ b/source/blender/blenlib/BLI_math_rotation.h @@ -40,10 +40,10 @@ extern "C" { /* init */ void unit_qt(float q[4]); -void copy_qt_qt(float q[4], float a[4]); +void copy_qt_qt(float q[4], const float a[4]); /* arithmetic */ -void mul_qt_qtqt(float q[4], float a[4], float b[4]); +void mul_qt_qtqt(float q[4], const float a[4], const float b[4]); void mul_qt_v3(float q[4], float r[3]); void mul_qt_fl(float q[4], float f); void mul_fac_qt_fl(float q[4], float f); @@ -51,6 +51,7 @@ void mul_fac_qt_fl(float q[4], float f); void sub_qt_qtqt(float q[4], float a[4], float b[4]); void invert_qt(float q[4]); +void invert_qt_qt(float *q1, const float *q2); void conjugate_qt(float q[4]); float dot_qtqt(float a[4], float b[4]); void normalize_qt(float q[4]); @@ -72,6 +73,7 @@ void tri_to_quat(float q[4], float a[3], float b[3], float c[3]); void vec_to_quat(float q[4], float vec[3], short axis, short upflag); /* note: v1 and v2 must be normalized */ void rotation_between_vecs_to_quat(float q[4], const float v1[3], const float v2[3]); +void rotation_between_quats_to_quat(float q[4], const float q1[4], const float q2[4]); /* TODO: don't what this is, but it's not the same as mat3_to_quat */ void mat3_to_quat_is_ok(float q[4], float mat[3][3]); diff --git a/source/blender/blenlib/BLI_storage_types.h b/source/blender/blenlib/BLI_storage_types.h index f8ebc3938a1..bc3584db03e 100644 --- a/source/blender/blenlib/BLI_storage_types.h +++ b/source/blender/blenlib/BLI_storage_types.h @@ -58,6 +58,8 @@ struct direntry{ char *path; #if (defined(WIN32) || defined(WIN64)) && (_MSC_VER>=1500) struct _stat64 s; +#elif defined(__MINGW32__) + struct _stati64 s; #else struct stat s; #endif diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 6e8f4622488..6c06da2e32d 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -309,6 +309,7 @@ void mul_v3_m4v3(float *in, float mat[][4], float *vec) in[2]= x*mat[0][2] + y*mat[1][2] + mat[2][2]*vec[2] + mat[3][2]; } +/* same as mul_m4_v3() but doesnt apply translation component */ void mul_mat3_m4_v3(float mat[][4], float *vec) { float x,y; diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index 6b5bf7743ef..a8cacb60f05 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -36,7 +36,7 @@ void unit_qt(float *q) q[1]= q[2]= q[3]= 0.0f; } -void copy_qt_qt(float *q1, float *q2) +void copy_qt_qt(float *q1, const float *q2) { q1[0]= q2[0]; q1[1]= q2[1]; @@ -49,7 +49,7 @@ int is_zero_qt(float *q) return (q[0] == 0 && q[1] == 0 && q[2] == 0 && q[3] == 0); } -void mul_qt_qtqt(float *q, float *q1, float *q2) +void mul_qt_qtqt(float *q, const float *q1, const float *q2) { float t0,t1,t2; @@ -104,6 +104,12 @@ void invert_qt(float *q) mul_qt_fl(q, 1.0f/f); } +void invert_qt_qt(float *q1, const float *q2) +{ + copy_qt_qt(q1, q2); + invert_qt(q1); +} + /* simple mult */ void mul_qt_fl(float *q, float f) { @@ -336,6 +342,23 @@ void rotation_between_vecs_to_quat(float *q, const float v1[3], const float v2[3 axis_angle_to_quat(q, axis, angle); } +void rotation_between_quats_to_quat(float *q, const float q1[4], const float q2[4]) +{ + float tquat[4]; + double dot = 0.0f; + int x; + + copy_qt_qt(tquat, q1); + conjugate_qt(tquat); + dot = 1.0f / dot_qtqt(tquat, tquat); + + for(x = 0; x < 4; x++) + tquat[x] *= dot; + + mul_qt_qtqt(q, tquat, q2); +} + + void vec_to_quat(float *q,float *vec, short axis, short upflag) { float q2[4], nor[3], *fp, mat[3][3], angle, si, co, x2, y2, z2, len1; diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index f4679aa4dcf..edb6aecabb1 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -29,11 +29,6 @@ * Some really low-level file thingies. */ -/* needed for mingw & _stat64i32 */ -#ifdef FREE_WINDOWS -# define __MSVCRT_VERSION__ 0x0800 -#endif - #include <sys/types.h> #include <stdio.h> #include <stdlib.h> @@ -255,6 +250,8 @@ void BLI_builddir(char *dirname, char *relname) // Excluding other than current MSVC compiler until able to test. #if (defined(WIN32) || defined(WIN64)) && (_MSC_VER>=1500) _stat64(dlink->name,&files[actnum].s); +#elif defined(__MINGW32__) + _stati64(dlink->name,&files[actnum].s); #else stat(dlink->name,&files[actnum].s); #endif @@ -449,14 +446,14 @@ int BLI_exist(char *name) if (len > 3 && ( tmp[len-1]=='\\' || tmp[len-1]=='/') ) tmp[len-1] = '\0'; res = _stat(tmp, &st); if (res == -1) return(0); -#elif defined(WIN32) && defined(__MINGW32__) - struct stat st; +#elif defined(__MINGW32__) + struct _stati64 st; char tmp[FILE_MAXDIR+FILE_MAXFILE]; int len, res; BLI_strncpy(tmp, name, FILE_MAXDIR+FILE_MAXFILE); len = strlen(tmp); if (len > 3 && ( tmp[len-1]=='\\' || tmp[len-1]=='/') ) tmp[len-1] = '\0'; - res = stat(tmp, &st); + res = _stati64(tmp, &st); if (res) return(0); #else struct stat st; diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index f8e793bd178..5386dbc8b98 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -2328,12 +2328,10 @@ void add_primitive_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d) Object *obedit= scene->obedit; // XXX get from context float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3]; EditBone *bone; - - VECCOPY(curs, give_cursor(scene, v3d)); /* Get inverse point for head and orientation for tail */ invert_m4_m4(obedit->imat, obedit->obmat); - mul_m4_v3(obedit->imat, curs); + mul_v3_m4v3(curs, obedit->imat, give_cursor(scene, v3d)); if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) copy_m3_m4(obmat, rv3d->viewmat); @@ -2348,7 +2346,7 @@ void add_primitive_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d) /* Create a bone */ bone= ED_armature_edit_bone_add(obedit->data, "Bone"); - VECCOPY(bone->head, curs); + copy_v3_v3(bone->head, curs); if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1 @@ -2941,17 +2939,14 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op) } else if (count == 1) { EditBonePoint *ebp; - float *fp, curs[3]; + float curs[3]; /* Get Points - selected joint */ ebp= (EditBonePoint *)points.first; /* Get points - cursor (tail) */ - fp= give_cursor(scene, v3d); - VECCOPY (curs, fp); - invert_m4_m4(obedit->imat, obedit->obmat); - mul_m4_v3(obedit->imat, curs); + mul_v3_m4v3(curs, obedit->imat, give_cursor(scene, v3d)); /* Create a bone */ newbone= add_points_bone(obedit, ebp->vec, curs); @@ -2979,15 +2974,13 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op) /* find which one should be the 'head' */ if ((ebp->head_owner && ebp2->head_owner) || (ebp->tail_owner && ebp2->tail_owner)) { /* rule: whichever one is closer to 3d-cursor */ - float curs[3], *fp= give_cursor(scene, v3d); + float curs[3]; float vecA[3], vecB[3]; float distA, distB; /* get cursor location */ - VECCOPY(curs, fp); - invert_m4_m4(obedit->imat, obedit->obmat); - mul_m4_v3(obedit->imat, curs); + mul_v3_m4v3(curs, obedit->imat, give_cursor(scene, v3d)); /* get distances */ sub_v3_v3v3(vecA, ebp->vec, curs); @@ -3007,12 +3000,12 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op) /* assign head/tail combinations */ if (headtail == 2) { - VECCOPY(head, ebp->vec); - VECCOPY(tail, ebp2->vec); + copy_v3_v3(head, ebp->vec); + copy_v3_v3(tail, ebp2->vec); } else if (headtail == 1) { - VECCOPY(head, ebp2->vec); - VECCOPY(tail, ebp->vec); + copy_v3_v3(head, ebp2->vec); + copy_v3_v3(tail, ebp->vec); } /* add new bone and parent it to the appropriate end */ @@ -3095,16 +3088,16 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone * - parent = parent of start */ if ((start->flag & BONE_TIPSEL) && ((start->flag & BONE_SELECTED) || start==arm->act_edbone)==0) { - VECCOPY(head, start->tail); + copy_v3_v3(head, start->tail); } else { - VECCOPY(head, start->head); + copy_v3_v3(head, start->head); } if ((end->flag & BONE_ROOTSEL) && ((end->flag & BONE_SELECTED) || end==arm->act_edbone)==0) { - VECCOPY(tail, end->head); + copy_v3_v3(tail, end->head); } else { - VECCOPY(tail, end->tail); + copy_v3_v3(tail, end->tail); } newbone= add_points_bone(obedit, head, tail); newbone->parent = start->parent; @@ -3376,8 +3369,8 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) newbone = MEM_callocN(sizeof(EditBone), "extrudebone"); if (do_extrude==1) { - VECCOPY (newbone->head, ebone->tail); - VECCOPY (newbone->tail, newbone->head); + copy_v3_v3(newbone->head, ebone->tail); + copy_v3_v3(newbone->tail, newbone->head); newbone->parent = ebone; newbone->flag = ebone->flag & BONE_TIPSEL; // copies it, in case mirrored bone @@ -3385,8 +3378,8 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) if (newbone->parent) newbone->flag |= BONE_CONNECTED; } else { - VECCOPY(newbone->head, ebone->head); - VECCOPY(newbone->tail, ebone->head); + copy_v3_v3(newbone->head, ebone->head); + copy_v3_v3(newbone->tail, ebone->head); newbone->parent= ebone->parent; newbone->flag= BONE_TIPSEL; @@ -3476,7 +3469,7 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "name", name); - VECCOPY(curs, give_cursor(CTX_data_scene(C),CTX_wm_view3d(C))); + copy_v3_v3(curs, give_cursor(CTX_data_scene(C),CTX_wm_view3d(C))); /* Get inverse point for head and orientation for tail */ invert_m4_m4(obedit->imat, obedit->obmat); @@ -3495,7 +3488,7 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) /* Create a bone */ bone= ED_armature_edit_bone_add(obedit->data, name); - VECCOPY(bone->head, curs); + copy_v3_v3(bone->head, curs); if(rv3d && (U.flag & USER_ADD_VIEWALIGNED)) add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1 @@ -3565,17 +3558,17 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op) BLI_addtail(arm->edbo, newbone); /* calculate location of newbone->head */ - VECCOPY(val1, ebone->head); - VECCOPY(val2, ebone->tail); - VECCOPY(val3, newbone->head); + copy_v3_v3(val1, ebone->head); + copy_v3_v3(val2, ebone->tail); + copy_v3_v3(val3, newbone->head); val3[0]= val1[0]*cutratio + val2[0]*cutratioI; val3[1]= val1[1]*cutratio + val2[1]*cutratioI; val3[2]= val1[2]*cutratio + val2[2]*cutratioI; - VECCOPY(newbone->head, val3); - VECCOPY(newbone->tail, ebone->tail); - VECCOPY(ebone->tail, newbone->head); + copy_v3_v3(newbone->head, val3); + copy_v3_v3(newbone->tail, ebone->tail); + copy_v3_v3(ebone->tail, newbone->head); newbone->rad_head= 0.5f * (ebone->rad_head + ebone->rad_tail); ebone->rad_tail= newbone->rad_head; @@ -3793,7 +3786,7 @@ void ARMATURE_OT_switch_direction(wmOperatorType *ot) static void bone_connect_to_existing_parent(EditBone *bone) { bone->flag |= BONE_CONNECTED; - VECCOPY(bone->head, bone->parent->tail); + copy_v3_v3(bone->head, bone->parent->tail); bone->rad_head = bone->parent->rad_tail; } @@ -3821,7 +3814,7 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo selbone->flag |= BONE_CONNECTED; sub_v3_v3v3(offset, actbone->tail, selbone->head); - VECCOPY(selbone->head, actbone->tail); + copy_v3_v3(selbone->head, actbone->tail); selbone->rad_head= actbone->rad_tail; add_v3_v3(selbone->tail, offset); @@ -4594,7 +4587,7 @@ static void add_vgroups__mapFunc(void *userData, int index, float *co, float *no /* DerivedMesh mapFunc for getting final coords in weight paint mode */ float (*verts)[3] = userData; - VECCOPY(verts[index], co); + copy_v3_v3(verts[index], co); } static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], int numbones, Bone **bonelist, bDeformGroup **dgrouplist, bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3], int *selected, float scale) @@ -4721,18 +4714,17 @@ void add_verts_to_dgroups(Scene *scene, Object *ob, Object *par, int heat, int m /* compute root and tip */ if (bbone) { - VECCOPY(root[j], bbone[segments].mat[3]); - mul_m4_v3(bone->arm_mat, root[j]); + mul_v3_m4v3(root[j], bone->arm_mat, bbone[segments].mat[3]); if ((segments+1) < bone->segments) { - VECCOPY(tip[j], bbone[segments+1].mat[3]) - mul_m4_v3(bone->arm_mat, tip[j]); + mul_v3_m4v3(tip[j], bone->arm_mat, bbone[segments+1].mat[3]); + } + else { + copy_v3_v3(tip[j], bone->arm_tail); } - else - VECCOPY(tip[j], bone->arm_tail) } else { - VECCOPY(root[j], bone->arm_head); - VECCOPY(tip[j], bone->arm_tail); + copy_v3_v3(root[j], bone->arm_head); + copy_v3_v3(tip[j], bone->arm_tail); } mul_m4_v3(par->obmat, root[j]); @@ -4789,7 +4781,7 @@ void add_verts_to_dgroups(Scene *scene, Object *ob, Object *par, int heat, int m /* transform verts to global space */ for (i=0; i < mesh->totvert; i++) { if (!vertsfilled) - VECCOPY(verts[i], mesh->mvert[i].co) + copy_v3_v3(verts[i], mesh->mvert[i].co); mul_m4_v3(ob->obmat, verts[i]); } @@ -5027,14 +5019,14 @@ static int pose_clear_rot_exec(bContext *C, wmOperator *op) float eul[3], oldeul[3], quat1[4] = {0}; if (pchan->rotmode == ROT_MODE_QUAT) { - QUATCOPY(quat1, pchan->quat); + copy_qt_qt(quat1, pchan->quat); quat_to_eul( oldeul,pchan->quat); } else if (pchan->rotmode == ROT_MODE_AXISANGLE) { axis_angle_to_eulO( oldeul, EULER_ORDER_DEFAULT,pchan->rotAxis, pchan->rotAngle); } else { - VECCOPY(oldeul, pchan->eul); + copy_v3_v3(oldeul, pchan->eul); } eul[0]= eul[1]= eul[2]= 0.0f; @@ -5057,7 +5049,7 @@ static int pose_clear_rot_exec(bContext *C, wmOperator *op) eulO_to_axis_angle( pchan->rotAxis, &pchan->rotAngle,eul, EULER_ORDER_DEFAULT); } else { - VECCOPY(pchan->eul, eul); + copy_v3_v3(pchan->eul, eul); } } } // Duplicated in source/blender/editors/object/object_transform.c diff --git a/source/blender/editors/include/ED_datafiles.h b/source/blender/editors/include/ED_datafiles.h index 9a5a1a5bea6..2c352abcd00 100644 --- a/source/blender/editors/include/ED_datafiles.h +++ b/source/blender/editors/include/ED_datafiles.h @@ -52,5 +52,93 @@ extern char datatoc_bfont_ttf[]; extern int datatoc_bmonofont_ttf_size; extern char datatoc_bmonofont_ttf[]; +/* Brush icon datafiles */ +/* TODO: this could be simplified by putting all + the brush icons in one file */ +extern int datatoc_add_png_size; +extern char datatoc_add_png[]; + +extern int datatoc_blob_png_size; +extern char datatoc_blob_png[]; + +extern int datatoc_blur_png_size; +extern char datatoc_blur_png[]; + +extern int datatoc_clay_png_size; +extern char datatoc_clay_png[]; + +extern int datatoc_clone_png_size; +extern char datatoc_clone_png[]; + +extern int datatoc_crease_png_size; +extern char datatoc_crease_png[]; + +extern int datatoc_darken_png_size; +extern char datatoc_darken_png[]; + +extern int datatoc_draw_png_size; +extern char datatoc_draw_png[]; + +extern int datatoc_fill_png_size; +extern char datatoc_fill_png[]; + +extern int datatoc_flatten_png_size; +extern char datatoc_flatten_png[]; + +extern int datatoc_grab_png_size; +extern char datatoc_grab_png[]; + +extern int datatoc_inflate_png_size; +extern char datatoc_inflate_png[]; + +extern int datatoc_layer_png_size; +extern char datatoc_layer_png[]; + +extern int datatoc_lighten_png_size; +extern char datatoc_lighten_png[]; + +extern int datatoc_mix_png_size; +extern char datatoc_mix_png[]; + +extern int datatoc_multiply_png_size; +extern char datatoc_multiply_png[]; + +extern int datatoc_nudge_png_size; +extern char datatoc_nudge_png[]; + +extern int datatoc_pinch_png_size; +extern char datatoc_pinch_png[]; + +extern int datatoc_scrape_png_size; +extern char datatoc_scrape_png[]; + +extern int datatoc_smear_png_size; +extern char datatoc_smear_png[]; + +extern int datatoc_smooth_png_size; +extern char datatoc_smooth_png[]; + +extern int datatoc_snake_hook_png_size; +extern char datatoc_snake_hook_png[]; + +extern int datatoc_soften_png_size; +extern char datatoc_soften_png[]; + +extern int datatoc_subtract_png_size; +extern char datatoc_subtract_png[]; + +extern int datatoc_texdraw_png_size; +extern char datatoc_texdraw_png[]; + +extern int datatoc_thumb_png_size; +extern char datatoc_thumb_png[]; + +extern int datatoc_twist_png_size; +extern char datatoc_twist_png[]; + +extern int datatoc_vertexdraw_png_size; +extern char datatoc_vertexdraw_png[]; + + #endif /* ED_DATAFILES_H */ diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h index fd459def112..6a139b124a6 100644 --- a/source/blender/editors/include/UI_icons.h +++ b/source/blender/editors/include/UI_icons.h @@ -27,8 +27,8 @@ */ /* Note: this is included twice with different #defines for DEF_ICON - once from UI_resources.h for the internal icon enum and once fro interface_api.c for - definition of the RNA enum for he icons */ + once from UI_resources.h for the internal icon enum and + once for interface_api.c for the definition of the RNA enum for the icons */ DEF_ICON(ICON_BLENDER) DEF_ICON(ICON_QUESTION) @@ -869,6 +869,37 @@ DEF_ICON(ICON_BLANK345) DEF_ICON(ICON_BLANK346) DEF_ICON(ICON_BLANK346b) + /* brush icons */ + +DEF_ICON(ICON_BRUSH_ADD) +DEF_ICON(ICON_BRUSH_BLOB) +DEF_ICON(ICON_BRUSH_BLUR) +DEF_ICON(ICON_BRUSH_CLAY) +DEF_ICON(ICON_BRUSH_CLONE) +DEF_ICON(ICON_BRUSH_CREASE) +DEF_ICON(ICON_BRUSH_DARKEN) +DEF_ICON(ICON_BRUSH_FILL) +DEF_ICON(ICON_BRUSH_FLATTEN) +DEF_ICON(ICON_BRUSH_GRAB) +DEF_ICON(ICON_BRUSH_INFLATE) +DEF_ICON(ICON_BRUSH_LAYER) +DEF_ICON(ICON_BRUSH_LIGHTEN) +DEF_ICON(ICON_BRUSH_MIX) +DEF_ICON(ICON_BRUSH_MULTIPLY) +DEF_ICON(ICON_BRUSH_NUDGE) +DEF_ICON(ICON_BRUSH_PINCH) +DEF_ICON(ICON_BRUSH_SCRAPE) +DEF_ICON(ICON_BRUSH_SCULPT_DRAW) +DEF_ICON(ICON_BRUSH_SMEAR) +DEF_ICON(ICON_BRUSH_SMOOTH) +DEF_ICON(ICON_BRUSH_SNAKE_HOOK) +DEF_ICON(ICON_BRUSH_SOFTEN) +DEF_ICON(ICON_BRUSH_SUBTRACT) +DEF_ICON(ICON_BRUSH_TEXDRAW) +DEF_ICON(ICON_BRUSH_THUMB) +DEF_ICON(ICON_BRUSH_ROTATE) +DEF_ICON(ICON_BRUSH_VERTEXDRAW) + /* vector icons */ DEF_ICON(VICO_VIEW3D_VEC) diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index b0dd3aac61d..02586a86d1e 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -44,9 +44,13 @@ #include "BLI_blenlib.h" #include "BLI_storage_types.h" +#include "DNA_brush_types.h" +#include "DNA_object_types.h" #include "DNA_screen_types.h" #include "DNA_userdef_types.h" -#include "DNA_brush_types.h" + +#include "RNA_access.h" +#include "RNA_enum_types.h" #include "BKE_context.h" #include "BKE_global.h" @@ -453,6 +457,51 @@ static void vicon_move_down_draw(int x, int y, int w, int h, float alpha) glDisable(GL_LINE_SMOOTH); } +static void init_brush_icons() +{ + +#define INIT_BRUSH_ICON(icon_id, name) \ + bbuf = IMB_ibImageFromMemory((unsigned char*)datatoc_ ##name## _png, \ + datatoc_ ##name## _png_size, IB_rect); \ + def_internal_icon(bbuf, icon_id, 0, 0, w, ICON_TYPE_BUFFER); \ + IMB_freeImBuf(bbuf); + // end INIT_BRUSH_ICON + + ImBuf *bbuf; + const int w = 96; + + INIT_BRUSH_ICON(ICON_BRUSH_ADD, add); + INIT_BRUSH_ICON(ICON_BRUSH_BLOB, blob); + INIT_BRUSH_ICON(ICON_BRUSH_BLUR, blur); + INIT_BRUSH_ICON(ICON_BRUSH_CLAY, clay); + INIT_BRUSH_ICON(ICON_BRUSH_CLONE, clone); + INIT_BRUSH_ICON(ICON_BRUSH_CREASE, crease); + INIT_BRUSH_ICON(ICON_BRUSH_DARKEN, darken); + INIT_BRUSH_ICON(ICON_BRUSH_SCULPT_DRAW, draw); + INIT_BRUSH_ICON(ICON_BRUSH_FILL, fill); + INIT_BRUSH_ICON(ICON_BRUSH_FLATTEN, flatten); + INIT_BRUSH_ICON(ICON_BRUSH_GRAB, grab); + INIT_BRUSH_ICON(ICON_BRUSH_INFLATE, inflate); + INIT_BRUSH_ICON(ICON_BRUSH_LAYER, layer); + INIT_BRUSH_ICON(ICON_BRUSH_LIGHTEN, lighten); + INIT_BRUSH_ICON(ICON_BRUSH_MIX, mix); + INIT_BRUSH_ICON(ICON_BRUSH_MULTIPLY, multiply); + INIT_BRUSH_ICON(ICON_BRUSH_NUDGE, nudge); + INIT_BRUSH_ICON(ICON_BRUSH_PINCH, pinch); + INIT_BRUSH_ICON(ICON_BRUSH_SCRAPE, scrape); + INIT_BRUSH_ICON(ICON_BRUSH_SMEAR, smear); + INIT_BRUSH_ICON(ICON_BRUSH_SMOOTH, smooth); + INIT_BRUSH_ICON(ICON_BRUSH_SNAKE_HOOK, snake_hook); + INIT_BRUSH_ICON(ICON_BRUSH_SOFTEN, soften); + INIT_BRUSH_ICON(ICON_BRUSH_SUBTRACT, subtract); + INIT_BRUSH_ICON(ICON_BRUSH_TEXDRAW, texdraw); + INIT_BRUSH_ICON(ICON_BRUSH_THUMB, thumb); + INIT_BRUSH_ICON(ICON_BRUSH_ROTATE, twist); + INIT_BRUSH_ICON(ICON_BRUSH_VERTEXDRAW, vertexdraw); + +#undef INIT_BRUSH_ICON +} + static void init_internal_icons() { bTheme *btheme= U.themes.first; @@ -740,6 +789,7 @@ void UI_icons_init(int first_dyn_id) init_iconfile_list(&iconfilelist); BKE_icons_init(first_dyn_id); init_internal_icons(); + init_brush_icons(); } /* Render size for preview images at level miplevel */ @@ -963,6 +1013,43 @@ void ui_id_icon_render(bContext *C, ID *id, int preview) } } +static int ui_id_brush_get_icon(bContext *C, ID *id, int preview) +{ + Brush *br = (Brush*)id; + + if(br->flag & BRUSH_CUSTOM_ICON) { + BKE_icon_getid(id); + ui_id_icon_render(C, id, preview); + } + else if(!id->icon_id) { + /* no icon found, reset it */ + + /* this is not nice, should probably make + brushes be strictly in one paint mode only + to avoid this kind of thing */ + Object *ob = CTX_data_active_object(C); + EnumPropertyItem *items; + int tool; + + if(ob->mode & OB_MODE_SCULPT) { + items = brush_sculpt_tool_items; + tool = br->sculpt_tool; + } + else if(ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT)) { + items = brush_vertexpaint_tool_items; + tool = br->vertexpaint_tool; + } + else { + items = brush_imagepaint_tool_items; + tool = br->imagepaint_tool; + } + + RNA_enum_icon_from_value(items, tool, &id->icon_id); + } + + return id->icon_id; +} + int ui_id_icon_get(bContext *C, ID *id, int preview) { int iconid= 0; @@ -970,12 +1057,14 @@ int ui_id_icon_get(bContext *C, ID *id, int preview) /* icon */ switch(GS(id->name)) { + case ID_BR: + iconid= ui_id_brush_get_icon(C, id, preview); + break; case ID_MA: /* fall through */ case ID_TE: /* fall through */ case ID_IM: /* fall through */ case ID_WO: /* fall through */ case ID_LA: /* fall through */ - case ID_BR: /* fall through */ iconid= BKE_icon_getid(id); /* checks if not exists, or changed */ ui_id_icon_render(C, id, preview); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index b7b9a2156ef..7044c10e523 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -508,12 +508,16 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, char *name, i type= RNA_property_type(prop); subtype= RNA_property_subtype(prop); - if(subtype == PROP_FILEPATH || subtype == PROP_DIRPATH) { + if(subtype == PROP_FILEPATH || subtype == PROP_DIRPATH || subtype == PROP_IMAGEPATH) { uiBlockSetCurLayout(block, uiLayoutRow(sub, 1)); uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, w-UI_UNIT_X, h); /* BUTTONS_OT_file_browse calls uiFileBrowseContextProperty */ but= uiDefIconButO(block, BUT, "BUTTONS_OT_file_browse", WM_OP_INVOKE_DEFAULT, ICON_FILESEL, x, y, UI_UNIT_X, h, NULL); + if(subtype == PROP_IMAGEPATH) { + RNA_boolean_set(uiButGetOperatorPtrRNA(but), "filter_folder", 1); + RNA_boolean_set(uiButGetOperatorPtrRNA(but), "filter_image", 1); + } } else if(subtype == PROP_DIRECTION) { uiDefButR(block, BUT_NORMAL, 0, name, x, y, 100, 100, ptr, RNA_property_identifier(prop), index, 0, 0, -1, -1, NULL); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index e18ae4882e8..491a13d4d7b 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -467,6 +467,10 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str if(!id_copy(id, NULL, 1 /* test only */) || (idfrom && idfrom->lib)) uiButSetFlag(but, UI_BUT_DISABLED); } + + if(id->lib == NULL && !(ELEM4(GS(id->name), ID_GR, ID_SCE, ID_SCR, ID_TXT))) { + uiDefButR(block, TOG, 0, "F", 0, 0, UI_UNIT_X, UI_UNIT_Y, &idptr, "fake_user", -1, 0, 0, -1, -1, NULL); + } } if(flag & UI_ID_ADD_NEW) { diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index d2860adbf50..8cd42b271a9 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -747,11 +747,10 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) static void widget_draw_preview(BIFIconID icon, float aspect, float alpha, rcti *rect) { int w, h, x, y, size; - - /* only display previews for actual preview images .. ? */ - if (icon < BIFICONID_LAST) + + if(!icon) return; - + w = rect->xmax - rect->xmin; h = rect->ymax - rect->ymin; size = MIN2(w, h); diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 8cbcd0e9402..4bb1f630dad 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -85,6 +85,7 @@ #include "WM_api.h" #include "WM_types.h" +#include "ED_datafiles.h" #include "ED_render.h" #include "ED_view3d.h" @@ -103,145 +104,13 @@ static int qtest() {return 0;} ImBuf* get_brush_icon(Brush *brush) { - /* Sculpt */ - extern char datatoc_blob_png; - extern char datatoc_clay_png; - extern char datatoc_crease_png; - extern char datatoc_draw_png; - extern char datatoc_fill_png; - extern char datatoc_flatten_png; - extern char datatoc_grab_png; - extern char datatoc_inflate_png; - extern char datatoc_layer_png; - extern char datatoc_nudge_png; - extern char datatoc_pinch_png; - extern char datatoc_scrape_png; - extern char datatoc_smooth_png; - extern char datatoc_snake_hook_png; - extern char datatoc_thumb_png; - extern char datatoc_twist_png; - - /* Paint */ - extern char datatoc_add_png; - extern char datatoc_blur_png; - extern char datatoc_clone_png; - extern char datatoc_darken_png; - extern char datatoc_lighten_png; - extern char datatoc_mix_png; - extern char datatoc_multiply_png; - extern char datatoc_smear_png; - extern char datatoc_soften_png; - extern char datatoc_subtract_png; - extern char datatoc_texdraw_png; - extern char datatoc_vertexdraw_png; - - extern int datatoc_blob_png_size; - extern int datatoc_clay_png_size; - extern int datatoc_crease_png_size; - extern int datatoc_draw_png_size; - extern int datatoc_fill_png_size; - extern int datatoc_flatten_png_size; - extern int datatoc_grab_png_size; - extern int datatoc_inflate_png_size; - extern int datatoc_layer_png_size; - extern int datatoc_nudge_png_size; - extern int datatoc_pinch_png_size; - extern int datatoc_scrape_png_size; - extern int datatoc_smooth_png_size; - extern int datatoc_snake_hook_png_size; - extern int datatoc_thumb_png_size; - extern int datatoc_twist_png_size; - - extern int datatoc_add_png_size; - extern int datatoc_blur_png_size; - extern int datatoc_clone_png_size; - extern int datatoc_darken_png_size; - extern int datatoc_lighten_png_size; - extern int datatoc_mix_png_size; - extern int datatoc_multiply_png_size; - extern int datatoc_smear_png_size; - extern int datatoc_soften_png_size; - extern int datatoc_subtract_png_size; - extern int datatoc_texdraw_png_size; - extern int datatoc_vertexdraw_png_size; - - void *icon_data[]= { - 0, - - &datatoc_blob_png, - &datatoc_clay_png, - &datatoc_crease_png, - &datatoc_draw_png, - &datatoc_fill_png, - &datatoc_flatten_png, - &datatoc_grab_png, - &datatoc_inflate_png, - &datatoc_layer_png, - &datatoc_nudge_png, - &datatoc_pinch_png, - &datatoc_scrape_png, - &datatoc_smooth_png, - &datatoc_snake_hook_png, - &datatoc_thumb_png, - &datatoc_twist_png, - - &datatoc_add_png, - &datatoc_blur_png, - &datatoc_clone_png, - &datatoc_darken_png, - &datatoc_lighten_png, - &datatoc_mix_png, - &datatoc_multiply_png, - &datatoc_smear_png, - &datatoc_soften_png, - &datatoc_subtract_png, - &datatoc_texdraw_png, - &datatoc_vertexdraw_png, - }; - - size_t icon_size[]= { - 0, - - datatoc_blob_png_size, - datatoc_clay_png_size, - datatoc_crease_png_size, - datatoc_draw_png_size, - datatoc_fill_png_size, - datatoc_flatten_png_size, - datatoc_grab_png_size, - datatoc_inflate_png_size, - datatoc_layer_png_size, - datatoc_nudge_png_size, - datatoc_pinch_png_size, - datatoc_scrape_png_size, - datatoc_smooth_png_size, - datatoc_snake_hook_png_size, - datatoc_thumb_png_size, - datatoc_twist_png_size, - - datatoc_add_png_size, - datatoc_blur_png_size, - datatoc_clone_png_size, - datatoc_darken_png_size, - datatoc_lighten_png_size, - datatoc_mix_png_size, - datatoc_multiply_png_size, - datatoc_smear_png_size, - datatoc_soften_png_size, - datatoc_subtract_png_size, - datatoc_texdraw_png_size, - datatoc_vertexdraw_png_size, - }; - static const int flags = IB_rect|IB_multilayer|IB_metadata; - static const int default_icon = BRUSH_ICON_SCULPTDRAW; - char path[240]; char *folder; if (!(brush->icon_imbuf)) { - if (brush->icon==BRUSH_ICON_FILE) { + if (brush->flag & BRUSH_CUSTOM_ICON) { if (brush->icon_filepath[0]) { // first use the path directly to try and load the file @@ -263,21 +132,13 @@ ImBuf* get_brush_icon(Brush *brush) brush->icon_imbuf= IMB_loadiffname(path, flags); } } - - // if all else fails use a default image - if (!(brush->icon_imbuf)) - brush->icon_imbuf= IMB_ibImageFromMemory(icon_data[default_icon], icon_size[default_icon], flags); - } - else { - if (!(brush->icon_imbuf)) - brush->icon_imbuf= IMB_ibImageFromMemory(icon_data[brush->icon], icon_size[brush->icon], flags); } - - BKE_icon_changed(BKE_icon_getid(&(brush->id))); } if (!(brush->icon_imbuf)) - printf("get_brush_icon: unable to resolve brush icon imbuf\n"); + brush->id.icon_id = 0; + else + BKE_icon_changed(BKE_icon_getid(&(brush->id))); return brush->icon_imbuf; } diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 4174662359f..6d58e7768fc 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -4830,13 +4830,13 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event) /* special exception here for too high pressure values on first touch in windows for some tablets, then we just skip first touch .. */ - if (tablet && (pressure >= 0.99f) && (pop->s.brush->flag & BRUSH_SPACING_PRESSURE) && brush_use_alpha_pressure(pop->s.brush) && brush_use_size_pressure(pop->s.brush)) + if (tablet && (pressure >= 0.99f) && ((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) || brush_use_alpha_pressure(pop->s.brush) || brush_use_size_pressure(pop->s.brush))) return; /* This can be removed once fixed properly in brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, double time, float pressure, void *user) at zero pressure we should do nothing 1/2^12 is .0002 which is the sensitivity of the most sensitive pen tablet available*/ - if ((pop->s.brush->flag & (BRUSH_ALPHA_PRESSURE|BRUSH_SIZE_PRESSURE|BRUSH_SPACING_PRESSURE)) && tablet && (pressure <= 0.0002f)) + if (tablet && (pressure < .0002f) && ((pop->s.brush->flag & BRUSH_SPACING_PRESSURE) || brush_use_alpha_pressure(pop->s.brush) || brush_use_size_pressure(pop->s.brush))) return; } diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 5419cbf048e..070c40d91c2 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -544,7 +544,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *unused) view3d_set_viewcontext(C, &vc); - if (vc.obact->paint->sculpt) { + if (vc.obact->paint && vc.obact->paint->sculpt) { Paint *paint = paint_get_active(CTX_data_scene(C)); Sculpt *sd = CTX_data_tool_settings(C)->sculpt; Brush *brush = paint_brush(paint); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index d6ffcf243cf..d69c34ad259 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -2085,8 +2085,8 @@ void ED_image_update_frame(const bContext *C) View3D *v3d= sa->spacedata.first; BGpic *bgpic; for(bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next) - if(v3d->bgpic->iuser.flag & IMA_ANIM_ALWAYS) - BKE_image_user_calc_frame(&v3d->bgpic->iuser, scene->r.cfra, 0); + if(bgpic->iuser.flag & IMA_ANIM_ALWAYS) + BKE_image_user_calc_frame(&bgpic->iuser, scene->r.cfra, 0); } else if(sa->spacetype==SPACE_IMAGE) { SpaceImage *sima= sa->spacedata.first; diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index 873deb30511..8570965bb03 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -1132,7 +1132,8 @@ static void draw_brackets(SpaceText *st, ARegion *ar) int viewc, viewl, offl, offc, x, y; char ch; - if(!text->curl) return; + // showsyntax must be on or else the format string will be null + if(!text->curl || !st->showsyntax) return; startl= text->curl; startc= text->curc; @@ -1146,23 +1147,29 @@ static void draw_brackets(SpaceText *st, ARegion *ar) endc= -1; find= -b; stack= 0; + + /* Dont highlight backets if syntax HL is off or bracket in string or comment. */ + if(!linep->format || linep->format[c] == 'l' || linep->format[c] == '#') + return; if(b>0) { /* opening bracket, search forward for close */ c++; while(linep) { while(c<linep->len) { - b= text_check_bracket(linep->line[c]); - if(b==find) { - if(stack==0) { - endl= linep; - endc= c; - break; + if(linep->format[c] != 'l' && linep->format[c] != '#') { + b= text_check_bracket(linep->line[c]); + if(b==find) { + if(stack==0) { + endl= linep; + endc= c; + break; + } + stack--; + } + else if(b==-find) { + stack++; } - stack--; - } - else if(b==-find) { - stack++; } c++; } @@ -1176,17 +1183,19 @@ static void draw_brackets(SpaceText *st, ARegion *ar) c--; while(linep) { while(c>=0) { - b= text_check_bracket(linep->line[c]); - if(b==find) { - if(stack==0) { - endl= linep; - endc= c; - break; + if(linep->format[c] != 'l' && linep->format[c] != '#') { + b= text_check_bracket(linep->line[c]); + if(b==find) { + if(stack==0) { + endl= linep; + endc= c; + break; + } + stack--; + } + else if(b==-find) { + stack++; } - stack--; - } - else if(b==-find) { - stack++; } c--; } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 83ff2145004..f27aedf174f 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2082,13 +2082,15 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E Mesh *me= ob->data; EditEdge *eed; EditFace *efa; - float v1[3], v2[3], v3[3], v4[3], x, y, z; + float v1[3], v2[3], v3[3], v4[3], vmid[3]; float fvec[3]; char val[32]; /* Stores the measurement display text here */ char conv_float[5]; /* Use a float conversion matching the grid size */ float area, col[3]; /* area of the face, color of the text to draw */ float grid= unit->system ? unit->scale_length : v3d->grid; - int do_split= unit->flag & USER_UNIT_OPT_SPLIT; + const int do_split= unit->flag & USER_UNIT_OPT_SPLIT; + const int do_global= v3d->flag & V3D_GLOBAL_STATS; + const int do_moving= G.moving; if(v3d->flag2 & V3D_RENDER_OVERRIDE) return; @@ -2121,24 +2123,22 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E for(eed= em->edges.first; eed; eed= eed->next) { /* draw non fgon edges, or selected edges, or edges next to selected verts while draging */ - if((eed->h != EM_FGON) && ((eed->f & SELECT) || (G.moving && ((eed->v1->f & SELECT) || (eed->v2->f & SELECT)) ))) { - VECCOPY(v1, eed->v1->co); - VECCOPY(v2, eed->v2->co); - - x= 0.5f*(v1[0]+v2[0]); - y= 0.5f*(v1[1]+v2[1]); - z= 0.5f*(v1[2]+v2[2]); - - if(v3d->flag & V3D_GLOBAL_STATS) { - mul_m4_v3(ob->obmat, v1); - mul_m4_v3(ob->obmat, v2); + if((eed->h != EM_FGON) && ((eed->f & SELECT) || (do_moving && ((eed->v1->f & SELECT) || (eed->v2->f & SELECT)) ))) { + copy_v3_v3(v1, eed->v1->co); + copy_v3_v3(v2, eed->v2->co); + + interp_v3_v3v3(vmid, v1, v2, 0.5f); + + if(do_global) { + mul_mat3_m4_v3(ob->obmat, v1); + mul_mat3_m4_v3(ob->obmat, v2); } if(unit->system) bUnit_AsString(val, sizeof(val), len_v3v3(v1, v2)*unit->scale_length, 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); else sprintf(val, conv_float, len_v3v3(v1, v2)); - view3d_cached_text_draw_add(x, y, z, val, 0, 0); + view3d_cached_text_draw_add(vmid[0], vmid[1], vmid[2], val, 0, 0); } } } @@ -2153,18 +2153,18 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E glColor3fv(col); for(efa= em->faces.first; efa; efa= efa->next) { - if((efa->f & SELECT)) { // XXX || (G.moving && faceselectedOR(efa, SELECT)) ) { - VECCOPY(v1, efa->v1->co); - VECCOPY(v2, efa->v2->co); - VECCOPY(v3, efa->v3->co); + if((efa->f & SELECT)) { // XXX || (do_moving && faceselectedOR(efa, SELECT)) ) { + copy_v3_v3(v1, efa->v1->co); + copy_v3_v3(v2, efa->v2->co); + copy_v3_v3(v3, efa->v3->co); if (efa->v4) { - VECCOPY(v4, efa->v4->co); + copy_v3_v3(v4, efa->v4->co); } - if(v3d->flag & V3D_GLOBAL_STATS) { - mul_m4_v3(ob->obmat, v1); - mul_m4_v3(ob->obmat, v2); - mul_m4_v3(ob->obmat, v3); - if (efa->v4) mul_m4_v3(ob->obmat, v4); + if(do_global) { + mul_mat3_m4_v3(ob->obmat, v1); + mul_mat3_m4_v3(ob->obmat, v2); + mul_mat3_m4_v3(ob->obmat, v3); + if (efa->v4) mul_mat3_m4_v3(ob->obmat, v4); } if (efa->v4) @@ -2192,20 +2192,20 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E glColor3fv(col); for(efa= em->faces.first; efa; efa= efa->next) { - VECCOPY(v1, efa->v1->co); - VECCOPY(v2, efa->v2->co); - VECCOPY(v3, efa->v3->co); + copy_v3_v3(v1, efa->v1->co); + copy_v3_v3(v2, efa->v2->co); + copy_v3_v3(v3, efa->v3->co); if(efa->v4) { - VECCOPY(v4, efa->v4->co); + copy_v3_v3(v4, efa->v4->co); } else { - VECCOPY(v4, v3); + copy_v3_v3(v4, v3); } - if(v3d->flag & V3D_GLOBAL_STATS) { - mul_m4_v3(ob->obmat, v1); - mul_m4_v3(ob->obmat, v2); - mul_m4_v3(ob->obmat, v3); - mul_m4_v3(ob->obmat, v4); + if(do_global) { + mul_mat3_m4_v3(ob->obmat, v1); + mul_mat3_m4_v3(ob->obmat, v2); + mul_mat3_m4_v3(ob->obmat, v3); + mul_mat3_m4_v3(ob->obmat, v4); /* intentionally executed even for tri's */ } e1= efa->e1; @@ -2215,19 +2215,19 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E /* Calculate the angles */ - if( (e4->f & e1->f & SELECT) || (G.moving && (efa->v1->f & SELECT)) ) { + if( (e4->f & e1->f & SELECT) || (do_moving && (efa->v1->f & SELECT)) ) { /* Vec 1 */ sprintf(val,"%.3f", RAD2DEG(angle_v3v3v3(v4, v1, v2))); interp_v3_v3v3(fvec, efa->cent, efa->v1->co, 0.8f); view3d_cached_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0, 0); } - if( (e1->f & e2->f & SELECT) || (G.moving && (efa->v2->f & SELECT)) ) { + if( (e1->f & e2->f & SELECT) || (do_moving && (efa->v2->f & SELECT)) ) { /* Vec 2 */ sprintf(val,"%.3f", RAD2DEG(angle_v3v3v3(v1, v2, v3))); interp_v3_v3v3(fvec, efa->cent, efa->v2->co, 0.8f); view3d_cached_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0, 0); } - if( (e2->f & e3->f & SELECT) || (G.moving && (efa->v3->f & SELECT)) ) { + if( (e2->f & e3->f & SELECT) || (do_moving && (efa->v3->f & SELECT)) ) { /* Vec 3 */ if(efa->v4) sprintf(val,"%.3f", RAD2DEG(angle_v3v3v3(v2, v3, v4))); @@ -2238,7 +2238,7 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E } /* Vec 4 */ if(efa->v4) { - if( (e3->f & e4->f & SELECT) || (G.moving && (efa->v4->f & SELECT)) ) { + if( (e3->f & e4->f & SELECT) || (do_moving && (efa->v4->f & SELECT)) ) { sprintf(val,"%.3f", RAD2DEG(angle_v3v3v3(v3, v4, v1))); interp_v3_v3v3(fvec, efa->cent, efa->v4->co, 0.8f); view3d_cached_text_draw_add(fvec[0], fvec[1], fvec[2], val, 0, 0); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index efbd91f45f1..63a9fa1dc2b 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -189,7 +189,7 @@ void view3d_clr_clipping(void) static int test_clipping(float *vec, float clip[][4]) { float view[3]; - VECCOPY(view, vec); + copy_v3_v3(view, vec); if(0.0f < clip[0][3] + INPR(view, clip[0])) if(0.0f < clip[1][3] + INPR(view, clip[1])) @@ -1729,8 +1729,12 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (* func)(void *)) if (v3d->afterdraw.first) { View3DAfter *v3da, *next; int num = 0; + int mask_orig; v3d->xray= TRUE; + /* transp materials can change the depth mask, see #21388 */ + glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig); + glDepthFunc(GL_ALWAYS); /* always write into the depth bufer, overwriting front z values */ for(v3da= v3d->afterdraw.first; v3da; v3da= next) { next= v3da->next; @@ -1757,6 +1761,8 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (* func)(void *)) } v3d->xray= FALSE; v3d->transp= FALSE; + + glDepthMask(mask_orig); } if(rv3d->rflag & RV3D_CLIPPING) @@ -1931,9 +1937,9 @@ static void view3d_main_area_setup_view(Scene *scene, View3D *v3d, ARegion *ar, { float len1, len2, vec[3]; - VECCOPY(vec, rv3d->persinv[0]); + copy_v3_v3(vec, rv3d->persinv[0]); len1= normalize_v3(vec); - VECCOPY(vec, rv3d->persinv[1]); + copy_v3_v3(vec, rv3d->persinv[1]); len2= normalize_v3(vec); rv3d->pixsize= 2.0f*(len1>len2?len1:len2); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index bce4a7e8f58..1385482212e 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -206,7 +206,7 @@ void view3d_boxview_copy(ScrArea *sa, ARegion *ar) if(rv3dtest->viewlock) { rv3dtest->dist= rv3d->dist; - VECCOPY(rv3dtest->ofs, rv3d->ofs); + copy_v3_v3(rv3dtest->ofs, rv3d->ofs); ED_region_tag_redraw(artest); } } @@ -310,14 +310,14 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event) vod->ar= CTX_wm_region(C); vod->rv3d= rv3d= vod->ar->regiondata; vod->dist0= rv3d->dist; - QUATCOPY(vod->oldquat, rv3d->viewquat); + copy_qt_qt(vod->oldquat, rv3d->viewquat); vod->origx= vod->oldx= event->x; vod->origy= vod->oldy= event->y; vod->origkey= event->type; /* the key that triggered the operator. */ vod->use_dyn_ofs= (U.uiflag & USER_ORBIT_SELECTION) ? 1:0; if (vod->use_dyn_ofs) { - VECCOPY(vod->ofs, rv3d->ofs); + copy_v3_v3(vod->ofs, rv3d->ofs); /* If there's no selection, lastofs is unmodified and last value since static */ calculateTransformCenter(C, V3D_CENTROID, lastofs); negate_v3_v3(vod->dyn_ofs, lastofs); @@ -336,8 +336,7 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event) float mat[3][3]; float upvec[3]; - VECCOPY(my_origin, rv3d->ofs); - negate_v3(my_origin); /* ofs is flipped */ + negate_v3_v3(my_origin, rv3d->ofs); /* ofs is flipped */ /* Set the dist value to be the distance from this 3d point */ /* this means youll always be able to zoom into it and panning wont go bad when dist was zero */ @@ -358,7 +357,7 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event) negate_v3_v3(rv3d->ofs, dvec); } negate_v3(vod->dyn_ofs); - VECCOPY(vod->ofs, rv3d->ofs); + copy_v3_v3(vod->ofs, rv3d->ofs); } else { vod->ofs[0] = vod->ofs[1] = vod->ofs[2] = 0.0f; } @@ -538,12 +537,12 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) if (vod->use_dyn_ofs) { /* compute the post multiplication quat, to rotate the offset correctly */ - QUATCOPY(q1, vod->oldquat); + copy_qt_qt(q1, vod->oldquat); conjugate_qt(q1); mul_qt_qtqt(q1, q1, rv3d->viewquat); conjugate_qt(q1); /* conj == inv for unit quat */ - VECCOPY(rv3d->ofs, vod->ofs); + copy_v3_v3(rv3d->ofs, vod->ofs); sub_v3_v3(rv3d->ofs, vod->dyn_ofs); mul_qt_v3(q1, rv3d->ofs); add_v3_v3(rv3d->ofs, vod->dyn_ofs); @@ -600,23 +599,66 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) /* check for view snap */ if (vod->axis_snap){ int i; - float viewmat[3][3]; + float viewquat_inv[4]; + float zaxis[3]={0,0,1}; + invert_qt_qt(viewquat_inv, rv3d->viewquat); - - quat_to_mat3( viewmat,rv3d->viewquat); + mul_qt_v3(viewquat_inv, zaxis); for (i = 0 ; i < 39; i++){ - float snapmat[3][3]; + float view = (int)snapquats[i][4]; + float viewquat_inv_test[4]; + float zaxis_test[3]={0,0,1}; + + invert_qt_qt(viewquat_inv_test, snapquats[i]); + mul_qt_v3(viewquat_inv_test, zaxis_test); + + if(angle_v3v3(zaxis_test, zaxis) < DEG2RAD(45/3)) { + /* find the best roll */ + float quat_roll[4], quat_final[4], quat_best[4]; + float viewquat_align[4]; /* viewquat aligned to zaxis_test */ + float viewquat_align_inv[4]; /* viewquat aligned to zaxis_test */ + float best_angle = FLT_MAX; + int j; + + /* viewquat_align is the original viewquat aligned to the snapped axis + * for testing roll */ + rotation_between_vecs_to_quat(viewquat_align, zaxis_test, zaxis); + normalize_qt(viewquat_align); + mul_qt_qtqt(viewquat_align, rv3d->viewquat, viewquat_align); + normalize_qt(viewquat_align); + invert_qt_qt(viewquat_align_inv, viewquat_align); + + /* find best roll */ + for(j= 0; j<8; j++) { + float angle; + float xaxis1[3]={1,0,0}; + float xaxis2[3]={1,0,0}; + float quat_final_inv[4]; + + axis_angle_to_quat(quat_roll, zaxis_test, j * DEG2RAD(45.0)); + normalize_qt(quat_roll); + + mul_qt_qtqt(quat_final, snapquats[i], quat_roll); + normalize_qt(quat_final); + + /* compare 2 vector angles to find the least roll */ + invert_qt_qt(quat_final_inv, quat_final); + mul_qt_v3(viewquat_align_inv, xaxis1); + mul_qt_v3(quat_final_inv, xaxis2); + angle= angle_v3v3(xaxis1, xaxis2); + + if(angle <= best_angle) { + best_angle= angle; + copy_qt_qt(quat_best, quat_final); + if(j) view= 0; /* view grid assumes certain up axis */ + } + } - quat_to_mat3( snapmat,snapquats[i]); + copy_qt_qt(rv3d->viewquat, quat_best); + rv3d->view= view; /* if we snap to a rolled camera the grid is invalid */ - if ((dot_v3v3(snapmat[0], viewmat[0]) > thres) && - (dot_v3v3(snapmat[1], viewmat[1]) > thres) && - (dot_v3v3(snapmat[2], viewmat[2]) > thres) - ) { - copy_qt_qt(rv3d->viewquat, snapquats[i]); - rv3d->view= view; break; } } @@ -981,7 +1023,7 @@ static void view_zoom_mouseloc(ARegion *ar, float dfac, int mx, int my) /* Offset to target position and dolly */ new_dist = rv3d->dist * dfac; - VECCOPY(rv3d->ofs, tvec); + copy_v3_v3(rv3d->ofs, tvec); rv3d->dist = new_dist; /* Calculate final offset */ @@ -1389,11 +1431,9 @@ static int viewselected_exec(bContext *C, wmOperator *op) /* like a localview wi if(pchan->bone->layer & arm->layer) { bPoseChannel *pchan_tx= pchan->custom_tx ? pchan->custom_tx : pchan; ok= 1; - VECCOPY(vec, pchan_tx->pose_head); - mul_m4_v3(ob->obmat, vec); + mul_v3_m4v3(vec, ob->obmat, pchan_tx->pose_head); DO_MINMAX(vec, min, max); - VECCOPY(vec, pchan_tx->pose_tail); - mul_m4_v3(ob->obmat, vec); + mul_v3_m4v3(vec, ob->obmat, pchan_tx->pose_tail); DO_MINMAX(vec, min, max); } } @@ -2041,7 +2081,7 @@ static int vieworbit_exec(bContext *C, wmOperator *op) } else if(orbitdir == V3D_VIEW_STEPDOWN || orbitdir == V3D_VIEW_STEPUP) { /* horizontal axis */ - VECCOPY(q1+1, rv3d->viewinv[0]); + copy_v3_v3(q1+1, rv3d->viewinv[0]); normalize_v3(q1+1); phi= (float)(M_PI/360.0)*U.pad_rot_angle; @@ -2354,7 +2394,7 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *op, wmEvent *event) fp= give_cursor(scene, v3d); // if(obedit && ctrl) lr_click= 1; - VECCOPY(oldcurs, fp); + copy_v3_v3(oldcurs, fp); mx= event->x - ar->winrct.xmin; my= event->y - ar->winrct.ymin; @@ -2939,7 +2979,7 @@ void viewmoveNDOF(Scene *scene, ARegion *ar, View3D *v3d, int mode) obofs[2] = -ob->obmat[3][2]; } else { - VECCOPY(obofs, rv3d->ofs); + copy_v3_v3(obofs, rv3d->ofs); } /* calc an adjustment based on distance from camera diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 714297b7807..fc3dea5fd22 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -356,11 +356,9 @@ static void do_lasso_select_pose(ViewContext *vc, Object *ob, short mcords[][2], if(ob->type!=OB_ARMATURE || ob->pose==NULL) return; for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - VECCOPY(vec, pchan->pose_head); - mul_m4_v3(ob->obmat, vec); + mul_v3_m4v3(vec, ob->obmat, pchan->pose_head); project_short(vc->ar, vec, sco1); - VECCOPY(vec, pchan->pose_tail); - mul_m4_v3(ob->obmat, vec); + mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail); project_short(vc->ar, vec, sco2); if(lasso_inside_edge(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1])) { @@ -644,11 +642,9 @@ static void do_lasso_select_armature(ViewContext *vc, short mcords[][2], short m for (ebone= arm->edbo->first; ebone; ebone=ebone->next) { - VECCOPY(vec, ebone->head); - mul_m4_v3(vc->obedit->obmat, vec); + mul_v3_m4v3(vec, vc->obedit->obmat, ebone->head); project_short(vc->ar, vec, sco1); - VECCOPY(vec, ebone->tail); - mul_m4_v3(vc->obedit->obmat, vec); + mul_v3_m4v3(vec, vc->obedit->obmat, ebone->tail); project_short(vc->ar, vec, sco2); didpoint= 0; @@ -2010,13 +2006,11 @@ static void armature_circle_select(ViewContext *vc, int selecting, short *mval, float vec[3]; /* project head location to screenspace */ - VECCOPY(vec, ebone->head); - mul_m4_v3(vc->obedit->obmat, vec); + mul_v3_m4v3(vec, vc->obedit->obmat, ebone->head); project_short(vc->ar, vec, sco1); /* project tail location to screenspace */ - VECCOPY(vec, ebone->tail); - mul_m4_v3(vc->obedit->obmat, vec); + mul_v3_m4v3(vec, vc->obedit->obmat, ebone->tail); project_short(vc->ar, vec, sco2); /* check if the head and/or tail is in the circle diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index d8982fb68ca..6b1f5736f03 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -194,15 +194,15 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo /* initialize sms */ memset(&sms,0,sizeof(struct SmoothViewStore)); - VECCOPY(sms.new_ofs, rv3d->ofs); - QUATCOPY(sms.new_quat, rv3d->viewquat); + copy_v3_v3(sms.new_ofs, rv3d->ofs); + copy_qt_qt(sms.new_quat, rv3d->viewquat); sms.new_dist= rv3d->dist; sms.new_lens= v3d->lens; sms.to_camera= 0; /* store the options we want to end with */ - if(ofs) VECCOPY(sms.new_ofs, ofs); - if(quat) QUATCOPY(sms.new_quat, quat); + if(ofs) copy_v3_v3(sms.new_ofs, ofs); + if(quat) copy_qt_qt(sms.new_quat, quat); if(dist) sms.new_dist= *dist; if(lens) sms.new_lens= *lens; @@ -243,8 +243,8 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo if (quat && !ofs && !dist) { float vec1[3], vec2[3]; - VECCOPY(vec1, sms.new_quat); - VECCOPY(vec2, sms.orig_quat); + copy_v3_v3(vec1, sms.new_quat); + copy_v3_v3(vec2, sms.orig_quat); normalize_v3(vec1); normalize_v3(vec2); /* scale the time allowed by the rotation */ @@ -257,8 +257,8 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo view3d_settings_from_ob(oldcamera, sms.orig_ofs, sms.orig_quat, &sms.orig_dist, &sms.orig_lens); } else { - VECCOPY(sms.orig_ofs, rv3d->ofs); - QUATCOPY(sms.orig_quat, rv3d->viewquat); + copy_v3_v3(sms.orig_ofs, rv3d->ofs); + copy_qt_qt(sms.orig_quat, rv3d->viewquat); sms.orig_dist= rv3d->dist; sms.orig_lens= v3d->lens; } @@ -289,8 +289,8 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo /* if we get here nothing happens */ if(sms.to_camera==0) { - VECCOPY(rv3d->ofs, sms.new_ofs); - QUATCOPY(rv3d->viewquat, sms.new_quat); + copy_v3_v3(rv3d->ofs, sms.new_ofs); + copy_qt_qt(rv3d->viewquat, sms.new_quat); rv3d->dist = sms.new_dist; v3d->lens = sms.new_lens; } @@ -317,14 +317,14 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *op, wmEvent *event) /* if we went to camera, store the original */ if(sms->to_camera) { rv3d->persp= RV3D_CAMOB; - VECCOPY(rv3d->ofs, sms->orig_ofs); - QUATCOPY(rv3d->viewquat, sms->orig_quat); + copy_v3_v3(rv3d->ofs, sms->orig_ofs); + copy_qt_qt(rv3d->viewquat, sms->orig_quat); rv3d->dist = sms->orig_dist; v3d->lens = sms->orig_lens; } else { - VECCOPY(rv3d->ofs, sms->new_ofs); - QUATCOPY(rv3d->viewquat, sms->new_quat); + copy_v3_v3(rv3d->ofs, sms->new_ofs); + copy_qt_qt(rv3d->viewquat, sms->new_quat); rv3d->dist = sms->new_dist; v3d->lens = sms->new_lens; } @@ -571,9 +571,9 @@ void viewvector(RegionView3D *rv3d, float coord[3], float vec[3]) { float p1[4], p2[4]; - VECCOPY(p1, coord); + copy_v3_v3(p1, coord); p1[3] = 1.0f; - VECCOPY(p2, p1); + copy_v3_v3(p2, p1); p2[3] = 1.0f; mul_m4_v4(rv3d->viewmat, p2); @@ -584,7 +584,7 @@ void viewvector(RegionView3D *rv3d, float coord[3], float vec[3]) sub_v3_v3v3(vec, p1, p2); } else { - VECCOPY(vec, rv3d->viewinv[2]); + copy_v3_v3(vec, rv3d->viewinv[2]); } normalize_v3(vec); } @@ -686,7 +686,7 @@ void view3d_project_float(ARegion *ar, float *vec, float *adr, float mat[4][4]) float vec4[4]; adr[0]= IS_CLIPPED; - VECCOPY(vec4, vec); + copy_v3_v3(vec4, vec); vec4[3]= 1.0; mul_m4_v4(mat, vec4); @@ -713,7 +713,7 @@ int boundbox_clip(RegionView3D *rv3d, float obmat[][4], BoundBox *bb) mul_m4_m4m4(mat, obmat, rv3d->persmat); for(a=0; a<8; a++) { - VECCOPY(vec, bb->vec[a]); + copy_v3_v3(vec, bb->vec[a]); vec[3]= 1.0; mul_m4_v4(mat, vec); max= vec[3]; @@ -746,7 +746,7 @@ void project_short(ARegion *ar, float *vec, short *adr) /* clips */ return; } - VECCOPY(vec4, vec); + copy_v3_v3(vec4, vec); vec4[3]= 1.0; mul_m4_v4(rv3d->persmat, vec4); @@ -771,7 +771,7 @@ void project_int(ARegion *ar, float *vec, int *adr) float fx, fy, vec4[4]; adr[0]= (int)2140000000.0f; - VECCOPY(vec4, vec); + copy_v3_v3(vec4, vec); vec4[3]= 1.0; mul_m4_v4(rv3d->persmat, vec4); @@ -795,7 +795,7 @@ void project_int_noclip(ARegion *ar, float *vec, int *adr) RegionView3D *rv3d= ar->regiondata; float fx, fy, vec4[4]; - VECCOPY(vec4, vec); + copy_v3_v3(vec4, vec); vec4[3]= 1.0; mul_m4_v4(rv3d->persmat, vec4); @@ -820,7 +820,7 @@ void project_short_noclip(ARegion *ar, float *vec, short *adr) float fx, fy, vec4[4]; adr[0]= IS_CLIPPED; - VECCOPY(vec4, vec); + copy_v3_v3(vec4, vec); vec4[3]= 1.0; mul_m4_v4(rv3d->persmat, vec4); @@ -846,7 +846,7 @@ void project_float(ARegion *ar, float *vec, float *adr) float vec4[4]; adr[0]= IS_CLIPPED; - VECCOPY(vec4, vec); + copy_v3_v3(vec4, vec); vec4[3]= 1.0; mul_m4_v4(rv3d->persmat, vec4); @@ -862,7 +862,7 @@ void project_float_noclip(ARegion *ar, float *vec, float *adr) RegionView3D *rv3d= ar->regiondata; float vec4[4]; - VECCOPY(vec4, vec); + copy_v3_v3(vec4, vec); vec4[3]= 1.0; mul_m4_v4(rv3d->persmat, vec4); @@ -1109,7 +1109,7 @@ static void obmat_to_viewmat(View3D *v3d, RegionView3D *rv3d, Object *ob, short float orig_ofs[3]; float orig_dist= rv3d->dist; float orig_lens= v3d->lens; - VECCOPY(orig_ofs, rv3d->ofs); + copy_v3_v3(orig_ofs, rv3d->ofs); /* Switch from camera view */ mat3_to_quat( new_quat,tmat); @@ -1205,11 +1205,11 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d) Object *ob= v3d->ob_centre; float vec[3]; - VECCOPY(vec, ob->obmat[3]); + copy_v3_v3(vec, ob->obmat[3]); if(ob->type==OB_ARMATURE && v3d->ob_centre_bone[0]) { bPoseChannel *pchan= get_pose_channel(ob->pose, v3d->ob_centre_bone); if(pchan) { - VECCOPY(vec, pchan->pose_mat[3]); + copy_v3_v3(vec, pchan->pose_mat[3]); mul_m4_v3(ob->obmat, vec); } } @@ -1543,8 +1543,8 @@ static void restore_localviewdata(ScrArea *sa, int free) if(rv3d->localvd) { rv3d->dist= rv3d->localvd->dist; - VECCOPY(rv3d->ofs, rv3d->localvd->ofs); - QUATCOPY(rv3d->viewquat, rv3d->localvd->viewquat); + copy_v3_v3(rv3d->ofs, rv3d->localvd->ofs); + copy_qt_qt(rv3d->viewquat, rv3d->localvd->viewquat); rv3d->view= rv3d->localvd->view; rv3d->persp= rv3d->localvd->persp; rv3d->camzoom= rv3d->localvd->camzoom; @@ -2057,7 +2057,7 @@ static int initFlyInfo (bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *even /* perspective or ortho */ if (fly->rv3d->persp==RV3D_ORTHO) fly->rv3d->persp= RV3D_PERSP; /*if ortho projection, make perspective */ - QUATCOPY(fly->rot_backup, fly->rv3d->viewquat); + copy_qt_qt(fly->rot_backup, fly->rv3d->viewquat); copy_v3_v3(fly->ofs_backup, fly->rv3d->ofs); fly->rv3d->dist= 0.0f; @@ -2101,8 +2101,8 @@ static int flyEnd(bContext *C, FlyInfo *fly) DAG_id_flush_update(&ob_back->id, OB_RECALC_OB); } else { /* Non Camera we need to reset the view back to the original location bacause the user canceled*/ - QUATCOPY(rv3d->viewquat, fly->rot_backup); - VECCOPY(rv3d->ofs, fly->ofs_backup); + copy_qt_qt(rv3d->viewquat, fly->rot_backup); + copy_v3_v3(rv3d->ofs, fly->ofs_backup); rv3d->persp= fly->persp_backup; } } @@ -2590,7 +2590,7 @@ static int flyApply(bContext *C, FlyInfo *fly) /*were not redrawing but we need to update the time else the view will jump */ fly->time_lastdraw= PIL_check_seconds_timer(); /* end drawing */ - VECCOPY(fly->dvec_prev, dvec); + copy_v3_v3(fly->dvec_prev, dvec); } /* moved to flyEnd() */ @@ -2703,7 +2703,7 @@ void view3d_align_axis_to_vector(View3D *v3d, RegionView3D *rv3d, int axisidx, f float orig_dist= rv3d->dist; float orig_lens= v3d->lens; - VECCOPY(orig_ofs, rv3d->ofs); + copy_v3_v3(orig_ofs, rv3d->ofs); rv3d->persp= RV3D_PERSP; rv3d->dist= 0.0; view3d_settings_from_ob(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index a87089fbba3..2a41529ffbd 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -55,8 +55,6 @@ typedef struct Brush { struct MTex mtex; struct ImBuf *icon_imbuf; - char icon; - char pad2[7]; PreviewImage *preview; char icon_filepath[240]; @@ -126,6 +124,7 @@ typedef struct Brush { #define BRUSH_RANDOM_ROTATION (1<<25) #define BRUSH_PLANE_TRIM (1<<26) #define BRUSH_FRONTFACE (1<<27) +#define BRUSH_CUSTOM_ICON (1<<28) /* Brush.sculpt_tool */ typedef enum { @@ -143,7 +142,7 @@ typedef enum { SCULPT_TOOL_THUMB, SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_ROTATE, - //SCULPT_TOOL_WAX // XXX: reuse this slot later + SCULPT_TOOL_WAX, // XXX: reuse this slot later SCULPT_TOOL_CREASE, SCULPT_TOOL_BLOB, SCULPT_TOOL_CLAY_TUBES, @@ -151,44 +150,9 @@ typedef enum { } SculptTool; /* Brush.vertexpaint_tool */ -#define VERTEX_PAINT_BLUR -1 +#define VERTEX_PAINT_BLUR 99 /* The other vpaint tools are in IMB_BlendMode */ -/* Internal Icons */ -#define BRUSH_ICON_FILE 0 - -#define BRUSH_ICON_BLOB 1 -#define BRUSH_ICON_CLAY 2 -#define BRUSH_ICON_CREASE 3 -#define BRUSH_ICON_SCULPTDRAW 4 -#define BRUSH_ICON_FILL 5 -#define BRUSH_ICON_FLATTEN 6 -#define BRUSH_ICON_GRAB 7 -#define BRUSH_ICON_INFLATE 8 -#define BRUSH_ICON_LAYER 9 -#define BRUSH_ICON_NUDGE 10 -#define BRUSH_ICON_PINCH 11 -#define BRUSH_ICON_SCRAPE 12 -#define BRUSH_ICON_SMOOTH 13 -#define BRUSH_ICON_SNAKE_HOOK 14 -#define BRUSH_ICON_THUMB 15 -#define BRUSH_ICON_TWIST 16 - -#define BRUSH_ICON_ADD 17 -#define BRUSH_ICON_BLUR 18 -#define BRUSH_ICON_CLONE 19 -#define BRUSH_ICON_DARKEN 20 -#define BRUSH_ICON_LIGHTEN 21 -#define BRUSH_ICON_MIX 22 -#define BRUSH_ICON_MULTIPLY 23 -#define BRUSH_ICON_SMEAR 24 -#define BRUSH_ICON_SOFTEN 25 -#define BRUSH_ICON_SUBTRACT 26 -#define BRUSH_ICON_TEXDRAW 27 -#define BRUSH_ICON_VERTEXDRAW 28 - -#define BRUSH_ICON_COUNT 29 - /* ImagePaintSettings.tool */ #define PAINT_TOOL_DRAW 0 #define PAINT_TOOL_SOFTEN 1 diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index f0ae3accc6b..b9bc1d626ac 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -823,9 +823,10 @@ void RNA_enum_set(PointerRNA *ptr, const char *name, int value); void RNA_enum_set_identifier(PointerRNA *ptr, const char *name, const char *id); int RNA_enum_is_equal(struct bContext *C, PointerRNA *ptr, const char *name, const char *enumname); -/* lower level functions that donr use a PointerRNA */ -int RNA_enum_value_from_id(EnumPropertyItem *item, const char *identifier, int *value); -int RNA_enum_id_from_value(EnumPropertyItem *item, int value, const char **identifier); +/* lower level functions that don't use a PointerRNA */ +int RNA_enum_value_from_id(EnumPropertyItem *item, const char *identifier, int *value); +int RNA_enum_id_from_value(EnumPropertyItem *item, int value, const char **identifier); +int RNA_enum_icon_from_value(EnumPropertyItem *item, int value, int *icon); void RNA_string_get(PointerRNA *ptr, const char *name, char *value); char *RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen); diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index bb0a1ba2c52..65870d54c11 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -66,6 +66,8 @@ extern EnumPropertyItem event_type_items[]; extern EnumPropertyItem operator_return_items[]; extern EnumPropertyItem brush_sculpt_tool_items[]; +extern EnumPropertyItem brush_vertexpaint_tool_items[]; +extern EnumPropertyItem brush_imagepaint_tool_items[]; extern EnumPropertyItem texture_type_items[]; diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index 88058769f4b..06e42c77daf 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -98,6 +98,7 @@ typedef enum PropertySubType { PROP_FILEPATH = 1, PROP_DIRPATH = 2, PROP_FILENAME = 3, + PROP_IMAGEPATH = 4, /* numbers */ PROP_UNSIGNED = 13, diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 35b2eff9c62..42b72ce4341 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -1652,6 +1652,7 @@ static const char *rna_property_subtypename(PropertySubType type) case PROP_FILEPATH: return "PROP_FILEPATH"; case PROP_FILENAME: return "PROP_FILENAME"; case PROP_DIRPATH: return "PROP_DIRPATH"; + case PROP_IMAGEPATH: return "PROP_IMAGEPATH"; case PROP_UNSIGNED: return "PROP_UNSIGNED"; case PROP_PERCENTAGE: return "PROP_PERCENTAGE"; case PROP_FACTOR: return "PROP_FACTOR"; diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 36c8764b3f4..62dd14b2ffa 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -3424,6 +3424,18 @@ int RNA_enum_id_from_value(EnumPropertyItem *item, int value, const char **ident return 0; } +int RNA_enum_icon_from_value(EnumPropertyItem *item, int value, int *icon) +{ + for( ; item->identifier; item++) { + if(item->value==value) { + *icon = item->icon; + return 1; + } + } + + return 0; +} + void RNA_string_get(PointerRNA *ptr, const char *name, char *value) { PropertyRNA *prop= RNA_struct_find_property(ptr, name); diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index c88deaa0b9f..100c24f3427 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -36,18 +36,85 @@ #include "IMB_imbuf.h" + #include "WM_types.h" +static EnumPropertyItem prop_direction_items[]= { + {0, "ADD", 0, "Add", "Add effect of brush"}, + {BRUSH_DIR_IN, "SUBTRACT", 0, "Subtract", "Subtract effect of brush"}, + {0, NULL, 0, NULL, NULL}}; + +EnumPropertyItem brush_sculpt_tool_items[] = { + {SCULPT_TOOL_BLOB, "BLOB", ICON_BRUSH_BLOB, "Blob", ""}, + {SCULPT_TOOL_CLAY, "CLAY", ICON_BRUSH_CLAY, "Clay", ""}, + {SCULPT_TOOL_CREASE, "CREASE",ICON_BRUSH_CREASE, "Crease", ""}, + {SCULPT_TOOL_DRAW, "DRAW", ICON_BRUSH_SCULPT_DRAW, "Draw", ""}, + {SCULPT_TOOL_FILL, "FILL", ICON_BRUSH_FILL, "Fill", ""}, + {SCULPT_TOOL_FLATTEN, "FLATTEN", ICON_BRUSH_FLATTEN, "Flatten", ""}, + {SCULPT_TOOL_GRAB, "GRAB", ICON_BRUSH_GRAB, "Grab", ""}, + {SCULPT_TOOL_INFLATE, "INFLATE", ICON_BRUSH_INFLATE, "Inflate", ""}, + {SCULPT_TOOL_LAYER, "LAYER", ICON_BRUSH_LAYER, "Layer", ""}, + //{SCULPT_TOOL_MASK, "MASK", 0, "Mask", ""}, + {SCULPT_TOOL_NUDGE, "NUDGE", ICON_BRUSH_NUDGE, "Nudge", ""}, + {SCULPT_TOOL_PINCH, "PINCH", ICON_BRUSH_PINCH, "Pinch", ""}, + {SCULPT_TOOL_ROTATE, "ROTATE", ICON_BRUSH_ROTATE, "Rotate", ""}, + {SCULPT_TOOL_SCRAPE, "SCRAPE", ICON_BRUSH_SCRAPE, "Scrape", ""}, + {SCULPT_TOOL_SMOOTH, "SMOOTH", ICON_BRUSH_SMOOTH, "Smooth", ""}, + {SCULPT_TOOL_SNAKE_HOOK, "SNAKE_HOOK", ICON_BRUSH_SNAKE_HOOK, "Snake Hook", ""}, + {SCULPT_TOOL_THUMB, "THUMB", ICON_BRUSH_THUMB, "Thumb", ""}, + {0, NULL, 0, NULL, NULL}}; + + +EnumPropertyItem brush_vertexpaint_tool_items[] = { + {IMB_BLEND_MIX, "MIX", ICON_BRUSH_MIX, "Mix", "Use mix blending mode while painting"}, + {IMB_BLEND_ADD, "ADD", ICON_BRUSH_ADD, "Add", "Use add blending mode while painting"}, + {IMB_BLEND_SUB, "SUB", ICON_BRUSH_SUBTRACT, "Subtract", "Use subtract blending mode while painting"}, + {IMB_BLEND_MUL, "MUL", ICON_BRUSH_MULTIPLY, "Multiply", "Use multiply blending mode while painting"}, + {IMB_BLEND_LIGHTEN, "LIGHTEN", ICON_BRUSH_LIGHTEN, "Lighten", "Use lighten blending mode while painting"}, + {IMB_BLEND_DARKEN, "DARKEN", ICON_BRUSH_DARKEN, "Darken", "Use darken blending mode while painting"}, + {IMB_BLEND_ERASE_ALPHA, "ERASE_ALPHA", ICON_BRUSH_LIGHTEN, "Erase Alpha", "Use erase alpha blending mode while painting"}, + {IMB_BLEND_ADD_ALPHA, "ADD_ALPHA", ICON_BRUSH_LIGHTEN, "Add Alpha", "Use darken blending mode while painting"}, + {VERTEX_PAINT_BLUR, "BLUR", ICON_BRUSH_BLUR, "Blur", "Blur the color with surrounding values"}, + {0, NULL, 0, NULL, NULL}}; + +EnumPropertyItem brush_imagepaint_tool_items[] = { + {PAINT_TOOL_DRAW, "DRAW", ICON_BRUSH_TEXDRAW, "Draw", ""}, + {PAINT_TOOL_SOFTEN, "SOFTEN", ICON_BRUSH_SOFTEN, "Soften", ""}, + {PAINT_TOOL_SMEAR, "SMEAR", ICON_BRUSH_SMEAR, "Smear", ""}, + {PAINT_TOOL_CLONE, "CLONE", ICON_BRUSH_CLONE, "Clone", ""}, + {0, NULL, 0, NULL, NULL}}; + #ifdef RNA_RUNTIME #include "MEM_guardedalloc.h" +#include "DNA_object_types.h" + +#include "RNA_access.h" + #include "BKE_texture.h" #include "BKE_brush.h" #include "BKE_icons.h" +#include "BKE_paint.h" + #include "WM_api.h" +static void rna_Brush_reset_icon(Brush *br, char *type) +{ + ID *id = &br->id; + + if(br->flag & BRUSH_CUSTOM_ICON) + return; + + if(id->icon_id >= BIFICONID_LAST) { + BKE_icon_delete(id); + BKE_previewimg_free_id(id); + } + + id->icon_id = 0; +} + static void rna_Brush_update(Main *bmain, Scene *scene, PointerRNA *ptr) { Brush *br= (Brush*)ptr->data; @@ -55,43 +122,43 @@ static void rna_Brush_update(Main *bmain, Scene *scene, PointerRNA *ptr) //WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D, NULL); } -static int rna_Brush_is_sculpt_brush(Brush *me, bContext *C) +static void rna_Brush_sculpt_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr) { - Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - int i; - - for (i= 0; i < sd->paint.brush_count; i++) { - if (strcmp(me->id.name+2, sd->paint.brushes[i]->id.name+2) == 0) - return 1; - } + Brush *br= (Brush*)ptr->data; + rna_Brush_reset_icon(br, "sculpt"); + rna_Brush_update(bmain, scene, ptr); +} + +static void rna_Brush_vertexpaint_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + Brush *br= (Brush*)ptr->data; + rna_Brush_reset_icon(br, "vertex_paint"); + rna_Brush_update(bmain, scene, ptr); +} + +static void rna_Brush_imagepaint_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + Brush *br= (Brush*)ptr->data; + rna_Brush_reset_icon(br, "texture_paint"); + rna_Brush_update(bmain, scene, ptr); +} - return 0; +static int rna_Brush_is_sculpt_brush(Brush *br, bContext *C) +{ + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + return paint_has_brush(&sd->paint, br); } -static int rna_Brush_is_vpaint_brush(Brush *me, bContext *C) +static int rna_Brush_is_vpaint_brush(Brush *br, bContext *C) { VPaint *vp = CTX_data_tool_settings(C)->vpaint; - int i; - - for (i= 0; i < vp->paint.brush_count; i++) { - if (strcmp(me->id.name+2, vp->paint.brushes[i]->id.name+2) == 0) - return 1; - } - - return 0; + return paint_has_brush(&vp->paint, br); } -static int rna_Brush_is_wpaint_brush(Brush *me, bContext *C) +static int rna_Brush_is_wpaint_brush(Brush *br, bContext *C) { VPaint *vp = CTX_data_tool_settings(C)->wpaint; - int i; - - for (i= 0; i < vp->paint.brush_count; i++) { - if (strcmp(me->id.name+2, vp->paint.brushes[i]->id.name+2) == 0) - return 1; - } - - return 0; + return paint_has_brush(&vp->paint, br); } static int rna_Brush_is_imapaint_brush(Brush *me, bContext *C) @@ -111,12 +178,17 @@ static void rna_Brush_icon_update(Main *bmain, Scene *scene, PointerRNA *ptr) { Brush *br= (Brush*)ptr->data; - if (br->icon_imbuf) { + if(br->icon_imbuf) { IMB_freeImBuf(br->icon_imbuf); br->icon_imbuf= NULL; } - BKE_icon_changed(BKE_icon_getid(&(br->id))); + br->id.icon_id = 0; + + if(br->flag & BRUSH_CUSTOM_ICON) { + BKE_previewimg_get(&br->id); + BKE_icon_changed(BKE_icon_getid(&br->id)); + } WM_main_add_notifier(NC_BRUSH|NA_EDITED, br); } @@ -193,6 +265,66 @@ static float rna_Brush_get_alpha(PointerRNA *ptr) return brush_alpha(me); } +static EnumPropertyItem *rna_Brush_direction_itemf(bContext *C, PointerRNA *ptr, int *free) +{ + static EnumPropertyItem prop_default_items[]= { + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem prop_flatten_contrast_items[]= { + {0, "FLATTEN", 0, "Flatten", "Add effect of brush"}, + {BRUSH_DIR_IN, "CONTRAST", 0, "Contrast", "Subtract effect of brush"}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem prop_fill_deepen_items[]= { + {0, "FILL", 0, "Fill", "Add effect of brush"}, + {BRUSH_DIR_IN, "DEEPEN", 0, "Deepen", "Subtract effect of brush"}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem prop_scrape_peaks_items[]= { + {0, "SCRAPE", 0, "Scrape", "Add effect of brush"}, + {BRUSH_DIR_IN, "PEAKS", 0, "Peaks", "Subtract effect of brush"}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem prop_pinch_magnify_items[]= { + {0, "PINCH", 0, "Pinch", "Add effect of brush"}, + {BRUSH_DIR_IN, "MAGNIFY", 0, "Magnify", "Subtract effect of brush"}, + {0, NULL, 0, NULL, NULL}}; + + static EnumPropertyItem prop_inflate_deflate_items[]= { + {0, "INFLATE", 0, "Inflate", "Add effect of brush"}, + {BRUSH_DIR_IN, "DEFLATE", 0, "Deflate", "Subtract effect of brush"}, + {0, NULL, 0, NULL, NULL}}; + + Brush *me= (Brush*)(ptr->data); + + switch (me->sculpt_tool) { + case SCULPT_TOOL_DRAW: + case SCULPT_TOOL_CREASE: + case SCULPT_TOOL_BLOB: + case SCULPT_TOOL_LAYER: + case SCULPT_TOOL_CLAY: + return prop_direction_items; + + case SCULPT_TOOL_FLATTEN: + return prop_flatten_contrast_items; + + case SCULPT_TOOL_FILL: + return prop_fill_deepen_items; + + case SCULPT_TOOL_SCRAPE: + return prop_scrape_peaks_items; + + case SCULPT_TOOL_PINCH: + return prop_pinch_magnify_items; + + case SCULPT_TOOL_INFLATE: + return prop_inflate_deflate_items; + + default: + return prop_default_items; + } +} + #else static void rna_def_brush_texture_slot(BlenderRNA *brna) @@ -239,27 +371,6 @@ static void rna_def_brush(BlenderRNA *brna) {IMB_BLEND_ADD_ALPHA, "ADD_ALPHA", 0, "Add Alpha", "Add alpha while painting"}, {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem brush_sculpt_tool_items[] = { - {SCULPT_TOOL_DRAW, "DRAW", 0, "Draw", ""}, - {SCULPT_TOOL_SMOOTH, "SMOOTH", 0, "Smooth", ""}, - {SCULPT_TOOL_CREASE, "CREASE", 0, "Crease", ""}, - {SCULPT_TOOL_BLOB, "BLOB", 0, "Blob", ""}, - {SCULPT_TOOL_PINCH, "PINCH", 0, "Pinch", ""}, - {SCULPT_TOOL_INFLATE, "INFLATE", 0, "Inflate", ""}, - {SCULPT_TOOL_GRAB, "GRAB", 0, "Grab", ""}, - {SCULPT_TOOL_SNAKE_HOOK, "SNAKE_HOOK", 0, "Snake Hook", ""}, - {SCULPT_TOOL_ROTATE, "ROTATE", 0, "Rotate", ""}, - {SCULPT_TOOL_THUMB, "THUMB", 0, "Thumb", ""}, - {SCULPT_TOOL_NUDGE, "NUDGE", 0, "Nudge", ""}, - {SCULPT_TOOL_LAYER, "LAYER", 0, "Layer", ""}, - {SCULPT_TOOL_FLATTEN, "FLATTEN", 0, "Flatten", ""}, - {SCULPT_TOOL_CLAY, "CLAY", 0, "Clay", ""}, - //{SCULPT_TOOL_CLAY_TUBES, "CLAY_TUBES", 0, "Clay Tubes", ""}, XXX: remove clay tubes from UI - {SCULPT_TOOL_FILL, "FILL", 0, "Fill", ""}, - {SCULPT_TOOL_SCRAPE, "SCRAPE", 0, "Scrape", ""}, - {SCULPT_TOOL_MASK, "MASK", 0, "Mask", ""}, - {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem brush_stroke_method_items[] = { {0, "DOTS", 0, "Dots", ""}, {BRUSH_RESTORE_MESH, "DRAG_DOT", 0, "Drag Dot", ""}, @@ -279,55 +390,6 @@ static void rna_def_brush(BlenderRNA *brna) {BRUSH_RAKE, "RAKE", 0, "Rake", ""}, {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem brush_vertexpaint_tool_items[] = { - {IMB_BLEND_MIX, "MIX", 0, "Mix", "Use mix blending mode while painting"}, - {IMB_BLEND_ADD, "ADD", 0, "Add", "Use add blending mode while painting"}, - {IMB_BLEND_SUB, "SUB", 0, "Subtract", "Use subtract blending mode while painting"}, - {IMB_BLEND_MUL, "MUL", 0, "Multiply", "Use multiply blending mode while painting"}, - {IMB_BLEND_LIGHTEN, "LIGHTEN", 0, "Lighten", "Use lighten blending mode while painting"}, - {IMB_BLEND_DARKEN, "DARKEN", 0, "Darken", "Use darken blending mode while painting"}, - {IMB_BLEND_ERASE_ALPHA, "ERASE_ALPHA", 0, "Erase Alpha", "Use erase alpha blending mode while painting"}, - {IMB_BLEND_ADD_ALPHA, "ADD_ALPHA", 0, "Add Alpha", "Use add alpha blending mode while painting"}, - {VERTEX_PAINT_BLUR, "BLUR", 0, "Blur", "Blur the color with surrounding values"}, - {0, NULL, 0, NULL, NULL}}; - - static EnumPropertyItem brush_imagepaint_tool_items[] = { - {PAINT_TOOL_DRAW, "DRAW", 0, "Draw", ""}, - {PAINT_TOOL_SOFTEN, "SOFTEN", 0, "Soften", ""}, - {PAINT_TOOL_SMEAR, "SMEAR", 0, "Smear", ""}, - {PAINT_TOOL_CLONE, "CLONE", 0, "Clone", ""}, - {0, NULL, 0, NULL, NULL}}; - - static const EnumPropertyItem prop_flip_direction_items[]= { - {0, "ADD", 0, "Add", "Add effect of brush"}, - {BRUSH_DIR_IN, "SUBTRACT", 0, "Subtract", "Subtract effect of brush"}, - {0, NULL, 0, NULL, NULL}}; - - static const EnumPropertyItem prop_flatten_contrast_items[]= { - {0, "FLATTEN", 0, "Flatten", "Add effect of brush"}, - {BRUSH_DIR_IN, "CONTRAST", 0, "Contrast", "Subtract effect of brush"}, - {0, NULL, 0, NULL, NULL}}; - - static const EnumPropertyItem prop_fill_deepen_items[]= { - {0, "FILL", 0, "Fill", "Add effect of brush"}, - {BRUSH_DIR_IN, "DEEPEN", 0, "Deepen", "Subtract effect of brush"}, - {0, NULL, 0, NULL, NULL}}; - - static const EnumPropertyItem prop_scrape_peaks_items[]= { - {0, "SCRAPE", 0, "Scrape", "Add effect of brush"}, - {BRUSH_DIR_IN, "PEAKS", 0, "Peaks", "Subtract effect of brush"}, - {0, NULL, 0, NULL, NULL}}; - - static const EnumPropertyItem prop_pinch_magnify_items[]= { - {0, "PINCH", 0, "Pinch", "Add effect of brush"}, - {BRUSH_DIR_IN, "MAGNIFY", 0, "Magnify", "Subtract effect of brush"}, - {0, NULL, 0, NULL, NULL}}; - - static const EnumPropertyItem prop_inflate_deflate_items[]= { - {0, "INFLATE", 0, "Inflate", "Add effect of brush"}, - {BRUSH_DIR_IN, "DEFLATE", 0, "Deflate", "Subtract effect of brush"}, - {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem brush_sculpt_plane_items[] = { {SCULPT_DISP_DIR_AREA, "AREA", 0, "Area Plane", ""}, {SCULPT_DISP_DIR_VIEW, "VIEW", 0, "View Plane", ""}, @@ -336,38 +398,6 @@ static void rna_def_brush(BlenderRNA *brna) {SCULPT_DISP_DIR_Z, "Z", 0, "Z Plane", ""}, {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem brush_icon_items[] = { - {BRUSH_ICON_FILE, "FILE", 0, "Use An Image File", ""}, - {BRUSH_ICON_BLOB, "BLOB", 0, "Blob", ""}, - {BRUSH_ICON_CREASE, "CREASE", 0, "Crease", ""}, - {BRUSH_ICON_CLAY, "CLAY", 0, "Clay", ""}, - {BRUSH_ICON_SCULPTDRAW, "SCULPTDRAW", 0, "Sculpt Draw", ""}, - {BRUSH_ICON_FILL, "FILL", 0, "Fill", ""}, - {BRUSH_ICON_FLATTEN, "FLATTEN", 0, "Flatten", ""}, - {BRUSH_ICON_GRAB, "GRAB", 0, "Grab", ""}, - {BRUSH_ICON_INFLATE, "INFLATE", 0, "Inflate", ""}, - {BRUSH_ICON_LAYER, "LAYER", 0, "Layer", ""}, - {BRUSH_ICON_NUDGE, "NUDGE", 0, "Nudge", ""}, - {BRUSH_ICON_PINCH, "PINCH", 0, "Pinch", ""}, - {BRUSH_ICON_TWIST, "TWIST", 0, "Twist", ""}, - {BRUSH_ICON_SCRAPE, "SCRAPE", 0, "Scrape", ""}, - {BRUSH_ICON_SMOOTH, "SMOOTH", 0, "Smooth", ""}, - {BRUSH_ICON_SNAKE_HOOK, "SNAKE_HOOK", 0, "Snake Hook", ""}, - {BRUSH_ICON_THUMB, "THUMB", 0, "Thumb", ""}, - {BRUSH_ICON_ADD, "ADD", 0, "Add", ""}, - {BRUSH_ICON_BLUR, "BLUR", 0, "Blur", ""}, - {BRUSH_ICON_CLONE, "CLONE", 0, "Clone", ""}, - {BRUSH_ICON_DARKEN, "DARKEN", 0, "Darken", ""}, - {BRUSH_ICON_LIGHTEN, "LIGHTEN", 0, "Lighten", ""}, - {BRUSH_ICON_MIX, "MIX", 0, "Mix", ""}, - {BRUSH_ICON_MULTIPLY, "MULTIPLY", 0, "Multiply", ""}, - {BRUSH_ICON_SMEAR, "SMEAR", 0, "Smear", ""}, - {BRUSH_ICON_SOFTEN, "SOFTEN", 0, "Soften", ""}, - {BRUSH_ICON_SUBTRACT, "SUBTRACT", 0, "Subtract", ""}, - {BRUSH_ICON_TEXDRAW, "TEXDRAW", 0, "Texture Draw", ""}, - {BRUSH_ICON_VERTEXDRAW, "VERTEXDRAW", 0, "Vertex Draw", ""}, - {0, NULL, 0, NULL, NULL}}; - FunctionRNA *func; PropertyRNA *parm; @@ -413,29 +443,25 @@ static void rna_def_brush(BlenderRNA *brna) prop= RNA_def_property(srna, "sculpt_tool", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, brush_sculpt_tool_items); RNA_def_property_ui_text(prop, "Sculpt Tool", ""); - RNA_def_property_update(prop, 0, "rna_Brush_update"); + RNA_def_property_update(prop, 0, "rna_Brush_sculpt_tool_update"); prop= RNA_def_property(srna, "vertexpaint_tool", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, brush_vertexpaint_tool_items); RNA_def_property_ui_text(prop, "Vertex/Weight Paint Tool", ""); - RNA_def_property_update(prop, 0, "rna_Brush_update"); + RNA_def_property_update(prop, 0, "rna_Brush_vertexpaint_tool_update"); prop= RNA_def_property(srna, "imagepaint_tool", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, brush_imagepaint_tool_items); RNA_def_property_ui_text(prop, "Image Paint Tool", ""); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, "rna_Brush_update"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, "rna_Brush_imagepaint_tool_update"); prop= RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); - RNA_def_property_enum_items(prop, prop_flip_direction_items); + RNA_def_property_enum_items(prop, prop_direction_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Brush_direction_itemf"); RNA_def_property_ui_text(prop, "Direction", ""); RNA_def_property_update(prop, 0, "rna_Brush_update"); - prop= RNA_def_property(srna, "icon", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, brush_icon_items); - RNA_def_property_ui_text(prop, "Brush Icon", ""); - RNA_def_property_update(prop, 0, "rna_Brush_icon_update"); - prop= RNA_def_property(srna, "stroke_method", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); RNA_def_property_enum_items(prop, brush_stroke_method_items); @@ -454,36 +480,6 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Texture Angle Source", ""); RNA_def_property_update(prop, 0, "rna_Brush_update"); - prop= RNA_def_property(srna, "flatten_contrast", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); - RNA_def_property_enum_items(prop, prop_flatten_contrast_items); - RNA_def_property_ui_text(prop, "Flatten/Contrast", ""); - RNA_def_property_update(prop, 0, "rna_Brush_update"); - - prop= RNA_def_property(srna, "inflate_deflate", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); - RNA_def_property_enum_items(prop, prop_inflate_deflate_items); - RNA_def_property_ui_text(prop, "Inflate/Deflate", ""); - RNA_def_property_update(prop, 0, "rna_Brush_update"); - - prop= RNA_def_property(srna, "fill_deepen", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); - RNA_def_property_enum_items(prop, prop_fill_deepen_items); - RNA_def_property_ui_text(prop, "Fill/Deepen", ""); - RNA_def_property_update(prop, 0, "rna_Brush_update"); - - prop= RNA_def_property(srna, "scrape_peaks", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); - RNA_def_property_enum_items(prop, prop_scrape_peaks_items); - RNA_def_property_ui_text(prop, "Scrape/Peaks", ""); - RNA_def_property_update(prop, 0, "rna_Brush_update"); - - prop= RNA_def_property(srna, "pinch_magnify", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); - RNA_def_property_enum_items(prop, prop_pinch_magnify_items); - RNA_def_property_ui_text(prop, "Pinch/Magnify", ""); - RNA_def_property_update(prop, 0, "rna_Brush_update"); - prop= RNA_def_property(srna, "sculpt_plane", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, brush_sculpt_plane_items); RNA_def_property_ui_text(prop, "Sculpt Plane", ""); @@ -772,7 +768,12 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Subract Color", "Color of cursor when subtracting"); RNA_def_property_update(prop, 0, "rna_Brush_update"); - prop= RNA_def_property(srna, "icon_filepath", PROP_STRING, PROP_FILEPATH); + prop= RNA_def_property(srna, "use_custom_icon", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", BRUSH_CUSTOM_ICON); + RNA_def_property_ui_text(prop, "Custom Icon", "Set the brush icon from an image file"); + RNA_def_property_update(prop, 0, "rna_Brush_icon_update"); + + prop= RNA_def_property(srna, "icon_filepath", PROP_STRING, PROP_IMAGEPATH); RNA_def_property_string_sdna(prop, NULL, "icon_filepath"); RNA_def_property_ui_text(prop, "Brush Icon Filepath", "File path to brush icon"); RNA_def_property_update(prop, 0, "rna_Brush_icon_update"); diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 31432fd7407..d463df7b0d3 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -1996,17 +1996,17 @@ static void rna_def_mesh(BlenderRNA *brna) prop= RNA_def_property(srna, "draw_edge_length", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_EDGELEN); - RNA_def_property_ui_text(prop, "Edge Length", "Displays selected edge lengths"); + RNA_def_property_ui_text(prop, "Edge Length", "Displays selected edge lengths, Using global values when set in the transform panel"); RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); prop= RNA_def_property(srna, "draw_edge_angle", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_EDGEANG); - RNA_def_property_ui_text(prop, "Edge Angles", "Displays the angles in the selected edges in degrees"); + RNA_def_property_ui_text(prop, "Edge Angles", "Displays the angles in the selected edges in degrees, Using global values when set in the transform panel"); RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); prop= RNA_def_property(srna, "draw_face_area", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "drawflag", ME_DRAW_FACEAREA); - RNA_def_property_ui_text(prop, "Face Area", "Displays the area of selected faces"); + RNA_def_property_ui_text(prop, "Face Area", "Displays the area of selected faces, Using global values when set in the transform panel"); RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); /* editflag */ diff --git a/source/blender/python/generic/mathutils_quat.c b/source/blender/python/generic/mathutils_quat.c index fe0d3cde308..480b724111d 100644 --- a/source/blender/python/generic/mathutils_quat.c +++ b/source/blender/python/generic/mathutils_quat.c @@ -190,9 +190,7 @@ static char Quaternion_Difference_doc[] = static PyObject *Quaternion_Difference(QuaternionObject * self, QuaternionObject * value) { - float quat[QUAT_SIZE], tempQuat[QUAT_SIZE]; - double dot = 0.0f; - int x; + float quat[QUAT_SIZE]; if (!QuaternionObject_Check(value)) { PyErr_SetString( PyExc_TypeError, "quat.difference(value): expected a quaternion argument" ); @@ -202,14 +200,8 @@ static PyObject *Quaternion_Difference(QuaternionObject * self, QuaternionObject if(!BaseMath_ReadCallback(self) || !BaseMath_ReadCallback(value)) return NULL; - copy_qt_qt(tempQuat, self->quat); - conjugate_qt(tempQuat); - dot = sqrt(dot_qtqt(tempQuat, tempQuat)); + rotation_between_quats_to_quat(quat, self->quat, value->quat); - for(x = 0; x < QUAT_SIZE; x++) { - tempQuat[x] /= (float)(dot * dot); - } - mul_qt_qtqt(quat, tempQuat, value->quat); return newQuaternionObject(quat, Py_NEW, NULL); } diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index bf91b0498ed..d01eaa56d34 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -44,6 +44,7 @@ #include "BKE_context.h" #include "BKE_text.h" +#include "BKE_font.h" /* only for utf8towchar */ #include "BKE_main.h" #include "BKE_global.h" /* only for script checking */ @@ -204,10 +205,13 @@ void BPY_start_python_path(void) #endif { - static wchar_t py_path_bundle_wchar[FILE_MAXDIR]; + static wchar_t py_path_bundle_wchar[FILE_MAX]; + + /* mbstowcs(py_path_bundle_wchar, py_path_bundle, FILE_MAXDIR); */ /* cant use this, on linux gives bug: #23018 */ + utf8towchar(py_path_bundle_wchar, py_path_bundle); - mbstowcs(py_path_bundle_wchar, py_path_bundle, FILE_MAXDIR); Py_SetPythonHome(py_path_bundle_wchar); + // printf("found python (wchar_t) '%ls'\n", py_path_bundle_wchar); } } diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index c278ad56ab9..b860a4d3957 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -41,6 +41,7 @@ EnumPropertyItem property_subtype_string_items[] = { {PROP_FILEPATH, "FILE_PATH", 0, "File Path", ""}, {PROP_DIRPATH, "DIR_PATH", 0, "Directory Path", ""}, {PROP_FILENAME, "FILENAME", 0, "Filename", ""}, + {PROP_IMAGEPATH, "IMAGE_PATH", 0, "Image Path", ""}, {PROP_NONE, "NONE", 0, "None", ""}, {0, NULL, 0, NULL, NULL}}; diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 69caee898a0..4a9c69ebedd 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -4235,18 +4235,18 @@ StructRNA *pyrna_struct_as_srna(PyObject *self, int parent, const char *error_pr } if(py_srna==NULL) { - PyErr_Format(PyExc_SystemError, "%.200s internal error, self of type '%.200s' had no bl_rna attribute, should never happen", error_prefix, Py_TYPE(self)->tp_name); + PyErr_Format(PyExc_SystemError, "%.200s, missing bl_rna attribute from '%.200s' instance (may not be registered)", error_prefix, Py_TYPE(self)->tp_name); return NULL; } if(!BPy_StructRNA_Check(py_srna)) { - PyErr_Format(PyExc_SystemError, "%.200s internal error, bl_rna was of type '%.200s', instead of %.200s instance", error_prefix, Py_TYPE(py_srna)->tp_name, pyrna_struct_Type.tp_name); + PyErr_Format(PyExc_SystemError, "%.200s, bl_rna attribute wrong type '%.200s' on '%.200s'' instance", error_prefix, Py_TYPE(py_srna)->tp_name, Py_TYPE(self)->tp_name); Py_DECREF(py_srna); return NULL; } if(py_srna->ptr.type != &RNA_Struct) { - PyErr_Format(PyExc_SystemError, "%.200s internal error, bl_rna was not a RNA_Struct type of rna struct", error_prefix); + PyErr_Format(PyExc_SystemError, "%.200s, bl_rna attribute not a RNA_Struct, on '%.200s'' instance", error_prefix, Py_TYPE(self)->tp_name); Py_DECREF(py_srna); return NULL; } diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c index ff718359a3e..fb69519236a 100644 --- a/source/blender/render/intern/source/occlusion.c +++ b/source/blender/render/intern/source/occlusion.c @@ -1390,8 +1390,7 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, f if(onlyshadow) envcolor= WO_AOPLAIN; - VECCOPY(nn, n); - negate_v3(nn); + negate_v3_v3(nn, n); occ_lookup(tree, thread, exclude, co, nn, &occ, (tree->doindirect)? rad: NULL, (env && envcolor)? bn: NULL); diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index 4f86f67f0e3..32ae3ba12dc 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -226,6 +226,9 @@ static void pointdensity_cache_object(Render *re, PointDensity *pd, Object *ob) static void cache_pointdensity(Render *re, Tex *tex) { PointDensity *pd = tex->pd; + + if(!pd) + return; if (pd->point_tree) { BLI_bvhtree_free(pd->point_tree); diff --git a/source/blender/render/intern/source/texture.c b/source/blender/render/intern/source/texture.c index 5938b64dedf..c8a15372e21 100644 --- a/source/blender/render/intern/source/texture.c +++ b/source/blender/render/intern/source/texture.c @@ -2881,6 +2881,9 @@ void do_lamp_tex(LampRen *la, float *lavec, ShadeInput *shi, float *colf, int ef if(la->type==LA_SPOT) { tempvec[0]*= la->spottexfac; tempvec[1]*= la->spottexfac; + /* project from 3d to 2d */ + tempvec[0] /= -tempvec[2]; + tempvec[1] /= -tempvec[2]; } co= tempvec; diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 12bb371de63..b678dd88811 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -125,14 +125,14 @@ IF(WITH_INSTALL) TARGET blender POST_BUILD MAIN_DEPENDENCY blender COMMAND rm -Rf ${TARGETDIR}/.blender COMMAND mkdir ${TARGETDIR}/.blender/ - COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/.blender/ + COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf ${TARGETDIR}/.blender/ ) IF(WITH_INTERNATIONAL) ADD_CUSTOM_COMMAND( TARGET blender POST_BUILD MAIN_DEPENDENCY blender - COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/.blender/ - COMMAND cp -R ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/.blender/ + COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages ${TARGETDIR}/.blender/ + COMMAND cp -R ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale ${TARGETDIR}/.blender/ ) ENDIF(WITH_INTERNATIONAL) @@ -200,7 +200,7 @@ IF(WITH_INSTALL) DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pixmaps ) INSTALL( - PROGRAMS ${CMAKE_SOURCE_DIR}/bin/blender-thumbnailer.py + PROGRAMS ${CMAKE_SOURCE_DIR}/release/bin/blender-thumbnailer.py DESTINATION ${CMAKE_INSTALL_PREFIX}/bin ) INSTALL( @@ -220,7 +220,7 @@ IF(WITH_INSTALL) ) IF(WITH_INTERNATIONAL) INSTALL( - DIRECTORY ${CMAKE_SOURCE_DIR}/bin/.blender/locale/ + DIRECTORY ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale/ DESTINATION ${BLENDERPATH}/datafiles/locale PATTERN ".svn" EXCLUDE ) @@ -243,14 +243,14 @@ IF(WITH_INSTALL) COMMAND cat ${SOURCEINFO} | sed s/VERSION/`cat ${CMAKE_SOURCE_DIR}/release/VERSION`/ | sed s/DATE/`date +'%Y-%b-%d'`/ > ${TARGETINFO} COMMAND rm -Rf ${TARGETDIR}/blender.app/Contents/MacOS/datafiles COMMAND mkdir ${TARGETDIR}/blender.app/Contents/MacOS/datafiles/ - COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/datafiles/ + COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.bfont.ttf ${TARGETDIR}/blender.app/Contents/MacOS/datafiles/ ) IF(WITH_INTERNATIONAL) ADD_CUSTOM_COMMAND( TARGET blender POST_BUILD MAIN_DEPENDENCY blender - COMMAND cp ${CMAKE_SOURCE_DIR}/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/datafiles/ - COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/datafiles/ + COMMAND cp ${CMAKE_SOURCE_DIR}/release/bin/.blender/.Blanguages ${TARGETDIR}/blender.app/Contents/MacOS/datafiles/ + COMMAND cp -Rf ${CMAKE_SOURCE_DIR}/release/bin/.blender/locale ${TARGETDIR}/blender.app/Contents/MacOS/datafiles/ ) ENDIF(WITH_INTERNATIONAL) @@ -286,9 +286,9 @@ IF(WITH_INSTALL) COMMAND if not exist \"${TARGETDIR}\\.blender\\locale\" mkdir \"${TARGETDIR}\\.blender\\locale\" COMMAND if not exist \"${TARGETDIR}\\.blender\\scripts\" mkdir \"${TARGETDIR}\\.blender\\scripts\" COMMAND if not exist \"${TARGETDIR}\\plugins\" mkdir \"${TARGETDIR}\\plugins\" - COMMAND copy /Y \"${CMAKE_SOURCE_DIR}\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\.blender\\\" - COMMAND copy /Y \"${CMAKE_SOURCE_DIR}\\bin\\.blender\\.bfont.ttf\" \"${TARGETDIR}\\.blender\\\" - COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\.blender\\locale\" + COMMAND copy /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\.Blanguages\" \"${TARGETDIR}\\.blender\\\" + COMMAND copy /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\.bfont.ttf\" \"${TARGETDIR}\\.blender\\\" + COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\bin\\.blender\\locale\\*.*\" \"${TARGETDIR}\\.blender\\locale\" COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\scripts\\*.*\" \"${TARGETDIR}\\.blender\\scripts\" COMMAND xcopy /E /Y \"${CMAKE_SOURCE_DIR}\\release\\plugins\\*.*\" \"${TARGETDIR}\\plugins\" COMMAND copy /Y \"${CMAKE_SOURCE_DIR}\\release\\text\\*.*\" \"${TARGETDIR}\" diff --git a/source/darwin/Makefile b/source/darwin/Makefile index 6007ff4d91c..9095f1d8e92 100644 --- a/source/darwin/Makefile +++ b/source/darwin/Makefile @@ -45,7 +45,7 @@ all:: @chmod +x $(DIR)/bin/$(APPLICATION).app/Contents/MacOS/$(APPLICATION) ifeq ($(APPLICATION), blender) @echo "---> copying message files" - @cp -R $(NANBLENDERHOME)/bin/.blender/locale $(DIR)/bin/$(APPLICATION).app/Contents/Resources + @cp -R $(NANBLENDERHOME)/release/bin/.blender/locale $(DIR)/bin/$(APPLICATION).app/Contents/Resources @echo "---> copying .Blanguages" @cp $(NANBLENDERHOME)/bin/.blender/.Blanguages $(DIR)/bin/$(APPLICATION).app/Contents/Resources @echo "---> copying .blender/ scripts" diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index 5914120d2c2..bcc61b533c3 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -295,49 +295,41 @@ bool SCA_PythonController::Import() { //printf("py module modified '%s'\n", m_scriptName.Ptr()); m_bModified= false; - + /* incase we re-import */ Py_XDECREF(m_function); m_function= NULL; - vector<STR_String> py_function_path = m_scriptText.Explode('.'); + STR_String mod_path_str= m_scriptText; /* just for storage, use C style string access */ + char *mod_path= mod_path_str.Ptr(); + char *function_string; + + function_string= strrchr(mod_path, '.'); - if(py_function_path.size() < 2) { + if(function_string == NULL) { printf("Python module name formatting error \"%s\":\n\texpected \"SomeModule.Func\", got \"%s\"\n", GetName().Ptr(), m_scriptText.Ptr()); return false; } - - PyObject *mod = PyImport_ImportModule((char *)py_function_path[0].Ptr()); - /* Dont reload yet, do this within the loop so packages reload too */ - - if(mod==NULL) { + + *function_string= '\0'; + function_string++; + + // Import the module and print an error if it's not found + PyObject *mod = PyImport_ImportModule(mod_path); + if(mod && m_debug) + mod = PyImport_ReloadModule(mod); + + if (mod == NULL) { ErrorPrint("Python module not found"); return false; } - /* 'mod' will be DECREF'd as 'base' - * 'm_function' will be left holding a reference that the controller owns */ - - PyObject *base= mod; - - for(unsigned int i=1; i < py_function_path.size(); i++) { - if(m_debug && PyModule_Check(base)) { /* base could be a class */ - Py_DECREF(base); /* getting a new one so dont hold a ref to the old one */ - base= PyImport_ReloadModule(base); - if (base==NULL) { - m_function= NULL; - break; - } - } - - m_function = PyObject_GetAttrString(base, py_function_path[i].Ptr()); - Py_DECREF(base); - base = m_function; /* for the next loop if there is on */ - - if(m_function==NULL) { - break; - } - } - + + // Get the function object + m_function = PyObject_GetAttrString(mod, function_string); + + // DECREF the module as we don't need it anymore + Py_DECREF(mod); + if(m_function==NULL) { if(PyErr_Occurred()) ErrorPrint("Python controller found the module but could not access the function"); |