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:
authorLukas Tönne <lukas.toenne@gmail.com>2015-05-04 19:28:42 +0300
committerLukas Tönne <lukas.toenne@gmail.com>2015-05-04 19:37:45 +0300
commitd52bdb6d3dd4bab95900c9f08e2c9f6f660067e9 (patch)
tree06cb2c01126d2fd489247d7a534b1af217f84559 /source/blender/editors/hair
parent16b6d6c676a8222361bbebce4624f256d0c0a05a (diff)
Moved particle related functions of the strands edit mode into a
separate file. This may seem a bit like overkill, but it helps ensure that no particle depedencies messes up the strand editing code. The same will be done for other use cases of the strand editing code in the future.
Diffstat (limited to 'source/blender/editors/hair')
-rw-r--r--source/blender/editors/hair/CMakeLists.txt1
-rw-r--r--source/blender/editors/hair/hair_edit.c60
-rw-r--r--source/blender/editors/hair/hair_intern.h5
-rw-r--r--source/blender/editors/hair/hair_object_particles.c101
4 files changed, 110 insertions, 57 deletions
diff --git a/source/blender/editors/hair/CMakeLists.txt b/source/blender/editors/hair/CMakeLists.txt
index 62db4de4fb8..277484fa0af 100644
--- a/source/blender/editors/hair/CMakeLists.txt
+++ b/source/blender/editors/hair/CMakeLists.txt
@@ -41,6 +41,7 @@ set(SRC
hair_cursor.c
hair_edit.c
hair_mirror.c
+ hair_object_particles.c
hair_ops.c
hair_select.c
hair_stroke.c
diff --git a/source/blender/editors/hair/hair_edit.c b/source/blender/editors/hair/hair_edit.c
index a637673369e..2e99d83ef88 100644
--- a/source/blender/editors/hair/hair_edit.c
+++ b/source/blender/editors/hair/hair_edit.c
@@ -39,7 +39,6 @@
#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"
@@ -51,7 +50,6 @@
#include "BKE_DerivedMesh.h"
#include "BKE_editstrands.h"
#include "BKE_paint.h"
-#include "BKE_particle.h"
#include "bmesh.h"
@@ -62,63 +60,11 @@
#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;
@@ -182,7 +128,7 @@ int hair_edit_toggle_poll(bContext *C)
if (CTX_data_edit_object(C))
return false;
- return has_hair_data(ob);
+ return ED_hair_object_has_hair_particle_data(ob);
}
static void toggle_hair_cursor(bContext *C, bool enable)
@@ -216,14 +162,14 @@ static int hair_edit_toggle_exec(bContext *C, wmOperator *op)
}
if (!is_mode_set) {
- init_hair_edit(scene, ob);
+ ED_hair_object_init_particle_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);
+ ED_hair_object_apply_particle_edit(ob);
ob->mode &= ~mode_flag;
toggle_hair_cursor(C, false);
diff --git a/source/blender/editors/hair/hair_intern.h b/source/blender/editors/hair/hair_intern.h
index 9644237517c..d26e9cf59a7 100644
--- a/source/blender/editors/hair/hair_intern.h
+++ b/source/blender/editors/hair/hair_intern.h
@@ -59,6 +59,11 @@ void HAIR_OT_select_linked(struct wmOperatorType *ot);
/* hair_stroke.c */
void HAIR_OT_stroke(struct wmOperatorType *ot);
+/* hair_object_particles.c */
+bool ED_hair_object_has_hair_particle_data(struct Object *ob);
+bool ED_hair_object_init_particle_edit(struct Scene *scene, struct Object *ob);
+bool ED_hair_object_apply_particle_edit(struct Object *ob);
+
/* ==== Hair Brush ==== */
diff --git a/source/blender/editors/hair/hair_object_particles.c b/source/blender/editors/hair/hair_object_particles.c
new file mode 100644
index 00000000000..6cd60c132c6
--- /dev/null
+++ b/source/blender/editors/hair/hair_object_particles.c
@@ -0,0 +1,101 @@
+/*
+ * ***** 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_object_particles.c
+ * \ingroup edhair
+ */
+
+#include <stdlib.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_utildefines.h"
+
+#include "DNA_mesh_types.h"
+#include "DNA_object_types.h"
+#include "DNA_particle_types.h"
+#include "DNA_scene_types.h"
+
+#include "BKE_cdderivedmesh.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_editstrands.h"
+#include "BKE_particle.h"
+
+#include "bmesh.h"
+
+#include "hair_intern.h"
+
+bool ED_hair_object_has_hair_particle_data(Object *ob)
+{
+ ParticleSystem *psys = psys_get_current(ob);
+ if (psys && psys->part->type == PART_HAIR)
+ return true;
+
+ return false;
+}
+
+bool ED_hair_object_init_particle_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;
+}
+
+bool ED_hair_object_apply_particle_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;
+}