15 entt::meta_factory<physics_box_shape>{}
16 .type(
"physics_box_shape"_hs)
21 .data<&physics_box_shape::center>(
"center"_hs)
27 .data<&physics_box_shape::extends>(
"extends"_hs)
37 try_save(ar, ser20::make_nvp(
"center", obj.center));
38 try_save(ar, ser20::make_nvp(
"extends", obj.extends));
45 try_load(ar, ser20::make_nvp(
"center", obj.center));
46 try_load(ar, ser20::make_nvp(
"extends", obj.extends));
54 entt::meta_factory<physics_sphere_shape>{}
55 .type(
"physics_sphere_shape"_hs)
60 .data<&physics_sphere_shape::center>(
"center"_hs)
66 .data<&physics_sphere_shape::radius>(
"radius"_hs)
78 try_save(ar, ser20::make_nvp(
"center", obj.center));
79 try_save(ar, ser20::make_nvp(
"radius", obj.radius));
86 try_load(ar, ser20::make_nvp(
"center", obj.center));
87 try_load(ar, ser20::make_nvp(
"radius", obj.radius));
95 entt::meta_factory<physics_capsule_shape>{}
96 .type(
"physics_capsule_shape"_hs)
101 .data<&physics_capsule_shape::center>(
"center"_hs)
107 .data<&physics_capsule_shape::radius>(
"radius"_hs)
115 .data<&physics_capsule_shape::length>(
"length"_hs)
127 try_save(ar, ser20::make_nvp(
"center", obj.center));
128 try_save(ar, ser20::make_nvp(
"radius", obj.radius));
129 try_save(ar, ser20::make_nvp(
"length", obj.length));
136 try_load(ar, ser20::make_nvp(
"center", obj.center));
137 try_load(ar, ser20::make_nvp(
"radius", obj.radius));
138 try_load(ar, ser20::make_nvp(
"length", obj.length));
146 entt::meta_factory<physics_cylinder_shape>{}
147 .type(
"physics_cylinder_shape"_hs)
152 .data<&physics_cylinder_shape::center>(
"center"_hs)
158 .data<&physics_cylinder_shape::radius>(
"radius"_hs)
166 .data<&physics_cylinder_shape::length>(
"length"_hs)
178 try_save(ar, ser20::make_nvp(
"center", obj.center));
179 try_save(ar, ser20::make_nvp(
"radius", obj.radius));
180 try_save(ar, ser20::make_nvp(
"length", obj.length));
187 try_load(ar, ser20::make_nvp(
"center", obj.center));
188 try_load(ar, ser20::make_nvp(
"radius", obj.radius));
189 try_load(ar, ser20::make_nvp(
"length", obj.length));
197 static const auto& ps = entt::resolve<physics_box_shape>();
198 static const auto& ss = entt::resolve<physics_sphere_shape>();
199 static const auto& cs = entt::resolve<physics_capsule_shape>();
200 static const auto& cys = entt::resolve<physics_cylinder_shape>();
202 std::vector<entt::meta_type> variant_types{ps, ss, cs, cys};
205 entt::meta_factory<physics_compound_shape>{}
206 .type(
"physics_compound_shape"_hs)
217 try_save(ar, ser20::make_nvp(
"shape", obj.shape));
224 try_load(ar, ser20::make_nvp(
"shape", obj.shape));
232 entt::meta_factory<physics_component>{}
233 .type(
"physics_component"_hs)
250 .data<&physics_component::set_is_kinematic, &physics_component::is_kinematic>(
"is_kinematic"_hs)
254 entt::attribute{
"tooltip",
"Is the rigidbody kinematic(A rigid body that is not affected by others and can be moved directly.)"},
256 .data<&physics_component::set_is_sensor, &physics_component::is_sensor>(
"is_sensor"_hs)
260 entt::attribute{
"tooltip",
"The rigidbody will not respond to collisions, i.e. it becomes a _sensor_."},
262 .data<&physics_component::set_is_autoscaled, &physics_component::is_autoscaled>(
"is_autoscaled"_hs)
266 entt::attribute{
"tooltip",
"Enables/Disables shape auto scale with transform."},
268 .data<&physics_component::set_mass, &physics_component::get_mass>(
"mass"_hs)
275 .data<&physics_component::set_collision_include_mask, &physics_component::get_collision_include_mask>(
"include_layers"_hs)
279 entt::attribute{
"tooltip",
"Layers to include when producing collisions."},
281 .data<&physics_component::set_collision_exclude_mask, &physics_component::get_collision_exclude_mask>(
"exclude_layers"_hs)
285 entt::attribute{
"tooltip",
"Layers to exclude when producing collisions."},
287 .data<nullptr, &physics_component::get_collision_mask>(
"collision_layers"_hs)
291 entt::attribute{
"tooltip",
"Layers (Include - Exclude) used when producing collisions."},
293 .data<nullptr, &physics_component::get_velocity>(
"velocity"_hs)
298 .data<nullptr, &physics_component::get_angular_velocity>(
"angular_velocity"_hs)
303 .data<&physics_component::set_freeze_position, &physics_component::get_freeze_position>(
"freeze_position"_hs)
309 .data<&physics_component::set_freeze_rotation, &physics_component::get_freeze_rotation>(
"freeze_rotation"_hs)
315 .data<&physics_component::set_material, &physics_component::get_material>(
"material"_hs)
321 .data<&physics_component::set_shapes, &physics_component::get_shapes>(
"shapes"_hs)
331 try_save(ar, ser20::make_nvp(
"is_using_gravity", obj.is_using_gravity()));
332 try_save(ar, ser20::make_nvp(
"is_kinematic", obj.is_kinematic()));
333 try_save(ar, ser20::make_nvp(
"is_sensor", obj.is_sensor()));
334 try_save(ar, ser20::make_nvp(
"is_autoscaled", obj.is_autoscaled()));
335 try_save(ar, ser20::make_nvp(
"mass", obj.get_mass()));
336 try_save(ar, ser20::make_nvp(
"include_layers", obj.get_collision_include_mask()));
337 try_save(ar, ser20::make_nvp(
"exclude_layers", obj.get_collision_exclude_mask()));
338 try_save(ar, ser20::make_nvp(
"freeze_position", obj.get_freeze_position()));
339 try_save(ar, ser20::make_nvp(
"freeze_rotation", obj.get_freeze_rotation()));
341 try_save(ar, ser20::make_nvp(
"material", obj.get_material()));
342 try_save(ar, ser20::make_nvp(
"shapes", obj.get_shapes()));
349 bool is_using_gravity{};
350 if(
try_load(ar, ser20::make_nvp(
"is_using_gravity", is_using_gravity)))
352 obj.set_is_using_gravity(is_using_gravity);
356 if(
try_load(ar, ser20::make_nvp(
"is_kinematic", is_kinematic)))
358 obj.set_is_kinematic(is_kinematic);
362 if(
try_load(ar, ser20::make_nvp(
"is_sensor", is_sensor)))
364 obj.set_is_sensor(is_sensor);
367 bool is_autoscaled{
true};
368 if(
try_load(ar, ser20::make_nvp(
"is_autoscaled", is_autoscaled)))
370 obj.set_is_autoscaled(is_autoscaled);
380 if(
try_load(ar, ser20::make_nvp(
"include_layers", include_layers)))
382 obj.set_collision_include_mask(include_layers);
385 if(
try_load(ar, ser20::make_nvp(
"exclude_layers", exclude_layers)))
387 obj.set_collision_exclude_mask(exclude_layers);
390 math::bvec3 freeze_position{};
391 if(
try_load(ar, ser20::make_nvp(
"freeze_position", freeze_position)))
393 obj.set_freeze_position(freeze_position);
396 math::bvec3 freeze_rotation{};
397 if(
try_load(ar, ser20::make_nvp(
"freeze_rotation", freeze_rotation)))
399 obj.set_freeze_rotation(freeze_rotation);
408 std::vector<physics_compound_shape> shapes;
409 if(
try_load(ar, ser20::make_nvp(
"shapes", shapes)))
411 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
#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 sphere shape for physics calculations.
Support for std::variant.