Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / physics / particle_edit.c
index 288c216..c705434 100644 (file)
@@ -189,7 +189,7 @@ static float pe_brush_size_get(const Scene *UNUSED(scene), ParticleBrushData *br
        // here we can enable unified brush size, needs more work...
        // UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
        // float size = (ups->flag & UNIFIED_PAINT_SIZE) ? ups->size : brush->size;
-       
+
        return brush->size * U.pixelsize;
 }
 
@@ -353,7 +353,7 @@ static int pe_x_mirror(Object *ob)
 {
        if (ob->type == OB_MESH)
                return (((Mesh *)ob->data)->editflag & ME_EDIT_MIRROR_X);
-       
+
        return 0;
 }
 
@@ -361,7 +361,7 @@ static int pe_x_mirror(Object *ob)
 
 typedef struct PEData {
        ViewContext vc;
-       
+
        const bContext *context;
        Scene *scene;
        ViewLayer *view_layer;
@@ -429,13 +429,13 @@ static void PE_set_view3d_data(bContext *C, PEData *data)
 static bool PE_create_shape_tree(PEData *data, Object *shapeob)
 {
        Mesh *mesh = BKE_object_get_evaluated_mesh(data->depsgraph, shapeob);
-       
+
        memset(&data->shape_bvh, 0, sizeof(data->shape_bvh));
-       
+
        if (!mesh) {
                return false;
        }
-       
+
        return (BKE_bvhtree_from_mesh_get(&data->shape_bvh, mesh, BVHTREE_FROM_LOOPTRI, 4) != NULL);
 }
 
@@ -506,7 +506,7 @@ static bool key_inside_circle(PEData *data, float rad, const float co[3], float
 
                return 1;
        }
-       
+
        return 0;
 }
 
@@ -545,7 +545,7 @@ static bool point_is_selected(PTCacheEditPoint *point)
        LOOP_SELECTED_KEYS {
                return 1;
        }
-       
+
        return 0;
 }
 
@@ -796,7 +796,7 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys)
        /* lookup particles and set in mirror cache */
        if (!edit->mirror_cache)
                edit->mirror_cache= MEM_callocN(sizeof(int)*totpart, "PE mirror cache");
-       
+
        LOOP_PARTICLES {
                key = pa->hair;
                psys_mat_hair_to_orco(ob, psmd->mesh_final, psys->part->from, pa, mat);
@@ -841,7 +841,7 @@ static void PE_mirror_particle(Object *ob, Mesh *mesh, ParticleSystem *psys, Par
        if (!mpa) {
                if (!edit->mirror_cache)
                        PE_update_mirror_cache(ob, psys);
-               
+
                if (!edit->mirror_cache)
                        return; /* something went wrong! */
 
@@ -967,7 +967,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit)
 
        LOOP_EDITED_POINTS {
                psys_mat_hair_to_object(ob, psmd->mesh_final, psys->part->from, psys->particles + p, hairmat);
-       
+
                LOOP_KEYS {
                        mul_m4_v3(hairmat, key->co);
                }
@@ -979,7 +979,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit)
                        }
                        else {
                                index= BLI_kdtree_find_nearest(edit->emitter_field, key->co, NULL);
-                               
+
                                vec=edit->emitter_cosnos +index*6;
                                nor=vec+3;
 
@@ -1004,7 +1004,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit)
                                        dist_1st*=1.3333f;
                        }
                }
-               
+
                invert_m4_m4(hairimat, hairmat);
 
                LOOP_KEYS {
@@ -1015,7 +1015,7 @@ static void pe_deflect_emitter(Scene *scene, Object *ob, PTCacheEdit *edit)
 /* force set distances between neighboring keys */
 static void PE_apply_lengths(Scene *scene, PTCacheEdit *edit)
 {
-       
+
        ParticleEditSettings *pset=PE_settings(scene);
        POINT_P; KEY_K;
        float dv1[3];
@@ -1156,7 +1156,7 @@ void recalc_emitter_field(Depsgraph *depsgraph, Object *ob, ParticleSystem *psys
                        mvert = &mesh->mvert[mface->v4];
                        add_v3_v3v3(vec, vec, mvert->co);
                        VECADD(nor, nor, mvert->no);
-                       
+
                        mul_v3_fl(vec, 0.25);
                }
                else
@@ -1181,7 +1181,7 @@ static void PE_update_selection(Depsgraph *depsgraph, Scene *scene, Object *ob,
                LOOP_POINTS
                        point->flag |= PEP_EDIT_RECALC;
 
-       /* flush edit key flag to hair key flag to preserve selection 
+       /* flush edit key flag to hair key flag to preserve selection
         * on save */
        if (edit->psys) LOOP_POINTS {
                hkey = edit->psys->particles[p].hair;
@@ -1276,7 +1276,7 @@ static void update_velocities(PTCacheEdit *edit)
                        }
                        else {
                                dfra = *(key+1)->time - *(key-1)->time;
-                               
+
                                if (dfra <= 0.0f)
                                        continue;
 
@@ -1464,7 +1464,7 @@ void PARTICLE_OT_select_all(wmOperatorType *ot)
        ot->name = "(De)select All";
        ot->idname = "PARTICLE_OT_select_all";
        ot->description = "(De)select all particles' keys";
-       
+
        /* api callbacks */
        ot->exec = pe_select_all_exec;
        ot->poll = PE_poll;
@@ -1524,7 +1524,7 @@ static void select_root(PEData *data, int point_index)
 
        if (point->flag & PEP_HIDE)
                return;
-       
+
        if (data->select_action != SEL_TOGGLE)
                select_action_apply(point, key, data->select_action);
        else if (key->flag & PEK_SELECT)
@@ -1562,7 +1562,7 @@ void PARTICLE_OT_select_roots(wmOperatorType *ot)
        ot->name = "Select Roots";
        ot->idname = "PARTICLE_OT_select_roots";
        ot->description = "Select roots of all visible particles";
-       
+
        /* api callbacks */
        ot->exec = select_roots_exec;
        ot->poll = PE_poll;
@@ -1586,10 +1586,10 @@ static void select_tip(PEData *data, int point_index)
        }
 
        key = &point->keys[point->totkey - 1];
-       
+
        if (point->flag & PEP_HIDE)
                return;
-       
+
        if (data->select_action != SEL_TOGGLE)
                select_action_apply(point, key, data->select_action);
        else if (key->flag & PEK_SELECT)
@@ -1761,7 +1761,7 @@ void PARTICLE_OT_select_linked(wmOperatorType *ot)
        ot->name = "Select Linked";
        ot->idname = "PARTICLE_OT_select_linked";
        ot->description = "Select nearest particle from mouse pointer";
-       
+
        /* api callbacks */
        ot->exec = select_linked_exec;
        ot->invoke = select_linked_invoke;
@@ -1969,7 +1969,7 @@ void PARTICLE_OT_hide(wmOperatorType *ot)
        ot->name = "Hide Selected";
        ot->idname = "PARTICLE_OT_hide";
        ot->description = "Hide selected particles";
-       
+
        /* api callbacks */
        ot->exec = hide_exec;
        ot->poll = PE_poll;
@@ -2015,7 +2015,7 @@ void PARTICLE_OT_reveal(wmOperatorType *ot)
        ot->name = "Reveal";
        ot->idname = "PARTICLE_OT_reveal";
        ot->description = "Show hidden particles";
-       
+
        /* api callbacks */
        ot->exec = reveal_exec;
        ot->poll = PE_poll;
@@ -2077,7 +2077,7 @@ void PARTICLE_OT_select_less(wmOperatorType *ot)
        ot->name = "Select Less";
        ot->idname = "PARTICLE_OT_select_less";
        ot->description = "Deselect boundary selected keys of each particle";
-       
+
        /* api callbacks */
        ot->exec = select_less_exec;
        ot->poll = PE_poll;
@@ -2139,7 +2139,7 @@ void PARTICLE_OT_select_more(wmOperatorType *ot)
        ot->name = "Select More";
        ot->idname = "PARTICLE_OT_select_more";
        ot->description = "Select keys linked to boundary selected keys of each particle";
-       
+
        /* api callbacks */
        ot->exec = select_more_exec;
        ot->poll = PE_poll;
@@ -2200,7 +2200,7 @@ static void rekey_particle(PEData *data, int pa_index)
        if (point->keys)
                MEM_freeN(point->keys);
        ekey= point->keys= MEM_callocN(pa->totkey * sizeof(PTCacheEditKey), "Hair re-key edit keys");
-               
+
        for (k=0, key=pa->hair; k<pa->totkey; k++, key++, ekey++) {
                ekey->co= key->co;
                ekey->time= &key->time;
@@ -2223,7 +2223,7 @@ static int rekey_exec(bContext *C, wmOperator *op)
        data.totrekey= RNA_int_get(op->ptr, "keys_number");
 
        foreach_selected_point(&data, rekey_particle);
-       
+
        recalc_lengths(data.edit);
        PE_update_object(data.depsgraph, data.scene, data.ob, 1);
        WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, data.ob);
@@ -2237,7 +2237,7 @@ void PARTICLE_OT_rekey(wmOperatorType *ot)
        ot->name = "Rekey";
        ot->idname = "PARTICLE_OT_rekey";
        ot->description = "Change the number of keys of selected particles (root and tip keys included)";
-       
+
        /* api callbacks */
        ot->exec = rekey_exec;
        ot->invoke = WM_operator_props_popup;
@@ -2275,7 +2275,7 @@ static void rekey_particle_to_time(const bContext *C, Scene *scene, Object *ob,
        pa->flag |= PARS_REKEY;
 
        key= new_keys= MEM_dupallocN(pa->hair);
-       
+
        /* interpolate new keys from old ones (roots stay the same) */
        for (k=1, key++; k < pa->totkey; k++, key++) {
                state.time= path_time * (float)k / (float)(pa->totkey-1);
@@ -2434,7 +2434,7 @@ static void remove_tagged_keys(Object *ob, ParticleSystem *psys)
                                        nhkey->editflag = hkey->editflag;
                                        nhkey->time= hkey->time;
                                        nhkey->weight= hkey->weight;
-                                       
+
                                        nkey->co= nhkey->co;
                                        nkey->time= &nhkey->time;
                                        /* these can be copied from old edit keys */
@@ -2453,7 +2453,7 @@ static void remove_tagged_keys(Object *ob, ParticleSystem *psys)
 
                        if (point->keys)
                                MEM_freeN(point->keys);
-                       
+
                        pa->hair= new_hkeys;
                        point->keys= new_keys;
 
@@ -2499,7 +2499,7 @@ static void subdivide_particle(PEData *data, int pa_index)
 
        nkey= new_keys= MEM_callocN((pa->totkey+totnewkey)*(sizeof(HairKey)), "Hair subdivide keys");
        nekey= new_ekeys= MEM_callocN((pa->totkey+totnewkey)*(sizeof(PTCacheEditKey)), "Hair subdivide edit keys");
-       
+
        key = pa->hair;
        endtime= key[pa->totkey-1].time;
 
@@ -2556,7 +2556,7 @@ static int subdivide_exec(bContext *C, wmOperator *UNUSED(op))
 
        PE_set_data(C, &data);
        foreach_point(&data, subdivide_particle);
-       
+
        recalc_lengths(data.edit);
        PE_update_object(data.depsgraph, data.scene, data.ob, 1);
        WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, data.ob);
@@ -2570,7 +2570,7 @@ void PARTICLE_OT_subdivide(wmOperatorType *ot)
        ot->name = "Subdivide";
        ot->idname = "PARTICLE_OT_subdivide";
        ot->description = "Subdivide selected particles segments (adds keys)";
-       
+
        /* api callbacks */
        ot->exec = subdivide_exec;
        ot->poll = PE_hair_poll;
@@ -2605,7 +2605,7 @@ static int remove_doubles_exec(bContext *C, wmOperator *op)
                removed= 0;
 
                tree=BLI_kdtree_new(psys->totpart);
-                       
+
                /* insert particles into kd tree */
                LOOP_SELECTED_POINTS {
                        psys_mat_hair_to_object(ob, psmd->mesh_final, psys->part->from, psys->particles+p, mat);
@@ -2659,7 +2659,7 @@ void PARTICLE_OT_remove_doubles(wmOperatorType *ot)
        ot->name = "Remove Doubles";
        ot->idname = "PARTICLE_OT_remove_doubles";
        ot->description = "Remove selected particles close enough of others";
-       
+
        /* api callbacks */
        ot->exec = remove_doubles_exec;
        ot->poll = PE_hair_poll;
@@ -2820,7 +2820,7 @@ void PARTICLE_OT_delete(wmOperatorType *ot)
        ot->name = "Delete";
        ot->idname = "PARTICLE_OT_delete";
        ot->description = "Delete selected particles or keys";
-       
+
        /* api callbacks */
        ot->exec = delete_exec;
        ot->invoke = WM_menu_invoke;
@@ -2914,7 +2914,7 @@ static void PE_mirror_x(
                }
 
                edit->totpoint= psys->totpart= newtotpart;
-                       
+
                /* create new elements */
                newpa= psys->particles + totpart;
                newpoint= edit->points + totpart;
@@ -2989,7 +2989,7 @@ static int mirror_exec(bContext *C, wmOperator *UNUSED(op))
        Scene *scene= CTX_data_scene(C);
        Object *ob= CTX_data_active_object(C);
        PTCacheEdit *edit= PE_get_current(scene, ob);
-       
+
        PE_mirror_x(scene, ob, 0);
 
        update_world_cos(CTX_data_depsgraph(C), ob, edit);
@@ -3005,7 +3005,7 @@ void PARTICLE_OT_mirror(wmOperatorType *ot)
        ot->name = "Mirror";
        ot->idname = "PARTICLE_OT_mirror";
        ot->description = "Duplicate and mirror the selected particles along the local X axis";
-       
+
        /* api callbacks */
        ot->exec = mirror_exec;
        ot->poll = PE_hair_poll;
@@ -3064,7 +3064,7 @@ static void brush_cut(PEData *data, int pa_index)
 
        o0= (float)data->mval[0];
        o1= (float)data->mval[1];
-       
+
        xo0= x0 - o0;
        xo1= x1 - o1;
 
@@ -3094,7 +3094,7 @@ static void brush_cut(PEData *data, int pa_index)
                        dv= v0*v0 + v1*v1;
 
                        d= (v0*xo1 - v1*xo0);
-                       
+
                        d= dv * rad2 - d*d;
 
                        if (d > 0.0f) {
@@ -3327,7 +3327,7 @@ static void BKE_brush_weight_get(PEData *data, float UNUSED(mat[4][4]), float UN
 }
 
 static void brush_smooth_get(PEData *data, float mat[4][4], float UNUSED(imat[4][4]), int UNUSED(point_index), int key_index, PTCacheEditKey *key)
-{      
+{
        if (key_index) {
                float dvec[3];
 
@@ -3341,7 +3341,7 @@ static void brush_smooth_get(PEData *data, float mat[4][4], float UNUSED(imat[4]
 static void brush_smooth_do(PEData *data, float UNUSED(mat[4][4]), float imat[4][4], int point_index, int key_index, PTCacheEditKey *key)
 {
        float vec[3], dvec[3];
-       
+
        if (key_index) {
                copy_v3_v3(vec, data->vec);
                mul_mat3_m4_v3(imat, vec);
@@ -3350,7 +3350,7 @@ static void brush_smooth_do(PEData *data, float UNUSED(mat[4][4]), float imat[4]
 
                sub_v3_v3v3(dvec, vec, dvec);
                mul_v3_fl(dvec, data->smoothfac);
-               
+
                add_v3_v3(key->co, dvec);
        }
 
@@ -3388,7 +3388,7 @@ static int particle_intersect_mesh(const bContext *C, Scene *scene, Object *ob,
        int i, totface, intersect=0;
        float cur_d, cur_uv[2], v1[3], v2[3], v3[3], v4[3], min[3], max[3], p_min[3], p_max[3];
        float cur_ipoint[3];
-       
+
        if (mesh == NULL) {
                psys_disable_all(ob);
 
@@ -3408,7 +3408,7 @@ static int particle_intersect_mesh(const bContext *C, Scene *scene, Object *ob,
 
        /* BMESH_ONLY, deform dm may not have tessface */
        BKE_mesh_tessface_ensure(mesh);
-       
+
 
        if (pa_minmax==0) {
                INIT_MINMAX(p_min, p_max);
@@ -3580,7 +3580,7 @@ static int brush_add(const bContext *C, PEData *data, short number)
                mul_m4_v3(imat, co1);
                mul_m4_v3(imat, co2);
                min_d=2.0;
-               
+
                /* warning, returns the derived mesh face */
                if (particle_intersect_mesh(C, scene, ob, mesh, 0, co1, co2, &min_d, &add_pars[n].num_dmcache, add_pars[n].fuv, 0, 0, 0, 0)) {
                        if (psys->part->use_modifier_stack && !psmd->mesh_final->runtime.deformed_only) {
@@ -3631,7 +3631,7 @@ static int brush_add(const bContext *C, PEData *data, short number)
                /* create tree for interpolation */
                if (pset->flag & PE_INTERPOLATE_ADDED && psys->totpart) {
                        tree=BLI_kdtree_new(psys->totpart);
-                       
+
                        for (i=0, pa=psys->particles; i<totpart; i++, pa++) {
                                psys_particle_on_dm(psmd->mesh_final, psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, cur_co, 0, 0, 0, 0);
                                BLI_kdtree_insert(tree, i, cur_co);
@@ -3659,14 +3659,14 @@ static int brush_add(const bContext *C, PEData *data, short number)
                                if (!(psys->flag & PSYS_GLOBAL_HAIR))
                                        key->flag |= PEK_USE_WCO;
                        }
-                       
+
                        pa->size= 1.0f;
                        initialize_particle(&sim, pa);
                        reset_particle(&sim, pa, 0.0, 1.0);
                        point->flag |= PEP_EDIT_RECALC;
                        if (pe_x_mirror(ob))
                                point->flag |= PEP_TAG; /* signal for duplicate */
-                       
+
                        framestep= pa->lifetime/(float)(pset->totaddkey-1);
 
                        if (tree) {
@@ -3681,7 +3681,7 @@ static int brush_add(const bContext *C, PEData *data, short number)
                                maxw = BLI_kdtree_find_nearest_n(tree, co1, ptn, 3);
 
                                maxd= ptn[maxw-1].dist;
-                               
+
                                for (w=0; w<maxw; w++) {
                                        weight[w] = (float)pow(2.0, (double)(-6.0f * ptn[w].dist / maxd));
                                        totw += weight[w];
@@ -3708,10 +3708,10 @@ static int brush_add(const bContext *C, PEData *data, short number)
                                        key3[0].time= thkey->time/ 100.0f;
                                        psys_get_particle_on_path(&sim, ptn[0].index, key3, 0);
                                        mul_v3_fl(key3[0].co, weight[0]);
-                                       
+
                                        /* TODO: interpolating the weight would be nicer */
                                        thkey->weight= (ppa->hair+MIN2(k, ppa->totkey-1))->weight;
-                                       
+
                                        if (maxw>1) {
                                                key3[1].time= key3[0].time;
                                                psys_get_particle_on_path(&sim, ptn[1].index, &key3[1], 0);
@@ -3755,7 +3755,7 @@ static int brush_add(const bContext *C, PEData *data, short number)
        MEM_freeN(add_pars);
 
        BLI_rng_free(rng);
-       
+
        return n;
 }
 
@@ -3785,7 +3785,7 @@ static int brush_edit_init(bContext *C, wmOperator *op)
        ARegion *ar= CTX_wm_region(C);
        BrushEdit *bedit;
        float min[3], max[3];
-       
+
        if (pset->brushtype < 0)
                return 0;
 
@@ -3916,7 +3916,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr)
                                case PE_BRUSH_LENGTH:
                                {
                                        data.mval= mval;
-                               
+
                                        data.rad= pe_brush_size_get(scene, brush);
                                        data.growfac= brush->strength / 50.0f;
 
@@ -4080,7 +4080,7 @@ static int brush_edit_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 {
        if (!brush_edit_init(C, op))
                return OPERATOR_CANCELLED;
-       
+
        brush_edit_apply_event(C, op, event);
 
        WM_event_add_modal_handler(C, op);
@@ -4115,7 +4115,7 @@ void PARTICLE_OT_brush_edit(wmOperatorType *ot)
        ot->name = "Brush Edit";
        ot->idname = "PARTICLE_OT_brush_edit";
        ot->description = "Apply a stroke of brush to the particles";
-       
+
        /* api callbacks */
        ot->exec = brush_edit_exec;
        ot->invoke = brush_edit_invoke;
@@ -4139,12 +4139,12 @@ static int shape_cut_poll(bContext *C)
        if (PE_hair_poll(C)) {
                Scene *scene = CTX_data_scene(C);
                ParticleEditSettings *pset = PE_settings(scene);
-               
+
                if (pset->shape_object && (pset->shape_object->type == OB_MESH)) {
                        return true;
                }
        }
-       
+
        return false;
 }
 
@@ -4156,9 +4156,9 @@ typedef struct PointInsideBVH {
 static void point_inside_bvh_cb(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
 {
        PointInsideBVH *data = userdata;
-       
+
        data->bvhdata.raycast_callback(&data->bvhdata, index, ray, hit);
-       
+
        if (hit->index != -1)
                ++data->num_hits;
 }
@@ -4169,14 +4169,14 @@ static bool shape_cut_test_point(PEData *data, ParticleCacheKey *key)
        BVHTreeFromMesh *shape_bvh = &data->shape_bvh;
        const float dir[3] = {1.0f, 0.0f, 0.0f};
        PointInsideBVH userdata;
-       
+
        userdata.bvhdata = data->shape_bvh;
        userdata.num_hits = 0;
-       
+
        BLI_bvhtree_ray_cast_all(
                shape_bvh->tree, key->co, dir, 0.0f, BVH_RAYCAST_DIST_MAX,
                point_inside_bvh_cb, &userdata);
-       
+
        /* for any point inside a watertight mesh the number of hits is uneven */
        return (userdata.num_hits % 2) == 1;
 }
@@ -4187,17 +4187,17 @@ static void shape_cut(PEData *data, int pa_index)
        Object *ob = data->ob;
        ParticleEditSettings *pset = PE_settings(data->scene);
        ParticleCacheKey *key;
-       
+
        bool cut;
        float cut_time = 1.0;
        int k, totkeys = 1 << pset->draw_step;
-       
+
        /* don't cut hidden */
        if (edit->points[pa_index].flag & PEP_HIDE)
                return;
-       
+
        cut = false;
-       
+
        /* check if root is inside the cut shape */
        key = edit->pathcache[pa_index];
        if (!shape_cut_test_point(data, key)) {
@@ -4209,10 +4209,10 @@ static void shape_cut(PEData *data, int pa_index)
                        BVHTreeRayHit hit;
                        float dir[3];
                        float len;
-                       
+
                        sub_v3_v3v3(dir, (key+1)->co, key->co);
                        len = normalize_v3(dir);
-                       
+
                        memset(&hit, 0, sizeof(hit));
                        hit.index = -1;
                        hit.dist = len;
@@ -4248,32 +4248,32 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
        Object *shapeob = pset->shape_object;
        int selected = count_selected_keys(scene, edit);
        int lock_root = pset->flag & PE_LOCK_FIRST;
-       
+
        if (!PE_start_edit(edit))
                return OPERATOR_CANCELLED;
-       
+
        /* disable locking temporatily for disconnected hair */
        if (edit->psys && edit->psys->flag & PSYS_GLOBAL_HAIR)
                pset->flag &= ~PE_LOCK_FIRST;
-       
+
        if (edit->psys && edit->pathcache) {
                PEData data;
                int removed;
-               
+
                PE_set_data(C, &data);
                if (!PE_create_shape_tree(&data, shapeob)) {
                        /* shapeob may not have faces... */
                        return OPERATOR_CANCELLED;
                }
-               
+
                if (selected)
                        foreach_selected_point(&data, shape_cut);
                else
                        foreach_point(&data, shape_cut);
-               
+
                removed = remove_tagged_particles(ob, edit->psys, pe_x_mirror(ob));
                recalc_lengths(edit);
-               
+
                if (removed) {
                        update_world_cos(depsgraph, ob, edit);
                        psys_free_path_cache(NULL, edit);
@@ -4282,7 +4282,7 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
                else {
                        PE_update_object(data.depsgraph, scene, ob, 1);
                }
-               
+
                if (edit->psys) {
                        WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob);
                        BKE_particle_batch_cache_dirty(edit->psys, BKE_PARTICLE_BATCH_DIRTY_ALL);
@@ -4292,12 +4292,12 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op))
                        DEG_id_tag_update(&ob->id, OB_RECALC_DATA);
                        WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob);
                }
-               
+
                PE_free_shape_tree(&data);
        }
-       
+
        pset->flag |= lock_root;
-       
+
        return OPERATOR_FINISHED;
 }
 
@@ -4307,7 +4307,7 @@ void PARTICLE_OT_shape_cut(wmOperatorType *ot)
        ot->name = "Shape Cut";
        ot->idname = "PARTICLE_OT_shape_cut";
        ot->description = "Cut hair to conform to the set shape object";
-       
+
        /* api callbacks */
        ot->exec = shape_cut_exec;
        ot->poll = shape_cut_poll;
@@ -4507,12 +4507,12 @@ static int particle_edit_toggle_exec(bContext *C, wmOperator *op)
 
                ob->mode |= mode_flag;
                edit= PE_create_current(depsgraph, scene, ob);
-       
+
                /* mesh may have changed since last entering editmode.
                 * note, this may have run before if the edit data was just created, so could avoid this and speed up a little */
                if (edit && edit->psys)
                        recalc_emitter_field(depsgraph, ob, edit->psys);
-               
+
                toggle_particle_cursor(C, 1);
                WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_PARTICLE, NULL);
        }
@@ -4539,7 +4539,7 @@ void PARTICLE_OT_particle_edit_toggle(wmOperatorType *ot)
        ot->name = "Particle Edit Toggle";
        ot->idname = "PARTICLE_OT_particle_edit_toggle";
        ot->description = "Toggle particle edit mode";
-       
+
        /* api callbacks */
        ot->exec = particle_edit_toggle_exec;
        ot->poll = particle_edit_toggle_poll;
@@ -4555,7 +4555,7 @@ static int clear_edited_exec(bContext *C, wmOperator *UNUSED(op))
 {
        Object *ob= CTX_data_active_object(C);
        ParticleSystem *psys = psys_get_current(ob);
-       
+
        if (psys->edit) {
                if (psys->edit->edited || 1) {
                        PE_free_ptcache_edit(psys->edit);
@@ -4594,7 +4594,7 @@ void PARTICLE_OT_edited_clear(wmOperatorType *ot)
        ot->name = "Clear Edited";
        ot->idname = "PARTICLE_OT_edited_clear";
        ot->description = "Undo all edition performed on the particle system";
-       
+
        /* api callbacks */
        ot->exec = clear_edited_exec;
        ot->poll = particle_edit_toggle_poll;