Blender V2.61 - r43446
Classes | Defines | Typedefs | Functions | Variables

editmesh.c File Reference

#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "MEM_guardedalloc.h"
#include "DNA_scene_types.h"
#include "DNA_object_types.h"
#include "DNA_key_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_editVert.h"
#include "BLI_dynstr.h"
#include "BLI_rand.h"
#include "BLI_utildefines.h"
#include "BKE_DerivedMesh.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
#include "BKE_global.h"
#include "BKE_key.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_mesh.h"
#include "BKE_paint.h"
#include "BKE_report.h"
#include "BKE_multires.h"
#include "ED_mesh.h"
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_util.h"
#include "ED_view3d.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "WM_api.h"
#include "WM_types.h"
#include "mesh_intern.h"

Go to the source code of this file.

Classes

struct  EditVertC
struct  EditEdgeC
struct  EditFaceC
struct  EditSelectionC
struct  UndoMesh

Defines

#define EDHASHSIZE   (512*512)
#define EDHASH(a, b)   (a % EDHASHSIZE)

Typedefs

typedef struct EditVertC EditVertC
typedef struct EditEdgeC EditEdgeC
typedef struct EditFaceC EditFaceC
typedef struct EditSelectionC EditSelectionC
typedef struct UndoMesh UndoMesh

Functions

static void BIF_undo_push (const char *UNUSED(arg))
static void error (const char *UNUSED(arg))
static void * calloc_em (EditMesh *UNUSED(em), size_t size, size_t nr)
EditVertaddvertlist (EditMesh *em, float *vec, EditVert *example)
void free_editvert (EditMesh *em, EditVert *eve)
EditEdgefindedgelist (EditMesh *em, EditVert *v1, EditVert *v2)
static void insert_hashedge (EditMesh *em, EditEdge *eed)
static void remove_hashedge (EditMesh *em, EditEdge *eed)
EditEdgeaddedgelist (EditMesh *em, EditVert *v1, EditVert *v2, EditEdge *example)
void remedge (EditMesh *em, EditEdge *eed)
void free_editedge (EditMesh *em, EditEdge *eed)
void free_editface (EditMesh *em, EditFace *efa)
void free_vertlist (EditMesh *em, ListBase *edve)
void free_edgelist (EditMesh *em, ListBase *lb)
void free_facelist (EditMesh *em, ListBase *lb)
EditFaceaddfacelist (EditMesh *em, EditVert *v1, EditVert *v2, EditVert *v3, EditVert *v4, EditFace *example, EditFace *exampleEdges)
EditVerteditedge_getOtherVert (EditEdge *eed, EditVert *eve)
EditVerteditedge_getSharedVert (EditEdge *eed, EditEdge *eed2)
int editedge_containsVert (EditEdge *eed, EditVert *eve)
int editface_containsVert (EditFace *efa, EditVert *eve)
int editface_containsEdge (EditFace *efa, EditEdge *eed)
static void * calloc_fastvert (EditMesh *em, size_t UNUSED(size), size_t UNUSED(nr))
static void * calloc_fastedge (EditMesh *em, size_t UNUSED(size), size_t UNUSED(nr))
static void * calloc_fastface (EditMesh *em, size_t UNUSED(size), size_t UNUSED(nr))
static void init_editmesh_fastmalloc (EditMesh *em, int totvert, int totedge, int totface)
static void end_editmesh_fastmalloc (void)
void free_editMesh (EditMesh *em)
static void editMesh_set_hash (EditMesh *em)
static void edge_normal_compare (EditEdge *eed, EditFace *efa1)
static void edge_drawflags (Mesh *me, EditMesh *em)
void make_editMesh (Scene *scene, Object *ob)
void load_editMesh (Scene *scene, Object *obedit)
void remake_editMesh (Scene *scene, Object *ob)
static int mesh_separate_selected (wmOperator *op, Main *bmain, Scene *scene, Base *editbase)
static int mesh_separate_material (wmOperator *op, Main *bmain, Scene *scene, Base *editbase)
static int mesh_separate_loose (wmOperator *op, Main *bmain, Scene *scene, Base *editbase)
static int mesh_separate_exec (bContext *C, wmOperator *op)
void MESH_OT_separate (wmOperatorType *ot)
static void free_undoMesh (void *umv)
static void * editMesh_to_undoMesh (void *emv)
static void undoMesh_to_editMesh (void *umv, void *emv)
static void * getEditMesh (bContext *C)
void undo_push_mesh (bContext *C, const char *name)
void EM_init_index_arrays (EditMesh *em, int forVert, int forEdge, int forFace)
void EM_free_index_arrays (void)
EditVertEM_get_vert_for_index (int index)
EditEdgeEM_get_edge_for_index (int index)
EditFaceEM_get_face_for_index (int index)
int EM_texFaceCheck (EditMesh *em)
int EM_vertColorCheck (EditMesh *em)
void em_setup_viewcontext (bContext *C, ViewContext *vc)
void paintvert_flush_flags (Object *ob)
void paintvert_deselect_all_visible (Object *ob, int action, short flush_flags)

