CMO Movement Top Left Corner based

Bug #966750 reported by Russ Adams
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Asgard
Fix Committed
Undecided
Sean Eubanks

Bug Description

If you click on the screen and leave your mouse in place, you'll see the CMO will travel to that spot. You'll notice that when she arrives, her top left corner will be underneath the mouse cursor. All math surrounding CMO movement should be around the center of the CMO.

Map Panning will face similar issues... the root cause for this and lp:966741 are the same.

Related branches

Revision history for this message
Russ Adams (rustushki) wrote :

The solution here is that we need to move MapObjects based on the center of the MapObject, not on its Top Left Corner.

Related (lp:966741) is that Map Pan events need to alter their checks as follows:

  1. if the bottom of the MapObject has passed the bottom margin of the screen, fire a map pan event.
  2. if the top of the MapObject has passed the top margin of the screen, fire a map pan event.
  3. if the right of the MapObject has passed the right margin of the screen, fire a map pan event.
  4. if the left of the MapObject has passed the left margin of the screen, fire a map pan event.

Right now each of these checks is against only the Top Left Corner of the Map Object.

It should be easy enough to write MapObject::getBottom(), getTop(), getLeft(), getRight(), and getCenter() since MapObjects have height and a width members. The problem is that MapObject height and width are tightly coupled to Drawable height and width. My Big Question is this:

Can we drop MapObject::height and MapObject::width, and instead have MapObject::getHeight() and MapObject::getWidth() return the respective height and width of the MapObject's current Drawable? Can you think of any problem with that approach?

That would allow us to get rid of the height and width fields in the MapObject table. We could then easily write MapObject::getBottom(), getTop(), getLeft(), getRight(), and getCenter() based on the Drawable's height and width and the current Top Left Corner of the MapObject.

Those accessors could then be used to solve both this case and lp:966741.

Revision history for this message
Russ Adams (rustushki) wrote :

kkaos says that we should use the 'feet' instead of the center. Here's my reply:

"""
You're right about the lack of functionality using MapObject::height and width. In fact, height and width are entirely incorrect values in the populate database sql script. Let's agree that getHeight() and getWidth() use the MapObject's current Drawable's height and width instead.

I like the 'feet' idea. Instead of getCenter() let's call it "Coordinate getFoot()". The "foot" is always the bottom/center of the MapObject. The Coordinate returned by getFoot() is a World Coordinate. We can compute this special coordinate in getFoot() like this:

    foot = (drawable.width/2 + mapobject.topleftcorner.x, drawable.height + mapobject.topleftcorner.y)

I'll get these changes done ASAP so that you can change movement to be foot-based, and so that I can change Map Pan events to fire based on edges of the MapObject rather than the top left corner.

Revision history for this message
Russ Adams (rustushki) wrote :

Partly there. Check r217:

"""
Removing MapObject::height and width from the whole stack. Adding stubs for MapObject::getHeight() and getWidth() which will always return the height and width of the current Drawable for the MapObject.
"""

Will implement getHeight and getWidth() soon.

Russ Adams (rustushki)
Changed in asgard:
status: New → Confirmed
Russ Adams (rustushki)
Changed in asgard:
status: Confirmed → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.