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:
authorHans Goudey <h.goudey@me.com>2022-08-03 06:17:46 +0300
committerHans Goudey <h.goudey@me.com>2022-08-03 06:17:46 +0300
commitd9683a5937fe6e55c309df06a47b9d551902d5bc (patch)
tree6e384ec5bbf5ca58c4e5913efdf596ff7f398a1a /source/blender/editors
parent41fb4bedb81603956d8a8f1b61614fd6f920a71a (diff)
parent43918ec28d12124cfa32b3e84ead1bfb65501f6f (diff)
Merge branch 'master' into refactor-mesh-hide-generic
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/include/ED_mesh.h14
-rw-r--r--source/blender/editors/mesh/mesh_data.cc243
-rw-r--r--source/blender/editors/mesh/mesh_intern.h4
-rw-r--r--source/blender/editors/mesh/mesh_ops.c4
-rw-r--r--source/blender/editors/object/object_add.cc5
-rw-r--r--source/blender/editors/physics/dynamicpaint_ops.c3
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_ops.c147
-rw-r--r--source/blender/editors/space_sequencer/sequencer_drag_drop.c293
-rw-r--r--source/blender/editors/uvedit/uvedit_intern.h3
-rw-r--r--source/blender/editors/uvedit/uvedit_ops.c9
10 files changed, 208 insertions, 517 deletions
diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h
index 9d7072ffbe1..8ecd1d850d1 100644
--- a/source/blender/editors/include/ED_mesh.h
+++ b/source/blender/editors/include/ED_mesh.h
@@ -555,16 +555,10 @@ void ED_mesh_uv_loop_reset_ex(struct Mesh *me, int layernum);
bool ED_mesh_color_ensure(struct Mesh *me, const char *name);
int ED_mesh_color_add(
struct Mesh *me, const char *name, bool active_set, bool do_init, struct ReportList *reports);
-bool ED_mesh_color_remove_index(struct Mesh *me, int n);
-bool ED_mesh_color_remove_active(struct Mesh *me);
-bool ED_mesh_color_remove_named(struct Mesh *me, const char *name);
-
-bool ED_mesh_sculpt_color_ensure(struct Mesh *me, const char *name);
-int ED_mesh_sculpt_color_add(
- struct Mesh *me, const char *name, bool active_set, bool do_init, struct ReportList *reports);
-bool ED_mesh_sculpt_color_remove_index(struct Mesh *me, int n);
-bool ED_mesh_sculpt_color_remove_active(struct Mesh *me);
-bool ED_mesh_sculpt_color_remove_named(struct Mesh *me, const char *name);
+int ED_mesh_sculpt_color_add(struct Mesh *me,
+ const char *name,
+ bool do_init,
+ struct ReportList *reports);
void ED_mesh_report_mirror(struct wmOperator *op, int totmirr, int totfail);
void ED_mesh_report_mirror_ex(struct wmOperator *op, int totmirr, int totfail, char selectmode);
diff --git a/source/blender/editors/mesh/mesh_data.cc b/source/blender/editors/mesh/mesh_data.cc
index 67834bf05ce..971fab1508e 100644
--- a/source/blender/editors/mesh/mesh_data.cc
+++ b/source/blender/editors/mesh/mesh_data.cc
@@ -444,44 +444,6 @@ bool ED_mesh_color_ensure(Mesh *me, const char *name)
return (layer != nullptr);
}
-bool ED_mesh_color_remove_index(Mesh *me, const int n)
-{
- CustomData *ldata = GET_CD_DATA(me, ldata);
- CustomDataLayer *cdl;
- int index;
-
- index = CustomData_get_layer_index_n(ldata, CD_PROP_BYTE_COLOR, n);
- cdl = (index == -1) ? nullptr : &ldata->layers[index];
-
- if (!cdl) {
- return false;
- }
-
- delete_customdata_layer(me, cdl);
- DEG_id_tag_update(&me->id, 0);
- WM_main_add_notifier(NC_GEOM | ND_DATA, me);
-
- return true;
-}
-bool ED_mesh_color_remove_active(Mesh *me)
-{
- CustomData *ldata = GET_CD_DATA(me, ldata);
- const int n = CustomData_get_active_layer(ldata, CD_PROP_BYTE_COLOR);
- if (n != -1) {
- return ED_mesh_color_remove_index(me, n);
- }
- return false;
-}
-bool ED_mesh_color_remove_named(Mesh *me, const char *name)
-{
- CustomData *ldata = GET_CD_DATA(me, ldata);
- const int n = CustomData_get_named_layer(ldata, CD_PROP_BYTE_COLOR, name);
- if (n != -1) {
- return ED_mesh_color_remove_index(me, n);
- }
- return false;
-}
-
/*********************** General poll ************************/
static bool layers_poll(bContext *C)
@@ -494,25 +456,7 @@ static bool layers_poll(bContext *C)
/*********************** Sculpt Vertex colors operators ************************/
-static bool sculpt_vertex_color_remove_poll(bContext *C)
-{
- if (!layers_poll(C)) {
- return false;
- }
-
- Object *ob = ED_object_context(C);
- Mesh *me = static_cast<Mesh *>(ob->data);
- CustomData *vdata = GET_CD_DATA(me, vdata);
- const int active = CustomData_get_active_layer(vdata, CD_PROP_COLOR);
- if (active != -1) {
- return true;
- }
-
- return false;
-}
-
-int ED_mesh_sculpt_color_add(
- Mesh *me, const char *name, const bool active_set, const bool do_init, ReportList *reports)
+int ED_mesh_sculpt_color_add(Mesh *me, const char *name, const bool do_init, ReportList *reports)
{
/* NOTE: keep in sync with #ED_mesh_uv_add. */
@@ -536,7 +480,7 @@ int ED_mesh_sculpt_color_add(
const int layernum_dst = CustomData_get_active_layer(&em->bm->vdata, CD_PROP_COLOR);
BM_data_layer_copy(em->bm, &em->bm->vdata, CD_PROP_COLOR, layernum_dst, layernum);
}
- if (active_set || layernum == 0) {
+ if (layernum == 0) {
CustomData_set_layer_active(&em->bm->vdata, CD_PROP_COLOR, layernum);
}
}
@@ -559,7 +503,7 @@ int ED_mesh_sculpt_color_add(
&me->vdata, CD_PROP_COLOR, CD_DEFAULT, nullptr, me->totvert, name);
}
- if (active_set || layernum == 0) {
+ if (layernum == 0) {
CustomData_set_layer_active(&me->vdata, CD_PROP_COLOR, layernum);
}
@@ -572,58 +516,6 @@ int ED_mesh_sculpt_color_add(
return layernum;
}
-bool ED_mesh_sculpt_color_ensure(Mesh *me, const char *name)
-{
- BLI_assert(me->edit_mesh == nullptr);
-
- if (me->totvert && !CustomData_has_layer(&me->vdata, CD_PROP_COLOR)) {
- CustomData_add_layer_named(&me->vdata, CD_PROP_COLOR, CD_DEFAULT, nullptr, me->totvert, name);
- BKE_mesh_update_customdata_pointers(me, true);
- }
-
- DEG_id_tag_update(&me->id, 0);
-
- return (me->mloopcol != nullptr);
-}
-
-bool ED_mesh_sculpt_color_remove_index(Mesh *me, const int n)
-{
- CustomData *vdata = GET_CD_DATA(me, vdata);
- CustomDataLayer *cdl;
- int index;
-
- index = CustomData_get_layer_index_n(vdata, CD_PROP_COLOR, n);
- cdl = (index == -1) ? nullptr : &vdata->layers[index];
-
- if (!cdl) {
- return false;
- }
-
- delete_customdata_layer(me, cdl);
- DEG_id_tag_update(&me->id, 0);
- WM_main_add_notifier(NC_GEOM | ND_DATA, me);
-
- return true;
-}
-bool ED_mesh_sculpt_color_remove_active(Mesh *me)
-{
- CustomData *vdata = GET_CD_DATA(me, vdata);
- const int n = CustomData_get_active_layer(vdata, CD_PROP_COLOR);
- if (n != -1) {
- return ED_mesh_sculpt_color_remove_index(me, n);
- }
- return false;
-}
-bool ED_mesh_sculpt_color_remove_named(Mesh *me, const char *name)
-{
- CustomData *vdata = GET_CD_DATA(me, vdata);
- const int n = CustomData_get_named_layer(vdata, CD_PROP_COLOR, name);
- if (n != -1) {
- return ED_mesh_sculpt_color_remove_index(me, n);
- }
- return false;
-}
-
/*********************** UV texture operators ************************/
static bool uv_texture_remove_poll(bContext *C)
@@ -709,135 +601,6 @@ void MESH_OT_uv_texture_remove(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-/*********************** vertex color operators ************************/
-
-static bool vertex_color_remove_poll(bContext *C)
-{
- if (!layers_poll(C)) {
- return false;
- }
-
- Object *ob = ED_object_context(C);
- Mesh *me = static_cast<Mesh *>(ob->data);
- CustomData *ldata = GET_CD_DATA(me, ldata);
- const int active = CustomData_get_active_layer(ldata, CD_PROP_BYTE_COLOR);
- if (active != -1) {
- return true;
- }
-
- return false;
-}
-
-static int mesh_vertex_color_add_exec(bContext *C, wmOperator *op)
-{
- Object *ob = ED_object_context(C);
- Mesh *me = static_cast<Mesh *>(ob->data);
-
- if (ED_mesh_color_add(me, nullptr, true, true, op->reports) == -1) {
- return OPERATOR_CANCELLED;
- }
-
- return OPERATOR_FINISHED;
-}
-
-void MESH_OT_vertex_color_add(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Add Vertex Color";
- ot->description = "Add vertex color layer";
- ot->idname = "MESH_OT_vertex_color_add";
-
- /* api callbacks */
- ot->poll = layers_poll;
- ot->exec = mesh_vertex_color_add_exec;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-static int mesh_vertex_color_remove_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Object *ob = ED_object_context(C);
- Mesh *me = static_cast<Mesh *>(ob->data);
-
- if (!ED_mesh_color_remove_active(me)) {
- return OPERATOR_CANCELLED;
- }
-
- return OPERATOR_FINISHED;
-}
-
-void MESH_OT_vertex_color_remove(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Remove Vertex Color";
- ot->description = "Remove vertex color layer";
- ot->idname = "MESH_OT_vertex_color_remove";
-
- /* api callbacks */
- ot->exec = mesh_vertex_color_remove_exec;
- ot->poll = vertex_color_remove_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-/*********************** Sculpt Vertex Color Operators ************************/
-
-static int mesh_sculpt_vertex_color_add_exec(bContext *C, wmOperator *op)
-{
- Object *ob = ED_object_context(C);
- Mesh *me = static_cast<Mesh *>(ob->data);
-
- if (ED_mesh_sculpt_color_add(me, nullptr, true, true, op->reports) == -1) {
- return OPERATOR_CANCELLED;
- }
-
- return OPERATOR_FINISHED;
-}
-
-void MESH_OT_sculpt_vertex_color_add(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Add Sculpt Vertex Color";
- ot->description = "Add vertex color layer";
- ot->idname = "MESH_OT_sculpt_vertex_color_add";
-
- /* api callbacks */
- ot->poll = layers_poll;
- ot->exec = mesh_sculpt_vertex_color_add_exec;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-static int mesh_sculpt_vertex_color_remove_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Object *ob = ED_object_context(C);
- Mesh *me = static_cast<Mesh *>(ob->data);
-
- if (!ED_mesh_sculpt_color_remove_active(me)) {
- return OPERATOR_CANCELLED;
- }
-
- return OPERATOR_FINISHED;
-}
-
-void MESH_OT_sculpt_vertex_color_remove(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Remove Sculpt Vertex Color";
- ot->description = "Remove vertex color layer";
- ot->idname = "MESH_OT_sculpt_vertex_color_remove";
-
- /* api callbacks */
- ot->exec = mesh_sculpt_vertex_color_remove_exec;
- ot->poll = sculpt_vertex_color_remove_poll;
-
- /* flags */
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
/* *** CustomData clear functions, we need an operator for each *** */
static int mesh_customdata_clear_exec__internal(bContext *C, char htype, int type)
diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h
index 303234df48c..7c8dbffeb31 100644
--- a/source/blender/editors/mesh/mesh_intern.h
+++ b/source/blender/editors/mesh/mesh_intern.h
@@ -308,10 +308,6 @@ void MESH_OT_mark_freestyle_face(struct wmOperatorType *ot);
void MESH_OT_uv_texture_add(struct wmOperatorType *ot);
void MESH_OT_uv_texture_remove(struct wmOperatorType *ot);
-void MESH_OT_vertex_color_add(struct wmOperatorType *ot);
-void MESH_OT_vertex_color_remove(struct wmOperatorType *ot);
-void MESH_OT_sculpt_vertex_color_add(struct wmOperatorType *ot);
-void MESH_OT_sculpt_vertex_color_remove(struct wmOperatorType *ot);
void MESH_OT_customdata_mask_clear(struct wmOperatorType *ot);
void MESH_OT_customdata_skin_add(struct wmOperatorType *ot);
void MESH_OT_customdata_skin_clear(struct wmOperatorType *ot);
diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c
index be7f60b0da0..b9e78740e3c 100644
--- a/source/blender/editors/mesh/mesh_ops.c
+++ b/source/blender/editors/mesh/mesh_ops.c
@@ -134,10 +134,6 @@ void ED_operatortypes_mesh(void)
WM_operatortype_append(MESH_OT_uv_texture_add);
WM_operatortype_append(MESH_OT_uv_texture_remove);
- WM_operatortype_append(MESH_OT_vertex_color_add);
- WM_operatortype_append(MESH_OT_vertex_color_remove);
- WM_operatortype_append(MESH_OT_sculpt_vertex_color_add);
- WM_operatortype_append(MESH_OT_sculpt_vertex_color_remove);
WM_operatortype_append(MESH_OT_customdata_mask_clear);
WM_operatortype_append(MESH_OT_customdata_skin_add);
WM_operatortype_append(MESH_OT_customdata_skin_clear);
diff --git a/source/blender/editors/object/object_add.cc b/source/blender/editors/object/object_add.cc
index 55366348f38..acd7a8e3c13 100644
--- a/source/blender/editors/object/object_add.cc
+++ b/source/blender/editors/object/object_add.cc
@@ -3715,14 +3715,15 @@ static int duplicate_exec(bContext *C, wmOperator *op)
}
}
CTX_DATA_END;
- /* Sync the collection now, after everything is duplicated. */
BKE_layer_collection_resync_allow();
- BKE_main_collection_sync(bmain);
if (source_bases_new_objects.is_empty()) {
return OPERATOR_CANCELLED;
}
+ /* Sync the collection now, after everything is duplicated. */
+ BKE_main_collection_sync(bmain);
+
/* After sync we can get to the new Base data, process it here. */
for (const auto &item : source_bases_new_objects) {
Object *ob_new = item.second;
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c
index e8ceb97ed7a..1ce90849a88 100644
--- a/source/blender/editors/physics/dynamicpaint_ops.c
+++ b/source/blender/editors/physics/dynamicpaint_ops.c
@@ -21,6 +21,7 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
+#include "BKE_attribute.h"
#include "BKE_context.h"
#include "BKE_deform.h"
#include "BKE_dynamicpaint.h"
@@ -233,7 +234,7 @@ static int output_toggle_exec(bContext *C, wmOperator *op)
ED_mesh_color_add(ob->data, name, true, true, op->reports);
}
else {
- ED_mesh_color_remove_named(ob->data, name);
+ BKE_id_attribute_remove(ob->data, name, NULL);
}
}
/* Vertex Weight Layer */
diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.c b/source/blender/editors/sculpt_paint/sculpt_ops.c
index 35f9989143d..151eb7744ea 100644
--- a/source/blender/editors/sculpt_paint/sculpt_ops.c
+++ b/source/blender/editors/sculpt_paint/sculpt_ops.c
@@ -617,151 +617,6 @@ void SCULPT_geometry_preview_lines_update(bContext *C, SculptSession *ss, float
ss->preview_vert_count = totpoints;
}
-static int vertex_to_loop_colors_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Object *ob = CTX_data_active_object(C);
-
- ID *data;
- data = ob->data;
- if (data == NULL || ID_IS_LINKED(data) || ID_IS_OVERRIDE_LIBRARY(data)) {
- return OPERATOR_CANCELLED;
- }
-
- if (ob->type != OB_MESH) {
- return OPERATOR_CANCELLED;
- }
-
- Mesh *mesh = ob->data;
-
- const int mloopcol_layer_n = CustomData_get_active_layer(&mesh->ldata, CD_PROP_BYTE_COLOR);
- if (mloopcol_layer_n == -1) {
- return OPERATOR_CANCELLED;
- }
- MLoopCol *loopcols = CustomData_get_layer_n(&mesh->ldata, CD_PROP_BYTE_COLOR, mloopcol_layer_n);
-
- const int MPropCol_layer_n = CustomData_get_active_layer(&mesh->vdata, CD_PROP_COLOR);
- if (MPropCol_layer_n == -1) {
- return OPERATOR_CANCELLED;
- }
- const MPropCol *vertcols = CustomData_get_layer_n(&mesh->vdata, CD_PROP_COLOR, MPropCol_layer_n);
-
- const MLoop *loops = CustomData_get_layer(&mesh->ldata, CD_MLOOP);
- const MPoly *polys = CustomData_get_layer(&mesh->pdata, CD_MPOLY);
-
- for (int i = 0; i < mesh->totpoly; i++) {
- const MPoly *c_poly = &polys[i];
- for (int j = 0; j < c_poly->totloop; j++) {
- int loop_index = c_poly->loopstart + j;
- const MLoop *c_loop = &loops[c_poly->loopstart + j];
- float srgb_color[4];
- linearrgb_to_srgb_v4(srgb_color, vertcols[c_loop->v].color);
- loopcols[loop_index].r = (char)(srgb_color[0] * 255);
- loopcols[loop_index].g = (char)(srgb_color[1] * 255);
- loopcols[loop_index].b = (char)(srgb_color[2] * 255);
- loopcols[loop_index].a = (char)(srgb_color[3] * 255);
- }
- }
-
- DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
-
- return OPERATOR_FINISHED;
-}
-
-static bool sculpt_colors_poll(bContext *C)
-{
- if (!SCULPT_mode_poll(C)) {
- return false;
- }
-
- Object *ob = CTX_data_active_object(C);
-
- if (!ob->sculpt || !ob->sculpt->pbvh || BKE_pbvh_type(ob->sculpt->pbvh) != PBVH_FACES) {
- return false;
- }
-
- return SCULPT_has_colors(ob->sculpt);
-}
-
-static void SCULPT_OT_vertex_to_loop_colors(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Sculpt Vertex Color to Vertex Color";
- ot->description = "Copy the Sculpt Vertex Color to a regular color layer";
- ot->idname = "SCULPT_OT_vertex_to_loop_colors";
-
- /* api callbacks */
- ot->poll = sculpt_colors_poll;
- ot->exec = vertex_to_loop_colors_exec;
-
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
-static int loop_to_vertex_colors_exec(bContext *C, wmOperator *UNUSED(op))
-{
- Object *ob = CTX_data_active_object(C);
-
- ID *data;
- data = ob->data;
- if (data == NULL || ID_IS_LINKED(data) || ID_IS_OVERRIDE_LIBRARY(data)) {
- return OPERATOR_CANCELLED;
- }
-
- if (ob->type != OB_MESH) {
- return OPERATOR_CANCELLED;
- }
-
- Mesh *mesh = ob->data;
-
- const int mloopcol_layer_n = CustomData_get_active_layer(&mesh->ldata, CD_PROP_BYTE_COLOR);
- if (mloopcol_layer_n == -1) {
- return OPERATOR_CANCELLED;
- }
- const MLoopCol *loopcols = CustomData_get_layer_n(
- &mesh->ldata, CD_PROP_BYTE_COLOR, mloopcol_layer_n);
-
- const int MPropCol_layer_n = CustomData_get_active_layer(&mesh->vdata, CD_PROP_COLOR);
- if (MPropCol_layer_n == -1) {
- return OPERATOR_CANCELLED;
- }
- MPropCol *vertcols = CustomData_get_layer_n(&mesh->vdata, CD_PROP_COLOR, MPropCol_layer_n);
-
- const MLoop *loops = CustomData_get_layer(&mesh->ldata, CD_MLOOP);
- const MPoly *polys = CustomData_get_layer(&mesh->pdata, CD_MPOLY);
-
- for (int i = 0; i < mesh->totpoly; i++) {
- const MPoly *c_poly = &polys[i];
- for (int j = 0; j < c_poly->totloop; j++) {
- int loop_index = c_poly->loopstart + j;
- const MLoop *c_loop = &loops[c_poly->loopstart + j];
- vertcols[c_loop->v].color[0] = (loopcols[loop_index].r / 255.0f);
- vertcols[c_loop->v].color[1] = (loopcols[loop_index].g / 255.0f);
- vertcols[c_loop->v].color[2] = (loopcols[loop_index].b / 255.0f);
- vertcols[c_loop->v].color[3] = (loopcols[loop_index].a / 255.0f);
- srgb_to_linearrgb_v4(vertcols[c_loop->v].color, vertcols[c_loop->v].color);
- }
- }
-
- DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
- WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
-
- return OPERATOR_FINISHED;
-}
-
-static void SCULPT_OT_loop_to_vertex_colors(wmOperatorType *ot)
-{
- /* identifiers */
- ot->name = "Vertex Color to Sculpt Vertex Color";
- ot->description = "Copy the active loop color layer to the vertex color";
- ot->idname = "SCULPT_OT_loop_to_vertex_colors";
-
- /* api callbacks */
- ot->poll = sculpt_colors_poll;
- ot->exec = loop_to_vertex_colors_exec;
-
- ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-}
-
static int sculpt_sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e))
{
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
@@ -1158,8 +1013,6 @@ void ED_operatortypes_sculpt(void)
WM_operatortype_append(SCULPT_OT_project_line_gesture);
WM_operatortype_append(SCULPT_OT_sample_color);
- WM_operatortype_append(SCULPT_OT_loop_to_vertex_colors);
- WM_operatortype_append(SCULPT_OT_vertex_to_loop_colors);
WM_operatortype_append(SCULPT_OT_color_filter);
WM_operatortype_append(SCULPT_OT_mask_by_color);
WM_operatortype_append(SCULPT_OT_dyntopo_detail_size_edit);
diff --git a/source/blender/editors/space_sequencer/sequencer_drag_drop.c b/source/blender/editors/space_sequencer/sequencer_drag_drop.c
index f6561cf07b9..4796d80b3a0 100644
--- a/source/blender/editors/space_sequencer/sequencer_drag_drop.c
+++ b/source/blender/editors/space_sequencer/sequencer_drag_drop.c
@@ -51,7 +51,9 @@
typedef struct SeqDropCoords {
float start_frame, channel;
int strip_len, channel_len;
+ float playback_rate;
bool in_use;
+ bool has_read_mouse_pos;
bool is_intersecting;
bool use_snapping;
float snap_point_x;
@@ -63,7 +65,7 @@ typedef struct SeqDropCoords {
* preloading data on drag start.
* Therefore we will for now use a global variable for this.
*/
-static SeqDropCoords g_drop_coords = {.in_use = false};
+static SeqDropCoords g_drop_coords = {.in_use = false, .has_read_mouse_pos = false};
static void generic_poll_operations(const wmEvent *event, uint8_t type)
{
@@ -82,31 +84,134 @@ static bool image_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *ev
}
}
- return WM_drag_is_ID_type(drag, ID_IM);
+ if (WM_drag_is_ID_type(drag, ID_IM)) {
+ generic_poll_operations(event, TH_SEQ_IMAGE);
+ return true;
+ }
+
+ return false;
}
-static bool movie_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *event)
+static bool is_movie(wmDrag *drag)
{
if (drag->type == WM_DRAG_PATH) {
- if (ELEM(drag->icon, 0, ICON_FILE_MOVIE, ICON_FILE_BLANK)) { /* Rule might not work? */
- generic_poll_operations(event, TH_SEQ_MOVIE);
+ if (ELEM(drag->icon, ICON_FILE_MOVIE, ICON_FILE_BLANK)) { /* Rule might not work? */
return true;
}
}
+ if (WM_drag_is_ID_type(drag, ID_MC)) {
+ return true;
+ }
+ return false;
+}
+
+static bool movie_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *event)
+{
+ if (is_movie(drag)) {
+ generic_poll_operations(event, TH_SEQ_MOVIE);
+ return true;
+ }
- return WM_drag_is_ID_type(drag, ID_MC);
+ return false;
}
-static bool sound_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *event)
+static bool is_sound(wmDrag *drag)
{
if (drag->type == WM_DRAG_PATH) {
if (ELEM(drag->icon, ICON_FILE_SOUND, ICON_FILE_BLANK)) { /* Rule might not work? */
- generic_poll_operations(event, TH_SEQ_AUDIO);
return true;
}
}
+ if (WM_drag_is_ID_type(drag, ID_SO)) {
+ return true;
+ }
+ return false;
+}
- return WM_drag_is_ID_type(drag, ID_SO);
+static bool sound_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *event)
+{
+ if (is_sound(drag)) {
+ generic_poll_operations(event, TH_SEQ_AUDIO);
+ return true;
+ }
+
+ return false;
+}
+
+static float update_overlay_strip_position_data(bContext *C, const int mval[2])
+{
+ SeqDropCoords *coords = &g_drop_coords;
+ ARegion *region = CTX_wm_region(C);
+ Scene *scene = CTX_data_scene(C);
+ int hand;
+ View2D *v2d = &region->v2d;
+
+ /* Update the position were we would place the strip if we complete the drag and drop action.
+ */
+ UI_view2d_region_to_view(v2d, mval[0], mval[1], &coords->start_frame, &coords->channel);
+ coords->start_frame = roundf(coords->start_frame);
+ if (coords->channel < 1.0f) {
+ coords->channel = 1;
+ }
+
+ float start_frame = coords->start_frame;
+ float end_frame;
+ float strip_len;
+
+ if (coords->playback_rate != 0.0f) {
+ float scene_playback_rate = (float)scene->r.frs_sec / scene->r.frs_sec_base;
+ strip_len = coords->strip_len / (coords->playback_rate / scene_playback_rate);
+ }
+ else {
+ strip_len = coords->strip_len;
+ }
+
+ end_frame = coords->start_frame + strip_len;
+
+ if (coords->use_snapping) {
+ /* Do snapping via the existing transform code. */
+ int snap_delta;
+ float snap_frame;
+ bool valid_snap;
+
+ valid_snap = ED_transform_snap_sequencer_to_closest_strip_calc(
+ scene, region, start_frame, end_frame, &snap_delta, &snap_frame);
+
+ if (valid_snap) {
+ /* We snapped onto something! */
+ start_frame += snap_delta;
+ coords->start_frame = start_frame;
+ end_frame = start_frame + strip_len;
+ coords->snap_point_x = snap_frame;
+ }
+ else {
+ /* Nothing was snapped to, disable snap drawing. */
+ coords->use_snapping = false;
+ }
+ }
+
+ if (strip_len < 1) {
+ /* Only check if there is a strip already under the mouse cursor. */
+ coords->is_intersecting = find_nearest_seq(scene, &region->v2d, &hand, mval);
+ }
+ else {
+ /* Check if there is a strip that would intersect with the new strip(s). */
+ coords->is_intersecting = false;
+ Sequence dummy_seq = {.machine = coords->channel,
+ .start = coords->start_frame,
+ .len = coords->strip_len,
+ .speed_factor = 1.0f,
+ .media_playback_rate = coords->playback_rate,
+ .flag = SEQ_AUTO_PLAYBACK_RATE};
+ Editing *ed = SEQ_editing_ensure(scene);
+
+ for (int i = 0; i < coords->channel_len && !coords->is_intersecting; i++) {
+ coords->is_intersecting = SEQ_transform_test_overlap(scene, ed->seqbasep, &dummy_seq);
+ dummy_seq.machine++;
+ }
+ }
+
+ return strip_len;
}
static void sequencer_drop_copy(bContext *C, wmDrag *drag, wmDropBox *drop)
@@ -153,93 +258,77 @@ static void sequencer_drop_copy(bContext *C, wmDrag *drag, wmDropBox *drop)
RNA_collection_add(drop->ptr, "files", &itemptr);
RNA_string_set(&itemptr, "name", file);
}
-
- if (g_drop_coords.in_use) {
- RNA_int_set(drop->ptr, "frame_start", g_drop_coords.start_frame);
- RNA_int_set(drop->ptr, "channel", g_drop_coords.channel);
- RNA_boolean_set(drop->ptr, "overlap_shuffle_override", true);
- }
- else {
- Scene *scene = CTX_data_scene(C);
- Editing *ed = SEQ_editing_get(scene);
- ListBase *seqbase = SEQ_active_seqbase_get(ed);
- ListBase *channels = SEQ_channels_displayed_get(ed);
- SpaceSeq *sseq = CTX_wm_space_seq(C);
-
- SeqCollection *strips = SEQ_query_rendered_strips(
- scene, channels, seqbase, scene->r.cfra, sseq->chanshown);
-
- /* Get the top most strip channel that is in view.*/
- Sequence *seq;
- int max_channel = -1;
- SEQ_ITERATOR_FOREACH (seq, strips) {
- max_channel = max_ii(seq->machine, max_channel);
- }
-
- if (max_channel != -1) {
- RNA_int_set(drop->ptr, "channel", max_channel);
- }
- SEQ_collection_free(strips);
- }
}
-}
-static void update_overlay_strip_poistion_data(bContext *C, const int mval[2])
-{
- SeqDropCoords *coords = &g_drop_coords;
- ARegion *region = CTX_wm_region(C);
- Scene *scene = CTX_data_scene(C);
- int hand;
- View2D *v2d = &region->v2d;
+ if (g_drop_coords.in_use) {
+ if (!g_drop_coords.has_read_mouse_pos) {
+ /* We didn't read the mouse position, so we need to do it manually here. */
+ int xy[2];
+ wmWindow *win = CTX_wm_window(C);
+ xy[0] = win->eventstate->xy[0];
+ xy[1] = win->eventstate->xy[1];
+
+ ARegion *region = CTX_wm_region(C);
+ int mval[2];
+ /* Convert mouse coordinates to region local coordinates. */
+ mval[0] = xy[0] - region->winrct.xmin;
+ mval[1] = xy[1] - region->winrct.ymin;
+
+ update_overlay_strip_position_data(C, mval);
+ }
- /* Update the position were we would place the strip if we complete the drag and drop action.
- */
- UI_view2d_region_to_view(v2d, mval[0], mval[1], &coords->start_frame, &coords->channel);
- coords->start_frame = roundf(coords->start_frame);
- if (coords->channel < 1.0f) {
- coords->channel = 1;
+ RNA_int_set(drop->ptr, "frame_start", g_drop_coords.start_frame);
+ RNA_int_set(drop->ptr, "channel", g_drop_coords.channel);
+ RNA_boolean_set(drop->ptr, "overlap_shuffle_override", true);
}
+ else {
+ /* We are dropped inside the preview region. Put the strip on top of the
+ * current displayed frame. */
+ Scene *scene = CTX_data_scene(C);
+ Editing *ed = SEQ_editing_get(scene);
+ ListBase *seqbase = SEQ_active_seqbase_get(ed);
+ ListBase *channels = SEQ_channels_displayed_get(ed);
+ SpaceSeq *sseq = CTX_wm_space_seq(C);
- float start_frame = coords->start_frame;
- float end_frame = coords->start_frame + coords->strip_len;
-
- if (coords->use_snapping) {
- /* Do snapping via the existing transform code. */
- int snap_delta;
- float snap_frame;
- bool valid_snap;
-
- valid_snap = ED_transform_snap_sequencer_to_closest_strip_calc(
- scene, region, start_frame, end_frame, &snap_delta, &snap_frame);
+ SeqCollection *strips = SEQ_query_rendered_strips(
+ scene, channels, seqbase, scene->r.cfra, sseq->chanshown);
- if (valid_snap) {
- /* We snapped onto something! */
- start_frame += snap_delta;
- coords->start_frame = start_frame;
- end_frame = start_frame + coords->strip_len;
- coords->snap_point_x = snap_frame;
+ /* Get the top most strip channel that is in view.*/
+ Sequence *seq;
+ int max_channel = -1;
+ SEQ_ITERATOR_FOREACH (seq, strips) {
+ max_channel = max_ii(seq->machine, max_channel);
}
- else {
- /* Nothing was snapped to, disable snap drawing. */
- coords->use_snapping = false;
+
+ if (max_channel != -1) {
+ RNA_int_set(drop->ptr, "channel", max_channel);
}
+ SEQ_collection_free(strips);
}
+}
- if (coords->strip_len < 1) {
- /* Only check if there is a strip already under the mouse cursor. */
- coords->is_intersecting = find_nearest_seq(scene, &region->v2d, &hand, mval);
+static void get_drag_path(wmDrag *drag, char r_path[FILE_MAX])
+{
+ ID *id = WM_drag_get_local_ID_or_import_from_asset(drag, 0);
+ /* ID dropped. */
+ if (id != NULL) {
+ const ID_Type id_type = GS(id->name);
+ if (id_type == ID_IM) {
+ Image *ima = (Image *)id;
+ BLI_strncpy(r_path, ima->filepath, FILE_MAX);
+ }
+ else if (id_type == ID_MC) {
+ MovieClip *clip = (MovieClip *)id;
+ BLI_strncpy(r_path, clip->filepath, FILE_MAX);
+ }
+ else if (id_type == ID_SO) {
+ bSound *sound = (bSound *)id;
+ BLI_strncpy(r_path, sound->filepath, FILE_MAX);
+ }
+ BLI_path_abs(r_path, BKE_main_blendfile_path_from_global());
}
else {
- /* Check if there is a strip that would intersect with the new strip(s). */
- coords->is_intersecting = false;
- Sequence dummy_seq = {
- .machine = coords->channel, .start = coords->start_frame, .len = coords->strip_len};
- Editing *ed = SEQ_editing_ensure(scene);
-
- for (int i = 0; i < coords->channel_len && !coords->is_intersecting; i++) {
- coords->is_intersecting = SEQ_transform_test_overlap(scene, ed->seqbasep, &dummy_seq);
- dummy_seq.machine++;
- }
+ BLI_strncpy(r_path, drag->path, FILE_MAX);
}
}
@@ -256,7 +345,7 @@ static void draw_seq_in_view(bContext *C, wmWindow *UNUSED(win), wmDrag *drag, c
mval[0] = xy[0] - region->winrct.xmin;
mval[1] = xy[1] - region->winrct.ymin;
- update_overlay_strip_poistion_data(C, mval);
+ float strip_len = update_overlay_strip_position_data(C, mval);
GPU_matrix_push();
UI_view2d_view_ortho(&region->v2d);
@@ -280,7 +369,7 @@ static void draw_seq_in_view(bContext *C, wmWindow *UNUSED(win), wmDrag *drag, c
/* Draw strips. The code here is taken from sequencer_draw. */
float x1 = coords->start_frame;
- float x2 = coords->start_frame + coords->strip_len;
+ float x2 = coords->start_frame + floorf(strip_len);
float strip_color[3];
uchar text_color[4] = {255, 255, 255, 255};
float pixelx = BLI_rctf_size_x(&region->v2d.cur) / BLI_rcti_size_x(&region->v2d.mask);
@@ -354,21 +443,22 @@ static void draw_seq_in_view(bContext *C, wmWindow *UNUSED(win), wmDrag *drag, c
const char *text_array[5];
char text_display[FILE_MAX];
char filename[FILE_MAX];
- char rel_path[FILE_MAX];
+ char path[FILE_MAX];
char strip_duration_text[16];
int len_text_arr = 0;
+ get_drag_path(drag, path);
+
if (sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_STRIP_NAME) {
- BLI_split_file_part(drag->path, filename, FILE_MAX);
+ BLI_split_file_part(path, filename, FILE_MAX);
text_array[len_text_arr++] = filename;
}
if (sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_STRIP_SOURCE) {
Main *bmain = CTX_data_main(C);
- BLI_strncpy(rel_path, drag->path, FILE_MAX);
- BLI_path_rel(rel_path, BKE_main_blendfile_path(bmain));
+ BLI_path_rel(path, BKE_main_blendfile_path(bmain));
text_array[len_text_arr++] = text_sep;
- text_array[len_text_arr++] = rel_path;
+ text_array[len_text_arr++] = path;
}
if (sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_STRIP_DURATION) {
@@ -442,6 +532,14 @@ static void prefetch_data_fn(void *custom_data,
if (anim != NULL) {
g_drop_coords.strip_len = IMB_anim_get_duration(anim, IMB_TC_NONE);
+ short frs_sec;
+ float frs_sec_base;
+ if (IMB_anim_get_fps(anim, &frs_sec, &frs_sec_base, true)) {
+ g_drop_coords.playback_rate = (float)frs_sec / frs_sec_base;
+ }
+ else {
+ g_drop_coords.playback_rate = 0;
+ }
IMB_free_anim(anim);
#ifdef WITH_AUDASPACE
/* Try to load sound and see if the video has a sound channel. */
@@ -464,7 +562,7 @@ static void free_prefetch_data_fn(void *custom_data)
MEM_freeN(job_data);
}
-static void start_audio_video_job(bContext *C, char *path, bool only_audio)
+static void start_audio_video_job(bContext *C, wmDrag *drag, bool only_audio)
{
g_drop_coords.strip_len = 0;
g_drop_coords.channel_len = 1;
@@ -478,8 +576,8 @@ static void start_audio_video_job(bContext *C, char *path, bool only_audio)
DropJobData *job_data = (DropJobData *)MEM_mallocN(sizeof(DropJobData),
"SeqDragDropPreviewData");
+ get_drag_path(drag, job_data->path);
- BLI_strncpy(job_data->path, path, FILE_MAX);
job_data->only_audio = only_audio;
job_data->scene_fps = FPS;
@@ -492,15 +590,15 @@ static void start_audio_video_job(bContext *C, char *path, bool only_audio)
static void video_prefetch(bContext *C, wmDrag *drag)
{
- if (drag->type == WM_DRAG_PATH && ELEM(drag->icon, ICON_FILE_MOVIE, ICON_FILE_BLANK)) {
- start_audio_video_job(C, drag->path, false);
+ if (is_movie(drag)) {
+ start_audio_video_job(C, drag, false);
}
}
static void audio_prefetch(bContext *C, wmDrag *drag)
{
- if (drag->type == WM_DRAG_PATH && ELEM(drag->icon, ICON_FILE_SOUND, ICON_FILE_BLANK)) {
- start_audio_video_job(C, drag->path, true);
+ if (is_sound(drag)) {
+ start_audio_video_job(C, drag, true);
}
}
@@ -534,6 +632,7 @@ static void sequencer_drop_draw_deactivate(struct wmDropBox *drop, wmDrag *UNUSE
SeqDropCoords *coords = drop->draw_data;
if (coords) {
coords->in_use = false;
+ coords->has_read_mouse_pos = false;
drop->draw_data = NULL;
}
}
diff --git a/source/blender/editors/uvedit/uvedit_intern.h b/source/blender/editors/uvedit/uvedit_intern.h
index 04128cf378c..434bfbc64f9 100644
--- a/source/blender/editors/uvedit/uvedit_intern.h
+++ b/source/blender/editors/uvedit/uvedit_intern.h
@@ -14,9 +14,6 @@ struct Scene;
struct SpaceImage;
struct wmOperatorType;
-/* geometric utilities */
-void uv_poly_copy_aspect(float uv_orig[][2], float uv[][2], float aspx, float aspy, int len);
-
/* find nearest */
typedef struct UvNearestHit {
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c
index 74a9989f550..5ebdfcec294 100644
--- a/source/blender/editors/uvedit/uvedit_ops.c
+++ b/source/blender/editors/uvedit/uvedit_ops.c
@@ -189,15 +189,6 @@ void uvedit_live_unwrap_update(SpaceImage *sima, Scene *scene, Object *obedit)
/** \name Geometric Utilities
* \{ */
-void uv_poly_copy_aspect(float uv_orig[][2], float uv[][2], float aspx, float aspy, int len)
-{
- int i;
- for (i = 0; i < len; i++) {
- uv[i][0] = uv_orig[i][0] * aspx;
- uv[i][1] = uv_orig[i][1] * aspy;
- }
-}
-
bool ED_uvedit_minmax_multi(
const Scene *scene, Object **objects_edit, uint objects_len, float r_min[2], float r_max[2])
{