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 cube non rectangle #216

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Justinidlerz
Copy link

Support cube tile non rectangle when in the last row or column position

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@Justinidlerz
Copy link
Author

I signed it!

@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

@Justinidlerz Justinidlerz force-pushed the feature/support-cube-non-rectangle branch from a07dfc0 to dd47e52 Compare January 30, 2019 08:39
@googlebot
Copy link

CLAs look good, thanks!

@@ -138,32 +140,46 @@ CubeTile.prototype.rotY = function() {


CubeTile.prototype.centerX = function() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this can be expressed more succinctly as

var levelWidth = this._level.width();
var tileWidth = this._level.tileWidth();
return (this.x * tileWidth + 0.5 * this.width()) / levelWidth - 0.5;

which is the same logic as in FlatView.

var foreWidth = this._level.tileWidth() * this.x;
var partOfWidth = this.width() / 2;
// Compute tile centerX of face
return (foreWidth + partOfWidth + 0.5) / this._level.width() - 0.5;
};


CubeTile.prototype.centerY = function() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Likewise as above.

@@ -488,47 +499,6 @@ CubeLevel.prototype.tileHeight = function() {
};


CubeLevel.prototype._validateWithParentLevel = function(parentLevel) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We still want to validate that each tile has at most one parent tile in the previous level (i.e., the tile width must be a submultiple of the parent width, and the same for height). Otherwise, CubeTile#parent and CubeTile#children no longer work correctly.

If you're up for it, you can lift this restriction afterwards (but please make it a separate PR, to keep each change small).

* - The number of tiles in a level must be a multiple of the number of tiles
* in the parent level.
* - All tiles must be square, except when in the last row or column position,
* and must form a rectangular grid;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add

- The tile width (respectively, height) for a level must be a submultiple of the tile width (respectively, height) for the parent level.

per the discussion above.

@@ -124,6 +124,8 @@ function CubeTile(face, x, y, z, geometry) {
this.z = z;
this._geometry = geometry;
this._level = geometry.levelList[z];
// Pre compute last tile size, when all is square, it's 0
this._tileResidue = this._level.width() % this._level.tileWidth();
Copy link
Collaborator

Choose a reason for hiding this comment

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

You also need to change the CubeTile#neighbors method. Currently, the logic assumes that an edge tile never meets more than one tile in the other face; this is no longer true with residual tiles.

Consider, for example, the non-residual tile at the top left of the down face. This tile meets two different tiles in the left face: the residual tile at the bottom right of the left face, and the non-residual tile immediately to the left.

A similar situation happens with some of the other corners of the cube. A strategy that might work is to have a lookup table indicating whether a particular corner is "special" or not ("special" meaning that a residual tile meets a non-residual one at that corner). Then add the additional tile to the neighbor set in the cases where the corner is "special".

Copy link
Collaborator

@tjgq tjgq left a comment

Choose a reason for hiding this comment

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

This is a great addition, but I have some concerns that need to be addressed. Please see my review comments.

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.

3 participants