11#pragma once
22
3- #include < cstdint>
4- #include < vector>
5-
6- #include < godot_cpp/classes/physics_server2d.hpp>
7- #include < godot_cpp/classes/physics_server3d.hpp>
8- #include < godot_cpp/classes/shape2d.hpp>
9- #include < godot_cpp/classes/shape3d.hpp>
10- #include < godot_cpp/variant/rid.hpp>
11- #include < godot_cpp/variant/transform2d.hpp>
12- #include < godot_cpp/variant/transform3d.hpp>
13- #include < godot_cpp/variant/variant.hpp>
143#include <godot_cpp/variant/vector2.hpp>
154#include <godot_cpp/variant/vector3.hpp>
165
176#include "src/flecs_registry.h"
18- #include " src/flecs_singleton_registry.h"
197
208
219struct Velocity2D
@@ -28,78 +16,11 @@ struct Velocity3D
2816 godot ::Vector3 value ;
2917};
3018
31- struct PhysicsBodyShape2DDefinition
32- {
33- godot::Ref<godot::Shape2D> shape;
34- godot::Transform2D local_transform;
35- };
36-
37- struct PhysicsBodyShapes2D
38- {
39- std::vector<PhysicsBodyShape2DDefinition> shapes;
40- godot::PhysicsServer2D::BodyMode body_mode = godot::PhysicsServer2D::BODY_MODE_RIGID;
41- int64_t collision_layer = 1 ;
42- int64_t collision_mask = 1 ;
43- };
44-
45- struct PhysicsBodyInstance2D
46- {
47- godot::RID body_rid;
48- };
49-
50- struct PhysicsSpace2D
51- {
52- godot::RID space_rid;
53-
54- operator godot::Variant () const { return space_rid; }
55- };
56-
57- struct PhysicsBodyShape3DDefinition
58- {
59- godot::Ref<godot::Shape3D> shape;
60- godot::Transform3D local_transform;
61- };
62-
63- struct PhysicsBodyShapes3D
64- {
65- std::vector<PhysicsBodyShape3DDefinition> shapes;
66- godot::PhysicsServer3D::BodyMode body_mode = godot::PhysicsServer3D::BODY_MODE_RIGID;
67- int64_t collision_layer = 1 ;
68- int64_t collision_mask = 1 ;
69- };
70-
71- struct PhysicsBodyInstance3D
72- {
73- godot::RID body_rid;
74- };
75-
76- struct PhysicsSpace3D
77- {
78- godot::RID space_rid;
79-
80- operator godot::Variant () const { return space_rid; }
81- };
8219
8320inline FlecsRegistry register_physics_components ([](flecs ::world & world ) {
8421 world .component < Velocity2D > ( )
8522 .member < godot ::Vector2 > ("value" );
8623
8724 world .component < Velocity3D > ( )
8825 .member < godot ::Vector3 > ("value" );
89-
90- world.component <PhysicsBodyShapes2D>();
91- world.component <PhysicsBodyInstance2D>();
92- world.component <PhysicsSpace2D>().add (flecs::Singleton);
93- world.component <PhysicsBodyShapes3D>();
94- world.component <PhysicsBodyInstance3D>();
95- world.component <PhysicsSpace3D>().add (flecs::Singleton);
96-
97- register_singleton_getter<PhysicsSpace2D>(" PhysicsSpace2D" );
98- register_singleton_setter<godot::RID>(" PhysicsSpace2D" , [](flecs::world& world, const godot::RID& space_rid) {
99- world.set <PhysicsSpace2D>({ space_rid });
100- });
101- register_singleton_getter<PhysicsSpace3D>(" PhysicsSpace3D" );
102- register_singleton_setter<godot::RID>(" PhysicsSpace3D" , [](flecs::world& world, const godot::RID& space_rid) {
103- world.set <PhysicsSpace3D>({ space_rid });
104- });
10526});
0 commit comments