diff --git a/Source/Editor/GUI/Table.cs b/Source/Editor/GUI/Table.cs
index 71b01aa0f..bcb4dd163 100644
--- a/Source/Editor/GUI/Table.cs
+++ b/Source/Editor/GUI/Table.cs
@@ -82,6 +82,53 @@ namespace FlaxEditor.GUI
}
}
+ private bool _alternateRows = true;
+
+ ///
+ /// Gets or sets a value indicating whether alternate row background colors should be applied.
+ ///
+ public bool AlternateRows
+ {
+ get => _alternateRows;
+ set
+ {
+ if (_alternateRows != value)
+ {
+ _alternateRows = value;
+ PerformLayout();
+ }
+ }
+ }
+
+ private Color? _rowColorEven;
+ private Color? _rowColorOdd;
+
+ ///
+ /// Gets or sets the background color of even rows.
+ ///
+ public Color RowColorEven
+ {
+ get => _rowColorEven ?? Color.Transparent;
+ set
+ {
+ _rowColorEven = value;
+ PerformLayout();
+ }
+ }
+
+ ///
+ /// Gets or sets the background color of odd rows.
+ ///
+ public Color RowColorOdd
+ {
+ get => _rowColorOdd ?? (Style.Current != null ? Style.Current.Background * 1.4f : Color.Transparent);
+ set
+ {
+ _rowColorOdd = value;
+ PerformLayout();
+ }
+ }
+
///
/// Initializes a new instance of the class.
///
@@ -250,6 +297,7 @@ namespace FlaxEditor.GUI
// Arrange rows
float y = _headerHeight;
+ int visibleRowIndex = 0;
for (int i = 0; i < Children.Count; i++)
{
var c = Children[i];
@@ -260,6 +308,12 @@ namespace FlaxEditor.GUI
bounds.Y = y;
c.Bounds = bounds;
y += bounds.Height + 1;
+
+ if (_alternateRows && c is Row row)
+ {
+ row.BackgroundColor = visibleRowIndex % 2 == 1 ? RowColorOdd : RowColorEven;
+ visibleRowIndex++;
+ }
}
}
diff --git a/Source/Editor/Windows/Profiler/Assets.cs b/Source/Editor/Windows/Profiler/Assets.cs
index e4e41c668..8ee6f5f6d 100644
--- a/Source/Editor/Windows/Profiler/Assets.cs
+++ b/Source/Editor/Windows/Profiler/Assets.cs
@@ -80,6 +80,8 @@ namespace FlaxEditor.Windows.Profiler
var textColor = style.Foreground;
_table = new Table
{
+ RowColorEven = Color.Transparent,
+ RowColorOdd = style.Background * 1.4f,
Columns = new[]
{
new ColumnDefinition
@@ -242,8 +244,6 @@ namespace FlaxEditor.Windows.Profiler
var resourcesOrdered = resources.OrderByDescending(x => x.MemoryUsage);
// Add rows
- var rowColor2 = Style.Current.Background * 1.4f;
- int rowIndex = 0;
foreach (var e in resourcesOrdered)
{
ClickableRow row;
@@ -271,9 +271,7 @@ namespace FlaxEditor.Windows.Profiler
// Add row to the table
row.Width = _table.Width;
- row.BackgroundColor = rowIndex % 2 == 1 ? rowColor2 : Color.Transparent;
row.Parent = _table;
- rowIndex++;
}
}
diff --git a/Source/Editor/Windows/Profiler/CPU.cs b/Source/Editor/Windows/Profiler/CPU.cs
index d034a058b..fad7c4de8 100644
--- a/Source/Editor/Windows/Profiler/CPU.cs
+++ b/Source/Editor/Windows/Profiler/CPU.cs
@@ -106,6 +106,8 @@ namespace FlaxEditor.Windows.Profiler
var textColor = style.Foreground;
_table = new Table
{
+ RowColorEven = Color.Transparent,
+ RowColorOdd = style.Background * 1.4f,
Columns = new[]
{
new ColumnDefinition
@@ -464,7 +466,6 @@ namespace FlaxEditor.Windows.Profiler
float totalTimeMs = _mainChart.SelectedSample;
// Add rows
- var rowColor2 = Style.Current.Background * 1.4f;
for (int j = 0; j < data.Length; j++)
{
var events = data[j].Events;
@@ -540,7 +541,6 @@ namespace FlaxEditor.Windows.Profiler
row.Depth = e.Depth;
row.Width = _table.Width;
row.Visible = e.Depth < 2;
- row.BackgroundColor = i % 2 == 1 ? rowColor2 : Color.Transparent;
row.Parent = _table;
}
}
diff --git a/Source/Editor/Windows/Profiler/GPU.cs b/Source/Editor/Windows/Profiler/GPU.cs
index 5cc9cd681..6abfef5e1 100644
--- a/Source/Editor/Windows/Profiler/GPU.cs
+++ b/Source/Editor/Windows/Profiler/GPU.cs
@@ -83,6 +83,8 @@ namespace FlaxEditor.Windows.Profiler
var textColor = style.Foreground;
_table = new Table
{
+ RowColorEven = Color.Transparent,
+ RowColorOdd = style.Background * 1.4f,
Columns = new[]
{
new ColumnDefinition
@@ -339,7 +341,6 @@ namespace FlaxEditor.Windows.Profiler
float totalTimeMs = _drawTimeGPU.SelectedSample;
// Add rows
- var rowColor2 = Style.Current.Background * 1.4f;
for (int i = 0; i < data.Length; i++)
{
var e = data[i];
@@ -386,7 +387,6 @@ namespace FlaxEditor.Windows.Profiler
row.Depth = e.Depth;
row.Width = _table.Width;
row.Visible = e.Depth < 3;
- row.BackgroundColor = i % 2 == 1 ? rowColor2 : Color.Transparent;
row.Parent = _table;
}
}
diff --git a/Source/Editor/Windows/Profiler/Memory.cs b/Source/Editor/Windows/Profiler/Memory.cs
index a74472a8c..56178acf2 100644
--- a/Source/Editor/Windows/Profiler/Memory.cs
+++ b/Source/Editor/Windows/Profiler/Memory.cs
@@ -84,6 +84,8 @@ namespace FlaxEditor.Windows.Profiler
var textColor = style.Foreground;
_table = new Table
{
+ RowColorEven = Color.Transparent,
+ RowColorOdd = style.Background * 1.4f,
Columns = new[]
{
new ColumnDefinition
@@ -236,7 +238,6 @@ namespace FlaxEditor.Windows.Profiler
});
// Add rows
- var rowColor2 = Style.Current.Background * 1.4f;
for (int i = 0; i < (int)ProfilerMemory.Groups.MAX; i++)
{
var group = _groupOrder[i];
@@ -278,7 +279,6 @@ namespace FlaxEditor.Windows.Profiler
row.BackgroundColors[3] = Color.Red.AlphaMultiplied(Mathf.Min(1, (float)groupCount / totalCount) * 0.5f);
}
row.Width = _table.Width;
- row.BackgroundColor = i % 2 == 1 ? rowColor2 : Color.Transparent;
row.Parent = _table;
var useBackground = group != (int)ProfilerMemory.Groups.Total &&
diff --git a/Source/Editor/Windows/Profiler/MemoryGPU.cs b/Source/Editor/Windows/Profiler/MemoryGPU.cs
index 11b8a1980..76c02888b 100644
--- a/Source/Editor/Windows/Profiler/MemoryGPU.cs
+++ b/Source/Editor/Windows/Profiler/MemoryGPU.cs
@@ -81,6 +81,8 @@ namespace FlaxEditor.Windows.Profiler
var textColor = style.Foreground;
_table = new Table
{
+ RowColorEven = Color.Transparent,
+ RowColorOdd = style.Background * 1.4f,
Columns = new[]
{
new ColumnDefinition
@@ -299,8 +301,6 @@ namespace FlaxEditor.Windows.Profiler
var resourcesOrdered = resources.OrderByDescending(x => x?.MemoryUsage ?? 0);
// Add rows
- var rowColor2 = Style.Current.Background * 1.4f;
- int rowIndex = 0;
foreach (var e in resourcesOrdered)
{
if (e == null)
@@ -335,9 +335,7 @@ namespace FlaxEditor.Windows.Profiler
// Add row to the table
row.Width = _table.Width;
- row.BackgroundColor = rowIndex % 2 == 1 ? rowColor2 : Color.Transparent;
row.Parent = _table;
- rowIndex++;
}
}
diff --git a/Source/Editor/Windows/Profiler/Network.cs b/Source/Editor/Windows/Profiler/Network.cs
index 988398b0c..2a2d542f5 100644
--- a/Source/Editor/Windows/Profiler/Network.cs
+++ b/Source/Editor/Windows/Profiler/Network.cs
@@ -190,7 +190,6 @@ namespace FlaxEditor.Windows.Profiler
var rowCount = Int2.Zero;
if (events != null && events.Length != 0)
{
- var rowColor2 = Style.Current.Background * 1.4f;
for (int i = 0; i < events.Length; i++)
{
var e = events[i];
@@ -230,7 +229,6 @@ namespace FlaxEditor.Windows.Profiler
var table = isRpc ? _tableRpc : _tableRep;
row.Width = table.Width;
- row.BackgroundColor = rowCount[isRpc ? 0 : 1] % 2 == 1 ? rowColor2 : Color.Transparent;
row.Parent = table;
if (isRpc)
rowCount.X++;
@@ -266,6 +264,8 @@ namespace FlaxEditor.Windows.Profiler
var textColor = style.Foreground;
var table = new Table
{
+ RowColorEven = Color.Transparent,
+ RowColorOdd = style.Background * 1.4f,
Columns = new[]
{
new ColumnDefinition
diff --git a/Source/Engine/Foliage/Foliage.cpp b/Source/Engine/Foliage/Foliage.cpp
index 7428a5a8b..fc6458272 100644
--- a/Source/Engine/Foliage/Foliage.cpp
+++ b/Source/Engine/Foliage/Foliage.cpp
@@ -909,7 +909,7 @@ void Foliage::RebuildClusters()
_box = BoundingBox(_transform.Translation, _transform.Translation);
_sphere = BoundingSphere(_transform.Translation, 0.0f);
if (_sceneRenderingKey != -1)
- GetSceneRendering()->UpdateActor(this, _sceneRenderingKey);
+ GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Bounds);
return;
}
diff --git a/Source/Engine/Particles/ParticleEffect.cpp b/Source/Engine/Particles/ParticleEffect.cpp
index 5e11cb2d9..e0fc7ceb9 100644
--- a/Source/Engine/Particles/ParticleEffect.cpp
+++ b/Source/Engine/Particles/ParticleEffect.cpp
@@ -372,7 +372,7 @@ void ParticleEffect::UpdateBounds()
_box = bounds;
BoundingSphere::FromBox(bounds, _sphere);
if (_sceneRenderingKey != -1)
- GetSceneRendering()->UpdateActor(this, _sceneRenderingKey);
+ GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Bounds);
}
void ParticleEffect::Sync()
diff --git a/Source/Engine/Renderer/ShadowsPass.cpp b/Source/Engine/Renderer/ShadowsPass.cpp
index da9f3909a..12848ed47 100644
--- a/Source/Engine/Renderer/ShadowsPass.cpp
+++ b/Source/Engine/Renderer/ShadowsPass.cpp
@@ -404,8 +404,17 @@ public:
// Dirty static objects to redraw when changed (eg. material modification)
if (a->HasStaticFlag(StaticFlags::Shadow))
{
- DirtyStaticBounds(prevBounds);
- DirtyStaticBounds(a->GetSphere());
+ // TODO: skip actors that don't cast shadows (eg. particles)
+ BoundingSphere bounds = a->GetSphere();
+ if (bounds != prevBounds)
+ {
+ // Avoid dirtying twice when bounds are close to each other
+ if (BoundingSphere::NearEqual(bounds, prevBounds, METERS_TO_UNITS_SCALE))
+ BoundingSphere::Merge(bounds, prevBounds, bounds);
+ else
+ DirtyStaticBounds(prevBounds);
+ }
+ DirtyStaticBounds(bounds);
}
else if (flags & StaticFlags)
{