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:
authorSergey Sharybin <sergey.vfx@gmail.com>2011-12-07 13:24:45 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2011-12-07 13:24:45 +0400
commitf354d44cbad105fc63c64c2cb243c4ceaa8d0ef0 (patch)
tree27693de0fbf3df09e3f6403e71c6c587dd19a904 /source
parenta0723afe2016396473fe32801e7b7b9339c9f027 (diff)
parent433033c2bf4b72e389d103e00a375d344588ac8e (diff)
Merging r42461 through r42481 from trunk into soc-2011-tomato
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c61
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c2
-rw-r--r--source/blender/blenkernel/intern/tracking.c9
-rw-r--r--source/blender/editors/mesh/editmesh.c2
-rw-r--r--source/blender/editors/object/object_vgroup.c48
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c10
-rw-r--r--source/blender/editors/space_node/node_draw.c10
-rw-r--r--source/blender/editors/space_outliner/outliner_select.c2
-rw-r--r--source/blender/makesdna/DNA_object_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_nodetree.c13
-rw-r--r--source/blender/python/intern/bpy_driver.c5
11 files changed, 103 insertions, 61 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index 795b36813e1..5c80038a50d 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -60,6 +60,7 @@
#include "BKE_texture.h"
#include "BKE_multires.h"
#include "BKE_armature.h"
+#include "BKE_deform.h"
#ifdef WITH_GAMEENGINE
#include "BKE_navmesh_conversion.h"
@@ -625,40 +626,49 @@ 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)
{
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) {
@@ -667,11 +677,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);
}
}
@@ -680,20 +686,23 @@ 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);
+ colf[0]= colf[1]= colf[2]= -1;
- 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;
+ 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;
+ }
}
static ColorBand *stored_cb= NULL;
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index e8e9c754806..718b3144677 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -1581,7 +1581,7 @@ typedef struct WipeZone {
static void precalc_wipe_zone(WipeZone *wipezone, WipeVars *wipe, int xo, int yo)
{
wipezone->flip = (wipe->angle < 0);
- wipezone->angle = pow(fabsf(wipe->angle)/45.0f, log(xo)/M_LN2);
+ wipezone->angle = tan(DEG2RAD(fabsf(wipe->angle)));
wipezone->xo = xo;
wipezone->yo = yo;
wipezone->width = (int)(wipe->edgeWidth*((xo+yo)/2.0f));
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index e7f99990dc5..d1929e25c40 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -1232,7 +1232,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;
@@ -1248,7 +1248,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);
@@ -1361,7 +1362,7 @@ int BKE_tracking_next(MovieTrackingContext *context)
{
/* 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);
}
}
@@ -1385,7 +1386,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/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c
index 159ef3a46c7..1477469ca85 100644
--- a/source/blender/editors/mesh/editmesh.c
+++ b/source/blender/editors/mesh/editmesh.c
@@ -1575,7 +1575,7 @@ void MESH_OT_separate(wmOperatorType *ot)
ot->poll= ED_operator_editmesh;
/* flags */
- ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag= OPTYPE_UNDO;
ot->prop= RNA_def_enum(ot->srna, "type", prop_separate_types, 0, "Type", "");
}
diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c
index 55d72bcf165..b809fd5dbb1 100644
--- a/source/blender/editors/object/object_vgroup.c
+++ b/source/blender/editors/object/object_vgroup.c
@@ -1608,21 +1608,37 @@ 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 \
)
EditVert *eve, *eve_mirr;
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) {
@@ -1631,8 +1647,7 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v
if (em) {
if(!CustomData_has_layer(&em->vdata, CD_MDEFORMVERT)) {
- MEM_freeN(flip_map);
- return;
+ goto cleanup;
}
EM_cache_x_mirror_vert(ob, em);
@@ -1654,7 +1669,6 @@ void ED_vgroup_mirror(Object *ob, const short mirror_weights, const short flip_v
eve->tmp.v= eve_mirr->tmp.v= NULL;
}
}
-
BKE_mesh_end_editmesh(me, em);
}
else {
@@ -1664,8 +1678,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) {
@@ -1712,8 +1725,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
@@ -1749,9 +1761,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)
@@ -2733,6 +2747,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);
@@ -2811,7 +2826,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;
@@ -2820,6 +2835,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) {
@@ -2861,6 +2878,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/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index a5bd38d6696..9cc81df6ce5 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -1022,6 +1022,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);
@@ -1879,10 +1880,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);
+ }
}
}
}
@@ -1954,7 +1958,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_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index 02a8b5cc9fb..67b4c43343e 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -605,15 +605,11 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
iconofs= rct->xmax - 7.0f;
if(node->typeinfo->flag & NODE_PREVIEW) {
- int icon_id;
+ float alpha = (node->flag & (NODE_ACTIVE_ID|NODE_DO_OUTPUT))? 1.0f: 0.5f;
- if(node->flag & (NODE_ACTIVE_ID|NODE_DO_OUTPUT))
- icon_id= ICON_MATERIAL;
- else
- icon_id= ICON_MATERIAL_DATA;
iconofs-=iconbutw;
- uiDefIconBut(node->block, LABEL, B_REDR, icon_id, iconofs, rct->ymax-NODE_DY,
- iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, 0.5, "");
+ uiDefIconBut(node->block, LABEL, B_REDR, ICON_MATERIAL, iconofs, rct->ymax-NODE_DY,
+ iconbutw, UI_UNIT_Y, NULL, 0.0, 0.0, 1.0, alpha, "");
}
if(node->type == NODE_GROUP) {
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/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/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c
index 8e567d0ac70..c588dc9c8ac 100644
--- a/source/blender/makesrna/intern/rna_nodetree.c
+++ b/source/blender/makesrna/intern/rna_nodetree.c
@@ -365,6 +365,17 @@ static void rna_Node_update(Main *bmain, Scene *scene, PointerRNA *ptr)
node_update(bmain, scene, ntree, node);
}
+static void rna_Node_material_update(Main *bmain, Scene *scene, PointerRNA *ptr)
+{
+ bNodeTree *ntree= (bNodeTree*)ptr->id.data;
+ bNode *node= (bNode*)ptr->data;
+
+ if(node->id)
+ nodeSetActive(ntree, node);
+
+ node_update(bmain, scene, ntree, node);
+}
+
static void rna_NodeGroup_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
bNodeTree *ntree= (bNodeTree*)ptr->id.data;
@@ -1119,7 +1130,7 @@ static void def_sh_material(StructRNA *srna)
RNA_def_property_struct_type(prop, "Material");
RNA_def_property_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Material", "");
- RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+ RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_material_update");
prop = RNA_def_property(srna, "use_diffuse", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "custom1", SH_NODE_MAT_DIFF);
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);
}