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 Planes- Terrain & optimizations, and/or option, plane primitives, edge highlighting #5996

Merged
merged 42 commits into from
Dec 4, 2017

Conversation

ggetz
Copy link
Contributor

@ggetz ggetz commented Nov 21, 2017

  • Added ClippingPlanesCollection to encompass clipping plane options
  • Added inclusive flag to clipping planes, which allows you to and/or the clipping across the planes specified
  • Added edgeWidth and edgeColor options to style the edges
  • Added terrainClippingPlanes option to Globe
  • Optimized the tile visibility function when clipping planes are applied to the globe
  • Added planePrimitive for visualizations.

@cesium-concierge
Copy link

Signed CLA is on file.

@ggetz, thanks for the pull request! Maintainers, we have a signed CLA from @ggetz, so you can review this at any time.


I am a bot who helps you make Cesium awesome! Contributions to my configuration are welcome.

🌍 🌎 🌏

@ggetz
Copy link
Contributor Author

ggetz commented Nov 21, 2017

@lilleyse This is all the rest of the features we had in scope for clipping planes. I have one item left to do that is only relevant to the sandcastle examples.

TODO:

  • Fix point cloud clipping example
  • Update both clipping sandcastle example thumbnails

@pjcozzi
Copy link
Contributor

pjcozzi commented Nov 22, 2017

Please bump when the TODOs are addressed.

@pjcozzi pjcozzi requested review from pjcozzi and lilleyse November 22, 2017 02:17
@pjcozzi
Copy link
Contributor

pjcozzi commented Nov 22, 2017

Also, please merge in master.

@ggetz
Copy link
Contributor Author

ggetz commented Nov 22, 2017

@pjcozzi @lilleyse TODO's are updated.

@pjcozzi
Copy link
Contributor

pjcozzi commented Nov 24, 2017

CI is failing:

/home/travis/build/AnalyticalGraphicsInc/cesium/Source/DataSources/PlaneGeometryUpdater.js
  371:13  error  'options' is assigned a value but never used  no-unused-vars
/home/travis/build/AnalyticalGraphicsInc/cesium/Source/Scene/Cesium3DTile.js
  745:14  error  'checkTileClipped' is defined but never used  no-unused-vars
/home/travis/build/AnalyticalGraphicsInc/cesium/Source/Scene/ClippingPlanesCollection.js
  40:13  error  'options' is already defined  no-redeclare
/home/travis/build/AnalyticalGraphicsInc/cesium/Source/Scene/GlobeSurfaceTileProvider.js
  1046:9   error  'scratchPlane' is assigned a value but never used   no-unused-vars
  1047:9   error  'scratchMatrix' is assigned a value but never used  no-unused-vars
  1318:25  error  'clippingPlanes' used outside of binding context    block-scoped-var
  1318:44  error  'clippingPlanes' used outside of binding context    block-scoped-var
  1319:17  error  'clippingPlanes' used outside of binding context    block-scoped-var
  1320:64  error  'clippingPlanes' used outside of binding context    block-scoped-var
  1321:85  error  'clippingPlanes' used outside of binding context    block-scoped-var
  1322:64  error  'clippingPlanes' used outside of binding context    block-scoped-var
  1325:49  error  'clippingPlanes' used outside of binding context    block-scoped-var
  1325:68  error  'clippingPlanes' used outside of binding context    block-scoped-var

https://travis-ci.org/AnalyticalGraphicsInc/cesium/builds/305997777?utm_source=github_status&utm_medium=notification

@pjcozzi
Copy link
Contributor

pjcozzi commented Nov 24, 2017

Part of #5765.

@ggetz can you please update the tasklist in #5765 (comment)

@lilleyse
Copy link
Contributor

lilleyse commented Dec 1, 2017

My recent comment was buried - just a reminder to address #5996 (comment)

@@ -2807,4 +2813,55 @@ defineSuite([
});
});

it('clipping planes cull hidden tiles', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of / or in addition to these tests, can you add tests like:

  • Calls update and checks that n draw commands are returned, sets a clipping plane, and checks that m draw calls are returned under different cases, e.g., when all draw commands are culled, no draw commands are culled, when a subset are culled in an HLOD fashion
  • Include i3dm in a tileset
  • Renders, checks that a pixel was colored, sets a clip plane to clip everything, renders, then checks that nothing was rendered
  • Multiple planes with and without combine

Similiar comment for terrain.

Also, looks like explicit tests are missing for Model?

The tests in PointCloud3DTileContentSpec.js look pretty solid - why not apply the pattern throughout? Don't worry about the duplication or encapsulate it.

Finally, please check code coverage for the new files and make it as high as reasonable.

@pjcozzi
Copy link
Contributor

pjcozzi commented Dec 1, 2017

Given the work that this needs, let's target 1.40. No need to rush for 1.39 even if it gets merged soon after the release.

CC @tfili

Copy link
Contributor

@lilleyse lilleyse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The globe and point clouds tests look good! @pjcozzi already addressed everything else.

Intersect,
Matrix4,
Plane) {
'use strict';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix indentation.

});

