[Bf-blender-cvs] [23b2843] strand_editmode: Removed deprecated code.

Lukas Tönne noreply at git.blender.org
Mon Apr 20 14:23:07 CEST 2015


Commit: 23b284348b86656dda539ff4dd00de0c8bc41e64
Author: Lukas Tönne
Date:   Fri Nov 28 14:21:11 2014 +0100
Branches: strand_editmode
https://developer.blender.org/rB23b284348b86656dda539ff4dd00de0c8bc41e64

Removed deprecated code.

===================================================================

M	source/blender/blenkernel/CMakeLists.txt
M	source/blender/blenkernel/intern/edithair.c
D	source/blender/blenkernel/intern/edithair_inline.h
D	source/blender/blenkernel/intern/edithair_particles.c

===================================================================

diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index bf1ca41..54d0e4d 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -92,9 +92,7 @@ set(SRC
 	intern/displist.c
 	intern/dynamicpaint.c
 	intern/editderivedmesh.c
-	intern/edithair_inline.h
 	intern/edithair.c
-	intern/edithair_particles.c
 	intern/editmesh.c
 	intern/editmesh_bvh.c
 	intern/effect.c
diff --git a/source/blender/blenkernel/intern/edithair.c b/source/blender/blenkernel/intern/edithair.c
index 30d1a11..67a8fc0 100644
--- a/source/blender/blenkernel/intern/edithair.c
+++ b/source/blender/blenkernel/intern/edithair.c
@@ -35,9 +35,17 @@
 #include "BLI_mempool.h"
 
 #include "DNA_customdata_types.h"
+#include "DNA_modifier_types.h"
+#include "DNA_object_types.h"
+#include "DNA_particle_types.h"
 
+#include "BKE_bvhutils.h"
 #include "BKE_customdata.h"
 #include "BKE_edithair.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_particle.h"
+
+#include "intern/bmesh_strands_conv.h"
 
 BMEditStrands *BKE_editstrands_create(BMesh *bm)
 {
@@ -73,221 +81,42 @@ void BKE_editstrands_free(BMEditStrands *em)
 		BM_mesh_free(em->bm);
 }
 
-#if 0
-static const int chunksize_default_totcurve = 512;
-static const int allocsize_default_totcurve = 512;
-
-static const int chunksize_default_totvert = 1024;
-static const int allocsize_default_totvert = 1024;
-
-static void edithair_mempool_init(HairEditData *hedit)
-{
-	hedit->cpool = BLI_mempool_create(sizeof(HairEditCurve), allocsize_default_totcurve,
-	                                  chunksize_default_totcurve, BLI_MEMPOOL_ALLOW_ITER);
-	hedit->vpool = BLI_mempool_create(sizeof(HairEditVertex), allocsize_default_totvert,
-	                                  chunksize_default_totvert, BLI_MEMPOOL_ALLOW_ITER);
-}
+/* === particle conversion === */
 
-HairEditData *BKE_edithair_create(void)
+BMesh *BKE_particles_to_bmesh(Object *ob, ParticleSystem *psys)
 {
-	HairEditData *hedit = MEM_callocN(sizeof(HairEditData), "hair edit data");
-	
-	edithair_mempool_init(hedit);
+	ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
 	
-	CustomData_reset(&hedit->cdata);
-	CustomData_reset(&hedit->vdata);
-	
-	return hedit;
-}
-
-void BKE_edithair_data_free(HairEditData *hedit)
-{
-	if (CustomData_bmesh_has_free(&(hedit->cdata))) {
-		HairEditCurve *curve;
-		HairEditIter iter;
-		HAIREDIT_ITER(curve, &iter, hedit, HAIREDIT_CURVES_OF_MESH) {
-			CustomData_bmesh_free_block(&hedit->cdata, &curve->data);
-		}
-	}
-	
-	if (CustomData_bmesh_has_free(&(hedit->vdata))) {
-		HairEditVertex *vert;
-		HairEditIter iter;
-		HAIREDIT_ITER(vert, &iter, hedit, HAIREDIT_VERTS_OF_MESH) {
-			CustomData_bmesh_free_block(&hedit->vdata, &vert->data);
-		}
-	}
-	
-	/* Free custom data pools, This should probably go in CustomData_free? */
-	if (hedit->cdata.totlayer) BLI_mempool_destroy(hedit->cdata.pool);
-	if (hedit->vdata.totlayer) BLI_mempool_destroy(hedit->vdata.pool);
-	
-	/* free custom data */
-	CustomData_free(&hedit->cdata, 0);
-	CustomData_free(&hedit->vdata, 0);
-
-	/* destroy element pools */
-	BLI_mempool_destroy(hedit->cpool);
-	BLI_mempool_destroy(hedit->vpool);
-}
-
-void BKE_edithair_clear(HairEditData *hedit)
-{
-	/* free old data */
-	BKE_edithair_data_free(hedit);
-	memset(hedit, 0, sizeof(HairEditData));
+	const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_PSYS(psys);
+	BMesh *bm;
 
-	/* allocate the memory pools for the hair elements */
-	edithair_mempool_init(hedit);
+	bm = BM_mesh_create(&allocsize);
 
-	CustomData_reset(&hedit->cdata);
-	CustomData_reset(&hedit->vdata);
-}
-
-void BKE_edithair_free(HairEditData *hedit)
-{
-	BKE_edithair_data_free(hedit);
-	
-	MEM_freeN(hedit);
-}
-
-void BKE_edithair_get_min_max(HairEditData *hedit, float r_min[3], float r_max[3])
-{
-	if (hedit->totverts) {
-		HairEditVertex *vert;
-		HairEditIter iter;
-		
-		INIT_MINMAX(r_min, r_max);
+	if (psmd && psmd->dm) {
+		DM_ensure_tessface(psmd->dm);
 		
-		HAIREDIT_ITER(vert, &iter, hedit, HAIREDIT_VERTS_OF_MESH) {
-			minmax_v3v3_v3(r_min, r_max, vert->co);
-		}
-	}
-	else {
-		zero_v3(r_min);
-		zero_v3(r_max);
-	}
-}
-
-HairEditCurve *BKE_edithair_curve_create(HairEditData *hedit, HairEditCurve *example)
-{
-	HairEditCurve *c = NULL;
-
-	c = BLI_mempool_alloc(hedit->cpool);
-
-	/* --- assign all members --- */
-	c->data = NULL;
-
-	c->v = NULL;
-	/* --- done --- */
-
-	hedit->totcurves++;
-
-	if (example) {
-		CustomData_bmesh_copy_data(&hedit->cdata, &hedit->cdata, example->data, &c->data);
-	}
-	else {
-		CustomData_bmesh_set_default(&hedit->cdata, &c->data);
-	}
-
-	return c;
-}
-
-int BKE_edithair_curve_vertex_count(HairEditData *UNUSED(hedit), HairEditCurve *c)
-{
-	const HairEditVertex *v;
-	int count = 0;
-	for (v = c->v; v; v = v->next) {
-		++count;
+		BM_strands_bm_from_psys(bm, psys, psmd->dm, true, psys->shapenr);
 	}
-	return count;
-}
-
-static HairEditVertex *edithair_vertex_create(HairEditData *hedit, HairEditVertex *example)
-{
-	HairEditVertex *v = NULL;
-
-	v = BLI_mempool_alloc(hedit->vpool);
-
-	/* --- assign all members --- */
-	v->data = NULL;
-
-	v->next = v->prev = NULL;
-	/* --- done --- */
-
-	hedit->totverts++;
 
-	if (example) {
-		CustomData_bmesh_copy_data(&hedit->vdata, &hedit->vdata, example->data, &v->data);
-	}
-	else {
-		CustomData_bmesh_set_default(&hedit->vdata, &v->data);
-	}
-
-	return v;
+	return bm;
 }
 
-HairEditVertex *BKE_edithair_curve_extend(HairEditData *hedit, HairEditCurve *c, HairEditVertex *example, int num)
+void BKE_particles_from_bmesh(Object *ob, ParticleSystem *psys)
 {
-	HairEditVertex *v_first = NULL;
-	int i;
-	
-	for (i = 0; i < num; ++i) {
-		HairEditVertex *v = edithair_vertex_create(hedit, example);
-		if (i == 0)
-			v_first = v;
-		
-		v->prev = c->v;
-		if (c->v)
-			c->v->next = v;
-		c->v = v;
-	}
+	ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
+	BMesh *bm = psys->hairedit ? psys->hairedit->bm : NULL;
 	
-	return v_first;
-}
-
-/* ==== Iterators ==== */
-
-/*
- * CURVE OF MESH CALLBACKS
- */
-
-void hairedit_iter__elem_of_mesh_begin(struct HairEditIter__elem_of_mesh *iter)
-{
-	BLI_mempool_iternew(iter->pooliter.pool, &iter->pooliter);
-}
-
-void *hairedit_iter__elem_of_mesh_step(struct HairEditIter__elem_of_mesh *iter)
-{
-	return BLI_mempool_iterstep(&iter->pooliter);
-}
-
-/*
- * VERT OF CURVE CALLBACKS
- */
-
-void  hairedit_iter__vert_of_curve_begin(struct HairEditIter__vert_of_curve *iter)
-{
-	if (iter->cdata->v) {
-		iter->v_first = iter->cdata->v;
-		iter->v_next = iter->cdata->v;
-	}
-	else {
-		iter->v_first = NULL;
-		iter->v_next = NULL;
-	}
-}
-
-void  *hairedit_iter__vert_of_curve_step(struct HairEditIter__vert_of_curve *iter)
-{
-	HairEditVertex *v_curr = iter->v_next;
-
-	if (iter->v_next) {
-		iter->v_next = iter->v_next->next;
+	if (bm) {
+		if (psmd && psmd->dm) {
+			BVHTreeFromMesh bvhtree = {NULL};
+			
+			DM_ensure_tessface(psmd->dm);
+			
+			bvhtree_from_mesh_faces(&bvhtree, psmd->dm, 0.0, 2, 6);
+			
+			BM_strands_bm_to_psys(bm, psys, psmd->dm, &bvhtree);
+			
+			free_bvhtree_from_mesh(&bvhtree);
+		}
 	}
-
-	return v_curr;
 }
-
-/* =================== */
-#endif
diff --git a/source/blender/blenkernel/intern/edithair_inline.h b/source/blender/blenkernel/intern/edithair_inline.h
deleted file mode 100644
index a95162c..0000000
--- a/source/blender/blenkernel/intern/edithair_inline.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * ***** 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 *****
- */
-
-#ifndef __EDITHAIR_INLINE_H__
-#define __EDITHAIR_INLINE_H__
-
-/** \file blender/editors/hair/edithair_inline.h
- *  \ingroup bke
- */
-
-#include "BLI_mempool.h"
-#include "BLI_utildefines.h"
-
-#include "BKE_edithair.h"
-
-/* iterator type structs */
-struct HairEditIter__elem_of_mesh {
-	BLI_mempool_iter pooliter;
-};
-struct HairEditIter__vert_of_curve {
-	HairEditCurve *cdata;
-	HairEditVertex *v_first, *v_next;
-};
-
-typedef void  (*HairEditIter__begin_cb) (void *);
-typedef void *(*HairEditIter__step_cb) (void *);
-
-typedef struct HairEditIter {
-	/* keep union first */
-	union {
-		struct HairEditIter__elem_of_mesh elem_of_mesh;
-		struct HairEditIter__vert_of_curve vert_of_curve;
-	} data;
-
-	HairEditIter__begin_cb begin;
-	HairEditIter__step_cb step;
-
-	int count;  /* note, only some iterators set this, don't rely on it */
-	char itype;
-} HairEditIter;
-
-#define HAIREDIT_ITER_CB_DEF(name) \
-	struct HairEditIter__##name; \
-	void  hairedit_iter__##name##_begin(struct HairEditIter__##name *iter); \
-	void *hairedit_iter__##name##_step(struct HairEditIter__##name *iter)
-
-HAIREDIT_ITER_CB_DEF(elem_of_mesh);
-HAIREDIT_ITER_CB_DEF(vert_of_curve);
-
-#undef HAIREDIT_ITER_CB_DEF
-
-/* inline here optimizes out the switch statement when called with
- * constant values (which is very common), nicer for loop-in-loop situations */
-
-/**
- * \brief Iterator Step
- *
- * Calls an iterators step function to return the next element.
- */
-BLI_INLINE void *HairEdit_iter_step(HairEditIter *iter)
-{
-	return iter->step(iter);
-}
-
-/**
- * \brief Iterator Init
- *
- * Takes a hair iterator structure and fills
- * it with the appropriate function pointers based
- * upon its type.
- */
-BLI_INLINE bool HairEdit_iter_init(HairEditIter *iter, HairEditData *hed

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list