commit 677a4afe0c8ea6f79b3b124f5bbcfc5425261929
parent f23c26fd9b60977b33bbcc3cf6501c3522b61f47
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date: Tue, 15 Oct 2024 14:35:37 -0700
Subdivide pointmap when a point is moved onto it
Diffstat:
1 file changed, 34 insertions(+), 0 deletions(-)
diff --git a/files/floorplans/floorplan/main.js b/files/floorplans/floorplan/main.js
@@ -687,6 +687,31 @@ function precisePointHandler(event, editor, state) {
cleanup()
}
+ const onMap = function(p) {
+ let maps = editor.thingsAt(p, "#pointmaps")
+ let toMaps = editor.backend.mappedPoints[state.to]
+
+ let map
+ for (let i = 0; !map && i < maps.length; ++i) {
+ let mid = lib.getID(maps[i])
+ let good = true
+ for (let k in toMaps) {
+ if (toMaps[k] === mid) {
+ good = false
+ break
+ }
+ }
+ if (good) {
+ map = maps[i]
+ }
+ }
+
+ if (map == null) {
+ return null
+ }
+ return { point: map.whereIsPoint(p.x, p.y), map: map }
+ }
+
const commit = function() {
if (state.onPoint) {
for (let oth in editor.backend.mappedPoints[state.to]) {
@@ -694,6 +719,15 @@ function precisePointHandler(event, editor, state) {
}
editor.remove(state.to)
}
+
+ let on = onMap(state.to.vec())
+ if (on !== null) {
+ let mapD = editor.backend.reqObj(lib.getID(on.map))
+ editor.movePoint(state.to, on.point)
+ editor.mapPoints({ a: mapD.a, b: state.to })
+ editor.mapPoints({ a: mapD.b, b: state.to })
+ editor.remove(on.map)
+ }
editor.finishAction()
cleanup()
}