Add inactive mesh instance handling to Layer for faster rendering#4
Closed
Add inactive mesh instance handling to Layer for faster rendering#4
Conversation
Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
…mization Introduce new properties and methods to Layer for handling inactive mesh instances that are fully excluded from renderer loops such as culling, rendering, and shadow casting. This allows for more efficient management of long-term hidden or pooled objects by removing them from active arrays and sets. Key additions: - _inactiveMeshInstances and _inactiveShadowCasters arrays and sets for O(1) lookups. - setMeshInstanceInactive() to activate/deactivate mesh instances. - setMeshInstancesInactive() for batch activation/deactivation. - isMeshInstanceInactive() and getInactiveMeshInstances() accessors. - Updates to add/remove methods to handle both active and inactive collections. This enhancement supports use cases like object pooling, region streaming, or large batches of temporarily unused instances, improving performance by avoiding unnecessary per-frame processing. Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduce inactive mesh instance support in Layer to exclude objects from all renderer loops, enabling efficient long-term deactivation, object pooling, and region streaming without affecting active rendering paths.
Changes
Core
_inactiveMeshInstancesand_inactiveMeshInstancesSet_inactiveShadowCastersand_inactiveShadowCastersSetsetMeshInstanceInactive(meshInstance, inactive)– mark a single mesh instance as inactive/activesetMeshInstancesInactive(meshInstances, inactive)– batch operation for multiple instancesisMeshInstanceInactive(meshInstance)– query inactive stategetInactiveMeshInstances()– retrieve read-only list of inactive mesh instances_removeInactiveShadowCasters(meshInstances)to keep inactive shadow casters in sync when deactivating.clear()to reset inactive caches alongside active lists.Behavior
meshInstancesand any active shadow caster lists, and places it into the inactive collections.Misc
examples/package-lock.jsonto2.9.0-beta.1to reflect changes.Rationale
API and Migration
Tests Plan
setMeshInstanceInactive. Verify:meshInstancesorshadowCastersduring rendering/cullingsetMeshInstanceInactive(..., false)returns items to active lists and rendering resumes as expectedsetMeshInstancesInactiveand confirm state changes reflect correctly.isMeshInstanceInactiveandgetInactiveMeshInstancesreport accurate state.Notes
castShadowat the time of reactivation.🌿 Generated by Terry
ℹ️ Tag @terragon-labs to ask questions and address PR feedback
📎 Task: https://www.terragonlabs.com/task/b8f2a3b7-9092-4396-9ba9-7baa450b0bbf