Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clipping region not functioning for block held in beaker #212

Closed
chrisklus opened this issue Feb 8, 2019 · 7 comments
Closed

Clipping region not functioning for block held in beaker #212

chrisklus opened this issue Feb 8, 2019 · 7 comments
Assignees
Labels

Comments

@chrisklus
Copy link
Contributor

chrisklus commented Feb 8, 2019

After #114 was implemented, a clipping region was in place to keep the back of the blocks opaque when they're in the beaker, regardless of wether they're resting or being held by a user. See behavior from dev.10:

kapture 2019-02-08 at 14 59 59

At some point, this functionality stopped working when the block is being held inside the beaker. See the behavior on the published version:

kapture 2019-02-08 at 15 05 25

@jbphet is going to look into this. Also assigning @ariel-phet for prioritization.

@chrisklus chrisklus changed the title Clipping region not functioning for block being held in beaker Clipping region not functioning for block held in beaker Feb 8, 2019
@ariel-phet
Copy link

Since this behavior was working before, and it is the desired behavior, marking as high priority since my guess is some investigation will yield a solution fairly quickly.

@ariel-phet ariel-phet removed their assignment Feb 12, 2019
@jbphet jbphet removed their assignment Feb 14, 2019
@jbphet
Copy link
Contributor

jbphet commented Feb 14, 2019

This was due to a test that was using incorrect bounds for the beaker. I think this may be the result of an attempted optimization that I did that was done incorrectly. It should be fixed now, and we should have it verified in the next release. Unassigning until then.

@KatieWoe
Copy link
Contributor

This can still happen a small amount if the two blocks are stacked on top of each other. The chunks in the water are lightly visible where the top of the bottom block and the bottom of the top block overlap.
tinybitseethrough

@KatieWoe
Copy link
Contributor

It is worse in the published version

@KatieWoe
Copy link
Contributor

Also, not sure if this is intended, but the chunks of the bottom block are visible in this area, even without moving the top block.
vissibleunder

@chrisklus
Copy link
Contributor Author

From #212 (comment):

This can still happen a small amount if the two blocks are stacked on top of each other. The chunks in the water are lightly visible where the top of the bottom block and the bottom of the top block overlap.

Right! Good catch. If the upper block is being grabbed, there is no clipping mask wherever the blocks overlap, as if their two clipping masks are canceling each other out. @jbphet do you think this is reasonable to fix/worth fixing?

It is worse in the published version

This issue was found after publication, so the original (and much more noticeable) problem identified in #212 (comment) is present in the published version.

Also, not sure if this is intended, but the chunks of the bottom block are visible in this area, even without moving the top block.

Since both blocks are transparent, this is intentional.

@chrisklus chrisklus assigned jbphet and unassigned chrisklus Mar 26, 2019
@jbphet
Copy link
Contributor

jbphet commented Mar 27, 2019

@jbphet do you think this is reasonable to fix/worth fixing?

I took a look at the code, which is in BeakerContainerView, and specifically in the addProjectedBlocksToClipArea method. Unfortunately, this would not be easy to correct. The clipping area that is created to hide the energy chunks is drawn with "holes" for the blocks, and if the holes overlap, the energy chunks behind them (i.e. in the water) can show through. There is specific code in place to handle that case where the blocks overlap due to be stacked, and in that case it just draws a single shape. In the case where the user is dragging a block and they overlap, we'd have to create a single shape the encompasses both, which would be tricky in situations where the top block is dragged such that it is not directly above the bottom block.

It might be possible to use some of the constructive area geometry (CAG) methods to make a union of these shapes. I'm skeptical that this would work, however, since the winding direction of the holes in the clipping mask have to be drawn in the opposite direction of the outside of the mask, and the CAG methods don't appear to provide any control over this.

So, bottom line, I don't think it's worth the time and effort to try to address this. If it's any consolation, even with this (IMO minor) issue, the clipping still works way better than it did in the Java version.

Since the more significant problem that originally motivated this GitHub issue is fixed and verified, I'm going to close this issue.

@jbphet jbphet closed this as completed Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants