From d7d65fa2f2b51d03f7bdfcbceedca99188ce979c Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Wed, 19 Feb 2014 11:57:14 -0300 Subject: -improved physics ccd -html5 exporter works again -disable repeat on image loader by default -can change shape offset en tileset, texture offset was broken --- scene/resources/shape_2d.cpp | 62 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'scene/resources/shape_2d.cpp') diff --git a/scene/resources/shape_2d.cpp b/scene/resources/shape_2d.cpp index d87645495..ca891920d 100644 --- a/scene/resources/shape_2d.cpp +++ b/scene/resources/shape_2d.cpp @@ -47,20 +47,82 @@ real_t Shape2D::get_custom_solver_bias() const{ } +bool Shape2D::collide_with_motion(const Matrix32& p_local_xform, const Vector2& p_local_motion, const Ref& p_shape, const Matrix32& p_shape_xform, const Vector2 &p_shape_motion) { + + ERR_FAIL_COND_V(p_shape.is_null(),false); + int r; + return Physics2DServer::get_singleton()->shape_collide(get_rid(),p_local_xform,p_local_motion,p_shape->get_rid(),p_shape_xform,p_shape_motion,NULL,0,r); +} + +bool Shape2D::collide(const Matrix32& p_local_xform, const Ref& p_shape, const Matrix32& p_shape_xform){ + ERR_FAIL_COND_V(p_shape.is_null(),false); + int r; + return Physics2DServer::get_singleton()->shape_collide(get_rid(),p_local_xform,Vector2(),p_shape->get_rid(),p_shape_xform,Vector2(),NULL,0,r); + + +} + +Variant Shape2D::collide_with_motion_and_get_contacts(const Matrix32& p_local_xform, const Vector2& p_local_motion, const Ref& p_shape, const Matrix32& p_shape_xform, const Vector2 &p_shape_motion){ + + ERR_FAIL_COND_V(p_shape.is_null(),Variant()); + const int max_contacts = 16; + Vector2 result[max_contacts*2]; + int contacts=0; + + if (!Physics2DServer::get_singleton()->shape_collide(get_rid(),p_local_xform,p_local_motion,p_shape->get_rid(),p_shape_xform,p_shape_motion,result,max_contacts,contacts)) + return Variant(); + + Array results; + results.resize(contacts*2); + for(int i=0;i& p_shape, const Matrix32& p_shape_xform){ + + ERR_FAIL_COND_V(p_shape.is_null(),Variant()); + const int max_contacts = 16; + Vector2 result[max_contacts*2]; + int contacts=0; + + if (!Physics2DServer::get_singleton()->shape_collide(get_rid(),p_local_xform,Vector2(),p_shape->get_rid(),p_shape_xform,Vector2(),result,max_contacts,contacts)) + return Variant(); + + Array results; + results.resize(contacts*2); + for(int i=0;ifree(shape); -- cgit v1.2.3-70-g09d2