{"action":"created","comment":{"url":"https://api.github.com/repos/rwengine/openrw/pulls/comments/207617806","pull_request_review_id":143272855,"id":207617806,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNzYxNzgwNg==","diff_hunk":"@@ -307,11 +323,78 @@ void VehicleObject::tickPhysics(float dt) {\n     if (physVehicle) {\n         // todo: a real engine function\n         float velFac = info->handling.maxVelocity;\n-        float engineForce = info->handling.acceleration * throttle * velFac;\n+        float velocity = collision->getBulletBody()->getLinearVelocity().length();\n+        float velocityForward = physVehicle->getCurrentSpeedKmHour() / 3.6f;\n+        float velocityMax = velFac / 9.f;\n+        float steerValue = 0.f;\n+        float steerLimit = glm::radians(info->handling.steeringLock);\n+        // The engine force is calculated from the acceleration and max velocity\n+        // of the vehicle, with a specific coefficient to make it adapted to\n+        // Bullet physics and avoid reaching top speed too fast.\n+        float engineForce = info->handling.acceleration * throttle * velFac / 1.2f;\n         float brakeF = getBraking();\n+        // Mass coefficient, that quantifies how heavy a vehicle is and excludes\n+        // light vehicles.\n+        float kM = (std::max(1500.f, info->handling.mass) - 1500.f) / 1500.f;\n+        unsigned int count = 0;\n+\n+        // Get the global vehicle steering value (for front wheels only).\n+        for (int w = 0; w < physVehicle->getNumWheels(); ++w) {\n+            btWheelInfo& wi = physVehicle->getWheelInfo(w);\n+\n+            if (wi.m_bIsFrontWheel) {\n+                steerValue += physVehicle->getSteeringValue(w);\n+                count++;\n+            }\n+        }\n+\n+        steerValue /= count;\n+\n+        // Increase the engine force based on the mass by up to 4 times.\n+        // Heavy vehicles need extra engine force to be reactive enough.\n+        engineForce *= std::min(1.f + kM, 4.f);\n+\n+        // Give vehicles a boost when starting (forward or backward) to reduce\n+        // general sluggishness. The engine force is multiplied by 1.5 before\n+        // reaching velocityMax / 4 and then reduces down to nominal force as\n+        // velocity reaches velocityMax / 2.\n+        if (velocity < velocityMax / 4.f)\n+            engineForce *= 1.5f;\n+        else if (velocity < velocityMax / 2.f)\n+            engineForce *= 1.f + 0.5f * (2.f - velocity / (velocityMax / 4.f));\n+\n+        // Reduce the engine force when steering, by a factor of up to 1.25 for\n+        // the maximum steering angle, linearly back to nominal value when no\n+        // steering is applied.\n+        if (std::abs(steerValue) > steerLimit / 8.f && velocity > velocityMax / 3.f)\n+            engineForce /= 1.f + std::abs(steerValue) / (4.f * steerLimit);\n+\n+        if (velocity > velocityMax) {\n+            btVector3 v = collision->getBulletBody()->getLinearVelocity().normalized();\n+\n+            velocity = velocityMax;\n+            v *= velocity;\n+\n+            collision->getBulletBody()->setLinearVelocity(v);\n+        }\n \n         if (handbrake) {\n             brakeF = 5.f;\n+        } else if (throttle < 0.f && velocityForward > velocityMax / 8.f) {\n+            engineForce = 0.f;\n+            brakeF = 2.f * std::min(1.f + kM, 4.f);\n+        }\n+\n+        if (isStopped() && throttle == 0.f) {","path":"rwengine/src/objects/VehicleObject.cpp","position":101,"original_position":101,"commit_id":"2286201c5b3a0274a26991aef8160734e2a27b0b","original_commit_id":"2286201c5b3a0274a26991aef8160734e2a27b0b","user":{"login":"paulkocialkowski","id":8561322,"node_id":"MDQ6VXNlcjg1NjEzMjI=","avatar_url":"https://avatars0.githubusercontent.com/u/8561322?v=4","gravatar_id":"","url":"https://api.github.com/users/paulkocialkowski","html_url":"https://github.com/paulkocialkowski","followers_url":"https://api.github.com/users/paulkocialkowski/followers","following_url":"https://api.github.com/users/paulkocialkowski/following{/other_user}","gists_url":"https://api.github.com/users/paulkocialkowski/gists{/gist_id}","starred_url":"https://api.github.com/users/paulkocialkowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulkocialkowski/subscriptions","organizations_url":"https://api.github.com/users/paulkocialkowski/orgs","repos_url":"https://api.github.com/users/paulkocialkowski/repos","events_url":"https://api.github.com/users/paulkocialkowski/events{/privacy}","received_events_url":"https://api.github.com/users/paulkocialkowski/received_events","type":"User","site_admin":false},"body":"I don't think that would be right. Throttle is set to an integer value (either -1.f, 0.f or 1.f) so there is about no need for setting a threshold. In addition, what we're really interested in here is the velocity, which is checked by isStopped. The throttle condition is really just a way to allow the car to start again (it can hardly happen if the x coordinate of the velocity vector remains 0, since it makes it hard for the two other coordinate to compensate until reaching the point where isStopped() == false). When there is no driver interaction with the vehicle, throttle is effectively equal to zero.","created_at":"2018-08-03T17:42:08Z","updated_at":"2018-08-03T17:42:09Z","html_url":"https://github.com/rwengine/openrw/pull/566#discussion_r207617806","pull_request_url":"https://api.github.com/repos/rwengine/openrw/pulls/566","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/rwengine/openrw/pulls/comments/207617806"},"html":{"href":"https://github.com/rwengine/openrw/pull/566#discussion_r207617806"},"pull_request":{"href":"https://api.github.com/repos/rwengine/openrw/pulls/566"}},"in_reply_to_id":207609402},"pull_request":{"url":"https://api.github.com/repos/rwengine/openrw/pulls/566","id":205876457,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA1ODc2NDU3","html_url":"https://github.com/rwengine/openrw/pull/566","diff_url":"https://github.com/rwengine/openrw/pull/566.diff","patch_url":"https://github.com/rwengine/openrw/pull/566.patch","issue_url":"https://api.github.com/repos/rwengine/openrw/issues/566","number":566,"state":"open","locked":false,"title":"Various vehicle improvements","user":{"login":"paulkocialkowski","id":8561322,"node_id":"MDQ6VXNlcjg1NjEzMjI=","avatar_url":"https://avatars0.githubusercontent.com/u/8561322?v=4","gravatar_id":"","url":"https://api.github.com/users/paulkocialkowski","html_url":"https://github.com/paulkocialkowski","followers_url":"https://api.github.com/users/paulkocialkowski/followers","following_url":"https://api.github.com/users/paulkocialkowski/following{/other_user}","gists_url":"https://api.github.com/users/paulkocialkowski/gists{/gist_id}","starred_url":"https://api.github.com/users/paulkocialkowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulkocialkowski/subscriptions","organizations_url":"https://api.github.com/users/paulkocialkowski/orgs","repos_url":"https://api.github.com/users/paulkocialkowski/repos","events_url":"https://api.github.com/users/paulkocialkowski/events{/privacy}","received_events_url":"https://api.github.com/users/paulkocialkowski/received_events","type":"User","site_admin":false},"body":"This is an attempt at making vehicles more usable in the game, with improvements to various aspects of driving.","created_at":"2018-08-02T22:15:42Z","updated_at":"2018-08-03T17:42:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"eebc0d8f47d8ad69666448f61f1370522d264ba6","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/rwengine/openrw/pulls/566/commits","review_comments_url":"https://api.github.com/repos/rwengine/openrw/pulls/566/comments","review_comment_url":"https://api.github.com/repos/rwengine/openrw/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rwengine/openrw/issues/566/comments","statuses_url":"https://api.github.com/repos/rwengine/openrw/statuses/2286201c5b3a0274a26991aef8160734e2a27b0b","head":{"label":"paulkocialkowski:vehicles","ref":"vehicles","sha":"2286201c5b3a0274a26991aef8160734e2a27b0b","user":{"login":"paulkocialkowski","id":8561322,"node_id":"MDQ6VXNlcjg1NjEzMjI=","avatar_url":"https://avatars0.githubusercontent.com/u/8561322?v=4","gravatar_id":"","url":"https://api.github.com/users/paulkocialkowski","html_url":"https://github.com/paulkocialkowski","followers_url":"https://api.github.com/users/paulkocialkowski/followers","following_url":"https://api.github.com/users/paulkocialkowski/following{/other_user}","gists_url":"https://api.github.com/users/paulkocialkowski/gists{/gist_id}","starred_url":"https://api.github.com/users/paulkocialkowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulkocialkowski/subscriptions","organizations_url":"https://api.github.com/users/paulkocialkowski/orgs","repos_url":"https://api.github.com/users/paulkocialkowski/repos","events_url":"https://api.github.com/users/paulkocialkowski/events{/privacy}","received_events_url":"https://api.github.com/users/paulkocialkowski/received_events","type":"User","site_admin":false},"repo":{"id":124765742,"node_id":"MDEwOlJlcG9zaXRvcnkxMjQ3NjU3NDI=","name":"openrw","full_name":"paulkocialkowski/openrw","owner":{"login":"paulkocialkowski","id":8561322,"node_id":"MDQ6VXNlcjg1NjEzMjI=","avatar_url":"https://avatars0.githubusercontent.com/u/8561322?v=4","gravatar_id":"","url":"https://api.github.com/users/paulkocialkowski","html_url":"https://github.com/paulkocialkowski","followers_url":"https://api.github.com/users/paulkocialkowski/followers","following_url":"https://api.github.com/users/paulkocialkowski/following{/other_user}","gists_url":"https://api.github.com/users/paulkocialkowski/gists{/gist_id}","starred_url":"https://api.github.com/users/paulkocialkowski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulkocialkowski/subscriptions","organizations_url":"https://api.github.com/users/paulkocialkowski/orgs","repos_url":"https://api.github.com/users/paulkocialkowski/repos","events_url":"https://api.github.com/users/paulkocialkowski/events{/privacy}","received_events_url":"https://api.github.com/users/paulkocialkowski/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/paulkocialkowski/openrw","description":"OpenRW \"Open ReWrite\" is an un-official open source recreation of the classic Grand Theft Auto III game executable","fork":true,"url":"https://api.github.com/repos/paulkocialkowski/openrw","forks_url":"https://api.github.com/repos/paulkocialkowski/openrw/forks","keys_url":"https://api.github.com/repos/paulkocialkowski/openrw/keys{/key_id}","collaborators_url":"https://api.github.com/repos/paulkocialkowski/openrw/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/paulkocialkowski/openrw/teams","hooks_url":"https://api.github.com/repos/paulkocialkowski/openrw/hooks","issue_events_url":"https://api.github.com/repos/paulkocialkowski/openrw/issues/events{/number}","events_url":"https://api.github.com/repos/paulkocialkowski/openrw/events","assignees_url":"https://api.github.com/repos/paulkocialkowski/openrw/assignees{/user}","branches_url":"https://api.github.com/repos/paulkocialkowski/openrw/branches{/branch}","tags_url":"https://api.github.com/repos/paulkocialkowski/openrw/tags","blobs_url":"https://api.github.com/repos/paulkocialkowski/openrw/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/paulkocialkowski/openrw/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/paulkocialkowski/openrw/git/refs{/sha}","trees_url":"https://api.github.com/repos/paulkocialkowski/openrw/git/trees{/sha}","statuses_url":"https://api.github.com/repos/paulkocialkowski/openrw/statuses/{sha}","languages_url":"https://api.github.com/repos/paulkocialkowski/openrw/languages","stargazers_url":"https://api.github.com/repos/paulkocialkowski/openrw/stargazers","contributors_url":"https://api.github.com/repos/paulkocialkowski/openrw/contributors","subscribers_url":"https://api.github.com/repos/paulkocialkowski/openrw/subscribers","subscription_url":"https://api.github.com/repos/paulkocialkowski/openrw/subscription","commits_url":"https://api.github.com/repos/paulkocialkowski/openrw/commits{/sha}","git_commits_url":"https://api.github.com/repos/paulkocialkowski/openrw/git/commits{/sha}","comments_url":"https://api.github.com/repos/paulkocialkowski/openrw/comments{/number}","issue_comment_url":"https://api.github.com/repos/paulkocialkowski/openrw/issues/comments{/number}","contents_url":"https://api.github.com/repos/paulkocialkowski/openrw/contents/{+path}","compare_url":"https://api.github.com/repos/paulkocialkowski/openrw/compare/{base}...{head}","merges_url":"https://api.github.com/repos/paulkocialkowski/openrw/merges","archive_url":"https://api.github.com/repos/paulkocialkowski/openrw/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/paulkocialkowski/openrw/downloads","issues_url":"https://api.github.com/repos/paulkocialkowski/openrw/issues{/number}","pulls_url":"https://api.github.com/repos/paulkocialkowski/openrw/pulls{/number}","milestones_url":"https://api.github.com/repos/paulkocialkowski/openrw/milestones{/number}","notifications_url":"https://api.github.com/repos/paulkocialkowski/openrw/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/paulkocialkowski/openrw/labels{/name}","releases_url":"https://api.github.com/repos/paulkocialkowski/openrw/releases{/id}","deployments_url":"https://api.github.com/repos/paulkocialkowski/openrw/deployments","created_at":"2018-03-11T14:38:51Z","updated_at":"2018-08-02T22:11:16Z","pushed_at":"2018-08-03T06:17:57Z","git_url":"git://github.com/paulkocialkowski/openrw.git","ssh_url":"git@github.com:paulkocialkowski/openrw.git","clone_url":"https://github.com/paulkocialkowski/openrw.git","svn_url":"https://github.com/paulkocialkowski/openrw","homepage":"http://openrw.org","size":3829,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rwengine:master","ref":"master","sha":"24b47a53f397132117343925b252d62c7bf20cb4","user":{"login":"rwengine","id":19520421,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5NTIwNDIx","avatar_url":"https://avatars0.githubusercontent.com/u/19520421?v=4","gravatar_id":"","url":"https://api.github.com/users/rwengine","html_url":"https://github.com/rwengine","followers_url":"https://api.github.com/users/rwengine/followers","following_url":"https://api.github.com/users/rwengine/following{/other_user}","gists_url":"https://api.github.com/users/rwengine/gists{/gist_id}","starred_url":"https://api.github.com/users/rwengine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rwengine/subscriptions","organizations_url":"https://api.github.com/users/rwengine/orgs","repos_url":"https://api.github.com/users/rwengine/repos","events_url":"https://api.github.com/users/rwengine/events{/privacy}","received_events_url":"https://api.github.com/users/rwengine/received_events","type":"Organization","site_admin":false},"repo":{"id":34529275,"node_id":"MDEwOlJlcG9zaXRvcnkzNDUyOTI3NQ==","name":"openrw","full_name":"rwengine/openrw","owner":{"login":"rwengine","id":19520421,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5NTIwNDIx","avatar_url":"https://avatars0.githubusercontent.com/u/19520421?v=4","gravatar_id":"","url":"https://api.github.com/users/rwengine","html_url":"https://github.com/rwengine","followers_url":"https://api.github.com/users/rwengine/followers","following_url":"https://api.github.com/users/rwengine/following{/other_user}","gists_url":"https://api.github.com/users/rwengine/gists{/gist_id}","starred_url":"https://api.github.com/users/rwengine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rwengine/subscriptions","organizations_url":"https://api.github.com/users/rwengine/orgs","repos_url":"https://api.github.com/users/rwengine/repos","events_url":"https://api.github.com/users/rwengine/events{/privacy}","received_events_url":"https://api.github.com/users/rwengine/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rwengine/openrw","description":"OpenRW \"Open ReWrite\" is an un-official open source recreation of the classic Grand Theft Auto III game executable","fork":false,"url":"https://api.github.com/repos/rwengine/openrw","forks_url":"https://api.github.com/repos/rwengine/openrw/forks","keys_url":"https://api.github.com/repos/rwengine/openrw/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rwengine/openrw/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rwengine/openrw/teams","hooks_url":"https://api.github.com/repos/rwengine/openrw/hooks","issue_events_url":"https://api.github.com/repos/rwengine/openrw/issues/events{/number}","events_url":"https://api.github.com/repos/rwengine/openrw/events","assignees_url":"https://api.github.com/repos/rwengine/openrw/assignees{/user}","branches_url":"https://api.github.com/repos/rwengine/openrw/branches{/branch}","tags_url":"https://api.github.com/repos/rwengine/openrw/tags","blobs_url":"https://api.github.com/repos/rwengine/openrw/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rwengine/openrw/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rwengine/openrw/git/refs{/sha}","trees_url":"https://api.github.com/repos/rwengine/openrw/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rwengine/openrw/statuses/{sha}","languages_url":"https://api.github.com/repos/rwengine/openrw/languages","stargazers_url":"https://api.github.com/repos/rwengine/openrw/stargazers","contributors_url":"https://api.github.com/repos/rwengine/openrw/contributors","subscribers_url":"https://api.github.com/repos/rwengine/openrw/subscribers","subscription_url":"https://api.github.com/repos/rwengine/openrw/subscription","commits_url":"https://api.github.com/repos/rwengine/openrw/commits{/sha}","git_commits_url":"https://api.github.com/repos/rwengine/openrw/git/commits{/sha}","comments_url":"https://api.github.com/repos/rwengine/openrw/comments{/number}","issue_comment_url":"https://api.github.com/repos/rwengine/openrw/issues/comments{/number}","contents_url":"https://api.github.com/repos/rwengine/openrw/contents/{+path}","compare_url":"https://api.github.com/repos/rwengine/openrw/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rwengine/openrw/merges","archive_url":"https://api.github.com/repos/rwengine/openrw/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rwengine/openrw/downloads","issues_url":"https://api.github.com/repos/rwengine/openrw/issues{/number}","pulls_url":"https://api.github.com/repos/rwengine/openrw/pulls{/number}","milestones_url":"https://api.github.com/repos/rwengine/openrw/milestones{/number}","notifications_url":"https://api.github.com/repos/rwengine/openrw/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rwengine/openrw/labels{/name}","releases_url":"https://api.github.com/repos/rwengine/openrw/releases{/id}","deployments_url":"https://api.github.com/repos/rwengine/openrw/deployments","created_at":"2015-04-24T16:26:12Z","updated_at":"2018-08-02T20:39:40Z","pushed_at":"2018-08-03T15:44:31Z","git_url":"git://github.com/rwengine/openrw.git","ssh_url":"git@github.com:rwengine/openrw.git","clone_url":"https://github.com/rwengine/openrw.git","svn_url":"https://github.com/rwengine/openrw","homepage":"http://openrw.org","size":3860,"stargazers_count":690,"watchers_count":690,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":85,"mirror_url":null,"archived":false,"open_issues_count":93,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":85,"open_issues":93,"watchers":690,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rwengine/openrw/pulls/566"},"html":{"href":"https://github.com/rwengine/openrw/pull/566"},"issue":{"href":"https://api.github.com/repos/rwengine/openrw/issues/566"},"comments":{"href":"https://api.github.com/repos/rwengine/openrw/issues/566/comments"},"review_comments":{"href":"https://api.github.com/repos/rwengine/openrw/pulls/566/comments"},"review_comment":{"href":"https://api.github.com/repos/rwengine/openrw/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rwengine/openrw/pulls/566/commits"},"statuses":{"href":"https://api.github.com/repos/rwengine/openrw/statuses/2286201c5b3a0274a26991aef8160734e2a27b0b"}},"author_association":"NONE"}}
{"actor":{"display_login":"paulkocialkowski"}}