From: Enlightenment S. <no-...@en...> - 2012-10-04 22:39:17
|
Log: ephysics: add define to infinite mass Also check for invalid values on mass set. Author: bdilly Date: 2012-10-04 15:39:10 -0700 (Thu, 04 Oct 2012) New Revision: 77459 Trac: http://trac.enlightenment.org/e/changeset/77459 Modified: trunk/ephysics/src/bin/ephysics_logo.c trunk/ephysics/src/lib/EPhysics.h trunk/ephysics/src/lib/ephysics_body.cpp Modified: trunk/ephysics/src/bin/ephysics_logo.c =================================================================== --- trunk/ephysics/src/bin/ephysics_logo.c 2012-10-04 22:38:58 UTC (rev 77458) +++ trunk/ephysics/src/bin/ephysics_logo.c 2012-10-04 22:39:10 UTC (rev 77459) @@ -6,9 +6,6 @@ #include <EPhysics.h> #include <Evas.h> -/* 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 @@ 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); Modified: trunk/ephysics/src/lib/EPhysics.h =================================================================== --- trunk/ephysics/src/lib/EPhysics.h 2012-10-04 22:38:58 UTC (rev 77458) +++ trunk/ephysics/src/lib/EPhysics.h 2012-10-04 22:39:10 UTC (rev 77459) @@ -1288,6 +1288,16 @@ */ /** + * @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 * * Body collision wraps collision informations. @@ -1770,6 +1780,13 @@ * 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. Modified: trunk/ephysics/src/lib/ephysics_body.cpp =================================================================== --- trunk/ephysics/src/lib/ephysics_body.cpp 2012-10-04 22:38:58 UTC (rev 77458) +++ trunk/ephysics/src/lib/ephysics_body.cpp 2012-10-04 22:39:10 UTC (rev 77459) @@ -1401,6 +1401,12 @@ 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); |