effekseer / EffekseerForCocos2d-x

MIT License
42 stars 18 forks source link

performance optimize #32

Closed IcarusLi closed 2 years ago

IcarusLi commented 2 years ago

bool EffectManager::Initialize(cocos2d::Size visibleSize)
{
    int32_t spriteSize = 4000;

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    // large buffer make application slow on Android
    **spriteSize = 600;**
#endif
....

Android(Virtualbox) not good performance when playing a lot of effect at same time , but if changed spriteSize to 50, have a nice fps.

IcarusLi commented 2 years ago
void EffectFactory::OnLoadingResource(Effect* effect, const void* data, int32_t size, const char16_t* materialPath)
{
    auto resourceMgr = effect->GetSetting()->GetResourceManager();

    for (auto i = 0; i < effect->GetColorImageCount(); i++)
    {
        char16_t fullPath[512];
        PathCombine(fullPath, materialPath, effect->GetColorImagePath(i));

        effect->AddRef();
        char path_[300];
        ::Effekseer::ConvertUtf16ToUtf8(path_, 300, fullPath);
        std::string fullPathimg = cocos2d::FileUtils::getInstance()->fullPathForFilename(path_);
        cocos2d::Director::getInstance()->getTextureCache()->addImageAsync(fullPathimg, [=](cocos2d::Texture2D* texN) {
            if (texN != nullptr)
            {
                auto resource = resourceMgr->LoadTexture(fullPath, TextureType::Color);
                SetTexture(effect, i, TextureType::Color, resource);
            } 
            effect->Release();
            }, fullPathimg,false);

    }

new thread do resource(texture) load (base on cocos)

IcarusLi commented 2 years ago

.efkmodel have a very amazing size ...

durswd commented 2 years ago

Android(Virtualbox)

Is it no problem on Android in a smart phone?

IcarusLi commented 2 years ago

no problem,only few low-end phone same as vittualbox.

durswd commented 2 years ago

It should add an option to change the number of instance.