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

Fix depth fail picking. #5337

Merged
merged 2 commits into from
May 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Change Log
* Fix `BoundingSphere.fromOrientedBoundingBox`. [#5334](https://github.com/AnalyticalGraphicsInc/cesium/issues/5334)
* Fixed bug where polylines would not update when `PolylineCollection` model matrix was updated [#5327](https://github.com/AnalyticalGraphicsInc/cesium/pull/5327)
* Fixed translucency bug for certain material types [#5335](https://github.com/AnalyticalGraphicsInc/cesium/pull/5335)
* Fix picking polylines that use a depth fail appearance. [#5337](https://github.com/AnalyticalGraphicsInc/cesium/pull/5337)

### 1.33 - 2017-05-01

Expand Down
9 changes: 6 additions & 3 deletions Source/Scene/Primitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -1369,18 +1369,21 @@ define([
primitive._backFaceRS = primitive._frontFaceRS;
}

rs = clone(renderState, false);
if (defined(primitive._depthFailAppearance)) {
rs.depthTest.enabled = false;
}

if (primitive.allowPicking) {
if (twoPasses) {
rs = clone(renderState, false);
rs.cull = {
enabled : false
};
primitive._pickRS = RenderState.fromCache(rs);
} else {
primitive._pickRS = primitive._frontFaceRS;
primitive._pickRS = RenderState.fromCache(rs);
}
} else {
rs = clone(renderState, false);
rs.colorMask = {
red : false,
green : false,
Expand Down
57 changes: 57 additions & 0 deletions Specs/Scene/PrimitiveSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,63 @@ defineSuite([
expect(scene).toRender([255, 0, 255, 255]);
});

it('pick with depth fail appearance', function() {
var rect = Rectangle.fromDegrees(-1.0, -1.0, 1.0, 1.0);
var translation = Cartesian3.multiplyByScalar(Cartesian3.normalize(ellipsoid.cartographicToCartesian(Rectangle.center(rect)), new Cartesian3()), 100.0, new Cartesian3());
var rectInstance = new GeometryInstance({
geometry : new RectangleGeometry({
vertexFormat : PerInstanceColorAppearance.VERTEX_FORMAT,
ellipsoid : ellipsoid,
rectangle : rect
}),
modelMatrix : Matrix4.fromTranslation(translation, new Matrix4()),
id : 'rect',
attributes : {
color : new ColorGeometryInstanceAttribute(1.0, 1.0, 0.0, 1.0)
}
});
var p0 = new Primitive({
geometryInstances : rectInstance,
appearance : new PerInstanceColorAppearance({
translucent : false
}),
asynchronous : false
});

var rectInstance2 = new GeometryInstance({
geometry : new RectangleGeometry({
vertexFormat : PerInstanceColorAppearance.VERTEX_FORMAT,
ellipsoid : ellipsoid,
rectangle : rect
}),
id : 'rect2',
attributes : {
color : new ColorGeometryInstanceAttribute(1.0, 0.0, 0.0, 1.0),
depthFailColor : new ColorGeometryInstanceAttribute(1.0, 0.0, 1.0, 1.0)
}
});
var p1 = new Primitive({
geometryInstances : rectInstance2,
appearance : new PerInstanceColorAppearance({
translucent : false
}),
depthFailAppearance : new PerInstanceColorAppearance({
translucent : false
}),
asynchronous : false
});

scene.primitives.add(p0);
scene.primitives.add(p1);
scene.camera.setView({ destination : rect });
scene.renderForSpecs();

expect(scene).toPickAndCall(function(result) {
expect(result.primitive).toEqual(p1);
expect(result.id).toEqual('rect2');
});
});

it('RTC throws with more than one instance', function() {
expect(function() {
return new Primitive({
Expand Down