Skip to content

Commit

Permalink
Bug 1572197 - Plane split dependency update
Browse files Browse the repository at this point in the history
  • Loading branch information
kvark committed Aug 9, 2019
1 parent bb2189a commit eb0617b
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 27 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions gfx/wr/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gfx/wr/webrender/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ lazy_static = "1"
log = "0.4"
malloc_size_of_derive = "0.1"
num-traits = "0.2"
plane-split = "0.14.0"
plane-split = "0.14.1"
png = { optional = true, version = "0.14" }
rayon = "1"
ron = { optional = true, version = "0.1.7" }
Expand Down
2 changes: 1 addition & 1 deletion third_party/rust/plane-split/.cargo-checksum.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"files":{"Cargo.toml":"2770453e4940bce81fed8d763daec0eecefcb4d14b1f296e467ef6ac22c24bfc","LICENSE":"b946744aeda89b467929585fe8eeb5461847695220c1b168fb375d8abd4ea3d0","README.md":"a65ed5c817c867fe23bc2029f34baea4a645a07dd5d101a0027e796d2923be58","benches/split.rs":"632a011dfc6d8235dea853785061b7bbfe0362eb85b91b3b01fbf77a7f1c7f26","src/bsp.rs":"964182582d53a160a86809231c61ba6512f38dde14b83c42b8145ef782064d30","src/clip.rs":"edb729a136706ad2e0d93fb8f79ec27ba9e1128d0debd2350e458d67beceb192","src/lib.rs":"aec71888fa99939b02e3fa3486817ce0d49d5bd5dc8e857fadbf7f48f24bf111","src/polygon.rs":"305af53f5d9334a10481f32ff60729e43e8c497d563c72e926b67dd7b68a261e","tests/clip.rs":"64e24fa6ea0ce05a7bfb837ef0e827f11a4c1c096cbac68283b74a2b32c47bb3","tests/main.rs":"238b0108b4605b8f7c77b2a886c9fb6ccb5ddc2644def166afb4eaedaec3a7c7","tests/split.rs":"f8f0784b9d2f1b3dbc0a0f25fc667ec3aa301b2ae4346f5b7ca0024c535570bc"},"package":"91821c7436aefc1b912552d494232efcaf9810c0189918749532be1e9dbace59"}
{"files":{"Cargo.toml":"224c30422b713d747e048697129f6988d2c97bb71a0b4ddf5e9bd6934a2843e3","LICENSE":"b946744aeda89b467929585fe8eeb5461847695220c1b168fb375d8abd4ea3d0","README.md":"558d046c8c9ad79f23adef1e4b26c28c4599dcba56dadd60e2e7dc3a03ec2806","benches/split.rs":"632a011dfc6d8235dea853785061b7bbfe0362eb85b91b3b01fbf77a7f1c7f26","src/bsp.rs":"964182582d53a160a86809231c61ba6512f38dde14b83c42b8145ef782064d30","src/clip.rs":"16bba7f4bb79b7fb4c8b55403c3d51deb8365c4663314411318d99e98cecbaf4","src/lib.rs":"d2476985e1a28d227cf3b2f11ce3d16dca9a244d29aa7d3ee427439b903235a3","src/polygon.rs":"305af53f5d9334a10481f32ff60729e43e8c497d563c72e926b67dd7b68a261e","tests/clip.rs":"87cd6b0ae58fbcec438eea667eabd3ed6aba89aedb97cbd9bd4c8b4c2046523c","tests/main.rs":"238b0108b4605b8f7c77b2a886c9fb6ccb5ddc2644def166afb4eaedaec3a7c7","tests/split.rs":"f8f0784b9d2f1b3dbc0a0f25fc667ec3aa301b2ae4346f5b7ca0024c535570bc"},"package":"68a117c887fbcd9af8dfc1b8b12ee19ba9dec0b2a91d0a9d2bd9114e459f9c78"}
2 changes: 1 addition & 1 deletion third_party/rust/plane-split/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

[package]
name = "plane-split"
version = "0.14.0"
version = "0.14.1"
authors = ["Dzmitry Malyshau <[email protected]>"]
description = "Plane splitting"
documentation = "https://docs.rs/plane-split"
Expand Down
2 changes: 1 addition & 1 deletion third_party/rust/plane-split/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# plane-split
[![Build Status](https://travis-ci.org/servo/plane-split.svg)](https://travis-ci.org/servo/plane-split)
[![Build Status](https://travis-ci.com/servo/plane-split.svg)](https://travis-ci.com/servo/plane-split)
[![](http://meritbadge.herokuapp.com/plane-split)](https://crates.io/crates/plane-split)
[![Documentation](https://docs.rs/plane-split/badge.svg)](https://docs.rs/plane-split)

Expand Down
35 changes: 22 additions & 13 deletions third_party/rust/plane-split/src/clip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use euclid::{Trig, Rect, Scale, Transform3D, Vector3D};
use euclid::approxeq::ApproxEq;
use num_traits::{Float, One, Zero};

use std::{fmt, mem, ops};
use std::{fmt, iter, mem, ops};


/// A helper object to clip polygons by a number of planes.
Expand Down Expand Up @@ -104,18 +104,27 @@ impl<
mem::swap(&mut self.results, &mut self.temp);

for mut poly in self.temp.drain(..) {
if let Intersection::Inside(line) = poly.intersect_plane(clip) {
let (res1, res2) = poly.split_with_normal(&line, &clip.normal);
self.results.extend(
res1
.into_iter()
.chain(res2)
.filter(|p| clip.signed_distance_sum_to(p) > T::zero())
);
}
// Note: if the intersection has happened, the `poly` will now
// contain the remainder of the original polygon.
if clip.signed_distance_sum_to(&poly) > T::zero() {
let dist = match poly.intersect_plane(clip) {
Intersection::Inside(line) => {
let (res1, res2) = poly.split_with_normal(&line, &clip.normal);
self.results.extend(
iter::once(poly)
.chain(res1)
.chain(res2)
.filter(|p| clip.signed_distance_sum_to(p) > T::zero())
);
continue
}
Intersection::Coplanar => {
let ndot = poly.plane.normal.dot(clip.normal);
clip.offset - ndot * poly.plane.offset
}
Intersection::Outside => {
clip.signed_distance_sum_to(&poly)
}
};

if dist > T::zero() {
self.results.push(poly);
}
}
Expand Down
7 changes: 3 additions & 4 deletions third_party/rust/plane-split/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,12 @@ impl<
// v = (d2*w - d1) / (1 - w*w) * n1 - (d2 - d1*w) / (1 - w*w) * n2
let w = self.normal.dot(other.normal);
let divisor = T::one() - w * w;
if divisor < T::approx_epsilon() {
if divisor < T::approx_epsilon() * T::approx_epsilon() {
return None
}
let factor = T::one() / divisor;
let origin = Point3D::origin() +
self.normal * ((other.offset * w - self.offset) * factor) -
other.normal* ((other.offset - self.offset * w) * factor);
self.normal * ((other.offset * w - self.offset) / divisor) -
other.normal* ((other.offset - self.offset * w) / divisor);

let cross_dir = self.normal.cross(other.normal);
// note: the cross product isn't too close to zero
Expand Down
20 changes: 20 additions & 0 deletions third_party/rust/plane-split/tests/clip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,23 @@ fn clip_badly_transformed() {
let results = clipper.clip_transformed(polygon, &tx, None);
assert!(results.is_err());
}

#[test]
fn clip_near_coplanar() {
let tx = Transform3D::<f32, (), ()>::row_major(
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
-960.0, -625.0, 1.0, -1.0,
100.0, -2852.0, 0.0, 1.0,
);
let mut clipper = Clipper::new();
let polygon = Polygon::from_rect(rect(0.0, 0.0, 1703.0, 4020.0), 0);

let bounds1 = rect(0.0, -430.0, 2048.0, 2048.0);
let results1 = clipper.clip_transformed(polygon.clone(), &tx, Some(bounds1));
assert_ne!(0, results1.unwrap().count());

let bounds2 = rect(0.0, 0.0, 816.0, 1039.0);
let results2 = clipper.clip_transformed(polygon, &tx, Some(bounds2));
assert_ne!(0, results2.unwrap().count());
}

0 comments on commit eb0617b

Please sign in to comment.