Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merging of wall issues on 2d #103

Open
micreales opened this issue Jul 16, 2020 · 1 comment
Open

merging of wall issues on 2d #103

micreales opened this issue Jul 16, 2020 · 1 comment

Comments

@micreales
Copy link

Is there any way to prevent merging of wall ? like if you drag the wall on other wall it become one, that has a front and back edge ? Thanks

@twolfson
Copy link

I was able to accomplish this via:

// src/model/corner.ts
// Disabled `this.mergeWithIntersected();`
private move(newX: number, newY: number) {
  this.x = newX;
  this.y = newY;
  // this.mergeWithIntersected(); -- Old behavior: Would merge while still dragging
  this.moved_callbacks.fire(this.x, this.y);

  this.wallStarts.forEach((wall) => {
    wall.fireMoved();
  });

  this.wallEnds.forEach((wall) => {
    wall.fireMoved();
  });
}
// src/floorplanner/floorplanner.ts
// Add `dragging` conditional + deletion
private mouseup() {
  this.mouseDown = false;

  // drawing
  if (this.mode == floorplannerModes.DRAW && !this.mouseMoved) {
    var corner = this.floorplan.newCorner(this.targetX, this.targetY);
    if (this.lastNode != null) {
      this.floorplan.newWall(this.lastNode, corner);
    }
    if (corner.mergeWithIntersected() && this.lastNode != null) {
      this.setMode(floorplannerModes.MOVE);
    }
    this.lastNode = corner;
  }

  // dragging
  if (this.mode == floorplannerModes.MOVE) {
    if (this.activeCorner) {
      this.activeCorner.mergeWithIntersected();
    } else if (this.activeWall) {
      this.activeWall.start.mergeWithIntersected();
      this.activeWall.end.mergeWithIntersected();
    }
  }
}

It did uncover bugs like not deleting corners properly which I'll be addressing in a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants