[Bf-blender-cvs] [d2219f8] gooseberry: After editing hair, apply the changes back to the active hair shape key.
Lukas Tönne
noreply at git.blender.org
Wed Jan 28 16:19:47 CET 2015
Commit: d2219f871c229f3afe907a5615999c40c91dd991
Author: Lukas Tönne
Date: Wed Jan 28 16:18:21 2015 +0100
Branches: gooseberry
https://developer.blender.org/rBd2219f871c229f3afe907a5615999c40c91dd991
After editing hair, apply the changes back to the active hair shape key.
This makes shape keys for hair actually usable by completing basic edit
mode integration.
===================================================================
M source/blender/editors/include/ED_particle.h
M source/blender/editors/physics/particle_edit.c
M source/blender/makesrna/intern/rna_particle.c
===================================================================
diff --git a/source/blender/editors/include/ED_particle.h b/source/blender/editors/include/ED_particle.h
index 54244d6..7c8a2b7 100644
--- a/source/blender/editors/include/ED_particle.h
+++ b/source/blender/editors/include/ED_particle.h
@@ -45,7 +45,8 @@ struct Scene;
/* particle edit mode */
void PE_free_ptcache_edit(struct PTCacheEdit *edit);
int PE_start_edit(struct PTCacheEdit *edit);
-bool PE_load(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys);
+bool PE_shapekey_load(struct Object *ob, struct ParticleSystem *psys);
+bool PE_shapekey_apply(struct Object *ob, struct ParticleSystem *psys);
/* access */
struct PTCacheEdit *PE_get_current(struct Scene *scene, struct Object *ob);
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 0d78f42..5bae6e5 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -1202,6 +1202,9 @@ void update_world_cos(Object *ob, PTCacheEdit *edit)
mul_m4_v3(hairmat, key->world_co);
}
}
+
+ /* apply hair changes to the active shape key */
+ PE_shapekey_apply(ob, psys);
}
static void update_velocities(PTCacheEdit *edit)
{
@@ -4555,7 +4558,7 @@ int PE_minmax(Scene *scene, float min[3], float max[3])
/************************ particle edit toggle operator ************************/
-bool PE_load(Scene *UNUSED(scene), Object *ob, ParticleSystem *psys)
+bool PE_shapekey_load(Object *ob, ParticleSystem *psys)
{
const int mode_flag = OB_MODE_PARTICLE_EDIT;
const bool is_mode_set = (ob->mode & mode_flag) != 0;
@@ -4574,6 +4577,25 @@ bool PE_load(Scene *UNUSED(scene), Object *ob, ParticleSystem *psys)
return true;
}
+bool PE_shapekey_apply(struct Object *ob, struct ParticleSystem *psys)
+{
+ const int mode_flag = OB_MODE_PARTICLE_EDIT;
+ const bool is_mode_set = (ob->mode & mode_flag) != 0;
+
+ if (!is_mode_set)
+ return false;
+
+ if (psys->edit) {
+ /* define the active shape key */
+ KeyBlock *actkb = BKE_keyblock_from_particles(psys);
+
+ if (actkb)
+ BKE_keyblock_convert_from_hair_keys(ob, psys, actkb);
+ }
+
+ return true;
+}
+
/* initialize needed data for bake edit */
void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache, ParticleSystem *psys)
{
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index e612820..f792d38 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -779,7 +779,7 @@ static void rna_Particle_active_shape_update(Main *bmain, Scene *scene, PointerR
Object *ob = ptr->id.data;
ParticleSystem *psys = ptr->data;
- if (PE_load(scene, ob, psys)) {
+ if (PE_shapekey_load(ob, psys)) {
WM_main_add_notifier(NC_SCENE | ND_PARTICLE | NS_MODE_PARTICLE, ptr->id.data);
}
More information about the Bf-blender-cvs
mailing list