Skip to content

Fixed animated group textures not animating#1124

Open
Nickelony wants to merge 8 commits into
developfrom
Nickelony/Fix-Animated-Group-Textures
Open

Fixed animated group textures not animating#1124
Nickelony wants to merge 8 commits into
developfrom
Nickelony/Fix-Animated-Group-Textures

Conversation

@Nickelony

@Nickelony Nickelony commented Feb 12, 2026

Copy link
Copy Markdown
Collaborator

This pull request introduces robust support for animated texture sub-areas - enabling tools that apply textures to only a portion of an animated frame (such as group texturing) to work seamlessly. The changes include a new utility for matching and generating sub-area animation sets, cache key structures for deduplication, and integration with both the general and TombEngine-specific texture managers. Additionally, some redundant code related to resetting texture parent areas was removed.

Animated texture sub-area support:

  • Added AnimatedTextureLookupUtility with methods for matching, quantizing, and generating sub-area animation sets, as well as a SubAreaKey struct for deduplicating sub-area lookups. (TombLib/TombLib/LevelData/Compilers/AnimatedTextureLookupUtility.cs)
  • Integrated sub-area animated texture matching and lookup generation into both TexInfoManager and TombEngineTexInfoManager, including logic to handle only compatible animation types and prevent redundant processing via _processedSubAreas. (TombLib/TombLib/LevelData/Compilers/Util/TexInfoManager.cs, TombLib/TombLib/LevelData/Compilers/TombEngine/TombEngineTexInfoManager.cs) [1] [2] [3] [4] [5]
  • Modified the animated lookup generation to accept a isForRoom parameter, ensuring correct scoping of generated lookups. (TombLib/TombLib/LevelData/Compilers/Util/TexInfoManager.cs) [1] [2]

Code cleanup and bug fixes:

  • Removed unnecessary resetting of texture.ParentArea before applying textures, preventing accidental loss of parent area information needed for sub-area matching. (TombEditor/EditorActions.cs) [1] [2]

Dependency management:

  • Added missing using directive for the new utility in TexInfoManager. (TombLib/TombLib/LevelData/Compilers/Util/TexInfoManager.cs)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a compiler-side issue where animated textures applied as sub-areas (via group texturing tools using ParentArea) were not being recognized as animated, causing them to compile as static textures instead.

Changes:

  • Detects textures with a non-zero ParentArea and attempts to match them against reference animated textures using reconstructed “full-frame” UVs.
  • When a match is found, synthesizes a sub-area AnimatedTextureSet, generates lookup entries for it, and retries AddTexture so the sub-area can be treated as animated.
  • Implements the same logic in both the classic TR compiler texinfo manager and the TombEngine texinfo manager.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 10 comments.

File Description
TombLib/TombLib/LevelData/Compilers/Util/TexInfoManager.cs Adds sub-area animated-texture detection + synthetic sub-animation lookup generation for classic/TR compilers.
TombLib/TombLib/LevelData/Compilers/TombEngine/TombEngineTexInfoManager.cs Mirrors the sub-area animated-texture handling for TombEngine texture compilation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread TombLib/TombLib/LevelData/Compilers/TombEngine/TombEngineTexInfoManager.cs Outdated
Comment thread TombLib/TombLib/LevelData/Compilers/TombEngine/TombEngineTexInfoManager.cs Outdated
Comment thread TombLib/TombLib/LevelData/Compilers/Util/TexInfoManager.cs Outdated
Comment thread TombLib/TombLib/LevelData/Compilers/Util/TexInfoManager.cs Outdated
Comment thread TombLib/TombLib/LevelData/Compilers/Util/TexInfoManager.cs Outdated
Comment thread TombLib/TombLib/LevelData/Compilers/TombEngine/TombEngineTexInfoManager.cs Outdated
Comment thread TombLib/TombLib/LevelData/Compilers/TombEngine/TombEngineTexInfoManager.cs Outdated
Comment thread TombLib/TombLib/LevelData/Compilers/TombEngine/TombEngineTexInfoManager.cs Outdated
Comment thread TombLib/TombLib/LevelData/Compilers/Util/TexInfoManager.cs Outdated
Comment thread TombLib/TombLib/LevelData/Compilers/Util/TexInfoManager.cs Outdated
@Nickelony
Nickelony marked this pull request as draft February 23, 2026 18:56
@Nickelony Nickelony changed the title Fixed animated group textures not animating WIP: Fixed animated group textures not animating Feb 23, 2026
@Nickelony Nickelony added work in progress The Pull Request is not finished yet or needs some extra work done to it. labels Feb 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread TombLib/TombLib/LevelData/Compilers/Util/TexInfoManager.cs
Comment thread TombLib/TombLib/LevelData/Compilers/Util/TexInfoManager.cs Outdated
Comment thread TombLib/TombLib/LevelData/Compilers/TombEngine/TombEngineTexInfoManager.cs Outdated
Comment thread TombLib/TombLib/LevelData/Compilers/TombEngine/TombEngineTexInfoManager.cs Outdated
Comment thread TombLib/TombLib/LevelData/Compilers/TombEngine/TombEngineTexInfoManager.cs Outdated
@Nickelony Nickelony changed the title WIP: Fixed animated group textures not animating Fixed animated group textures not animating Mar 22, 2026
@Nickelony
Nickelony marked this pull request as ready for review March 22, 2026 21:56
@Nickelony Nickelony added ready for review The Pull Request is finished and ready for review. and removed work in progress The Pull Request is not finished yet or needs some extra work done to it. labels Mar 22, 2026
@Nickelony
Nickelony requested a review from Copilot March 22, 2026 21:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread TombLib/TombLib/LevelData/Compilers/Util/TexInfoManager.cs Outdated
Comment thread TombLib/TombLib/LevelData/Compilers/TombEngine/TombEngineTexInfoManager.cs Outdated
Comment thread TombLib/TombLib/LevelData/Compilers/Util/TexInfoManager.cs Outdated
Comment thread TombLib/TombLib/LevelData/Compilers/Util/TexInfoManager.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread TombLib/TombLib/LevelData/Compilers/TombEngine/TombEngineTexInfoManager.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Nickelony

Copy link
Copy Markdown
Collaborator Author

This PR is now complete and ready for review.

@Nickelony Nickelony added this to the Version 2.0 milestone Mar 23, 2026
@Nickelony Nickelony added the enhancement A task which adds something new or improves on existing features. label Mar 23, 2026
Comment thread TombEditor/EditorActions.cs
Comment thread TombEditor/EditorActions.cs
GenerateAnimTexture(refTex, refQuad, destination, isForTriangle);
var result = AddTexture(texture, destination, isForTriangle, blendMode);
{
result.Animated = true;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really understanding where this flag is now checked, or why it was removed. Please describe.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Animated flag is consumed when polygons are emitted (Result.CreateTombEnginePolygon3/4 set polygon.Animated = Animated). In the sub-area retry path, forcing result.Animated = true was removed so animation is now determined by the recursive AddTexture(...) match result instead of being forced, preventing incorrect animated marking on fallback paths. Commit: f875ab2.

}
}

// Check if this is a sub-area of an animated texture (e.g. applied via group texturing tools).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this to a helper method to avoid clutter in the parent function?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. I moved the sub-area animated-texture block out of AddTexture(...) into a dedicated helper method (TryAddSubAreaAnimatedTexture(...)) to reduce clutter and keep the parent function focused. Commit: f875ab2.

/// <param name="rect">The rectangle to normalize.</param>
/// <param name="margin">The quantization step used by animated texture lookup comparisons.</param>
/// <returns>A rectangle snapped to the lookup grid defined by <paramref name="margin"/>.</returns>
public static Rectangle2 NormalizeLookupRectangle(Rectangle2 rect, float margin) => new(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this to be public?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I reduced visibility in AnimatedTextureLookupUtility: members used only within the type are now private, and cross-type helpers are internal (no unnecessary public). Commit: f875ab2.

/// <param name="first">The first texture to compare.</param>
/// <param name="second">The second texture to compare.</param>
/// <returns><see langword="true"/> when both textures resolve to the same identity; otherwise <see langword="false"/>.</returns>
public static bool AreEquivalentTextures(Texture first, Texture second)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated accordingly: methods in AnimatedTextureLookupUtility are no longer unnecessarily public; they’re now private/internal based on actual usage. Commit: f875ab2.

/// </summary>
/// <param name="texture">The texture whose identity hash should be computed.</param>
/// <returns>A hash code suitable for deduplication keys.</returns>
public static int GetTextureIdentityHash(Texture texture)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, and for all other public methods that are not used outside the class.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied across the utility: non-external methods were tightened to private/internal so only required surface area remains exposed. Commit: f875ab2.

@MontyTRC89 MontyTRC89 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To test for performance with big levels

@MontyTRC89 MontyTRC89 modified the milestones: Version 2.0, Version 2.1 Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement A task which adds something new or improves on existing features. ready for review The Pull Request is finished and ready for review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants