Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cartesian-theatrics committed Nov 26, 2024
1 parent 5ff96b3 commit 89e544b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
13 changes: 4 additions & 9 deletions src/main/plexus/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@
along the x axis by negative `:curve-radians`.
opts
`:angle` - number of radians to cufve.
`:curve-radius` - radius of the curve."
`:angle` - number of radians to curve.
`:curve-radius` - radius of the curve.
`:arc-length` - Arc length of the curve (exclusive with `:angle`)."
schema/curve-schema)

(defop right
Expand Down Expand Up @@ -194,13 +195,7 @@
opts
`:name` (required) A keyword or string naming the frame.
`:cross-section` (optional) Cross-section to associate with the
current frame.
Options that specify default values to for future extrusion segments applied to this frame:
`:cs` (optional) specifies the default number of circular segments to each
curved extrusion.
`:curve-radius` (optional) Default curve-radius of future segments applied to this frame."
current frame."
schema/frame-schema)

(defop save-transform
Expand Down
32 changes: 19 additions & 13 deletions src/main/plexus/impl.clj
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@
(assoc form :cross-section (:cross-section (get frames replace)))
form)
default-frame-id (:default-frame state)
_ default-frame-id
default-frame (get frames default-frame-id)
default-frame-transform (m/compose-frames
(:frame-transform default-frame)
Expand All @@ -233,13 +232,13 @@
(assoc frame
:segment-transform
(m/compose-frames
(m/invert-frame (:frame-transform frame))
default-frame-transform))
(m/invert-frame (:frame-transform frame))
default-frame-transform))
(assoc default-frame
:segments []
:segment-transform (m/frame 1)
:frame-transform default-frame-transform))
(select-keys form [:name :cross-section :curve-radius])))
(select-keys form [:name :cross-section :curve-radius])))
(or (:meta form) {}))]
(recur (cond-> (-> state
(assoc :default-frame frame-id)
Expand Down Expand Up @@ -384,10 +383,13 @@
(into result-forms (:result-forms form))))

(:plexus.impl/left :plexus.impl/right :plexus.impl/up :plexus.impl/down)
(let [{:keys [curve-radius angle to op transform-step-fn props gap cs]
(let [{:keys [curve-radius angle to op transform-step-fn props gap cs arc-length]
:or {transform-step-fn (fn [tf angle] tf)
cs 20}} form
apply-to (if to (set to) current-frame-ids)]
apply-to (if to (set to) current-frame-ids)
angle (if angle
angle
(/ arc-length curve-radius))]
(recur state
forms
(reduce
Expand All @@ -405,6 +407,9 @@
(f (sign r))
(tf/go-forward d)
(f (sign (- angle r))))
is-gap (or (true? gap)
(and (sequential? gap) (contains? (set gap) frame-id)))
cross-section (and (not is-gap) (:cross-section frame))
all-tfs (if gap
[]
(all-transforms start-transform
Expand All @@ -417,9 +422,6 @@
angle
cs
transform-step-fn))
is-gap (or (true? gap)
(and (sequential? gap) (contains? (set gap) frame-id)))
cross-section (and (not is-gap) (:cross-section frame))
manifold (when cross-section
(-> cross-section
(m/rotate 180)
Expand Down Expand Up @@ -452,7 +454,9 @@

:plexus.impl/translate
(let [{:keys [x y z to global?]} form
apply-to (if to (set to) current-frame-ids)]
apply-to (if to
(set to)
(conj current-frame-ids (:default-frame state)))]
(recur state
forms
(reduce
Expand All @@ -466,13 +470,15 @@
(DoubleVec3. (or x 0) (or y 0) (or z 0))))
(update frame :segment-transform m/translate [(or x 0) (or y 0) (or z 0)])))))
frames
(conj apply-to (:default-frame state)))
apply-to)
result-forms))


:plexus.impl/rotate
(let [{:keys [x y z to]} form
apply-to (if to (set to) current-frame-ids)]
apply-to (if to
(set to)
(conj current-frame-ids (:default-frame state)))]
(recur state
forms
(reduce
Expand All @@ -484,7 +490,7 @@
(* 1 (or y 0))
(* 1 (or z 0))]))))
frames
(conj apply-to (:default-frame state)))
apply-to)
result-forms))

:plexus.impl/segment
Expand Down
1 change: 1 addition & 0 deletions src/main/plexus/schema.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
(def curve-schema
[:map
[:angle {:optional true} number?]
[:arc-length {:optional true} number?]
[:curve-radius {:optional true} number?]
[:transform-step-fn {:optional true} fn?]])

Expand Down

0 comments on commit 89e544b

Please sign in to comment.