Skip to content

Commit

Permalink
Merge branch 'release/0.13.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Kruptein committed Jan 19, 2019
2 parents 1b4617c + 1494e27 commit a256fea
Show file tree
Hide file tree
Showing 19 changed files with 124 additions and 38 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ All notable changes to this project will be documented in this file.

## Unreleased

## [0.13.3] - 2019-01-19

### Fixed

- Multiple bugs with triangle vision

## [0.13.2] - 2019-01-13

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "planarally-client",
"version": "0.13.2",
"version": "0.13.3",
"description": "A companion tool for when you travel into the planes.",
"scripts": {
"serve": "vue-cli-service serve",
Expand Down
2 changes: 1 addition & 1 deletion client/src/game/ui/menu/menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ import NoteDialog from "@/game/ui/note.vue";
import { getRef, uuidv4 } from "@/core/utils";
import { socket } from "@/game/api/socket";
import { Note } from "@/game/comm/types/general";
import { gameStore } from "@/game/store";
import { layerManager } from "@/game/layers/manager";
import { gameStore } from "@/game/store";
@Component({
components: {
Expand Down
30 changes: 23 additions & 7 deletions client/src/game/visibility/te/cdt.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
BoundingBox,
EdgeCirculator,
FaceCirculator,
LineFaceCirculator,
Expand Down Expand Up @@ -232,7 +233,15 @@ export class CDT {
const pb = vbb.point!;
const pc = vcc.point!;
const pd = vdd.point!;
const pi = intersection(pa, pb, pc, pd);
let pi = intersection(pa, pb, pc, pd);
if (pi !== pa && pi !== pb && pi !== pc && pi !== pd) {
const bbox = new BoundingBox(pi!);
bbox.dilate(4);
if (bbox.overlaps(new BoundingBox(pa))) pi = pa;
if (bbox.overlaps(new BoundingBox(pb))) pi = pb;
if (bbox.overlaps(new BoundingBox(pc))) pi = pc;
if (bbox.overlaps(new BoundingBox(pd))) pi = pd;
}
let vi: Vertex;
if (pi === null) throw new Error("what");
else {
Expand Down Expand Up @@ -312,11 +321,7 @@ export class CDT {
lessEdge(e1: Edge, e2: Edge) {
const ind1 = e1[1];
const ind2 = e2[1];
/* return( (&(*e1.first) < &(*e2.first))
|| ( (&(*e1.first) == &(*e2.first)) && (ind1 < ind2)));*/
// TODO: This is not proper.
// console.error("This has to be done correctly");
return ind1 < ind2;
return e1[0].uid < e2[0].uid || (e1[0].uid === e2[0].uid && ind1 < ind2);
}

propagatingFlipE(edges: Edge[]) {
Expand Down Expand Up @@ -352,6 +357,17 @@ export class CDT {
e[2] = [ni, cw(indn)];
e[3] = [ni, ccw(indn)];

for (const edge of e) {
const tt = edge![0];
const ii = edge![1];
eni = [tt.neighbours[ii]!, this.tds.mirrorIndex(tt, ii)];
if (this.lessEdge(edge!, eni))
edgeSet.splice(edgeSet.findIndex(ed => ed[0] === edge![0] && ed[1] === edge![1]), 1);
else edgeSet.splice(edgeSet.findIndex(ed => ed[0] === eni[0] && ed[1] === eni[1]), 1);
}

this.flip(t, indf);

for (const edge of e) {
const tt = edge![0];
const ii = edge![1];
Expand Down Expand Up @@ -615,7 +631,7 @@ export class CDT {
if (c.isInfinite()) {
return { loc: c, lt: LocateType.OUTSIDE_CONVEX_HULL, li: c.indexV(this.tds._infinite) };
}
const leftFirst = Math.round(Math.random());
const leftFirst = 0; // Math.round(Math.random());
const p0 = c.vertices[0]!.point!;
const p1 = c.vertices[1]!.point!;
const p2 = c.vertices[2]!.point!;
Expand Down
30 changes: 17 additions & 13 deletions client/src/game/visibility/te/draw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function drl(ctx: CanvasRenderingContext2D, from: number[], to: number[], constr
ctx.stroke();
}

function drawPolygonT(tds: TDS, local = true, clear = true) {
function drawPolygonT(tds: TDS, local = true, clear = true, logs: 0 | 1 | 2 = 0) {
I = 0;
J = 0;
let T = 0;
Expand All @@ -88,15 +88,17 @@ function drawPolygonT(tds: TDS, local = true, clear = true) {
do {
const fromP = ei.edge.first!.vertices[ccw(ei.edge.second)]!.point!;
const toP = ei.edge.first!.vertices[cw(ei.edge.second)]!.point!;
// if (fromP[0] === -Infinity || toP[0] === -Infinity) {
// ei.next();
// continue;
// }
J++;
// if (ei.edge.first!.constraints[ei.edge.second]) {
// I++;
// console.log(`Edge: (*) ${fromP} > ${toP}`);
// } else console.log(`Edge: ${fromP} > ${toP}`);
if (logs > 0) {
if (fromP[0] === -Infinity || toP[0] === -Infinity) {
ei.next();
continue;
}
J++;
if (ei.edge.first!.constraints[ei.edge.second]) {
I++;
if (logs === 2) console.log(`Edge: (*) ${fromP} > ${toP}`);
} else if (logs === 2) console.log(`Edge: ${fromP} > ${toP}`);
}
do {
ei.next();
ei.collect();
Expand Down Expand Up @@ -126,7 +128,7 @@ function drawPolygonT(tds: TDS, local = true, clear = true) {
ctx.closePath();
ctx.fill();
}
// console.log("[T] ", ...po, t.constraints);
if (logs === 2) console.log("[T] ", ...po, t.constraints);

ctx.moveTo(x(t.vertices[0]!.point![0], local), y(t.vertices[0]!.point![1], local));
if (t.vertices[0] !== undefined && t.vertices[1] !== undefined)
Expand All @@ -136,8 +138,10 @@ function drawPolygonT(tds: TDS, local = true, clear = true) {
if (t.vertices[2] !== undefined && t.vertices[0] !== undefined)
drl(ctx, t.vertices[2]!.point!, t.vertices[0]!.point!, t.constraints[1], local);
}
console.log(`Edges: ${I}/${J}`);
console.log(`Faces: ${T}`);
if (logs > 0) {
console.log(`Edges: ${I}/${J}`);
console.log(`Faces: ${T}`);
}
}

(<any>window).DP = drawPolygon;
Expand Down
33 changes: 29 additions & 4 deletions client/src/game/visibility/te/tds.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { uuidv4 } from "@/core/utils";
import { CDT } from "./cdt";
import { ccw, cw, orientation } from "./triag";
import { ccw, cw, orientation, ulp } from "./triag";

export type Point = number[];

Expand Down Expand Up @@ -48,7 +47,8 @@ export class Triangle {
vertices: (Vertex | null)[] = [];
neighbours: (Triangle | null)[] = [null, null, null];
constraints = [false, false, false];
uuid = uuidv4();
static _counter = 0;
uid = Triangle._counter++;

constructor(...vertices: (Vertex | null)[]) {
this.vertices = vertices;
Expand Down Expand Up @@ -105,7 +105,6 @@ export class Vertex {
infinite = false;
private _point: Point | undefined;
triangle: Triangle | undefined;
uuid = uuidv4();

constructor(point?: Point) {
this._point = point;
Expand Down Expand Up @@ -611,3 +610,29 @@ export class TDS {
return v;
}
}

export class BoundingBox {
x1: number;
x2: number;
y1: number;
y2: number;
constructor(p: Point) {
this.x1 = p[0];
this.y1 = p[1];
this.x2 = p[0];
this.y2 = p[1];
}

dilate(dist: number) {
this.x1 -= dist * ulp(this.x1);
this.y1 -= dist * ulp(this.y1);
this.x2 += dist * ulp(this.x2);
this.y2 += dist * ulp(this.y2);
}

overlaps(other: BoundingBox): boolean {
if (this.x2 < other.x1 || other.x2 < this.x1) return false;
if (this.y2 < other.y1 || other.y2 < this.y1) return false;
return true;
}
}
39 changes: 37 additions & 2 deletions client/src/game/visibility/te/triag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export function xyEqual(p: Point, q: Point) {
}

export function xySmaller(p: Point, q: Point) {
return p[0] <= q[0] && p[1] <= q[1];
return p[0] < q[0] || (p[0] === q[0] && p[1] < q[1]);
}

export function xyCompare(p: Point, q: Point) {
Expand Down Expand Up @@ -218,7 +218,7 @@ function getLine(p0: Point, p1: Point): Line {
if (p0[1] === p1[1]) return [0, 1, -p0[1]];
const x = p1[0] - p0[0];
const y = p1[1] - p0[1];
return [-y, x, -x + y];
return [-y, x, -x * p0[1] + y * p0[0]];
}

function getIntersectionType(pa: Point, pb: Point, pc: Point, pd: Point) {
Expand Down Expand Up @@ -424,3 +424,38 @@ function doIntersect(A1: Point, A2: Point, B1: Point, B2: Point): boolean {
}
}
}

function nextUp(x: number) {
if (x !== x) {
return x;
}
if (x === -1 / 0) {
return -Number.MAX_VALUE;
}
if (x === +1 / 0) {
return +1 / 0;
}
if (x === +Number.MAX_VALUE) {
return +1 / 0;
}
let y = x * (x < 0 ? 1 - Number.EPSILON / 2 : 1 + Number.EPSILON);
if (y === x) {
y = Number.MIN_VALUE * Number.EPSILON > 0 ? x + Number.MIN_VALUE * Number.EPSILON : x + Number.MIN_VALUE;
}
if (y === +1 / 0) {
y = +Number.MAX_VALUE;
}
const b = x + (y - x) / 2;
if (x < b && b < y) {
y = b;
}
const c = (y + x) / 2;
if (x < c && c < y) {
y = c;
}
return y === 0 ? -0 : y;
}

export function ulp(x: number) {
return x < 0 ? nextUp(x) - x : x + nextUp(-x);
}
2 changes: 1 addition & 1 deletion server/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.13.2
0.13.3

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions server/static/js/app-legacy.e427aa98.js

This file was deleted.

1 change: 0 additions & 1 deletion server/static/js/app-legacy.e427aa98.js.map

This file was deleted.

2 changes: 2 additions & 0 deletions server/static/js/app-legacy.e9743101.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions server/static/js/app-legacy.e9743101.js.map

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions server/static/js/app.e427aa98.js

This file was deleted.

1 change: 0 additions & 1 deletion server/static/js/app.e427aa98.js.map

This file was deleted.

2 changes: 2 additions & 0 deletions server/static/js/app.e9743101.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions server/static/js/app.e9743101.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion server/templates/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><title>PlanarAlly - The companion tool for your planar travels.</title><script defer src=https://use.fontawesome.com/releases/v5.0.8/js/all.js></script><link rel=stylesheet type=text/css href=/static/extern/css/directory.css><link href=/static/css/app.20405678.css rel=preload as=style><link href=/static/js/app.e427aa98.js rel=modulepreload as=script><link href=/static/js/chunk-vendors.026de90a.js rel=modulepreload as=script><link href=/static/css/app.20405678.css rel=stylesheet></head><body><noscript><strong>We're sorry but PlanarAlly doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script type=module src=/static/js/chunk-vendors.026de90a.js></script><script type=module src=/static/js/app.e427aa98.js></script><script>!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script src=/static/js/chunk-vendors-legacy.026de90a.js nomodule></script><script src=/static/js/app-legacy.e427aa98.js nomodule></script></body></html>
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><title>PlanarAlly - The companion tool for your planar travels.</title><script defer src=https://use.fontawesome.com/releases/v5.0.8/js/all.js></script><link rel=stylesheet type=text/css href=/static/extern/css/directory.css><link href=/static/css/app.fd504196.css rel=preload as=style><link href=/static/js/app.e9743101.js rel=modulepreload as=script><link href=/static/js/chunk-vendors.026de90a.js rel=modulepreload as=script><link href=/static/css/app.fd504196.css rel=stylesheet></head><body><noscript><strong>We're sorry but PlanarAlly doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script type=module src=/static/js/chunk-vendors.026de90a.js></script><script type=module src=/static/js/app.e9743101.js></script><script>!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()},!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script><script src=/static/js/chunk-vendors-legacy.026de90a.js nomodule></script><script src=/static/js/app-legacy.e9743101.js nomodule></script></body></html>

0 comments on commit a256fea

Please sign in to comment.