1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! Building trees off the main thread: [`BuildInBackground`].
use *;
use Reflect;
use check_ready;
use ;
/// Build this tree's meshes in the background, on Bevy's async compute pool, instead of in the
/// frame it is spawned or its [`ProceduralTree`](crate::ProceduralTree) or
/// [`TreeAge`](crate::TreeAge) changes: a game that plants trees as the player walks (a streamed
/// chunk, a sapling the player plants) does not hitch while they are built.
///
/// A new tree draws nothing (it has no [`TreeRender`](crate::TreeRender) yet) until its first
/// build is done, usually a frame or a few later, and [`TreeGenerated`](crate::TreeGenerated) is
/// sent then; after a change it keeps its old meshes until the new ones are in. A change while a
/// build is under way starts a new one in its place (a change of age waits for it, and the tree
/// is then brought to its age). A [`Growing`](crate::Growing) tree is rebuilt in the background
/// at every age too, so it shows each age a frame or two late; grow many trees with
/// [`GpuGrowth`](crate::GpuGrowth), which this also works with (its one build, of the mature
/// tree, goes to the background; ageing it stays in the frame, as it costs a few kilobytes of
/// writes). Pools are unaffected: [`build_pool`](crate::build_pool) is a call of its own.
;
/// The task building a [`BuildInBackground`] tree; `R` is what the CPU or the GPU path builds.
/// Replacing or removing it (or despawning the tree) drops the task, so its result is never
/// applied.
pub ;