Altın Konu Görüş Mesafesi Sistemi

5.00 yıldız(lar) 2 Değerlendirme Değerlendirenler
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...

NaimSazak

TURKMMO
Katılım
30 Mar 2017
Konular
296
Mesajlar
1,340
Çözüm
8
Online süresi
2mo 3d
Reaksiyon Skoru
1,904
Altın Konu
33
TM Yaşı
9 Yıl 2 Ay 15 Gün
Başarım Puanı
272
Yaş
35
MmoLira
643
DevLira
12
Ticaret - 0%
0   0   0

ROHAN2 WORLD 1-120 TR TİPİ OFFICIAL YOHARA, BALATHOR VE AMON! 80. GÜNÜNDE! +10.000 ONLİNE! HİLE VE BOT %100 ENGELLİ HEMEN TIKLA!

Serverinizde haritalarda kasma,donma,takılma gibi bir çok problemden şikayetçi olabilirsiniz düşük sistemlerde bu sıkça karşımıza çıkmaktadır bunun için aşağıda bulunan sistemi deneyebilirsiniz
Örnek ; Sizin karakterinizin etrafındaki objeler gözükücektir daha uzaktaki objeler siz oraya gittikçe render olacak ve görünücektir bu yüzden kasma takılma vb olma olasılığını düşürücektir..


İlk Olarak Sunucu Dosyalarımızdan : EterBase/Utils.h Giriş Yapın. ( Alta Verilen Kodları Ekleyiniz )
Kod:
template<typename T>
constexpr T LinearInterpolation(const T& tMin, const T& tMax, float fRatio)
{
    return T((1.0f - fRatio) * tMin + fRatio * tMax);
}

template<typename T>
constexpr T HermiteInterpolation(const T& tMin, const T& tMax, float fRatio)
{
    fRatio = MINMAX(0.0f, fRatio, 1.0f);
    fRatio = fRatio * fRatio * (3.0f - 2.0f * fRatio);
    return LinearInterpolation(tMin, tMax, fRatio);
}

2. GameLib/Area.h Giriş Yapıyoruz. ( BU KODU )
Kod:
void            Update();
2.1. Bu Kod İle Değiştiriyoruz.
Kod:
void            Update(D3DXVECTOR3& v3Player);
2.2. Ardından Yeniliyoruz

Kod:
void            Refresh();
2.3. Ardından Bu Kodu Giriş Yapın
Kod:
void Refresh ( TObjectInstance * pObjectInstance , bool bRemove );
2.4. Altaki kodu aratıyoruz.

Kod:
void            __UpdateAniThingList();
2.5. Alta Bulunan Kodu Ekleyiniz.
Kod:
void            __UpdateLoadedObjectInstances(D3DXVECTOR3& v3Player);
void            __UpdateEffectList(D3DXVECTOR3& v3Player);
float            GetMaxLoadingDistanceSqr() const;
2.6. Ardından Tekrar Arama Kısmına yazıp Aratıyoruz
Kod:
        BOOL                                            m_bPortalEnable;
2.7. Bu Kısmada Bu Kodu Ekleyiniz
Kod:
std::vector<CEffectInstance*>                    m_kVct_pkEftInstSort; // for rendering
        int                                                m_iUpdateCount;
2.8. Tekrardan Arama kısmına Alta Bulunan Kodu Yazınız
Kod:
dwEffectInstanceIndex = 0xffffffff;
2.9. Bu Kod İle Değiştiriniz
Kod:
dwEffectInstanceIndex = 0;

Şimdi GameLib/Area.cpp: Giriş Yapalım ve Kodu Ekleyelim
Kod:
#include "../UserInterface/PythonApplication.h"
Kod:
void CArea::__UpdateLoadedObjectInstances(D3DXVECTOR3& v3Player)
{
    const float fMaxDist = GetMaxLoadingDistanceSqr();
    const DWORD dwStartTime = ELTimer_GetMSec();

    DWORD i = 0;
    for (auto it = m_ObjectInstanceVector.begin(); it != m_ObjectInstanceVector.end(); ++it, ++i)
    {
        const TObjectData* c_pObjectData;

        if (!GetObjectDataPointer(i, &c_pObjectData))
            continue;

        bool bDidModify = false;
        const float fDist = (v3Player.x - c_pObjectData->Position.x) * (v3Player.x - c_pObjectData->Position.x)
            + (v3Player.y - c_pObjectData->Position.y) * (v3Player.y - c_pObjectData->Position.y);

        if (fMaxDist > fDist)
        {
            if ((*it) == nullptr)
            {
                *it = ms_ObjectInstancePool.Alloc();
                (*it)->Clear();

                __SetObjectInstance(*it, c_pObjectData);

                // ĂÖŔűČżë
                if ((*it)->dwType == prt::PROPERTY_TYPE_BUILDING)
                    m_GraphicThingInstanceCRCMap.emplace(TGraphicThingInstanceCRCMap::value_type((*it)->pThingInstance, c_pObjectData->dwCRC));

                Refresh(*it, false);
                bDidModify = true;
            }
        }
        else
        {
            if ((*it) != nullptr)
            {
                if ((*it)->dwType == prt::PROPERTY_TYPE_BUILDING)
                    m_GraphicThingInstanceCRCMap.erase((*it)->pThingInstance);

                Refresh(*it, true);

                __Clear_DestroyObjectInstance(*it);
                *it = nullptr;
                bDidModify = true;
            }
        }

        if (bDidModify)
        {
            const DWORD dwElapsed = ELTimer_GetMSec() - dwStartTime;
            if (dwElapsed > 2)
                break;
        }
    }
}