Variables

static void *(* callocvert )(EditMesh *, size_t, size_t) = calloc_em
static void *(* callocedge )(EditMesh *, size_t, size_t) = calloc_em
static void *(* callocface )(EditMesh *, size_t, size_t) = calloc_em
static EnumPropertyItem prop_separate_types []
static EditVert ** g_em_vert_array = NULL
static EditEdge ** g_em_edge_array = NULL
static EditFace ** g_em_face_array = NULL

Detailed Description

Definition in file editmesh.c.


Define Documentation

#define EDHASH (   a,
 
)    (a % EDHASHSIZE)

Definition at line 94 of file editmesh.c.

Referenced by findedgelist(), insert_hashedge(), and remove_hashedge().

#define EDHASHSIZE   (512*512)

Definition at line 93 of file editmesh.c.

Referenced by addvertlist(), findedgelist(), and free_editMesh().


Typedef Documentation

typedef struct EditEdgeC EditEdgeC
typedef struct EditFaceC EditFaceC
typedef struct EditVertC EditVertC
typedef struct UndoMesh UndoMesh

Function Documentation

EditEdge* addedgelist ( EditMesh em,
EditVert v1,
EditVert v2,
EditEdge example 
) [read]
EditFace* addfacelist ( EditMesh em,
EditVert v1,
EditVert v2,
EditVert v3,
EditVert v4,
EditFace example,
EditFace exampleEdges 
) [read]
EditVert* addvertlist ( EditMesh em,
float *  vec,
EditVert example 
) [read]
static void BIF_undo_push ( const char *  UNUSEDarg) [static]

Definition at line 86 of file editmesh.c.

Referenced by remake_editMesh().

static void* calloc_em ( EditMesh UNUSEDem,
size_t  size,
size_t  nr 
) [static]

Definition at line 99 of file editmesh.c.

Referenced by end_editmesh_fastmalloc().

static void* calloc_fastedge ( EditMesh em,
size_t   UNUSEDsize,
size_t   UNUSEDnr 
) [static]

Definition at line 462 of file editmesh.c.

References EditMesh::curedge, HashEdge::eed, and EditEdge::fast.

Referenced by init_editmesh_fastmalloc().

static void* calloc_fastface ( EditMesh em,
size_t   UNUSEDsize,
size_t   UNUSEDnr 
) [static]

Definition at line 468 of file editmesh.c.

References EditMesh::curface, and EditFace::fast.

Referenced by init_editmesh_fastmalloc().

static void* calloc_fastvert ( EditMesh em,
size_t   UNUSEDsize,
size_t   UNUSEDnr 
) [static]

Definition at line 456 of file editmesh.c.

References EditMesh::curvert, and EditVert::fast.

Referenced by init_editmesh_fastmalloc().

static void edge_drawflags ( Mesh me,
EditMesh em 
) [static]
static void edge_normal_compare ( EditEdge eed,
EditFace efa1 
) [static]
int editedge_containsVert ( EditEdge eed,
EditVert eve 
)

Definition at line 437 of file editmesh.c.

References EditEdge::v1, and EditEdge::v2.

Referenced by createSlideVerts().

EditVert* editedge_getOtherVert ( EditEdge eed,
EditVert eve 
) [read]

Definition at line 415 of file editmesh.c.

References NULL, EditEdge::v1, and EditEdge::v2.

Referenced by createSlideVerts(), and doEdgeSlide().

EditVert* editedge_getSharedVert ( EditEdge eed,
EditEdge eed2 
) [read]

Definition at line 426 of file editmesh.c.

References NULL, EditEdge::v1, and EditEdge::v2.

Referenced by createSlideVerts(), and doEdgeSlide().

int editface_containsEdge ( EditFace efa,
EditEdge eed 
)

Definition at line 447 of file editmesh.c.

References EditFace::e1, EditFace::e2, EditFace::e3, and EditFace::e4.

Referenced by createSlideVerts().

int editface_containsVert ( EditFace efa,
EditVert eve 
)

Definition at line 442 of file editmesh.c.

References EditFace::v1, EditFace::v2, EditFace::v3, and EditFace::v4.

static void editMesh_set_hash ( EditMesh em) [static]
static void* editMesh_to_undoMesh ( void *  emv) [static]

Definition at line 1649 of file editmesh.c.

References EditVertC::bweight, EditVert::bweight, EditEdgeC::bweight, EditEdge::bweight, CD_CALLOC, CD_MASK_EDITMESH, EditVertC::co, EditVert::co, copy_v3_v3(), EditEdgeC::crease, EditEdge::crease, CustomData_copy(), CustomData_from_em_block(), EditSelection::data, EditFace::data, EditVert::data, EditEdge::data, EditMesh::edata, UndoMesh::edata, UndoMesh::edges, EditMesh::edges, EDITEDGE, EDITFACE, EDITVERT, EditFaceC::f, EditEdge::f, EditVert::f, EditEdgeC::f, EditFace::f, EditVertC::f, UndoMesh::faces, EditMesh::faces, UndoMesh::fdata, EditMesh::fdata, EditFace::fgonf, EditFaceC::fgonf, EditEdge::fgoni, EditEdgeC::fgoni, ListBase::first, EditFace::flag, EditFaceC::flag, EditFaceC::h, EditEdge::h, EditVert::h, EditEdgeC::h, EditFace::h, EditVertC::h, EditSelectionC::index, EditVert::keyindex, EditVertC::keyindex, EditVert::l, EditFace::l, EditEdge::l, EditFaceC::mat_nr, EditFace::mat_nr, MEM_callocN(), EditEdge::next, EditFace::next, EditVert::next, EditSelection::next, EditVertC::no, EditVert::no, NULL, EditEdge::seam, EditEdgeC::seam, EditMesh::selected, UndoMesh::selected, EditMesh::selectmode, UndoMesh::selectmode, UndoMesh::shapenr, EditMesh::shapenr, EditEdge::sharp, EditEdgeC::sharp, EditVert::tmp, EditFace::tmp, EditEdge::tmp, UndoMesh::totedge, UndoMesh::totface, UndoMesh::totsel, UndoMesh::totvert, EditSelection::type, EditSelectionC::type, EditFace::v1, EditEdgeC::v1, EditEdge::v1, EditFaceC::v1, EditFace::v2, EditEdgeC::v2, EditEdge::v2, EditFaceC::v2, EditFace::v3, EditFaceC::v3, EditFace::v4, EditFaceC::v4, UndoMesh::vdata, EditMesh::vdata, UndoMesh::verts, and EditMesh::verts.

Referenced by undo_push_mesh().

void EM_free_index_arrays ( void  )
EditEdge* EM_get_edge_for_index ( int  index) [read]
EditFace* EM_get_face_for_index ( int  index) [read]
EditVert* EM_get_vert_for_index ( int  index) [read]
void EM_init_index_arrays ( EditMesh em,
int  forVert,
int  forEdge,
int  forFace 
)
void em_setup_viewcontext ( bContext C,
ViewContext vc 
)
int EM_texFaceCheck ( EditMesh em)
int EM_vertColorCheck ( EditMesh em)
static void end_editmesh_fastmalloc ( void  ) [static]

Definition at line 499 of file editmesh.c.

References calloc_em(), callocedge, callocface, and callocvert.

Referenced by make_editMesh(), and undoMesh_to_editMesh().

static void error ( const char *  UNUSEDarg) [static]

