Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-12-07 22:29:21 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-12-07 22:29:21 +0400
commitb245dfbc06feec5b73df23e55df21ef404feacd3 (patch)
tree1a04addb2909c27827f42339d91a9bba22fb2677 /source
parent2a35e8f9c140d082c6292efcf5b05f52aee6c95e (diff)
parent3637794436b6a37ae9447adbd9baaccc0add0823 (diff)
svn merge ^/trunk/blender -r42466:42495
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c61
-rw-r--r--source/blender/blenkernel/intern/tracking.c18
-rw-r--r--source/blender/blenkernel/intern/unit.c2
-rw-r--r--source/blender/editors/interface/resources.c2
-rw-r--r--source/blender/editors/object/object_vgroup.c48
-rw-r--r--source/blender/editors/render/render_internal.c6
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c10
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_snap.c99
-rw-r--r--source/blender/makesdna/DNA_object_types.h2
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h4
-rw-r--r--source/blender/makesrna/intern/rna_userdef.c5
-rw-r--r--source/blender/python/intern/bpy_driver.c5
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c3
14 files changed, 154 insertions, 113 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index f9b07ed150e..64a802f225f 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -64,6 +64,7 @@
#include "BKE_particle.h"
#include "BKE_tessmesh.h"
#include "BKE_bvhutils.h"
+#include "BKE_deform.h"
#ifdef WITH_GAMEENGINE
#include "BKE_navmesh_conversion.h"
@@ -866,40 +867,51 @@ void weight_to_rgb(float r_rgb[3], const float weight)
r_rgb[1]= blend * (1.0f-((weight-0.75f)*4.0f));
r_rgb[2]= 0.0f;
}
+ else {
+ /* exceptional value, unclamped or nan,
+ * avoid uninitialized memory use */
+ r_rgb[0]= 1.0f;
+ r_rgb[1]= 0.0f;
+ r_rgb[2]= 1.0f;
+ }
}
/* draw_flag's for calc_weightpaint_vert_color */
enum {
CALC_WP_MULTIPAINT= (1<<0),
- CALC_WP_AUTO_NORMALIZE= (1<<1),
+ CALC_WP_AUTO_NORMALIZE= (1<<1)
};
-static void calc_weightpaint_vert_color(Object *ob, ColorBand *coba, int vert, unsigned char *col, char *dg_flags, int selected, int UNUSED(unselected), const int draw_flag)
+static void calc_weightpaint_vert_color(
+ Object *ob, ColorBand *coba, int vert, unsigned char *col,
+ const char *dg_flags, int selected, int UNUSED(unselected), const int draw_flag)
{
Mesh *me = ob->data;
- float colf[4], input = 0.0f;
- int i;
-
+ float input = 0.0f;
int make_black= FALSE;
if (me->dvert) {
+ MDeformVert *dvert= &me->dvert[vert];
+
if ((selected > 1) && (draw_flag & CALC_WP_MULTIPAINT)) {
-
int was_a_nonzero= FALSE;
- for (i=0; i<me->dvert[vert].totweight; i++) {
+ int i;
+
+ MDeformWeight *dw= dvert->dw;
+ for (i = dvert->totweight; i > 0; i--, dw++) {
/* in multipaint, get the average if auto normalize is inactive
* get the sum if it is active */
- if(dg_flags[me->dvert[vert].dw[i].def_nr]) {
- if(me->dvert[vert].dw[i].weight) {
- input+= me->dvert[vert].dw[i].weight;
+ if (dg_flags[dw->def_nr]) {
+ if (dw->weight) {
+ input += dw->weight;
was_a_nonzero= TRUE;
}
}
}
/* make it black if the selected groups have no weight on a vertex */
- if(was_a_nonzero == FALSE) {
+ if (was_a_nonzero == FALSE) {
make_black = TRUE;
}
else if ((draw_flag & CALC_WP_AUTO_NORMALIZE) == FALSE) {
@@ -908,11 +920,7 @@ static void calc_weightpaint_vert_color(Object *ob, ColorBand *coba, int vert, u
}
else {
/* default, non tricky behavior */
- for (i=0; i<me->dvert[vert].totweight; i++) {
- if (me->dvert[vert].dw[i].def_nr==ob->actdef-1) {
- input+=me->dvert[vert].dw[i].weight;
- }
- }
+ input= defvert_find_weight(dvert, ob->actdef-1);
}
}
@@ -921,20 +929,19 @@ static void calc_weightpaint_vert_color(Object *ob, ColorBand *coba, int vert, u
col[2] = 0;
col[1] = 0;
col[0] = 255;
- return;
}
+ else {
+ float colf[4];
+ CLAMP(input, 0.0f, 1.0f);
- CLAMP(input, 0.0f, 1.0f);
+ if(coba) do_colorband(coba, input, colf);
+ else weight_to_rgb(colf, input);
- if(coba)
- do_colorband(coba, input, colf);
- else
- weight_to_rgb(colf, input);
-
- col[3] = (unsigned char)(colf[0] * 255.0f);
- col[2] = (unsigned char)(colf[1] * 255.0f);
- col[1] = (unsigned char)(colf[2] * 255.0f);
- col[0] = 255;
+ col[3] = (unsigned char)(colf[0] * 255.0f);
+ col[2] = (unsigned char)(colf[1] * 255.0f);
+ col[1] = (unsigned char)(colf[2] * 255.0f);
+ col[0] = 255;
+ }
}
static ColorBand *stored_cb= NULL;
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index 66c0c0265a1..cacea980fe2 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -76,8 +76,7 @@ void BKE_tracking_init_settings(MovieTracking *tracking)
tracking->camera.pixel_aspect= 1.0f;
tracking->camera.units= CAMERA_UNITS_MM;
- tracking->settings.default_tracker= TRACKER_KLT;
- tracking->settings.default_pyramid_levels= 2;
+ tracking->settings.default_tracker= TRACKER_HYBRID;
tracking->settings.default_minimum_correlation= 0.75;
tracking->settings.default_pattern_size= 11;
tracking->settings.default_search_size= 51;
@@ -810,9 +809,9 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u
int level= MIN2(track->pyramid_levels, max_pyramid_levels);
if(track->tracker==TRACKER_KLT)
- track_context.region_tracker= libmv_pyramidRegionTrackerNew(100, level, MAX2(wndx, wndy));
+ track_context.region_tracker= libmv_pyramidRegionTrackerNew(100, level, MAX2(wndx, wndy), track->minimum_correlation);
else
- track_context.region_tracker= libmv_hybridRegionTrackerNew(100, MAX2(wndx, wndy));
+ track_context.region_tracker= libmv_hybridRegionTrackerNew(100, MAX2(wndx, wndy), track->minimum_correlation);
}
else if(track->tracker==TRACKER_SAD) {
track_context.pattern_size= MAX2(patx, paty);
@@ -1158,7 +1157,7 @@ int BKE_tracking_next(MovieTrackingContext *context)
if(marker && (marker->flag&MARKER_DISABLED)==0) {
#ifdef WITH_LIBMV
int width, height, origin[2], tracked= 0, need_readjust= 0;
- float pos[2], margin[2];
+ float pos[2], margin[2], dim[2];
double x1, y1, x2, y2;
ImBuf *ibuf= NULL;
MovieTrackingMarker marker_new, *marker_keyed;
@@ -1174,7 +1173,8 @@ int BKE_tracking_next(MovieTrackingContext *context)
else nextfra= curfra+1;
/* margin from frame boundaries */
- sub_v2_v2v2(margin, track->pat_max, track->pat_min);
+ sub_v2_v2v2(dim, track->pat_max, track->pat_min);
+ margin[0]= margin[1]= MAX2(dim[0], dim[1]) / 2.0f;
margin[0]= MAX2(margin[0], (float)track->margin / ibuf_new->x);
margin[1]= MAX2(margin[1], (float)track->margin / ibuf_new->y);
@@ -1281,13 +1281,13 @@ int BKE_tracking_next(MovieTrackingContext *context)
}
coords_correct= !isnan(x2) && !isnan(y2) && finite(x2) && finite(y2);
- if(coords_correct && (tracked || !context->disable_failed)) {
+ if(coords_correct && !onbound && (tracked || !context->disable_failed)) {
if(context->first_time) {
#pragma omp critical
{
/* check if there's no keyframe/tracked markers before tracking marker.
if so -- create disabled marker before currently tracking "segment" */
- put_disabled_marker(track, marker, 1, 0);
+ put_disabled_marker(track, marker, !context->backwards, 0);
}
}
@@ -1311,7 +1311,7 @@ int BKE_tracking_next(MovieTrackingContext *context)
/* make currently tracked segment be finished with disabled marker */
#pragma omp critical
{
- put_disabled_marker(track, &marker_new, 0, 0);
+ put_disabled_marker(track, &marker_new, context->backwards, 0);
}
} else {
marker_new= *marker;
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index 616c27f6b0b..aa914998a72 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -494,7 +494,7 @@ static int unit_scale_str(char *str, int len_max, char *str_tmp, double scale_pr
len_name = strlen(replace_str);
len_move= (len - (found_ofs+len_name)) + 1; /* 1+ to copy the string terminator */
- len_num= BLI_snprintf(str_tmp, TEMP_STR_SIZE, "*%lg"SEP_STR, unit->scalar/scale_pref); /* # removed later */
+ len_num= BLI_snprintf(str_tmp, TEMP_STR_SIZE, "*%g"SEP_STR, unit->scalar/scale_pref); /* # removed later */
if(len_num > len_max)
len_num= len_max;
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index dee945ecd7d..c3fe50edcd3 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -1715,6 +1715,8 @@ void init_userdef_do_versions(void)
U.ndof_flag = NDOF_LOCK_HORIZON |
NDOF_SHOULD_PAN | NDOF_SHOULD_ZOOM | NDOF_SHOULD_ROTATE;
}
+ if (U.tweak_threshold == 0 )
+ U.tweak_threshold= 10;
/* funny name, but it is GE stuff, moves userdef stuff to engine */
// XXX space_set_commmandline_options();
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index 149c73e2980..c08c4034cdb 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -1608,7 +1608,7 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v
sel, sel_mirr, \
flip_map, flip_map_len, \
mirror_weights, flip_vgroups, \
- all_vgroups, act_vgroup \
+ all_vgroups, def_nr \
)
BMVert *eve, *eve_mirr;
@@ -1616,14 +1616,30 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v
MDeformVert *dvert, *dvert_mirr;
short sel, sel_mirr;
int *flip_map, flip_map_len;
- const int act_vgroup= ob->actdef > 0 ? ob->actdef-1 : 0;
+ const int def_nr= ob->actdef-1;
- if(mirror_weights==0 && flip_vgroups==0)
+ if ( (mirror_weights==0 && flip_vgroups==0) ||
+ (BLI_findlink(&ob->defbase, def_nr) == NULL) )
+ {
return;
+ }
- flip_map= all_vgroups ?
- defgroup_flip_map(ob, &flip_map_len, FALSE) :
- defgroup_flip_map_single(ob, &flip_map_len, FALSE, act_vgroup);
+ if (flip_vgroups) {
+ flip_map= all_vgroups ?
+ defgroup_flip_map(ob, &flip_map_len, FALSE) :
+ defgroup_flip_map_single(ob, &flip_map_len, FALSE, def_nr);
+
+ BLI_assert(flip_map != NULL);
+
+ if (flip_map == NULL) {
+ /* something went wrong!, possibly no groups */
+ return;
+ }
+ }
+ else {
+ flip_map= NULL;
+ flip_map_len= 0;
+ }
/* only the active group */
if(ob->type == OB_MESH) {
@@ -1634,8 +1650,7 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v
BMIter iter;
if(!CustomData_has_layer(&em->bm->vdata, CD_MDEFORMVERT)) {
- MEM_freeN(flip_map);
- return;
+ goto cleanup;
}
EDBM_CacheMirrorVerts(em, FALSE);
@@ -1659,7 +1674,6 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v
EDBM_ClearMirrorVert(em, eve_mirr);
}
}
-
EDBM_EndMirrorCache(em);
}
else {
@@ -1669,8 +1683,7 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v
const int use_vert_sel= (me->editflag & ME_EDIT_VERT_SEL) != 0;
if (me->dvert == NULL) {
- MEM_freeN(flip_map);
- return;
+ goto cleanup;
}
if (!use_vert_sel) {
@@ -1717,8 +1730,7 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v
if(lt->editlatt) lt= lt->editlatt->latt;
if(lt->pntsu == 1 || lt->dvert == NULL) {
- MEM_freeN(flip_map);
- return;
+ goto cleanup;
}
/* unlike editmesh we know that by only looping over the first hald of
@@ -1754,9 +1766,11 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v
}
}
- MEM_freeN(flip_map);
+cleanup:
+ if (flip_map) MEM_freeN(flip_map);
#undef VGROUP_MIRR_OP
+
}
static void vgroup_remap_update_users(Object *ob, int *map)
@@ -2738,6 +2752,7 @@ static int set_active_group_exec(bContext *C, wmOperator *op)
int nr= RNA_enum_get(op->ptr, "group");
ob->actdef= nr+1;
+ BLI_assert(ob->actdef >= 0);
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob);
@@ -2816,7 +2831,7 @@ static int vgroup_do_remap(Object *ob, char *name_array, wmOperator *op)
MDeformVert *dvert= NULL;
bDeformGroup *def;
int def_tot = BLI_countlist(&ob->defbase);
- int *sort_map_update= MEM_mallocN(MAX_VGROUP_NAME * sizeof(int) * def_tot + 1, "sort vgroups"); /* needs a dummy index at the start*/
+ int *sort_map_update= MEM_mallocN(sizeof(int) * (def_tot + 1), "sort vgroups"); /* needs a dummy index at the start*/
int *sort_map= sort_map_update + 1;
char *name;
int i;
@@ -2825,6 +2840,8 @@ static int vgroup_do_remap(Object *ob, char *name_array, wmOperator *op)
for(def= ob->defbase.first, i=0; def; def=def->next, i++){
sort_map[i]= BLI_findstringindex(&ob->defbase, name, offsetof(bDeformGroup, name));
name += MAX_VGROUP_NAME;
+
+ BLI_assert(sort_map[i] != -1);
}
if(ob->mode == OB_MODE_EDIT) {
@@ -2867,6 +2884,7 @@ static int vgroup_do_remap(Object *ob, char *name_array, wmOperator *op)
vgroup_remap_update_users(ob, sort_map_update);
ob->actdef= sort_map_update[ob->actdef];
+ BLI_assert(ob->actdef >= 0);
MEM_freeN(sort_map_update);
diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c
index dbd1e27024e..8a580627da3 100644
--- a/source/blender/editors/render/render_internal.c
+++ b/source/blender/editors/render/render_internal.c
@@ -378,8 +378,12 @@ static void render_progress_update(void *rjv, float progress)
{
RenderJob *rj= rjv;
- if(rj->progress)
+ if(rj->progress && *rj->progress != progress) {
*rj->progress = progress;
+
+ /* make jobs timer to send notifier */
+ *(rj->do_update)= 1;
+ }
}
static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrect)
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 7cc15cd4e77..05ae51b80fc 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -1102,6 +1102,7 @@ static int weight_sample_group_exec(bContext *C, wmOperator *op)
view3d_set_viewcontext(C, &vc);
vc.obact->actdef= type + 1;
+ BLI_assert(vc.obact->actdef >= 0);
DAG_id_tag_update(&vc.obact->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, vc.obact);
@@ -1959,10 +1960,13 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED
if(pchan) {
bDeformGroup *dg= defgroup_find_name(ob, pchan->name);
- if(dg==NULL)
+ if(dg==NULL) {
dg= ED_vgroup_add_name(ob, pchan->name); /* sets actdef */
- else
+ }
+ else {
ob->actdef= 1 + defgroup_find_index(ob, dg);
+ BLI_assert(ob->actdef >= 0);
+ }
}
}
}
@@ -2034,7 +2038,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
wpi.defbase_tot= wpd->defbase_tot;
wpi.defbase_sel= MEM_mallocN(wpi.defbase_tot*sizeof(char), "wpi.defbase_sel");
wpi.defbase_tot_sel= get_selected_defgroups(ob, wpi.defbase_sel, wpi.defbase_tot);
- if(wpi.defbase_tot_sel == 0 && ob->actdef) wpi.defbase_tot_sel = 1;
+ if(wpi.defbase_tot_sel == 0 && ob->actdef > 0) wpi.defbase_tot_sel = 1;
wpi.defbase_tot_unsel= wpi.defbase_tot - wpi.defbase_tot_sel;
wpi.vgroup_mirror= wpd->vgroup_mirror;
wpi.lock_flags= wpd->lock_flags;
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index aa50b3d5154..89547edaafa 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -397,6 +397,8 @@ static int tree_element_active_defgroup(bContext *C, Scene *scene, TreeElement *
ob= (Object *)tselem->id;
if(set) {
ob->actdef= te->index+1;
+ BLI_assert(ob->actdef >= 0);
+
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
}
diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c
index efa7837087a..cf61fe92814 100644
--- a/source/blender/editors/space_view3d/view3d_snap.c
+++ b/source/blender/editors/space_view3d/view3d_snap.c
@@ -94,9 +94,7 @@ static int tottrans= 0;
/* copied from editobject.c, now uses (almost) proper depgraph */
static void special_transvert_update(Object *obedit)
{
-
if(obedit) {
-
DAG_id_tag_update(obedit->data, 0);
if(obedit->type==OB_MESH) {
@@ -180,7 +178,7 @@ static void special_transvert_update(Object *obedit)
}
}
}
- if(arm->flag & ARM_MIRROR_EDIT)
+ if(arm->flag & ARM_MIRROR_EDIT)
transform_armature_mirror_update(obedit);
}
else if(obedit->type==OB_LATTICE) {
@@ -209,7 +207,7 @@ static void set_mapped_co(void *vuserdata, int index, float *co, float *UNUSED(n
/* mode flags: */
#define TM_ALL_JOINTS 1 /* all joints (for bones only) */
#define TM_SKIP_HANDLES 2 /* skip handles when control point is selected (for curves only) */
-static void make_trans_verts(Object *obedit, float *min, float *max, int mode)
+static void make_trans_verts(Object *obedit, float *min, float *max, int mode)
{
Nurb *nu;
BezTriple *bezt;
@@ -337,7 +335,7 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode)
if ((tipsel && rootsel) || (rootsel)) {
/* Don't add the tip (unless mode & TM_ALL_JOINTS, for getting all joints),
* otherwise we get zero-length bones as tips will snap to the same
- * location as heads.
+ * location as heads.
*/
if (rootok) {
copy_v3_v3(tv->oldloc, ebo->head);
@@ -355,7 +353,7 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode)
tv->flag= 1;
tv++;
tottrans++;
- }
+ }
}
else if (tipsel) {
copy_v3_v3(tv->oldloc, ebo->tail);
@@ -365,7 +363,7 @@ static void make_trans_verts(Object *obedit, float *min, float *max, int mode)
tv++;
tottrans++;
}
- }
+ }
}
}
else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
@@ -524,7 +522,7 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op))
if(obedit) {
tottrans= 0;
- if ELEM6(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL)
+ if ELEM6(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL)
make_trans_verts(obedit, bmat[0], bmat[1], 0);
if(tottrans==0) return OPERATOR_CANCELLED;
@@ -533,7 +531,6 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op))
tv= transvmain;
for(a=0; a<tottrans; a++, tv++) {
-
copy_v3_v3(vec, tv->loc);
mul_m3_v3(bmat, vec);
add_v3_v3(vec, obedit->obmat[3]);
@@ -550,7 +547,6 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op))
MEM_freeN(transvmain);
transvmain= NULL;
-
}
else {
struct KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_LOCATION_ID);
@@ -560,34 +556,42 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op))
bPoseChannel *pchan;
bArmature *arm= ob->data;
+ invert_m4_m4(ob->imat, ob->obmat);
+
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
if(pchan->bone->flag & BONE_SELECTED) {
if(pchan->bone->layer & arm->layer) {
- if((pchan->bone->flag & BONE_CONNECTED)==0) {
- float vecN[3], nLoc[3];
+ if((pchan->bone->flag & BONE_CONNECTED)==0) {
+ float nLoc[3];
+ float inv_restmat[4][4];
/* get nearest grid point to snap to */
copy_v3_v3(nLoc, pchan->pose_mat[3]);
+ /* We must operate in world space! */
+ mul_m4_v3(ob->obmat, nLoc);
vec[0]= gridf * (float)(floor(0.5f+ nLoc[0]/gridf));
vec[1]= gridf * (float)(floor(0.5f+ nLoc[1]/gridf));
vec[2]= gridf * (float)(floor(0.5f+ nLoc[2]/gridf));
+ /* Back in object space... */
+ mul_m4_v3(ob->imat, vec);
- /* get bone-space location of grid point */
- armature_loc_pose_to_bone(pchan, vec, vecN);
+ /* get location of grid point in *rest* bone-space */
+ invert_m4_m4(inv_restmat, pchan->bone->arm_mat);
+ mul_m4_v3(inv_restmat, vec);
/* adjust location */
- if ((pchan->protectflag & OB_LOCK_LOCX)==0)
- pchan->loc[0]= vecN[0];
- if ((pchan->protectflag & OB_LOCK_LOCY)==0)
- pchan->loc[0]= vecN[1];
- if ((pchan->protectflag & OB_LOCK_LOCZ)==0)
- pchan->loc[0]= vecN[2];
+ if ((pchan->protectflag & OB_LOCK_LOCX)==0)
+ pchan->loc[0]= vec[0];
+ if ((pchan->protectflag & OB_LOCK_LOCY)==0)
+ pchan->loc[1]= vec[1];
+ if ((pchan->protectflag & OB_LOCK_LOCZ)==0)
+ pchan->loc[2]= vec[2];
/* auto-keyframing */
ED_autokeyframe_pchan(C, scene, ob, pchan, ks);
}
- /* if the bone has a parent and is connected to the parent,
- * don't do anything - will break chain unless we do auto-ik.
+ /* if the bone has a parent and is connected to the parent,
+ * don't do anything - will break chain unless we do auto-ik.
*/
}
}
@@ -631,7 +635,6 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op))
void VIEW3D_OT_snap_selected_to_grid(wmOperatorType *ot)
{
-
/* identifiers */
ot->name= "Snap Selection to Grid";
ot->description= "Snap selected item(s) to nearest grid node";
@@ -662,7 +665,7 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op))
if(obedit) {
tottrans= 0;
- if ELEM6(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL)
+ if ELEM6(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL)
make_trans_verts(obedit, bmat[0], bmat[1], 0);
if(tottrans==0) return OPERATOR_CANCELLED;
@@ -680,7 +683,6 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op))
MEM_freeN(transvmain);
transvmain= NULL;
-
}
else {
struct KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_LOCATION_ID);
@@ -689,34 +691,34 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op))
if(ob->mode & OB_MODE_POSE) {
bPoseChannel *pchan;
bArmature *arm= ob->data;
- float cursp[3];
invert_m4_m4(ob->imat, ob->obmat);
- copy_v3_v3(cursp, curs);
- mul_m4_v3(ob->imat, cursp);
+ copy_v3_v3(vec, curs);
+ mul_m4_v3(ob->imat, vec);
for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) {
if(pchan->bone->flag & BONE_SELECTED) {
if(pchan->bone->layer & arm->layer) {
- if((pchan->bone->flag & BONE_CONNECTED)==0) {
- float curspn[3];
+ if((pchan->bone->flag & BONE_CONNECTED)==0) {
+ float inv_restmat[4][4];
- /* get location of cursor in bone-space */
- armature_loc_pose_to_bone(pchan, cursp, curspn);
+ /* get location of cursor in *rest* bone-space */
+ invert_m4_m4(inv_restmat, pchan->bone->arm_mat);
+ mul_m4_v3(inv_restmat, vec);
/* copy new position */
- if ((pchan->protectflag & OB_LOCK_LOCX)==0)
- pchan->loc[0]= curspn[0];
- if ((pchan->protectflag & OB_LOCK_LOCY)==0)
- pchan->loc[1]= curspn[1];
- if ((pchan->protectflag & OB_LOCK_LOCZ)==0)
- pchan->loc[2]= curspn[2];
+ if ((pchan->protectflag & OB_LOCK_LOCX)==0)
+ pchan->loc[0]= vec[0];
+ if ((pchan->protectflag & OB_LOCK_LOCY)==0)
+ pchan->loc[1]= vec[1];
+ if ((pchan->protectflag & OB_LOCK_LOCZ)==0)
+ pchan->loc[2]= vec[2];
/* auto-keyframing */
ED_autokeyframe_pchan(C, scene, ob, pchan, ks);
}
- /* if the bone has a parent and is connected to the parent,
- * don't do anything - will break chain unless we do auto-ik.
+ /* if the bone has a parent and is connected to the parent,
+ * don't do anything - will break chain unless we do auto-ik.
*/
}
}
@@ -760,7 +762,6 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op))
void VIEW3D_OT_snap_selected_to_cursor(wmOperatorType *ot)
{
-
/* identifiers */
ot->name= "Snap Selection to Cursor";
ot->description= "Snap selected item(s) to cursor";
@@ -797,7 +798,6 @@ static int snap_curs_to_grid(bContext *C, wmOperator *UNUSED(op))
void VIEW3D_OT_snap_cursor_to_grid(wmOperatorType *ot)
{
-
/* identifiers */
ot->name= "Snap Cursor to Grid";
ot->description= "Snap cursor to nearest grid node";
@@ -862,7 +862,7 @@ static int snap_curs_to_sel(bContext *C, wmOperator *UNUSED(op))
if(obedit) {
tottrans=0;
- if ELEM6(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL)
+ if ELEM6(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE, OB_MBALL)
make_trans_verts(obedit, bmat[0], bmat[1], TM_ALL_JOINTS|TM_SKIP_HANDLES);
if(tottrans==0) return OPERATOR_CANCELLED;
@@ -940,10 +940,9 @@ static int snap_curs_to_sel(bContext *C, wmOperator *UNUSED(op))
void VIEW3D_OT_snap_cursor_to_selected(wmOperatorType *ot)
{
-
/* identifiers */
ot->name= "Snap Cursor to Selected";
- ot->description= "Snap cursor to center of selected item(s)";
+ ot->description= "Snap cursor to center of selected item(s)";
ot->idname= "VIEW3D_OT_snap_cursor_to_selected";
/* api callbacks */
@@ -991,7 +990,6 @@ static int snap_curs_to_active(bContext *C, wmOperator *UNUSED(op))
void VIEW3D_OT_snap_cursor_to_active(wmOperatorType *ot)
{
-
/* identifiers */
ot->name= "Snap Cursor to Active";
ot->description= "Snap cursor to active item";
@@ -1025,13 +1023,12 @@ static int snap_curs_to_center(bContext *C, wmOperator *UNUSED(op))
void VIEW3D_OT_snap_cursor_to_center(wmOperatorType *ot)
{
-
/* identifiers */
ot->name= "Snap Cursor to Center";
ot->description= "Snap cursor to the Center";
ot->idname= "VIEW3D_OT_snap_cursor_to_center";
- /* api callbacks */
+ /* api callbacks */
ot->exec= snap_curs_to_center;
ot->poll= ED_operator_view3d_active;
@@ -1049,7 +1046,7 @@ int minmax_verts(Object *obedit, float *min, float *max)
int a;
tottrans=0;
- if ELEM5(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE)
+ if ELEM5(obedit->type, OB_ARMATURE, OB_LATTICE, OB_MESH, OB_SURF, OB_CURVE)
make_trans_verts(obedit, bmat[0], bmat[1], TM_ALL_JOINTS);
if(tottrans==0) return 0;
@@ -1057,12 +1054,12 @@ int minmax_verts(Object *obedit, float *min, float *max)
copy_m3_m4(bmat, obedit->obmat);
tv= transvmain;
- for(a=0; a<tottrans; a++, tv++) {
+ for(a=0; a<tottrans; a++, tv++) {
copy_v3_v3(vec, tv->maploc);
mul_m3_v3(bmat, vec);
add_v3_v3(vec, obedit->obmat[3]);
add_v3_v3(centroid, vec);
- DO_MINMAX(vec, min, max);
+ DO_MINMAX(vec, min, max);
}
MEM_freeN(transvmain);
diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h
index e4237197fca..8707ae038c3 100644
--- a/source/blender/makesdna/DNA_object_types.h
+++ b/source/blender/makesdna/DNA_object_types.h
@@ -219,7 +219,7 @@ typedef struct Object {
ListBase controllers; /* game logic controllers */
ListBase actuators; /* game logic actuators */
- float bbsize[3];
+ float bbsize[3] DNA_DEPRECATED;
short index; /* custom index, for renderpasses */
unsigned short actdef; /* current deformation group, note: index starts at 1 */
float col[4]; /* object color */
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 4f6c7e22f5e..851d4b562e6 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -408,7 +408,9 @@ typedef struct UserDef {
struct ColorBand coba_weight; /* from texture.h */
float sculpt_paint_overlay_col[3];
- int pad3;
+
+ short tweak_threshold;
+ short pad3;
char author[80]; /* author name for file formats supporting it */
} UserDef;
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index 0ea6b902150..f9b20d3ac78 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -2929,6 +2929,11 @@ static void rna_def_userdef_input(BlenderRNA *brna)
RNA_def_property_range(prop, 3, 40);
RNA_def_property_ui_text(prop, "Drag Threshold", "Amount of pixels you have to drag before dragging UI items happens");
+ prop= RNA_def_property(srna, "tweak_threshold", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "tweak_threshold");
+ RNA_def_property_range(prop, 3, 1024);
+ RNA_def_property_ui_text(prop, "Tweak Threshold", "Number of pixels you have to drag before tweak event is triggered");
+
/* 3D mouse settings */
/* global options */
prop= RNA_def_property(srna, "ndof_sensitivity", PROP_FLOAT, PROP_NONE);
diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c
index 34270c832ea..db408374b7f 100644
--- a/source/blender/python/intern/bpy_driver.c
+++ b/source/blender/python/intern/bpy_driver.c
@@ -82,9 +82,10 @@ int bpy_pydriver_create_dict(void)
}
/* add noise to global namespace */
- mod= PyImport_ImportModuleLevel((char *)"mathutils.noise", NULL, NULL, NULL, 0);
+ mod= PyImport_ImportModuleLevel((char *)"mathutils", NULL, NULL, NULL, 0);
if (mod) {
- PyDict_SetItemString(bpy_pydriver_Dict, "noise", mod);
+ PyObject *modsub= PyDict_GetItemString(PyModule_GetDict(mod), "noise");
+ PyDict_SetItemString(bpy_pydriver_Dict, "noise", modsub);
Py_DECREF(mod);
}
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index 56f8909ca8f..6940764c6ad 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -124,14 +124,13 @@ void WM_gestures_remove(bContext *C)
/* tweak and line gestures */
-#define TWEAK_THRESHOLD 10
int wm_gesture_evaluate(wmGesture *gesture)
{
if(gesture->type==WM_GESTURE_TWEAK) {
rcti *rect= gesture->customdata;
int dx= rect->xmax - rect->xmin;
int dy= rect->ymax - rect->ymin;
- if(ABS(dx)+ABS(dy) > TWEAK_THRESHOLD) {
+ if(ABS(dx)+ABS(dy) > U.tweak_threshold) {
int theta= (int)floor(4.0f*atan2f((float)dy, (float)dx)/(float)M_PI + 0.5f);
int val= EVT_GESTURE_W;