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

Support for different types of bounding volumes for 3D tiles #3325

Merged
merged 47 commits into from
Jan 14, 2016

Conversation

e-andersson
Copy link
Contributor

Bounding volume is now specified as boundingVolume.box or boundingVolume.sphere where it was previously only box. boundingVolume.box is the same as the old box for now.

PR for issue Different bounding volumes.

Somewhat rudimentary tests are included, feedback welcome.

this._debugBox = undefined;
this._debugcontentBox = undefined;
this._debugOrientedBoundingBox = undefined;
this._debugContentsOrientedBoundingBox = undefined;
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 kept only one debug volume for the tile and one debug volume for the tile contents. Not sure whether there is any need to keep them separated.

Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like the right approach to me. We will have to modify Cities.html to remove some of the extra buttons, but that can be a later commit.

@pjcozzi
Copy link
Contributor

pjcozzi commented Dec 10, 2015

@lilleyse can you do the initial review?

@e-andersson we'll want to use box for an AABB. What is a good name for the current box? region?

@e-andersson
Copy link
Contributor Author

@pjcozzi Could we call it something along the lines of curved_box or perhaps WGS84_box (unless other coordinates may be used)? A little bit more verbose than region but possible clearer?

@pjcozzi
Copy link
Contributor

pjcozzi commented Dec 10, 2015

A lot of KML use cases will be served by served by 3D Tiles. In particular, KML regions, which call this LatLonAltBox. So "region" will be familiar to many users (I would not use LatLonAltBox, by Cesium conventions, it would be longitudeLatitudeHeightBox).

By the way, we use camel case for property names so curved_box would be curvedBox. There is an (incomplete) Spec Writing Guide here: CesiumGS/3d-tiles#26

@lilleyse is there a more precise graphics term for this that we are over looking?

@lilleyse
Copy link
Contributor

I'm not sure what the proper term is. Maybe tileBox if that isn't too general.

BoundingSphere.distanceToCamera = function(sphere, frameState) {
return Math.max(0.0, Cartesian3.distance(sphere.center, frameState.camera.positionWC) - sphere.radius);
};

Copy link
Contributor

Choose a reason for hiding this comment

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

Add a comment above this function, but add @private at the end for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Throw DeveloperError if sphere or frameState is not defined, similar to what the other functions do.

@e-andersson
Copy link
Contributor Author

@lilleyse box and tileBox may be a bit too similar, it's probably easier to see the difference between box and region (at least if one is familiar with regions from KML).

0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 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.

Cleaner to do var modelMatrix = Matrix4.clone(Matrix4.IDENTITY);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks -- I stumbled on the immutability of Matrix4.IDENTITY, didn't figure out I should clone it :)

@lilleyse
Copy link
Contributor

Those are all my comments. I did a quick test and it works fine. When everything here is final, I'll update the test data sets to reflect the new tiles.json changes, as well as add some sphere and AABB tests (once we include AABB support).

When we pick a name for region, we may want to change the name of TileBoundingBox as well.

@e-andersson
Copy link
Contributor Author

Thanks @lilleyse. I'll update the code in line with the comments tomorrow morning.

@lilleyse
Copy link
Contributor

I added a boundingVolume getter to replace orientedBoundingBox. The getter will have to change once we add new box types.

@e-andersson
Copy link
Contributor Author

@lilleyse Would you mind having a look at why the Instanced3DTileContentProvider and Composite3DTileContentProvider resolve tests don't pass (timeout)? The sample data looks fine and there isn't any problem instantiating the bounding volumes, so I'm not sure where the problem is. Do you have an idea?

@lilleyse
Copy link
Contributor

It looks like the tests are failing because ModelInstanceCollection expects the bounding volume to have a center property in order to do relative to center rendering. So a quick fix would be to to add a center getter in TileBoundingRegion, or the boundingVolume getter could return this._orientedBoundingBox instead.

@e-andersson
Copy link
Contributor Author

@lilleyse Thanks, that indeed seems to be it.

@e-andersson
Copy link
Contributor Author

I added a temporary solution for creating an oriented bounding box from points representing the corners when creating a TileBoundingRegion. We'll probably not want when there is a OrientedBoundingBox.fromCorners method, but until then it's nice to have a real box.

@e-andersson
Copy link
Contributor Author

@pjcozzi I think this is ready. EDIT: Updating a few tests... done!

@pjcozzi
Copy link
Contributor

pjcozzi commented Dec 22, 2015

@e-andersson can you merge the 3d-tiles branch into this? Looks like there are some minor conflicts from @lilleyse's test branch that we merged today.

*
* @private
*/
this._orientedBoundingBox = OrientedBoundingBox.fromPoints(getBoxPoints(this.rectangle, this.minimumHeight, this.maximumHeight));
Copy link
Contributor

Choose a reason for hiding this comment

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

@pjcozzi
Copy link
Contributor

pjcozzi commented Dec 22, 2015

@e-andersson can you merge the 3d-tiles branch into this? Looks like there are some minor conflicts from @lilleyse's test branch that we merged today.

Also, when you merge in master, please change the new tiles.json files for the tests in Specs/Data/Cesium3DTiles so they follow the latest schema for bounding volumes

@pjcozzi
Copy link
Contributor

pjcozzi commented Dec 22, 2015

Just those comments. Once the 3d-tiles branch is merged in, I'll test this locally, and then we should be good to merge.

@e-andersson
Copy link
Contributor Author

Merged in 3d-tiles into this branch. Note that I seem to have introduced two test failures, possibly due to the _orientedBoundingBox in TileBoundingRegion being incorrectly created using OrientedBoundingBox.fromPoints. It seems this is also manifested as error-prone culling/tile selection in the viewer.
@pjcozzi and @lilleyse, does the above seem correct? If so, it will be fixed by introduction of a way to create oriented bounding boxes as discussed in #3325 (comment), right?

@lilleyse
Copy link
Contributor

Maybe you can try OrientedBoundingBox.fromRectangle from this comment #3325 (comment)

@e-andersson
Copy link
Contributor Author

Thanks for the pointer @lilleyse, I seem to have missed that comment. Works fine now.

This is ready now @pjcozzi.

EDIT: Currently there are no destroy functions for the the bounding volumes of a Cesium3DTile -- there doesn't seem to be much we could destroy, no GL resources held by the bounding volumes which if I've understood it correctly would be a reason to explicitly destroy objects. (I put a TODO note in Cesium3DTile about this.)

this._debugcontentBox = this._debugcontentBox && this._debugcontentBox.destroy();
this._debugOrientedBoundingBox = this._debugOrientedBoundingBox && this._debugOrientedBoundingBox.destroy();
this._debugContentsOrientedBoundingBox = this._debugContentsOrientedBoundingBox && this._debugContentsOrientedBoundingBox.destroy();
// TODO: Is there a reason to destroy the bounding volumes (and thus to implement destroy() functions for them)? The destroyObject function description says it should be used to for objects that have GL resources.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is only needed for the debug volumes since they contain Cesium primitives, which contain GL resources.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, got it. (Sean has fixed it.)

@pjcozzi
Copy link
Contributor

pjcozzi commented Jan 14, 2016

Thanks again @e-andersson! I'm going to merge this since we have some changes we want to make that depend on this. Can you please open a separate PR into the 3d-tiles branch to address these two minor comments: #3325 (diff) and #3325 (diff)

pjcozzi added a commit that referenced this pull request Jan 14, 2016
Support for different types of bounding volumes for 3D tiles
@pjcozzi pjcozzi merged commit 65ca279 into CesiumGS:3d-tiles Jan 14, 2016
@pjcozzi pjcozzi deleted the 3d-tiles_bounding_volumes branch January 14, 2016 15:39
@pjcozzi
Copy link
Contributor

pjcozzi commented Jan 14, 2016

@tfili and anyone else using 3D Tiles - note that next time you update to the latest 3d-tiles branch that this is a small breaking change.

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.

4 participants