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
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/mesh/editmesh_select_similar.c54
-rw-r--r--source/blender/editors/object/object_constraint.c2
-rw-r--r--source/blender/editors/object/object_relations.c4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_cloth.c34
-rw-r--r--source/blender/editors/space_graph/graph_utils.c2
-rw-r--r--source/blender/editors/space_text/text_ops.c4
-rw-r--r--source/blender/editors/transform/transform_convert_gpencil.c56
-rw-r--r--source/blender/editors/transform/transform_convert_particle.c2
-rw-r--r--source/blender/editors/transform/transform_snap.c15
9 files changed, 111 insertions, 62 deletions
diff --git a/source/blender/editors/mesh/editmesh_select_similar.c b/source/blender/editors/mesh/editmesh_select_similar.c
index 365c5b5d264..635fc6279ea 100644
--- a/source/blender/editors/mesh/editmesh_select_similar.c
+++ b/source/blender/editors/mesh/editmesh_select_similar.c
@@ -23,6 +23,7 @@
#include "MEM_guardedalloc.h"
+#include "BLI_bitmap.h"
#include "BLI_kdtree.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
@@ -1007,7 +1008,9 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
BMEditMesh *em = BKE_editmesh_from_object(ob);
BMesh *bm = em->bm;
int cd_dvert_offset = -1;
- int dvert_selected = 0;
+ BLI_bitmap *defbase_selected = NULL;
+ int defbase_len = 0;
+
invert_m4_m4(ob->imat, ob->obmat);
if (bm->totvertsel == 0) {
@@ -1019,6 +1022,11 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
if (cd_dvert_offset == -1) {
continue;
}
+ defbase_len = BLI_listbase_count(&ob->defbase);
+ if (defbase_len == 0) {
+ continue;
+ }
+ defbase_selected = BLI_BITMAP_NEW(defbase_len, __func__);
}
BMVert *vert; /* Mesh vertex. */
@@ -1048,7 +1056,9 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
for (int i = 0; i < dvert->totweight; i++, dw++) {
if (dw->weight > 0.0f) {
- dvert_selected |= (1 << dw->def_nr);
+ if (LIKELY(dw->def_nr < defbase_len)) {
+ BLI_BITMAP_ENABLE(defbase_selected, dw->def_nr);
+ }
}
}
break;
@@ -1060,13 +1070,15 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
if (type == SIMVERT_VGROUP) {
/* We store the names of the vertex groups, so we can select
* vertex groups with the same name in different objects. */
- const int dvert_tot = BLI_listbase_count(&ob->defbase);
- for (int i = 0; i < dvert_tot; i++) {
- if (dvert_selected & (1 << i)) {
- bDeformGroup *dg = BLI_findlink(&ob->defbase, i);
+
+ int i = 0;
+ LISTBASE_FOREACH (bDeformGroup *, dg, &ob->defbase) {
+ if (BLI_BITMAP_TEST(defbase_selected, i)) {
BLI_gset_add(gset, dg->name);
}
+ i += 1;
}
+ MEM_freeN(defbase_selected);
}
}
@@ -1082,32 +1094,42 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
BLI_kdtree_3d_balance(tree_3d);
}
- /* Run .the BM operators. */
+ /* Run the matching operations. */
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *ob = objects[ob_index];
BMEditMesh *em = BKE_editmesh_from_object(ob);
BMesh *bm = em->bm;
bool changed = false;
int cd_dvert_offset = -1;
- int dvert_selected = 0;
+ BLI_bitmap *defbase_selected = NULL;
+ int defbase_len = 0;
if (type == SIMVERT_VGROUP) {
cd_dvert_offset = CustomData_get_offset(&bm->vdata, CD_MDEFORMVERT);
if (cd_dvert_offset == -1) {
continue;
}
+ defbase_len = BLI_listbase_count(&ob->defbase);
+ if (defbase_len == 0) {
+ continue;
+ }
/* We map back the names of the vertex groups to their corresponding indices
* for this object. This is fast, and keep the logic for each vertex very simple. */
+
+ defbase_selected = BLI_BITMAP_NEW(defbase_len, __func__);
+ bool found_any = false;
GSetIterator gs_iter;
GSET_ITER (gs_iter, gset) {
const char *name = BLI_gsetIterator_getKey(&gs_iter);
int vgroup_id = BLI_findstringindex(&ob->defbase, name, offsetof(bDeformGroup, name));
if (vgroup_id != -1) {
- dvert_selected |= (1 << vgroup_id);
+ BLI_BITMAP_ENABLE(defbase_selected, vgroup_id);
+ found_any = true;
}
}
- if (dvert_selected == 0) {
+ if (found_any == false) {
+ MEM_freeN(defbase_selected);
continue;
}
}
@@ -1167,9 +1189,11 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
for (int i = 0; i < dvert->totweight; i++, dw++) {
if (dw->weight > 0.0f) {
- if (dvert_selected & (1 << dw->def_nr)) {
- select = true;
- break;
+ if (LIKELY(dw->def_nr < defbase_len)) {
+ if (BLI_BITMAP_TEST(defbase_selected, dw->def_nr)) {
+ select = true;
+ break;
+ }
}
}
}
@@ -1184,6 +1208,10 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
}
}
+ if (type == SIMVERT_VGROUP) {
+ MEM_freeN(defbase_selected);
+ }
+
if (changed) {
EDBM_selectmode_flush(em);
EDBM_update_generic(ob->data, false, false);
diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c
index 1e04355c9a7..a2d33ffe413 100644
--- a/source/blender/editors/object/object_constraint.c
+++ b/source/blender/editors/object/object_constraint.c
@@ -678,7 +678,7 @@ static bool edit_constraint_poll_generic(bContext *C, StructRNA *rna_type)
return 0;
}
- if (ID_IS_OVERRIDE_LIBRARY(ob)) {
+ if (ID_IS_OVERRIDE_LIBRARY(ob) && ptr.data != NULL) {
CTX_wm_operator_poll_msg_set(C, "Cannot edit constraints coming from library override");
return (((bConstraint *)ptr.data)->flag & CONSTRAINT_OVERRIDE_LIBRARY_LOCAL) != 0;
}
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index eed3f2ea90c..fd2fcb11635 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -2400,10 +2400,6 @@ static int make_override_library_exec(bContext *C, wmOperator *op)
/* TODO: is setting active needed? */
BKE_view_layer_base_select_and_set_active(view_layer, base);
}
- else {
- /* Disable auto-override tags for non-active objects, will help with performaces... */
- new_ob->id.override_library->flag &= ~OVERRIDE_LIBRARY_AUTO;
- }
/* We still want to store all objects' current override status (i.e. change of parent). */
BKE_lib_override_library_operations_create(bmain, &new_ob->id, true);
}
diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c b/source/blender/editors/sculpt_paint/sculpt_cloth.c
index 3203282c30c..7776af11a77 100644
--- a/source/blender/editors/sculpt_paint/sculpt_cloth.c
+++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c
@@ -106,6 +106,27 @@
#define CLOTH_MAX_CONSTRAINTS_PER_VERTEX 1024
#define CLOTH_SIMULATION_TIME_STEP 0.01f
+static void cloth_brush_constraint_key_get(int r_key[2], const int v1, const int v2)
+{
+ if (v1 < v2) {
+ r_key[0] = v1;
+ r_key[1] = v2;
+ }
+ else {
+ r_key[0] = v2;
+ r_key[1] = v1;
+ }
+}
+
+static bool cloth_brush_sim_has_length_constraint(SculptClothSimulation *cloth_sim,
+ const int v1,
+ const int v2)
+{
+ int constraint[2];
+ cloth_brush_constraint_key_get(constraint, v1, v2);
+ return BLI_gset_haskey(cloth_sim->created_length_constraints, constraint);
+}
+
static void cloth_brush_add_length_constraint(SculptSession *ss,
SculptClothSimulation *cloth_sim,
const int v1,
@@ -126,6 +147,11 @@ static void cloth_brush_add_length_constraint(SculptSession *ss,
sizeof(SculptClothLengthConstraint),
"length constraints");
}
+
+ /* Add the constraint to the GSet to avoid creating it again. */
+ int constraint[2];
+ cloth_brush_constraint_key_get(constraint, v1, v2);
+ BLI_gset_add(cloth_sim->created_length_constraints, constraint);
}
static void do_cloth_brush_build_constraints_task_cb_ex(
@@ -159,7 +185,8 @@ static void do_cloth_brush_build_constraints_task_cb_ex(
for (int c_i = 0; c_i < tot_indices; c_i++) {
for (int c_j = 0; c_j < tot_indices; c_j++) {
- if (c_i != c_j) {
+ if (c_i != c_j && !cloth_brush_sim_has_length_constraint(
+ data->cloth_sim, build_indices[c_i], build_indices[c_j])) {
cloth_brush_add_length_constraint(
ss, data->cloth_sim, build_indices[c_i], build_indices[c_j]);
}
@@ -445,6 +472,9 @@ static void cloth_brush_build_nodes_constraints(Sculpt *sd,
TaskParallelSettings settings;
BKE_pbvh_parallel_range_settings(&settings, false, totnode);
+ cloth_sim->created_length_constraints = BLI_gset_new(
+ BLI_ghashutil_inthash_v2_p, BLI_ghashutil_inthash_v2_cmp, "created length constraints");
+
SculptThreadedTaskData build_constraints_data = {
.sd = sd,
.ob = ob,
@@ -456,6 +486,8 @@ static void cloth_brush_build_nodes_constraints(Sculpt *sd,
};
BLI_task_parallel_range(
0, totnode, &build_constraints_data, do_cloth_brush_build_constraints_task_cb_ex, &settings);
+
+ BLI_gset_free(cloth_sim->created_length_constraints, NULL);
}
static void cloth_brush_satisfy_constraints(SculptSession *ss,
diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c
index 03ed8870d67..6d08fd00cab 100644
--- a/source/blender/editors/space_graph/graph_utils.c
+++ b/source/blender/editors/space_graph/graph_utils.c
@@ -52,7 +52,7 @@
/* Set Up Drivers Editor */
/* Set up UI configuration for Drivers Editor */
-/* NOTE: Currently called from windowmanager
+/* NOTE: Currently called from window-manager
* (new drivers editor window) and RNA (mode switching) */
void ED_drivers_editor_init(bContext *C, ScrArea *area)
{
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index fa378954a30..e50b25de412 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -3667,7 +3667,7 @@ static int text_find_set_selected_exec(bContext *C, wmOperator *op)
void TEXT_OT_find_set_selected(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Find Set Selected";
+ ot->name = "Find & Set Selection";
ot->idname = "TEXT_OT_find_set_selected";
ot->description = "Find specified text and set as selected";
@@ -3698,7 +3698,7 @@ static int text_replace_set_selected_exec(bContext *C, wmOperator *UNUSED(op))
void TEXT_OT_replace_set_selected(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "Replace Set Selected";
+ ot->name = "Replace & Set Selection";
ot->idname = "TEXT_OT_replace_set_selected";
ot->description = "Replace text with specified text and set as selected";
diff --git a/source/blender/editors/transform/transform_convert_gpencil.c b/source/blender/editors/transform/transform_convert_gpencil.c
index 2bfce9f8418..22261b9bbd8 100644
--- a/source/blender/editors/transform/transform_convert_gpencil.c
+++ b/source/blender/editors/transform/transform_convert_gpencil.c
@@ -26,6 +26,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_ghash.h"
+#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BKE_colortools.h"
@@ -76,7 +77,6 @@ void createTransGPencil(bContext *C, TransInfo *t)
bool use_multiframe_falloff = (ts->gp_sculpt.flag & GP_SCULPT_SETT_FLAG_FRAME_FALLOFF) != 0;
Object *obact = CTX_data_active_object(C);
- bGPDlayer *gpl;
TransData *td = NULL;
float mtx[3][3], smtx[3][3];
@@ -110,15 +110,12 @@ void createTransGPencil(bContext *C, TransInfo *t)
/* First Pass: Count the number of data-points required for the strokes,
* (and additional info about the configuration - e.g. 2D/3D?).
*/
- for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
- /* only editable and visible layers are considered */
+ LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
+ /* Only editable and visible layers are considered. */
if (BKE_gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) {
bGPDframe *gpf;
bGPDstroke *gps;
- bGPDframe *init_gpf = gpl->actframe;
- if (is_multiedit) {
- init_gpf = gpl->frames.first;
- }
+ bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
for (gpf = init_gpf; gpf; gpf = gpf->next) {
if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) {
@@ -127,7 +124,7 @@ void createTransGPencil(bContext *C, TransInfo *t)
if (ED_gpencil_stroke_can_use(C, gps) == false) {
continue;
}
- /* check if the color is editable */
+ /* Check if the color is editable. */
if (ED_gpencil_stroke_color_use(obact, gpl, gps) == false) {
continue;
}
@@ -135,23 +132,22 @@ void createTransGPencil(bContext *C, TransInfo *t)
if (is_prop_edit) {
/* Proportional Editing... */
if (is_prop_edit_connected) {
- /* connected only - so only if selected */
+ /* Connected only - so only if selected. */
if (gps->flag & GP_STROKE_SELECT) {
tc->data_len += gps->totpoints;
}
}
else {
- /* everything goes - connection status doesn't matter */
+ /* Everything goes - connection status doesn't matter. */
tc->data_len += gps->totpoints;
}
}
else {
- /* only selected stroke points are considered */
+ /* Only selected stroke points are considered. */
if (gps->flag & GP_STROKE_SELECT) {
bGPDspoint *pt;
int i;
- // TODO: 2D vs 3D?
for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
if (pt->flag & GP_SPOINT_SELECT) {
tc->data_len++;
@@ -161,7 +157,7 @@ void createTransGPencil(bContext *C, TransInfo *t)
}
}
}
- /* if not multiedit out of loop */
+ /* If not multiedit out of loop. */
if (!is_multiedit) {
break;
}
@@ -169,7 +165,7 @@ void createTransGPencil(bContext *C, TransInfo *t)
}
}
- /* Stop trying if nothing selected */
+ /* Stop trying if nothing selected. */
if (tc->data_len == 0) {
return;
}
@@ -181,21 +177,17 @@ void createTransGPencil(bContext *C, TransInfo *t)
unit_m3(smtx);
unit_m3(mtx);
- /* Second Pass: Build transdata array */
- for (gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ /* Second Pass: Build transdata array. */
+ LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
/* only editable and visible layers are considered */
if (BKE_gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) {
const int cfra = (gpl->flag & GP_LAYER_FRAMELOCK) ? gpl->actframe->framenum : cfra_scene;
bGPDframe *gpf = gpl->actframe;
- bGPDstroke *gps;
float diff_mat[4][4];
float inverse_diff_mat[4][4];
- bGPDframe *init_gpf = gpl->actframe;
- if (is_multiedit) {
- init_gpf = gpl->frames.first;
- }
- /* init multiframe falloff options */
+ bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe;
+ /* Init multiframe falloff options. */
int f_init = 0;
int f_end = 0;
@@ -203,9 +195,9 @@ void createTransGPencil(bContext *C, TransInfo *t)
BKE_gpencil_frame_range_selected(gpl, &f_init, &f_end);
}
- /* calculate difference matrix */
+ /* Calculate difference matrix. */
BKE_gpencil_parent_matrix_get(depsgraph, obact, gpl, diff_mat);
- /* undo matrix */
+ /* Undo matrix. */
invert_m4_m4(inverse_diff_mat, diff_mat);
/* Make a new frame to work on if the layer's frame
@@ -214,7 +206,6 @@ void createTransGPencil(bContext *C, TransInfo *t)
* - This is useful when animating as it saves that "uh-oh" moment when you realize you've
* spent too much time editing the wrong frame...
*/
- // XXX: should this be allowed when framelock is enabled?
if ((gpf->framenum != cfra) && (!is_multiedit)) {
gpf = BKE_gpencil_frame_addcopy(gpl, cfra);
/* in some weird situations (framelock enabled) return NULL */
@@ -239,7 +230,7 @@ void createTransGPencil(bContext *C, TransInfo *t)
gpf, gpl->actframe->framenum, f_init, f_end, ts->gp_sculpt.cur_falloff);
}
- for (gps = gpf->strokes.first; gps; gps = gps->next) {
+ LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
TransData *head = td;
TransData *tail = td;
bool stroke_ok;
@@ -286,20 +277,20 @@ void createTransGPencil(bContext *C, TransInfo *t)
/* include point? */
if (is_prop_edit) {
- /* Always all points in strokes that get included */
+ /* Always all points in strokes that get included. */
point_ok = true;
}
else {
- /* Only selected points in selected strokes */
+ /* Only selected points in selected strokes. */
point_ok = (pt->flag & GP_SPOINT_SELECT) != 0;
}
/* do point... */
if (point_ok) {
copy_v3_v3(td->iloc, &pt->x);
- /* only copy center in local origins.
+ /* Only copy center in local origins.
* This allows get interesting effects also when move
- * using proportional editing */
+ * using proportional editing. */
if ((gps->flag & GP_STROKE_SELECT) &&
(ts->transform_pivot_point == V3D_AROUND_LOCAL_ORIGINS)) {
copy_v3_v3(td->center, center);
@@ -316,8 +307,8 @@ void createTransGPencil(bContext *C, TransInfo *t)
td->flag |= TD_SELECTED;
}
- /* for other transform modes (e.g. shrink-fatten), need to additional data
- * but never for mirror
+ /* For other transform modes (e.g. shrink-fatten), need to additional data
+ * but never for mirror.
*/
if (t->mode != TFM_MIRROR) {
if (t->mode != TFM_GPENCIL_OPACITY) {
@@ -363,7 +354,6 @@ void createTransGPencil(bContext *C, TransInfo *t)
/* March over these points, and calculate the proportional editing distances */
if (is_prop_edit && (head != tail)) {
- /* XXX: for now, we are similar enough that this works... */
calc_distanceCurveVerts(head, tail - 1);
}
}
diff --git a/source/blender/editors/transform/transform_convert_particle.c b/source/blender/editors/transform/transform_convert_particle.c
index 5feaa70ba19..3fa722d14cf 100644
--- a/source/blender/editors/transform/transform_convert_particle.c
+++ b/source/blender/editors/transform/transform_convert_particle.c
@@ -250,7 +250,7 @@ static void flushTransParticles(TransInfo *t)
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Recalc Trasform Particles Data
+/** \name Recalc Transform Particles Data
*
* \{ */
diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c
index c6d7b92fb42..4f942221f79 100644
--- a/source/blender/editors/transform/transform_snap.c
+++ b/source/blender/editors/transform/transform_snap.c
@@ -634,12 +634,15 @@ static void initSnappingMode(TransInfo *t)
t->tsnap.object_context = ED_transform_snap_object_context_create_view3d(
t->scene, 0, t->region, t->view);
- ED_transform_snap_object_context_set_editmesh_callbacks(
- t->tsnap.object_context,
- (bool (*)(BMVert *, void *))BM_elem_cb_check_hflag_disabled,
- bm_edge_is_snap_target,
- bm_face_is_snap_target,
- POINTER_FROM_UINT((BM_ELEM_SELECT | BM_ELEM_HIDDEN)));
+ if (t->data_type == TC_MESH_VERTS) {
+ /* Ignore elements being transformed. */
+ ED_transform_snap_object_context_set_editmesh_callbacks(
+ t->tsnap.object_context,
+ (bool (*)(BMVert *, void *))BM_elem_cb_check_hflag_disabled,
+ bm_edge_is_snap_target,
+ bm_face_is_snap_target,
+ POINTER_FROM_UINT((BM_ELEM_SELECT | BM_ELEM_HIDDEN)));
+ }
}
}
}