Definition at line 87 of file editmesh.c.

Referenced by make_editMesh(), and mesh_separate_loose().

EditEdge* findedgelist ( EditMesh em,
EditVert v1,
EditVert v2 
) [read]
void free_edgelist ( EditMesh em,
ListBase lb 
)
void free_editedge ( EditMesh em,
EditEdge eed 
)
void free_editface ( EditMesh em,
EditFace efa 
)
void free_editMesh ( EditMesh em)
void free_editvert ( EditMesh em,
EditVert eve 
)
void free_facelist ( EditMesh em,
ListBase lb 
)
static void free_undoMesh ( void *  umv) [static]
void free_vertlist ( EditMesh em,
ListBase edve 
)
static void* getEditMesh ( bContext C) [static]

Definition at line 1850 of file editmesh.c.

References CTX_data_edit_object(), Object::data, Mesh::edit_mesh, NULL, OB_MESH, and Object::type.

Referenced by undo_push_mesh().

static void init_editmesh_fastmalloc ( EditMesh em,
int  totvert,
int  totedge,
int  totface 
) [static]
static void insert_hashedge ( EditMesh em,
EditEdge eed 
) [static]
void load_editMesh ( Scene scene,
Object obedit 
)

Definition at line 950 of file editmesh.c.

References Mesh::act_face, Scene::base, BLI_findlink(), Key::block, EditEdge::bweight, MEdge::bweight, EditVert::bweight, MVert::bweight, CD_ASSIGN, CD_CALLOC, CD_MASK_MESH, CD_MEDGE, CD_MFACE, CD_MVERT, EditVert::co, MVert::co, EditEdge::crease, MEdge::crease, CustomData_add_layer(), CustomData_copy(), CustomData_free(), CustomData_from_em_block(), CustomData_set_layer(), EditSelection::data, KeyBlock::data, EditFace::data, EditEdge::data, EditVert::data, Object::data, EditFace::e1, EditFace::e2, EditFace::e3, EditFace::e4, EditMesh::edata, edge_drawflags(), EditMesh::edges, Mesh::edit_mesh, EDITEDGE, EDITFACE, EDITVERT, ELEM, Key::elemsize, EM_FGON, EM_get_actFace(), EM_stats_update(), eModifierType_Hook, EditFace::f, EditEdge::f, EditVert::f, EditEdge::f2, EditMesh::faces, EditMesh::fdata, Mesh::fdata, ListBase::first, EditFace::flag, MFace::flag, MEdge::flag, MVert::flag, G, EditFace::h, EditEdge::h, EditVert::h, i, Mesh::id, Object::id, if(), MSelect::index, HookModifierData::indexar, Mesh::key, KEY_RELATIVE, EditVert::keyindex, EditFace::l, EditEdge::l, EditVert::l, EditFace::mat_nr, MFace::mat_nr, ME_EDGEDRAW, ME_EDGERENDER, ME_FACE_SEL, ME_FGON, ME_HIDE, ME_LOOSEEDGE, ME_SEAM, ME_SHARP, MEM_callocN(), MEM_freeN(), mesh_calc_normals(), mesh_update_customdata_pointers(), Mesh::mface, Object::modifiers, Mesh::mselect, multires_topology_changed(), Mesh::mvert, Base::next, EditSelection::next, KeyBlock::next, ModifierData::next, ID::next, EditFace::next, EditEdge::next, EditVert::next, EditVert::no, MVert::no, normal_float_to_short_v3(), NULL, OB_RECALC_DATA, Base::object, Object::par1, Object::par2, Object::par3, Object::parent, Object::partype, PARVERT1, PARVERT3, Object::recalc, Key::refkey, KeyBlock::relative, EditEdge::seam, SELECT, EditMesh::selected, EditMesh::shapenr, EditEdge::sharp, sub_v3_v3v3(), test_index_face(), EditFace::tmp, EditEdge::tmp, EditVert::tmp, Mesh::totedge, EditMesh::totedge, KeyBlock::totelem, Mesh::totface, EditMesh::totface, HookModifierData::totindex, Mesh::totselect, Mesh::totvert, EditMesh::totvert, EditSelection::type, MSelect::type, Key::type, ModifierData::type, ID::us, EditFace::v1, MFace::v1, EditEdge::v1, MEdge::v1, EditFace::v2, MFace::v2, EditEdge::v2, MEdge::v2, EditFace::v3, MFace::v3, MFace::v4, EditFace::v4, EditMesh::vdata, VECADD, VECCOPY, and EditMesh::verts.

