summaryrefslogtreecommitdiff
path: root/legacy/ephysics/src/lib/EPhysics.h
diff options
context:
space:
mode:
authorLeandro Dorileo <dorileo@profusion.mobi>2012-11-29 18:51:51 +0000
committerLeandro Dorileo <dorileo@profusion.mobi>2012-11-29 18:51:51 +0000
commit0b558bc80ce7c6ed4bae0c64fd0c37cd0c8a1fab (patch)
tree21bb2b60852cde6eb5d6e9fa2af43b3023380f2e /legacy/ephysics/src/lib/EPhysics.h
parent603239627c12d8f855bc3da610cf6cae1c48749d (diff)
EPhysics: generic constraint
This patch changes how constraints are created and configured, now we use a bullet generic implementation which let us operate on the 6 degrees of freedom(linear and angular ones). We have used 6dof for slider constraint but now we assume 2 types of constraints, single body - simply ephysics_constraint_add(body) - and a linked one - ephysics_constraint_linked_add(body1, body2) used to constrain 2 bodies linked together. Having said that we introduce the following changes: + migrate p2p constraint to 6Dof We want to have a constraint api generic enouth to allow many different constraint behaviour, 6Dof was picked to do that, so p2p needs a migration. + move ephysics_constraint_slider_* functions Since the whole constraint infra-sctructure is being migrated to 6Dof the linear and angular limit functions - previously used only by slider constraint - now looks more generic enough to be used by constraint in general. + add constraint anchor API Instead of telling the anchoring positioning in the constraint creating we have set it's default value to the the middle os the body and if the user wants to change it call ephysics_constraint_anchor_set and reset it. The ephysics_constraint_anchor_set() considers the canvas coordinate instead of using the body orientation. So now one can tell a constraints anchor is set to 100, 10, 0 in the canvas coordinate system and not (body_center.x - 20, body_center.y - 5, body_center.z - 1). + constraint migrate the bt_constraint Since we're working only with 6Dof constraints it is reasonable to change the constraints bt_constraint field to btGeneric6DofConstraint. + add 3 axes to constraints Now constraints API knows about x, y and z axes - linear and angular limiting, anchor setting and the constraint creation functions are fully supported. + constraint calls are renamed The constraint calls were renamed so ephysics_constraint_p2p_add() now is known as ephysics_constraint_linked_add() and ephysics_constraint_slider_add() became ephysics_constraint_add() where the first one is meant for constrain 2 bodies and the second one for single body constraints. --This line, and those below, will be ignored-- SVN revision: 79848
Diffstat (limited to '')
-rw-r--r--legacy/ephysics/src/lib/EPhysics.h163
1 files changed, 116 insertions, 47 deletions
diff --git a/legacy/ephysics/src/lib/EPhysics.h b/legacy/ephysics/src/lib/EPhysics.h
index f0c0b07e94..affac90c14 100644
--- a/legacy/ephysics/src/lib/EPhysics.h
+++ b/legacy/ephysics/src/lib/EPhysics.h
@@ -4397,123 +4397,192 @@ EAPI Eina_Bool ephysics_body_clockwise_get(const EPhysics_Body *body);
4397 * between bodies and the world. Constraints can limit movement angle, 4397 * between bodies and the world. Constraints can limit movement angle,
4398 * translation, or work like a motor. 4398 * translation, or work like a motor.
4399 * 4399 *
4400 * Constraints can be created with @ref ephysics_constraint_p2p_add() 4400 * Constraints can be created with @ref ephysics_constraint_linked_add()
4401 * or @ref ephysics_constraint_slider_add() and removed 4401 * or @ref ephysics_constraint_add() and removed
4402 * with @ref ephysics_constraint_del(). 4402 * with @ref ephysics_constraint_del().
4403 * Can be applied between two bodies or between a body and the world. 4403 * Can be applied between two bodies or between a body and the world.
4404 */ 4404 */
4405 4405
4406typedef struct _EPhysics_Constraint EPhysics_Constraint; /**< Constraint handle, used to limit bodies movements. Created with @ref ephysics_constraint_p2p_add() or @ref ephysics_constraint_slider_add() and deleted with @ref ephysics_constraint_del(). */ 4406typedef struct _EPhysics_Constraint EPhysics_Constraint; /**< Constraint handle, used to limit bodies movements. Created with @ref ephysics_constraint_linked_add() or @ref ephysics_constraint_add() and deleted with @ref ephysics_constraint_del(). */
4407 4407
4408/** 4408/**
4409 * @brief 4409 * @brief
4410 * Create a new constraint between 2 bodies(Point to Point constraint). 4410 * Create a new constraint between 2 bodies(Point to Point constraint).
4411 * 4411 *
4412 * The constraint will join two bodies(@p body1 and @p body2) limiting their 4412 * The constraint will join two bodies(@p body1 and @p body2) with angular and
4413 * movements based on specified anchors. 4413 * linear movements limited by calling ephysics_constraint_linear_limit_set()
4414 * and ephysics_constraint_angular_limit_set(). Anchors values can be defined
4415 * with ephysics_constraint_anchor_set().
4414 * 4416 *
4415 * @param body1 The first body to apply the constraint. 4417 * @param body1 The first body to apply the constraint.
4416 * @param body2 The second body to apply the constraint. 4418 * @param body2 The second body to apply the constraint.
4419 * @return A new linked(joining 2 bodies) constraint or @c NULL, on errors.
4420 *
4421 * @see ephysics_constraint_del().
4422 *
4423 * @ingroup EPhysics_Constraint
4424 */
4425EAPI EPhysics_Constraint *ephysics_constraint_linked_add(EPhysics_Body *body1, EPhysics_Body *body2);
4426
4427/**
4428 * @brief
4429 * Change the constraints anchors values on both constrained bodies.
4430 *
4431 * @note By default the anchors are in the middle of a body, if a body of 20, 20
4432 * is positioned at (10, 10) then its anchor is set to (20, 20).
4433 *
4434 * @note There`s no need to inform @p anchor_b2_x, @p anchor_b2_y and @p
4435 * anchor_b2_z if the constraint has been created using
4436 * ephysics_constraint_add().
4437 *
4438 * @param constraint The constraint to be set.
4417 * @param anchor_b1_x The first body X anchor. 4439 * @param anchor_b1_x The first body X anchor.
4418 * @param anchor_b1_y The fist body Y anchor. 4440 * @param anchor_b1_y The first body Y anchor.
4441 * @param anchor_b1_z The first body Z anchor.
4419 * @param anchor_b2_x The second body X anchor. 4442 * @param anchor_b2_x The second body X anchor.
4420 * @param anchor_b2_y The second body Y anchor. 4443 * @param anchor_b2_y The second body Y anchor.
4421 * @return A new p2p(point to point) constraint or @c NULL, on errors. 4444 * @param anchor_b2_z The second body Z anchor.
4422 * 4445 *
4423 * @see ephysics_constraint_del(). 4446 * @see ephysics_constraint_anchor_get().
4447 * @see ephysics_constraint_linked_add().
4424 * 4448 *
4425 * @ingroup EPhysics_Constraint 4449 * @ingroup EPhysics_Constraint
4426 */ 4450 */
4427EAPI EPhysics_Constraint *ephysics_constraint_p2p_add(EPhysics_Body *body1, EPhysics_Body *body2, Evas_Coord anchor_b1_x, Evas_Coord anchor_b1_y, Evas_Coord anchor_b2_x, Evas_Coord anchor_b2_y); 4451EAPI void ephysics_constraint_anchor_set(EPhysics_Constraint *constraint, Evas_Coord anchor_b1_x, Evas_Coord anchor_b1_y, Evas_Coord anchor_b1_z, Evas_Coord anchor_b2_x, Evas_Coord anchor_b2_y, Evas_Coord anchor_b2_z);
4428 4452
4429/** 4453/**
4430 * @brief 4454 * @brief
4431 * Create a new slider constraint. 4455 * Get the constraints anchors values on both constrained bodies.
4432 * 4456 *
4433 * The constraint will limit the linear and angular moving of a body. 4457 * @param constraint The constraint to get anchor values from.
4458 * @param anchor_b1_x Pointer to an Evas_Coord in which to store the first body
4459 * X anchor value.
4460 * @param anchor_b1_y Pointer to an Evas_Coord in which to store the first body
4461 * Y anchor value.
4462 * @param anchor_b1_z Pointer to an Evas_Coord in which to store the first body
4463 * Z anchor value.
4464 * @param anchor_b2_x Pointer to an Evas_Coord in which to store the second body
4465 * X anchor value.
4466 * @param anchor_b2_y Pointer to an Evas_Coord in which to store the second body
4467 * Y anchor value.
4468 * @param anchor_b2_z Pointer to an Evas_Coord in which to store the second body
4469 * Z anchor value.
4470 *
4471 * @see ephysics_constraint_anchor_set().
4472 * @see ephysics_constraint_linked_add().
4473 *
4474 * @ingroup EPhysics_Constraint
4475 */
4476EAPI void ephysics_constraint_anchor_get(const EPhysics_Constraint *constraint, Evas_Coord *anchor_b1_x, Evas_Coord *anchor_b1_y, Evas_Coord *anchor_b1_z, Evas_Coord *anchor_b2_x, Evas_Coord *anchor_b2_y, Evas_Coord *anchor_b2_z);
4477
4478/**
4479 * @brief
4480 * Create a new constraint.
4481 *
4482 * The constraint will limit the linear and angular moving of a body. This simple
4483 * constraint is designated to constraint a single body.
4434 * 4484 *
4435 * @param body The body to apply the constraint. 4485 * @param body The body to apply the constraint.
4436 * 4486 *
4437 * @see ephysics_constraint_slider_linear_limit_set() for linear moving limit 4487 * @see ephysics_constraint_linear_limit_set() for linear moving limit
4438 * configuration. 4488 * configuration.
4439 * @see ephysics_constraint_slider_angular_limit_set() for angular moving limit 4489 * @see ephysics_constraint_angular_limit_set() for angular moving limit
4440 * configuration. 4490 * configuration.
4441 * @return A new slider constraint or @c NULL on erros. 4491 * @return A new constraint or @c NULL on erros.
4442 * 4492 *
4443 * @see ephysics_constraint_del(). 4493 * @see ephysics_constraint_del().
4444 * 4494 *
4445 * @ingroup EPhysics_Constraint 4495 * @ingroup EPhysics_Constraint
4446 */ 4496 */
4447EAPI EPhysics_Constraint *ephysics_constraint_slider_add(EPhysics_Body *body); 4497EAPI EPhysics_Constraint *ephysics_constraint_add(EPhysics_Body *body);
4448 4498
4449/** 4499/**
4450 * @brief 4500 * @brief
4451 * Define the linear moving limits of a slider @p constraint. 4501 * Define the linear moving limits of a @p constraint.
4452 * 4502 *
4453 * The linear limits are defined from the body's position on. The user will 4503 * The linear limits are defined from the body's position on. The user will
4454 * want to limit the movements to the left, right, under and above the rigid 4504 * want to limit the movements on X, Y and Z axis where lower == upper axis
4455 * body. The unit for every limits are defined on Evas coordinates. 4505 * will be locked, lower > upper axis is free, lower < upper axis is limited to
4506 * the range.
4507 *
4508 * The unit for every limits are defined on Evas coordinates.
4456 * 4509 *
4457 * @param constraint The constraint to be set. 4510 * @param constraint The constraint to be set.
4458 * @param left_x The moving limit to the left on X axis - from the body's 4511 * @param lower_x The lower linear moving limit on X axis.
4459 * position on. 4512 * @param upper_x The upper linear moving limit on X axis.
4460 * @param under_y The moving limit down on Y axis - from the body's position 4513 * @param lower_y The lower linear moving limit on Y axis.
4461 * on. 4514 * @param upper_y The upper linear moving limit on Y axis.
4462 * @param right_x The moving limit to the right on X axis - from the body's 4515 * @param lower_z The lower linear moving limit on Z axis.
4463 * position on. 4516 * @param upper_z The upper linear moving limit on Z axis.
4464 * @param above_y The moving limit up on Y axis - from the body's position on. 4517 *
4465 * 4518 *
4466 * @see ephysics_constraint_slider_linear_limit_get() 4519 * @see ephysics_constraint_linear_limit_get()
4467 * @ingroup EPhysics_Constraint 4520 * @ingroup EPhysics_Constraint
4468 */ 4521 */
4469EAPI void ephysics_constraint_slider_linear_limit_set(EPhysics_Constraint *constraint, Evas_Coord left_x, Evas_Coord under_y, Evas_Coord right_x, Evas_Coord above_y); 4522EAPI void ephysics_constraint_linear_limit_set(EPhysics_Constraint *constraint, Evas_Coord lower_x, Evas_Coord upper_x, Evas_Coord lower_y, Evas_Coord upper_y, Evas_Coord lower_z, Evas_Coord upper_z);
4470 4523
4471/** 4524/**
4472 * @brief 4525 * @brief
4473 * Get the linear moving limits of a slider constraint. 4526 * Get the linear moving limits of a @p constraint.
4474 * 4527 *
4475 * @param constraint The constraint to get linear limits from. 4528 * @param constraint The constraint to get linear limits from.
4476 * @param left_x Pointer to set with the limit to the left on X axis. 4529 * @param lower_x Pointer to set with the lower limit to the X axis.
4477 * @param under_y Pointer to set with the limit down on Y axis. 4530 * @param upper_x Pointer to set with the upper limit to the X axis.
4478 * @param right_x Pointer to set with the limit to the right on X axis. 4531 * @param lower_y Pointer to set with the lower limit to the Y axis.
4479 * @param above_y Pointer to set with the limit up on Y axis. 4532 * @param upper_y Pointer to set with the upper limit to the Y axis.
4480 * 4533 * @param lower_z Pointer to set with the lower limit to the Z axis.
4481 * @see ephysics_constraint_slider_linear_limit_set() 4534 * @param upper_z Pointer to set with the upper limit to the Z axis.
4535 *
4536 * @see ephysics_constraint_linear_limit_set()
4482 * @ingroup EPhysics_Constraint 4537 * @ingroup EPhysics_Constraint
4483 */ 4538 */
4484EAPI void ephysics_constraint_slider_linear_limit_get(const EPhysics_Constraint *constraint, Evas_Coord *left_x, Evas_Coord *under_y, Evas_Coord *right_x, Evas_Coord *above_y); 4539EAPI void ephysics_constraint_linear_limit_get(const EPhysics_Constraint *constraint, Evas_Coord *lower_x, Evas_Coord *upper_x, Evas_Coord *lower_y, Evas_Coord *upper_y, Evas_Coord *lower_z, Evas_Coord *upper_z);
4485 4540
4486/** 4541/**
4487 * @brief 4542 * @brief
4488 * Set the angular moving limits of a slider @p constraint. 4543 * Set the angular moving limits of a @p constraint.
4489 * 4544 *
4490 * The angular moving limits is defined in degrees and will limit the moving on 4545 * The angular moving limits is defined in degrees and will limit the moving on
4491 * Z axis - counter clockwise and clockwise directions. 4546 * Z axis - counter clockwise and clockwise directions.
4492 * 4547 *
4493 * @param constraint The constraint to be set. 4548 * @param constraint The constraint to be set.
4549 * @param counter_clock_x Amount of degrees from 0.0 to 360.0 to limit counter
4550 * clockwise rotation on X axis.
4551 * @param clock_wise_x Amount of degrees from 0.0 to 360.0 to limit clockwise
4552 * rotation on X axis.
4553 * @param counter_clock_y Amount of degrees from 0.0 to 360.0 to limit counter
4554 * clockwise rotation o Y axis.
4555 * @param clock_wise_y Amount of degrees from 0.0 to 360.0 to limit clockwise
4556 * rotation on Y axis.
4494 * @param counter_clock_z Amount of degrees from 0.0 to 360.0 to limit 4557 * @param counter_clock_z Amount of degrees from 0.0 to 360.0 to limit
4495 * counter clockwise rotation. 4558 * counter clockwise rotation on Z axis.
4496 * @param clock_wise_z Amount of degrees from 0.0 to 360.0 to limit clockwise 4559 * @param clock_wise_z Amount of degrees from 0.0 to 360.0 to limit clockwise
4497 * rotation. 4560 * rotation on Z axis.
4498 * 4561 *
4499 * @see ephysics_constraint_slider_angular_limit_get() 4562 * @see ephysics_constraint_angular_limit_get()
4500 * @ingroup EPhysics_Constraint 4563 * @ingroup EPhysics_Constraint
4501 */ 4564 */
4502EAPI void ephysics_constraint_slider_angular_limit_set(EPhysics_Constraint *constraint, double counter_clock_z, double clock_wise_z); 4565EAPI void ephysics_constraint_angular_limit_set(EPhysics_Constraint *constraint, double counter_clock_x, double clock_wise_x, double counter_clock_y, double clock_wise_y, double counter_clock_z, double clock_wise_z);
4503 4566
4504/** 4567/**
4505 * @brief 4568 * @brief
4506 * Get the angular moving limits of a slider @p constraint. 4569 * Get the angular moving limits of a @p constraint.
4507 * 4570 *
4508 * @param constraint The constraint to get the angular limits from. 4571 * @param constraint The constraint to get the angular limits from.
4572 * @param counter_clock_x Pointer to set with the counter clockwise limmit
4573 * degrees on X axis.
4574 * @param clock_wise_x Pointer to set with the clockwise limit degrees on X axis.
4575 * @param counter_clock_y Pointer to set with the counter clockwise limit
4576 * degrees on Y axis.
4577 * @param clock_wise_y Pointer to set with the clockwise limit degrees on Y axis.
4509 * @param counter_clock_z Pointer to set with the counter clockwise limit 4578 * @param counter_clock_z Pointer to set with the counter clockwise limit
4510 * degrees. 4579 * degrees on Z axis.
4511 * @param clock_wise_z Pointer to set with the clockwise limit degrees. 4580 * @param clock_wise_z Pointer to set with the clockwise limit degrees on Z axis.
4512 * 4581 *
4513 * @see ephysics_constraint_slider_angular_limit_set() 4582 * @see ephysics_constraint_angular_limit_set()
4514 * @ingroup EPhysics_Constraint 4583 * @ingroup EPhysics_Constraint
4515 */ 4584 */
4516EAPI void ephysics_constraint_slider_angular_limit_get(const EPhysics_Constraint *constraint, double *counter_clock_z, double *clock_wise_z); 4585EAPI void ephysics_constraint_angular_limit_get(const EPhysics_Constraint *constraint, double *counter_clock_x, double *clock_wise_x, double *counter_clock_y, double *clock_wise_y, double *counter_clock_z, double *clock_wise_z);
4517 4586
4518/** 4587/**
4519 * @brief 4588 * @brief
@@ -4521,7 +4590,7 @@ EAPI void ephysics_constraint_slider_angular_limit_get(const EPhysics_Constraint
4521 * 4590 *
4522 * @param constraint The constraint to be deleted. 4591 * @param constraint The constraint to be deleted.
4523 * 4592 *
4524 * @see ephysics_constraint_p2p_add() for more details. 4593 * @see ephysics_constraint_linked_add() for more details.
4525 * @see ephysics_constraint_slider_add() for more details. 4594 * @see ephysics_constraint_slider_add() for more details.
4526 * 4595 *
4527 * @ingroup EPhysics_Constraint 4596 * @ingroup EPhysics_Constraint