Merge branch 'master' into ImprovementSlider

This commit is contained in:
Phantom
2026-06-23 12:18:50 +02:00
7 changed files with 43 additions and 17 deletions
@@ -478,6 +478,13 @@ void MaterialParameter::Bind(BindMeta& meta) const
meta.Context->BindSR(_registerIndex, texture ? texture->GetTexture() : nullptr);
break;
}
case VariantType::Object:
{
// GPU Texture bind must match dimensions of the value archetype (eg. 2d or cube texture)
auto gpuTexture = Cast<GPUTexture>(e->Value.AsObject);
meta.Context->BindSR(_registerIndex, gpuTexture);
break;
}
default:
#if !BUILD_RELEASE
LOG(Warning, "Invalid Gameplay Global '{}' ({}) value type '{}' to bind to material", _name, _asAsset->GetPath(), e->Value.Type.ToString());
+2 -2
View File
@@ -1317,8 +1317,8 @@ MaterialBase* AnimatedModel::GetMaterial(int32 entryIndex)
SkinnedModel->WaitForLoaded();
else
return nullptr;
CHECK_RETURN(entryIndex >= 0 && entryIndex < Entries.Count(), nullptr);
MaterialBase* material = Entries[entryIndex].Material.Get();
CHECK_RETURN(entryIndex >= 0 && entryIndex < SkinnedModel->MaterialSlots.Count(), nullptr);
MaterialBase* material = entryIndex < Entries.Count() ? Entries[entryIndex].Material.Get() : nullptr;
if (!material)
{
material = SkinnedModel->MaterialSlots[entryIndex].Material.Get();
@@ -39,6 +39,9 @@ void ModelInstanceActor::SetMaterial(int32 entryIndex, MaterialBase* material)
WaitForModelLoad();
if (Entries.Count() == 0 && !material)
return;
const int32 slotsCount = GetMaterialSlots().Length();
if (Entries.Count() != slotsCount)
Entries.Setup(slotsCount);
CHECK(entryIndex >= 0 && entryIndex < Entries.Count());
if (Entries[entryIndex].Material == material)
return;
@@ -50,6 +53,10 @@ void ModelInstanceActor::SetMaterial(int32 entryIndex, MaterialBase* material)
MaterialInstance* ModelInstanceActor::CreateAndSetVirtualMaterialInstance(int32 entryIndex)
{
WaitForModelLoad();
const int32 slotsCount = GetMaterialSlots().Length();
CHECK_RETURN(entryIndex >= 0 && entryIndex < slotsCount, nullptr);
if (Entries.Count() != slotsCount)
Entries.Setup(slotsCount);
MaterialBase* material = GetMaterial(entryIndex);
CHECK_RETURN(material && !material->WaitForLoaded(), nullptr);
MaterialInstance* result = material->CreateVirtualInstance();
+2 -2
View File
@@ -356,8 +356,8 @@ MaterialBase* SplineModel::GetMaterial(int32 entryIndex)
Model->WaitForLoaded();
else
return nullptr;
CHECK_RETURN(entryIndex >= 0 && entryIndex < Entries.Count(), nullptr);
MaterialBase* material = Entries[entryIndex].Material.Get();
CHECK_RETURN(entryIndex >= 0 && entryIndex < Model->MaterialSlots.Count(), nullptr);
MaterialBase* material = entryIndex < Entries.Count() ? Entries[entryIndex].Material.Get() : nullptr;
if (!material)
{
material = Model->MaterialSlots[entryIndex].Material.Get();
+4 -4
View File
@@ -128,7 +128,7 @@ MaterialBase* StaticModel::GetMaterial(int32 meshIndex, int32 lodIndex) const
Math::IsInRange(meshIndex, 0, model->LODs[lodIndex].Meshes.Count()));
const auto& mesh = model->LODs[lodIndex].Meshes[meshIndex];
const auto materialSlotIndex = mesh.GetMaterialSlotIndex();
MaterialBase* material = Entries[materialSlotIndex].Material.Get();
MaterialBase* material = materialSlotIndex < Entries.Count() ? Entries[materialSlotIndex].Material.Get() : nullptr;
return material ? material : model->MaterialSlots[materialSlotIndex].Material.Get();
}
@@ -586,9 +586,9 @@ MaterialBase* StaticModel::GetMaterial(int32 entryIndex)
{
if (!Model || Model->WaitForLoaded())
return nullptr;
CHECK_RETURN(entryIndex >= 0 && entryIndex < Entries.Count(), nullptr);
MaterialBase* material = Entries[entryIndex].Material.Get();
if (!material && entryIndex < Model->MaterialSlots.Count())
CHECK_RETURN(entryIndex >= 0 && entryIndex < Model->MaterialSlots.Count(), nullptr);
MaterialBase* material = entryIndex < Entries.Count() ? Entries[entryIndex].Material.Get() : nullptr;
if (!material)
{
material = Model->MaterialSlots[entryIndex].Material.Get();
if (!material)
+9 -2
View File
@@ -247,6 +247,13 @@ FORCE_INLINE void ApplyTransform(const Float2& value, Float2& result)
Matrix3x3::Transform2DPoint(value, TransformCached, result);
}
FORCE_INLINE float GetTransformScale()
{
const Float2 axisX(TransformCached.M11, TransformCached.M12);
const Float2 axisY(TransformCached.M21, TransformCached.M22);
return (axisX.Length() + axisY.Length()) * 0.5f;
}
void ApplyTransform(const Rectangle& value, RotatedRectangle& result)
{
const RotatedRectangle rotated(value);
@@ -1464,7 +1471,7 @@ void Render2D::DrawRectangle(const Rectangle& rect, const Color& color1, const C
const auto& mask = ClipLayersStack.Peek().Mask;
float thick = thickness;
thickness *= (TransformCached.M11 + TransformCached.M22 + TransformCached.M33) * 0.3333333f;
thickness *= GetTransformScale();
// When lines thickness is very large, don't use corner caps and place line ends to not overlap
if (thickness > 4.0f)
@@ -1840,7 +1847,7 @@ void DrawLines(const Float2* points, int32 pointsCount, const Color& color1, con
ASSERT(points && pointsCount >= 2);
const auto& mask = ClipLayersStack.Peek().Mask;
thickness *= (TransformCached.M11 + TransformCached.M22 + TransformCached.M33) * 0.3333333f;
thickness *= GetTransformScale();
Render2DDrawCall& drawCall = DrawCalls.AddOne();
drawCall.StartIB = IBIndex;
+12 -7
View File
@@ -228,19 +228,27 @@ namespace FlaxEngine.GUI
float progressNormalized = Mathf.InverseLerp(_minimum, _maximum, _current);
if (progressNormalized > 0.001f)
{
Rectangle barRect = new Rectangle(0, 0, Width * progressNormalized, Height);
Rectangle rect = new Rectangle(0, 0, Width, Height);
BarMargin.ShrinkRectangle(ref rect);
if (rect.Width <= 0.0f || rect.Height <= 0.0f)
return;
Rectangle barRect = rect;
switch (Origin)
{
case BarOrigin.HorizontalLeft:
barRect.Width *= progressNormalized;
break;
case BarOrigin.HorizontalRight:
barRect = new Rectangle(Width - Width * progressNormalized, 0, Width * progressNormalized, Height);
barRect.Width *= progressNormalized;
barRect.X = rect.Right - barRect.Width;
break;
case BarOrigin.VerticalTop:
barRect = new Rectangle(0, 0, Width, Height * progressNormalized);
barRect.Height *= progressNormalized;
break;
case BarOrigin.VerticalBottom:
barRect = new Rectangle(0, Height - Height * progressNormalized, Width, Height * progressNormalized);
barRect.Height *= progressNormalized;
barRect.Y = rect.Bottom - barRect.Height;
break;
default: break;
}
@@ -248,15 +256,12 @@ namespace FlaxEngine.GUI
switch (Method)
{
case BarMethod.Stretch:
BarMargin.ShrinkRectangle(ref barRect);
if (BarBrush != null)
BarBrush.Draw(barRect, BarColor);
else
Render2D.FillRectangle(barRect, BarColor);
break;
case BarMethod.Clip:
var rect = new Rectangle(0, 0, Width, Height);
BarMargin.ShrinkRectangle(ref rect);
Render2D.PushClip(ref barRect);
if (BarBrush != null)
BarBrush.Draw(rect, BarColor);