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/mesh/mesh_data.c')
-rw-r--r--source/blender/editors/mesh/mesh_data.c117
1 files changed, 27 insertions, 90 deletions
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index d1c6ff4c4ae..cfd1b006ece 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -38,6 +38,11 @@
#include "DNA_scene_types.h"
#include "DNA_view3d_types.h"
+#include "BLI_math.h"
+#include "BLI_editVert.h"
+#include "BLI_edgehash.h"
+#include "BLI_utildefines.h"
+
#include "BKE_context.h"
#include "BKE_depsgraph.h"
#include "BKE_displist.h"
@@ -47,10 +52,6 @@
#include "BKE_mesh.h"
#include "BKE_report.h"
-#include "BLI_math.h"
-#include "BLI_editVert.h"
-#include "BLI_edgehash.h"
-
#include "RNA_access.h"
#include "RNA_define.h"
@@ -157,7 +158,7 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la
}
}
-int ED_mesh_uv_texture_add(bContext *C, Scene *scene, Object *ob, Mesh *me, const char *name, int active_set)
+int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_set)
{
EditMesh *em;
int layernum;
@@ -189,7 +190,7 @@ int ED_mesh_uv_texture_add(bContext *C, Scene *scene, Object *ob, Mesh *me, cons
mesh_update_customdata_pointers(me);
}
- DAG_id_flush_update(&me->id, OB_RECALC_DATA);
+ DAG_id_tag_update(&me->id, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
return 1;
@@ -208,7 +209,7 @@ int ED_mesh_uv_texture_remove(bContext *C, Object *ob, Mesh *me)
return 0;
delete_customdata_layer(C, ob, cdl);
- DAG_id_flush_update(&me->id, OB_RECALC_DATA);
+ DAG_id_tag_update(&me->id, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
return 1;
@@ -252,7 +253,7 @@ int ED_mesh_color_add(bContext *C, Scene *scene, Object *ob, Mesh *me, const cha
shadeMeshMCol(scene, ob, me);
}
- DAG_id_flush_update(&me->id, OB_RECALC_DATA);
+ DAG_id_tag_update(&me->id, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
return 1;
@@ -271,7 +272,7 @@ int ED_mesh_color_remove(bContext *C, Object *ob, Mesh *me)
return 0;
delete_customdata_layer(C, ob, cdl);
- DAG_id_flush_update(&me->id, OB_RECALC_DATA);
+ DAG_id_tag_update(&me->id, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
return 1;
@@ -286,13 +287,12 @@ static int layers_poll(bContext *C)
return (ob && !ob->id.lib && ob->type==OB_MESH && data && !data->lib);
}
-static int uv_texture_add_exec(bContext *C, wmOperator *op)
+static int uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op))
{
- Scene *scene= CTX_data_scene(C);
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
Mesh *me= ob->data;
- if(!ED_mesh_uv_texture_add(C, scene, ob, me, NULL, TRUE))
+ if(!ED_mesh_uv_texture_add(C, me, NULL, TRUE))
return OPERATOR_CANCELLED;
return OPERATOR_FINISHED;
@@ -316,6 +316,7 @@ void MESH_OT_uv_texture_add(wmOperatorType *ot)
static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
Scene *scene= CTX_data_scene(C);
+ View3D *v3d= CTX_wm_view3d(C);
Base *base= ED_view3d_give_base_under_cursor(C, event->mval);
Image *ima= NULL;
Mesh *me;
@@ -334,8 +335,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event)
char path[FILE_MAX];
RNA_string_get(op->ptr, "filepath", path);
- ima= BKE_add_image_file(path,
- scene ? scene->r.cfra : 1);
+ ima= BKE_add_image_file(path);
}
else {
RNA_string_get(op->ptr, "name", name);
@@ -368,6 +368,10 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event)
me->edit_mesh= NULL;
}
+ /* dummie drop support; ensure view shows a result :) */
+ if(v3d)
+ v3d->flag2 |= V3D_SOLID_TEX;
+
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
return OPERATOR_FINISHED;
@@ -392,7 +396,7 @@ void MESH_OT_drop_named_image(wmOperatorType *ot)
RNA_def_string(ot->srna, "filepath", "Path", FILE_MAX, "Filepath", "Path to image file");
}
-static int uv_texture_remove_exec(bContext *C, wmOperator *op)
+static int uv_texture_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
Mesh *me= ob->data;
@@ -420,7 +424,7 @@ void MESH_OT_uv_texture_remove(wmOperatorType *ot)
/*********************** vertex color operators ************************/
-static int vertex_color_add_exec(bContext *C, wmOperator *op)
+static int vertex_color_add_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene= CTX_data_scene(C);
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
@@ -447,7 +451,7 @@ void MESH_OT_vertex_color_add(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
-static int vertex_color_remove_exec(bContext *C, wmOperator *op)
+static int vertex_color_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
Mesh *me= ob->data;
@@ -475,7 +479,7 @@ void MESH_OT_vertex_color_remove(wmOperatorType *ot)
/*********************** sticky operators ************************/
-static int sticky_add_exec(bContext *C, wmOperator *op)
+static int sticky_add_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene= CTX_data_scene(C);
View3D *v3d= CTX_wm_view3d(C);
@@ -487,7 +491,7 @@ static int sticky_add_exec(bContext *C, wmOperator *op)
RE_make_sticky(scene, v3d);
- DAG_id_flush_update(&me->id, OB_RECALC_DATA);
+ DAG_id_tag_update(&me->id, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
return OPERATOR_FINISHED;
@@ -508,7 +512,7 @@ void MESH_OT_sticky_add(wmOperatorType *ot)
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
}
-static int sticky_remove_exec(bContext *C, wmOperator *op)
+static int sticky_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data;
Mesh *me= ob->data;
@@ -519,7 +523,7 @@ static int sticky_remove_exec(bContext *C, wmOperator *op)
CustomData_free_layer_active(&me->vdata, CD_MSTICKY, me->totvert);
me->msticky= NULL;
- DAG_id_flush_update(&me->id, OB_RECALC_DATA);
+ DAG_id_tag_update(&me->id, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
return OPERATOR_FINISHED;
@@ -542,81 +546,14 @@ void MESH_OT_sticky_remove(wmOperatorType *ot)
/************************** Add Geometry Layers *************************/
-static void mesh_calc_edges(Mesh *mesh, int update)
-{
- CustomData edata;
- EdgeHashIterator *ehi;
- MFace *mf = mesh->mface;
- MEdge *med, *med_orig;
- EdgeHash *eh = BLI_edgehash_new();
- int i, totedge, totface = mesh->totface;
-
- if(mesh->totedge==0)
- update= 0;
-
- if(update) {
- /* assume existing edges are valid
- * useful when adding more faces and generating edges from them */
- med= mesh->medge;
- for(i= 0; i<mesh->totedge; i++, med++)
- BLI_edgehash_insert(eh, med->v1, med->v2, med);
- }
-
- for (i = 0; i < totface; i++, mf++) {
- if (!BLI_edgehash_haskey(eh, mf->v1, mf->v2))
- BLI_edgehash_insert(eh, mf->v1, mf->v2, NULL);
- if (!BLI_edgehash_haskey(eh, mf->v2, mf->v3))
- BLI_edgehash_insert(eh, mf->v2, mf->v3, NULL);
-
- if (mf->v4) {
- if (!BLI_edgehash_haskey(eh, mf->v3, mf->v4))
- BLI_edgehash_insert(eh, mf->v3, mf->v4, NULL);
- if (!BLI_edgehash_haskey(eh, mf->v4, mf->v1))
- BLI_edgehash_insert(eh, mf->v4, mf->v1, NULL);
- } else {
- if (!BLI_edgehash_haskey(eh, mf->v3, mf->v1))
- BLI_edgehash_insert(eh, mf->v3, mf->v1, NULL);
- }
- }
-
- totedge = BLI_edgehash_size(eh);
-
- /* write new edges into a temporary CustomData */
- memset(&edata, 0, sizeof(edata));
- CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
-
- ehi = BLI_edgehashIterator_new(eh);
- med = CustomData_get_layer(&edata, CD_MEDGE);
- for(i = 0; !BLI_edgehashIterator_isDone(ehi);
- BLI_edgehashIterator_step(ehi), ++i, ++med) {
-
- if(update && (med_orig=BLI_edgehashIterator_getValue(ehi))) {
- *med= *med_orig; /* copy from the original */
- } else {
- BLI_edgehashIterator_getKey(ehi, (int*)&med->v1, (int*)&med->v2);
- med->flag = ME_EDGEDRAW|ME_EDGERENDER;
- }
- }
- BLI_edgehashIterator_free(ehi);
-
- /* free old CustomData and assign new one */
- CustomData_free(&mesh->edata, mesh->totedge);
- mesh->edata = edata;
- mesh->totedge = totedge;
-
- mesh->medge = CustomData_get_layer(&mesh->edata, CD_MEDGE);
-
- BLI_edgehash_free(eh, NULL);
-}
-
void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges)
{
if(calc_edges || (mesh->totface && mesh->totedge == 0))
- mesh_calc_edges(mesh, calc_edges);
+ BKE_mesh_calc_edges(mesh, calc_edges);
mesh_calc_normals(mesh->mvert, mesh->totvert, mesh->mface, mesh->totface, NULL);
- DAG_id_flush_update(&mesh->id, OB_RECALC_DATA);
+ DAG_id_tag_update(&mesh->id, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, mesh);
}