Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/tiled/transformmapobjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,26 @@ void TransformMapObjects::redo()

bool TransformMapObjects::mergeWith(const QUndoCommand *other)
{
// Don't merge when the other command affects different properties
auto o = static_cast<const TransformMapObjects*>(other);
if (mChangedProperties != o->mChangedProperties)

auto dominantType = [](MapObject::ChangedProperties p) {
if (p & MapObject::RotationProperty)
return 0;
if (p & (MapObject::SizeProperty | MapObject::ShapeProperty))
return 1;
if (p & MapObject::PositionProperty)
return 2;
return 3;
};

if (dominantType(mChangedProperties) != dominantType(o->mChangedProperties))
return false;

if (!ChangeValue<MapObject, TransformState>::mergeWith(other))
return false;

return ChangeValue<MapObject, TransformState>::mergeWith(other);
mChangedProperties |= o->mChangedProperties;
return true;
}

TransformState TransformMapObjects::getValue(const MapObject *mapObject) const
Expand Down