public static bool edit(ref MyIntVec2 val) => edit(ref val.x) || edit(ref val.y);
public static bool edit(ref MyIntVec2 val, int min, MyIntVec2 max) => edit(ref val.x, min, max.x) || edit(ref val.y, min, max.y);
public int PixelNo(MyIntVec2 v) => PixelNo(v.x, v.y);
private Color PixelSafe_Slow(MyIntVec2 v) => Pixels[PixelNo(v.x, v.y)];
public void Execute() { Blit_Functions.alphaMode_dlg _alphaMode; Blit_Functions.blitModeFunction _blitMode = GetBlitMode(); if (smooth) { _alphaMode = CircleAlpha; } else { _alphaMode = NoAlpha; } if (!isVolumeBlit) { int ihalf = (int)(half - 0.5f); if (smooth) { ihalf += 1; } MyIntVec2 tmp = pixelNumber; int fromx = tmp.x - ihalf; tmp.y -= ihalf; for (y = -ihalf; y < ihalf + 1; y++) { tmp.x = fromx; for (x = -ihalf; x < ihalf + 1; x++) { if (_alphaMode()) { var ind = PixelNo(tmp); var col = values[ind]; _blitMode(ref col); values[ind] = col; } tmp.x += 1; } tmp.y += 1; } } else { if (slices > 1) { int ihalf = (int)(half - 0.5f); if (smooth) { ihalf += 1; } _alphaMode = SphereAlpha; int sliceWidth = texWidth / slices; int hw = sliceWidth / 2; y = (int)pos.y; z = (int)(pos.z + hw); x = (int)(pos.x + hw); for (y = -ihalf; y < ihalf + 1; y++) { int h = y + y; if (h >= volHeight) { return; } if (h >= 0) { int hy = h / slices; int hx = h % slices; int hTex_index = (hy * texWidth + hx) * sliceWidth; for (z = -ihalf; z < ihalf + 1; z++) { int trueZ = z + z; if (trueZ >= 0 && trueZ < sliceWidth) { int yTex_index = hTex_index + trueZ * texWidth; for (x = -ihalf; x < ihalf + 1; x++) { int trueX = x + x; if (trueX >= 0 && trueX < sliceWidth) { int texIndex = yTex_index + trueX; if (_alphaMode()) { var col = values[texIndex]; _blitMode(ref col); values[texIndex] = col; } } } } } } } return; } return; } }
public void Init() { if (brushConfig == null) { brushConfig = new BrushConfig(); } if ((meshPackagingSolutions == null) || (meshPackagingSolutions.Count == 0)) { meshPackagingSolutions = new List <MeshPackagingProfile> { (new MeshPackagingProfile()).LoadFromResources(MeshPackagingProfile.folderName, "Simple"), (new MeshPackagingProfile()).LoadFromResources(MeshPackagingProfile.folderName, "Bevel"), (new MeshPackagingProfile()).LoadFromResources(MeshPackagingProfile.folderName, "AtlasedProjected"), (new MeshPackagingProfile()).LoadFromResources(MeshPackagingProfile.folderName, "Standard_Atlased") } } ; if (samplingMaskSize.x == 0) { samplingMaskSize = new MyIntVec2(4); } if (atlasFolderName == null || atlasFolderName.Length == 0) { materialsFolderName = "Materials"; texturesFolderName = "Textures"; vectorsFolderName = "Vectors"; meshesFolderName = "Models"; atlasFolderName = "ATLASES"; recordingNames = new List <string>(); } #if BUILD_WITH_PAINTER || UNITY_EDITOR if (pixPerfectCopy == null) { pixPerfectCopy = Shader.Find("Editor/PixPerfectCopy"); } if (Blit_Smoothed == null) { Blit_Smoothed = Shader.Find("Editor/BufferBlit_Smooth"); } if (brushRendy_bufferCopy == null) { brushRendy_bufferCopy = Shader.Find("Editor/BufferCopier"); } if (br_Blit == null) { br_Blit = Shader.Find("Editor/br_Blit"); } if (br_Add == null) { br_Add = Shader.Find("Editor/br_Add"); } if (br_Copy == null) { br_Copy = Shader.Find("Editor/br_Copy"); } if (br_Multishade == null) { br_Multishade = Shader.Find("Editor/br_Multishade"); } if (br_BlurN_SmudgeBrush == null) { br_BlurN_SmudgeBrush = Shader.Find("Editor/BlurN_SmudgeBrush"); } if (br_ColorFill == null) { br_ColorFill = Shader.Find("Editor/br_ColorFill"); } if (br_Preview == null) { br_Preview = Shader.Find("Editor/br_Preview"); } if (mesh_Preview == null) { mesh_Preview = Shader.Find("Editor/MeshEditorAssist"); } TerrainPreview = Shader.Find("Editor/TerrainPreview"); #endif var encody = new StdDecoder(meshToolsSTD); foreach (var tag in encody) { var d = encody.GetData(); foreach (var m in MeshToolBase.AllTools) { if (m.ToString().SameAs(tag)) { m.Decode(d); break; } } } }
public bool PaintTexture2D(StrokeVector stroke, float brushAlpha, ImageData image, BrushConfig bc, PlaytimePainter pntr) { if (pntr.IsAtlased()) { Vector2 uvCoords = stroke.uvFrom; Vector2 AtlasedSection = GetAtlasedSection(); sectorSize = image.width / atlasRows; atlasSector.From(AtlasedSection * sectorSize); Blit_Functions.brAlpha = brushAlpha; Blit_Functions.half = (bc.Size(false)) / 2; int ihalf = Mathf.FloorToInt(Blit_Functions.half - 0.5f); bool smooth = bc.Type(true) != BrushTypePixel.Inst; if (smooth) { Blit_Functions._alphaMode = Blit_Functions.circleAlpha; } else { Blit_Functions._alphaMode = Blit_Functions.noAlpha; } Blit_Functions._blitMode = bc.BlitMode.BlitFunctionTex2D; if (smooth) { ihalf += 1; } Blit_Functions.alpha = 1; Blit_Functions.r = bc.mask.GetFlag(BrushMask.R); Blit_Functions.g = bc.mask.GetFlag(BrushMask.G); Blit_Functions.b = bc.mask.GetFlag(BrushMask.B); Blit_Functions.a = bc.mask.GetFlag(BrushMask.A); Blit_Functions.csrc = bc.colorLinear.ToGamma(); MyIntVec2 tmp = image.UvToPixelNumber(uvCoords);//new myIntVec2 (pixIndex); int fromx = tmp.x - ihalf; tmp.y -= ihalf; var pixels = image.Pixels; for (Blit_Functions.y = -ihalf; Blit_Functions.y < ihalf + 1; Blit_Functions.y++) { tmp.x = fromx; for (Blit_Functions.x = -ihalf; Blit_Functions.x < ihalf + 1; Blit_Functions.x++) { if (Blit_Functions._alphaMode()) { int sx = tmp.x - atlasSector.x; int sy = tmp.y - atlasSector.y; sx %= sectorSize; if (sx < 0) { sx += sectorSize; } sy %= sectorSize; if (sy < 0) { sy += sectorSize; } Blit_Functions._blitMode(ref pixels[((atlasSector.y + sy)) * image.width + (atlasSector.x + sx)]); } tmp.x += 1; } tmp.y += 1; } return(true); } return(false); }