本文整理汇总了C#中VRage.Voxels.MyCellCoord.WriteRange方法的典型用法代码示例。如果您正苦于以下问题:C# MyCellCoord.WriteRange方法的具体用法?C# MyCellCoord.WriteRange怎么用?C# MyCellCoord.WriteRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VRage.Voxels.MyCellCoord
的用法示例。
在下文中一共展示了MyCellCoord.WriteRange方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteRange
private static void WriteRange(
ref WriteRangeArgs args,
byte defaultData,
int lodIdx,
Vector3I lodCoord,
ref Vector3I min,
ref Vector3I max)
{
MyOctreeNode node = new MyOctreeNode();
{
MyCellCoord leaf = new MyCellCoord(lodIdx - LeafLodCount, ref lodCoord);
var leafKey = leaf.PackId64();
if (args.Leaves.ContainsKey(leafKey))
{
args.Leaves.Remove(leafKey);
var childBase = lodCoord << 1;
Vector3I childOffset;
MyCellCoord child = new MyCellCoord();
child.Lod = leaf.Lod - 1;
var leafSize = LeafSizeInVoxels << child.Lod;
for (int i = 0; i < MyOctreeNode.CHILD_COUNT; ++i)
{
ComputeChildCoord(i, out childOffset);
child.CoordInLod = childBase + childOffset;
var childCopy = child;
childCopy.Lod += LeafLodCount;
IMyOctreeLeafNode octreeLeaf = new MyProviderLeaf(args.Provider, args.DataType, ref childCopy);
args.Leaves.Add(child.PackId64(), octreeLeaf);
node.SetChild(i, true);
node.SetData(i, octreeLeaf.GetFilteredValue());
}
}
else
{
leaf.Lod -= 1; // changes to node coord instead of leaf coord
var nodeKey = leaf.PackId64();
if (!args.Nodes.TryGetValue(nodeKey, out node))
{
for (int i = 0; i < MyOctreeNode.CHILD_COUNT; ++i)
node.SetData(i, defaultData);
}
}
}
if (lodIdx == (LeafLodCount + 1))
{
MyCellCoord child = new MyCellCoord();
Vector3I childBase = lodCoord << 1;
Vector3I minInLod = min >> LeafLodCount;
Vector3I maxInLod = max >> LeafLodCount;
Vector3I leafSizeMinusOne = new Vector3I(LeafSizeInVoxels - 1);
Vector3I childOffset;
for (int i = 0; i < MyOctreeNode.CHILD_COUNT; ++i)
{
ComputeChildCoord(i, out childOffset);
child.CoordInLod = childBase + childOffset;
if (!child.CoordInLod.IsInsideInclusive(ref minInLod, ref maxInLod))
continue;
var childMin = child.CoordInLod << LeafLodCount;
var childMax = childMin + LeafSizeInVoxels - 1;
Vector3I.Max(ref childMin, ref min, out childMin);
Vector3I.Min(ref childMax, ref max, out childMax);
var readOffset = childMin - min;
IMyOctreeLeafNode leaf;
var leafKey = child.PackId64();
var startInChild = childMin - (child.CoordInLod << LeafLodCount);
var endInChild = childMax - (child.CoordInLod << LeafLodCount);
args.Leaves.TryGetValue(leafKey, out leaf);
byte uniformValue;
bool uniformLeaf;
{
// ensure leaf exists and is writable
// the only writable leaf type is MicroOctree at this point
byte childDefaultData = node.GetData(i);
if (leaf == null)
{
var octree = new MyMicroOctreeLeaf(args.DataType, LeafLodCount, child.CoordInLod << (child.Lod + LeafLodCount));
octree.BuildFrom(childDefaultData);
leaf = octree;
}
if (leaf.ReadOnly)
{
var rangeEnd = new Vector3I(LeafSizeInVoxels - 1);
m_temporaryCache.Resize(Vector3I.Zero, rangeEnd);
leaf.ReadRange(m_temporaryCache, ref Vector3I.Zero, 0, ref Vector3I.Zero, ref rangeEnd);
var inCell = startInChild;
for (var it2 = new Vector3I.RangeIterator(ref startInChild, ref endInChild);
it2.IsValid(); it2.GetNext(out inCell))
{
var read = readOffset + (inCell - startInChild);
m_temporaryCache.Set(args.DataType, ref inCell, args.Source.Get(args.DataType, ref read));
}
var octree = new MyMicroOctreeLeaf(args.DataType, LeafLodCount, child.CoordInLod << (child.Lod + LeafLodCount));
//.........这里部分代码省略.........