Skip to content

Performance Enhancement: Moved Automap to its Own Physics Layer#2790

Open
Vwing wants to merge 5 commits into
Interkarma:masterfrom
Vwing:optimize-automap
Open

Performance Enhancement: Moved Automap to its Own Physics Layer#2790
Vwing wants to merge 5 commits into
Interkarma:masterfrom
Vwing:optimize-automap

Conversation

@Vwing

@Vwing Vwing commented May 24, 2026

Copy link
Copy Markdown
Contributor

Moved Automap onto its own non-interacting physics layer, so we don't have to constantly enable/disable its game objects. This is a huge performance boost in large dungeons.

Also we now destroy the generated Automap geo immediately on transition to the outside. This could wait, before, because the geo was disabled; but now that we don't disable geo, we need to do it immediately.

EDIT: Ah, it was already on its own physics layer. I just set it non-interacting with other layers and removed all the then-unnecessary-and-super-unperformant enable/disable code.

Moved Automap onto its own non-interacting physics layer, so we don't have to constantly enable/disable its game objects. This is a *huge* performance boost in large dungeons.

Also we now destroy the generated geo immediately on transition to the outside. This could wait, before, because the geo was disabled; but now that we don't disable geo, we need to do it immediately.
@Daneel53

Copy link
Copy Markdown
Collaborator

Will push this one into the next 1.2 Test3.

@RedRoryOTheGlen

Copy link
Copy Markdown
Contributor

Tested on 1.2-Test3, the automap markers and models are detectable by the player's activation raycast. This makes activating actionable objects inconsistent as the raycast may hit the automap model of the object (and result in no activation) or hit the player or compass automap marker model.

To replicate, Privateer's Hold has the lever in the throne room and the hidden switch that rotates the book shelf in the summoning circle room. Both actionable objects are affected by this issue.

Activation check returning automap model of lever (with name manually changed for clarity)
image

Automap markers blocking the activation raycast
image

Excluding the Automap layer from PlayerActivate.playerLayerMask has been tested to solve this issue.

Thanks for your work!

Made sure we keep using the implicit Physics.DefaultRaycastLayers for casts that were using that, but with Automap excluded. Added a PhysicsLayers utility script to expose that mask as a static PhysicsLayers.DefaultRaycastLayersWithoutAutomap.
@Vwing

Vwing commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Glad you caught that. I went ahead and excluded the 'Automap' layer from every raycast that doesn't need to interact with it, PlayerActivate included.

Interkarma#2781 already ignores the Automap layer in DaggerfallMissile and WeaponManager
@Vwing

Vwing commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Undid changes that would've conflicted with #2781, since it already ignores Automap.

Daneel53
Daneel53 previously approved these changes Jun 9, 2026

@Daneel53 Daneel53 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.

This PR was deeply tested into 1.2 Test3 in the same time as RedRoryTheGlen's PR 2781.
Both authors confirm that all is now working as intended.
Both PR are ready to be integrated into the game.

@KABoissonneault KABoissonneault 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.

I'm not sure I understand why every raycast call needed to be modified for this change. It seems like if that's truly necessary, then this change would break any mod using a raycast that's not been modified to exclude the Automap. Can't the Automap be excluded from physics by default, and be enabled only in those sections that need for rays with the automap to block?

Gonna put this PR on blocked while we resolve this

m_ClothInterCollisionStiffness: 0
m_ContactsGeneration: 1
m_LayerCollisionMatrix: fffffefffffffeffffbffefffffffffffffffefffffffefffffffffffffffffffffffefffffffefffffffefffffffefffffffefffffffefffbbffefffffffeffc800fe0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffffefffffffefffffffeff
m_LayerCollisionMatrix: fffbfefffffbfeffffbbfefffffffffffffbfefffffbfefffffffffffffffffffffbfefffffbfeffc804fe0ffffbfefffffbfefffffbfefffbbbfefffffbfeffc800fe0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffbfefffffbfefffffbfefffffbfeff

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.

Could we get some screenshots of what this change looks like from the editor?

@Vwing Vwing Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, here's an animated gif showing before and after the change:

automap-layers

Before: Automap collided with everything
After: Automap only collides with Automap

@Vwing

Vwing commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

It's not entirely necessary, was just being prudent. The only tested-broken cast was in PlayerActivate; trying to select a lever, for instance, would sometimes hit the automap version of that lever.

Unfortunately there isn't a way to make a layer default-excluded from raycasts.

But I could test a couple workarounds that are more constrained to just changing the automap code. Will investigate later this week.

Vwing added 2 commits June 9, 2026 21:40
… geo

This solves the issue where it occasionally consumes raycasts meant to hit e.g. levers.
@Vwing

Vwing commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

@KABoissonneault I have reworked the AutoMap so that it no longer generates its geometry at the same position as the real world geometry. I set the offset to -10,000 in the y, so it's being generated 10 kilometers below the world (Unity units, not game units - Unity units are larger). In cultural reference terms, it is now a "Backrooms" rather than an "Upside Down".

Also reverted all changes to Raycasts.

Tested it out, and levers work as expected. Automap functions as expected. And we still get 30fps performance gains in large dungeons, the goal of this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants