{"action":"created","comment":{"url":"https://api.github.com/repos/OsnaCS/plantex/pulls/comments/71988916","id":71988916,"diff_hunk":"@@ -157,20 +167,33 @@ impl TreeGen {\n     /// direction to use for a new child branch.\n     fn gen_branch_direction<R: Rng>(&self, rng: &mut R, parent_dir: Vector3f) -> Vector3f {\n         // `branch_angle_deg` specifies the angle range in degrees\n-        let mut x_angle = range_sample(&self.preset.branch_angle_deg, rng);\n-        let mut y_angle = range_sample(&self.preset.branch_angle_deg, rng);\n-\n-        // Invert sign with 50%, to mirror the specified range to the other side\n-        x_angle = if rng.gen() { -x_angle } else { x_angle };\n-        y_angle = if rng.gen() { -y_angle } else { y_angle };\n-\n-        // Rotate the growing direction of the parent branch\n-        let rotation = Basis3::from(Euler {\n-            x: Deg::new(x_angle),\n-            y: Deg::new(y_angle),\n-            z: Deg::new(0.0),\n-        });\n-        rotation.rotate_vector(parent_dir)\n+        let angle = range_sample(&self.preset.branch_angle_deg, rng);\n+\n+        // AWESOME hack: Generate *any* vector that is not parallel to `parent_dir`,\n+        // calculate the cross product between it and `parent_dir`.\n+        // This gets us a vector perpendicular to `parent_dir`, which we can rotate\n+        // `parent_dir` around to tilt it by `angle` degrees.\n+        let mut rand_vec = Vector3f::rand(rng).normalize();\n+        while rand_vec.angle(parent_dir).approx_eq(&Rad::new(0.0)) {\n+            // They're parallel, so generate a new vector. This is probably unnecessary,\n+            // but someone\n+            // who *actually* knows their math instead of faking it should check.\n+            rand_vec = Vector3f::rand(rng);","path":"base/src/gen/plant/tree.rs","position":95,"original_position":91,"commit_id":"2601732b1c2644505e17eca46766778e72ab5d57","original_commit_id":"2dcb814243429673e0c25eb660db81fdcc6bb086","user":{"login":"jonas-schievink","id":1786438,"avatar_url":"https://avatars.githubusercontent.com/u/1786438?v=3","gravatar_id":"","url":"https://api.github.com/users/jonas-schievink","html_url":"https://github.com/jonas-schievink","followers_url":"https://api.github.com/users/jonas-schievink/followers","following_url":"https://api.github.com/users/jonas-schievink/following{/other_user}","gists_url":"https://api.github.com/users/jonas-schievink/gists{/gist_id}","starred_url":"https://api.github.com/users/jonas-schievink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonas-schievink/subscriptions","organizations_url":"https://api.github.com/users/jonas-schievink/orgs","repos_url":"https://api.github.com/users/jonas-schievink/repos","events_url":"https://api.github.com/users/jonas-schievink/events{/privacy}","received_events_url":"https://api.github.com/users/jonas-schievink/received_events","type":"User","site_admin":false},"body":"I only normalized it above because I wasn't sure what would happen if the random vector ends up extremely large.\r\n\r\nThe `approx_eq` should in theory already use such a threshold.","created_at":"2016-07-24T13:49:26Z","updated_at":"2016-07-24T13:49:26Z","html_url":"https://github.com/OsnaCS/plantex/pull/67#discussion_r71988916","pull_request_url":"https://api.github.com/repos/OsnaCS/plantex/pulls/67","_links":{"self":{"href":"https://api.github.com/repos/OsnaCS/plantex/pulls/comments/71988916"},"html":{"href":"https://github.com/OsnaCS/plantex/pull/67#discussion_r71988916"},"pull_request":{"href":"https://api.github.com/repos/OsnaCS/plantex/pulls/67"}}},"pull_request":{"url":"https://api.github.com/repos/OsnaCS/plantex/pulls/67","id":78582029,"html_url":"https://github.com/OsnaCS/plantex/pull/67","diff_url":"https://github.com/OsnaCS/plantex/pull/67.diff","patch_url":"https://github.com/OsnaCS/plantex/pull/67.patch","issue_url":"https://api.github.com/repos/OsnaCS/plantex/issues/67","number":67,"state":"open","locked":false,"title":"Treegen and rendering tweaks/fixes and cleanup","user":{"login":"jonas-schievink","id":1786438,"avatar_url":"https://avatars.githubusercontent.com/u/1786438?v=3","gravatar_id":"","url":"https://api.github.com/users/jonas-schievink","html_url":"https://github.com/jonas-schievink","followers_url":"https://api.github.com/users/jonas-schievink/followers","following_url":"https://api.github.com/users/jonas-schievink/following{/other_user}","gists_url":"https://api.github.com/users/jonas-schievink/gists{/gist_id}","starred_url":"https://api.github.com/users/jonas-schievink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonas-schievink/subscriptions","organizations_url":"https://api.github.com/users/jonas-schievink/orgs","repos_url":"https://api.github.com/users/jonas-schievink/repos","events_url":"https://api.github.com/users/jonas-schievink/events{/privacy}","received_events_url":"https://api.github.com/users/jonas-schievink/received_events","type":"User","site_admin":false},"body":"* `debug!` the config we use\r\n* Fix growing of new tree branches\r\n * Their growing direction wasn't randomized properly\r\n* Higher chance of growing branches out of the trunk\r\n* Stop extending branches when they have a diameter of <1mm\r\n* Add an FPS counter which prints the FPS to the console every second\r\n* Make `HeightType` a tiny bit less confusing\r\n* Chunk rendering: Drop the `scale_matrix` and pass a `height` instead\r\n* Make material colors RGB instead of RGBA\r\n * The shader ignored the Alpha channel anyways\r\n * I'm not convinced that we need or want transparent ground","created_at":"2016-07-23T20:39:24Z","updated_at":"2016-07-24T13:49:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b46b24cbd543caf59ae8b7710fbfb077be359857","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/OsnaCS/plantex/pulls/67/commits","review_comments_url":"https://api.github.com/repos/OsnaCS/plantex/pulls/67/comments","review_comment_url":"https://api.github.com/repos/OsnaCS/plantex/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OsnaCS/plantex/issues/67/comments","statuses_url":"https://api.github.com/repos/OsnaCS/plantex/statuses/2601732b1c2644505e17eca46766778e72ab5d57","head":{"label":"jonas-schievink:master","ref":"master","sha":"2601732b1c2644505e17eca46766778e72ab5d57","user":{"login":"jonas-schievink","id":1786438,"avatar_url":"https://avatars.githubusercontent.com/u/1786438?v=3","gravatar_id":"","url":"https://api.github.com/users/jonas-schievink","html_url":"https://github.com/jonas-schievink","followers_url":"https://api.github.com/users/jonas-schievink/followers","following_url":"https://api.github.com/users/jonas-schievink/following{/other_user}","gists_url":"https://api.github.com/users/jonas-schievink/gists{/gist_id}","starred_url":"https://api.github.com/users/jonas-schievink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonas-schievink/subscriptions","organizations_url":"https://api.github.com/users/jonas-schievink/orgs","repos_url":"https://api.github.com/users/jonas-schievink/repos","events_url":"https://api.github.com/users/jonas-schievink/events{/privacy}","received_events_url":"https://api.github.com/users/jonas-schievink/received_events","type":"User","site_admin":false},"repo":{"id":63777373,"name":"plantex","full_name":"jonas-schievink/plantex","owner":{"login":"jonas-schievink","id":1786438,"avatar_url":"https://avatars.githubusercontent.com/u/1786438?v=3","gravatar_id":"","url":"https://api.github.com/users/jonas-schievink","html_url":"https://github.com/jonas-schievink","followers_url":"https://api.github.com/users/jonas-schievink/followers","following_url":"https://api.github.com/users/jonas-schievink/following{/other_user}","gists_url":"https://api.github.com/users/jonas-schievink/gists{/gist_id}","starred_url":"https://api.github.com/users/jonas-schievink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonas-schievink/subscriptions","organizations_url":"https://api.github.com/users/jonas-schievink/orgs","repos_url":"https://api.github.com/users/jonas-schievink/repos","events_url":"https://api.github.com/users/jonas-schievink/events{/privacy}","received_events_url":"https://api.github.com/users/jonas-schievink/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jonas-schievink/plantex","description":":seedling: open-world game about plants :evergreen_tree: :leaves: :herb: :palm_tree:","fork":true,"url":"https://api.github.com/repos/jonas-schievink/plantex","forks_url":"https://api.github.com/repos/jonas-schievink/plantex/forks","keys_url":"https://api.github.com/repos/jonas-schievink/plantex/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jonas-schievink/plantex/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jonas-schievink/plantex/teams","hooks_url":"https://api.github.com/repos/jonas-schievink/plantex/hooks","issue_events_url":"https://api.github.com/repos/jonas-schievink/plantex/issues/events{/number}","events_url":"https://api.github.com/repos/jonas-schievink/plantex/events","assignees_url":"https://api.github.com/repos/jonas-schievink/plantex/assignees{/user}","branches_url":"https://api.github.com/repos/jonas-schievink/plantex/branches{/branch}","tags_url":"https://api.github.com/repos/jonas-schievink/plantex/tags","blobs_url":"https://api.github.com/repos/jonas-schievink/plantex/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jonas-schievink/plantex/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jonas-schievink/plantex/git/refs{/sha}","trees_url":"https://api.github.com/repos/jonas-schievink/plantex/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jonas-schievink/plantex/statuses/{sha}","languages_url":"https://api.github.com/repos/jonas-schievink/plantex/languages","stargazers_url":"https://api.github.com/repos/jonas-schievink/plantex/stargazers","contributors_url":"https://api.github.com/repos/jonas-schievink/plantex/contributors","subscribers_url":"https://api.github.com/repos/jonas-schievink/plantex/subscribers","subscription_url":"https://api.github.com/repos/jonas-schievink/plantex/subscription","commits_url":"https://api.github.com/repos/jonas-schievink/plantex/commits{/sha}","git_commits_url":"https://api.github.com/repos/jonas-schievink/plantex/git/commits{/sha}","comments_url":"https://api.github.com/repos/jonas-schievink/plantex/comments{/number}","issue_comment_url":"https://api.github.com/repos/jonas-schievink/plantex/issues/comments{/number}","contents_url":"https://api.github.com/repos/jonas-schievink/plantex/contents/{+path}","compare_url":"https://api.github.com/repos/jonas-schievink/plantex/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jonas-schievink/plantex/merges","archive_url":"https://api.github.com/repos/jonas-schievink/plantex/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jonas-schievink/plantex/downloads","issues_url":"https://api.github.com/repos/jonas-schievink/plantex/issues{/number}","pulls_url":"https://api.github.com/repos/jonas-schievink/plantex/pulls{/number}","milestones_url":"https://api.github.com/repos/jonas-schievink/plantex/milestones{/number}","notifications_url":"https://api.github.com/repos/jonas-schievink/plantex/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jonas-schievink/plantex/labels{/name}","releases_url":"https://api.github.com/repos/jonas-schievink/plantex/releases{/id}","deployments_url":"https://api.github.com/repos/jonas-schievink/plantex/deployments","created_at":"2016-07-20T11:50:38Z","updated_at":"2016-07-20T11:50:38Z","pushed_at":"2016-07-24T13:40:32Z","git_url":"git://github.com/jonas-schievink/plantex.git","ssh_url":"git@github.com:jonas-schievink/plantex.git","clone_url":"https://github.com/jonas-schievink/plantex.git","svn_url":"https://github.com/jonas-schievink/plantex","homepage":null,"size":8437,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"OsnaCS:master","ref":"master","sha":"1ad6d5496e5463f497175f8e70c00d0c35b40a74","user":{"login":"OsnaCS","id":8659522,"avatar_url":"https://avatars.githubusercontent.com/u/8659522?v=3","gravatar_id":"","url":"https://api.github.com/users/OsnaCS","html_url":"https://github.com/OsnaCS","followers_url":"https://api.github.com/users/OsnaCS/followers","following_url":"https://api.github.com/users/OsnaCS/following{/other_user}","gists_url":"https://api.github.com/users/OsnaCS/gists{/gist_id}","starred_url":"https://api.github.com/users/OsnaCS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OsnaCS/subscriptions","organizations_url":"https://api.github.com/users/OsnaCS/orgs","repos_url":"https://api.github.com/users/OsnaCS/repos","events_url":"https://api.github.com/users/OsnaCS/events{/privacy}","received_events_url":"https://api.github.com/users/OsnaCS/received_events","type":"Organization","site_admin":false},"repo":{"id":61811363,"name":"plantex","full_name":"OsnaCS/plantex","owner":{"login":"OsnaCS","id":8659522,"avatar_url":"https://avatars.githubusercontent.com/u/8659522?v=3","gravatar_id":"","url":"https://api.github.com/users/OsnaCS","html_url":"https://github.com/OsnaCS","followers_url":"https://api.github.com/users/OsnaCS/followers","following_url":"https://api.github.com/users/OsnaCS/following{/other_user}","gists_url":"https://api.github.com/users/OsnaCS/gists{/gist_id}","starred_url":"https://api.github.com/users/OsnaCS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OsnaCS/subscriptions","organizations_url":"https://api.github.com/users/OsnaCS/orgs","repos_url":"https://api.github.com/users/OsnaCS/repos","events_url":"https://api.github.com/users/OsnaCS/events{/privacy}","received_events_url":"https://api.github.com/users/OsnaCS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OsnaCS/plantex","description":":seedling: open-world game about plants :evergreen_tree: :leaves: :herb: :palm_tree:","fork":false,"url":"https://api.github.com/repos/OsnaCS/plantex","forks_url":"https://api.github.com/repos/OsnaCS/plantex/forks","keys_url":"https://api.github.com/repos/OsnaCS/plantex/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OsnaCS/plantex/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OsnaCS/plantex/teams","hooks_url":"https://api.github.com/repos/OsnaCS/plantex/hooks","issue_events_url":"https://api.github.com/repos/OsnaCS/plantex/issues/events{/number}","events_url":"https://api.github.com/repos/OsnaCS/plantex/events","assignees_url":"https://api.github.com/repos/OsnaCS/plantex/assignees{/user}","branches_url":"https://api.github.com/repos/OsnaCS/plantex/branches{/branch}","tags_url":"https://api.github.com/repos/OsnaCS/plantex/tags","blobs_url":"https://api.github.com/repos/OsnaCS/plantex/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OsnaCS/plantex/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OsnaCS/plantex/git/refs{/sha}","trees_url":"https://api.github.com/repos/OsnaCS/plantex/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OsnaCS/plantex/statuses/{sha}","languages_url":"https://api.github.com/repos/OsnaCS/plantex/languages","stargazers_url":"https://api.github.com/repos/OsnaCS/plantex/stargazers","contributors_url":"https://api.github.com/repos/OsnaCS/plantex/contributors","subscribers_url":"https://api.github.com/repos/OsnaCS/plantex/subscribers","subscription_url":"https://api.github.com/repos/OsnaCS/plantex/subscription","commits_url":"https://api.github.com/repos/OsnaCS/plantex/commits{/sha}","git_commits_url":"https://api.github.com/repos/OsnaCS/plantex/git/commits{/sha}","comments_url":"https://api.github.com/repos/OsnaCS/plantex/comments{/number}","issue_comment_url":"https://api.github.com/repos/OsnaCS/plantex/issues/comments{/number}","contents_url":"https://api.github.com/repos/OsnaCS/plantex/contents/{+path}","compare_url":"https://api.github.com/repos/OsnaCS/plantex/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OsnaCS/plantex/merges","archive_url":"https://api.github.com/repos/OsnaCS/plantex/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OsnaCS/plantex/downloads","issues_url":"https://api.github.com/repos/OsnaCS/plantex/issues{/number}","pulls_url":"https://api.github.com/repos/OsnaCS/plantex/pulls{/number}","milestones_url":"https://api.github.com/repos/OsnaCS/plantex/milestones{/number}","notifications_url":"https://api.github.com/repos/OsnaCS/plantex/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OsnaCS/plantex/labels{/name}","releases_url":"https://api.github.com/repos/OsnaCS/plantex/releases{/id}","deployments_url":"https://api.github.com/repos/OsnaCS/plantex/deployments","created_at":"2016-06-23T14:25:11Z","updated_at":"2016-07-22T09:18:47Z","pushed_at":"2016-07-24T13:40:32Z","git_url":"git://github.com/OsnaCS/plantex.git","ssh_url":"git@github.com:OsnaCS/plantex.git","clone_url":"https://github.com/OsnaCS/plantex.git","svn_url":"https://github.com/OsnaCS/plantex","homepage":null,"size":9868,"stargazers_count":6,"watchers_count":6,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":23,"mirror_url":null,"open_issues_count":22,"forks":23,"open_issues":22,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OsnaCS/plantex/pulls/67"},"html":{"href":"https://github.com/OsnaCS/plantex/pull/67"},"issue":{"href":"https://api.github.com/repos/OsnaCS/plantex/issues/67"},"comments":{"href":"https://api.github.com/repos/OsnaCS/plantex/issues/67/comments"},"review_comments":{"href":"https://api.github.com/repos/OsnaCS/plantex/pulls/67/comments"},"review_comment":{"href":"https://api.github.com/repos/OsnaCS/plantex/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OsnaCS/plantex/pulls/67/commits"},"statuses":{"href":"https://api.github.com/repos/OsnaCS/plantex/statuses/2601732b1c2644505e17eca46766778e72ab5d57"}}}}
{"actor":{"display_login":"jonas-schievink"}}