[Bf-blender-cvs] [1c7053f] strand_editmode: Store hair edit data in particle systems and manage it in the operator for entering/exiting the edit mode.
Lukas Tönne
noreply at git.blender.org
Mon Apr 20 14:22:45 CEST 2015
Commit: 1c7053f7a0529d4087cd820139ccbb37bd0bf56a
Author: Lukas Tönne
Date: Tue Nov 25 09:30:59 2014 +0100
Branches: strand_editmode
https://developer.blender.org/rB1c7053f7a0529d4087cd820139ccbb37bd0bf56a
Store hair edit data in particle systems and manage it in the operator
for entering/exiting the edit mode.
Conflicts:
source/blender/blenkernel/intern/particle.c
===================================================================
M source/blender/blenkernel/intern/edithair_particles.c
M source/blender/blenkernel/intern/object.c
M source/blender/blenkernel/intern/particle.c
M source/blender/blenloader/intern/readfile.c
M source/blender/editors/hair/hair_edit.c
M source/blender/makesdna/DNA_particle_types.h
===================================================================
diff --git a/source/blender/blenkernel/intern/edithair_particles.c b/source/blender/blenkernel/intern/edithair_particles.c
index 215ba24..463af02 100644
--- a/source/blender/blenkernel/intern/edithair_particles.c
+++ b/source/blender/blenkernel/intern/edithair_particles.c
@@ -173,9 +173,6 @@ static void create_particle_data(ParticleSystem *psys, HairEditData *hedit)
void BKE_edithair_to_particles(HairEditData *hedit, Object *UNUSED(ob), ParticleSystem *psys)
{
- psys->flag |= PSYS_EDITED;
-
free_particle_data(psys);
-
create_particle_data(psys, hedit);
}
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index f14f726..304275d 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1321,6 +1321,7 @@ ParticleSystem *BKE_object_copy_particlesystem(ParticleSystem *psys)
psysn->pathcache = NULL;
psysn->childcache = NULL;
psysn->edit = NULL;
+ psysn->hairedit = NULL;
psysn->pdd = NULL;
psysn->effectors = NULL;
psysn->tree = NULL;
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index afcf5e1..1adfff3 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -65,6 +65,7 @@
#include "BKE_boids.h"
#include "BKE_cloth.h"
#include "BKE_colortools.h"
+#include "BKE_edithair.h"
#include "BKE_effect.h"
#include "BKE_global.h"
#include "BKE_group.h"
@@ -546,6 +547,8 @@ void psys_free(Object *ob, ParticleSystem *psys)
if (psys->edit && psys->free_edit)
psys->free_edit(psys->edit);
+ if (psys->hairedit)
+ BKE_edithair_free(psys->hairedit);
if (psys->child) {
MEM_freeN(psys->child);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 3687ccb..718e089 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3992,6 +3992,7 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles)
psys->edit = NULL;
psys->free_edit = NULL;
+ psys->hairedit = NULL;
psys->pathcache = NULL;
psys->childcache = NULL;
BLI_listbase_clear(&psys->pathcachebufs);
diff --git a/source/blender/editors/hair/hair_edit.c b/source/blender/editors/hair/hair_edit.c
index e92d647..70da2ac 100644
--- a/source/blender/editors/hair/hair_edit.c
+++ b/source/blender/editors/hair/hair_edit.c
@@ -40,6 +40,7 @@
#include "BKE_context.h"
#include "BKE_depsgraph.h"
#include "BKE_edithair.h"
+#include "BKE_particle.h"
#include "RNA_access.h"
@@ -53,25 +54,42 @@
static bool has_hair_data(Object *ob)
{
- ParticleSystem *psys;
+ ParticleSystem *psys = psys_get_current(ob);
+ if (psys->part->type == PART_HAIR)
+ return true;
- for (psys = ob->particlesystem.first; psys; psys = psys->next) {
- if (psys->part->type == PART_HAIR)
- return true;
+ return false;
+}
+
+static bool init_hair_edit(Object *ob)
+{
+ ParticleSystem *psys = psys_get_current(ob);
+ if (psys->part->type == PART_HAIR) {
+ HairEditData *hedit = psys->hairedit;
+ if (!hedit)
+ psys->hairedit = hedit = BKE_edithair_create();
+
+ BKE_edithair_from_particles(hedit, ob, psys);
+
+ return true;
}
return false;
}
-static bool init_hair_edit(Object *ob, HairEditData *hedit)
+static bool apply_hair_edit(Object *ob)
{
- ParticleSystem *psys;
-
- for (psys = ob->particlesystem.first; psys; psys = psys->next) {
- if (psys->part->type == PART_HAIR) {
- BKE_edithair_from_particles(hedit, ob, psys);
- return true;
+ ParticleSystem *psys = psys_get_current(ob);
+ if (psys->part->type == PART_HAIR) {
+ if (psys->hairedit) {
+ BKE_edithair_to_particles(psys->hairedit, ob, psys);
+ psys->flag |= PSYS_EDITED;
+
+ BKE_edithair_free(psys->hairedit);
+ psys->hairedit = NULL;
}
+
+ return true;
}
return false;
@@ -107,16 +125,14 @@ static int hair_edit_toggle_exec(bContext *C, wmOperator *op)
}
if (!is_mode_set) {
- HairEditData *hedit = BKE_edithair_create();
-
+ init_hair_edit(ob);
ob->mode |= mode_flag;
- init_hair_edit(ob, hedit);
// toggle_particle_cursor(C, 1);
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_HAIR, NULL);
}
else {
-// hair_edit_to_particles();
+ apply_hair_edit(ob);
ob->mode &= ~mode_flag;
// toggle_particle_cursor(C, 0);
diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h
index 95cb5c8..6178c0d 100644
--- a/source/blender/makesdna/DNA_particle_types.h
+++ b/source/blender/makesdna/DNA_particle_types.h
@@ -274,6 +274,7 @@ typedef struct ParticleSystem {
struct PTCacheEdit *edit; /* particle editmode (runtime) */
void (*free_edit)(struct PTCacheEdit *edit); /* free callback */
+ struct HairEditData *hairedit; /* hair edit data (runtime) */
struct ParticleCacheKey **pathcache; /* path cache (runtime) */
struct ParticleCacheKey **childcache; /* child cache (runtime) */
More information about the Bf-blender-cvs
mailing list