From aa4a3ef940be5b1dcc11cc828bbae93563f6750e Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 14 Mar 2023 11:01:26 +0100 Subject: [PATCH] :bug: Fix apply structure modifiers to children --- common/src/app/common/geom/shapes/modifiers.cljc | 14 ++++++++++++-- common/src/app/common/types/modifiers.cljc | 8 ++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/common/src/app/common/geom/shapes/modifiers.cljc b/common/src/app/common/geom/shapes/modifiers.cljc index 62a7e784db..582d2a4040 100644 --- a/common/src/app/common/geom/shapes/modifiers.cljc +++ b/common/src/app/common/geom/shapes/modifiers.cljc @@ -322,10 +322,20 @@ (defn- apply-structure-modifiers [objects modif-tree] - (letfn [(apply-shape [objects [id {:keys [modifiers]}]] + (letfn [(update-children-structure-modifiers + [objects ids modifiers] + (reduce #(update %1 %2 ctm/apply-structure-modifiers modifiers) objects ids)) + + (apply-shape [objects [id {:keys [modifiers]}]] (cond-> objects (ctm/has-structure? modifiers) - (update id ctm/apply-structure-modifiers modifiers)))] + (update id ctm/apply-structure-modifiers modifiers) + + (and (ctm/has-structure? modifiers) + (ctm/has-structure-child? modifiers)) + (update-children-structure-modifiers + (cph/get-children-ids objects id) + (ctm/select-child-structre-modifiers modifiers))))] (reduce apply-shape objects modif-tree))) (defn merge-modif-tree diff --git a/common/src/app/common/types/modifiers.cljc b/common/src/app/common/types/modifiers.cljc index 1884ff0436..5a76d41008 100644 --- a/common/src/app/common/types/modifiers.cljc +++ b/common/src/app/common/types/modifiers.cljc @@ -543,6 +543,10 @@ (or (d/not-empty? structure-parent) (d/not-empty? structure-child))) +(defn has-structure-child? + [modifiers] + (d/not-empty? (dm/get-prop modifiers :structure-child))) + ;; Extract subsets of modifiers (defn select-child @@ -565,6 +569,10 @@ [modifiers] (-> modifiers select-child select-geometry)) +(defn select-child-structre-modifiers + [modifiers] + (-> modifiers select-child select-structure)) + (defn added-children-frames "Returns the frames that have an 'add-children' operation" [modif-tree]