Particle edit: Make check to work within copy-on-write concept

Not fully optimal, we can probably store pointer to original psys
similar to ID's orig_id.
This commit is contained in:
Sergey Sharybin
2018-05-15 12:34:18 +02:00
parent e5560e8d56
commit fe01430f74

View File

@@ -291,14 +291,31 @@ void psys_enable_all(Object *ob)
bool psys_in_edit_mode(Depsgraph *depsgraph, ParticleSystem *psys)
{
ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
const ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
if (view_layer->basact == NULL) {
/* TODO(sergey): Needs double-check with multi-object edit. */
return false;
}
const bool use_render_params = (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
return (view_layer->basact &&
(view_layer->basact->object->mode & OB_MODE_PARTICLE_EDIT) &&
psys == psys_get_current((view_layer->basact)->object) &&
(psys->edit || psys->pointcache->edit) &&
!use_render_params);
const Object *object = view_layer->basact->object;
if (object->mode != OB_MODE_PARTICLE_EDIT) {
return false;
}
/* TODO(sergey): Find a faster way to switch to an original psys. */
/*const*/ Object *object_orig = DEG_get_original_object(view_layer->basact->object);
ParticleSystem *psys_orig = object_orig->particlesystem.first;
while (psys_orig != NULL) {
if (STREQ(psys_orig->name, psys->name)) {
break;
}
psys = psys->next;
psys_orig = psys_orig->next;
}
if (psys_orig != psys_get_current(object_orig)) {
return false;
}
return (psys_orig->edit || psys->pointcache->edit) &&
(use_render_params == false);
}
bool psys_check_enabled(Object *ob, ParticleSystem *psys, const bool use_render_params)