Particle Edit Mode:
* Fix crash trying to enter particle mode when the particle modifier is disabled in the stack. * Fix redraw being very slow due to the draw function causing the object to be recalculated on each redraw (through PE_draw_object). * Removed the system where PE_get_current would automatically create the particle edit, this would run from poll() functions, which gave all kinds of issues, now it only creates the data on enter/exit and switching active particle system.
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user