Depsgraph: Keep track of original particle system
Allows to have quicker lookup in particle edit mode.
This commit is contained in:
@@ -302,6 +302,7 @@ void psys_set_current_num(Object *ob, int index);
|
||||
|
||||
struct LatticeDeformData *psys_create_lattice_deform_data(struct ParticleSimulationData *sim);
|
||||
|
||||
struct ParticleSystem *psys_original_get(struct ParticleSystem *psys);
|
||||
bool psys_in_edit_mode(struct Depsgraph *depsgraph, struct ParticleSystem *psys);
|
||||
bool psys_check_enabled(struct Object *ob, struct ParticleSystem *psys, const bool use_render_params);
|
||||
bool psys_check_edited(struct ParticleSystem *psys);
|
||||
|
||||
@@ -289,6 +289,14 @@ void psys_enable_all(Object *ob)
|
||||
psys->flag &= ~PSYS_DISABLED;
|
||||
}
|
||||
|
||||
ParticleSystem *psys_original_get(ParticleSystem *psys)
|
||||
{
|
||||
if (psys->orig_psys == NULL) {
|
||||
return psys;
|
||||
}
|
||||
return psys->orig_psys;
|
||||
}
|
||||
|
||||
bool psys_in_edit_mode(Depsgraph *depsgraph, ParticleSystem *psys)
|
||||
{
|
||||
const ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
|
||||
@@ -301,19 +309,7 @@ bool psys_in_edit_mode(Depsgraph *depsgraph, ParticleSystem *psys)
|
||||
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;
|
||||
}
|
||||
ParticleSystem *psys_orig = psys_original_get(psys);
|
||||
return (psys_orig->edit || psys->pointcache->edit) &&
|
||||
(use_render_params == false);
|
||||
}
|
||||
|
||||
@@ -4476,6 +4476,7 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles)
|
||||
psys->tree = NULL;
|
||||
psys->bvhtree = NULL;
|
||||
|
||||
psys->orig_psys = NULL;
|
||||
psys->batch_cache = NULL;
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -67,6 +67,7 @@ extern "C" {
|
||||
#include "DNA_mesh_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_particle_types.h"
|
||||
|
||||
#ifdef NESTED_ID_NASTY_WORKAROUND
|
||||
# include "DNA_curve_types.h"
|
||||
@@ -443,11 +444,26 @@ void updata_edit_mode_pointers(const Depsgraph *depsgraph,
|
||||
break;
|
||||
case ID_ME:
|
||||
updata_mesh_edit_mode_pointers(depsgraph, id_orig, id_cow);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void update_particle_system_orig_pointers(const Object *object_orig,
|
||||
Object *object_cow)
|
||||
{
|
||||
ParticleSystem *psys_cow =
|
||||
(ParticleSystem *) object_cow->particlesystem.first;
|
||||
ParticleSystem *psys_orig =
|
||||
(ParticleSystem *) object_orig->particlesystem.first;
|
||||
while (psys_orig != NULL) {
|
||||
psys_cow->orig_psys = psys_orig;
|
||||
psys_cow = psys_cow->next;
|
||||
psys_orig = psys_orig->next;
|
||||
}
|
||||
}
|
||||
|
||||
/* Do some special treatment of data transfer from original ID to it's
|
||||
* CoW complementary part.
|
||||
*
|
||||
@@ -473,6 +489,7 @@ void update_special_pointers(const Depsgraph *depsgraph,
|
||||
BKE_pose_remap_bone_pointers((bArmature *)object_cow->data,
|
||||
object_cow->pose);
|
||||
}
|
||||
update_particle_system_orig_pointers(object_orig, object_cow);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -183,6 +183,9 @@ static void particle_cache_populate(void *vedata, Object *object)
|
||||
Object *object_orig = DEG_get_original_object(object);
|
||||
PTCacheEdit *edit = PE_create_current(
|
||||
draw_ctx->depsgraph, scene_orig, object_orig);
|
||||
/* NOTE: We need to pass evaluated particle system, which we need
|
||||
* to find first.
|
||||
*/
|
||||
ParticleSystem *psys = object->particlesystem.first;
|
||||
ParticleSystem *psys_orig = object_orig->particlesystem.first;
|
||||
while (psys_orig != NULL) {
|
||||
|
||||
@@ -326,6 +326,15 @@ typedef struct ParticleSystem {
|
||||
float lattice_strength; /* influence of the lattice modifier */
|
||||
|
||||
void *batch_cache;
|
||||
|
||||
/* Set by dependency graph's copy-on-write, allows to quickly go
|
||||
* from evaluated particle system to original one.
|
||||
*
|
||||
* Original system will have this set to NULL.
|
||||
*
|
||||
* Use psys_original_get() function to access,
|
||||
*/
|
||||
struct ParticleSystem *orig_psys;
|
||||
} ParticleSystem;
|
||||
|
||||
typedef enum eParticleDrawFlag {
|
||||
|
||||
Reference in New Issue
Block a user