diff --git a/src/kunpocc.ts b/src/kunpocc.ts index 1f53b0f..db79336 100644 --- a/src/kunpocc.ts +++ b/src/kunpocc.ts @@ -31,9 +31,9 @@ export { ReadNetFile } from "./net/nettools/ReadNetFile"; /** 四叉树 */ export { Box } from "./quadtree/Box"; export { Circle } from "./quadtree/Circle"; +export { IShape } from "./quadtree/IShape"; export { Polygon } from "./quadtree/Polygon"; export { QTConfig, QuadTree } from "./quadtree/QuadTree"; -export { Shape } from "./quadtree/Shape"; /** 行为树 */ export { Agent as BTAgent } from "./behaviortree/Agent"; diff --git a/src/quadtree/Circle.ts b/src/quadtree/Circle.ts index 76d1d6a..9a65e1d 100644 --- a/src/quadtree/Circle.ts +++ b/src/quadtree/Circle.ts @@ -9,7 +9,7 @@ import { ShapeType } from "./IShape"; import { Shape } from "./Shape"; export class Circle extends Shape { - public radius: number; // 半径 + private _radius: number; // 半径 public get shapeType(): ShapeType { return ShapeType.CIRCLE; @@ -17,14 +17,26 @@ export class Circle extends Shape { constructor(radius: number, tag: number = -1) { super(tag); - this.radius = radius; - this._boundingBox.x = -this.radius; - this._boundingBox.y = -this.radius; - this._boundingBox.width = this.radius * 2; - this._boundingBox.height = this.radius * 2; + this._radius = radius; + this._boundingBox.x = -this._radius; + this._boundingBox.y = -this._radius; + this._boundingBox.width = this._radius * 2; + this._boundingBox.height = this._radius * 2; } public getBoundingBox(): Rect { return this._boundingBox; } + + public get radius(): number { + return this._radius; + } + + public set radius(value: number) { + this._radius = value; + this._boundingBox.x = -this._radius; + this._boundingBox.y = -this._radius; + this._boundingBox.width = this._radius * 2; + this._boundingBox.height = this._radius * 2; + } } \ No newline at end of file diff --git a/src/quadtree/Polygon.ts b/src/quadtree/Polygon.ts index 7066dea..d3266d4 100644 --- a/src/quadtree/Polygon.ts +++ b/src/quadtree/Polygon.ts @@ -87,5 +87,6 @@ export class Polygon extends Shape { for (let i = 0, len = pts.length; i < len; i++) { this._realPoints[i] = v2(pts[i].x, pts[i].y); } + this._isDirty = true; } } \ No newline at end of file