summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-08-21 12:55:44 -0400
committerJules Laplace <jules@okfoc.us>2015-08-21 12:55:44 -0400
commit62c899384b0cf4aab6288f662e12f11321de95df (patch)
tree1eb1963e5bf5e24e6f89b0e0ddc8ce0d48144de2
parentca76295998fb75e9ab9c83ee9a1a694b9e0656c1 (diff)
getting full coverage with rooms
-rw-r--r--public/assets/javascripts/rectangles/engine/shapes/polyline.js2
-rw-r--r--public/assets/javascripts/rectangles/engine/shapes/regionlist.js12
-rw-r--r--public/assets/javascripts/ui/blueprint/BlueprintEditor.js11
3 files changed, 16 insertions, 9 deletions
diff --git a/public/assets/javascripts/rectangles/engine/shapes/polyline.js b/public/assets/javascripts/rectangles/engine/shapes/polyline.js
index 99c8fda..6c64128 100644
--- a/public/assets/javascripts/rectangles/engine/shapes/polyline.js
+++ b/public/assets/javascripts/rectangles/engine/shapes/polyline.js
@@ -47,7 +47,7 @@ var Polyline = Fiber.extend(function(base){
return null
}
exports.hasEndPointNear = function(p){
- if (this.closed) return null
+ if (this.closed || ! this.points.length) return null
if (this.firstPoint().distanceTo( p ) < 10/map.zoom) {
return this.firstPoint()
}
diff --git a/public/assets/javascripts/rectangles/engine/shapes/regionlist.js b/public/assets/javascripts/rectangles/engine/shapes/regionlist.js
index acb4ead..f86968f 100644
--- a/public/assets/javascripts/rectangles/engine/shapes/regionlist.js
+++ b/public/assets/javascripts/rectangles/engine/shapes/regionlist.js
@@ -13,6 +13,7 @@ var RegionList = (function(){
var rooms = []
var open_segments = []
+ var closed_segments = []
var segment, open_segment, x_segment, y_segments, overlapped
@@ -21,6 +22,7 @@ var RegionList = (function(){
if (! segment.isVertical()) {
continue
}
+ console.log(segment+"")
overlapped = false
for (var j = 0; j < open_segments.length; j++) {
open_segment = open_segments[j]
@@ -28,17 +30,17 @@ var RegionList = (function(){
// if we have overlap, it means we have made a full room
console.log(segment.y+"", "overlaps", open_segment.y+"")
overlapped = true
+ closed_segments.push(open_segments[j])
open_segments.splice(j--, 1)
x_segment = new vec2( open_segment.x.a, segment.x.b )
- y_segments = segment.y.split(open_segment.y, TOP, BOTTOM)
+ y_segments = open_segment.y.split(segment.y, TOP, BOTTOM)
console.log(y_segments.map(function(s){ return s+"" }).join("\n"))
y_segments.forEach(function(seg){
-
rooms.push(new Rect( x_segment, seg[0] ))
var new_seg = new Rect( segment.x, seg[0] )
- open_segments.shift(new_seg)
+ open_segments.unshift(new_seg)
j++
})
}
@@ -49,8 +51,8 @@ var RegionList = (function(){
}
// console.log(rooms.map(function(s){ return s.toString() }).join("\n"))
-
- return { rooms: rooms, open_segments: open_segments, segments: segments }
+ console.log({ rooms: rooms, open_segments: open_segments, segments: segments, closed_segments: closed_segments })
+ return { rooms: rooms, open_segments: open_segments, segments: segments, closed_segments: closed_segments }
}
RegionList.getSortedSegments = function(){
diff --git a/public/assets/javascripts/ui/blueprint/BlueprintEditor.js b/public/assets/javascripts/ui/blueprint/BlueprintEditor.js
index 7ec1352..cf9dea6 100644
--- a/public/assets/javascripts/ui/blueprint/BlueprintEditor.js
+++ b/public/assets/javascripts/ui/blueprint/BlueprintEditor.js
@@ -116,9 +116,14 @@ var BlueprintEditor = View.extend(AnimatedView.prototype).extend({
map.draw.mouse(map.ui.mouse.cursor)
map.draw.camera(scene.camera)
- this.rooms.segments.forEach(function(seg,i){
- map.draw.ctx.fillStyle = "#f00"
- map.draw.ctx.fillRect( seg.x.a, seg.y.a, seg.width()+1, seg.height()+1 )
+ this.rooms.open_segments.forEach(function(seg,i){
+ map.draw.ctx.fillStyle = "#00f"
+ map.draw.ctx.fillRect( seg.x.a, seg.y.a, seg.width()+10, seg.height() )
+ })
+
+ this.rooms.closed_segments.forEach(function(seg,i){
+ map.draw.ctx.fillStyle = "#0ff"
+ map.draw.ctx.fillRect( seg.x.a, seg.y.a, seg.width()+10, seg.height() )
})
this.rooms.rooms.forEach(function(room,i){