Referenced by drop_named_image_invoke(), ED_object_exit_editmode(), join_mesh_exec(), mesh_separate_selected(), object_hook_index_array(), and vertex_parent_set_exec().

void make_editMesh ( Scene scene,
Object ob 
)

Definition at line 730 of file editmesh.c.

References Mesh::act_face, EditMesh::act_face, Object::actcol, addedgelist(), addfacelist(), addvertlist(), BLI_addtail(), MEdge::bweight, EditEdge::bweight, MVert::bweight, EditVert::bweight, CD_CALLOC, CD_MASK_EDITMESH, MVert::co, co, MEdge::crease, EditEdge::crease, CustomData_copy(), CustomData_to_em_block(), EditSelection::data, EditFace::data, EditEdge::data, EditVert::data, KeyBlock::data, Object::data, EditMesh::edata, Mesh::edit_mesh, EDITEDGE, EDITFACE, EDITVERT, EM_FGON, EM_fgon_flags(), EM_free_index_arrays(), EM_get_actFace(), EM_get_edge_for_index(), EM_get_face_for_index(), EM_get_vert_for_index(), EM_hide_reset(), EM_init_index_arrays(), EM_select_edge(), EM_select_face(), EM_selectmode_set(), EM_set_actFace(), end_editmesh_fastmalloc(), error(), EditFace::f, EditEdge::f, EditVert::f, EditMesh::faces, FALSE, EditMesh::fdata, Mesh::fdata, ListBase::first, MFace::flag, EditFace::flag, MEdge::flag, MVert::flag, free_editMesh(), EditFace::h, EditEdge::h, EditVert::h, MSelect::index, init_editmesh_fastmalloc(), EditVert::keyindex, MFace::mat_nr, EditFace::mat_nr, EditMesh::mat_nr, ME_FACE_SEL, ME_FGON, ME_HIDE, ME_SEAM, ME_SHARP, Mesh::medge, MEM_callocN(), MEM_freeN(), MEM_mallocN(), Mesh::mface, Mesh::mselect, Mesh::mvert, MVert::no, EditVert::no, normal_short_to_float_v3(), NULL, ob_get_keyblock(), paint_facesel_test(), paint_vertsel_test(), SCE_SELECT_EDGE, EditEdge::seam, SELECT, EditMesh::selected, ToolSettings::selectmode, EditMesh::selectmode, Object::shapenr, EditMesh::shapenr, EditEdge::sharp, Scene::toolsettings, Mesh::totedge, EditMesh::totedge, KeyBlock::totelem, totelem, Mesh::totface, EditMesh::totface, Mesh::totselect, Mesh::totvert, EditMesh::totvert, EditSelection::type, MSelect::type, undo_editmode_clear(), EditFace::v1, MFace::v1, EditEdge::v1, MEdge::v1, EditFace::v2, MFace::v2, EditEdge::v2, MEdge::v2, EditFace::v3, MFace::v3, EditFace::v4, MFace::v4, and EditMesh::vdata.

Referenced by drop_named_image_invoke(), ED_object_enter_editmode(), join_mesh_exec(), mesh_separate_selected(), object_hook_index_array(), remake_editMesh(), and vertex_parent_set_exec().

void MESH_OT_separate ( wmOperatorType ot)
static int mesh_separate_exec ( bContext C,
wmOperator op 
) [static]
static int mesh_separate_loose ( wmOperator op,
Main bmain,
Scene scene,
Base editbase 
) [static]
static int mesh_separate_material ( wmOperator op,
Main bmain,
Scene scene,
Base editbase 
) [static]
static int mesh_separate_selected ( wmOperator op,
Main bmain,
Scene scene,
Base editbase 
) [static]
void paintvert_deselect_all_visible ( Object ob,
int  action,
short  flush_flags 
)
void paintvert_flush_flags ( Object ob)
void remake_editMesh ( Scene scene,
Object ob 
)
void remedge ( EditMesh em,
EditEdge eed 
)
static void remove_hashedge ( EditMesh em,
EditEdge eed 
) [static]
void undo_push_mesh ( bContext C,
const char *  name 
)
static void undoMesh_to_editMesh ( void *  umv,
void *  emv 
) [static]

