MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / _parseZOrderFrame

Method _parseZOrderFrame

Source/3rdParty/dragonBones/parser/JSONDataParser.cpp:1308–1376  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1306}
1307
1308unsigned JSONDataParser::_parseZOrderFrame(const rapidjson::Value& rawData, unsigned frameStart, unsigned frameCount)
1309{
1310 const auto frameOffset = _parseFrame(rawData, frameStart, frameCount);
1311
1312 if (rawData.HasMember(Z_ORDER))
1313 {
1314 const auto& rawZOrder = rawData[Z_ORDER];
1315 if (!rawZOrder.Empty())
1316 {
1317 const auto slotCount = _armature->sortedSlots.size();
1318 std::vector<int> unchanged;
1319 std::vector<int> zOrders;
1320 unchanged.resize(slotCount - rawZOrder.Size() / 2);
1321 zOrders.resize(slotCount);
1322
1323 for (std::size_t i = 0; i < unchanged.size(); ++i)
1324 {
1325 unchanged[i] = 0;
1326 }
1327
1328 for (std::size_t i = 0; i < slotCount; ++i)
1329 {
1330 zOrders[i] = -1;
1331 }
1332
1333 unsigned originalIndex = 0;
1334 unsigned unchangedIndex = 0;
1335 for (std::size_t i = 0, l = rawZOrder.Size(); i < l; i += 2)
1336 {
1337 const auto slotIndex = rawZOrder[(rapidjson::SizeType)i].GetInt();
1338 const auto zOrderOffset = rawZOrder[(rapidjson::SizeType)i + 1].GetInt();
1339 while (originalIndex != (unsigned)slotIndex)
1340 {
1341 unchanged[unchangedIndex++] = originalIndex++;
1342 }
1343
1344 unsigned index = originalIndex + zOrderOffset;
1345 zOrders[index] = originalIndex++;
1346 }
1347
1348 while (originalIndex < slotCount)
1349 {
1350 unchanged[unchangedIndex++] = originalIndex++;
1351 }
1352
1353 _frameArray.resize(_frameArray.size() + 1 + slotCount);
1354 _frameArray[frameOffset + 1] = (int16_t)slotCount;
1355
1356 int i = (int)slotCount;
1357 while (i--)
1358 {
1359 if (zOrders[i] == -1)
1360 {
1361 _frameArray[frameOffset + 2 + i] = unchanged[--unchangedIndex];
1362 }
1363 else {
1364 _frameArray[frameOffset + 2 + i] = zOrders[i];
1365 }

Callers

nothing calls this directly

Calls 6

HasMemberMethod · 0.80
GetIntMethod · 0.80
SizeMethod · 0.65
EmptyMethod · 0.45
sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected