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

Add is_backface_visible. #223

Merged
merged 2 commits into from Aug 24, 2017
Merged

Add is_backface_visible. #223

merged 2 commits into from Aug 24, 2017

Conversation

@mephisto41
Copy link
Contributor

mephisto41 commented Aug 24, 2017

We need this utility function for servo/webrender#1419

r? @kvark


This change is Reviewable

Copy link
Collaborator

nical left a comment

It would be good to have a few tests for this.

@@ -177,6 +177,17 @@ where T: Copy + Clone +
)
}

/// Checks if we're facing backface

This comment has been minimized.

@nical

nical Aug 24, 2017

Collaborator

The comment is a bit confusing because the matrix itself does not face any direction. Could you replace it with something like "Check whether shapes on the XY plane with Z pointing towards the screen transformed by this matrix would be facing back."

@mephisto41 mephisto41 force-pushed the mephisto41:backface-visible branch from a990125 to ac09340 Aug 24, 2017
@mephisto41
Copy link
Contributor Author

mephisto41 commented Aug 24, 2017

Thanks for comment. I've replaced the comment and add some tests.

@mephisto41 mephisto41 force-pushed the mephisto41:backface-visible branch from ac09340 to d8cba77 Aug 24, 2017
@@ -177,6 +177,18 @@ where T: Copy + Clone +
)
}

/// Check whether shapes on the XY plane with Z pointing towards the
/// screen transformed by this matrix would be facing back.

This comment has been minimized.

@kvark

kvark Aug 24, 2017

Member

I think the comment needs to be fixed: "Z pointing towards the screen" implies that it's front facing already

This comment has been minimized.

@nical

nical Aug 24, 2017

Collaborator

It implies "something front-facing being transformed will become back-facing" which is maybe a bit convoluted but I believe it conveys the correct information.

This comment has been minimized.

@mephisto41

mephisto41 Aug 24, 2017

Author Contributor

I think the comment is right. It says "XY plane with Z pointing towards the screen" transformed by "this matrix" would be facing back. Which means a plane facing the screen become facing back after transformed by this matrix.

/// Check whether shapes on the XY plane with Z pointing towards the
/// screen transformed by this matrix would be facing back.
pub fn is_backface_visible(&self) -> bool {
// inverse().m33 < 0;

This comment has been minimized.

@kvark

kvark Aug 24, 2017

Member

could you provide the links/sources onto why you think inverse().m33 < 0 is our target condition for backface visibility?

This comment has been minimized.

@nical

nical Aug 24, 2017

Collaborator

Not terribly useful to understand the underlying math but this is ported from gecko's code apparently: https://searchfox.org/mozilla-central/rev/48ea452803907f2575d81021e8678634e8067fc2/gfx/2d/Matrix.h#1392

This comment has been minimized.

@@ -662,6 +674,7 @@ mod tests {
use super::*;

use std::f32::consts::FRAC_PI_2;
use std::f32::consts::PI;

This comment has been minimized.

@kvark

kvark Aug 24, 2017

Member

nit: combine with the previous use

This comment has been minimized.

@mephisto41

mephisto41 Aug 24, 2017

Author Contributor

I'll fix this.

@kvark
kvark approved these changes Aug 24, 2017
Copy link
Member

kvark left a comment

Alright, thanks for explanation!

@mephisto41 mephisto41 force-pushed the mephisto41:backface-visible branch from c55c353 to 6617f20 Aug 24, 2017
@kvark
Copy link
Member

kvark commented Aug 24, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Aug 24, 2017

📌 Commit 6617f20 has been approved by kvark

@bors-servo
Copy link
Contributor

bors-servo commented Aug 24, 2017

Testing commit 6617f20 with merge e1ab971...

bors-servo added a commit that referenced this pull request Aug 24, 2017
Add is_backface_visible.

We need this utility function for servo/webrender#1419

r? @kvark

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/euclid/223)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Aug 24, 2017

☀️ Test successful - status-travis
Approved by: kvark
Pushing e1ab971 to master...

@bors-servo bors-servo merged commit 6617f20 into servo:master Aug 24, 2017
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.