[Bf-blender-cvs] [bf7e8b4] strand_editmode: Merge branch 'master' into strand_editmode
Lukas Tönne
noreply at git.blender.org
Mon May 4 17:14:39 CEST 2015
Commit: bf7e8b42fa269c310e456fa55263ff2d9849804e
Author: Lukas Tönne
Date: Mon May 4 17:00:40 2015 +0200
Branches: strand_editmode
https://developer.blender.org/rBbf7e8b42fa269c310e456fa55263ff2d9849804e
Merge branch 'master' into strand_editmode
Conflicts:
source/blender/bmesh/bmesh_class.h
source/blender/bmesh/intern/bmesh_mesh_conv.h
===================================================================
===================================================================
diff --cc source/blender/bmesh/bmesh_class.h
index 75de216,ada0fab..058fec5
--- a/source/blender/bmesh/bmesh_class.h
+++ b/source/blender/bmesh/bmesh_class.h
@@@ -256,19 -256,28 +256,36 @@@ enum
#define BM_ALL (BM_VERT | BM_EDGE | BM_LOOP | BM_FACE)
#define BM_ALL_NOLOOP (BM_VERT | BM_EDGE | BM_FACE)
+ /* args for _Generic */
+ #define _BM_GENERIC_TYPE_ELEM_NONCONST \
+ void *, BMVert *, BMEdge *, BMLoop *, BMFace *, \
+ BMElem *, BMElemF *, BMHeader *
+
+ #define _BM_GENERIC_TYPE_ELEM_CONST \
+ const void *, const BMVert *, const BMEdge *, const BMLoop *, const BMFace *, \
+ const BMElem *, const BMElemF *, const BMHeader *, \
+ void * const, BMVert * const, BMEdge * const, BMLoop * const, BMFace * const, \
+ BMElem * const, BMElemF * const, BMHeader * const
+
+ #define BM_CHECK_TYPE_ELEM_CONST(ele) \
+ CHECK_TYPE_ANY(ele, _BM_GENERIC_TYPES_CONST)
+
+ #define BM_CHECK_TYPE_ELEM_NONCONST(ele) \
+ CHECK_TYPE_ANY(ele, _BM_GENERIC_TYPE_ELEM_NONCONST)
+
#define BM_CHECK_TYPE_ELEM(ele) \
- CHECK_TYPE_ANY(ele, void *, BMFace *, BMEdge *, BMVert *, BMLoop *, BMElem *, BMElemF *, BMHeader *)
+ CHECK_TYPE_ANY(ele, _BM_GENERIC_TYPE_ELEM_NONCONST, _BM_GENERIC_TYPE_ELEM_CONST)
+#ifndef __cplusplus
#define BM_CHECK_TYPE_ELEM_ASSIGN(ele) \
- (BM_CHECK_TYPE_ELEM(ele), CHECK_TYPE_NONCONST(ele)), ele
+ (BM_CHECK_TYPE_ELEM(ele)), ele
+#else
+/* for C++: cast the lhs to a void*,
+ * because C++ does not allow implicit void* casting of the rhs
+ */
+#define BM_CHECK_TYPE_ELEM_ASSIGN(ele) \
+ (BM_CHECK_TYPE_ELEM(ele), CHECK_TYPE_NONCONST(ele)), *(void**)(&(ele))
+#endif
/* BMHeader->hflag (char) */
enum {
diff --cc source/blender/bmesh/intern/bmesh_mesh_conv.c
index 9852113,24d70ce..a0ef12c
--- a/source/blender/bmesh/intern/bmesh_mesh_conv.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c
@@@ -224,20 -222,10 +225,21 @@@ static BMFace *bm_face_create_from_mpol
*
* \warning This function doesn't calculate face normals.
*/
- void BM_mesh_bm_from_me(BMesh *bm, Mesh *me,
- const bool calc_face_normal, const bool set_key, int act_key_nr)
+ void BM_mesh_bm_from_me(
+ BMesh *bm, Mesh *me,
+ const bool calc_face_normal, const bool set_key, int act_key_nr)
{
+ BM_mesh_bm_from_me_ex(bm, me, CD_MASK_BMESH, calc_face_normal, set_key, act_key_nr);
+}
+
+/**
+ * \brief Mesh -> BMesh
+ *
+ * \warning This function doesn't calculate face normals.
+ */
+void BM_mesh_bm_from_me_ex(BMesh *bm, Mesh *me, CustomDataMask mask,
+ const bool calc_face_normal, const bool set_key, int act_key_nr)
+{
MVert *mvert;
MEdge *medge;
MLoop *mloop;
diff --cc source/blender/bmesh/intern/bmesh_mesh_conv.h
index f910c69,ce286f6..0d235a1
--- a/source/blender/bmesh/intern/bmesh_mesh_conv.h
+++ b/source/blender/bmesh/intern/bmesh_mesh_conv.h
@@@ -42,11 -39,9 +42,12 @@@ void BM_mesh_cd_flag_ensure(BMesh *bm,
void BM_mesh_cd_flag_apply(BMesh *bm, const char cd_flag);
char BM_mesh_cd_flag_from_bmesh(BMesh *bm);
- void BM_mesh_bm_from_me(BMesh *bm, struct Mesh *me,
- const bool calc_face_normal, const bool set_key, int act_key_nr);
+ void BM_mesh_bm_from_me(
+ BMesh *bm, struct Mesh *me,
+ const bool calc_face_normal, const bool set_key, int act_key_nr);
+void BM_mesh_bm_from_me_ex(BMesh *bm, struct Mesh *me, CustomDataMask mask,
+ const bool calc_face_normal, const bool set_key, int act_key_nr);
void BM_mesh_bm_to_me(BMesh *bm, struct Mesh *me, bool do_tessface);
+void BM_mesh_bm_to_me_ex(BMesh *bm, struct Mesh *me, CustomDataMask mask, bool do_tessface);
#endif /* __BMESH_MESH_CONV_H__ */
diff --cc source/blender/editors/hair/hair_edit.c
index 6705991,0000000..a637673
mode 100644,000000..100644
--- a/source/blender/editors/hair/hair_edit.c
+++ b/source/blender/editors/hair/hair_edit.c
@@@ -1,503 -1,0 +1,503 @@@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) Blender Foundation
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Lukas Toenne
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/hair/hair_edit.c
+ * \ingroup edhair
+ */
+
+#include <stdlib.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_utildefines.h"
+#include "BLI_math.h"
+
+#include "DNA_brush_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_object_types.h"
+#include "DNA_particle_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_view3d_types.h"
+
+#include "BKE_brush.h"
+#include "BKE_cdderivedmesh.h"
+#include "BKE_context.h"
+#include "BKE_depsgraph.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_editstrands.h"
+#include "BKE_paint.h"
+#include "BKE_particle.h"
+
+#include "bmesh.h"
+
+#include "RNA_access.h"
+#include "RNA_define.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "ED_object.h"
+#include "ED_physics.h"
+#include "ED_view3d.h"
+
+#include "hair_intern.h"
+#include "paint_intern.h"
+
+static bool has_hair_data(Object *ob)
+{
+ ParticleSystem *psys = psys_get_current(ob);
+ if (psys && psys->part->type == PART_HAIR)
+ return true;
+
+ return false;
+}
+
+static bool init_hair_edit(Scene *scene, Object *ob)
+{
+ ParticleSystem *psys = psys_get_current(ob);
+ BMesh *bm;
+ DerivedMesh *dm;
+
+ if (psys && psys->part->type == PART_HAIR) {
+ if (!psys->hairedit) {
+ bm = BKE_particles_to_bmesh(ob, psys);
+
+ if (ob->type == OB_MESH || ob->derivedFinal)
+ dm = ob->derivedFinal ? ob->derivedFinal : mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
+ else
+ dm = NULL;
+
+ psys->hairedit = BKE_editstrands_create(bm, dm);
+ }
+ return true;
+ }
+
+ return false;
+}
+
+static bool apply_hair_edit(Object *ob)
+{
+ ParticleSystem *psys = psys_get_current(ob);
+ if (psys->part->type == PART_HAIR) {
+ if (psys->hairedit) {
+ BKE_particles_from_bmesh(ob, psys);
+ psys->flag |= PSYS_EDITED;
+
+ BKE_editstrands_free(psys->hairedit);
+ MEM_freeN(psys->hairedit);
+ psys->hairedit = NULL;
+ }
+
+ return true;
+ }
+
+ return false;
+}
+
+int hair_edit_poll(bContext *C)
+{
+ Object *obact;
+
+ obact = CTX_data_active_object(C);
+ if ((obact && obact->mode & OB_MODE_HAIR_EDIT) && CTX_wm_region_view3d(C)) {
+ return true;
+ }
+
+ return false;
+}
+
+bool hair_use_mirror_x(Object *ob)
+{
+ if (ob->type == OB_MESH)
+ return ((Mesh *)ob->data)->editflag & ME_EDIT_MIRROR_X;
+ else
+ return false;
+}
+
+bool hair_use_mirror_topology(Object *ob)
+{
+ if (ob->type == OB_MESH)
+ return ((Mesh *)ob->data)->editflag & ME_EDIT_MIRROR_TOPO;
+ else
+ return false;
+}
+
+
+/* ==== BMesh utilities ==== */
+
+void hair_bm_min_max(BMEditStrands *edit, float min[3], float max[3])
+{
+ BMVert *v;
+ BMIter iter;
+
+ if (edit->bm->totvert > 0) {
+ INIT_MINMAX(min, max);
+
+ BM_ITER_MESH(v, &iter, edit->bm, BM_VERTS_OF_MESH) {
+ minmax_v3v3_v3(min, max, v->co);
+ }
+ }
+ else {
+ zero_v3(min);
+ zero_v3(max);
+ }
+}
+
+
+/* ==== edit mode toggle ==== */
+
+int hair_edit_toggle_poll(bContext *C)
+{
+ Object *ob = CTX_data_active_object(C);
+
+ if (ob == NULL)
+ return false;
+ if (!ob->data || ((ID *)ob->data)->lib)
+ return false;
+ if (CTX_data_edit_object(C))
+ return false;
+
+ return has_hair_data(ob);
+}
+
+static void toggle_hair_cursor(bContext *C, bool enable)
+{
+ wmWindowManager *wm = CTX_wm_manager(C);
+ Scene *scene = CTX_data_scene(C);
+ HairEditSettings *settings = &scene->toolsettings->hair_edit;
+
+ if (enable) {
+ hair_edit_cursor_start(C, hair_edit_toggle_poll);
+ }
+ else {
+ if (settings->paint_cursor) {
+ WM_paint_cursor_end(wm, settings->paint_cursor);
+ settings->paint_cursor = NULL;
+ }
+ }
+}
+
+static int hair_edit_toggle_exec(bContext *C, wmOperator *op)
+{
+ Scene *scene = CTX_data_scene(C);
+ Object *ob = CTX_data_active_object(C);
+ const int mode_flag = OB_MODE_HAIR_EDIT;
+ const bool is_mode_set = (ob->mode & mode_flag) != 0;
+
+ if (!is_mode_set) {
+ if (!ED_object_mode_compat_set(C, ob, mode_flag, op->reports)) {
+ return OPERATOR_CANCELLED;
+ }
+ }
+
+ if (!is_mode_set) {
+ init_hair_edit(scene, ob);
+ ob->mode |= mode_flag;
+
+ toggle_hair_cursor(C, true);
+ WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_HAIR, NULL);
+ }
+ else {
+ apply_hair_edit(ob);
+ ob->mode &= ~mode_flag;
+
+ toggle_hair_cursor(C, false);
+ WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_HAIR, NULL);
+ }
+
+ DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
+
+ return OPERATOR_FINISHED;
+}
+
+void HAIR_OT_hair_edit_toggle(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Hair Edit Toggle";
+ ot->idname = "HAIR_OT_hair_edit_toggle";
+ ot->description = "Toggle hair edit mode";
+
+ /* api callbacks */
+ ot->exec = hair_edit_toggle_exec;
+ ot->poll = hair_edit_toggle_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+
+/* ==== brush stroke ==== */
+
+void hair_init_viewdata(bContext *C, HairViewData *viewdata)
+{
+ View3D *v3d;
+ bool has_zbuf;
+
+ view3d_set_viewcontext(C, &viewdata->vc);
+
+ v3d = viewdata->vc.v3d;
+ has_zbuf = (v3d->drawtype > OB_WIRE) && (v3d->flag & V3D_ZBUF_SELE
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list