void CArea::__UpdateEffectList(D3DXVECTOR3& v3Player)
{
    m_kVct_pkEftInstSort.clear();

    const int iUpdateFPS = MAX(2, CPythonApplication::Instance().GetUpdateFPS());
    const float fMaxDist = GetMaxLoadingDistanceSqr();

    if (CEffectManager* pEffectManager = CEffectManager::InstancePtr())
    {
        // Effect
        for (auto i = m_EffectInstanceMap.begin(); i != m_EffectInstanceMap.end();)
        {
            CEffectInstance* pEffectInstance = i->second;

            const D3DMATRIX& gMatrix = pEffectInstance->GetGlobalMatrix();
            const float fDist = (v3Player.x - gMatrix._41) * (v3Player.x - gMatrix._41) + (v3Player.y - gMatrix._42) * (v3Player.y - gMatrix._42);
            const int iDistRatio = HermiteInterpolation(1, iUpdateFPS / 2, fDist / fMaxDist);

            if (m_iUpdateCount % iDistRatio == 0)
                pEffectInstance->Update();

            if (!pEffectInstance->isAlive())
            {
                i = m_EffectInstanceMap.erase(i);
                pEffectManager->DestroyUnsafeEffectInstance(pEffectInstance);
                continue;
            }

            if (pEffectInstance->isShow())
            {
                m_kVct_pkEftInstSort.emplace_back(pEffectInstance);
            }

            ++i;
        }
    }

    ++m_iUpdateCount;
    if (m_iUpdateCount > iUpdateFPS)
        m_iUpdateCount = 0;
}

float CArea::GetMaxLoadingDistanceSqr() const
{
    int peNum;
    float pfStart, pfEnd, pfFarClip;
    CPythonBackground::instance().GetDistanceSetInfo(&peNum, &pfStart, &pfEnd, &pfFarClip);
    return pfFarClip * pfFarClip;
}

CArea::CArea Giriş Yapalım
[CODE highlight="4,5"]BU KODU
m_wX = m_wY = 0xFF;

BU KODU EKLEYELİM İÇİNE
m_iUpdateCount = 0;
[/CODE]

CArea::__SetObjectInstance_SetEffect Kodu Bulun ve Aşağıdaki Kod ile Değiştirelim.
Kod:
pObjectInstance->dwEffectInstanceIndex = m_EffectInstanceMap.size();
Kod:
pObjectInstance->dwEffectInstanceIndex = (DWORD)pEffectInstance;

CArea::__Clear_DestroyObjectInstance Kodunu Bulunuz Değiştiriniz
Kod:
if (pObjectInstance->dwEffectInstanceIndex!=0xffffffff)
if (pObjectInstance->dwEffectInstanceIndex!=0)
pObjectInstance->dwEffectInstanceIndex = 0xffffffff;
pObjectInstance -> dwEffectInstanceIndex = 0 ;

CArea::Update Yükleme İşlevini Bulalım ve Değiştirelim
Kod:
void CArea::Update(D3DXVECTOR3& v3Player)
{
    __UpdateLoadedObjectInstances(v3Player);
    __UpdateAniThingList();
    __UpdateEffectList(v3Player);
}

