Opened 12 years ago

Closed 4 years ago

#1109 closed enhancement (fixed)

[PATCH] Atlas Enhancement: Map re-sizing position

Reported by: michael Owned by: Stan
Priority: Must Have Milestone: Alpha 24
Component: Atlas editor Keywords:
Cc: trompetin17 Patch: Phab:D825

Description (last modified by Stan)

In Atlas, I want to be able to choose from where to re-size a map--corners or center.

Attached image may make it clearer.

Attachments (8)

map resize dialog.png (39.3 KB ) - added by michael 12 years ago.
normalDialog.png (730.8 KB ) - added by Stephen Imhoff 8 years ago.
Initial new dialog entry
growDialog.png (658.6 KB ) - added by Stephen Imhoff 8 years ago.
New dialog map growing
shrinkDialog.png (675.9 KB ) - added by Stephen Imhoff 8 years ago.
new dialog map shrinking
recenterDialog.png (664.4 KB ) - added by Stephen Imhoff 8 years ago.
new dialog moving center
1109_Recenter.patch (60.2 KB ) - added by Stephen Imhoff 8 years ago.
Initial patch
1109_Recenter_Undo.patch (65.8 KB ) - added by Stephen Imhoff 8 years ago.
Patch with true undo.
1109_Recenter_Undo.2.patch (72.3 KB ) - added by Stephen Imhoff 7 years ago.

Change History (37)

by michael, 12 years ago

Attachment: map resize dialog.png added

comment:1 by Kieran P, 12 years ago

Milestone: Alpha 9Backlog

comment:2 by leper, 10 years ago

Priority: Nice to HaveMust Have

comment:3 by Stephen Imhoff, 8 years ago

Owner: set to Stephen Imhoff
Status: newassigned

comment:4 by Stephen Imhoff, 8 years ago

Keywords: rfc patch added
Milestone: BacklogAlpha 22
Summary: Atlas Enhancement: Map re-sizing position[PATCH] Atlas Enhancement: Map re-sizing position

by Stephen Imhoff, 8 years ago

Attachment: normalDialog.png added

Initial new dialog entry

by Stephen Imhoff, 8 years ago

Attachment: growDialog.png added

New dialog map growing

by Stephen Imhoff, 8 years ago

Attachment: shrinkDialog.png added

new dialog map shrinking

by Stephen Imhoff, 8 years ago

Attachment: recenterDialog.png added

new dialog moving center

comment:5 by Stephen Imhoff, 8 years ago

Added the ability to recenter the map, based on a mini-map like display (terrain only, though). This was done for one simple reason - under the original target design, there was no way to tell what "corner" was going to be chosen.

Note that the warning about resizing/recentering is very on-target, because it doesn't move any entities. This was previously mostly invisible due to always working from "upper-left", but since a new origin can be chosen the results may not be what is expected.

comment:6 by elexis, 8 years ago

I noticed you use this repository https://github.com/Clockwork-Muse/0ad/commits/mapresize_tone (might make things easier to review)

in reply to:  6 comment:7 by Stephen Imhoff, 8 years ago

Replying to elexis:

I noticed you use this repository https://github.com/Clockwork-Muse/0ad/commits/mapresize_tone (might make things easier to review)

Yeah, but I'm not sure how many people pay attention to the GitHub repository, given it's not the source of truth.

I keep debating about cloning the repository again and attempting a rebase/cleanup (ie, remove all historical instances of built binaries), but at this point I'd wait for the next version of premake, and get the new packaging feature. I'd probably end up with a list of commands to run, rather than a patch, to make it easier to review. That, and a set of instructions for artists since their workflow would most likely change. Probably the in-game assets are small enough Git wouldn't complain, it would just be the built executable they'd need to grab from somewhere else. Especially since I'd probably move most of the current stuff to it's own sub-repository, to make sure that it can be disabled cleanly.

But.... that's a bit offtopic for now.

comment:8 by Stan, 8 years ago

To be honest I think only elexis does. I agree though it does make it easier to review patches of patches as you just have to make a branch. Now AtlasUI2 by trompetin17 was made on github and it's quite dead now.

On topic. Thanks for working on it Can you show us how it looks like ?

comment:9 by Stephen Imhoff, 8 years ago

...I added images under attachments? Were those not enough?

comment:10 by Stan, 8 years ago

Uh sorry yeah that functionnality looks great Did you make sure entities are deleted ? Looks good for commiting.

comment:11 by Stan, 8 years ago

Cc: trompetin17 added
Milestone: Alpha 22Alpha 21

comment:12 by Stephen Imhoff, 8 years ago

(could have sworn I commented on this earlier) No, I just left the existing functionality. So of course if there's anything in the map it gets moved around pretty badly. Looking into deleting, or recentering the units.

Amusingly, in testing, it looks like resizing the map didn't remove entities to begin with. It would blithely save entities off the edge of the map. Or, if they only ended up in the matted-out region, just not display them.

Should I just leave things as-is for now, and deal with entities in a separate patch, since it's already broken anyways?

in reply to:  12 ; comment:13 by Michael D. Hafer, 8 years ago

Clockwork-Muse, this is fantastic work and outstrips my wildest imagination when I created this ticket 5 years ago.

I think the entity deletion is a crucial component of map resizing going forward and it's something that's always bothered me. Can't wait to see this added to Atlas.

Last edited 8 years ago by Michael D. Hafer (previous) (diff)

by Stephen Imhoff, 8 years ago

Attachment: 1109_Recenter.patch added

Initial patch

in reply to:  13 comment:14 by Stephen Imhoff, 8 years ago

