//---------------------------------------------------------------------
	void TerrainQuadTreeNode::updateVertexData(bool positions, bool deltas, 
		const Rect& rect, bool cpuData)
	{
		if (rect.left <= mBoundaryX || rect.right > mOffsetX
			|| rect.top <= mBoundaryY || rect.bottom > mOffsetY)
		{
			// Do we have vertex data?
			if (mVertexDataRecord)
			{
				// Trim to our bounds
				Rect updateRect(mOffsetX, mOffsetY, mBoundaryX, mBoundaryY);
				updateRect.left = std::max(updateRect.left, rect.left);
				updateRect.right = std::min(updateRect.right, rect.right);
				updateRect.top = std::max(updateRect.top, rect.top);
				updateRect.bottom = std::min(updateRect.bottom, rect.bottom);

				// update the GPU buffer directly
				// TODO: do we have no use for CPU vertex data after initial load?
				// if so, destroy it to free RAM, this should be fast enough to 
				// to direct
				if(!cpuData)
				{
					if(mVertexDataRecord->gpuPosVertexBuf == NULL) 
						createGpuVertexData();
				}

				updateVertexBuffer(updateRect);
			}

			// pass on to children
			if (!isLeaf())
			{
				for (int i = 0; i < 4; ++i)
				{
					mChildren[i]->updateVertexData(positions, deltas, rect, cpuData);

					// merge bounds from children
					AABB childBox = mChildren[i]->getAABB();
					// this box is relative to child centre
					VEC3 boxoffset = mChildren[i]->getLocalCentre() - getLocalCentre();
					childBox.m_minCorner = childBox.m_minCorner + boxoffset;
					childBox.m_maxCorner = childBox.m_maxCorner + boxoffset;
					mAABB.Merge(childBox);
				}

			}
		}

	}
Beispiel #2
0
    //------------------------------------------------------------------------
    void TerrainBatch::load()
    {
        if ( mRenderEnable && !mIsLoaded )
        {
            //////////////////////////////////

            createGpuVertexData();
            createGpuIndexData();

            loadChilds();

            loadRenderableObject();

            updateVertexData( mVertexRectInTile );

            if ( EngineMain::getInstance().getMode() != EM_EDITOR )
            {
                destroyGpuVertexBackupData();
                destroyGpuIndexBackupData();
            }
            
            mIsLoaded = true;
        }
    }
	void TerrainQuadTreeNode::loadSelf()
	{
		createGpuVertexData();
		createGpuIndexData();
	}