CArea::Refresh İşlevini Bulalım ve Değiştirelim
C++:
void CArea::Refresh(TObjectInstance* pObjectInstance, bool bRemove)
{
    if (!pObjectInstance)
        return;

    if (prt::PROPERTY_TYPE_TREE == pObjectInstance->dwType)
    {
        if (pObjectInstance->pTree)
        {
            if (bRemove)
            {
                auto it = std::find(m_TreeCloneInstaceVector.begin(), m_TreeCloneInstaceVector.end(), pObjectInstance->pTree);
                if (it != m_TreeCloneInstaceVector.end())
                    m_TreeCloneInstaceVector.erase(it);
            }
            else
            {
                m_TreeCloneInstaceVector.emplace_back(pObjectInstance->pTree);

                const float* pfPosition;
                pfPosition = pObjectInstance->pTree->GetPosition();
                pObjectInstance->pTree->UpdateBoundingSphere();
                pObjectInstance->pTree->UpdateCollisionData();
            }
        }
    }
    else if (prt::PROPERTY_TYPE_BUILDING == pObjectInstance->dwType)
    {
        if (bRemove)
        {
            auto it = std::find(m_ThingCloneInstaceVector.begin(), m_ThingCloneInstaceVector.end(), pObjectInstance->pThingInstance);
            if (it != m_ThingCloneInstaceVector.end())
                m_ThingCloneInstaceVector.erase(it);

            if (pObjectInstance->pThingInstance->IsMotionThing())
            {
                auto it = std::find(m_AniThingCloneInstanceVector.begin(), m_AniThingCloneInstanceVector.end(), pObjectInstance->pThingInstance);
                if (it != m_AniThingCloneInstanceVector.end())
                    m_AniThingCloneInstanceVector.erase(it);
            }

            if (pObjectInstance->isShadowFlag)
            {
                auto it = std::find(m_ShadowThingCloneInstaceVector.begin(), m_ShadowThingCloneInstaceVector.end(), pObjectInstance->pThingInstance);
                if (it != m_ShadowThingCloneInstaceVector.end())
                    m_ShadowThingCloneInstaceVector.erase(it);
            }
        }
        else
        {
            pObjectInstance->pThingInstance->Update();
            pObjectInstance->pThingInstance->Transform();
            pObjectInstance->pThingInstance->Show();
            pObjectInstance->pThingInstance->DeformAll();
            m_ThingCloneInstaceVector.emplace_back(pObjectInstance->pThingInstance);

            pObjectInstance->pThingInstance->BuildBoundingSphere();
            pObjectInstance->pThingInstance->UpdateBoundingSphere();

            if (pObjectInstance->pThingInstance->IsMotionThing())
            {
                m_AniThingCloneInstanceVector.emplace_back(pObjectInstance->pThingInstance);
                pObjectInstance->pThingInstance->SetMotion(0);
            }

            if (pObjectInstance->isShadowFlag)
            {
                m_ShadowThingCloneInstaceVector.emplace_back(pObjectInstance->pThingInstance);
            }

            if (pObjectInstance->pAttributeInstance)
            {
                pObjectInstance->pThingInstance->UpdateCollisionData(&pObjectInstance->pAttributeInstance->GetObjectPointer()->GetCollisionDataVector());
                pObjectInstance->pAttributeInstance->RefreshObject(pObjectInstance->pThingInstance->GetTransform());
                pObjectInstance->pThingInstance->UpdateHeightInstance(pObjectInstance->pAttributeInstance);
            }
        }
    }
    else if (prt::PROPERTY_TYPE_EFFECT == pObjectInstance->dwType)
    {
    }
    else if (prt::PROPERTY_TYPE_AMBIENCE == pObjectInstance->dwType)
    {
        if (bRemove)
        {
            auto it = std::find(m_AmbienceCloneInstanceVector.begin(), m_AmbienceCloneInstanceVector.end(), pObjectInstance->pAmbienceInstance);
            if (it != m_AmbienceCloneInstanceVector.end())
                m_AmbienceCloneInstanceVector.erase(it);
        }
        else
        {
            m_AmbienceCloneInstanceVector.emplace_back(pObjectInstance->pAmbienceInstance);
        }
    }
    else if (prt::PROPERTY_TYPE_DUNGEON_BLOCK == pObjectInstance->dwType)
    {
        if (bRemove)
        {
            auto it = std::find(m_DungeonBlockCloneInstanceVector.begin(), m_DungeonBlockCloneInstanceVector.end(), pObjectInstance->pDungeonBlock);
            if (it != m_DungeonBlockCloneInstanceVector.end())
                m_DungeonBlockCloneInstanceVector.erase(it);
        }
        else
        {
            pObjectInstance->pDungeonBlock->Update();
            pObjectInstance->pDungeonBlock->Deform();
            pObjectInstance->pDungeonBlock->UpdateBoundingSphere();
            m_DungeonBlockCloneInstanceVector.emplace_back(pObjectInstance->pDungeonBlock);

            if (pObjectInstance->pAttributeInstance)
            {
                pObjectInstance->pDungeonBlock->UpdateCollisionData(&pObjectInstance->pAttributeInstance->GetObjectPointer()->GetCollisionDataVector());
                pObjectInstance->pAttributeInstance->RefreshObject(pObjectInstance->pDungeonBlock->GetTransform());
                pObjectInstance->pDungeonBlock->UpdateHeightInstance(pObjectInstance->pAttributeInstance);
            }
        }
    }
}
CArea::__Load_BuildObjectInstances Bulalım ve Değiştirelim
Kod:
void CArea::__Load_BuildObjectInstances()
{
    m_ObjectInstanceVector.clear();
    m_ObjectInstanceVector.resize(GetObjectDataCount(), nullptr);

    m_GraphicThingInstanceCRCMap.clear();

     std::sort(m_ObjectDataVector.begin(), m_ObjectDataVector.end(), ObjectDataComp());
}

