EnTThas been a dream so far, we haven't found a single bug to date and it's super easy to work with-- Every EnTT User Ever
EnTT is a header-only, tiny and easy to use library for game programming and much more written in modern C++ .
Among others, it's used in Minecraft by Mojang, the ArcGIS Runtime SDKs by Esri and the amazing Ragdoll .
如果您没有在列表中看到您的项目,请打开问题,提交PR或将#entt标签添加到您的主题中! ?
您想跟上更改吗?还是有一个不需要您打开问题的问题?
加入Gitter频道和Discord Server,与您这样的其他用户会面。我们越多,对每个人来说越好。
不要忘记检查常见问题解答和Wiki。您的答案可能已经存在。
您想支持EnTT吗?考虑成为赞助商或通过PayPal捐款。
非常感谢这些人,并特别感谢:


实体 - 组件系统(也称为ECS )是主要用于游戏开发的建筑模式。有关更多详细信息:
该项目最初是纯实体组件系统。随着时间的流逝,随着越来越多的类和功能的添加,代码库不断增长。
这是今天提供的简短但不完整的清单:
constexpr实用程序。 Consider this list a work in progress as well as the project. The whole API is fully documented in-code for those who are brave enough to read it.
Please, do note that all tools are also DLL-friendly now and run smoothly across boundaries.
One thing known to most is that EnTT is also used in Minecraft .
鉴于该游戏几乎无处不在,因此我可以自信地说,在可以铭记的每个平台上对图书馆进行了充分的测试。
# include < entt/entt.hpp >
struct position {
float x;
float y;
};
struct velocity {
float dx;
float dy;
};
void update (entt::registry ®istry) {
auto view = registry. view < const position, velocity>();
// use a callback
view. each ([]( const auto &pos, auto &vel) { /* ... */ });
// use an extended callback
view. each ([]( const auto entity, const auto &pos, auto &vel) { /* ... */ });
// use a range-for
for ( auto [entity, pos, vel]: view. each ()) {
// ...
}
// use forward iterators and get only the components of interest
for ( auto entity: view) {
auto &vel = view. get <velocity>(entity);
// ...
}
}
int main () {
entt::registry registry;
for ( auto i = 0u ; i < 10u ; ++i) {
const auto entity = registry. create ();
registry. emplace <position>(entity, i * 1 . f , i * 1 . f );
if (i % 2 == 0 ) { registry. emplace <velocity>(entity, i * . 1f , i * . 1f ); }
}
update (registry);
}出于错误的原因,我开始开发EnTT :我的目标是设计一个实体组件系统,以在性能和可能的内存使用方面击败另一个知名的开源库。
In the end, I did it, but it wasn't very satisfying. Actually it wasn't satisfying at all. The fastest and nothing more, fairly little indeed.当我意识到这一点时,我努力保持完整的EnTT表现,并同时添加我想在自己的库中看到的所有功能。
如今, EnTT终于是我想要的:仍然比竞争对手快,在平均情况下使用较低的内存使用情况,非常好的API和一系列惊人的功能。 And even more, of course.
就其价值而言,您永远不会看到我试图使其他项目看起来不好,或者提供可疑的比较只是为了使该库看起来更酷。
I leave this activity to others, if they enjoy it (and it seems that some people actually like it). I prefer to make better use of my time.
如果您有兴趣,可以通过将ENTT_BUILD_BENCHMARK CMake设置为ON ,可以在发行模式下编译benchmark测试(启用编译器优化,否则就没有意义),然后评估您对结果是否满意。
There are also a lot of projects out there that use EnTT as a basis for comparison (this should already tell you a lot).这些基准中的许多是完全错误的,许多其他基准只是不完整的,善于省略一些信息并使用错误的功能比较给定功能。当然,也有不错的,但是如果没有人更新它们,它们会很快,尤其是当与之打交道的图书馆会积极开发时。
Out of all of them, this seems like the most up-to-date project and also covers a certain number of libraries. I can't say exactly whether EnTT is used correctly or not. However, even if used poorly, it should still give the reader an idea of where it's going to operate.
EnTT is a header-only library. This means that including the entt.hpp header is enough to include the library as a whole and use it. For those who are interested only in the entity-component system, consider to include the sole entity/registry.hpp header instead.
It's a matter of adding the following line to the top of a file:
# include < entt/entt.hpp >Use the line below to include only the entity-component system instead:
# include < entt/entity/registry.hpp > Then pass the proper -I argument to the compiler to add the src directory to the include paths.
To be able to use EnTT , users must provide a full-featured compiler that supports at least C++17.
The requirements below are mandatory to compile the tests and to extract the documentation:
CMake version 3.7 or later.Doxygen version 1.8 or later.另外,巴泽尔也被支持作为建筑系统(Zaucy愿意维护它的Zaucy)。
In the documentation below I'll still refer to CMake , this being the official build system of the library.
To use EnTT from a CMake project, just link an existing target to the EnTT::EnTT alias.
该库提供了您所需的所有定位(如find_package ),嵌入(如add_subdirectory中),获取(如FetchContent )或以许多您可以想到的方式以及涉及CMake方式。
涵盖所有可能的案例将需要论文而不是简单的回复文件文件,但是我有信心阅读本节的任何人也知道它的含义,并且可以在毫无问题的情况下使用CMake项目中的EnTT 。
When using CMake , just enable the option ENTT_INCLUDE_NATVIS and enjoy it.
否则,大多数工具都通过NATVI覆盖,所有文件都可以在natvis目录中找到,除以模块。
如果您发现错误或有建议,欢迎任何贡献!
EnTT可用于一些最著名的包装工具。尤其:
Conan ,开发人员的C/C ++软件包管理器。
vcpkg ,Microsoft VC ++包装工具。
您只需几个简单的步骤即可下载和安装EnTT :
$ git clone https://github.com/Microsoft/vcpkg.git
$ cd vcpkg
$ ./bootstrap-vcpkg.sh
$ ./vcpkg integrate install
$ vcpkg install entt
或者,您可以使用experimental功能来测试最新更改:
vcpkg install entt[experimental] --head
vcpkg中的EnTT端口由Microsoft团队成员和社区贡献者保持最新状态。
如果该版本已过时,请在vcpkg存储库上创建问题或拉出请求。
Homebrew ,MacOS缺少的软件包经理。
可作为自制配方。只需键入以下内容即可安装它:
brew install skypjack/entt/entt
build2 ,构建用于开发和包装C和C ++代码的工具链。
为了在build2项目中使用entt软件包,在manifest文件中添加以下行或类似行:
depends: entt ^3.0.0
还要检查配置是否是指有效的存储库,以便可以通过build2 :build2:
开源社区中央存储库cppget.org ,可作为https://pkg.cppget.org/1/stable访问。
包源存储库:可作为https://github.com/build2-packaging/entt.git或ssh://[email protected]/build2-packaging/entt.git访问。随时报告此软件包的问题。
两者都可以与bpkg add-repo一起使用,也可以在project repositories.manifest中添加。有关更多详细信息,请参见官方文档。
bzlmod ,Bazel的外部依赖管理系统。
要在bazel项目中使用entt模块,请将以下内容添加到您的MODULE.bazel文件:
bazel_dep ( name = "entt" , version = "3.12.2" )现在将以@entt ( @entt//:entt的简短)提供ENTT,可在您的cc_*规则deps中使用。
将此列表视为正在进行的工作,并在您愿意的情况下帮助我更长的时间。
EnTT还支持pkg-config (至少为支持的某些定义)。运行CMake时,生成并安装在适当目录中entt.pc合适文件。
这也应该使与Meson或类似工具的工具更容易使用。
该文档基于doxygen。建造它:
$ cd build
$ cmake .. -DENTT_BUILD_DOCS=ON
$ make
API参考是在build/docs/html目录中以HTML格式创建的。使用您喜欢的浏览器来浏览它:
$ cd build
$ your_favorite_browser docs/html/index.html
同一版本也可以在线提供最新版本,这是最后一个稳定的标签。
此外,还有一个致力于该项目的Wiki,用户可以在其中找到所有相关的文档页面。
要编译和运行测试, EnTT需要Googletest 。
cmake downloads and compiles the library before compiling anything else. In order to build the tests, set the CMake option ENTT_BUILD_TESTING to ON .
To build the most basic set of tests:
$ cd build$ cmake -DENTT_BUILD_TESTING=ON ..$ make$ make testNote that benchmarks are not part of this set.
EnTT is widely used in private and commercial applications. I cannot even mention most of them because of some signatures I put on some documents time ago.幸运的是,也有一些人花时间基于EnTT实施开源项目,并且在记录记录时没有退缩。
Here you can find an incomplete list of games, applications and articles that can be used as a reference.
If you know of other resources out there that are about EnTT , feel free to open an issue or a PR and I'll be glad to add them to the list.
Requests for features, PRs, suggestions and feedback are highly appreciated.
如果您发现自己可以通过您的经验为项目提供帮助,并且想为项目做出贡献,或者出于某些其他原因确实想获得该项目的一部分,请随时与我联系(您可以在个人资料中找到邮件)。
I can't promise that each and every contribution will be accepted, but I can assure that I'll do my best to take them all as soon as possible.
If you decide to participate, please see the guidelines for contributing before to create issues or pull requests.
Take also a look at the contributors list to know who has participated so far.
Code and documentation Copyright (c) 2017-2024 Michele Caini.
Colorful logo Copyright (c) 2018-2021 Richard Caseres.
Code released under the MIT license.
Documentation released under CC BY 4.0.
All logos released under CC BY-SA 4.0.