Fix shape groups in tweens

This commit is contained in:
2017-05-09 00:26:22 +07:00
parent faff1d4c6e
commit 55d7df349e
8 changed files with 79 additions and 8 deletions

View File

@@ -1,7 +1,7 @@
fileFormatVersion: 2
guid: 1d1e25227793d42be83f2d255a773ef6
guid: 31fd11df111b54e3dbf8f0b135da45d9
folderAsset: yes
timeCreated: 1488879578
timeCreated: 1494224348
licenseType: Free
DefaultImporter:
userData:

Binary file not shown.

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 667a3cd1a987d40d5a4c9b6495da5480
timeCreated: 1494255165
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3540b3774e01146108280109128381e8
timeCreated: 1494224354
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,3 +1,6 @@
###### Version 1.3.8
* Fix shape groups in tweens
###### Version 1.3.7
* Fix multiple import
* Fix single frame optimization

View File

@@ -226,6 +226,7 @@
ft.profile_function(function() { ftdoc.remove_unused_items(doc); }, "Remove unused items");
ft.profile_function(function() { ftdoc.prepare_all_bitmaps(doc); }, "Prepare all bitmaps");
ft.profile_function(function() { ftdoc.unlock_all_timelines(doc); }, "Unlock all timelines");
ft.profile_function(function() { ftdoc.prepare_all_groups(doc); }, "Prepare all groups");
ft.profile_function(function() { ftdoc.calculate_item_scales(doc); }, "Calculate item scales");
ft.profile_function(function() { ftdoc.optimize_all_timelines(doc); }, "Optimize all timelines");
ft.profile_function(function() { ftdoc.rasterize_all_shapes(doc); }, "Rasterize all shapes");
@@ -328,6 +329,12 @@
fttim.unlock(doc.getTimeline());
};
ftdoc.prepare_all_groups = function (doc) {
ft.type_assert(doc, Document);
ftlib.prepare_all_groups(doc, doc.library);
fttim.prepare_all_groups(doc, doc.getTimeline());
};
ftdoc.calculate_item_scales = function (doc) {
ft.type_assert(doc, Document);
@@ -590,6 +597,14 @@
});
};
ftlib.prepare_all_groups = function (doc, library) {
ft.type_assert(doc, Document);
ft.type_assert(library, Library);
ftlib.edit_all_symbol_items(doc, library, function (item) {
fttim.prepare_all_groups(doc, item.timeline);
});
};
ftlib.prepare_all_bitmaps = function (library) {
ft.type_assert(library, Library);
ft.array_foreach(library.items, function (item) {
@@ -607,6 +622,10 @@
return elem.elementType == "shape";
};
fttim.is_shape_group_instance = function (elem) {
return elem.elementType == "shape" && elem.isGroup;
};
fttim.is_symbol_instance = function (elem) {
return elem.elementType == "instance" && elem.instanceType == "symbol";
};
@@ -623,7 +642,7 @@
return fttim.is_symbol_instance(elem) && elem.symbolType == "movie clip";
};
fttim.is_shape_frame = function (frame) {
fttim.is_tween_shape_frame = function (frame) {
ft.type_assert(frame, Frame);
return frame.tweenType == "shape";
};
@@ -776,6 +795,34 @@
}, true);
};
fttim.prepare_all_groups = function (doc, timeline) {
ft.type_assert(doc, Document);
ft.type_assert(timeline, Timeline);
var group_count = 0;
ft.array_reverse_foreach(timeline.layers, function (layer, layer_index) {
timeline.setSelectedLayers(layer_index);
ft.array_foreach(layer.frames, function (frame, frame_index) {
timeline.currentFrame = frame_index;
timeline.setSelectedFrames(frame_index, frame_index + 1, true);
ft.array_foreach(frame.elements, function (elem) {
doc.selectNone();
doc.selection = [elem];
var elem_depth = elem.depth;
var wrapper_item_name = ft.gen_unique_name();
var wrapper_item = doc.convertToSymbol("graphic", wrapper_item_name , "top left");
for (var i = 0; i < elem_depth; ++i) {
doc.arrange("backward");
}
++group_count;
}, fttim.is_shape_group_instance);
}, fttim.is_keyframe);
}, fttim.is_not_guide_layer);
if (group_count > 0 && ft.verbose_mode) {
ft.trace_fmt("Prepare shape groups({0}) in '{1}'", group_count, timeline.name);
}
};
fttim.rasterize_all_shapes = function (doc, timeline) {
ft.type_assert(doc, Document);
ft.type_assert(timeline, Timeline);
@@ -789,11 +836,11 @@
throw "Animation uses shape tweens. To export this animation you should use Adobe Animate CC or higher!";
}
}, function (frame, frame_index) {
return fttim.is_keyframe(frame, frame_index) && fttim.is_shape_frame(frame);
return fttim.is_keyframe(frame, frame_index) && fttim.is_tween_shape_frame(frame);
});
}, fttim.is_not_guide_layer);
var any_rasterize = false;
var rasterize_count = 0;
ft.array_reverse_foreach(timeline.layers, function (layer, layer_index) {
timeline.setSelectedLayers(layer_index);
ft.array_foreach(layer.frames, function (frame, frame_index) {
@@ -804,12 +851,12 @@
if (doc.selection.length > 0) {
ftdoc.convert_selection_to_bitmap(doc, timeline.libraryItem);
doc.arrange("back");
any_rasterize = true;
++rasterize_count;
}
}, fttim.is_keyframe);
}, fttim.is_not_guide_layer);
if (any_rasterize && ft.verbose_mode) {
ft.trace_fmt("Rasterize vector shapes in '{0}'", timeline.name);
if (rasterize_count > 0 && ft.verbose_mode) {
ft.trace_fmt("Rasterize vector shapes({0}) in '{1}'", rasterize_count, timeline.name);
}
};

View File

@@ -53,13 +53,18 @@ https://gist.github.com/talecrafter/111ea3345911bd238f4998b4d5a04bf3
*** Улучшения
**** TODO Ворнинг на shape-tween
**** TODO Интеграция с автобилдами
**** TODO Избавиться от условия на _ExternalAlpha
**** TODO Добавить возможность брать bounds у клипа
**** TODO Возможно не стоит преобразовывать группы в символы
**** TODO В ошибках конвертации писать, что нужно прогнать через скрипт экспорта
А еще лучше как-то метить прогнанную анимацию и нет
*** Баги
**** TODO При больших (>= 4000 пикселей) выделениях не работает convertSelectionToBitmap
**** TODO Не работает конвертация в batchmod'е
**** TODO В ошибках конвертации не пишется путь до swf
**** DONE Не растеризуются группы в твинах
**** TODO Unity может переставлять сабмеши на одинаковой глубине (проблема с масками)
**** TODO При автоплее с пустым клипом контроллер накапливает _tickTimer
**** TODO Возможно проблемы с DX9
UNITY_UV_STARTS_AT_TOP
UNITY_HALF_TEXEL_OFFSET