CArea::GetObjectInstancePointer Arayıp Sonucu Aşağıdaki Kod İle Değiştirelim
Kod:
const bool CArea::GetObjectInstancePointer(const DWORD & dwIndex, const TObjectInstance ** ppObjectInstance) const
{
    if (dwIndex >= m_ObjectInstanceVector.size())
        return false;

    *ppObjectInstance = m_ObjectInstanceVector[dwIndex];
    return (*ppObjectInstance) != nullptr;
}

BİLİYORUM SIKILDINIZ DURMADAN KOD EKLEMEKTEN AMA SABREDİN ÇOK AZ KALDI HERŞEY SİZ VE OYUNCULARINIZ İÇİN

CArea::RenderEffect Bulalım ve Değiştirelim
Kod:
void CArea::RenderEffect()
{
    // Effect
    STATEMANAGER.SetTexture(0, NULL);
    STATEMANAGER.SetTexture(1, NULL);

    std::sort(m_kVct_pkEftInstSort.begin(), m_kVct_pkEftInstSort.end(), CArea_LessEffectInstancePtrRenderOrder());
    std::for_each(m_kVct_pkEftInstSort.begin(), m_kVct_pkEftInstSort.end(), CArea_FEffectInstanceRender());
}

CArea::RefreshPortal Giriş Yapalım ve Altaki Kodları Ekleyiniz Sırayla
Kod:
        TObjectInstance * pInstance = m_ObjectInstanceVector[i];
Kod:
if (!pInstance)
            continue;
Kod:
        TObjectInstance * pObjectInstance = *it;
Kod:
if (!pObjectInstance)
            continue;

CArea::Clear function Buluyoruz Tekrar ve Değiştiriyoruz
Kod:
for (it = m_ObjectInstanceVector.begin();it!=m_ObjectInstanceVector.end();++it)
        __Clear_DestroyObjectInstance(*it);
[CODE title="Bunu Ekliyoruz"]for (it = m_ObjectInstanceVector.begin(); it != m_ObjectInstanceVector.end(); ++it)
{
if ((*it) != nullptr)
__Clear_DestroyObjectInstance(*it);
}[/CODE]
GameLib/MapOutdoor.h Giriş Yapın ve 1 Kodu Bulalım ardından silip 2 ci Kodu Ekleyelim
Kod:
void            __UpdateAroundAreaList();
Kod:
void            __UpdateAroundAreaList(D3DXVECTOR3& v3Player);
GameLib/MapOutdoorUpdate.cpp Giriş Yapalım CMapOutdoor::__Game_UpdateArea Bulalım ve Kaldıralım
1 KALDIRILACAK :
Kod:
__UpdateAroundAreaList
2 EKLENECEK :
Kod:
    __UpdateAroundAreaList(v3Player);
3 SONUÇ :
Kod:
    __CollectShadowReceiver(v3Player, v3Light);

Son Olarak CMapOutdoor::__UpdateAroundAreaList Bulun ve Altaki Kod İle Değiştirelim
Kod:
void CMapOutdoor::__UpdateAroundAreaList(D3DXVECTOR3& v3Player)
{
#ifdef __PERFORMANCE_CHECKER__
    DWORD ft1=timeGetTime();
#endif
    DWORD at[AROUND_AREA_NUM];
    for (int i = 0; i < AROUND_AREA_NUM; ++i)
    {
        DWORD t1=timeGetTime();
        CArea * pArea;
        if (GetAreaPointer(i, &pArea))
            pArea->Update(v3Player);
        DWORD t2=timeGetTime();

        at[i]=t2-t1;
    }
#ifdef __PERFORMANCE_CHECKER__
    DWORD ft2=timeGetTime();
    if (ft2-ft1>5)
    {
        for (int i=0; i<AROUND_AREA_NUM; ++i)
            Tracef("Area %d %d\n", i, at[i]);
    }
#endif
}

İyi ForumlarDilerim.​
 
Son düzenleme:

En Çok Reaksiyon Alan Mesajlar

Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...

Şu an konuyu görüntüleyenler (Toplam : 0, Üye: 0, Misafir: 0)