public void CopyRange(Vector2I start, Vector2I end, IMyWrappedCubemapFace other, Vector2I oStart, Vector2I oEnd) { MyCubemapData <TPixel> data = other as MyCubemapData <TPixel>; if (data != null) { this.CopyRange(start, end, data, oStart, oEnd); } }
public void CopyRange(Vector2I start, Vector2I end, MyCubemapData <T> other, Vector2I oStart, Vector2I oEnd) { Vector2I myStep = MyCubemapHelpers.GetStep(ref start, ref end); Vector2I oStep = MyCubemapHelpers.GetStep(ref oStart, ref oEnd); T val; for (; start != end; start += myStep, oStart += oStep) { other.GetValue(oStart.X, oStart.Y, out val); SetValue(start.X, start.Y, ref val); } other.GetValue(oStart.X, oStart.Y, out val); SetValue(start.X, start.Y, ref val); }
public void CopyRange(Vector2I start, Vector2I end, MyCubemapData <TPixel> other, Vector2I oStart, Vector2I oEnd) { TPixel local; Vector2I step = MyCubemapHelpers.GetStep(ref start, ref end); Vector2I vectori2 = MyCubemapHelpers.GetStep(ref oStart, ref oEnd); while (start != end) { other.GetValue(oStart.X, oStart.Y, out local); this.SetValue(start.X, start.Y, ref local); start += step; oStart += vectori2; } other.GetValue(oStart.X, oStart.Y, out local); this.SetValue(start.X, start.Y, ref local); }
private unsafe byte ComputeMapBlend(Vector2 coords, int face, ref MapBlendCache cache, MyCubemapData <byte> map) { byte num; coords = (coords * map.Resolution) - 0.5f; Vector2I vectori = new Vector2I(coords); if (((cache.HashCode != this.m_hashCode) || (cache.Face != face)) || (cache.Cell != vectori)) { cache.HashCode = this.m_hashCode; cache.Cell = vectori; cache.Face = (byte)face; if (this.m_materialMap != null) { byte num2; byte num3; byte num4; byte num5; map.GetValue(vectori.X, vectori.Y, out num2); map.GetValue(vectori.X + 1, vectori.Y, out num3); map.GetValue(vectori.X, vectori.Y + 1, out num4); map.GetValue(vectori.X + 1, vectori.Y + 1, out num5); byte *v = stackalloc byte[4]; v[0] = num2; v[1] = num3; v[2] = num4; v[3] = num5; if (((num2 != num3) || (num4 != num5)) || (num4 != num2)) { Sort4(v); ComputeTilePattern(num2, num3, num4, num5, v, &cache.Data.FixedElementField); numRef = null; } else { IntPtr ptr1 = (IntPtr) & cache.Data.FixedElementField; ptr1[0] = (IntPtr)((ushort)((num2 << 8) | 15)); ptr1[2] = IntPtr.Zero; ptr1[(int)(((IntPtr)2) * 2)] = IntPtr.Zero; ptr1[(int)(((IntPtr)3) * 2)] = IntPtr.Zero; numRef = null; } } } ushort *values = &cache.Data.FixedElementField; coords -= Vector2.Floor(coords); if (coords.X == 1f) { coords.X = 0.99999f; } if (coords.Y == 1f) { coords.Y = 0.99999f; } this.SampleTile(values, ref coords, out num); fixed(ushort *numRef = null) { return(num); } }
private unsafe byte ComputeMapBlend(Vector2 coords, int face, ref MapBlendCache cache, MyCubemapData <byte> map) { coords = coords * map.Resolution - .5f; Vector2I isample = new Vector2I(coords); if (cache.HashCode != m_hashCode || cache.Face != face || cache.Cell != isample) { byte tl, tr, bl, br; cache.HashCode = m_hashCode; cache.Cell = isample; cache.Face = (byte)face; // Biome if (m_materialMap != null) { map.GetValue(isample.X, isample.Y, out tl); map.GetValue(isample.X + 1, isample.Y, out tr); map.GetValue(isample.X, isample.Y + 1, out bl); map.GetValue(isample.X + 1, isample.Y + 1, out br); byte *ss = stackalloc byte[4]; ss[0] = tl; ss[1] = tr; ss[2] = bl; ss[3] = br; if (tl == tr && bl == br && bl == tl) { fixed(ushort *smpls = cache.Data) { smpls[0] = (ushort)((tl << 8) | 0xF); smpls[1] = 0; smpls[2] = 0; smpls[3] = 0; } } else { fixed(ushort *smpls = cache.Data) { Sort4(ss); ComputeTilePattern(tl, tr, bl, br, ss, smpls); } } } } byte value; fixed(ushort *smpls = cache.Data) { coords -= Vector2.Floor(coords); if (coords.X == 1) { coords.X = .99999f; } if (coords.Y == 1) { coords.Y = .99999f; } SampleTile(smpls, ref coords, out value); } return(value); }