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

Added BoundsOverlay Rendermode Primitive #1336

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

Conversation

jpchip
Copy link

@jpchip jpchip commented Oct 23, 2016

As a response to #1332 and designed to Display land ownership on map.bitquest.co, I created a new RenderMode Primitive called BoundsOverlay. This rendermode overlays colors on the map within sets of bounding boxes, specified as multiple tuples of the form (minx, minz, maxx, maxz). So by specifying (0, 0, 16, 16) all the blocks (inclusive) within the boundary created by these coordinates will be colored. The color is specified as (r, g, b, a).

An example usage in the config.py would be:

renders["boundsoverlay"] = {
        'world': 'woot',
        'title': 'Land Ownership',
        'rendermode': [ClearBase(), BoundsOverlay(bounds=[
                        (((0, 0, 16, 16), (-70, -30, -54, -14)), (255, 160, 122, 127)),
                        (((100, 100, 116, 116),(17, 0, 33, 16)), (75, 0, 130, 127)),
                       ])],
        'overlay': ['day']
}

with a result like:

screenshot 2016-10-20 21 26 19

I also updated the docs with example usage.

Copy link

@gluth gluth left a comment

Choose a reason for hiding this comment

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

Overall: there is nothing critical here, but few changes need to be applied to increase code readability and overall code quality.

**/
// iterate over all the colors
for ( col = 0; col < self->numcolors; col++) {
any = false;
Copy link

Choose a reason for hiding this comment

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

Code format need more care here and over the whole PR.

/**
* Check if a sane option was passed.
**/
if (opt && opt != Py_None) {
Copy link

Choose a reason for hiding this comment

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

This if is taking whole function with exception for one command at the end. I would invert it and close function fast. By example:

if (!opt || opt == Py_None) {
  self->parent.get_color = get_color;
  return 0;
}

There is one line which will be repeated, but overall this will increase code readability with limited number of levels.

/**
* Try to parse the definitions of conditions and colors.
**/
if (cont) {
Copy link

Choose a reason for hiding this comment

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

Similar situation here, if not cond set parent color and return 0. There is no need to wait with this till the function end.

}
}

if (self->bounds) {
Copy link

Choose a reason for hiding this comment

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

The same condition in two ifs side by side, join them into one if or fail fast if there is no self->bounds.

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.

None yet

3 participants