Axiom.Components.Terrain.TerrainQuadTreeNode.UpdateVertexData C# (CSharp) Method

UpdateVertexData() public method

Tell the node to update its vertex data for a given region.
public UpdateVertexData ( bool positions, bool deltas, Rectangle rect, bool cpuData ) : void
positions bool
deltas bool
rect Axiom.Core.Rectangle
cpuData bool
return void
        public void UpdateVertexData(bool positions, bool deltas, Rectangle rect, bool cpuData)
        {
            if (rect.Left <= mBoundaryX || rect.Right > mOffsetX
                || rect.Top <= mBoundaryY || rect.Bottom > mOffsetY)
            {
                // Do we have vertex data?
                if (mVertexDataRecord != null)
                {
                    // Trim to our bounds
                    Rectangle updateRect = new Rectangle(mOffsetX, mOffsetY, mBoundaryX, mBoundaryY);
                    updateRect.Left = System.Math.Max(updateRect.Left, rect.Left);
                    updateRect.Right = System.Math.Min(updateRect.Right, rect.Right);
                    updateRect.Top = System.Math.Max(updateRect.Top, rect.Top);
                    updateRect.Bottom = System.Math.Min(updateRect.Bottom, rect.Bottom);
                    // update the GPU buffer directly
#warning 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

                    HardwareVertexBuffer posbuf = null, deltabuf = null;
                    VertexData targetData = cpuData ?
                        mVertexDataRecord.CpuVertexData : mVertexDataRecord.GpuVertexData;

                    if (positions)
                        posbuf = targetData.vertexBufferBinding.GetBuffer((short)POSITION_BUFFER);
                    if (deltas)
                        deltabuf = targetData.vertexBufferBinding.GetBuffer((short)DELTA_BUFFER);

                    UpdateVertexBuffer(posbuf, deltabuf, 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

                        AxisAlignedBox childBox = new AxisAlignedBox(mChildren[i].AABB);

                        // this box is relative to child centre
                        Vector3 boxoffset = mChildren[i].LocalCentre - LocalCentre;
                        childBox.Minimum = childBox.Minimum + boxoffset;
                        childBox.Maximum = childBox.Maximum + boxoffset;
                        mAABB.Merge(childBox);

                    }
                }
                if (mRend != null)
                    mRend.ParentSceneNode.NeedUpdate();
                // Make sure node knows to update
              /*  if (mMovable != null)
                    mMovable.ParentSceneNode.NeedUpdate();*/
            }
        }
        /// <summary>