Finally managed to spare some time to finish this. Entities are now deleted or moved, as appropriate. Note that, since the terrain data isn't saved for undo (but entities are), undoing may give some bizarre results (instant Atlantis!).

I still haven't updated the window string, since I'm not sure what translation/localization procedures are.

@Mythos_Ruler @elexis @stanislas69 @trompetin17

comment:15 by Stan, 8 years ago

Atlas doesn't have localization yet.

Atlantis effect is bad though I believe it goes far beyond this ticket. So unless that's a trivial fix it should have its own patch.

comment:16 by Stephen Imhoff, 8 years ago

Okay, should I just change the text, or is that something we have people managing in general (when you work for a big company that has people that manage text for consistency...)?

Not sure how trivial a change it would be. Potentially we could just make the action undoable, since the terrain data doesn't come back.

comment:17 by Vladislav Belov, 8 years ago

About 1109_Recenter.patch: as I see, you use std::map<entity_id_t, CFixedVector3D>, but never search there, only store values, so you could use simple std::vector<std::pair<entity_id_t, CFixedVector3D>> instead, perfomance will be better.

Then m_NewPositions.emplace_back(entityId, position + offset) instead of m_NewPositions[entityId] = position + offset.

It's guranteed that entities have different IDs. Or even you have the same IDs there for some reason (really don't know why) you could sort + unique, that still faster than an insertion to a map.

Last edited 8 years ago by Vladislav Belov (previous) (diff)

in reply to:  17 comment:18 by Stephen Imhoff, 8 years ago

Replying to vladislavbelov:

About 1109_Recenter.patch...

Done, But I'm going to avoid updating the patch for now, waiting to see if anybody else has something.

Replying to stanislas69:

Atlas doesn't have localization yet.

Atlantis effect is bad though I believe it goes far beyond this ticket. So unless that's a trivial fix it should have its own patch.

Took a quick look at the Atlantis problem as it effects this. The problem is that, during resize, we discard the old map data. So we have no idea what it was, and figuring out new heights is liable to be problematic (ie, you'd likely end up with civilizations on islands with no resources). Now, it looks possible to save off the data beforehand - we can get access to patches/tiles, and the underlying data. The problem is that we'd have to remove the cleanup from resize (since it deletes the previous set). So extra memory in use. Re-adding patches/tiles doesn't look too terrible, although it does create additional management overhead.

So I see a dichotomy here; mark the command as non-undoable (and update the text to warn) - possibly just for now - , or put in the extra effort to save off the map data too, and take the memory hit (an initial look suggests we might need three complete copies of the data - old, new, and current - instead of being able to toggle between old and new).

comment:19 by elexis, 8 years ago

Milestone: Alpha 21Alpha 22

Feature freeze in 2 days.

by Stephen Imhoff, 8 years ago

Attachment: 1109_Recenter_Undo.patch added

Patch with true undo.

comment:20 by Stephen Imhoff, 8 years ago

Actually, I couldn't find anything about turning undo off (thought I'd seen a flag at one point), so just made it work as true undo instead. Keeps both heightmaps and terrain tile data.

Dynamic data is cleaned up when the command goes off the stack - when a different command replaces it in history, new map is created, program is closed (at least).

comment:21 by Vladislav Belov, 7 years ago

Few notes:

  • &(dst.m_MiniPatches[0][0]) == &dst.m_MiniPatches[0][0], because priority of & is smaller than of ().
  • m_SelectionRadius = double(std::min(m_NewSize, m_CurrentSize)) / std::max(m_NewSize, m_CurrentSize) * PanelRadius; why double?
  • Few no new line warnings.
Last edited 7 years ago by Vladislav Belov (previous) (diff)

comment:22 by elexis, 7 years ago

Milestone: Alpha 22Work In Progress

Moving to the new WIP milestone.

by Stephen Imhoff, 7 years ago

Attachment: 1109_Recenter_Undo.2.patch added

comment:23 by Stephen Imhoff, 7 years ago

@vladislavbelov

  • Hokay
  • Because I needed a ratio, in the range of [0, 1). But I switched it to an integer-only operation.
  • Fixed.

Sorry it took so long for me to notice. I thought notifications happened? Or am I just thinking of something else?

in reply to:  23 comment:24 by Stan, 7 years ago

Description: modified (diff)

Replying to Stephen Imhoff:

@vladislavbelov

  • Hokay
  • Because I needed a ratio, in the range of [0, 1). But I switched it to an integer-only operation.
  • Fixed.

Sorry it took so long for me to notice. I thought notifications happened? Or am I just thinking of something else?

I'm sorry it took us so much time to look at this ticket again. If you get this notification, would you please tell us if you are still interested in working on that patch ? If so, could you please port it to code.wildfiregames.com ? Our review process has changed and so have the tools, so no patch will get commited if they haven't been submitted to Phabricator first.see wiki:SubmittingPatches

comment:26 by Stan, 7 years ago

Thanks for keeping it updated :) and for coming back.

comment:27 by Stan, 7 years ago

Patch: Phab:D825

comment:28 by Stan, 4 years ago

Keywords: rfc patch removed
Milestone: Work In ProgressAlpha 24
Owner: changed from Stephen Imhoff to Stan
Status: assignednew

comment:29 by Vladislav Belov, 4 years ago

Resolution: fixed
Status: newclosed

Fixed in r23859:

Allow map to recenter during resize in Atlas. Fixes #1109.

Patch By: Clockwork-Muse

Tested By: Stan

Differential Revision: https://code.wildfiregames.com/D825

Note: See TracTickets for help on using tickets.