You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update creator docs to reflect improved sleep system (#1242)
## Changes
Update the creator docs to reflect recent improvements to the sleep
system. This [forum
post](https://devforum.roblox.com/t/improved-sleep-system-enhancing-accuracy-consistency-and-performance/3587885)
details the improvements.
## Checks
By submitting your pull request for review, you agree to the following:
- [x] This contribution was created in whole or in part by me, and I
have the right to submit it under the terms of this repository's open
source licenses.
- [x] I understand and agree that this contribution and a record of it
are public, maintained indefinitely, and may be redistributed under the
terms of this repository's open source licenses.
- [x] To the best of my knowledge, all proposed changes are accurate.
---------
Co-authored-by: IgnisRBX <[email protected]>
Copy file name to clipboardExpand all lines: content/en-us/physics/sleep-system.md
+50-32Lines changed: 50 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,36 +9,38 @@ Assemblies can be connected together with [mechanical constraints](../physics/me
9
9
10
10
## Sleep states
11
11
12
-
Each assembly can be in one of three states: [awake](#awake), [sleep‑checking](#sleep-checking), or [sleeping](#sleeping).
12
+
Each assembly can be in one of three states: [awake](#awake), [sleeping](#sleeping), or [sleep‑checking](#sleep-checking).
13
13
14
14
### Awake
15
15
16
-
An **awake** assembly is moving or accelerating, and is therefore simulated. Assemblies enter this state from situations outlined in [sleep‑checking](#sleep-checking) and [sleeping](#sleeping), as well as [additional wake situations](#additional-wake-situations).
17
-
18
-
### Sleep-checking
19
-
20
-
A non-moving assembly that shares a constraint with at least one [awake](#awake) neighboring assembly is put into the **sleep-checking** state and is not simulated. On each worldstep, a sleep-checking assembly checks whether:
21
-
22
-
- The **position deviation** of a neighboring assembly is greater than the [Neighbor Displacement](#threshold-reference) threshold.
23
-
- The product of a neighboring assembly's **acceleration** and current timestep size is greater than the [Neighbor Angular Velocity](#threshold-reference) and/or [Neighbor Linear Velocity](#threshold-reference) threshold.
24
-
25
-
If either of these conditions is true, or under any of the [additional wake situations](#additional-wake-situations), the sleep-checking assembly enters the [awake](#awake) state.
16
+
An **awake** assembly is moving or accelerating, and is therefore simulated. Assemblies enter this state from situations outlined in [sleeping](#sleeping) and [sleep‑checking](#sleep-checking), as well as [additional wake situations](#additional-wake-situations).
26
17
27
18
### Sleeping
28
19
29
20
A **sleeping** assembly is neither moving nor accelerating, and is therefore not simulated.
30
21
31
-
An assembly is determined to be non-moving by checking its **position deviation**, calculated as the maximum deviation from the average position of the point furthest from its center of mass over the most recent set of worldsteps. If this deviation is greater than the [Displacement](#threshold-reference) threshold, the assembly enters the [awake](#awake) state.
22
+
An assembly is determined to be non-moving by checking its **linear velocity** and **rotational velocity**. If its linear velocity is less than the [Linear Velocity](#threshold-reference) threshold and its rotational velocity is less than the [Rotational Velocity](#threshold-reference) threshold, the assembly is considered to be non-moving.
32
23
33
-
In some cases, simply checking for non-movement would cause an assembly to incorrectly enter the sleeping state. For example, if a ball is thrown straight up, its position barely changes for a number of worldsteps as it approaches its maximum height, making it a candidate to sleep and never fall back down. To handle such cases, the engine monitors whether the product of the assembly's acceleration and current timestep size exceeds the [Linear Velocity](#threshold-reference) and/or [Angular Velocity](#threshold-reference)threshold.
24
+
In some cases, simply checking for non-movement would cause an assembly to incorrectly enter the sleeping state. For example, if a ball is thrown straight up, its velocity approaches zero as it reaches its maximum height, making it a candidate to sleep and never fall back down. To handle such cases, the engine considers an assembly to be accelerating if its **linear acceleration** or **rotational acceleration** are greater than the [Linear Acceleration](#threshold-reference) and[Rotational Acceleration](#threshold-reference)thresholds, respectively, and will prevent the assembly from falling asleep.
34
25
35
26
<Alertseverity="info">
36
27
If an assembly falls asleep when you expect it to remain awake, it's commonly because the assembly is moving too slowly. In addition to automatic checks outlined in [sleep‑checking](#sleep-checking) and [sleeping](#sleeping), you can forcibly wake up an assembly through the conditions outlined in [additional wake situations](#additional-wake-situations).
37
28
</Alert>
38
29
30
+
### Sleep-checking
31
+
32
+
A non-moving assembly that shares a constraint with at least one [awake](#awake) neighboring assembly is put into the **sleep-checking** state and is not simulated. On each worldstep, a sleep-checking assembly checks whether:
33
+
34
+
- Its **linear acceleration** is greater than the [Wake Linear Acceleration](#threshold-reference) threshold.
35
+
- Its **rotational acceleration** is greater than the [Wake Rotational Acceleration](#threshold-reference) threshold.
36
+
- A neighboring assembly's **linear velocity** is greater than the [Neighbor Linear Velocity](#threshold-reference) threshold.
37
+
- A neighboring assembly's **rotational velocity** is greater than the [Neighbor Rotational Velocity](#threshold-reference) threshold.
38
+
39
+
If any of these conditions is true, or under any of the [additional wake situations](#additional-wake-situations), the sleep-checking assembly enters the [awake](#awake) state.
40
+
39
41
## Threshold reference
40
42
41
-
The following table provides the various displacement and velocity thresholds used to determine if an assembly is moving or accelerating.
43
+
The following table provides the various velocity and acceleration thresholds used to determine if an assembly is moving or accelerating.
42
44
43
45
<table>
44
46
<thead>
@@ -50,43 +52,59 @@ The following table provides the various displacement and velocity thresholds us
Rotational velocity and acceleration thresholds reflect the velocity and acceleration of a point located on the assembly bounding sphere (a sphere that contains all of the parts in an assembly) that moves rigidly with the assembly.
98
+
99
+
<Alertseverity="info">
100
+
For a given angular velocity, the rotational velocity of an assembly is proportional to the assembly bounding sphere radius. This means that larger assemblies can rotate at a lower angular velocity without falling asleep.
101
+
</Alert>
102
+
85
103
## Additional wake situations
86
104
87
105
In addition to situations outlined in [sleep‑checking](#sleep-checking) and [sleeping](#sleeping), an assembly enters the [awake](#awake) state when:
88
106
89
-
- It collides with another assembly.
107
+
- It collides with another assembly moving faster than 1 studs/s.
90
108
- Any physics-related property of any `Class.BasePart` within the assembly changes, including:
0 commit comments