16 entt::meta_factory<physics_box_shape>{}
17 .type(
"physics_box_shape"_hs)
22 .data<&physics_box_shape::center>(
"center"_hs)
28 .data<&physics_box_shape::extends>(
"extends"_hs)
38 try_save(ar, ser20::make_nvp(
"center", obj.center));
39 try_save(ar, ser20::make_nvp(
"extends", obj.extends));
46 try_load(ar, ser20::make_nvp(
"center", obj.center));
47 try_load(ar, ser20::make_nvp(
"extends", obj.extends));
55 entt::meta_factory<physics_sphere_shape>{}
56 .type(
"physics_sphere_shape"_hs)
61 .data<&physics_sphere_shape::center>(
"center"_hs)
67 .data<&physics_sphere_shape::radius>(
"radius"_hs)
79 try_save(ar, ser20::make_nvp(
"center", obj.center));
80 try_save(ar, ser20::make_nvp(
"radius", obj.radius));
87 try_load(ar, ser20::make_nvp(
"center", obj.center));
88 try_load(ar, ser20::make_nvp(
"radius", obj.radius));
96 entt::meta_factory<physics_capsule_shape>{}
97 .type(
"physics_capsule_shape"_hs)
102 .data<&physics_capsule_shape::center>(
"center"_hs)
108 .data<&physics_capsule_shape::radius>(
"radius"_hs)
116 .data<&physics_capsule_shape::length>(
"length"_hs)
128 try_save(ar, ser20::make_nvp(
"center", obj.center));
129 try_save(ar, ser20::make_nvp(
"radius", obj.radius));
130 try_save(ar, ser20::make_nvp(
"length", obj.length));
137 try_load(ar, ser20::make_nvp(
"center", obj.center));
138 try_load(ar, ser20::make_nvp(
"radius", obj.radius));
139 try_load(ar, ser20::make_nvp(
"length", obj.length));
147 entt::meta_factory<physics_cylinder_shape>{}
148 .type(
"physics_cylinder_shape"_hs)
153 .data<&physics_cylinder_shape::center>(
"center"_hs)
159 .data<&physics_cylinder_shape::radius>(
"radius"_hs)
167 .data<&physics_cylinder_shape::length>(
"length"_hs)
179 try_save(ar, ser20::make_nvp(
"center", obj.center));
180 try_save(ar, ser20::make_nvp(
"radius", obj.radius));
181 try_save(ar, ser20::make_nvp(
"length", obj.length));
188 try_load(ar, ser20::make_nvp(
"center", obj.center));
189 try_load(ar, ser20::make_nvp(
"radius", obj.radius));
190 try_load(ar, ser20::make_nvp(
"length", obj.length));
198 entt::meta_factory<mesh_collision_type>{}
199 .type(
"mesh_collision_type"_hs)
204 .data<mesh_collision_type::convex>(
"convex"_hs)
210 entt::meta_factory<physics_mesh_shape>{}
211 .type(
"physics_mesh_shape"_hs)
216 .data<&physics_mesh_shape::center>(
"center"_hs)
219 entt::attribute{
"tooltip",
"Center offset of the mesh collision shape."},
221 .data<&physics_mesh_shape::mesh_asset>(
"mesh_asset"_hs)
226 .data<&physics_mesh_shape::collision_type>(
"collision_type"_hs)
229 entt::attribute{
"tooltip",
"Type of collision shape (convex for dynamic, concave for static)."},
235 try_save(ar, ser20::make_nvp(
"center", obj.center));
236 try_save(ar, ser20::make_nvp(
"mesh_asset", obj.mesh_asset));
237 try_save(ar, ser20::make_nvp(
"collision_type", obj.collision_type));
245 try_load(ar, ser20::make_nvp(
"center", obj.center));
246 try_load(ar, ser20::make_nvp(
"mesh_asset", obj.mesh_asset));
247 try_load(ar, ser20::make_nvp(
"collision_type", obj.collision_type));
255 static const auto&
ps = entt::resolve<physics_box_shape>();
256 static const auto& ss = entt::resolve<physics_sphere_shape>();
257 static const auto& cs = entt::resolve<physics_capsule_shape>();
258 static const auto& cys = entt::resolve<physics_cylinder_shape>();
259 static const auto& ms = entt::resolve<physics_mesh_shape>();
261 std::vector<entt::meta_type> variant_types{
ps, ss, cs, cys, ms};
264 entt::meta_factory<physics_compound_shape>{}
265 .type(
"physics_compound_shape"_hs)
276 try_save(ar, ser20::make_nvp(
"shape", obj.shape));
283 try_load(ar, ser20::make_nvp(
"shape", obj.shape));
291 entt::meta_factory<physics_component>{}
292 .type(
"physics_component"_hs)
309 .data<&physics_component::set_is_kinematic, &physics_component::is_kinematic>(
"is_kinematic"_hs)
313 entt::attribute{
"tooltip",
"Is the rigidbody kinematic(A rigid body that is not affected by others and can be moved directly.)"},
315 .data<&physics_component::set_is_sensor, &physics_component::is_sensor>(
"is_sensor"_hs)
319 entt::attribute{
"tooltip",
"The rigidbody will not respond to collisions, i.e. it becomes a _sensor_."},
321 .data<&physics_component::set_is_autoscaled, &physics_component::is_autoscaled>(
"is_autoscaled"_hs)
325 entt::attribute{
"tooltip",
"Enables/Disables shape auto scale with transform."},
327 .data<&physics_component::set_mass, &physics_component::get_mass>(
"mass"_hs)
334 .data<&physics_component::set_collision_include_mask, &physics_component::get_collision_include_mask>(
"include_layers"_hs)
338 entt::attribute{
"tooltip",
"Layers to include when producing collisions."},
340 .data<&physics_component::set_collision_exclude_mask, &physics_component::get_collision_exclude_mask>(
"exclude_layers"_hs)
344 entt::attribute{
"tooltip",
"Layers to exclude when producing collisions."},
346 .data<nullptr, &physics_component::get_collision_mask>(
"collision_layers"_hs)
350 entt::attribute{
"tooltip",
"Layers (Include - Exclude) used when producing collisions."},
352 .data<nullptr, &physics_component::get_velocity>(
"velocity"_hs)
357 .data<nullptr, &physics_component::get_angular_velocity>(
"angular_velocity"_hs)
362 .data<&physics_component::set_freeze_position, &physics_component::get_freeze_position>(
"freeze_position"_hs)
368 .data<&physics_component::set_freeze_rotation, &physics_component::get_freeze_rotation>(
"freeze_rotation"_hs)
374 .data<&physics_component::set_material, &physics_component::get_material>(
"material"_hs)
380 .data<&physics_component::set_shapes, &physics_component::get_shapes>(
"shapes"_hs)
390 try_save(ar, ser20::make_nvp(
"is_using_gravity", obj.is_using_gravity()));
391 try_save(ar, ser20::make_nvp(
"is_kinematic", obj.is_kinematic()));
392 try_save(ar, ser20::make_nvp(
"is_sensor", obj.is_sensor()));
393 try_save(ar, ser20::make_nvp(
"is_autoscaled", obj.is_autoscaled()));
394 try_save(ar, ser20::make_nvp(
"mass", obj.get_mass()));
395 try_save(ar, ser20::make_nvp(
"include_layers", obj.get_collision_include_mask()));
396 try_save(ar, ser20::make_nvp(
"exclude_layers", obj.get_collision_exclude_mask()));
397 try_save(ar, ser20::make_nvp(
"freeze_position", obj.get_freeze_position()));
398 try_save(ar, ser20::make_nvp(
"freeze_rotation", obj.get_freeze_rotation()));
400 try_save(ar, ser20::make_nvp(
"material", obj.get_material()));
401 try_save(ar, ser20::make_nvp(
"shapes", obj.get_shapes()));
408 bool is_using_gravity{};
409 if(
try_load(ar, ser20::make_nvp(
"is_using_gravity", is_using_gravity)))
411 obj.set_is_using_gravity(is_using_gravity);
415 if(
try_load(ar, ser20::make_nvp(
"is_kinematic", is_kinematic)))
417 obj.set_is_kinematic(is_kinematic);
421 if(
try_load(ar, ser20::make_nvp(
"is_sensor", is_sensor)))
423 obj.set_is_sensor(is_sensor);
426 bool is_autoscaled{
true};
427 if(
try_load(ar, ser20::make_nvp(
"is_autoscaled", is_autoscaled)))
429 obj.set_is_autoscaled(is_autoscaled);
439 if(
try_load(ar, ser20::make_nvp(
"include_layers", include_layers)))
441 obj.set_collision_include_mask(include_layers);
444 if(
try_load(ar, ser20::make_nvp(
"exclude_layers", exclude_layers)))
446 obj.set_collision_exclude_mask(exclude_layers);
449 math::bvec3 freeze_position{};
450 if(
try_load(ar, ser20::make_nvp(
"freeze_position", freeze_position)))
452 obj.set_freeze_position(freeze_position);
455 math::bvec3 freeze_rotation{};
456 if(
try_load(ar, ser20::make_nvp(
"freeze_rotation", freeze_rotation)))
458 obj.set_freeze_rotation(freeze_rotation);
467 std::vector<physics_compound_shape> shapes;
468 if(
try_load(ar, ser20::make_nvp(
"shapes", shapes)))
470 obj.set_shapes(shapes);
Base class for materials used in rendering.
Component that handles physics properties and behaviors.
void set_is_using_gravity(bool use_gravity)
Sets whether the component uses gravity.
auto is_using_gravity() const noexcept -> bool
Checks if the component uses gravity.
attributes::value_type attribute
std::map< std::string, meta_any > attributes
BinaryInputArchive iarchive_binary_t
simd::JSONOutputArchive oarchive_associative_t
BinaryOutputArchive oarchive_binary_t
simd::JSONInputArchive iarchive_associative_t
mesh_collision_type
Specifies the type of mesh collision shape.
@ concave
Concave mesh collision (static only, slower but accurate)
#define SAVE_INSTANTIATE(cls, Archive)
auto try_save(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool
#define LOAD_INSTANTIATE(cls, Archive)
auto try_load(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool
Represents a handle to an asset, providing access and management functions.
Represents a box shape for physics calculations.
Represents a capsule shape for physics calculations.
Represents a compound shape that can contain multiple types of shapes.
Represents a cylinder shape for physics calculations.
Represents a mesh shape for physics calculations.
Represents a sphere shape for physics calculations.
Support for std::variant.