it('transform throws without a plane', function() {
var point = Cartesian3.ZERO;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a Matrix4.

}).toThrowDeveloperError();
});

it('transform throws without a point', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

point -> transform.

createDynamicGeometryBoundingSphereSpecs,
createDynamicProperty,
createScene) {
'use strict';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix indentation.

visibility = tileset._root.visibility(scene.frameState, CullingVolume.MASK_INSIDE);

expect(visibility).not.toBe(CullingVolume.MASK_OUTSIDE);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test should be tweaked to call tileset.update and check the number of draw commands, similar to some of the other tests. It should expect 5 commands before the clipping plane is enabled and 1 command after. Checking the visibility directly is a bit too low level.

Realized later this is basically a duplicate of @pjcozzi's comment.

Intersect,
Matrix4,
Plane) {
'use strict';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix indentation.


var result = clippingPlanes.transformAndPackPlanes(transform);
expect(result.length).toEqual(2);
expect(result[0] instanceof Cartesian4).toBe(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use toBeInstanceOf

});
});

it('computes tile visibility culls tiles when clipped', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wording is awkward.

@ggetz
Copy link
Contributor Author

ggetz commented Dec 1, 2017

@lilleyse Spec updates are in, and addressed the plane normals and point cloud issue.

@ggetz
Copy link
Contributor Author

ggetz commented Dec 1, 2017

I assume it would be best to merge in master and update CHANGES.md finally when merging clip-planes-master into master?

}
for (var i = 0; i < length; ++i) {
var plane = this.planes[i];
result.planes[i] = new Plane(plane.normal, plane.distance);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also try to avoid the new here. Above when the new array is created it could initialize with new planes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok if I point this at the same plane object? The planes aren't manipulated down at the model level after the collection is cloned, just the enabling and modelMatrix. Or better yet just point it at the same array?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably better not to use the same plane object or array since callers would expect a deep clone (even though the code right now doesn't care).

@lilleyse
Copy link
Contributor

lilleyse commented Dec 1, 2017

I tried running the Sandcastle demo with an i3dm tileset but it seems to always clip. This may just be a matter of hooking up clipping planes in Instanced3DModel3DTileContent and ModelInstanceCollection.

@ggetz
Copy link
Contributor Author

ggetz commented Dec 1, 2017

Sorry, I didn't know I also had to hook up that class. It looks like the content is a collection of models, so that's what I should clip, correct?

@lilleyse
Copy link
Contributor

lilleyse commented Dec 1, 2017

Sorry, I didn't know I also had to hook up that class. It looks like the content is a collection of models, so that's what I should clip, correct?

Yeah it should be easy I think, the clipping planes just need to get to the underlying model that the model instance collection creates.

@lilleyse
Copy link
Contributor

lilleyse commented Dec 1, 2017

Also - don't worry about clipping individual instances (i.e. changing the draw command's instance count).

@ggetz
Copy link
Contributor Author

ggetz commented Dec 1, 2017

@lilleyse Added i3dm and tests, and it works with the composite tilset.

var plane = this.planes[i];
result.planes[i] = new Plane(plane.normal, plane.distance);
var resultPlane = result.planes[i];
resultPlane.normal = plane.normal;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Cartesian3.clone here, with resultPlane.normal as the result.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind I see that this is already in.

var scratchPlane = new Cesium.Plane(Cesium.Cartesian3.UNIT_X, 0.0);
function createPlaneUpdateFunction(plane, transform) {
return function () {
plane.distance = Cesium.Math.lerp(plane.distance, targetY, 0.1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think lerping here makes sense. Doing it this way never converges, so the value of plane.distance changes slightly every frame

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove it. It is there to make the plane movement smooth since reflecting the mouse movement directly can be shaky.

@lilleyse
Copy link
Contributor

lilleyse commented Dec 4, 2017

Thanks @ggetz all looks good from my end.

@ggetz
Copy link
Contributor Author

ggetz commented Dec 4, 2017

Thanks @lilleyse, @hpinkos ! Updated.

@lilleyse
Copy link
Contributor

lilleyse commented Dec 4, 2017

I assume it would be best to merge in master and update CHANGES.md finally when merging clip-planes-master into master?

Sounds good. Feel free to open that PR now. I might do one quick glance over everything but it should be quick to merge.

@lilleyse lilleyse merged commit 66d6e05 into CesiumGS:clip-planes-master Dec 4, 2017
This was referenced Dec 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants