diff --git a/legacy/ephysics/src/bin/ephysics_logo.c b/legacy/ephysics/src/bin/ephysics_logo.c index aa8f996edb..faaff4e14e 100644 --- a/legacy/ephysics/src/bin/ephysics_logo.c +++ b/legacy/ephysics/src/bin/ephysics_logo.c @@ -6,9 +6,6 @@ #include #include -/* TODO: move to EPhysics.h */ -#define EPHYSICS_BODY_MASS_IMMUTABLE (0.0) - #define WIDTH (512) #define HEIGHT (384) #define FLOOR_Y (HEIGHT - 80) @@ -219,7 +216,7 @@ elm_main(int argc __UNUSED__, char **argv __UNUSED__) ephysics_world_render_geometry_set(world, 0, 0, WIDTH, HEIGHT); ground_body = ephysics_body_box_add(world); - ephysics_body_mass_set(ground_body, EPHYSICS_BODY_MASS_IMMUTABLE); + ephysics_body_mass_set(ground_body, EPHYSICS_BODY_MASS_STATIC); ephysics_body_geometry_set(ground_body, -100, FLOOR_Y, WIDTH + 800, 10); ephysics_body_restitution_set(ground_body, 0.65); ephysics_body_friction_set(ground_body, 0.8); diff --git a/legacy/ephysics/src/lib/EPhysics.h b/legacy/ephysics/src/lib/EPhysics.h index 2d07668c3a..52d6ec83c5 100644 --- a/legacy/ephysics/src/lib/EPhysics.h +++ b/legacy/ephysics/src/lib/EPhysics.h @@ -1287,6 +1287,16 @@ EAPI void ephysics_world_simulation_get(const EPhysics_World *world, double *fix * moved or rotated. */ +/** + * @def EPHYSICS_BODY_MASS_STATIC + * @brief Mass amount used to makes a body static. + * + * Body will be set with infinite mass, so it will be immovable. + * + * @see ephysics_body_mass_set() for details. + */ +#define EPHYSICS_BODY_MASS_STATIC (0.0) + /** * @typedef EPhysics_Body_Collision * @@ -1770,6 +1780,13 @@ EAPI void ephysics_body_geometry_get(const EPhysics_Body *body, Evas_Coord *x, E * an object's resistance to the change of its speed. It's required to apply * more force on objects with more mass to increase its speed. * + * If mass is set to 0 the body will have infinite mass, so it will be + * immovable, static. @ref EPHYSICS_BODY_MASS_STATIC can be used too. + * + * Negative mass is not allowed. + * + * By default, a body is created with 1 kg. + * * @note The unit used for mass is kilograms. * * @param body The body to has its mass set. diff --git a/legacy/ephysics/src/lib/ephysics_body.cpp b/legacy/ephysics/src/lib/ephysics_body.cpp index 35bf24f9eb..2d1a16336b 100644 --- a/legacy/ephysics/src/lib/ephysics_body.cpp +++ b/legacy/ephysics/src/lib/ephysics_body.cpp @@ -1401,6 +1401,12 @@ ephysics_body_mass_set(EPhysics_Body *body, double mass) return; } + if (mass < 0) + { + ERR("Can't set body's mass, it must to be non-negative."); + return; + } + ephysics_world_lock_take(body->world); _ephysics_body_mass_set(body, mass); ephysics_world_lock_release(body->world);