mirror of
https://github.com/Gongxh0901/kunpolibrary
synced 2025-05-30 22:24:25 +00:00
四叉树形状改变重置包围盒
This commit is contained in:
parent
1b73738c39
commit
8758ea570f
@ -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";
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user