processing / processing/processing4

PShape.contains() is broken for transformed shapes (double invert)

未关闭
#1,445 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

paused
主要语言
Java
星标
494
派生
183
平均合并
4 小时 39 分钟
30 天内合并 PR
3

描述

contains() in PShape is inverting the matrix twice, so it cancels itself out and hit-testing runs in the wrong space.

In PShape.java:

PMatrix inverseCoords = matrix.get();
inverseCoords.invert();
inverseCoords.invert();
inverseCoords.mult(new PVector(x, y), p);

That second invert() should not be there.

So for translated/rotated/scaled shapes, contains(x, y) gives wrong answers.

Quick repro:

PShape s = createShape(RECT, 0, 0, 50, 50);
s.translate(100, 100);
println(s.contains(120, 120)); // false, should be true

Expected: point-in-shape test respects the shape transform.
Actual: transform handling is wrong because inverse matrix is never actually applied.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 PShape.java 中的 contains() 开始,issue 指出这里存在两次连续的矩阵求逆。运行提供的 translated-rectangle repro,并验证移除多余的求逆操作后,经过变换的形状调用 contains(120, 120) 会返回 true。

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
computer-graphics
Issue 类型
缺陷
难度
1/5
预计耗时
1 小时以内
活跃度
停滞
描述清晰度
描述清楚
新手友好度
55/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。