{"action":"created","issue":{"url":"https://api.github.com/repos/MovingBlocks/Terasology/issues/3199","repository_url":"https://api.github.com/repos/MovingBlocks/Terasology","labels_url":"https://api.github.com/repos/MovingBlocks/Terasology/issues/3199/labels{/name}","comments_url":"https://api.github.com/repos/MovingBlocks/Terasology/issues/3199/comments","events_url":"https://api.github.com/repos/MovingBlocks/Terasology/issues/3199/events","html_url":"https://github.com/MovingBlocks/Terasology/pull/3199","id":284542991,"number":3199,"title":"Physics refactor","user":{"login":"eviltak","id":8018181,"avatar_url":"https://avatars1.githubusercontent.com/u/8018181?v=4","gravatar_id":"","url":"https://api.github.com/users/eviltak","html_url":"https://github.com/eviltak","followers_url":"https://api.github.com/users/eviltak/followers","following_url":"https://api.github.com/users/eviltak/following{/other_user}","gists_url":"https://api.github.com/users/eviltak/gists{/gist_id}","starred_url":"https://api.github.com/users/eviltak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eviltak/subscriptions","organizations_url":"https://api.github.com/users/eviltak/orgs","repos_url":"https://api.github.com/users/eviltak/repos","events_url":"https://api.github.com/users/eviltak/events{/privacy}","received_events_url":"https://api.github.com/users/eviltak/received_events","type":"User","site_admin":false},"labels":[{"id":788671472,"url":"https://api.github.com/repos/MovingBlocks/Terasology/labels/Physics","name":"Physics","color":"bafca4","default":false}],"state":"open","locked":false,"assignee":{"login":"Cervator","id":1063833,"avatar_url":"https://avatars3.githubusercontent.com/u/1063833?v=4","gravatar_id":"","url":"https://api.github.com/users/Cervator","html_url":"https://github.com/Cervator","followers_url":"https://api.github.com/users/Cervator/followers","following_url":"https://api.github.com/users/Cervator/following{/other_user}","gists_url":"https://api.github.com/users/Cervator/gists{/gist_id}","starred_url":"https://api.github.com/users/Cervator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cervator/subscriptions","organizations_url":"https://api.github.com/users/Cervator/orgs","repos_url":"https://api.github.com/users/Cervator/repos","events_url":"https://api.github.com/users/Cervator/events{/privacy}","received_events_url":"https://api.github.com/users/Cervator/received_events","type":"User","site_admin":false},"assignees":[{"login":"Cervator","id":1063833,"avatar_url":"https://avatars3.githubusercontent.com/u/1063833?v=4","gravatar_id":"","url":"https://api.github.com/users/Cervator","html_url":"https://github.com/Cervator","followers_url":"https://api.github.com/users/Cervator/followers","following_url":"https://api.github.com/users/Cervator/following{/other_user}","gists_url":"https://api.github.com/users/Cervator/gists{/gist_id}","starred_url":"https://api.github.com/users/Cervator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Cervator/subscriptions","organizations_url":"https://api.github.com/users/Cervator/orgs","repos_url":"https://api.github.com/users/Cervator/repos","events_url":"https://api.github.com/users/Cervator/events{/privacy}","received_events_url":"https://api.github.com/users/Cervator/received_events","type":"User","site_admin":false}],"milestone":null,"comments":27,"created_at":"2017-12-26T11:42:07Z","updated_at":"2018-02-01T06:07:22Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/MovingBlocks/Terasology/pulls/3199","html_url":"https://github.com/MovingBlocks/Terasology/pull/3199","diff_url":"https://github.com/MovingBlocks/Terasology/pull/3199.diff","patch_url":"https://github.com/MovingBlocks/Terasology/pull/3199.patch"},"body":"## Goal\r\nThis refactor aims to reduce the dependency of engine code on the physics engine library used. Engine items currently use items in the `com.bulletphysics` ([MovingBlocks/TeraBullet](https://github.com/MovingBlocks/TeraBullet)) package, which can cause problems while refactoring (moving to a different engine) and necessitates adding an otherwise unrelated package to the module whitelist. The main cuplrits were references to `com.bulletphysics.collision.shapes.CollisionShape` and its subclasses, and `com.bulletphysics.linearmath.Transform`. All these classes have been wrapped around engine classes and interfaces, which can be easily used in both engine as well as module code.\r\n\r\nThese changes also allow for easily changing the underlying physics engine used without having to change _any_ engine or module code (except the contents of the `PhysicsEngineManager` class). All physics engine integration code will reside in a subpackage of the `physics` subpackage, and will only be interacted with via the relevant interfaces. Theoretically, this also allows multiple physics engine integrations to coexist, with the ability to change the physics engine used at _runtime_ (or in the worst case, a couple of lines of code).\r\n\r\n## Contents\r\n### Introduces\r\n- Wrapper around TeraBullet's `CollisionShape` (and derivatives) by way of interfaces of the same name under the `physics.shapes` subpackage\r\n- `CollisionShapeFactory` interface for creating `CollisionShape`s for entities and blocks, primarily used in the prefab and block loading system\r\n- Functional equivalent of TeraBullet's `Transform` in the `math` subpackage\r\n- A static helper class `PhysicsEngineManager` containing a helper method which creates a new `PhysicsEngine` instance and a constant reference to a `CollisionShapeFactory` instance\r\n\r\n### Changes\r\n- Removes reliance on `com.bulletphysics.linearmath.AabbUtil2` by inlining functionally equivalent implementations of the methods used.\r\n- Moves the collision shape component classes from `physics.shapes` to the more suited `physics.components.shapes` package\r\n- Adds a custom `EPSILON` value to `Vector3fUtil` instead of referring to `BulletGlobals.SIMD_EPSILON`\r\n\r\n## Considerations\r\n\r\n1. ~Introduce a `CompoundShapeFactory` that helps create  a `CompoundShape` and add child shapes to it in order to restrict the `CollisionShape` interface API to read-only methods, further increasing API security~ Not required, as discussed below.\r\n\r\n## Future Work\r\n\r\n1. Introduce more methods to the `CollisionShape` interface family that may be required in the future\r\n2. Improve upon and widely adopt or fully remove the `Transform` class \r\n3. Add an `EPSILON` constant to the `PhysicsEngineManager` class, thereby making `PhysicsEngine.getEpsilon` redundant, or find a way to make available the value returned by `getEpsilon` everywhere without needing a `PhysicsEngine` instance (using a static method or a constant). This makes it easier to refer to the epsilon value used by the physics engine without needing to refer to the `PhysicsEngine` instance (like in the case of `Vector3fUtil.safeNormalize`).  \r\nRelated: #3204\r\n\r\n## TODO\r\n- Document \r\n  - [x] `CollisionShape` interface family\r\n  - [x] `CollisionShapeFactory`\r\n  - [x] `Transform`\r\n\r\nComments on the future considerations, general suggestions and improvements are welcome."},"comment":{"url":"https://api.github.com/repos/MovingBlocks/Terasology/issues/comments/362168281","html_url":"https://github.com/MovingBlocks/Terasology/pull/3199#issuecomment-362168281","issue_url":"https://api.github.com/repos/MovingBlocks/Terasology/issues/3199","id":362168281,"user":{"login":"GooeyHub","id":4524000,"avatar_url":"https://avatars1.githubusercontent.com/u/4524000?v=4","gravatar_id":"","url":"https://api.github.com/users/GooeyHub","html_url":"https://github.com/GooeyHub","followers_url":"https://api.github.com/users/GooeyHub/followers","following_url":"https://api.github.com/users/GooeyHub/following{/other_user}","gists_url":"https://api.github.com/users/GooeyHub/gists{/gist_id}","starred_url":"https://api.github.com/users/GooeyHub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GooeyHub/subscriptions","organizations_url":"https://api.github.com/users/GooeyHub/orgs","repos_url":"https://api.github.com/users/GooeyHub/repos","events_url":"https://api.github.com/users/GooeyHub/events{/privacy}","received_events_url":"https://api.github.com/users/GooeyHub/received_events","type":"User","site_admin":false},"created_at":"2018-02-01T06:07:22Z","updated_at":"2018-02-01T06:07:22Z","author_association":"OWNER","body":"Hooray Jenkins reported success with all tests good!\n"}}
{"actor":{"display_login":"GooeyHub"}}