Skip to content

Commit

Permalink
Merge branch 'upgrade' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
sgratzl committed Nov 16, 2024
2 parents 1eaee18 + dc3fe49 commit 8aa13fe
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 14 deletions.
48 changes: 36 additions & 12 deletions src/BubbleSets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,55 @@ import { PointPath } from './PointPath';

export interface IPotentialOptions {
/**
* how many pixels per potential area group to improve speed
* the resolution of the algorithm in square pixels
* @default 4
*/
pixelGroup?: number;
/**
* the amount of space to move the virtual edge when wrapping around obstacles
* @default 10
*/
morphBuffer?: number;
}

export interface IRoutingOptions {
virtualEdges?: boolean;
/**
* maximum number of iterations when computing routes between members
* number of times to run the algorithm to refine the path finding in difficult areas
* @default 100
*/
maxRoutingIterations?: number;
/**
* the amount of space to move the virtual edge when wrapping around obstacles
* @default 10
*/
morphBuffer?: number;
}
export interface IOutlineOptions {
/**
* maximum number of iterations when computing the contour
* number of times to refine the boundary
* @default 20
*/
maxMarchingIterations?: number;

/**
* the distance from edges at which energy is 1 (full influence)
* @default 10
*/
edgeR0?: number;
/**
* the distance from edges at which energy is 0 (no influence)
* @default 20
*/
edgeR1?: number;
/**
* the distance from nodes which energy is 1 (full influence)
* @default 15
*/
nodeR0?: number;
/**
* the distance from nodes at which energy is 0 (no influence)
* @default 50
*/
nodeR1?: number;

threshold?: number;
Expand All @@ -48,14 +71,15 @@ export interface IOutlineOptions {
export interface IBubbleSetOptions extends IRoutingOptions, IOutlineOptions, IPotentialOptions {}

export const defaultOptions: Readonly<Required<IBubbleSetOptions>> = {
maxRoutingIterations: 100,
maxMarchingIterations: 20,
pixelGroup: 4,
edgeR0: 10,
edgeR1: 20,
nodeR0: 15,
nodeR1: 50,
morphBuffer: 10,
// override these defaults to change the spacing and bubble precision; affects performance and appearance
maxRoutingIterations: 100, // number of times to run the algorithm to refine the path finding in difficult areas
maxMarchingIterations: 20, // number of times to refine the boundary
pixelGroup: 4, // the resolution of the algorithm in square pixels
edgeR0: 10, // the distance from edges at which energy is 1 (full influence)
edgeR1: 20, // the distance from edges at which energy is 0 (no influence)
nodeR0: 15, // the distance from nodes which energy is 1 (full influence)
nodeR1: 50, // the distance from nodes at which energy is 0 (no influence)
morphBuffer: 10, // the amount of space to move the virtual edge when wrapping around obstacles

threshold: 1,
memberInfluenceFactor: 1,
Expand Down
4 changes: 2 additions & 2 deletions src/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ function rerouteLine(
}
// else through top to bottom, calculate areas
const totalArea = item.height * item.width;
const leftArea = item.height * ((topIntersect.x - item.x + (rightIntersect.x - item.x)) * 0.5);
const leftArea = item.height * ((topIntersect.x - item.x + (bottomIntersect.x - item.x)) * 0.5);
if (leftArea < totalArea * 0.5) {
// go around left
if (topIntersect.x > bottomIntersect.x)
Expand Down Expand Up @@ -368,7 +368,7 @@ function rerouteLine(
}
// else through top to bottom, calculate areas
const totalArea = item.height * item.width;
const leftArea = item.height * ((topIntersect.x - item.x + (rightIntersect.x - item.x)) * 0.5);
const leftArea = item.height * ((topIntersect.x - item.x + (bottomIntersect.x - item.x)) * 0.5);
if (leftArea < totalArea * 0.5) {
// go around right
if (topIntersect.x > bottomIntersect.x)
Expand Down

0 comments on commit 8aa13fe

Please sign in to comment.