Skip to content

Commit

Permalink
IDB updates now happen in IDB rather than in Draw.
Browse files Browse the repository at this point in the history
  • Loading branch information
vchelaru committed Jan 21, 2024
1 parent ce0d908 commit a420394
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 14 deletions.
15 changes: 1 addition & 14 deletions Engines/FlatRedBallXNA/FlatRedBall/Graphics/Renderer.Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,7 @@ private static void DrawMixed(SpriteList spriteListUnfiltered, SortType sortType
// DRAWABLE BATCHES: Only DrawableBatches remain so draw them all.
while (batchIndex < mVisibleBatches.Count)
{
IDrawableBatch batchAtIndex = mVisibleBatches[batchIndex];
if (mUpdateDrawableBatches && batchAtIndex.UpdateEveryFrame)
{
batchAtIndex.Update();
}
var batchAtIndex = mVisibleBatches[batchIndex];

if (Renderer.RecordRenderBreaks)
{
Expand Down Expand Up @@ -633,11 +629,6 @@ private static void DrawMixed(SpriteList spriteListUnfiltered, SortType sortType
{
IDrawableBatch batchAtIndex = mVisibleBatches[batchIndex];

if (mUpdateDrawableBatches && batchAtIndex.UpdateEveryFrame)
{
batchAtIndex.Update();
}

if(Renderer.RecordRenderBreaks)
{
// Even though we aren't using a RenderBreak here, we should record a render break
Expand Down Expand Up @@ -1149,10 +1140,6 @@ private static void DrawUnlayeredObjects(Camera camera, RenderMode renderMode, S

foreach (var drawableBatch in SpriteManager.mZBufferedDrawableBatches)
{
if (drawableBatch.UpdateEveryFrame)
{
drawableBatch.Update();
}
drawableBatch.Draw(camera);
}

Expand Down
45 changes: 45 additions & 0 deletions Engines/FlatRedBallXNA/FlatRedBall/SpriteManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,14 @@ public static class SpriteManager
static PositionedObjectList<SpriteFrame> mSpriteFrames;
static ReadOnlyCollection<SpriteFrame> mSpriteFramesReadOnly;

/// <summary>
/// Unlayered, sorted drawable batches
/// </summary>
static List<IDrawableBatch> mDrawableBatches;

/// <summary>
/// Unlayered, ZBuffered drawable batches
/// </summary>
static internal List<IDrawableBatch> mZBufferedDrawableBatches = new List<IDrawableBatch>();
static ReadOnlyCollection<IDrawableBatch> mDrawableBatchesReadOnlyCollection;

Expand Down Expand Up @@ -2984,6 +2991,44 @@ public static void Update(Section section )
mSpriteFrames[i].Manage();
}

// January 21,2024
// This used to be handled
// in Renderer, but now we want
// to have this happen before CustomActivity
// so that updating collision will properly use
// animation state.
if(Renderer.UpdateDrawableBatches)
{
for(int i = 0; i < mDrawableBatches.Count; i++)
{
var batch = mDrawableBatches[i];
if(batch.UpdateEveryFrame)
{
batch.Update();
}
}
for(int i = 0; i < mZBufferedDrawableBatches.Count; i++)
{
var batch = mZBufferedDrawableBatches[i];
if (batch.UpdateEveryFrame)
{
batch.Update();
}
}
for (int i = 0; i < mLayers.Count; i++)
{
var layer = mLayers[i];
for(int idbIndex = 0; idbIndex < layer.Batches.Count; i++)
{
var batch = layer.Batches[idbIndex];
if (batch.UpdateEveryFrame)
{
batch.Update();
}
}
}
}

if (section != null)
{
Section.EndContextAndTime();
Expand Down

0 comments on commit a420394

Please sign in to comment.