Commit: be3392e0f902a32e1077179743f23716f4dc19b0
Author: Mai Lavelle
Date:   Thu Apr 12 03:32:36 2018 -0400
Branches: blender2.8
https://developer.blender.org/rBbe3392e0f902a32e1077179743f23716f4dc19b0

Make particle edit mode work again

This is just to have hair rendering and editing mostly working as in
master. A better fix is probably needed, there seems to be some
missing depsgraph relations for particle edit settings, and particle
edit code doesn't rebuild caches after applying edits. But at least
you can see and interact with hair now until those things can be
sorted out.

===================================================================

M       source/blender/blenkernel/CMakeLists.txt
M       source/blender/blenkernel/intern/particle.c
M       source/blender/blenkernel/intern/particle_system.c

===================================================================

diff --git a/source/blender/blenkernel/CMakeLists.txt 
b/source/blender/blenkernel/CMakeLists.txt
index e8fd71c2b2d..27c1eeb3d77 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -31,6 +31,7 @@ set(INC
        ../blentranslation
        ../depsgraph
        ../draw
+       ../editors/include
        ../gpu
        ../ikplugin
        ../imbuf
diff --git a/source/blender/blenkernel/intern/particle.c 
b/source/blender/blenkernel/intern/particle.c
index cbc3b17a5c2..e1e24a24245 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -2618,7 +2618,7 @@ void psys_cache_edit_paths(Depsgraph *depsgraph, Scene 
*scene, Object *ob, PTCac
 
        if (!cache || edit->totpoint != edit->totcached) {
                /* clear out old and create new empty path cache */
-               psys_free_path_cache(edit->psys, edit);
+               psys_free_path_cache(NULL, edit);
                cache = edit->pathcache = 
psys_alloc_path_cache_buffers(&edit->pathcachebufs, totpart, segments + 1);
 
                /* set flag for update (child particles check this too) */
diff --git a/source/blender/blenkernel/intern/particle_system.c 
b/source/blender/blenkernel/intern/particle_system.c
index b9361f3499b..edc3f2e42fd 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -96,6 +96,8 @@
 
 #include "RE_shader_ext.h"
 
+#include "ED_particle.h"
+
 /* fluid sim particle import */
 #ifdef WITH_MOD_FLUID
 #include "DNA_object_fluidsim_types.h"
@@ -2906,9 +2908,7 @@ static void psys_update_path_cache(ParticleSimulationData 
*sim, float cfra, cons
 {
        ParticleSystem *psys = sim->psys;
        ParticleSettings *part = psys->part;
-#if 0
        ParticleEditSettings *pset = &sim->scene->toolsettings->particle;
-#endif
        int distr=0, alloc=0, skip=0;
 
        if ((psys->part->childtype && psys->totchild != 
psys_get_tot_child(sim->scene, psys, use_render_params)) || 
psys->recalc&PSYS_RECALC_RESET)
@@ -2944,14 +2944,14 @@ static void 
psys_update_path_cache(ParticleSimulationData *sim, float cfra, cons
                else if (psys->pointcache->flag & PTCACHE_BAKING)
                        skip = 1; /* no need to cache paths while baking 
dynamics */
 
-#if 0 /* TODO(mai): something is very wrong with these conditionals, they dont 
make sense and the cache isnt updating */
                else if (psys_in_edit_mode(sim->depsgraph, psys)) {
                        if ((pset->flag & PE_DRAW_PART)==0)
                                skip = 1;
+#if 0 /* TODO(mai): something is very wrong with these conditionals, they dont 
make sense and the cache isnt updating */
                        else if (part->childtype==0 && (psys->flag & 
PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED)==0)
                                skip = 1; /* in edit mode paths are needed for 
child particles and dynamic hair */
-               }
 #endif
+               }
        }
 
 
@@ -4384,6 +4384,22 @@ void particle_system_update(struct Depsgraph *depsgraph, 
Scene *scene, Object *o
        /* save matrix for duplicators, at rendertime the actual dupliobject's 
matrix is used so don't update! */
        invert_m4_m4(psys->imat, ob->obmat);
 
+       if (ob->mode & OB_MODE_PARTICLE_EDIT && ob == 
OBACT(DEG_get_evaluated_view_layer(depsgraph))) {
+               PTCacheEdit *edit = PE_create_current(depsgraph, scene, ob);
+
+               if (edit && edit->psys == psys) {
+                       if (edit->psys && edit->psys->flag & PSYS_HAIR_UPDATED) 
{
+                               PE_update_object(depsgraph, scene, ob, 0);
+                       }
+
+                       /* create path and child path cache if it doesn't exist 
already */
+                       if (edit->pathcache == NULL) {
+                               psys_cache_edit_paths(depsgraph, scene, ob, 
edit, DEG_get_ctime(depsgraph), DEG_get_mode(depsgraph) == DAG_EVAL_RENDER);
+
+                       }
+               }
+       }
+
        BKE_particle_batch_cache_dirty(psys, BKE_PARTICLE_BATCH_DIRTY_ALL);
 }

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to