Skip to content

Commit 3913efa

Browse files
committed
🐛 修复自环有时缩放视野时看不到的问题
1 parent 960a476 commit 3913efa

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

app/src/core/dataStruct/shape/Circle.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ export class Circle extends Shape {
3131
getRectangle(): Rectangle {
3232
const left = this.location.x - this.radius;
3333
const top = this.location.y - this.radius;
34-
const right = this.location.x + this.radius;
35-
const bottom = this.location.y + this.radius;
36-
return new Rectangle(new Vector(left, top), new Vector(right, bottom));
34+
return new Rectangle(new Vector(left, top), Vector.same(this.radius * 2));
3735
}
3836
}

app/src/core/render/canvas2d/renderer.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ export namespace Renderer {
282282
// 是否超出了视野之外
283283
export function isOverView(viewRectangle: Rectangle, entity: StageObject): boolean {
284284
if (!Camera.limitCameraInCycleSpace) {
285+
// 如果没有开循环空间,就要看看是否超出了视野
285286
if (isRenderingChildStage) {
286287
if (!entity.collisionBox.getRectangle().isAbsoluteIn(viewRectangle)) {
287288
return true;
@@ -293,6 +294,7 @@ export namespace Renderer {
293294
}
294295
return false;
295296
}
297+
// 如果开了循环空间,就永远不算超出视野
296298
return false;
297299
}
298300

@@ -672,7 +674,7 @@ export namespace Renderer {
672674
function renderEdges(viewRectangle: Rectangle) {
673675
renderedEdges = 0;
674676
for (const association of StageManager.getAssociations()) {
675-
if (!Camera.limitCameraInCycleSpace && isOverView(viewRectangle, association)) {
677+
if (isOverView(viewRectangle, association)) {
676678
continue;
677679
}
678680
if (association instanceof LineEdge) {

app/src/core/stage/stageObject/association/EdgeCollisionBoxGetter.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,8 @@ export namespace EdgeCollisionBoxGetter {
2626
export function getCollisionBox(edge: LineEdge): CollisionBox {
2727
if (edge.source.uuid === edge.target.uuid) {
2828
// 是一个自环,碰撞箱是圆形
29-
return new CollisionBox([
30-
new Circle(
31-
edge.source.collisionBox.getRectangle().location,
32-
edge.source.collisionBox.getRectangle().size.y / 2,
33-
),
34-
]);
29+
const sourceEntityRect = edge.source.collisionBox.getRectangle();
30+
return new CollisionBox([new Circle(sourceEntityRect.location, sourceEntityRect.size.y / 2)]);
3531
} else {
3632
if (currentStyle === "bezier") {
3733
return getBezierCollisionBox(edge);

0 commit comments

Comments
 (0)