[Bf-blender-cvs] [eb52570] strand_editmode: New drawing code for hair edit mode.
Lukas Tönne
noreply at git.blender.org
Mon Apr 20 14:23:08 CEST 2015
Commit: eb5257002bfd65b92c713a96a524ccf7c19bca9d
Author: Lukas Tönne
Date: Fri Nov 28 17:09:39 2014 +0100
Branches: strand_editmode
https://developer.blender.org/rBeb5257002bfd65b92c713a96a524ccf7c19bca9d
New drawing code for hair edit mode.
Conflicts:
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_intern.h
===================================================================
M source/blender/blenkernel/BKE_edithair.h
M source/blender/blenkernel/intern/edithair.c
M source/blender/bmesh/intern/bmesh_strands.c
M source/blender/bmesh/intern/bmesh_strands.h
M source/blender/bmesh/intern/bmesh_strands_conv.c
M source/blender/editors/space_view3d/CMakeLists.txt
M source/blender/editors/space_view3d/drawobject.c
A source/blender/editors/space_view3d/drawstrands.c
M source/blender/editors/space_view3d/view3d_intern.h
===================================================================
diff --git a/source/blender/blenkernel/BKE_edithair.h b/source/blender/blenkernel/BKE_edithair.h
index e579a23..ff3d91f 100644
--- a/source/blender/blenkernel/BKE_edithair.h
+++ b/source/blender/blenkernel/BKE_edithair.h
@@ -39,6 +39,8 @@
#include "BKE_customdata.h"
#include "bmesh.h"
+struct Object;
+
typedef struct BMEditStrands {
struct BMesh *bm;
@@ -51,10 +53,14 @@ typedef struct BMEditStrands {
/* Object this editmesh came from (if it came from one) */
struct Object *ob;
+
+ unsigned int vertex_glbuf;
+ unsigned int elem_glbuf;
} BMEditStrands;
struct BMEditStrands *BKE_editstrands_create(struct BMesh *bm);
struct BMEditStrands *BKE_editstrands_copy(struct BMEditStrands *em);
+struct BMEditStrands *BKE_editstrands_from_object(struct Object *ob);
void BKE_editstrands_update_linked_customdata(struct BMEditStrands *em);
void BKE_editstrands_free(struct BMEditStrands *em);
diff --git a/source/blender/blenkernel/intern/edithair.c b/source/blender/blenkernel/intern/edithair.c
index 67a8fc0..4bd5a8a 100644
--- a/source/blender/blenkernel/intern/edithair.c
+++ b/source/blender/blenkernel/intern/edithair.c
@@ -56,29 +56,41 @@ BMEditStrands *BKE_editstrands_create(BMesh *bm)
return es;
}
-BMEditStrands *BKE_editstrands_copy(BMEditStrands *em)
+BMEditStrands *BKE_editstrands_copy(BMEditStrands *es)
{
BMEditStrands *es_copy = MEM_callocN(sizeof(BMEditStrands), __func__);
- *es_copy = *em;
+ *es_copy = *es;
- es_copy->bm = BM_mesh_copy(em->bm);
+ es_copy->bm = BM_mesh_copy(es->bm);
return es_copy;
}
-void BKE_editstrands_update_linked_customdata(BMEditStrands *em)
+/**
+ * \brief Return the BMEditStrands for a given object
+ */
+BMEditStrands *BKE_editstrands_from_object(Object *ob)
+{
+ ParticleSystem *psys = psys_get_current(ob);
+ if (psys) {
+ return psys->hairedit;
+ }
+ return NULL;
+}
+
+void BKE_editstrands_update_linked_customdata(BMEditStrands *es)
{
- BMesh *bm = em->bm;
+ BMesh *bm = es->bm;
/* this is done for BMEditMesh, but should never exist for strands */
BLI_assert(!CustomData_has_layer(&bm->pdata, CD_MTEXPOLY));
}
/*does not free the BMEditStrands struct itself*/
-void BKE_editstrands_free(BMEditStrands *em)
+void BKE_editstrands_free(BMEditStrands *es)
{
- if (em->bm)
- BM_mesh_free(em->bm);
+ if (es->bm)
+ BM_mesh_free(es->bm);
}
/* === particle conversion === */
diff --git a/source/blender/bmesh/intern/bmesh_strands.c b/source/blender/bmesh/intern/bmesh_strands.c
index 09bc574..ae8fd7a 100644
--- a/source/blender/bmesh/intern/bmesh_strands.c
+++ b/source/blender/bmesh/intern/bmesh_strands.c
@@ -86,3 +86,32 @@ void *bmstranditer__verts_of_strand_step(struct BMIter__vert_of_strand *iter)
return v_curr;
}
+
+/* ------------------------------------------------------------------------- */
+
+int BM_strands_count(BMesh *bm)
+{
+ BMVert *v;
+ BMIter iter;
+
+ int count = 0;
+ BM_ITER_STRANDS(v, &iter, bm, BM_STRANDS_OF_MESH) {
+ ++count;
+ }
+
+ return count;
+}
+
+int BM_strands_keys_count(BMVert *root)
+{
+ BMVert *v;
+ BMIter iter;
+
+ int count = 0;
+ BM_ITER_STRANDS_ELEM(v, &iter, root, BM_VERTS_OF_STRAND) {
+ ++count;
+ }
+
+ return count;
+}
+
diff --git a/source/blender/bmesh/intern/bmesh_strands.h b/source/blender/bmesh/intern/bmesh_strands.h
index f2c8bf5..7df7eb6 100644
--- a/source/blender/bmesh/intern/bmesh_strands.h
+++ b/source/blender/bmesh/intern/bmesh_strands.h
@@ -51,6 +51,9 @@ BLI_INLINE bool BM_strands_vert_is_root(BMVert *v)
return false;
}
+int BM_strands_count(BMesh *bm);
+int BM_strands_keys_count(BMVert *root);
+
/* ==== Iterators ==== */
typedef enum BMStrandsIterType {
diff --git a/source/blender/bmesh/intern/bmesh_strands_conv.c b/source/blender/bmesh/intern/bmesh_strands_conv.c
index 5238c24..95ee8cd 100644
--- a/source/blender/bmesh/intern/bmesh_strands_conv.c
+++ b/source/blender/bmesh/intern/bmesh_strands_conv.c
@@ -177,7 +177,7 @@ static void bm_make_particles(BMesh *bm, ParticleSystem *psys, struct DerivedMes
ParticleData *pa;
HairKey *hkey;
int p, k, j;
- int vindex;
+ int vindex, eindex;
BMVert *v = NULL, *v_prev;
BMEdge *e;
@@ -185,13 +185,14 @@ static void bm_make_particles(BMesh *bm, ParticleSystem *psys, struct DerivedMes
float mass = psys->part->mass;
vindex = 0;
+ eindex = 0;
for (p = 0, pa = psys->particles; p < psys->totpart; ++p, ++pa) {
- for (k = 0, hkey = pa->hair; k < pa->totkey; ++k, ++hkey, ++vindex) {
+ for (k = 0, hkey = pa->hair; k < pa->totkey; ++k, ++hkey) {
v_prev = v;
v = BM_vert_create(bm, keyco ? keyco[vindex] : hkey->co, NULL, BM_CREATE_SKIP_CD);
- BM_elem_index_set(v, vindex); /* set_ok */
+ BM_elem_index_set(v, vindex++); /* set_ok */
/* transfer flag */
// v->head.hflag = BM_vert_flag_from_mflag(mvert->flag & ~SELECT);
@@ -234,7 +235,7 @@ static void bm_make_particles(BMesh *bm, ParticleSystem *psys, struct DerivedMes
if (k > 0) {
e = BM_edge_create(bm, v_prev, v, NULL, BM_CREATE_SKIP_CD);
- BM_elem_index_set(e, vindex - p); /* set_ok; one less edge than vertices for each particle */
+ BM_elem_index_set(e, eindex++); /* set_ok; one less edge than vertices for each particle */
/* transfer flags */
// e->head.hflag = BM_edge_flag_from_mflag(medge->flag & ~SELECT);
@@ -428,35 +429,9 @@ BLI_INLINE void bmesh_quick_edgedraw_flag(MEdge *med, BMEdge *e)
}
#endif
-static int bm_strands_count(BMesh *bm)
-{
- BMVert *v;
- BMIter iter;
-
- int count = 0;
- BM_ITER_STRANDS(v, &iter, bm, BM_STRANDS_OF_MESH) {
- ++count;
- }
-
- return count;
-}
-
-static int bm_keys_count(BMVert *root)
-{
- BMVert *v;
- BMIter iter;
-
- int count = 0;
- BM_ITER_STRANDS_ELEM(v, &iter, root, BM_VERTS_OF_STRAND) {
- ++count;
- }
-
- return count;
-}
-
static void make_particle_hair(BMesh *bm, BMVert *root, ParticleSystem *psys, struct DerivedMesh *emitter_dm, struct BVHTreeFromMesh *emitter_bvhtree, struct ParticleData *pa)
{
- int totkey = bm_keys_count(root);
+ int totkey = BM_strands_keys_count(root);
HairKey *hair;
BMVert *v;
@@ -527,7 +502,7 @@ void BM_strands_bm_to_psys(BMesh *bm, ParticleSystem *psys, struct DerivedMesh *
ototpart = psys->totpart;
ototkey = BM_strands_count_psys_keys(psys);
- ntotpart = bm_strands_count(bm);
+ ntotpart = BM_strands_count(bm);
/* new particles block */
if (bm->totvert == 0) particles = NULL;
diff --git a/source/blender/editors/space_view3d/CMakeLists.txt b/source/blender/editors/space_view3d/CMakeLists.txt
index ab69e67..7d36931 100644
--- a/source/blender/editors/space_view3d/CMakeLists.txt
+++ b/source/blender/editors/space_view3d/CMakeLists.txt
@@ -45,6 +45,7 @@ set(SRC
drawmesh.c
drawobject.c
drawsimdebug.c
+ drawstrands.c
drawvolume.c
space_view3d.c
view3d_buttons.c
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index ece195a..2c1ed2f 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -58,6 +58,7 @@
#include "BKE_DerivedMesh.h"
#include "BKE_deform.h"
#include "BKE_displist.h"
+#include "BKE_edithair.h"
#include "BKE_font.h"
#include "BKE_global.h"
#include "BKE_image.h"
@@ -7925,14 +7926,16 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
view3d_cached_text_draw_begin();
for (psys = ob->particlesystem.first; psys; psys = psys->next) {
- /* run this so that possible child particles get cached */
- if (ob->mode & OB_MODE_PARTICLE_EDIT && is_obact) {
- PTCacheEdit *edit = PE_create_current(scene, ob);
- if (edit && edit->psys == psys)
- draw_update_ptcache_edit(scene, ob, edit);
+ if (!(ob->mode & OB_MODE_HAIR_EDIT)) {
+ /* run this so that possible child particles get cached */
+ if (ob->mode & OB_MODE_PARTICLE_EDIT && is_obact) {
+ PTCacheEdit *edit = PE_create_current(scene, ob);
+ if (edit && edit->psys == psys)
+ draw_update_ptcache_edit(scene, ob, edit);
+ }
+
+ draw_new_particle_system(scene, v3d, rv3d, base, psys, dt, dflag);
}
-
- draw_new_particle_system(scene, v3d, rv3d, base, psys, dt, dflag);
}
invert_m4_m4(ob->imat, ob->obmat);
view3d_cached_text_draw_end(v3d, ar, 0, NULL);
@@ -7957,6 +7960,13 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short
glMultMatrixf(ob->obmat);
}
}
+
+ if (ob->mode & OB_MODE_HAIR_EDIT && is_obact) {
+ BMEditStrands *edit = BKE_editstrands_from_object(ob);
+ if (edit) {
+ draw_strands_edit(scene, v3d, edit);
+ }
+ }
}
/* draw code for smoke */
diff --git a/source/blender/editors/space_view3d/drawstrands.c b/source/blender/editors/space_view3d/drawstrands.c
new file mode 100644
index 0000000..1638fdd
--- /dev/null
+++ b/source/blender/editors/space_view3d/drawstrands.c
@@ -0,0 +1,144 @@
+/*
+ * ***** 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.
+ *
+ * Contributor(s): Lukas Toenne.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/space_view3d/drawstrands.c
+ * \ingroup spview3d
+ */
+
+#include "BLI_utildefines.h"
+#include "BLI_math.h"
+
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_view3d_types.h"
+
+#include "BKE_edithair.h"
+#include "BKE_main.h"
+
+#include "bmesh.h"
+
+#include "ED_screen.h"
+#include "ED_types.h"
+
+#include "UI_resources.h"
+#include "UI_interface_icons.h"
+
+#include "BIF_gl.h"
+#include "BIF_glutil.h"
+
+#include "GPU_
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list