ephysics: fix triangles index get
It will works only with cloths for now. SVN revision: 78730
This commit is contained in:
parent
cd4a6f05d7
commit
818e957c89
|
@ -1803,13 +1803,13 @@ ephysics_body_soft_body_triangle_move(EPhysics_Body *body, int idx, Evas_Coord x
|
||||||
EAPI int
|
EAPI int
|
||||||
ephysics_body_soft_body_triangle_index_get(EPhysics_Body *body, Evas_Coord x, Evas_Coord y)
|
ephysics_body_soft_body_triangle_index_get(EPhysics_Body *body, Evas_Coord x, Evas_Coord y)
|
||||||
{
|
{
|
||||||
btVector3 ray_from;
|
int w, h, r, c, index = -1;
|
||||||
btVector3 ray_to;
|
|
||||||
btSoftBody::sRayCast result;
|
if (!body->evas_obj)
|
||||||
Evas_Coord wh, bw;
|
{
|
||||||
btScalar xx, yy;
|
ERR("No evas object associated to body");
|
||||||
double rate;
|
return -1;
|
||||||
int index = -1;
|
}
|
||||||
|
|
||||||
if (body->type == EPHYSICS_BODY_TYPE_RIGID)
|
if (body->type == EPHYSICS_BODY_TYPE_RIGID)
|
||||||
{
|
{
|
||||||
|
@ -1817,21 +1817,17 @@ ephysics_body_soft_body_triangle_index_get(EPhysics_Body *body, Evas_Coord x, Ev
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ephysics_world_lock_take(body->world);
|
if (body->type == EPHYSICS_BODY_TYPE_SOFT)
|
||||||
rate = ephysics_world_rate_get(body->world);
|
{
|
||||||
ephysics_world_render_geometry_get(body->world, NULL, NULL, NULL, NULL, &wh,
|
ERR("Can't get node index, not implemented for soft bodies yet.");
|
||||||
NULL);
|
return -1;
|
||||||
ephysics_body_geometry_get(body, NULL, NULL, NULL, &bw, NULL, NULL);
|
}
|
||||||
|
|
||||||
xx = x / rate;
|
evas_object_geometry_get(body->evas_obj, NULL, NULL, &w, &h);
|
||||||
yy = (wh - y) / rate;
|
r = y * body->cloth_rows / h;
|
||||||
|
c = (w - x) * body->cloth_columns / w;
|
||||||
|
|
||||||
ray_from = btVector3(xx, yy, -100);
|
index = 2 * r + c * body->cloth_rows * 2;
|
||||||
ray_to = btVector3(xx, yy, 100);
|
|
||||||
|
|
||||||
if (body->soft_body->rayTest(ray_from, ray_to, result))
|
|
||||||
index = result.index;
|
|
||||||
ephysics_world_lock_release(body->world);
|
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue