Skip to content

Commit

Permalink
Merge pull request #5337 from AnalyticalGraphicsInc/pick-depth-fail
Browse files Browse the repository at this point in the history
Fix depth fail picking.
  • Loading branch information
Hannah authored May 17, 2017
2 parents b97cdc5 + 6ba47b7 commit d63ec2a
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 3 deletions.
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

0 comments on commit d63ec2a

Please sign in to comment.