mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-05 02:52:39 +08:00
Merge pull request #775 from jareguo/v1.6
dragonbones: sync fixes from official repo
This commit is contained in:
@@ -12,9 +12,15 @@ void BaseObject::_returnObject(BaseObject* object)
|
||||
const auto maxCountIterator = _maxCountMap.find(classTypeIndex);
|
||||
const auto maxCount = maxCountIterator != _maxCountMap.end() ? maxCountIterator->second : _defaultMaxCount;
|
||||
|
||||
auto& pool = _poolsMap[classTypeIndex];
|
||||
if (pool.size() < maxCount)
|
||||
const auto iterator = _poolsMap.find(classTypeIndex);
|
||||
if (iterator != _poolsMap.end())
|
||||
{
|
||||
auto& pool = iterator->second;
|
||||
if (pool.size() >= maxCount) {
|
||||
delete object;
|
||||
return;
|
||||
}
|
||||
|
||||
if (std::find(pool.cbegin(), pool.cend(), object) == pool.cend())
|
||||
{
|
||||
pool.push_back(object);
|
||||
|
||||
@@ -30,15 +30,16 @@ protected:
|
||||
scale = 1.f;
|
||||
offset = 0.f;
|
||||
|
||||
T* prevFrame = nullptr;
|
||||
for (const auto frame : frames)
|
||||
{
|
||||
if (prevFrame && frame != prevFrame)
|
||||
{
|
||||
prevFrame->returnToPool();
|
||||
std::vector<T*> deleteFrames;
|
||||
for (const auto frame : frames) {
|
||||
auto i = std::find(deleteFrames.begin(), deleteFrames.end(), frame);
|
||||
if (i == deleteFrames.end()) {
|
||||
deleteFrames.push_back(frame);
|
||||
}
|
||||
}
|
||||
|
||||
prevFrame = frame;
|
||||
for (const auto frame : deleteFrames) {
|
||||
frame->returnToPool();
|
||||
}
|
||||
|
||||
frames.clear();
|
||||
|
||||
Reference in New Issue
Block a user