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:
-rw-r--r--source/blender/blenloader/intern/readfile.c2
-rw-r--r--source/blender/editors/include/ED_particle.h2
-rw-r--r--source/blender/editors/physics/particle_edit.c39
-rw-r--r--source/blender/makesrna/intern/rna_object.c13
4 files changed, 42 insertions, 14 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 9b4ed4d11a7..184b584d188 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3918,7 +3918,7 @@ static void direct_link_object(FileData *fd, Object *ob)
ob->flag &= ~OB_FROMGROUP;
/* editmode doesn't get saved in files, so should get cleared when reloading... */
- ob->mode &= ~OB_MODE_EDIT;
+ ob->mode &= ~(OB_MODE_EDIT|OB_MODE_PARTICLE_EDIT);
ob->disp.first=ob->disp.last= NULL;
diff --git a/source/blender/editors/include/ED_particle.h b/source/blender/editors/include/ED_particle.h
index 3d7fc5ea15b..fcdaf8cb59d 100644
--- a/source/blender/editors/include/ED_particle.h
+++ b/source/blender/editors/include/ED_particle.h
@@ -46,6 +46,8 @@ int PE_start_edit(struct PTCacheEdit *edit);
/* access */
struct PTCacheEdit *PE_get_current(struct Scene *scene, struct Object *ob);
+struct PTCacheEdit *PE_create_current(struct Scene *scene, struct Object *ob);
+void PE_current_changed(struct Scene *scene, struct Object *ob);
int PE_minmax(struct Scene *scene, float *min, float *max);
struct ParticleEditSettings *PE_settings(struct Scene *scene);
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index ac47ddebc1f..e3f54158fbb 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -194,7 +194,7 @@ ParticleEditSettings *PE_settings(Scene *scene)
}
/* always gets atleast the first particlesystem even if PSYS_CURRENT flag is not set */
-PTCacheEdit *PE_get_current(Scene *scene, Object *ob)
+static PTCacheEdit *pe_get_current(Scene *scene, Object *ob, int create)
{
ParticleEditSettings *pset= PE_settings(scene);
PTCacheEdit *edit = NULL;
@@ -232,18 +232,18 @@ PTCacheEdit *PE_get_current(Scene *scene, Object *ob)
if(psys->flag & PSYS_CURRENT) {
if(psys->part && psys->part->type == PART_HAIR) {
if(psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED) {
- if(!psys->pointcache->edit)
+ if(create && !psys->pointcache->edit)
PE_create_particle_edit(scene, ob, pid->cache, NULL);
edit = pid->cache->edit;
}
else {
- if(!psys->edit && psys->flag & PSYS_HAIR_DONE)
+ if(create && !psys->edit && psys->flag & PSYS_HAIR_DONE)
PE_create_particle_edit(scene, ob, NULL, psys);
edit = psys->edit;
}
}
else {
- if(pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit)
+ if(create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit)
PE_create_particle_edit(scene, ob, pid->cache, psys);
edit = pid->cache->edit;
}
@@ -252,13 +252,13 @@ PTCacheEdit *PE_get_current(Scene *scene, Object *ob)
}
}
else if(pset->edittype == PE_TYPE_SOFTBODY && pid->type == PTCACHE_TYPE_SOFTBODY) {
- if(pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit)
+ if(create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit)
PE_create_particle_edit(scene, ob, pid->cache, NULL);
edit = pid->cache->edit;
break;
}
else if(pset->edittype == PE_TYPE_CLOTH && pid->type == PTCACHE_TYPE_CLOTH) {
- if(pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit)
+ if(create && pid->cache->flag & PTCACHE_BAKED && !pid->cache->edit)
PE_create_particle_edit(scene, ob, pid->cache, NULL);
edit = pid->cache->edit;
break;
@@ -273,6 +273,22 @@ PTCacheEdit *PE_get_current(Scene *scene, Object *ob)
return edit;
}
+PTCacheEdit *PE_get_current(Scene *scene, Object *ob)
+{
+ return pe_get_current(scene, ob, 0);
+}
+
+PTCacheEdit *PE_create_current(Scene *scene, Object *ob)
+{
+ return pe_get_current(scene, ob, 1);
+}
+
+void PE_current_changed(Scene *scene, Object *ob)
+{
+ if(ob->mode == OB_MODE_PARTICLE_EDIT)
+ PE_create_current(scene, ob);
+}
+
void PE_hide_keys_time(Scene *scene, PTCacheEdit *edit, float cfra)
{
ParticleEditSettings *pset=PE_settings(scene);
@@ -1195,8 +1211,6 @@ void PE_update_object(Scene *scene, Object *ob, int useflag)
if(edit->psys)
edit->psys->flag &= ~PSYS_HAIR_UPDATED;
-
- DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
}
/************************************************/
@@ -2409,7 +2423,6 @@ static int delete_exec(bContext *C, wmOperator *op)
}
PE_update_object(data.scene, data.ob, 0);
-
DAG_id_flush_update(&data.ob->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_DATA, data.ob);
@@ -3734,13 +3747,15 @@ int PE_minmax(Scene *scene, float *min, float *max)
/* initialize needed data for bake edit */
static void PE_create_particle_edit(Scene *scene, Object *ob, PointCache *cache, ParticleSystem *psys)
{
- PTCacheEdit *edit= psys ? psys->edit : cache->edit;
+ PTCacheEdit *edit= (psys)? psys->edit : cache->edit;
+ ParticleSystemModifierData *psmd= (psys)? psys_get_modifier(ob, psys): NULL;
POINT_P; KEY_K;
ParticleData *pa = NULL;
HairKey *hkey;
int totpoint;
- if(!psys && !cache)
+ /* no psmd->dm happens in case particle system modifier is not enabled */
+ if(!(psys && psmd && psmd->dm) && !cache)
return;
if(cache && cache->flag & PTCACHE_DISK_CACHE)
@@ -3850,10 +3865,12 @@ static int particle_edit_toggle_poll(bContext *C)
static int particle_edit_toggle_exec(bContext *C, wmOperator *op)
{
+ Scene *scene= CTX_data_scene(C);
Object *ob= CTX_data_active_object(C);
if(!(ob->mode & OB_MODE_PARTICLE_EDIT)) {
ob->mode |= OB_MODE_PARTICLE_EDIT;
+ PE_create_current(scene, ob);
toggle_particle_cursor(C, 1);
WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_PARTICLE, NULL);
}
diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c
index 694eb7e23e4..611585c8809 100644
--- a/source/blender/makesrna/intern/rna_object.c
+++ b/source/blender/makesrna/intern/rna_object.c
@@ -102,6 +102,7 @@ EnumPropertyItem object_type_items[] = {
#include "BLI_editVert.h" /* for EditMesh->mat_nr */
#include "ED_object.h"
+#include "ED_particle.h"
void rna_Object_update(bContext *C, PointerRNA *ptr)
{
@@ -460,12 +461,20 @@ static int rna_Object_active_particle_system_index_get(PointerRNA *ptr)
return psys_get_current_num(ob);
}
-static void rna_Object_active_particle_system_index_set(struct PointerRNA *ptr, int value)
+static void rna_Object_active_particle_system_index_set(PointerRNA *ptr, int value)
{
Object *ob= (Object*)ptr->id.data;
psys_set_current_num(ob, value);
}
+static void rna_Object_particle_update(bContext *C, PointerRNA *ptr)
+{
+ Scene *scene= CTX_data_scene(C);
+ Object *ob= (Object*)ptr->id.data;
+
+ PE_current_changed(scene, ob);
+}
+
/* rotation - axis-angle */
static void rna_Object_rotation_axis_angle_get(PointerRNA *ptr, float *value)
{
@@ -1418,7 +1427,7 @@ static void rna_def_object(BlenderRNA *brna)
prop= RNA_def_property(srna, "active_particle_system_index", PROP_INT, PROP_UNSIGNED);
RNA_def_property_int_funcs(prop, "rna_Object_active_particle_system_index_get", "rna_Object_active_particle_system_index_set", "rna_Object_active_particle_system_index_range");
RNA_def_property_ui_text(prop, "Active Particle System Index", "Index of active particle system slot.");
- RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
+ RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_particle_update");
/* restrict */
prop= RNA_def_property(srna, "restrict_view", PROP_BOOLEAN, PROP_NONE);