当前位置: 首页>>代码示例>>C++>>正文


C++ Chunk::CompleteMesh方法代码示例

本文整理汇总了C++中Chunk::CompleteMesh方法的典型用法代码示例。如果您正苦于以下问题:C++ Chunk::CompleteMesh方法的具体用法?C++ Chunk::CompleteMesh怎么用?C++ Chunk::CompleteMesh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Chunk的用法示例。


在下文中一共展示了Chunk::CompleteMesh方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateNewChunk

// Chunk Creation
void ChunkManager::CreateNewChunk(int x, int y, int z)
{
    ChunkCoordKeys coordKeys;
    coordKeys.x = x;
    coordKeys.y = y;
    coordKeys.z = z;

    // Create a new chunk at this grid position
    Chunk* pNewChunk = new Chunk(m_pRenderer, this, m_pVoxSettings);
    pNewChunk->SetPlayer(m_pPlayer);
    pNewChunk->SetSceneryManager(m_pSceneryManager);

    float xPos = x * (Chunk::CHUNK_SIZE * Chunk::BLOCK_RENDER_SIZE*2.0f);
    float yPos = y * (Chunk::CHUNK_SIZE * Chunk::BLOCK_RENDER_SIZE*2.0f);
    float zPos = z * (Chunk::CHUNK_SIZE * Chunk::BLOCK_RENDER_SIZE*2.0f);

    pNewChunk->SetPosition(vec3(xPos, yPos, zPos));
    pNewChunk->SetGrid(coordKeys.x, coordKeys.y, coordKeys.z);

    m_ChunkMapMutexLock.lock();
    m_chunksMap[coordKeys] = pNewChunk;
    m_ChunkMapMutexLock.unlock();

    pNewChunk->Setup();
    pNewChunk->SetNeedsRebuild(false, true);
    pNewChunk->RebuildMesh();
    pNewChunk->CompleteMesh();
    pNewChunk->SetCreated(true);

    UpdateChunkNeighbours(pNewChunk, x, y, z);
}
开发者ID:CodeMason,项目名称:Vox,代码行数:32,代码来源:ChunkManager.cpp

示例2: Update

void ChunkManager::Update() {
    ChunkList unloadList;

    m_chunkMapMutex.lock();
    std::map<ChunkCoordKey, Chunk*>::iterator it;
    for (it = m_chunkMap.begin(); it != m_chunkMap.end(); ++it) {
        Chunk* chunk = it->second;
        if (chunk->IsUnloading()) {
            unloadList.push_back(chunk);
        }
        else if (chunk->IsRebuildComplete()) {
            chunk->CompleteMesh();
        }
    }
    m_chunkMapMutex.unlock();
    
    int numUnloadChunks = 0;
    const static int MAX_NUM_CHUNKS_UNLOAD = 1;
    for (unsigned int i = 0; i < unloadList.size() && numUnloadChunks < MAX_NUM_CHUNKS_UNLOAD; ++i) {
        Chunk* chunk = unloadList[i];
        UnloadChunk(chunk);
    }
}
开发者ID:ggtucker,项目名称:SugoiEngine,代码行数:23,代码来源:ChunkManager.cpp

示例3: UpdatingChunksThread


//.........这里部分代码省略.........
                            }
                            if (pChunk->GetzPlus() == NULL)
                            {
                                ChunkCoordKeys coordKey;
                                coordKey.x = gridX;
                                coordKey.y = gridY;
                                coordKey.z = gridZ + 1;
                                float xPos = coordKey.x * Chunk::CHUNK_SIZE * Chunk::BLOCK_RENDER_SIZE*2.0f;
                                float yPos = coordKey.y * Chunk::CHUNK_SIZE * Chunk::BLOCK_RENDER_SIZE*2.0f;
                                float zPos = coordKey.z * Chunk::CHUNK_SIZE * Chunk::BLOCK_RENDER_SIZE*2.0f;

                                vec3 chunkCenter = vec3(xPos, yPos, zPos) + vec3(Chunk::CHUNK_SIZE*Chunk::BLOCK_RENDER_SIZE, Chunk::CHUNK_SIZE*Chunk::BLOCK_RENDER_SIZE, Chunk::CHUNK_SIZE*Chunk::BLOCK_RENDER_SIZE);
                                vec3 distanceVec = chunkCenter - m_pPlayer->GetCenter();
                                float lengthValue = length(distanceVec);

                                if (lengthValue <= m_loaderRadius)
                                {
                                    addChunkList.push_back(coordKey);
                                    numAddedChunks++;
                                }
                            }
                        }
                    }
                }
            }
        }
        updateChunkList.clear();

        // Adding chunks
        for (unsigned int i = 0; i < (int)addChunkList.size(); i++)
        {
            ChunkCoordKeys coordKey = addChunkList[i];
            Chunk* pChunk = GetChunk(coordKey.x, coordKey.y, coordKey.z);

            if (pChunk == NULL)
            {
                CreateNewChunk(coordKey.x, coordKey.y, coordKey.z);
            }
            else
            {
                UpdateChunkNeighbours(pChunk, coordKey.x, coordKey.y, coordKey.z);
            }
        }
        addChunkList.clear();

        // Unloading chunks
        for (unsigned int i = 0; i < (int)unloadChunkList.size(); i++)
        {
            Chunk* pChunk = unloadChunkList[i];

            UnloadChunk(pChunk);
        }
        unloadChunkList.clear();

        // Check for rebuild chunks
        m_ChunkMapMutexLock.lock();
        for (it_type iterator = m_chunksMap.begin(); iterator != m_chunksMap.end(); iterator++)
        {
            Chunk* pChunk = iterator->second;

            if (pChunk != NULL)
            {
                if (pChunk->NeedsRebuild())
                {
                    rebuildChunkList.push_back(pChunk);
                }
            }
        }
        m_ChunkMapMutexLock.unlock();

        // Rebuilding chunks
        int numRebuildChunks = 0;
        int MAX_NUM_CHUNKS_REBUILD = 30;
        for (unsigned int i = 0; i < (int)rebuildChunkList.size() && numRebuildChunks < MAX_NUM_CHUNKS_REBUILD; i++)
        {
            Chunk* pChunk = rebuildChunkList[i];

            pChunk->SwitchToCachedMesh();
            pChunk->RebuildMesh();
            pChunk->CompleteMesh();
            pChunk->UndoCachedMesh();

            numRebuildChunks++;
        }
        rebuildChunkList.clear();

        if (m_stepLockEnabled == true && m_updateStepLock == false)
        {
            m_updateStepLock = true;
        }

#ifdef _WIN32
        Sleep(10);
#else
        usleep(10000);
#endif
    }

    m_updateThreadFinished = true;
}
开发者ID:CodeMason,项目名称:Vox,代码行数:101,代码来源:ChunkManager.cpp


注:本文中的Chunk::CompleteMesh方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。