mirror of
https://github.com/bevyengine/bevy
synced 2024-11-21 20:23:28 +00:00
Use en-us
locale for typos
(#16037)
# Objective Bevy seems to want to standardize on "American English" spellings. Not sure if this is laid out anywhere in writing, but see also #15947. While perusing the docs for `typos`, I noticed that it has a `locale` config option and tried it out. ## Solution Switch to `en-us` locale in the `typos` config and run `typos -w` ## Migration Guide The following methods or fields have been renamed from `*dependants*` to `*dependents*`. - `ProcessorAssetInfo::dependants` - `ProcessorAssetInfos::add_dependant` - `ProcessorAssetInfos::non_existent_dependants` - `AssetInfo::dependants_waiting_on_load` - `AssetInfo::dependants_waiting_on_recursive_dep_load` - `AssetInfos::loader_dependants` - `AssetInfos::remove_dependants_and_labels`
This commit is contained in:
parent
472bbaae26
commit
30d84519a2
58 changed files with 191 additions and 190 deletions
|
@ -3327,11 +3327,11 @@ doc-scrape-examples = true
|
||||||
hidden = true
|
hidden = true
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
name = "minimising"
|
name = "minimizing"
|
||||||
path = "tests/window/minimising.rs"
|
path = "tests/window/minimizing.rs"
|
||||||
doc-scrape-examples = true
|
doc-scrape-examples = true
|
||||||
|
|
||||||
[package.metadata.example.minimising]
|
[package.metadata.example.minimizing]
|
||||||
hidden = true
|
hidden = true
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
|
|
|
@ -24,7 +24,7 @@ pub(crate) fn trigger_animation_event(
|
||||||
|
|
||||||
/// An event that can be used with animations.
|
/// An event that can be used with animations.
|
||||||
/// It can be derived to trigger as an observer event,
|
/// It can be derived to trigger as an observer event,
|
||||||
/// if you need more complex behaviour, consider
|
/// if you need more complex behavior, consider
|
||||||
/// a manual implementation.
|
/// a manual implementation.
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
|
|
|
@ -52,7 +52,7 @@ fn js_value_to_err(context: &str) -> impl FnOnce(JsValue) -> std::io::Error + '_
|
||||||
|
|
||||||
impl HttpWasmAssetReader {
|
impl HttpWasmAssetReader {
|
||||||
async fn fetch_bytes<'a>(&self, path: PathBuf) -> Result<impl Reader, AssetReaderError> {
|
async fn fetch_bytes<'a>(&self, path: PathBuf) -> Result<impl Reader, AssetReaderError> {
|
||||||
// The JS global scope includes a self-reference via a specialising name, which can be used to determine the type of global context available.
|
// The JS global scope includes a self-reference via a specializing name, which can be used to determine the type of global context available.
|
||||||
let global: Global = js_sys::global().unchecked_into();
|
let global: Global = js_sys::global().unchecked_into();
|
||||||
let promise = if !global.window().is_undefined() {
|
let promise = if !global.window().is_undefined() {
|
||||||
let window: web_sys::Window = global.unchecked_into();
|
let window: web_sys::Window = global.unchecked_into();
|
||||||
|
|
|
@ -670,7 +670,7 @@ impl AssetProcessor {
|
||||||
}
|
}
|
||||||
|
|
||||||
for dependency in dependencies {
|
for dependency in dependencies {
|
||||||
asset_infos.add_dependant(&dependency, asset_path.clone());
|
asset_infos.add_dependent(&dependency, asset_path.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1137,7 +1137,7 @@ pub enum ProcessStatus {
|
||||||
pub(crate) struct ProcessorAssetInfo {
|
pub(crate) struct ProcessorAssetInfo {
|
||||||
processed_info: Option<ProcessedInfo>,
|
processed_info: Option<ProcessedInfo>,
|
||||||
/// Paths of assets that depend on this asset when they are being processed.
|
/// Paths of assets that depend on this asset when they are being processed.
|
||||||
dependants: HashSet<AssetPath<'static>>,
|
dependents: HashSet<AssetPath<'static>>,
|
||||||
status: Option<ProcessStatus>,
|
status: Option<ProcessStatus>,
|
||||||
/// A lock that controls read/write access to processed asset files. The lock is shared for both the asset bytes and the meta bytes.
|
/// A lock that controls read/write access to processed asset files. The lock is shared for both the asset bytes and the meta bytes.
|
||||||
/// _This lock must be locked whenever a read or write to processed assets occurs_
|
/// _This lock must be locked whenever a read or write to processed assets occurs_
|
||||||
|
@ -1161,7 +1161,7 @@ impl Default for ProcessorAssetInfo {
|
||||||
status_sender.set_overflow(true);
|
status_sender.set_overflow(true);
|
||||||
Self {
|
Self {
|
||||||
processed_info: Default::default(),
|
processed_info: Default::default(),
|
||||||
dependants: Default::default(),
|
dependents: Default::default(),
|
||||||
file_transaction_lock: Default::default(),
|
file_transaction_lock: Default::default(),
|
||||||
status: None,
|
status: None,
|
||||||
status_sender,
|
status_sender,
|
||||||
|
@ -1187,13 +1187,13 @@ pub struct ProcessorAssetInfos {
|
||||||
/// The "current" in memory view of the asset space. During processing, if path does not exist in this, it should
|
/// The "current" in memory view of the asset space. During processing, if path does not exist in this, it should
|
||||||
/// be considered non-existent.
|
/// be considered non-existent.
|
||||||
/// NOTE: YOU MUST USE `Self::get_or_insert` or `Self::insert` TO ADD ITEMS TO THIS COLLECTION TO ENSURE
|
/// NOTE: YOU MUST USE `Self::get_or_insert` or `Self::insert` TO ADD ITEMS TO THIS COLLECTION TO ENSURE
|
||||||
/// `non_existent_dependants` DATA IS CONSUMED
|
/// `non_existent_dependents` DATA IS CONSUMED
|
||||||
infos: HashMap<AssetPath<'static>, ProcessorAssetInfo>,
|
infos: HashMap<AssetPath<'static>, ProcessorAssetInfo>,
|
||||||
/// Dependants for assets that don't exist. This exists to track "dangling" asset references due to deleted / missing files.
|
/// Dependents for assets that don't exist. This exists to track "dangling" asset references due to deleted / missing files.
|
||||||
/// If the dependant asset is added, it can "resolve" these dependencies and re-compute those assets.
|
/// If the dependent asset is added, it can "resolve" these dependencies and re-compute those assets.
|
||||||
/// Therefore this _must_ always be consistent with the `infos` data. If a new asset is added to `infos`, it should
|
/// Therefore this _must_ always be consistent with the `infos` data. If a new asset is added to `infos`, it should
|
||||||
/// check this maps for dependencies and add them. If an asset is removed, it should update the dependants here.
|
/// check this maps for dependencies and add them. If an asset is removed, it should update the dependents here.
|
||||||
non_existent_dependants: HashMap<AssetPath<'static>, HashSet<AssetPath<'static>>>,
|
non_existent_dependents: HashMap<AssetPath<'static>, HashSet<AssetPath<'static>>>,
|
||||||
check_reprocess_queue: VecDeque<AssetPath<'static>>,
|
check_reprocess_queue: VecDeque<AssetPath<'static>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1201,9 +1201,9 @@ impl ProcessorAssetInfos {
|
||||||
fn get_or_insert(&mut self, asset_path: AssetPath<'static>) -> &mut ProcessorAssetInfo {
|
fn get_or_insert(&mut self, asset_path: AssetPath<'static>) -> &mut ProcessorAssetInfo {
|
||||||
self.infos.entry(asset_path.clone()).or_insert_with(|| {
|
self.infos.entry(asset_path.clone()).or_insert_with(|| {
|
||||||
let mut info = ProcessorAssetInfo::default();
|
let mut info = ProcessorAssetInfo::default();
|
||||||
// track existing dependants by resolving existing "hanging" dependants.
|
// track existing dependents by resolving existing "hanging" dependents.
|
||||||
if let Some(dependants) = self.non_existent_dependants.remove(&asset_path) {
|
if let Some(dependents) = self.non_existent_dependents.remove(&asset_path) {
|
||||||
info.dependants = dependants;
|
info.dependents = dependents;
|
||||||
}
|
}
|
||||||
info
|
info
|
||||||
})
|
})
|
||||||
|
@ -1217,15 +1217,15 @@ impl ProcessorAssetInfos {
|
||||||
self.infos.get_mut(asset_path)
|
self.infos.get_mut(asset_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_dependant(&mut self, asset_path: &AssetPath<'static>, dependant: AssetPath<'static>) {
|
fn add_dependent(&mut self, asset_path: &AssetPath<'static>, dependent: AssetPath<'static>) {
|
||||||
if let Some(info) = self.get_mut(asset_path) {
|
if let Some(info) = self.get_mut(asset_path) {
|
||||||
info.dependants.insert(dependant);
|
info.dependents.insert(dependent);
|
||||||
} else {
|
} else {
|
||||||
let dependants = self
|
let dependents = self
|
||||||
.non_existent_dependants
|
.non_existent_dependents
|
||||||
.entry(asset_path.clone())
|
.entry(asset_path.clone())
|
||||||
.or_default();
|
.or_default();
|
||||||
dependants.insert(dependant);
|
dependents.insert(dependent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1238,7 +1238,7 @@ impl ProcessorAssetInfos {
|
||||||
match result {
|
match result {
|
||||||
Ok(ProcessResult::Processed(processed_info)) => {
|
Ok(ProcessResult::Processed(processed_info)) => {
|
||||||
debug!("Finished processing \"{:?}\"", asset_path);
|
debug!("Finished processing \"{:?}\"", asset_path);
|
||||||
// clean up old dependants
|
// clean up old dependents
|
||||||
let old_processed_info = self
|
let old_processed_info = self
|
||||||
.infos
|
.infos
|
||||||
.get_mut(&asset_path)
|
.get_mut(&asset_path)
|
||||||
|
@ -1247,15 +1247,15 @@ impl ProcessorAssetInfos {
|
||||||
self.clear_dependencies(&asset_path, old_processed_info);
|
self.clear_dependencies(&asset_path, old_processed_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
// populate new dependants
|
// populate new dependents
|
||||||
for process_dependency_info in &processed_info.process_dependencies {
|
for process_dependency_info in &processed_info.process_dependencies {
|
||||||
self.add_dependant(&process_dependency_info.path, asset_path.to_owned());
|
self.add_dependent(&process_dependency_info.path, asset_path.to_owned());
|
||||||
}
|
}
|
||||||
let info = self.get_or_insert(asset_path);
|
let info = self.get_or_insert(asset_path);
|
||||||
info.processed_info = Some(processed_info);
|
info.processed_info = Some(processed_info);
|
||||||
info.update_status(ProcessStatus::Processed).await;
|
info.update_status(ProcessStatus::Processed).await;
|
||||||
let dependants = info.dependants.iter().cloned().collect::<Vec<_>>();
|
let dependents = info.dependents.iter().cloned().collect::<Vec<_>>();
|
||||||
for path in dependants {
|
for path in dependents {
|
||||||
self.check_reprocess_queue.push_back(path);
|
self.check_reprocess_queue.push_back(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1298,7 +1298,7 @@ impl ProcessorAssetInfos {
|
||||||
full_hash: AssetHash::default(),
|
full_hash: AssetHash::default(),
|
||||||
process_dependencies: vec![],
|
process_dependencies: vec![],
|
||||||
});
|
});
|
||||||
self.add_dependant(dependency.path(), asset_path.to_owned());
|
self.add_dependent(dependency.path(), asset_path.to_owned());
|
||||||
}
|
}
|
||||||
|
|
||||||
let info = self.get_mut(&asset_path).expect("info should exist");
|
let info = self.get_mut(&asset_path).expect("info should exist");
|
||||||
|
@ -1319,13 +1319,13 @@ impl ProcessorAssetInfos {
|
||||||
.broadcast(ProcessStatus::NonExistent)
|
.broadcast(ProcessStatus::NonExistent)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
if !info.dependants.is_empty() {
|
if !info.dependents.is_empty() {
|
||||||
error!(
|
error!(
|
||||||
"The asset at {asset_path} was removed, but it had assets that depend on it to be processed. Consider updating the path in the following assets: {:?}",
|
"The asset at {asset_path} was removed, but it had assets that depend on it to be processed. Consider updating the path in the following assets: {:?}",
|
||||||
info.dependants
|
info.dependents
|
||||||
);
|
);
|
||||||
self.non_existent_dependants
|
self.non_existent_dependents
|
||||||
.insert(asset_path.clone(), info.dependants);
|
.insert(asset_path.clone(), info.dependents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1334,31 +1334,31 @@ impl ProcessorAssetInfos {
|
||||||
async fn rename(&mut self, old: &AssetPath<'static>, new: &AssetPath<'static>) {
|
async fn rename(&mut self, old: &AssetPath<'static>, new: &AssetPath<'static>) {
|
||||||
let info = self.infos.remove(old);
|
let info = self.infos.remove(old);
|
||||||
if let Some(mut info) = info {
|
if let Some(mut info) = info {
|
||||||
if !info.dependants.is_empty() {
|
if !info.dependents.is_empty() {
|
||||||
// TODO: We can't currently ensure "moved" folders with relative paths aren't broken because AssetPath
|
// TODO: We can't currently ensure "moved" folders with relative paths aren't broken because AssetPath
|
||||||
// doesn't distinguish between absolute and relative paths. We have "erased" relativeness. In the short term,
|
// doesn't distinguish between absolute and relative paths. We have "erased" relativeness. In the short term,
|
||||||
// we could do "remove everything in a folder and re-add", but that requires full rebuilds / destroying the cache.
|
// we could do "remove everything in a folder and re-add", but that requires full rebuilds / destroying the cache.
|
||||||
// If processors / loaders could enumerate dependencies, we could check if the new deps line up with a rename.
|
// If processors / loaders could enumerate dependencies, we could check if the new deps line up with a rename.
|
||||||
// If deps encoded "relativeness" as part of loading, that would also work (this seems like the right call).
|
// If deps encoded "relativeness" as part of loading, that would also work (this seems like the right call).
|
||||||
// TODO: it would be nice to log an error here for dependants that aren't also being moved + fixed.
|
// TODO: it would be nice to log an error here for dependents that aren't also being moved + fixed.
|
||||||
// (see the remove impl).
|
// (see the remove impl).
|
||||||
error!(
|
error!(
|
||||||
"The asset at {old} was removed, but it had assets that depend on it to be processed. Consider updating the path in the following assets: {:?}",
|
"The asset at {old} was removed, but it had assets that depend on it to be processed. Consider updating the path in the following assets: {:?}",
|
||||||
info.dependants
|
info.dependents
|
||||||
);
|
);
|
||||||
self.non_existent_dependants
|
self.non_existent_dependents
|
||||||
.insert(old.clone(), core::mem::take(&mut info.dependants));
|
.insert(old.clone(), core::mem::take(&mut info.dependents));
|
||||||
}
|
}
|
||||||
if let Some(processed_info) = &info.processed_info {
|
if let Some(processed_info) = &info.processed_info {
|
||||||
// Update "dependant" lists for this asset's "process dependencies" to use new path.
|
// Update "dependent" lists for this asset's "process dependencies" to use new path.
|
||||||
for dep in &processed_info.process_dependencies {
|
for dep in &processed_info.process_dependencies {
|
||||||
if let Some(info) = self.infos.get_mut(&dep.path) {
|
if let Some(info) = self.infos.get_mut(&dep.path) {
|
||||||
info.dependants.remove(old);
|
info.dependents.remove(old);
|
||||||
info.dependants.insert(new.clone());
|
info.dependents.insert(new.clone());
|
||||||
} else if let Some(dependants) = self.non_existent_dependants.get_mut(&dep.path)
|
} else if let Some(dependents) = self.non_existent_dependents.get_mut(&dep.path)
|
||||||
{
|
{
|
||||||
dependants.remove(old);
|
dependents.remove(old);
|
||||||
dependants.insert(new.clone());
|
dependents.insert(new.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1367,7 +1367,7 @@ impl ProcessorAssetInfos {
|
||||||
.broadcast(ProcessStatus::NonExistent)
|
.broadcast(ProcessStatus::NonExistent)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let dependants: Vec<AssetPath<'static>> = {
|
let dependents: Vec<AssetPath<'static>> = {
|
||||||
let new_info = self.get_or_insert(new.clone());
|
let new_info = self.get_or_insert(new.clone());
|
||||||
new_info.processed_info = info.processed_info;
|
new_info.processed_info = info.processed_info;
|
||||||
new_info.status = info.status;
|
new_info.status = info.status;
|
||||||
|
@ -1375,13 +1375,13 @@ impl ProcessorAssetInfos {
|
||||||
if let Some(status) = new_info.status {
|
if let Some(status) = new_info.status {
|
||||||
new_info.status_sender.broadcast(status).await.unwrap();
|
new_info.status_sender.broadcast(status).await.unwrap();
|
||||||
}
|
}
|
||||||
new_info.dependants.iter().cloned().collect()
|
new_info.dependents.iter().cloned().collect()
|
||||||
};
|
};
|
||||||
// Queue the asset for a reprocess check, in case it needs new meta.
|
// Queue the asset for a reprocess check, in case it needs new meta.
|
||||||
self.check_reprocess_queue.push_back(new.clone());
|
self.check_reprocess_queue.push_back(new.clone());
|
||||||
for dependant in dependants {
|
for dependent in dependents {
|
||||||
// Queue dependants for reprocessing because they might have been waiting for this asset.
|
// Queue dependents for reprocessing because they might have been waiting for this asset.
|
||||||
self.check_reprocess_queue.push_back(dependant);
|
self.check_reprocess_queue.push_back(dependent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1389,11 +1389,11 @@ impl ProcessorAssetInfos {
|
||||||
fn clear_dependencies(&mut self, asset_path: &AssetPath<'static>, removed_info: ProcessedInfo) {
|
fn clear_dependencies(&mut self, asset_path: &AssetPath<'static>, removed_info: ProcessedInfo) {
|
||||||
for old_load_dep in removed_info.process_dependencies {
|
for old_load_dep in removed_info.process_dependencies {
|
||||||
if let Some(info) = self.infos.get_mut(&old_load_dep.path) {
|
if let Some(info) = self.infos.get_mut(&old_load_dep.path) {
|
||||||
info.dependants.remove(asset_path);
|
info.dependents.remove(asset_path);
|
||||||
} else if let Some(dependants) =
|
} else if let Some(dependents) =
|
||||||
self.non_existent_dependants.get_mut(&old_load_dep.path)
|
self.non_existent_dependents.get_mut(&old_load_dep.path)
|
||||||
{
|
{
|
||||||
dependants.remove(asset_path);
|
dependents.remove(asset_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,8 @@ pub(crate) struct AssetInfo {
|
||||||
failed_dependencies: HashSet<UntypedAssetId>,
|
failed_dependencies: HashSet<UntypedAssetId>,
|
||||||
loading_rec_dependencies: HashSet<UntypedAssetId>,
|
loading_rec_dependencies: HashSet<UntypedAssetId>,
|
||||||
failed_rec_dependencies: HashSet<UntypedAssetId>,
|
failed_rec_dependencies: HashSet<UntypedAssetId>,
|
||||||
dependants_waiting_on_load: HashSet<UntypedAssetId>,
|
dependents_waiting_on_load: HashSet<UntypedAssetId>,
|
||||||
dependants_waiting_on_recursive_dep_load: HashSet<UntypedAssetId>,
|
dependents_waiting_on_recursive_dep_load: HashSet<UntypedAssetId>,
|
||||||
/// The asset paths required to load this asset. Hashes will only be set for processed assets.
|
/// The asset paths required to load this asset. Hashes will only be set for processed assets.
|
||||||
/// This is set using the value from [`LoadedAsset`].
|
/// This is set using the value from [`LoadedAsset`].
|
||||||
/// This will only be populated if [`AssetInfos::watching_for_changes`] is set to `true` to
|
/// This will only be populated if [`AssetInfos::watching_for_changes`] is set to `true` to
|
||||||
|
@ -53,8 +53,8 @@ impl AssetInfo {
|
||||||
loading_rec_dependencies: HashSet::default(),
|
loading_rec_dependencies: HashSet::default(),
|
||||||
failed_rec_dependencies: HashSet::default(),
|
failed_rec_dependencies: HashSet::default(),
|
||||||
loader_dependencies: HashMap::default(),
|
loader_dependencies: HashMap::default(),
|
||||||
dependants_waiting_on_load: HashSet::default(),
|
dependents_waiting_on_load: HashSet::default(),
|
||||||
dependants_waiting_on_recursive_dep_load: HashSet::default(),
|
dependents_waiting_on_recursive_dep_load: HashSet::default(),
|
||||||
handle_drops_to_skip: 0,
|
handle_drops_to_skip: 0,
|
||||||
waiting_tasks: Vec::new(),
|
waiting_tasks: Vec::new(),
|
||||||
}
|
}
|
||||||
|
@ -65,12 +65,12 @@ impl AssetInfo {
|
||||||
pub(crate) struct AssetInfos {
|
pub(crate) struct AssetInfos {
|
||||||
path_to_id: HashMap<AssetPath<'static>, TypeIdMap<UntypedAssetId>>,
|
path_to_id: HashMap<AssetPath<'static>, TypeIdMap<UntypedAssetId>>,
|
||||||
infos: HashMap<UntypedAssetId, AssetInfo>,
|
infos: HashMap<UntypedAssetId, AssetInfo>,
|
||||||
/// If set to `true`, this informs [`AssetInfos`] to track data relevant to watching for changes (such as `load_dependants`)
|
/// If set to `true`, this informs [`AssetInfos`] to track data relevant to watching for changes (such as `load_dependents`)
|
||||||
/// This should only be set at startup.
|
/// This should only be set at startup.
|
||||||
pub(crate) watching_for_changes: bool,
|
pub(crate) watching_for_changes: bool,
|
||||||
/// Tracks assets that depend on the "key" asset path inside their asset loaders ("loader dependencies")
|
/// Tracks assets that depend on the "key" asset path inside their asset loaders ("loader dependencies")
|
||||||
/// This should only be set when watching for changes to avoid unnecessary work.
|
/// This should only be set when watching for changes to avoid unnecessary work.
|
||||||
pub(crate) loader_dependants: HashMap<AssetPath<'static>, HashSet<AssetPath<'static>>>,
|
pub(crate) loader_dependents: HashMap<AssetPath<'static>, HashSet<AssetPath<'static>>>,
|
||||||
/// Tracks living labeled assets for a given source asset.
|
/// Tracks living labeled assets for a given source asset.
|
||||||
/// This should only be set when watching for changes to avoid unnecessary work.
|
/// This should only be set when watching for changes to avoid unnecessary work.
|
||||||
pub(crate) living_labeled_assets: HashMap<AssetPath<'static>, HashSet<Box<str>>>,
|
pub(crate) living_labeled_assets: HashMap<AssetPath<'static>, HashSet<Box<str>>>,
|
||||||
|
@ -372,7 +372,7 @@ impl AssetInfos {
|
||||||
Self::process_handle_drop_internal(
|
Self::process_handle_drop_internal(
|
||||||
&mut self.infos,
|
&mut self.infos,
|
||||||
&mut self.path_to_id,
|
&mut self.path_to_id,
|
||||||
&mut self.loader_dependants,
|
&mut self.loader_dependents,
|
||||||
&mut self.living_labeled_assets,
|
&mut self.living_labeled_assets,
|
||||||
&mut self.pending_tasks,
|
&mut self.pending_tasks,
|
||||||
self.watching_for_changes,
|
self.watching_for_changes,
|
||||||
|
@ -380,7 +380,7 @@ impl AssetInfos {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates [`AssetInfo`] / load state for an asset that has finished loading (and relevant dependencies / dependants).
|
/// Updates [`AssetInfo`] / load state for an asset that has finished loading (and relevant dependencies / dependents).
|
||||||
pub(crate) fn process_asset_load(
|
pub(crate) fn process_asset_load(
|
||||||
&mut self,
|
&mut self,
|
||||||
loaded_asset_id: UntypedAssetId,
|
loaded_asset_id: UntypedAssetId,
|
||||||
|
@ -407,7 +407,7 @@ impl AssetInfos {
|
||||||
| RecursiveDependencyLoadState::NotLoaded => {
|
| RecursiveDependencyLoadState::NotLoaded => {
|
||||||
// If dependency is loading, wait for it.
|
// If dependency is loading, wait for it.
|
||||||
dep_info
|
dep_info
|
||||||
.dependants_waiting_on_recursive_dep_load
|
.dependents_waiting_on_recursive_dep_load
|
||||||
.insert(loaded_asset_id);
|
.insert(loaded_asset_id);
|
||||||
}
|
}
|
||||||
RecursiveDependencyLoadState::Loaded => {
|
RecursiveDependencyLoadState::Loaded => {
|
||||||
|
@ -425,7 +425,7 @@ impl AssetInfos {
|
||||||
match dep_info.load_state {
|
match dep_info.load_state {
|
||||||
LoadState::NotLoaded | LoadState::Loading => {
|
LoadState::NotLoaded | LoadState::Loading => {
|
||||||
// If dependency is loading, wait for it.
|
// If dependency is loading, wait for it.
|
||||||
dep_info.dependants_waiting_on_load.insert(loaded_asset_id);
|
dep_info.dependents_waiting_on_load.insert(loaded_asset_id);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
LoadState::Loaded => {
|
LoadState::Loaded => {
|
||||||
|
@ -469,7 +469,7 @@ impl AssetInfos {
|
||||||
(_loading, _failed) => RecursiveDependencyLoadState::Failed(rec_dep_error.unwrap()),
|
(_loading, _failed) => RecursiveDependencyLoadState::Failed(rec_dep_error.unwrap()),
|
||||||
};
|
};
|
||||||
|
|
||||||
let (dependants_waiting_on_load, dependants_waiting_on_rec_load) = {
|
let (dependents_waiting_on_load, dependents_waiting_on_rec_load) = {
|
||||||
let watching_for_changes = self.watching_for_changes;
|
let watching_for_changes = self.watching_for_changes;
|
||||||
// if watching for changes, track reverse loader dependencies for hot reloading
|
// if watching for changes, track reverse loader dependencies for hot reloading
|
||||||
if watching_for_changes {
|
if watching_for_changes {
|
||||||
|
@ -479,11 +479,11 @@ impl AssetInfos {
|
||||||
.expect("Asset info should always exist at this point");
|
.expect("Asset info should always exist at this point");
|
||||||
if let Some(asset_path) = &info.path {
|
if let Some(asset_path) = &info.path {
|
||||||
for loader_dependency in loaded_asset.loader_dependencies.keys() {
|
for loader_dependency in loaded_asset.loader_dependencies.keys() {
|
||||||
let dependants = self
|
let dependents = self
|
||||||
.loader_dependants
|
.loader_dependents
|
||||||
.entry(loader_dependency.clone())
|
.entry(loader_dependency.clone())
|
||||||
.or_default();
|
.or_default();
|
||||||
dependants.insert(asset_path.clone());
|
dependents.insert(asset_path.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -501,22 +501,22 @@ impl AssetInfos {
|
||||||
info.loader_dependencies = loaded_asset.loader_dependencies;
|
info.loader_dependencies = loaded_asset.loader_dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
let dependants_waiting_on_rec_load =
|
let dependents_waiting_on_rec_load =
|
||||||
if rec_dep_load_state.is_loaded() || rec_dep_load_state.is_failed() {
|
if rec_dep_load_state.is_loaded() || rec_dep_load_state.is_failed() {
|
||||||
Some(core::mem::take(
|
Some(core::mem::take(
|
||||||
&mut info.dependants_waiting_on_recursive_dep_load,
|
&mut info.dependents_waiting_on_recursive_dep_load,
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
(
|
(
|
||||||
core::mem::take(&mut info.dependants_waiting_on_load),
|
core::mem::take(&mut info.dependents_waiting_on_load),
|
||||||
dependants_waiting_on_rec_load,
|
dependents_waiting_on_rec_load,
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
for id in dependants_waiting_on_load {
|
for id in dependents_waiting_on_load {
|
||||||
if let Some(info) = self.get_mut(id) {
|
if let Some(info) = self.get_mut(id) {
|
||||||
info.loading_dependencies.remove(&loaded_asset_id);
|
info.loading_dependencies.remove(&loaded_asset_id);
|
||||||
if info.loading_dependencies.is_empty() && !info.dep_load_state.is_failed() {
|
if info.loading_dependencies.is_empty() && !info.dep_load_state.is_failed() {
|
||||||
|
@ -526,20 +526,20 @@ impl AssetInfos {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(dependants_waiting_on_rec_load) = dependants_waiting_on_rec_load {
|
if let Some(dependents_waiting_on_rec_load) = dependents_waiting_on_rec_load {
|
||||||
match rec_dep_load_state {
|
match rec_dep_load_state {
|
||||||
RecursiveDependencyLoadState::Loaded => {
|
RecursiveDependencyLoadState::Loaded => {
|
||||||
for dep_id in dependants_waiting_on_rec_load {
|
for dep_id in dependents_waiting_on_rec_load {
|
||||||
Self::propagate_loaded_state(self, loaded_asset_id, dep_id, sender);
|
Self::propagate_loaded_state(self, loaded_asset_id, dep_id, sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RecursiveDependencyLoadState::Failed(ref error) => {
|
RecursiveDependencyLoadState::Failed(ref error) => {
|
||||||
for dep_id in dependants_waiting_on_rec_load {
|
for dep_id in dependents_waiting_on_rec_load {
|
||||||
Self::propagate_failed_state(self, loaded_asset_id, dep_id, error);
|
Self::propagate_failed_state(self, loaded_asset_id, dep_id, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RecursiveDependencyLoadState::Loading | RecursiveDependencyLoadState::NotLoaded => {
|
RecursiveDependencyLoadState::Loading | RecursiveDependencyLoadState::NotLoaded => {
|
||||||
// dependants_waiting_on_rec_load should be None in this case
|
// dependents_waiting_on_rec_load should be None in this case
|
||||||
unreachable!("`Loading` and `NotLoaded` state should never be propagated.")
|
unreachable!("`Loading` and `NotLoaded` state should never be propagated.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -553,7 +553,7 @@ impl AssetInfos {
|
||||||
waiting_id: UntypedAssetId,
|
waiting_id: UntypedAssetId,
|
||||||
sender: &Sender<InternalAssetEvent>,
|
sender: &Sender<InternalAssetEvent>,
|
||||||
) {
|
) {
|
||||||
let dependants_waiting_on_rec_load = if let Some(info) = infos.get_mut(waiting_id) {
|
let dependents_waiting_on_rec_load = if let Some(info) = infos.get_mut(waiting_id) {
|
||||||
info.loading_rec_dependencies.remove(&loaded_id);
|
info.loading_rec_dependencies.remove(&loaded_id);
|
||||||
if info.loading_rec_dependencies.is_empty() && info.failed_rec_dependencies.is_empty() {
|
if info.loading_rec_dependencies.is_empty() && info.failed_rec_dependencies.is_empty() {
|
||||||
info.rec_dep_load_state = RecursiveDependencyLoadState::Loaded;
|
info.rec_dep_load_state = RecursiveDependencyLoadState::Loaded;
|
||||||
|
@ -563,7 +563,7 @@ impl AssetInfos {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
Some(core::mem::take(
|
Some(core::mem::take(
|
||||||
&mut info.dependants_waiting_on_recursive_dep_load,
|
&mut info.dependents_waiting_on_recursive_dep_load,
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -572,8 +572,8 @@ impl AssetInfos {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(dependants_waiting_on_rec_load) = dependants_waiting_on_rec_load {
|
if let Some(dependents_waiting_on_rec_load) = dependents_waiting_on_rec_load {
|
||||||
for dep_id in dependants_waiting_on_rec_load {
|
for dep_id in dependents_waiting_on_rec_load {
|
||||||
Self::propagate_loaded_state(infos, waiting_id, dep_id, sender);
|
Self::propagate_loaded_state(infos, waiting_id, dep_id, sender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -586,19 +586,19 @@ impl AssetInfos {
|
||||||
waiting_id: UntypedAssetId,
|
waiting_id: UntypedAssetId,
|
||||||
error: &Arc<AssetLoadError>,
|
error: &Arc<AssetLoadError>,
|
||||||
) {
|
) {
|
||||||
let dependants_waiting_on_rec_load = if let Some(info) = infos.get_mut(waiting_id) {
|
let dependents_waiting_on_rec_load = if let Some(info) = infos.get_mut(waiting_id) {
|
||||||
info.loading_rec_dependencies.remove(&failed_id);
|
info.loading_rec_dependencies.remove(&failed_id);
|
||||||
info.failed_rec_dependencies.insert(failed_id);
|
info.failed_rec_dependencies.insert(failed_id);
|
||||||
info.rec_dep_load_state = RecursiveDependencyLoadState::Failed(error.clone());
|
info.rec_dep_load_state = RecursiveDependencyLoadState::Failed(error.clone());
|
||||||
Some(core::mem::take(
|
Some(core::mem::take(
|
||||||
&mut info.dependants_waiting_on_recursive_dep_load,
|
&mut info.dependents_waiting_on_recursive_dep_load,
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(dependants_waiting_on_rec_load) = dependants_waiting_on_rec_load {
|
if let Some(dependents_waiting_on_rec_load) = dependents_waiting_on_rec_load {
|
||||||
for dep_id in dependants_waiting_on_rec_load {
|
for dep_id in dependents_waiting_on_rec_load {
|
||||||
Self::propagate_failed_state(infos, waiting_id, dep_id, error);
|
Self::propagate_failed_state(infos, waiting_id, dep_id, error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -611,7 +611,7 @@ impl AssetInfos {
|
||||||
}
|
}
|
||||||
|
|
||||||
let error = Arc::new(error);
|
let error = Arc::new(error);
|
||||||
let (dependants_waiting_on_load, dependants_waiting_on_rec_load) = {
|
let (dependents_waiting_on_load, dependents_waiting_on_rec_load) = {
|
||||||
let Some(info) = self.get_mut(failed_id) else {
|
let Some(info) = self.get_mut(failed_id) else {
|
||||||
// The asset was already dropped.
|
// The asset was already dropped.
|
||||||
return;
|
return;
|
||||||
|
@ -623,12 +623,12 @@ impl AssetInfos {
|
||||||
waker.wake();
|
waker.wake();
|
||||||
}
|
}
|
||||||
(
|
(
|
||||||
core::mem::take(&mut info.dependants_waiting_on_load),
|
core::mem::take(&mut info.dependents_waiting_on_load),
|
||||||
core::mem::take(&mut info.dependants_waiting_on_recursive_dep_load),
|
core::mem::take(&mut info.dependents_waiting_on_recursive_dep_load),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
for waiting_id in dependants_waiting_on_load {
|
for waiting_id in dependents_waiting_on_load {
|
||||||
if let Some(info) = self.get_mut(waiting_id) {
|
if let Some(info) = self.get_mut(waiting_id) {
|
||||||
info.loading_dependencies.remove(&failed_id);
|
info.loading_dependencies.remove(&failed_id);
|
||||||
info.failed_dependencies.insert(failed_id);
|
info.failed_dependencies.insert(failed_id);
|
||||||
|
@ -639,20 +639,20 @@ impl AssetInfos {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for waiting_id in dependants_waiting_on_rec_load {
|
for waiting_id in dependents_waiting_on_rec_load {
|
||||||
Self::propagate_failed_state(self, failed_id, waiting_id, &error);
|
Self::propagate_failed_state(self, failed_id, waiting_id, &error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove_dependants_and_labels(
|
fn remove_dependents_and_labels(
|
||||||
info: &AssetInfo,
|
info: &AssetInfo,
|
||||||
loader_dependants: &mut HashMap<AssetPath<'static>, HashSet<AssetPath<'static>>>,
|
loader_dependents: &mut HashMap<AssetPath<'static>, HashSet<AssetPath<'static>>>,
|
||||||
path: &AssetPath<'static>,
|
path: &AssetPath<'static>,
|
||||||
living_labeled_assets: &mut HashMap<AssetPath<'static>, HashSet<Box<str>>>,
|
living_labeled_assets: &mut HashMap<AssetPath<'static>, HashSet<Box<str>>>,
|
||||||
) {
|
) {
|
||||||
for loader_dependency in info.loader_dependencies.keys() {
|
for loader_dependency in info.loader_dependencies.keys() {
|
||||||
if let Some(dependants) = loader_dependants.get_mut(loader_dependency) {
|
if let Some(dependents) = loader_dependents.get_mut(loader_dependency) {
|
||||||
dependants.remove(path);
|
dependents.remove(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -676,7 +676,7 @@ impl AssetInfos {
|
||||||
fn process_handle_drop_internal(
|
fn process_handle_drop_internal(
|
||||||
infos: &mut HashMap<UntypedAssetId, AssetInfo>,
|
infos: &mut HashMap<UntypedAssetId, AssetInfo>,
|
||||||
path_to_id: &mut HashMap<AssetPath<'static>, TypeIdMap<UntypedAssetId>>,
|
path_to_id: &mut HashMap<AssetPath<'static>, TypeIdMap<UntypedAssetId>>,
|
||||||
loader_dependants: &mut HashMap<AssetPath<'static>, HashSet<AssetPath<'static>>>,
|
loader_dependents: &mut HashMap<AssetPath<'static>, HashSet<AssetPath<'static>>>,
|
||||||
living_labeled_assets: &mut HashMap<AssetPath<'static>, HashSet<Box<str>>>,
|
living_labeled_assets: &mut HashMap<AssetPath<'static>, HashSet<Box<str>>>,
|
||||||
pending_tasks: &mut HashMap<UntypedAssetId, Task<()>>,
|
pending_tasks: &mut HashMap<UntypedAssetId, Task<()>>,
|
||||||
watching_for_changes: bool,
|
watching_for_changes: bool,
|
||||||
|
@ -703,9 +703,9 @@ impl AssetInfos {
|
||||||
};
|
};
|
||||||
|
|
||||||
if watching_for_changes {
|
if watching_for_changes {
|
||||||
Self::remove_dependants_and_labels(
|
Self::remove_dependents_and_labels(
|
||||||
&info,
|
&info,
|
||||||
loader_dependants,
|
loader_dependents,
|
||||||
path,
|
path,
|
||||||
living_labeled_assets,
|
living_labeled_assets,
|
||||||
);
|
);
|
||||||
|
@ -735,7 +735,7 @@ impl AssetInfos {
|
||||||
Self::process_handle_drop_internal(
|
Self::process_handle_drop_internal(
|
||||||
&mut self.infos,
|
&mut self.infos,
|
||||||
&mut self.path_to_id,
|
&mut self.path_to_id,
|
||||||
&mut self.loader_dependants,
|
&mut self.loader_dependents,
|
||||||
&mut self.living_labeled_assets,
|
&mut self.living_labeled_assets,
|
||||||
&mut self.pending_tasks,
|
&mut self.pending_tasks,
|
||||||
self.watching_for_changes,
|
self.watching_for_changes,
|
||||||
|
|
|
@ -1523,10 +1523,10 @@ pub fn handle_internal_asset_events(world: &mut World) {
|
||||||
infos: &AssetInfos,
|
infos: &AssetInfos,
|
||||||
paths_to_reload: &mut HashSet<AssetPath<'static>>,
|
paths_to_reload: &mut HashSet<AssetPath<'static>>,
|
||||||
) {
|
) {
|
||||||
if let Some(dependants) = infos.loader_dependants.get(asset_path) {
|
if let Some(dependents) = infos.loader_dependents.get(asset_path) {
|
||||||
for dependant in dependants {
|
for dependent in dependents {
|
||||||
paths_to_reload.insert(dependant.to_owned());
|
paths_to_reload.insert(dependent.to_owned());
|
||||||
queue_ancestors(dependant, infos, paths_to_reload);
|
queue_ancestors(dependent, infos, paths_to_reload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ fn fragment(
|
||||||
// This means that for a frame time of 20ms, the shutter is only open for 10ms.
|
// This means that for a frame time of 20ms, the shutter is only open for 10ms.
|
||||||
//
|
//
|
||||||
// Using a shutter angle larger than 1.0 is non-physical, objects would need to move further
|
// Using a shutter angle larger than 1.0 is non-physical, objects would need to move further
|
||||||
// than they physically travelled during a frame, which is not possible. Note: we allow values
|
// than they physically traveled during a frame, which is not possible. Note: we allow values
|
||||||
// larger than 1.0 because it may be desired for artistic reasons.
|
// larger than 1.0 because it may be desired for artistic reasons.
|
||||||
let exposure_vector = shutter_angle * this_motion_vector;
|
let exposure_vector = shutter_angle * this_motion_vector;
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ pub mod internal {
|
||||||
let thread_pool = AsyncComputeTaskPool::get();
|
let thread_pool = AsyncComputeTaskPool::get();
|
||||||
|
|
||||||
// Only queue a new system refresh task when necessary
|
// Only queue a new system refresh task when necessary
|
||||||
// Queueing earlier than that will not give new data
|
// Queuing earlier than that will not give new data
|
||||||
if last_refresh.elapsed() > sysinfo::MINIMUM_CPU_UPDATE_INTERVAL
|
if last_refresh.elapsed() > sysinfo::MINIMUM_CPU_UPDATE_INTERVAL
|
||||||
// These tasks don't yield and will take up all of the task pool's
|
// These tasks don't yield and will take up all of the task pool's
|
||||||
// threads if we don't limit their amount.
|
// threads if we don't limit their amount.
|
||||||
|
|
|
@ -32,7 +32,7 @@ use core::{any::TypeId, ptr::NonNull};
|
||||||
///
|
///
|
||||||
/// Each bundle represents a static set of [`Component`] types.
|
/// Each bundle represents a static set of [`Component`] types.
|
||||||
/// Currently, bundles can only contain one of each [`Component`], and will
|
/// Currently, bundles can only contain one of each [`Component`], and will
|
||||||
/// panic once initialised if this is not met.
|
/// panic once initialized if this is not met.
|
||||||
///
|
///
|
||||||
/// ## Insertion
|
/// ## Insertion
|
||||||
///
|
///
|
||||||
|
|
|
@ -153,7 +153,7 @@ type IdCursor = isize;
|
||||||
reflect(Serialize, Deserialize)
|
reflect(Serialize, Deserialize)
|
||||||
)]
|
)]
|
||||||
// Alignment repr necessary to allow LLVM to better output
|
// Alignment repr necessary to allow LLVM to better output
|
||||||
// optimised codegen for `to_bits`, `PartialEq` and `Ord`.
|
// optimized codegen for `to_bits`, `PartialEq` and `Ord`.
|
||||||
#[repr(C, align(8))]
|
#[repr(C, align(8))]
|
||||||
pub struct Entity {
|
pub struct Entity {
|
||||||
// Do not reorder the fields here. The ordering is explicitly used by repr(C)
|
// Do not reorder the fields here. The ordering is explicitly used by repr(C)
|
||||||
|
@ -170,7 +170,7 @@ pub struct Entity {
|
||||||
impl PartialEq for Entity {
|
impl PartialEq for Entity {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn eq(&self, other: &Entity) -> bool {
|
fn eq(&self, other: &Entity) -> bool {
|
||||||
// By using `to_bits`, the codegen can be optimised out even
|
// By using `to_bits`, the codegen can be optimized out even
|
||||||
// further potentially. Relies on the correct alignment/field
|
// further potentially. Relies on the correct alignment/field
|
||||||
// order of `Entity`.
|
// order of `Entity`.
|
||||||
self.to_bits() == other.to_bits()
|
self.to_bits() == other.to_bits()
|
||||||
|
@ -179,10 +179,10 @@ impl PartialEq for Entity {
|
||||||
|
|
||||||
impl Eq for Entity {}
|
impl Eq for Entity {}
|
||||||
|
|
||||||
// The derive macro codegen output is not optimal and can't be optimised as well
|
// The derive macro codegen output is not optimal and can't be optimized as well
|
||||||
// by the compiler. This impl resolves the issue of non-optimal codegen by relying
|
// by the compiler. This impl resolves the issue of non-optimal codegen by relying
|
||||||
// on comparing against the bit representation of `Entity` instead of comparing
|
// on comparing against the bit representation of `Entity` instead of comparing
|
||||||
// the fields. The result is then LLVM is able to optimise the codegen for Entity
|
// the fields. The result is then LLVM is able to optimize the codegen for Entity
|
||||||
// far beyond what the derive macro can.
|
// far beyond what the derive macro can.
|
||||||
// See <https://github.com/rust-lang/rust/issues/106107>
|
// See <https://github.com/rust-lang/rust/issues/106107>
|
||||||
impl PartialOrd for Entity {
|
impl PartialOrd for Entity {
|
||||||
|
@ -193,10 +193,10 @@ impl PartialOrd for Entity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The derive macro codegen output is not optimal and can't be optimised as well
|
// The derive macro codegen output is not optimal and can't be optimized as well
|
||||||
// by the compiler. This impl resolves the issue of non-optimal codegen by relying
|
// by the compiler. This impl resolves the issue of non-optimal codegen by relying
|
||||||
// on comparing against the bit representation of `Entity` instead of comparing
|
// on comparing against the bit representation of `Entity` instead of comparing
|
||||||
// the fields. The result is then LLVM is able to optimise the codegen for Entity
|
// the fields. The result is then LLVM is able to optimize the codegen for Entity
|
||||||
// far beyond what the derive macro can.
|
// far beyond what the derive macro can.
|
||||||
// See <https://github.com/rust-lang/rust/issues/106107>
|
// See <https://github.com/rust-lang/rust/issues/106107>
|
||||||
impl Ord for Entity {
|
impl Ord for Entity {
|
||||||
|
@ -310,7 +310,7 @@ impl Entity {
|
||||||
|
|
||||||
match id {
|
match id {
|
||||||
Ok(entity) => entity,
|
Ok(entity) => entity,
|
||||||
Err(_) => panic!("Attempted to initialise invalid bits as an entity"),
|
Err(_) => panic!("Attempted to initialize invalid bits as an entity"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use core::fmt;
|
||||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub enum IdentifierError {
|
pub enum IdentifierError {
|
||||||
/// A given ID has an invalid value for initialising to a [`crate::identifier::Identifier`].
|
/// A given ID has an invalid value for initializing to a [`crate::identifier::Identifier`].
|
||||||
InvalidIdentifier,
|
InvalidIdentifier,
|
||||||
/// A given ID has an invalid configuration of bits for converting to an [`crate::entity::Entity`].
|
/// A given ID has an invalid configuration of bits for converting to an [`crate::entity::Entity`].
|
||||||
InvalidEntityId(u64),
|
InvalidEntityId(u64),
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub(crate) mod masks;
|
||||||
#[cfg_attr(feature = "bevy_reflect", reflect(opaque))]
|
#[cfg_attr(feature = "bevy_reflect", reflect(opaque))]
|
||||||
#[cfg_attr(feature = "bevy_reflect", reflect(Debug, Hash, PartialEq))]
|
#[cfg_attr(feature = "bevy_reflect", reflect(Debug, Hash, PartialEq))]
|
||||||
// Alignment repr necessary to allow LLVM to better output
|
// Alignment repr necessary to allow LLVM to better output
|
||||||
// optimised codegen for `to_bits`, `PartialEq` and `Ord`.
|
// optimized codegen for `to_bits`, `PartialEq` and `Ord`.
|
||||||
#[repr(C, align(8))]
|
#[repr(C, align(8))]
|
||||||
pub struct Identifier {
|
pub struct Identifier {
|
||||||
// Do not reorder the fields here. The ordering is explicitly used by repr(C)
|
// Do not reorder the fields here. The ordering is explicitly used by repr(C)
|
||||||
|
@ -49,7 +49,7 @@ impl Identifier {
|
||||||
let packed_high = IdentifierMask::pack_kind_into_high(masked_value, kind);
|
let packed_high = IdentifierMask::pack_kind_into_high(masked_value, kind);
|
||||||
|
|
||||||
// If the packed high component ends up being zero, that means that we tried
|
// If the packed high component ends up being zero, that means that we tried
|
||||||
// to initialise an Identifier into an invalid state.
|
// to initialize an Identifier into an invalid state.
|
||||||
if packed_high == 0 {
|
if packed_high == 0 {
|
||||||
Err(IdentifierError::InvalidIdentifier)
|
Err(IdentifierError::InvalidIdentifier)
|
||||||
} else {
|
} else {
|
||||||
|
@ -107,7 +107,7 @@ impl Identifier {
|
||||||
|
|
||||||
match id {
|
match id {
|
||||||
Ok(id) => id,
|
Ok(id) => id,
|
||||||
Err(_) => panic!("Attempted to initialise invalid bits as an id"),
|
Err(_) => panic!("Attempted to initialize invalid bits as an id"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ impl Identifier {
|
||||||
impl PartialEq for Identifier {
|
impl PartialEq for Identifier {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
// By using `to_bits`, the codegen can be optimised out even
|
// By using `to_bits`, the codegen can be optimized out even
|
||||||
// further potentially. Relies on the correct alignment/field
|
// further potentially. Relies on the correct alignment/field
|
||||||
// order of `Entity`.
|
// order of `Entity`.
|
||||||
self.to_bits() == other.to_bits()
|
self.to_bits() == other.to_bits()
|
||||||
|
@ -142,10 +142,10 @@ impl PartialEq for Identifier {
|
||||||
|
|
||||||
impl Eq for Identifier {}
|
impl Eq for Identifier {}
|
||||||
|
|
||||||
// The derive macro codegen output is not optimal and can't be optimised as well
|
// The derive macro codegen output is not optimal and can't be optimized as well
|
||||||
// by the compiler. This impl resolves the issue of non-optimal codegen by relying
|
// by the compiler. This impl resolves the issue of non-optimal codegen by relying
|
||||||
// on comparing against the bit representation of `Entity` instead of comparing
|
// on comparing against the bit representation of `Entity` instead of comparing
|
||||||
// the fields. The result is then LLVM is able to optimise the codegen for Entity
|
// the fields. The result is then LLVM is able to optimize the codegen for Entity
|
||||||
// far beyond what the derive macro can.
|
// far beyond what the derive macro can.
|
||||||
// See <https://github.com/rust-lang/rust/issues/106107>
|
// See <https://github.com/rust-lang/rust/issues/106107>
|
||||||
impl PartialOrd for Identifier {
|
impl PartialOrd for Identifier {
|
||||||
|
@ -156,10 +156,10 @@ impl PartialOrd for Identifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The derive macro codegen output is not optimal and can't be optimised as well
|
// The derive macro codegen output is not optimal and can't be optimized as well
|
||||||
// by the compiler. This impl resolves the issue of non-optimal codegen by relying
|
// by the compiler. This impl resolves the issue of non-optimal codegen by relying
|
||||||
// on comparing against the bit representation of `Entity` instead of comparing
|
// on comparing against the bit representation of `Entity` instead of comparing
|
||||||
// the fields. The result is then LLVM is able to optimise the codegen for Entity
|
// the fields. The result is then LLVM is able to optimize the codegen for Entity
|
||||||
// far beyond what the derive macro can.
|
// far beyond what the derive macro can.
|
||||||
// See <https://github.com/rust-lang/rust/issues/106107>
|
// See <https://github.com/rust-lang/rust/issues/106107>
|
||||||
impl Ord for Identifier {
|
impl Ord for Identifier {
|
||||||
|
|
|
@ -88,7 +88,7 @@ impl Component for ObserverState {
|
||||||
/// Type for function that is run when an observer is triggered.
|
/// Type for function that is run when an observer is triggered.
|
||||||
///
|
///
|
||||||
/// Typically refers to the default runner that runs the system stored in the associated [`Observer`] component,
|
/// Typically refers to the default runner that runs the system stored in the associated [`Observer`] component,
|
||||||
/// but can be overridden for custom behaviour.
|
/// but can be overridden for custom behavior.
|
||||||
pub type ObserverRunner = fn(DeferredWorld, ObserverTrigger, PtrMut, propagate: &mut bool);
|
pub type ObserverRunner = fn(DeferredWorld, ObserverTrigger, PtrMut, propagate: &mut bool);
|
||||||
|
|
||||||
/// An [`Observer`] system. Add this [`Component`] to an [`Entity`] to turn it into an "observer".
|
/// An [`Observer`] system. Add this [`Component`] to an [`Entity`] to turn it into an "observer".
|
||||||
|
|
|
@ -315,7 +315,7 @@ where
|
||||||
/// If you configure two [`System`]s like `(GameSystem::A).after(GameSystem::B)` or `(GameSystem::A).before(GameSystem::B)`, the `GameSystem::B` will not be automatically scheduled.
|
/// If you configure two [`System`]s like `(GameSystem::A).after(GameSystem::B)` or `(GameSystem::A).before(GameSystem::B)`, the `GameSystem::B` will not be automatically scheduled.
|
||||||
///
|
///
|
||||||
/// This means that the system `GameSystem::A` and the system or systems in `GameSystem::B` will run independently of each other if `GameSystem::B` was never explicitly scheduled with [`configure_sets`]
|
/// This means that the system `GameSystem::A` and the system or systems in `GameSystem::B` will run independently of each other if `GameSystem::B` was never explicitly scheduled with [`configure_sets`]
|
||||||
/// If that is the case, `.after`/`.before` will not provide the desired behaviour
|
/// If that is the case, `.after`/`.before` will not provide the desired behavior
|
||||||
/// and the systems can run in parallel or in any order determined by the scheduler.
|
/// and the systems can run in parallel or in any order determined by the scheduler.
|
||||||
/// Only use `after(GameSystem::B)` and `before(GameSystem::B)` when you know that `B` has already been scheduled for you,
|
/// Only use `after(GameSystem::B)` and `before(GameSystem::B)` when you know that `B` has already been scheduled for you,
|
||||||
/// e.g. when it was provided by Bevy or a third-party dependency,
|
/// e.g. when it was provided by Bevy or a third-party dependency,
|
||||||
|
|
|
@ -1138,7 +1138,7 @@ impl ScheduleGraph {
|
||||||
Ok(self.build_schedule_inner(dependency_flattened_dag, hier_results.reachable))
|
Ok(self.build_schedule_inner(dependency_flattened_dag, hier_results.reachable))
|
||||||
}
|
}
|
||||||
|
|
||||||
// modify the graph to have sync nodes for any dependants after a system with deferred system params
|
// modify the graph to have sync nodes for any dependents after a system with deferred system params
|
||||||
fn auto_insert_apply_deferred(
|
fn auto_insert_apply_deferred(
|
||||||
&mut self,
|
&mut self,
|
||||||
dependency_flattened: &mut GraphMap<NodeId, (), Directed>,
|
dependency_flattened: &mut GraphMap<NodeId, (), Directed>,
|
||||||
|
|
|
@ -735,10 +735,10 @@ impl<'w, 's> Commands<'w, 's> {
|
||||||
/// # high_score: u32,
|
/// # high_score: u32,
|
||||||
/// # }
|
/// # }
|
||||||
/// #
|
/// #
|
||||||
/// # fn initialise_scoreboard(mut commands: Commands) {
|
/// # fn initialize_scoreboard(mut commands: Commands) {
|
||||||
/// commands.init_resource::<Scoreboard>();
|
/// commands.init_resource::<Scoreboard>();
|
||||||
/// # }
|
/// # }
|
||||||
/// # bevy_ecs::system::assert_is_system(initialise_scoreboard);
|
/// # bevy_ecs::system::assert_is_system(initialize_scoreboard);
|
||||||
/// ```
|
/// ```
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn init_resource<R: Resource + FromWorld>(&mut self) {
|
pub fn init_resource<R: Resource + FromWorld>(&mut self) {
|
||||||
|
|
|
@ -659,7 +659,7 @@ impl<Marker, F> FunctionSystem<Marker, F>
|
||||||
where
|
where
|
||||||
F: SystemParamFunction<Marker>,
|
F: SystemParamFunction<Marker>,
|
||||||
{
|
{
|
||||||
/// Message shown when a system isn't initialised
|
/// Message shown when a system isn't initialized
|
||||||
// When lines get too long, rustfmt can sometimes refuse to format them.
|
// When lines get too long, rustfmt can sometimes refuse to format them.
|
||||||
// Work around this by storing the message separately.
|
// Work around this by storing the message separately.
|
||||||
const PARAM_MESSAGE: &'static str = "System's param_state was not found. Did you forget to initialize this system before running it?";
|
const PARAM_MESSAGE: &'static str = "System's param_state was not found. Did you forget to initialize this system before running it?";
|
||||||
|
|
|
@ -1190,7 +1190,7 @@ pub trait SystemBuffer: FromWorld + Send + 'static {
|
||||||
///
|
///
|
||||||
/// use bevy_ecs::system::{Deferred, SystemBuffer, SystemMeta};
|
/// use bevy_ecs::system::{Deferred, SystemBuffer, SystemMeta};
|
||||||
///
|
///
|
||||||
/// // Uses deferred mutations to allow signalling the alarm from multiple systems in parallel.
|
/// // Uses deferred mutations to allow signaling the alarm from multiple systems in parallel.
|
||||||
/// #[derive(Resource, Default)]
|
/// #[derive(Resource, Default)]
|
||||||
/// struct AlarmFlag(bool);
|
/// struct AlarmFlag(bool);
|
||||||
///
|
///
|
||||||
|
|
|
@ -3257,7 +3257,7 @@ impl World {
|
||||||
let id = self
|
let id = self
|
||||||
.bundles
|
.bundles
|
||||||
.register_info::<B>(&mut self.components, &mut self.storages);
|
.register_info::<B>(&mut self.components, &mut self.storages);
|
||||||
// SAFETY: We just initialised the bundle so its id should definitely be valid.
|
// SAFETY: We just initialized the bundle so its id should definitely be valid.
|
||||||
unsafe { self.bundles.get(id).debug_checked_unwrap() }
|
unsafe { self.bundles.get(id).debug_checked_unwrap() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1836,7 +1836,7 @@ async fn load_buffers(
|
||||||
/// Iterator for a Gltf tree.
|
/// Iterator for a Gltf tree.
|
||||||
///
|
///
|
||||||
/// It resolves a Gltf tree and allows for a safe Gltf nodes iteration,
|
/// It resolves a Gltf tree and allows for a safe Gltf nodes iteration,
|
||||||
/// putting dependant nodes before dependencies.
|
/// putting dependent nodes before dependencies.
|
||||||
struct GltfTreeIterator<'a> {
|
struct GltfTreeIterator<'a> {
|
||||||
nodes: Vec<Node<'a>>,
|
nodes: Vec<Node<'a>>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ impl Image {
|
||||||
Vec::with_capacity(width as usize * height as usize * format.pixel_size());
|
Vec::with_capacity(width as usize * height as usize * format.pixel_size());
|
||||||
|
|
||||||
for pixel in image.into_raw().chunks_exact(3) {
|
for pixel in image.into_raw().chunks_exact(3) {
|
||||||
// TODO: use the array_chunks method once stabilised
|
// TODO: use the array_chunks method once stabilized
|
||||||
// https://github.com/rust-lang/rust/issues/74985
|
// https://github.com/rust-lang/rust/issues/74985
|
||||||
let r = pixel[0];
|
let r = pixel[0];
|
||||||
let g = pixel[1];
|
let g = pixel[1];
|
||||||
|
|
|
@ -395,7 +395,7 @@ pub enum KeyCode {
|
||||||
/// Japanese: <kbd>無変換</kbd> (muhenkan)
|
/// Japanese: <kbd>無変換</kbd> (muhenkan)
|
||||||
NonConvert,
|
NonConvert,
|
||||||
/// <kbd>⌦</kbd>. The forward delete key.
|
/// <kbd>⌦</kbd>. The forward delete key.
|
||||||
/// Note that on Apple keyboards, the key labelled <kbd>Delete</kbd> on the main part of
|
/// Note that on Apple keyboards, the key labeled <kbd>Delete</kbd> on the main part of
|
||||||
/// the keyboard is encoded as [`Backspace`].
|
/// the keyboard is encoded as [`Backspace`].
|
||||||
///
|
///
|
||||||
/// [`Backspace`]: Self::Backspace
|
/// [`Backspace`]: Self::Backspace
|
||||||
|
@ -532,9 +532,9 @@ pub enum KeyCode {
|
||||||
/// <kbd>Eject</kbd> or <kbd>⏏</kbd>. This key is placed in the function section on some Apple
|
/// <kbd>Eject</kbd> or <kbd>⏏</kbd>. This key is placed in the function section on some Apple
|
||||||
/// keyboards.
|
/// keyboards.
|
||||||
Eject,
|
Eject,
|
||||||
/// Sometimes labelled <kbd>My Computer</kbd> on the keyboard
|
/// Sometimes labeled <kbd>My Computer</kbd> on the keyboard
|
||||||
LaunchApp1,
|
LaunchApp1,
|
||||||
/// Sometimes labelled <kbd>Calculator</kbd> on the keyboard
|
/// Sometimes labeled <kbd>Calculator</kbd> on the keyboard
|
||||||
LaunchApp2,
|
LaunchApp2,
|
||||||
/// LaunchMail
|
/// LaunchMail
|
||||||
LaunchMail,
|
LaunchMail,
|
||||||
|
@ -927,7 +927,7 @@ pub enum Key {
|
||||||
/// be restored. The computer will then shutdown.
|
/// be restored. The computer will then shutdown.
|
||||||
Hibernate,
|
Hibernate,
|
||||||
/// The Standby key. This key turns off the display and places the computer into a low-power
|
/// The Standby key. This key turns off the display and places the computer into a low-power
|
||||||
/// mode without completely shutting down. It is sometimes labelled `Suspend` or `Sleep` key.
|
/// mode without completely shutting down. It is sometimes labeled `Suspend` or `Sleep` key.
|
||||||
/// (`KEYCODE_SLEEP`)
|
/// (`KEYCODE_SLEEP`)
|
||||||
Standby,
|
Standby,
|
||||||
/// The WakeUp key. (`KEYCODE_WAKEUP`)
|
/// The WakeUp key. (`KEYCODE_WAKEUP`)
|
||||||
|
|
|
@ -108,7 +108,7 @@ pub(crate) struct FlushGuard(SyncCell<tracing_chrome::FlushGuard>);
|
||||||
/// If you define the `RUST_LOG` environment variable, the [`LogPlugin`] settings
|
/// If you define the `RUST_LOG` environment variable, the [`LogPlugin`] settings
|
||||||
/// will be ignored.
|
/// will be ignored.
|
||||||
///
|
///
|
||||||
/// Also, to disable colour terminal output (ANSI escape codes), you can
|
/// Also, to disable color terminal output (ANSI escape codes), you can
|
||||||
/// set the environment variable `NO_COLOR` to any value. This common
|
/// set the environment variable `NO_COLOR` to any value. This common
|
||||||
/// convention is documented at [no-color.org](https://no-color.org/).
|
/// convention is documented at [no-color.org](https://no-color.org/).
|
||||||
/// For example:
|
/// For example:
|
||||||
|
|
|
@ -83,7 +83,7 @@ impl IRect {
|
||||||
|
|
||||||
/// Create a new rectangle from its center and size.
|
/// Create a new rectangle from its center and size.
|
||||||
///
|
///
|
||||||
/// # Rounding Behaviour
|
/// # Rounding Behavior
|
||||||
///
|
///
|
||||||
/// If the size contains odd numbers they will be rounded down to the nearest whole number.
|
/// If the size contains odd numbers they will be rounded down to the nearest whole number.
|
||||||
///
|
///
|
||||||
|
@ -190,7 +190,7 @@ impl IRect {
|
||||||
|
|
||||||
/// Rectangle half-size.
|
/// Rectangle half-size.
|
||||||
///
|
///
|
||||||
/// # Rounding Behaviour
|
/// # Rounding Behavior
|
||||||
///
|
///
|
||||||
/// If the full size contains odd numbers they will be rounded down to the nearest whole number when calculating the half size.
|
/// If the full size contains odd numbers they will be rounded down to the nearest whole number when calculating the half size.
|
||||||
///
|
///
|
||||||
|
@ -208,7 +208,7 @@ impl IRect {
|
||||||
|
|
||||||
/// The center point of the rectangle.
|
/// The center point of the rectangle.
|
||||||
///
|
///
|
||||||
/// # Rounding Behaviour
|
/// # Rounding Behavior
|
||||||
///
|
///
|
||||||
/// If the (min + max) contains odd numbers they will be rounded down to the nearest whole number when calculating the center.
|
/// If the (min + max) contains odd numbers they will be rounded down to the nearest whole number when calculating the center.
|
||||||
///
|
///
|
||||||
|
|
|
@ -83,7 +83,7 @@ impl URect {
|
||||||
|
|
||||||
/// Create a new rectangle from its center and size.
|
/// Create a new rectangle from its center and size.
|
||||||
///
|
///
|
||||||
/// # Rounding Behaviour
|
/// # Rounding Behavior
|
||||||
///
|
///
|
||||||
/// If the size contains odd numbers they will be rounded down to the nearest whole number.
|
/// If the size contains odd numbers they will be rounded down to the nearest whole number.
|
||||||
///
|
///
|
||||||
|
@ -187,7 +187,7 @@ impl URect {
|
||||||
|
|
||||||
/// Rectangle half-size.
|
/// Rectangle half-size.
|
||||||
///
|
///
|
||||||
/// # Rounding Behaviour
|
/// # Rounding Behavior
|
||||||
///
|
///
|
||||||
/// If the full size contains odd numbers they will be rounded down to the nearest whole number when calculating the half size.
|
/// If the full size contains odd numbers they will be rounded down to the nearest whole number when calculating the half size.
|
||||||
///
|
///
|
||||||
|
@ -205,7 +205,7 @@ impl URect {
|
||||||
|
|
||||||
/// The center point of the rectangle.
|
/// The center point of the rectangle.
|
||||||
///
|
///
|
||||||
/// # Rounding Behaviour
|
/// # Rounding Behavior
|
||||||
///
|
///
|
||||||
/// If the (min + max) contains odd numbers they will be rounded down to the nearest whole number when calculating the center.
|
/// If the (min + max) contains odd numbers they will be rounded down to the nearest whole number when calculating the center.
|
||||||
///
|
///
|
||||||
|
|
|
@ -420,7 +420,7 @@ impl ShapeSample for Cylinder {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sample_boundary<R: Rng + ?Sized>(&self, rng: &mut R) -> Vec3 {
|
fn sample_boundary<R: Rng + ?Sized>(&self, rng: &mut R) -> Vec3 {
|
||||||
// This uses the area of the ends divided by the overall surface area (optimised)
|
// This uses the area of the ends divided by the overall surface area (optimized)
|
||||||
// [2 (\pi r^2)]/[2 (\pi r^2) + 2 \pi r h] = r/(r + h)
|
// [2 (\pi r^2)]/[2 (\pi r^2) + 2 \pi r h] = r/(r + h)
|
||||||
if self.radius + 2.0 * self.half_height > 0.0 {
|
if self.radius + 2.0 * self.half_height > 0.0 {
|
||||||
if rng.gen_bool((self.radius / (self.radius + 2.0 * self.half_height)) as f64) {
|
if rng.gen_bool((self.radius / (self.radius + 2.0 * self.half_height)) as f64) {
|
||||||
|
|
|
@ -87,7 +87,7 @@ pub const VERTEX_ATTRIBUTE_BUFFER_ID: u64 = 10;
|
||||||
/// other APIs can have other conventions, `OpenGL` starts at bottom-left.
|
/// other APIs can have other conventions, `OpenGL` starts at bottom-left.
|
||||||
/// - It is possible and sometimes useful for multiple vertices to have the same
|
/// - It is possible and sometimes useful for multiple vertices to have the same
|
||||||
/// [position attribute](Mesh::ATTRIBUTE_POSITION) value,
|
/// [position attribute](Mesh::ATTRIBUTE_POSITION) value,
|
||||||
/// it's a common technique in 3D modelling for complex UV mapping or other calculations.
|
/// it's a common technique in 3D modeling for complex UV mapping or other calculations.
|
||||||
/// - Bevy performs frustum culling based on the `Aabb` of meshes, which is calculated
|
/// - Bevy performs frustum culling based on the `Aabb` of meshes, which is calculated
|
||||||
/// and added automatically for new meshes only. If a mesh is modified, the entity's `Aabb`
|
/// and added automatically for new meshes only. If a mesh is modified, the entity's `Aabb`
|
||||||
/// needs to be updated manually or deleted so that it is re-calculated.
|
/// needs to be updated manually or deleted so that it is re-calculated.
|
||||||
|
|
|
@ -86,7 +86,7 @@ impl MeshBuilder for ConeMeshBuilder {
|
||||||
// The tip doesn't have a singular normal that works correctly.
|
// The tip doesn't have a singular normal that works correctly.
|
||||||
// We use an invalid normal here so that it becomes NaN in the fragment shader
|
// We use an invalid normal here so that it becomes NaN in the fragment shader
|
||||||
// and doesn't affect the overall shading. This might seem hacky, but it's one of
|
// and doesn't affect the overall shading. This might seem hacky, but it's one of
|
||||||
// the only ways to get perfectly smooth cones without creases or other shading artefacts.
|
// the only ways to get perfectly smooth cones without creases or other shading artifacts.
|
||||||
//
|
//
|
||||||
// Note that this requires that normals are not normalized in the vertex shader,
|
// Note that this requires that normals are not normalized in the vertex shader,
|
||||||
// as that would make the entire triangle invalid and make the cone appear as black.
|
// as that would make the entire triangle invalid and make the cone appear as black.
|
||||||
|
|
|
@ -12,11 +12,11 @@ pub enum PerimeterSegment {
|
||||||
///
|
///
|
||||||
/// This has the effect of rendering the segment's faces with softened edges, so it is appropriate for curved shapes.
|
/// This has the effect of rendering the segment's faces with softened edges, so it is appropriate for curved shapes.
|
||||||
///
|
///
|
||||||
/// The normals for the vertices that are part of this segment will be calculated based on the positions of their neighbours.
|
/// The normals for the vertices that are part of this segment will be calculated based on the positions of their neighbors.
|
||||||
/// Each normal is interpolated between the normals of the two line segments connecting it with its neighbours.
|
/// Each normal is interpolated between the normals of the two line segments connecting it with its neighbors.
|
||||||
/// Closer vertices have a stronger effect on the normal than more distant ones.
|
/// Closer vertices have a stronger effect on the normal than more distant ones.
|
||||||
///
|
///
|
||||||
/// Since the vertices corresponding to the first and last indices do not have two neighbouring vertices, their normals must be provided manually.
|
/// Since the vertices corresponding to the first and last indices do not have two neighboring vertices, their normals must be provided manually.
|
||||||
Smooth {
|
Smooth {
|
||||||
/// The normal of the first vertex.
|
/// The normal of the first vertex.
|
||||||
first_normal: Vec2,
|
first_normal: Vec2,
|
||||||
|
@ -348,8 +348,8 @@ where
|
||||||
uvs.push([uv_x, uv_y]);
|
uvs.push([uv_x, uv_y]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The normal for the current vertices can be calculated based on the two neighbouring vertices.
|
// The normal for the current vertices can be calculated based on the two neighboring vertices.
|
||||||
// The normal is interpolated between the normals of the two line segments connecting the current vertex with its neighbours.
|
// The normal is interpolated between the normals of the two line segments connecting the current vertex with its neighbors.
|
||||||
// Closer vertices have a stronger effect on the normal than more distant ones.
|
// Closer vertices have a stronger effect on the normal than more distant ones.
|
||||||
let n = {
|
let n = {
|
||||||
let ab = Vec2::from_slice(&b) - Vec2::from_slice(&a);
|
let ab = Vec2::from_slice(&b) - Vec2::from_slice(&a);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
//! modification to Morten S. Mikkelsen's original tangent space algorithm
|
//! modification to Morten S. Mikkelsen's original tangent space algorithm
|
||||||
//! implementation written in C. The original source code can be found at
|
//! implementation written in C. The original source code can be found at
|
||||||
//! <https://archive.blender.org/wiki/index.php/Dev:Shading/Tangent_Space_Normal_Maps>
|
//! <https://archive.blender.org/wiki/index.php/Dev:Shading/Tangent_Space_Normal_Maps>
|
||||||
//! and includes the following licence:
|
//! and includes the following license:
|
||||||
//!
|
//!
|
||||||
//! Copyright (C) 2011 by Morten S. Mikkelsen
|
//! Copyright (C) 2011 by Morten S. Mikkelsen
|
||||||
//!
|
//!
|
||||||
|
|
|
@ -51,7 +51,7 @@ pub mod light_consts {
|
||||||
/// Predefined for lux values in several locations.
|
/// Predefined for lux values in several locations.
|
||||||
///
|
///
|
||||||
/// The **lux** (symbol: **lx**) is the unit of [illuminance], or [luminous flux] per unit area,
|
/// The **lux** (symbol: **lx**) is the unit of [illuminance], or [luminous flux] per unit area,
|
||||||
/// in the [International System of Units] (SI). It is equal to one lumen per square metre.
|
/// in the [International System of Units] (SI). It is equal to one lumen per square meter.
|
||||||
///
|
///
|
||||||
/// For more information, see [wikipedia](https://en.wikipedia.org/wiki/Lux)
|
/// For more information, see [wikipedia](https://en.wikipedia.org/wiki/Lux)
|
||||||
///
|
///
|
||||||
|
|
|
@ -387,7 +387,7 @@ pub struct StandardMaterial {
|
||||||
|
|
||||||
/// Specifies the level of exposure to ambient light.
|
/// Specifies the level of exposure to ambient light.
|
||||||
///
|
///
|
||||||
/// This is usually generated and stored automatically ("baked") by 3D-modelling software.
|
/// This is usually generated and stored automatically ("baked") by 3D-modeling software.
|
||||||
///
|
///
|
||||||
/// Typically, steep concave parts of a model (such as the armpit of a shirt) are darker,
|
/// Typically, steep concave parts of a model (such as the armpit of a shirt) are darker,
|
||||||
/// because they have little exposure to light.
|
/// because they have little exposure to light.
|
||||||
|
@ -913,7 +913,7 @@ pub struct StandardMaterialUniform {
|
||||||
// Use a color for user-friendliness even though we technically don't use the alpha channel
|
// Use a color for user-friendliness even though we technically don't use the alpha channel
|
||||||
// Might be used in the future for exposure correction in HDR
|
// Might be used in the future for exposure correction in HDR
|
||||||
pub emissive: Vec4,
|
pub emissive: Vec4,
|
||||||
/// Color white light takes after travelling through the attenuation distance underneath the material surface
|
/// Color white light takes after traveling through the attenuation distance underneath the material surface
|
||||||
pub attenuation_color: Vec4,
|
pub attenuation_color: Vec4,
|
||||||
/// The transform applied to the UVs corresponding to `ATTRIBUTE_UV_0` on the mesh before sampling. Default is identity.
|
/// The transform applied to the UVs corresponding to `ATTRIBUTE_UV_0` on the mesh before sampling. Default is identity.
|
||||||
pub uv_transform: Mat3,
|
pub uv_transform: Mat3,
|
||||||
|
|
|
@ -77,7 +77,7 @@ fn cluster_debug_visualization(
|
||||||
|
|
||||||
// Cluster allocation debug (using 'over' alpha blending)
|
// Cluster allocation debug (using 'over' alpha blending)
|
||||||
#ifdef CLUSTERED_FORWARD_DEBUG_Z_SLICES
|
#ifdef CLUSTERED_FORWARD_DEBUG_Z_SLICES
|
||||||
// NOTE: This debug mode visualises the z-slices
|
// NOTE: This debug mode visualizes the z-slices
|
||||||
let cluster_overlay_alpha = 0.1;
|
let cluster_overlay_alpha = 0.1;
|
||||||
var z_slice: u32 = view_z_to_z_slice(view_z, is_orthographic);
|
var z_slice: u32 = view_z_to_z_slice(view_z, is_orthographic);
|
||||||
// A hack to make the colors alternate a bit more
|
// A hack to make the colors alternate a bit more
|
||||||
|
@ -96,7 +96,7 @@ fn cluster_debug_visualization(
|
||||||
);
|
);
|
||||||
#endif // CLUSTERED_FORWARD_DEBUG_Z_SLICES
|
#endif // CLUSTERED_FORWARD_DEBUG_Z_SLICES
|
||||||
#ifdef CLUSTERED_FORWARD_DEBUG_CLUSTER_COMPLEXITY
|
#ifdef CLUSTERED_FORWARD_DEBUG_CLUSTER_COMPLEXITY
|
||||||
// NOTE: This debug mode visualises the number of clusterable objects within
|
// NOTE: This debug mode visualizes the number of clusterable objects within
|
||||||
// the cluster that contains the fragment. It shows a sort of cluster
|
// the cluster that contains the fragment. It shows a sort of cluster
|
||||||
// complexity measure.
|
// complexity measure.
|
||||||
let cluster_overlay_alpha = 0.1;
|
let cluster_overlay_alpha = 0.1;
|
||||||
|
|
|
@ -537,7 +537,7 @@ pub const fn dangling_with_align(align: NonZeroUsize) -> NonNull<u8> {
|
||||||
debug_assert!(align.is_power_of_two(), "Alignment must be power of two.");
|
debug_assert!(align.is_power_of_two(), "Alignment must be power of two.");
|
||||||
// SAFETY: The pointer will not be null, since it was created
|
// SAFETY: The pointer will not be null, since it was created
|
||||||
// from the address of a `NonZero<usize>`.
|
// from the address of a `NonZero<usize>`.
|
||||||
// TODO: use https://doc.rust-lang.org/std/ptr/struct.NonNull.html#method.with_addr once stabilised
|
// TODO: use https://doc.rust-lang.org/std/ptr/struct.NonNull.html#method.with_addr once stabilized
|
||||||
unsafe { NonNull::new_unchecked(ptr::null_mut::<u8>().wrapping_add(align.get())) }
|
unsafe { NonNull::new_unchecked(ptr::null_mut::<u8>().wrapping_add(align.get())) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1001,7 +1001,7 @@ impl<'a> ReflectTypePath<'a> {
|
||||||
///
|
///
|
||||||
/// Returns [`None`] if the type is [primitive] or [anonymous].
|
/// Returns [`None`] if the type is [primitive] or [anonymous].
|
||||||
///
|
///
|
||||||
/// For non-customised [internal] paths this is created from [`module_path`].
|
/// For non-customized [internal] paths this is created from [`module_path`].
|
||||||
///
|
///
|
||||||
/// For `Option<PhantomData>`, this is `"core"`.
|
/// For `Option<PhantomData>`, this is `"core"`.
|
||||||
///
|
///
|
||||||
|
@ -1131,7 +1131,7 @@ impl<'a> ReflectTypePath<'a> {
|
||||||
///
|
///
|
||||||
/// Returns [`None`] if the type is [primitive] or [anonymous].
|
/// Returns [`None`] if the type is [primitive] or [anonymous].
|
||||||
///
|
///
|
||||||
/// For non-customised [internal] paths this is created from [`module_path`].
|
/// For non-customized [internal] paths this is created from [`module_path`].
|
||||||
///
|
///
|
||||||
/// For `Option<PhantomData>`, this is `"std::option"`.
|
/// For `Option<PhantomData>`, this is `"std::option"`.
|
||||||
///
|
///
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
//! `dyn Reflect` trait objects can be used similarly to `dyn PartialReflect`,
|
//! `dyn Reflect` trait objects can be used similarly to `dyn PartialReflect`,
|
||||||
//! but `Reflect` is also often used in trait bounds (like `T: Reflect`).
|
//! but `Reflect` is also often used in trait bounds (like `T: Reflect`).
|
||||||
//!
|
//!
|
||||||
//! The distinction between `PartialReflect` and `Reflect` is summarised in the following:
|
//! The distinction between `PartialReflect` and `Reflect` is summarized in the following:
|
||||||
//! * `PartialReflect` is a trait for interacting with values under `bevy_reflect`'s data model.
|
//! * `PartialReflect` is a trait for interacting with values under `bevy_reflect`'s data model.
|
||||||
//! This means values implementing `PartialReflect` can be dynamically constructed and introspected.
|
//! This means values implementing `PartialReflect` can be dynamically constructed and introspected.
|
||||||
//! * The `Reflect` trait, however, ensures that the interface exposed by `PartialReflect`
|
//! * The `Reflect` trait, however, ensures that the interface exposed by `PartialReflect`
|
||||||
|
|
|
@ -159,7 +159,7 @@ impl<'a, T: ShaderType + WriteInto> IntoBinding<'a> for &'a StorageBuffer<T> {
|
||||||
///
|
///
|
||||||
/// The contained data is stored in system RAM. [`write_buffer`](DynamicStorageBuffer::write_buffer)
|
/// The contained data is stored in system RAM. [`write_buffer`](DynamicStorageBuffer::write_buffer)
|
||||||
/// queues copying of the data from system RAM to VRAM. The data within a storage buffer binding must conform to
|
/// queues copying of the data from system RAM to VRAM. The data within a storage buffer binding must conform to
|
||||||
/// [std430 alignment/padding requirements]. `DynamicStorageBuffer` takes care of serialising the inner type to conform to
|
/// [std430 alignment/padding requirements]. `DynamicStorageBuffer` takes care of serializing the inner type to conform to
|
||||||
/// these requirements. Each item [`push`](DynamicStorageBuffer::push)ed into this structure
|
/// these requirements. Each item [`push`](DynamicStorageBuffer::push)ed into this structure
|
||||||
/// will additionally be aligned to meet dynamic offset alignment requirements.
|
/// will additionally be aligned to meet dynamic offset alignment requirements.
|
||||||
///
|
///
|
||||||
|
|
|
@ -55,7 +55,7 @@ impl RenderDevice {
|
||||||
.contains(wgpu::Features::SPIRV_SHADER_PASSTHROUGH) =>
|
.contains(wgpu::Features::SPIRV_SHADER_PASSTHROUGH) =>
|
||||||
{
|
{
|
||||||
// SAFETY:
|
// SAFETY:
|
||||||
// This call passes binary data to the backend as-is and can potentially result in a driver crash or bogus behaviour.
|
// This call passes binary data to the backend as-is and can potentially result in a driver crash or bogus behavior.
|
||||||
// No attempt is made to ensure that data is valid SPIR-V.
|
// No attempt is made to ensure that data is valid SPIR-V.
|
||||||
unsafe {
|
unsafe {
|
||||||
self.device
|
self.device
|
||||||
|
|
|
@ -9,9 +9,9 @@ use bevy_transform::components::{GlobalTransform, Transform};
|
||||||
|
|
||||||
/// A [`Bundle`] of components for drawing a single sprite from an image.
|
/// A [`Bundle`] of components for drawing a single sprite from an image.
|
||||||
///
|
///
|
||||||
/// # Extra behaviours
|
/// # Extra behaviors
|
||||||
///
|
///
|
||||||
/// You may add one or both of the following components to enable additional behaviours:
|
/// You may add one or both of the following components to enable additional behaviors:
|
||||||
/// - [`ImageScaleMode`](crate::ImageScaleMode) to enable either slicing or tiling of the texture
|
/// - [`ImageScaleMode`](crate::ImageScaleMode) to enable either slicing or tiling of the texture
|
||||||
/// - [`TextureAtlas`](crate::TextureAtlas) to draw a specific section of the texture
|
/// - [`TextureAtlas`](crate::TextureAtlas) to draw a specific section of the texture
|
||||||
#[derive(Bundle, Clone, Debug, Default)]
|
#[derive(Bundle, Clone, Debug, Default)]
|
||||||
|
|
|
@ -56,7 +56,7 @@ pub trait StateSet: StateSetSealed {
|
||||||
///
|
///
|
||||||
/// The isolation works because it is implemented for both S & [`Option<S>`], and has the `RawState` associated type
|
/// The isolation works because it is implemented for both S & [`Option<S>`], and has the `RawState` associated type
|
||||||
/// that allows it to know what the resource in the world should be. We can then essentially "unwrap" it in our
|
/// that allows it to know what the resource in the world should be. We can then essentially "unwrap" it in our
|
||||||
/// `StateSet` implementation - and the behaviour of that unwrapping will depend on the arguments expected by the
|
/// `StateSet` implementation - and the behavior of that unwrapping will depend on the arguments expected by the
|
||||||
/// the [`ComputedStates`] & [`SubStates]`.
|
/// the [`ComputedStates`] & [`SubStates]`.
|
||||||
trait InnerStateSet: Sized {
|
trait InnerStateSet: Sized {
|
||||||
type RawState: States;
|
type RawState: States;
|
||||||
|
|
|
@ -161,7 +161,7 @@ pub trait SubStates: States + FreelyMutableState {
|
||||||
/// it will be created from the returned [`Some`] as the initial state.
|
/// it will be created from the returned [`Some`] as the initial state.
|
||||||
///
|
///
|
||||||
/// Value within [`Some`] is ignored if the state already exists in the world
|
/// Value within [`Some`] is ignored if the state already exists in the world
|
||||||
/// and only symbolises that the state should still exist.
|
/// and only symbolizes that the state should still exist.
|
||||||
///
|
///
|
||||||
/// Initial value can also be overwritten by [`NextState`](crate::state::NextState).
|
/// Initial value can also be overwritten by [`NextState`](crate::state::NextState).
|
||||||
fn should_exist(sources: Self::SourceStates) -> Option<Self>;
|
fn should_exist(sources: Self::SourceStates) -> Option<Self>;
|
||||||
|
|
|
@ -135,7 +135,7 @@ pub(crate) fn internal_apply_state_transition<S: States>(
|
||||||
Some(entered) => {
|
Some(entered) => {
|
||||||
match current_state {
|
match current_state {
|
||||||
// If the [`State<S>`] resource exists, and the state is not the one we are
|
// If the [`State<S>`] resource exists, and the state is not the one we are
|
||||||
// entering - we need to set the new value, compute dependant states, send transition events
|
// entering - we need to set the new value, compute dependent states, send transition events
|
||||||
// and register transition schedules.
|
// and register transition schedules.
|
||||||
Some(mut state_resource) => {
|
Some(mut state_resource) => {
|
||||||
let exited = match *state_resource == entered {
|
let exited = match *state_resource == entered {
|
||||||
|
@ -151,7 +151,7 @@ pub(crate) fn internal_apply_state_transition<S: States>(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
// If the [`State<S>`] resource does not exist, we create it, compute dependant states, send a transition event and register the `OnEnter` schedule.
|
// If the [`State<S>`] resource does not exist, we create it, compute dependent states, send a transition event and register the `OnEnter` schedule.
|
||||||
commands.insert_resource(State(entered.clone()));
|
commands.insert_resource(State(entered.clone()));
|
||||||
|
|
||||||
event.send(StateTransitionEvent {
|
event.send(StateTransitionEvent {
|
||||||
|
@ -162,7 +162,7 @@ pub(crate) fn internal_apply_state_transition<S: States>(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
// We first remove the [`State<S>`] resource, and if one existed we compute dependant states, send a transition event and run the `OnExit` schedule.
|
// We first remove the [`State<S>`] resource, and if one existed we compute dependent states, send a transition event and run the `OnExit` schedule.
|
||||||
if let Some(resource) = current_state {
|
if let Some(resource) = current_state {
|
||||||
commands.remove_resource::<State<S>>();
|
commands.remove_resource::<State<S>>();
|
||||||
|
|
||||||
|
|
|
@ -537,7 +537,7 @@ mod test {
|
||||||
|
|
||||||
// Time will wrap to modulo duration from full `elapsed()`, not to what
|
// Time will wrap to modulo duration from full `elapsed()`, not to what
|
||||||
// is left in `elapsed_wrapped()`. This test of values is here to ensure
|
// is left in `elapsed_wrapped()`. This test of values is here to ensure
|
||||||
// that we notice if we change that behaviour.
|
// that we notice if we change that behavior.
|
||||||
assert_eq!(time.elapsed_wrapped(), Duration::from_secs(0));
|
assert_eq!(time.elapsed_wrapped(), Duration::from_secs(0));
|
||||||
assert_eq!(time.elapsed_secs_wrapped(), 0.0);
|
assert_eq!(time.elapsed_secs_wrapped(), 0.0);
|
||||||
assert_eq!(time.elapsed_secs_wrapped_f64(), 0.0);
|
assert_eq!(time.elapsed_secs_wrapped_f64(), 0.0);
|
||||||
|
|
|
@ -58,9 +58,9 @@ pub struct NodeBundle {
|
||||||
|
|
||||||
/// A UI node that is an image
|
/// A UI node that is an image
|
||||||
///
|
///
|
||||||
/// # Extra behaviours
|
/// # Extra behaviors
|
||||||
///
|
///
|
||||||
/// You may add one or both of the following components to enable additional behaviours:
|
/// You may add one or both of the following components to enable additional behaviors:
|
||||||
/// - [`ImageScaleMode`](bevy_sprite::ImageScaleMode) to enable either slicing or tiling of the texture
|
/// - [`ImageScaleMode`](bevy_sprite::ImageScaleMode) to enable either slicing or tiling of the texture
|
||||||
/// - [`TextureAtlas`](bevy_sprite::TextureAtlas) to draw a specific section of the texture
|
/// - [`TextureAtlas`](bevy_sprite::TextureAtlas) to draw a specific section of the texture
|
||||||
#[derive(Bundle, Debug, Default)]
|
#[derive(Bundle, Debug, Default)]
|
||||||
|
@ -111,9 +111,9 @@ pub struct ImageBundle {
|
||||||
|
|
||||||
/// A UI node that is a button
|
/// A UI node that is a button
|
||||||
///
|
///
|
||||||
/// # Extra behaviours
|
/// # Extra behaviors
|
||||||
///
|
///
|
||||||
/// You may add one or both of the following components to enable additional behaviours:
|
/// You may add one or both of the following components to enable additional behaviors:
|
||||||
/// - [`ImageScaleMode`](bevy_sprite::ImageScaleMode) to enable either slicing or tiling of the texture
|
/// - [`ImageScaleMode`](bevy_sprite::ImageScaleMode) to enable either slicing or tiling of the texture
|
||||||
/// - [`TextureAtlas`](bevy_sprite::TextureAtlas) to draw a specific section of the texture
|
/// - [`TextureAtlas`](bevy_sprite::TextureAtlas) to draw a specific section of the texture
|
||||||
#[derive(Bundle, Clone, Debug)]
|
#[derive(Bundle, Clone, Debug)]
|
||||||
|
|
|
@ -138,7 +138,7 @@ pub struct WindowDestroyed {
|
||||||
/// Not to be confused with the `MouseMotion` event from `bevy_input`.
|
/// Not to be confused with the `MouseMotion` event from `bevy_input`.
|
||||||
///
|
///
|
||||||
/// Because the range of data is limited by the window area and it may have been transformed by the OS to implement certain effects like acceleration,
|
/// Because the range of data is limited by the window area and it may have been transformed by the OS to implement certain effects like acceleration,
|
||||||
/// you should not use it for non-cursor-like behaviour such as 3D camera control. Please see `MouseMotion` instead.
|
/// you should not use it for non-cursor-like behavior such as 3D camera control. Please see `MouseMotion` instead.
|
||||||
///
|
///
|
||||||
/// [`WindowEvent::CursorMoved`]: https://docs.rs/winit/latest/winit/event/enum.WindowEvent.html#variant.CursorMoved
|
/// [`WindowEvent::CursorMoved`]: https://docs.rs/winit/latest/winit/event/enum.WindowEvent.html#variant.CursorMoved
|
||||||
#[derive(Event, Debug, Clone, PartialEq, Reflect)]
|
#[derive(Event, Debug, Clone, PartialEq, Reflect)]
|
||||||
|
@ -250,7 +250,7 @@ pub struct WindowFocused {
|
||||||
/// The window has been occluded (completely hidden from view).
|
/// The window has been occluded (completely hidden from view).
|
||||||
///
|
///
|
||||||
/// This is different to window visibility as it depends on
|
/// This is different to window visibility as it depends on
|
||||||
/// whether the window is closed, minimised, set invisible,
|
/// whether the window is closed, minimized, set invisible,
|
||||||
/// or fully occluded by another window.
|
/// or fully occluded by another window.
|
||||||
///
|
///
|
||||||
/// It is the translated version of [`WindowEvent::Occluded`] from the `winit` crate.
|
/// It is the translated version of [`WindowEvent::Occluded`] from the `winit` crate.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
## Cargo Features
|
## Cargo Features
|
||||||
|
|
||||||
Bevy exposes many features to customise the engine. Enabling them add functionalities but often come at the cost of longer compilation times and extra dependencies.
|
Bevy exposes many features to customize the engine. Enabling them add functionalities but often come at the cost of longer compilation times and extra dependencies.
|
||||||
|
|
||||||
### Default Features
|
### Default Features
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
## Cargo Features
|
## Cargo Features
|
||||||
|
|
||||||
Bevy exposes many features to customise the engine. Enabling them add functionalities but often come at the cost of longer compilation times and extra dependencies.
|
Bevy exposes many features to customize the engine. Enabling them add functionalities but often come at the cost of longer compilation times and extra dependencies.
|
||||||
|
|
||||||
### Default Features
|
### Default Features
|
||||||
|
|
||||||
|
|
|
@ -254,7 +254,7 @@ fn example_control_system(
|
||||||
camera: Single<(&mut Camera, &mut Transform, &GlobalTransform), With<Camera3d>>,
|
camera: Single<(&mut Camera, &mut Transform, &GlobalTransform), With<Camera3d>>,
|
||||||
mut labels: Query<(&mut Node, &ExampleLabel)>,
|
mut labels: Query<(&mut Node, &ExampleLabel)>,
|
||||||
mut display: Single<&mut Text, With<ExampleDisplay>>,
|
mut display: Single<&mut Text, With<ExampleDisplay>>,
|
||||||
labelled: Query<&GlobalTransform>,
|
labeled: Query<&GlobalTransform>,
|
||||||
mut state: Local<ExampleState>,
|
mut state: Local<ExampleState>,
|
||||||
time: Res<Time>,
|
time: Res<Time>,
|
||||||
input: Res<ButtonInput<KeyCode>>,
|
input: Res<ButtonInput<KeyCode>>,
|
||||||
|
@ -308,7 +308,7 @@ fn example_control_system(
|
||||||
camera_transform.rotate_around(Vec3::ZERO, Quat::from_rotation_y(rotation));
|
camera_transform.rotate_around(Vec3::ZERO, Quat::from_rotation_y(rotation));
|
||||||
|
|
||||||
for (mut node, label) in &mut labels {
|
for (mut node, label) in &mut labels {
|
||||||
let world_position = labelled.get(label.entity).unwrap().translation() + Vec3::Y;
|
let world_position = labeled.get(label.entity).unwrap().translation() + Vec3::Y;
|
||||||
|
|
||||||
let viewport_position = camera
|
let viewport_position = camera
|
||||||
.world_to_viewport(camera_global_transform, world_position)
|
.world_to_viewport(camera_global_transform, world_position)
|
||||||
|
|
|
@ -58,7 +58,7 @@ fn setup(mut commands: Commands) {
|
||||||
|
|
||||||
// Other color spaces like `Srgba` or `Hsva` are neither perceptually nor physically linear.
|
// Other color spaces like `Srgba` or `Hsva` are neither perceptually nor physically linear.
|
||||||
// As such, we cannot use curves in these spaces.
|
// As such, we cannot use curves in these spaces.
|
||||||
// However, we can still mix these colours and animate that way. In fact, mixing colors works in any color space.
|
// However, we can still mix these colors and animate that way. In fact, mixing colors works in any color space.
|
||||||
|
|
||||||
// Spawn a spritre using the provided colors for mixing.
|
// Spawn a spritre using the provided colors for mixing.
|
||||||
spawn_mixed_sprite(&mut commands, -75., colors.map(Hsla::from));
|
spawn_mixed_sprite(&mut commands, -75., colors.map(Hsla::from));
|
||||||
|
|
|
@ -212,7 +212,7 @@ fn alter_mesh(
|
||||||
position[2] *= scale_factor;
|
position[2] *= scale_factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flip the local value to reverse the behaviour next time the key is pressed.
|
// Flip the local value to reverse the behavior next time the key is pressed.
|
||||||
*is_mesh_scaled = !*is_mesh_scaled;
|
*is_mesh_scaled = !*is_mesh_scaled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@ fn orbit(
|
||||||
camera.rotation = Quat::from_euler(EulerRot::YXZ, yaw, pitch, roll);
|
camera.rotation = Quat::from_euler(EulerRot::YXZ, yaw, pitch, roll);
|
||||||
|
|
||||||
// Adjust the translation to maintain the correct orientation toward the orbit target.
|
// Adjust the translation to maintain the correct orientation toward the orbit target.
|
||||||
// In our example it's a static target, but this could easily be customised.
|
// In our example it's a static target, but this could easily be customized.
|
||||||
let target = Vec3::ZERO;
|
let target = Vec3::ZERO;
|
||||||
camera.translation = target - camera.forward() * camera_settings.orbit_distance;
|
camera.translation = target - camera.forward() * camera_settings.orbit_distance;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ use bevy::{
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
/// Hooks can also be registered during component initialisation by
|
/// Hooks can also be registered during component initialization by
|
||||||
/// using [`Component`] derive macro:
|
/// using [`Component`] derive macro:
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// #[derive(Component)]
|
/// #[derive(Component)]
|
||||||
|
@ -31,7 +31,7 @@ struct MyComponent(KeyCode);
|
||||||
impl Component for MyComponent {
|
impl Component for MyComponent {
|
||||||
const STORAGE_TYPE: StorageType = StorageType::Table;
|
const STORAGE_TYPE: StorageType = StorageType::Table;
|
||||||
|
|
||||||
/// Hooks can also be registered during component initialisation by
|
/// Hooks can also be registered during component initialization by
|
||||||
/// implementing `register_component_hooks`
|
/// implementing `register_component_hooks`
|
||||||
fn register_component_hooks(_hooks: &mut ComponentHooks) {
|
fn register_component_hooks(_hooks: &mut ComponentHooks) {
|
||||||
// Register hooks...
|
// Register hooks...
|
||||||
|
|
|
@ -254,7 +254,7 @@ fn update_config(
|
||||||
|
|
||||||
if keyboard.just_pressed(KeyCode::KeyB) {
|
if keyboard.just_pressed(KeyCode::KeyB) {
|
||||||
// AABB gizmos are normally only drawn on entities with a ShowAabbGizmo component
|
// AABB gizmos are normally only drawn on entities with a ShowAabbGizmo component
|
||||||
// We can change this behaviour in the configuration of AabbGizmoGroup
|
// We can change this behavior in the configuration of AabbGizmoGroup
|
||||||
config_store.config_mut::<AabbGizmoConfigGroup>().1.draw_all ^= true;
|
config_store.config_mut::<AabbGizmoConfigGroup>().1.draw_all ^= true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -541,7 +541,7 @@ fn handle_mouse(
|
||||||
let displacement = accumulated_mouse_motion.delta;
|
let displacement = accumulated_mouse_motion.delta;
|
||||||
camera_rig.yaw += displacement.x / 90.;
|
camera_rig.yaw += displacement.x / 90.;
|
||||||
camera_rig.pitch += displacement.y / 90.;
|
camera_rig.pitch += displacement.y / 90.;
|
||||||
// The extra 0.01 is to disallow weird behaviour at the poles of the rotation
|
// The extra 0.01 is to disallow weird behavior at the poles of the rotation
|
||||||
camera_rig.pitch = camera_rig.pitch.clamp(-PI / 2.01, PI / 2.01);
|
camera_rig.pitch = camera_rig.pitch.clamp(-PI / 2.01, PI / 2.01);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ impl ComputedStates for IsPaused {
|
||||||
// Lastly, we have our tutorial, which actually has a more complex derivation.
|
// Lastly, we have our tutorial, which actually has a more complex derivation.
|
||||||
//
|
//
|
||||||
// Like `IsPaused`, the tutorial has a few fully distinct possible states, so we want to represent them
|
// Like `IsPaused`, the tutorial has a few fully distinct possible states, so we want to represent them
|
||||||
// as an Enum. However - in this case they are all dependant on multiple states: the root [`TutorialState`],
|
// as an Enum. However - in this case they are all dependent on multiple states: the root [`TutorialState`],
|
||||||
// and both [`InGame`] and [`IsPaused`] - which are in turn derived from [`AppState`].
|
// and both [`InGame`] and [`IsPaused`] - which are in turn derived from [`AppState`].
|
||||||
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
|
#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash)]
|
||||||
enum Tutorial {
|
enum Tutorial {
|
||||||
|
|
|
@ -179,7 +179,7 @@ fn spawn_layout(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a coloured rectangle node. The node has size as it is assumed that it will be
|
/// Create a colored rectangle node. The node has size as it is assumed that it will be
|
||||||
/// spawned as a child of a Grid container with `AlignItems::Stretch` and `JustifyItems::Stretch`
|
/// spawned as a child of a Grid container with `AlignItems::Stretch` and `JustifyItems::Stretch`
|
||||||
/// which will allow it to take its size from the size of the grid area it occupies.
|
/// which will allow it to take its size from the size of the grid area it occupies.
|
||||||
fn item_rect(builder: &mut ChildBuilder, color: Srgba) {
|
fn item_rect(builder: &mut ChildBuilder, color: Srgba) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//! A test to confirm that `bevy` allows minimising the window
|
//! A test to confirm that `bevy` allows minimizing the window
|
||||||
//! This is run in CI to ensure that this doesn't regress again.
|
//! This is run in CI to ensure that this doesn't regress again.
|
||||||
use bevy::{core::FrameCount, prelude::*};
|
use bevy::{core::FrameCount, prelude::*};
|
||||||
|
|
||||||
|
@ -8,17 +8,17 @@ fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
.add_plugins(DefaultPlugins.set(WindowPlugin {
|
||||||
primary_window: Some(Window {
|
primary_window: Some(Window {
|
||||||
title: "Minimising".into(),
|
title: "Minimizing".into(),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
..default()
|
..default()
|
||||||
}))
|
}))
|
||||||
.add_systems(Startup, (setup_3d, setup_2d))
|
.add_systems(Startup, (setup_3d, setup_2d))
|
||||||
.add_systems(Update, minimise_automatically)
|
.add_systems(Update, minimize_automatically)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn minimise_automatically(mut window: Single<&mut Window>, frames: Res<FrameCount>) {
|
fn minimize_automatically(mut window: Single<&mut Window>, frames: Res<FrameCount>) {
|
||||||
if frames.0 != 60 {
|
if frames.0 != 60 {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
|
@ -28,6 +28,7 @@ LOD = "LOD" # Level of detail
|
||||||
TOI = "TOI" # Time of impact
|
TOI = "TOI" # Time of impact
|
||||||
|
|
||||||
[default]
|
[default]
|
||||||
|
locale = "en-us"
|
||||||
extend-ignore-identifiers-re = [
|
extend-ignore-identifiers-re = [
|
||||||
"NDK", # NDK - Native Development Kit
|
"NDK", # NDK - Native Development Kit
|
||||||
"inventario", # Inventory in Portuguese
|
"inventario", # Inventory in Portuguese
|
||||||
|
|
Loading…
Reference in a new issue