Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADR 256: static entities #281

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions content/ADR-256-static-entities.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
layout: adr
adr: 256
title: Static Entities
date: 2025-01-03
status: Draft
type: RFC
spdx-license: CC0-1.0
authors:
- nearnshaw
---

# Abstract

Make it possible for creators to mark an entity as **Static**. Static entities are expected to not change position, perform animations, etc.

Each engine can handle this as they see best, but there are surely many opportunities for optimizing in all cases.

# Context

All game engines have some equivalent concept. Knowing which entities are certain to not move or change over time can enable many engine-side optimizations, these can involve lighting, colliders, etc.

In most scenes, it's common for most of the environment to not need to change over time, and often the environment contains most of the triangles and textures in the scene. For example on Genesis Plaza, we mostly only need to make the NPCs, doors, and elevators non-static.

# Proposal

Add an additional field to the `Transform` component, a `static` boolean. This should be _false_ by default.

If an entity is marked as static, we expect to not see any of the following:

- Any change in the `Transform`
- Any change in `Material`, or if the material has a `VideoTexture`
- Any change in `GltfContainer` or `MeshRenderer`
- Any change in `Visibility`
- An `Animator`
- A `Tween` or `TweenSequence`
- A `Billboard`

If a creator makes the mistake of marking an entity as static but then also does one of the forbidden things listed above, each engine is free to handle that as it wishes. Ideally instructions should be ignored by the engine, to potentially avoid glitchy-looking effects. When this happens, the SDK should print an error message to console.

All static entities should be instanced on the scene's first frame, either as part of a `.composite` file (that is created by interacting with the Creator Hub UI) or instanced on the `main()` function. A static entity should remain static for all of the scene's lifecycle, it can't be removed or switched back to non-static, since several engine optimizations might be relying on this state being permanent.

Note: As an alternative approach, we also discussed handling this via a separate new `Static` component instead of a new field on the `Transform` component. There are pros and cons to each approach.

- On one hand, an extra field on the Transform adds a slight overhead to each update message regarding any transform. (Although if the value of its corresponding protobuff digit is 1, then there should be no Transform updates beyond the initial creation)
- On the other hand, it's easier to creators to find where to add this property if it exists on the Transform. Any object that makes sense to make static will always have a Transform anyway.

Choose a reason for hiding this comment

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

I'd choose Static component rather than an extra bool in Transform.

  1. Static feature affect many other components beside Transform, it makes more sense to implement it as a new component in my opinion
  2. I'd say that it would affect L-caching performance on engine's side because each extra field makes an array of structures bigger and it turns to handle less components at the time. But this aspect could be easily optimised


# Conclusion

The change to the protocol required is minimal, just one boolean to the already existing Transform. There are however many corner cases to be mindful of.
Loading