{"action":"created","issue":{"url":"https://api.github.com/repos/craftworkgames/MonoGame.Extended/issues/132","repository_url":"https://api.github.com/repos/craftworkgames/MonoGame.Extended","labels_url":"https://api.github.com/repos/craftworkgames/MonoGame.Extended/issues/132/labels{/name}","comments_url":"https://api.github.com/repos/craftworkgames/MonoGame.Extended/issues/132/comments","events_url":"https://api.github.com/repos/craftworkgames/MonoGame.Extended/issues/132/events","html_url":"https://github.com/craftworkgames/MonoGame.Extended/issues/132","id":138133311,"number":132,"title":"Swtich TiledTile from class to struct to raise performance","user":{"login":"kreynes","id":439632,"avatar_url":"https://avatars.githubusercontent.com/u/439632?v=3","gravatar_id":"","url":"https://api.github.com/users/kreynes","html_url":"https://github.com/kreynes","followers_url":"https://api.github.com/users/kreynes/followers","following_url":"https://api.github.com/users/kreynes/following{/other_user}","gists_url":"https://api.github.com/users/kreynes/gists{/gist_id}","starred_url":"https://api.github.com/users/kreynes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kreynes/subscriptions","organizations_url":"https://api.github.com/users/kreynes/orgs","repos_url":"https://api.github.com/users/kreynes/repos","events_url":"https://api.github.com/users/kreynes/events{/privacy}","received_events_url":"https://api.github.com/users/kreynes/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/craftworkgames/MonoGame.Extended/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/craftworkgames/MonoGame.Extended/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/craftworkgames/MonoGame.Extended/milestones/5","html_url":"https://github.com/craftworkgames/MonoGame.Extended/milestones/Version%200.5","labels_url":"https://api.github.com/repos/craftworkgames/MonoGame.Extended/milestones/5/labels","id":1491350,"number":5,"title":"Version 0.5","description":"By the end of this version I want to have completed small game demo to show off the library and make improvements discovered by using it in a real game.","creator":{"login":"craftworkgames","id":3201643,"avatar_url":"https://avatars.githubusercontent.com/u/3201643?v=3","gravatar_id":"","url":"https://api.github.com/users/craftworkgames","html_url":"https://github.com/craftworkgames","followers_url":"https://api.github.com/users/craftworkgames/followers","following_url":"https://api.github.com/users/craftworkgames/following{/other_user}","gists_url":"https://api.github.com/users/craftworkgames/gists{/gist_id}","starred_url":"https://api.github.com/users/craftworkgames/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/craftworkgames/subscriptions","organizations_url":"https://api.github.com/users/craftworkgames/orgs","repos_url":"https://api.github.com/users/craftworkgames/repos","events_url":"https://api.github.com/users/craftworkgames/events{/privacy}","received_events_url":"https://api.github.com/users/craftworkgames/received_events","type":"User","site_admin":false},"open_issues":14,"closed_issues":12,"state":"open","created_at":"2016-01-08T12:26:34Z","updated_at":"2016-03-06T23:47:25Z","due_on":null,"closed_at":null},"comments":13,"created_at":"2016-03-03T10:00:27Z","updated_at":"2016-03-07T12:02:43Z","closed_at":null,"body":"There was a discussion held in the MonoGame.Extended gitter regarding the topic of switching TiledTile from a class to a struct as it may, or may not increase the performance, as, generally, it fits the criteria of a struct. I've attached a 500x500 tiles map, each tile is 16x16 pixels. Without any culling, this map has brought my CPU usage up to 96%, and it could be a good subject to testing whether it'll actually be efficient enough to be noticeable, and worth the effort of converting to a struct.\r\n\r\n[MSDN / Choosing between a class and a struct](https://msdn.microsoft.com/en-us/library/ms229017) if anyone is interested on the subject.\r\n\r\n[test_map.zip](https://github.com/craftworkgames/MonoGame.Extended/files/158512/test_map.zip)\r\n\r\nThe map is pretty plain and only contains 2 layers with some terrain and a small area of trees. If there would be a need to compile the same sized map, but with more layers and objects (closer to a real-deal map that would be used in a game) I'd gladly do so.\r\n"},"comment":{"url":"https://api.github.com/repos/craftworkgames/MonoGame.Extended/issues/comments/193221280","html_url":"https://github.com/craftworkgames/MonoGame.Extended/issues/132#issuecomment-193221280","issue_url":"https://api.github.com/repos/craftworkgames/MonoGame.Extended/issues/132","id":193221280,"user":{"login":"craftworkgames","id":3201643,"avatar_url":"https://avatars.githubusercontent.com/u/3201643?v=3","gravatar_id":"","url":"https://api.github.com/users/craftworkgames","html_url":"https://github.com/craftworkgames","followers_url":"https://api.github.com/users/craftworkgames/followers","following_url":"https://api.github.com/users/craftworkgames/following{/other_user}","gists_url":"https://api.github.com/users/craftworkgames/gists{/gist_id}","starred_url":"https://api.github.com/users/craftworkgames/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/craftworkgames/subscriptions","organizations_url":"https://api.github.com/users/craftworkgames/orgs","repos_url":"https://api.github.com/users/craftworkgames/repos","events_url":"https://api.github.com/users/craftworkgames/events{/privacy}","received_events_url":"https://api.github.com/users/craftworkgames/received_events","type":"User","site_admin":false},"created_at":"2016-03-07T12:02:43Z","updated_at":"2016-03-07T12:02:43Z","body":"> I wonder if the render target technique can be avoided by locking the tile positions to the nearest integer when zooming in and out with the camera.\r\n\r\nI tried this before implementing the render target approach. It's not as easy as it sounds. I don't remember the exact details but I spent a good few nights on it. I really do feel that render targets are the right approach here. Have a read of [this](https://msdn.microsoft.com/en-us/library/bb976073(v=xnagamestudio.31).aspx).\r\n\r\nThat said, there may be other strategies we can use. Perhaps the `PrimitiveBatch` will help. We could render the tiles in a single polygon mesh to make sure the triangles are properly stitched together. The same way a 3D game renders a terrain.\r\n\r\nI didn't get a lot of time to work on this tonight but I'm confident I can get the render target approach really fast. I'll implement a very basic draw strategy and then we can talk about implementing more sophisticated ones.\r\n"}}