Skip to content

EnTT v3.4.0

Compare
Choose a tag to compare
@skypjack skypjack released this 09 May 21:50
· 4946 commits to master since this release

Changelog

  • config:

    • Added ENTT_IS_EMPTY as an opaque way to recognize empty types (ENTT_DISABLE_ETO affects also this variable).
  • core:

    • Added entt::id_type as an user-friendly alternative for ENTT_ID_TYPE.
    • Added the entt::type_index class sfinae-friendly template to assign library wide sequential identifiers to types.
    • Added entt::has_type_index[_v] to know if a given type T has assigned a library wide sequential identifier.
    • Added entt::integral_constant as a shortcut for its standard counterpart.
  • entity:

    • Added registry::remove_all to orphan entities.
    • Added registry::patch<T> to replace an object in-place.
    • Added registry::on_update<T> to attach listeners to observe changes.
    • Added registry::emplace<T> to assign components to multiple entities at once.
    • Added registry::insert<T> to assign components to entities.
    • Added registry::get_or_emplace<T> get a component and construct it if it doesn't exist yet.
    • registry::replace from arguments is no longer deprecated and still available.
    • Added storage<T>::emplace to assign objects to entities.
    • Added storage<T>::insert to assign objects to multiple entities at once.
    • Added sparse_set::emplace to assign objects to entities.
    • Added sparse_set::insert to assign objects to multiple entities at once.
    • Added entt::invoke, a shortcut to invoke members on components from callbacks.
    • Added registry::destroy with suggested version.
  • meta:

    • Added meta_type::detach to make it possible to detach meta type from contexts (for example, during a visit).
    • Added a reviewed version of meta_factory::type that uses type_info<T>::id() as a default initializer.
    • Added meta_type::type_id to get the type id of the underlying (erased) type.
    • Added entt::resolve_if to lookup meta types using custom predicates.
    • Added entt::resolve_id to lookup meta types by identifier.
    • Added entt::resolve_type to lookup meta types by type id.
    • Added meta_any::ref to invoke aliasing constructor and get references to unmanaged objects.
  • Performance improvements here and there (more devirtualization, less branches, ...).

Build system

  • homebrew-entt is automatically updated on tags.
  • Updated installation process.

EnTT across boundaries

It turned out that the latest version had a problem when multiple registries containing different component types were used concurrently from different threads (see #449 for further details).
Because of this, the way used to make EnTT work across boundaries has changed and has been further refined. There exist now two paths within some of the data structure available in EnTT: the default one (also known as indexed access) based on the type_index class and its fallback based on the type_info class.

In particular:

  • When EnTT is used standalone and its main classes (such as the registry) are not pushed across boundaries, there is nothing to worry about.

  • In case of linked libraries and when exporting the necessary symbols isn't a problem, use the ENTT_API_IMPORT and ENTT_API_EXPORT definitions as appropriate. This will make EnTT use the indexed access even across boundaries.

  • In all other cases, suppress the index generation to force EnTT to use a fallback:

    template<typename Type>
    struct entt::type_index<Type> {};
    

    It's recommended to use range operations as much as possible in this case.

The lib directory contains many examples for who's interested in the topic.
The meta system has not undergone any changes since its previous version.

Breaking changes

  • Empty types are no longer returned nor are they available in any case.
    • The storage class for empty types doesn't offer anymore get, try_get and so on.
    • Views and groups no longer return empty types during a call to each and don't allow anymore to get an empty type for an entity.
    • ENTT_DISABLE_ETO is no longer considered, use ENTT_NO_ETO instead.
    • ENTT_ENABLE_ETO is no longer exported, use ENTT_IS_EMPTY instead.
  • iterator_type aliases have been renamed to iterator for better integration.
  • meta_type::id returns the type identifier rather than the type id.
  • basic_snapshot<T>::entities stores aside also destroyed entities, not only the ones still alive.
  • basic_snapshot_loader<T>::entities expects also destroyed entities, not only the ones still alive.
  • basic_continuous_loader<T>::entities expects also destroyed entities, not only the ones still alive.

Deprecated functions

All previously deprecated functions and classes have been removed.
This is the list of features deprecated with this release:

  • registry::replace with callbacks, use registry::patch instead.
  • registry::on_replace, use registry::on_update instead.
  • registry::assign<T> for a single entity, use registry::emplace<T> instead.
  • registry::assign<T> for multiple entities, use registry::insert<T> instead.
  • registry::get_or_assign<T>, use registry::get_or_emplace<T> instead.
  • registry::snapshot, basic_snapshot<T> has now a constructor that accepts a reference to a registry.
  • registry::loader, basic_snapshot_loader<T> has now a constructor that accepts a reference to a registry.
  • storage<T>::construct for a single entity, use storage<T>::emplace instead.
  • storage<T>::construct for multiple entities, use storage<T>::insert instead.
  • storage<T>::destroy, use storage<T>::erase instead.
  • sparse_set::construct for a single entity, use sparse_set::emplace instead.
  • sparse_set::construct for multiple entities, use sparse_set::insert instead.
  • sparse_set::destroy, use sparse_set::erase instead.
  • sparse_set::has, use sparse_set::contains instead.
  • group::less, use group::each instead.
  • view::less, use view::each instead.
  • meta_factory::alias, use meta_factory::type instead.
  • meta_type::alias, use meta_type::id instead.
  • meta_data::alias, use meta_data::id instead.
  • meta_func::alias, use meta_func::id instead.
  • entt::as_alias_t and entt::as_alias, use entt::as_ref_t and entt::as_ref instead.
  • entt::resolve by identifier, use entt::resolve_id instead.
  • observer::replace, use observer::update instead.
  • basic_snapshot<T>::destroyed, use basic_snapshot<T>::entities instead.
  • basic_snapshot_loader<T>::destroyed, use basic_snapshot_loader<T>::entities instead.
  • basic_continuous_loader<T>::destroyed, use basic_continuous_loader<T>::entities instead.
  • basic_continuous_loader::has, use basic_continuous_loader::contains instead.

Any other business

The documentation is up-to-date and the library is battle-tested with 100% coverage as usual.
I've also updated the FAQs and the section EnTT in Action with more and more examples.

I started a long term process to reduce the number of instantiations and therefore speed up the compilation.
This release contains some more changes in this regard. Still a work in progress though.