Definition at line 1746 of file editmesh.c.

References addedgelist(), addfacelist(), addvertlist(), BLI_addtail(), EditVertC::bweight, EditVert::bweight, EditEdgeC::bweight, EditEdge::bweight, CD_CALLOC, CD_MASK_EDITMESH, EditVertC::co, copy_v3_v3(), EditEdgeC::crease, EditEdge::crease, CustomData_copy(), CustomData_free(), CustomData_to_em_block(), EditSelection::data, EditFace::data, EditVert::data, EditEdge::data, EditMesh::edata, UndoMesh::edata, UndoMesh::edges, EDITEDGE, EDITFACE, EDITVERT, EM_free_index_arrays(), EM_get_edge_for_index(), EM_get_face_for_index(), EM_get_vert_for_index(), EM_init_index_arrays(), EM_nedges_selected(), EM_nfaces_selected(), EM_nvertices_selected(), end_editmesh_fastmalloc(), EditFaceC::f, EditEdge::f, EditVert::f, EditEdgeC::f, EditFace::f, EditVertC::f, UndoMesh::faces, UndoMesh::fdata, EditMesh::fdata, EditFace::fgonf, EditFaceC::fgonf, EditEdge::fgoni, EditEdgeC::fgoni, EditFace::flag, EditFaceC::flag, free_editMesh(), EditFaceC::h, EditEdge::h, EditVert::h, EditEdgeC::h, EditFace::h, EditVertC::h, EditSelectionC::index, init_editmesh_fastmalloc(), EditVert::keyindex, EditVertC::keyindex, EditFaceC::mat_nr, EditFace::mat_nr, MEM_callocN(), MEM_freeN(), MEM_mallocN(), EditVertC::no, EditVert::no, NULL, EditEdge::seam, EditEdgeC::seam, EditMesh::selected, UndoMesh::selected, EditMesh::selectmode, UndoMesh::selectmode, UndoMesh::shapenr, EditMesh::shapenr, EditEdge::sharp, EditEdgeC::sharp, UndoMesh::totedge, EditMesh::totedge, EditMesh::totface, UndoMesh::totface, UndoMesh::totsel, EditMesh::totvert, UndoMesh::totvert, EditSelection::type, EditSelectionC::type, EditEdgeC::v1, EditFaceC::v1, EditEdgeC::v2, EditFaceC::v2, EditFaceC::v3, EditFaceC::v4, UndoMesh::vdata, EditMesh::vdata, and UndoMesh::verts.

Referenced by undo_push_mesh().


Variable Documentation

void*(* callocedge)(EditMesh *, size_t, size_t) = calloc_em [static]

Definition at line 106 of file editmesh.c.

Referenced by addedgelist(), end_editmesh_fastmalloc(), and init_editmesh_fastmalloc().

void*(* callocface)(EditMesh *, size_t, size_t) = calloc_em [static]

Definition at line 107 of file editmesh.c.

Referenced by addfacelist(), end_editmesh_fastmalloc(), and init_editmesh_fastmalloc().

void*(* callocvert)(EditMesh *, size_t, size_t) = calloc_em [static]

Definition at line 105 of file editmesh.c.

Referenced by addvertlist(), end_editmesh_fastmalloc(), and init_editmesh_fastmalloc().

EditEdge** g_em_edge_array = NULL [static]

Definition at line 1871 of file editmesh.c.

EditFace** g_em_face_array = NULL [static]

Definition at line 1872 of file editmesh.c.

EditVert** g_em_vert_array = NULL [static]

Definition at line 1870 of file editmesh.c.

Initial value:
 {
    {0, "SELECTED", 0, "Selection", ""},
    {1, "MATERIAL", 0, "By Material", ""},
    {2, "LOOSE", 0, "By loose parts", ""},
    {0, NULL, 0, NULL, NULL}
}

Definition at line 1340 of file editmesh.c.