{"action":"created","issue":{"url":"https://api.github.com/repos/los-cocos/cocos/issues/249","labels_url":"https://api.github.com/repos/los-cocos/cocos/issues/249/labels{/name}","comments_url":"https://api.github.com/repos/los-cocos/cocos/issues/249/comments","events_url":"https://api.github.com/repos/los-cocos/cocos/issues/249/events","html_url":"https://github.com/los-cocos/cocos/pull/249","id":107698678,"number":249,"title":"Issue #248 RectMapCollider, player sometimes stuck","user":{"login":"dangillet","id":992522,"avatar_url":"https://avatars.githubusercontent.com/u/992522?v=3","gravatar_id":"","url":"https://api.github.com/users/dangillet","html_url":"https://github.com/dangillet","followers_url":"https://api.github.com/users/dangillet/followers","following_url":"https://api.github.com/users/dangillet/following{/other_user}","gists_url":"https://api.github.com/users/dangillet/gists{/gist_id}","starred_url":"https://api.github.com/users/dangillet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dangillet/subscriptions","organizations_url":"https://api.github.com/users/dangillet/orgs","repos_url":"https://api.github.com/users/dangillet/repos","events_url":"https://api.github.com/users/dangillet/events{/privacy}","received_events_url":"https://api.github.com/users/dangillet/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":16,"created_at":"2015-09-22T11:50:42Z","updated_at":"2015-10-24T07:13:44Z","closed_at":"2015-10-24T07:13:44Z","pull_request":{"url":"https://api.github.com/repos/los-cocos/cocos/pulls/249","html_url":"https://github.com/los-cocos/cocos/pull/249","diff_url":"https://github.com/los-cocos/cocos/pull/249.diff","patch_url":"https://github.com/los-cocos/cocos/pull/249.patch"},"body":"Hello,\r\n\r\nI've been thinking a bit about this problem. I'm sure physic engines have excellent solutions. Here is what I came up with. The basic idea is to say that for each cell we collide with, we only want to correct the new rect by the shortest distance possible. So if we find that we need to move it by 4 px in the X and by 2 px in the Y, we only move it by 2 px in the Y.\r\nNow the only problem that is left is if we are positioned exactly on the diagonal and we find out that we should be moved by the same amount on the X and Y axis. In this case, we first don't correct anything with this cell, but we mark it with a special flag. We will come back to this cell after resolving all the other collisions. So we give the opportunity to the other cells which don't have this special positioning (being on the diagonal) to correct the new rect position correctly.\r\n\r\nOnce we're done with the collision resolutions, we take all the cells that were flagged, and we now see if we're still in the same situation. The situation might have changed if there were other cells which corrected the new rect position. \r\nBut if are are still in the same situation, we now choose to move the new rect on both X and Y axis. We could have chosen an arbitrary axis instead.\r\n\r\nHere is a proposition of this method.\r\n\r\nRegards,\r\nDaniel."},"comment":{"url":"https://api.github.com/repos/los-cocos/cocos/issues/comments/150772051","html_url":"https://github.com/los-cocos/cocos/pull/249#issuecomment-150772051","issue_url":"https://api.github.com/repos/los-cocos/cocos/issues/249","id":150772051,"user":{"login":"dangillet","id":992522,"avatar_url":"https://avatars.githubusercontent.com/u/992522?v=3","gravatar_id":"","url":"https://api.github.com/users/dangillet","html_url":"https://github.com/dangillet","followers_url":"https://api.github.com/users/dangillet/followers","following_url":"https://api.github.com/users/dangillet/following{/other_user}","gists_url":"https://api.github.com/users/dangillet/gists{/gist_id}","starred_url":"https://api.github.com/users/dangillet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dangillet/subscriptions","organizations_url":"https://api.github.com/users/dangillet/orgs","repos_url":"https://api.github.com/users/dangillet/repos","events_url":"https://api.github.com/users/dangillet/events{/privacy}","received_events_url":"https://api.github.com/users/dangillet/received_events","type":"User","site_admin":false},"created_at":"2015-10-24T07:13:44Z","updated_at":"2015-10-24T07:13:44Z","body":"Closing this pullrequest as the issue has been fixed."}}