From efefdbf847f6ae3cd27bf0db2c51ea18cf16221b Mon Sep 17 00:00:00 2001 From: MathemanFlo Date: Wed, 9 Mar 2022 15:16:37 +0100 Subject: [PATCH] Add pbr swatch feature to color picker --- Sources/arm/Project.hx | 4 ++++ Sources/arm/ui/UIHeader.hx | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Sources/arm/Project.hx b/Sources/arm/Project.hx index ac674001..2da11c7b 100644 --- a/Sources/arm/Project.hx +++ b/Sources/arm/Project.hx @@ -584,6 +584,10 @@ class Project { return { base: base, opacity: 1.0, occlusion: 1.0, roughness: 0.0, metallic: 0.0, normal: 0xff8080ff, emission: 0.0, height: 0.0, subsurface: 0.0 }; } + public static function cloneSwatch(swatch: TSwatchColor) : TSwatchColor { + return { base: swatch.base, opacity: swatch.opacity, occlusion: swatch.occlusion, roughness: swatch.roughness, metallic: swatch.metallic, normal: swatch.normal, emission: swatch.emission, height: swatch.height, subsurface: swatch.subsurface }; + } + public static function setDefaultSwatches() { // 32-Color Palette by Andrew Kensler // http://eastfarthing.com/blog/2016-05-06-palette/ diff --git a/Sources/arm/ui/UIHeader.hx b/Sources/arm/ui/UIHeader.hx index 2832d08e..24829423 100644 --- a/Sources/arm/ui/UIHeader.hx +++ b/Sources/arm/ui/UIHeader.hx @@ -95,7 +95,7 @@ class UIHeader { var uiy = ui._y; App.dragOffX = -(mouse.x - uix - ui._windowX - 3); App.dragOffY = -(mouse.y - uiy - ui._windowY + 1); - App.dragSwatch = Project.makeSwatch(h.color.value); + App.dragSwatch = Project.cloneSwatch(Context.pickedColor); } if (ui.isHovered) ui.tooltip(tr("Drag and drop picked color to swatches, materials, layers or to the node editor.")); if (ui.isHovered && ui.inputReleased) { @@ -107,7 +107,7 @@ class UIHeader { }, 10); } if (ui.button(tr("Add Swatch"))) { - var newSwatch = Project.makeSwatch(Context.pickedColor.base); + var newSwatch = Project.cloneSwatch(Context.pickedColor); Context.setSwatch(newSwatch); Project.raw.swatches.push(newSwatch); UIStatus.inst.statusHandle.redraws = 1;