From c7e27b743eb8488ec71adaf365056ff500b458ab Mon Sep 17 00:00:00 2001 From: Julie Lala Date: Wed, 23 Jul 2014 17:03:04 -0400 Subject: preparing modules for clip test --- .../assets/javascripts/rectangles/models/rect.js | 28 +++++----------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'public/assets/javascripts/rectangles/models/rect.js') diff --git a/public/assets/javascripts/rectangles/models/rect.js b/public/assets/javascripts/rectangles/models/rect.js index c14d62c..3341239 100644 --- a/public/assets/javascripts/rectangles/models/rect.js +++ b/public/assets/javascripts/rectangles/models/rect.js @@ -140,15 +140,20 @@ var splits = [] var sides = this.sides + // bisect (or trisect) two overlapping rectangles var x_intervals = this.x.split( r.x, LEFT, RIGHT ) var y_intervals = this.y.split( r.y, FRONT, BACK ) + // generate rectangular regions by crossing the two sets of vectors x_intervals.forEach(function(x, i){ y_intervals.forEach(function(y, i){ var rn = new Rect(x[0], y[0]) rn.id = rz.id rn.sides = ((x[1] | y[1]) & sides) + rn.focused = rz.focused + splits.push(rn) + // cull extra walls from overlapping regions if (r.x.contains(rn.x.a) && r.x.contains(rn.x.b)) { if (rz.y.a == rn.y.a && r.y.containsCenter(rn.y.a)) { // top edges rn.sides &= ~ FRONT @@ -168,30 +173,9 @@ } } -// if (rz.x.contains(r.x.a) || rz.x.contains(r.x.b)) { -// if (r.x.contains(rn.x.b)) { -// rn.sides &= ~ LEFT -// } -// if (r.x.contains(rn.x.b)) { -// rn.sides &= ~ RIGHT -// } -// } -// if (rz.y.contains(r.y.a) || rz.y.contains(r.y.b)) { -// if (r.y.contains(rn.y.a)) { -// rn.sides &= ~ FRONT -// } -// if (r.y.contains(rn.y.b)) { -// rn.sides &= ~ BACK -// } -// } - -// if (r.intersects(rn)) { -// rn.sides = 0 -// } - rn.focused = rz.focused - splits.push(rn) }) }) + return splits } -- cgit v1.2.3-70-g09d2