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)
209 .data<mesh_collision_type::concave>(
"concave"_hs)
218 entt::meta_factory<physics_mesh_shape>{}
219 .type(
"physics_mesh_shape"_hs)
224 .data<&physics_mesh_shape::center>(
"center"_hs)
227 entt::attribute{
"tooltip",
"Center offset of the mesh collision shape."},
229 .data<&physics_mesh_shape::mesh_asset>(
"mesh_asset"_hs)
234 .data<&physics_mesh_shape::collision_type>(
"collision_type"_hs)
237 entt::attribute{
"tooltip",
"Type of collision shape (convex for dynamic, concave for static)."},
243 try_save(ar, ser20::make_nvp(
"center", obj.center));
244 try_save(ar, ser20::make_nvp(
"mesh_asset", obj.mesh_asset));
245 try_save(ar, ser20::make_nvp(
"collision_type", obj.collision_type));
253 try_load(ar, ser20::make_nvp(
"center", obj.center));
254 try_load(ar, ser20::make_nvp(
"mesh_asset", obj.mesh_asset));
255 try_load(ar, ser20::make_nvp(
"collision_type", obj.collision_type));
263 static const auto&
ps = entt::resolve<physics_box_shape>();
264 static const auto& ss = entt::resolve<physics_sphere_shape>();
265 static const auto& cs = entt::resolve<physics_capsule_shape>();
266 static const auto& cys = entt::resolve<physics_cylinder_shape>();
267 static const auto& ms = entt::resolve<physics_mesh_shape>();
269 std::vector<entt::meta_type> variant_types{
ps, ss, cs, cys, ms};
272 entt::meta_factory<physics_compound_shape>{}
273 .type(
"physics_compound_shape"_hs)
284 try_save(ar, ser20::make_nvp(
"shape", obj.shape));
291 try_load(ar, ser20::make_nvp(
"shape", obj.shape));
299 entt::meta_factory<physics_component>{}
300 .type(
"physics_component"_hs)
317 .data<&physics_component::set_is_kinematic, &physics_component::is_kinematic>(
"is_kinematic"_hs)
321 entt::attribute{
"tooltip",
"Is the rigidbody kinematic(A rigid body that is not affected by others and can be moved directly.)"},
323 .data<&physics_component::set_is_sensor, &physics_component::is_sensor>(
"is_sensor"_hs)
327 entt::attribute{
"tooltip",
"The rigidbody will not respond to collisions, i.e. it becomes a _sensor_."},
329 .data<&physics_component::set_is_autoscaled, &physics_component::is_autoscaled>(
"is_autoscaled"_hs)
333 entt::attribute{
"tooltip",
"Enables/Disables shape auto scale with transform."},
335 .data<&physics_component::set_mass, &physics_component::get_mass>(
"mass"_hs)
342 .data<&physics_component::set_collision_include_mask, &physics_component::get_collision_include_mask>(
"include_layers"_hs)
346 entt::attribute{
"tooltip",
"Layers to include when producing collisions."},
348 .data<&physics_component::set_collision_exclude_mask, &physics_component::get_collision_exclude_mask>(
"exclude_layers"_hs)
352 entt::attribute{
"tooltip",
"Layers to exclude when producing collisions."},
354 .data<nullptr, &physics_component::get_collision_mask>(
"collision_layers"_hs)
358 entt::attribute{
"tooltip",
"Layers (Include - Exclude) used when producing collisions."},
360 .data<nullptr, &physics_component::get_velocity>(
"velocity"_hs)
365 .data<nullptr, &physics_component::get_angular_velocity>(
"angular_velocity"_hs)
370 .data<&physics_component::set_freeze_position, &physics_component::get_freeze_position>(
"freeze_position"_hs)
376 .data<&physics_component::set_freeze_rotation, &physics_component::get_freeze_rotation>(
"freeze_rotation"_hs)
382 .data<&physics_component::set_material, &physics_component::get_material>(
"material"_hs)
388 .data<&physics_component::set_shapes, &physics_component::get_shapes>(
"shapes"_hs)
398 try_save(ar, ser20::make_nvp(
"is_using_gravity", obj.is_using_gravity()));
399 try_save(ar, ser20::make_nvp(
"is_kinematic", obj.is_kinematic()));
400 try_save(ar, ser20::make_nvp(
"is_sensor", obj.is_sensor()));
401 try_save(ar, ser20::make_nvp(
"is_autoscaled", obj.is_autoscaled()));
402 try_save(ar, ser20::make_nvp(
"mass", obj.get_mass()));
403 try_save(ar, ser20::make_nvp(
"include_layers", obj.get_collision_include_mask()));
404 try_save(ar, ser20::make_nvp(
"exclude_layers", obj.get_collision_exclude_mask()));
405 try_save(ar, ser20::make_nvp(
"freeze_position", obj.get_freeze_position()));
406 try_save(ar, ser20::make_nvp(
"freeze_rotation", obj.get_freeze_rotation()));
408 try_save(ar, ser20::make_nvp(
"material", obj.get_material()));
409 try_save(ar, ser20::make_nvp(
"shapes", obj.get_shapes()));
416 bool is_using_gravity{};
417 if(
try_load(ar, ser20::make_nvp(
"is_using_gravity", is_using_gravity)))
419 obj.set_is_using_gravity(is_using_gravity);
423 if(
try_load(ar, ser20::make_nvp(
"is_kinematic", is_kinematic)))
425 obj.set_is_kinematic(is_kinematic);
429 if(
try_load(ar, ser20::make_nvp(
"is_sensor", is_sensor)))
431 obj.set_is_sensor(is_sensor);
434 bool is_autoscaled{
true};
435 if(
try_load(ar, ser20::make_nvp(
"is_autoscaled", is_autoscaled)))
437 obj.set_is_autoscaled(is_autoscaled);
447 if(
try_load(ar, ser20::make_nvp(
"include_layers", include_layers)))
449 obj.set_collision_include_mask(include_layers);
452 if(
try_load(ar, ser20::make_nvp(
"exclude_layers", exclude_layers)))
454 obj.set_collision_exclude_mask(exclude_layers);
457 math::bvec3 freeze_position{};
458 if(
try_load(ar, ser20::make_nvp(
"freeze_position", freeze_position)))
460 obj.set_freeze_position(freeze_position);
463 math::bvec3 freeze_rotation{};
464 if(
try_load(ar, ser20::make_nvp(
"freeze_rotation", freeze_rotation)))
466 obj.set_freeze_rotation(freeze_rotation);
475 std::vector<physics_compound_shape> shapes;
476 if(
try_load(ar, ser20::make_nvp(
"shapes", shapes)))
478 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.
#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
Thread-safe handle to an asset.
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.