Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Octree by DynamicBVH in cull code #44623

Merged
merged 1 commit into from
Dec 24, 2020

Conversation

reduz
Copy link
Member

@reduz reduz commented Dec 23, 2020

-Much greater pairing/unpairing performance
-For now, using it for culling too, but this will change in a couple of days.
-Added a paged allocator, to efficiently alloc/free some types of objects.

@Calinou
Copy link
Member

Calinou commented Dec 23, 2020

Does this PR fix the issue where hidden nodes are still counted in the culling code, therefore decreasing performance?

@Calinou Calinou added this to the 4.0 milestone Dec 23, 2020
@reduz reduz force-pushed the rewrite-renderer-indexer branch 3 times, most recently from 0f7e4f4 to aa4792c Compare December 23, 2020 18:47
@reduz
Copy link
Member Author

reduz commented Dec 23, 2020

Does this PR fix the issue where hidden nodes are still counted in the culling code, therefore decreasing performance?

I think so, hidden nodes are no longer part of the culling nor inserted into the bvh.

Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only reviewed for obvious typos and errors.

servers/rendering/renderer_rd/renderer_scene_render_rd.h Outdated Show resolved Hide resolved
servers/rendering_server.cpp Outdated Show resolved Hide resolved
-Much greater pairing/unpairing performance
-For now, using it for culling too, but this will change in a couple of days.
-Added a paged allocator, to efficiently alloc/free some types of objects.
Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved so we can get this merged.

@reduz reduz merged commit 3fdf4bf into godotengine:master Dec 24, 2020
@lawnjelly
Copy link
Member

I don't have IRC logs so I don't know if any changes were since but this was for the version from 14 hours ago:

I added some basic debug print of the bvh tree:
https://pastebin.com/BcWjD7zh
This is adding 8 random boxes...

<lawnjelly> So I'm not sure that the optimize is doing anything
<lawnjelly> and the tree is staying in worst case balance I think.
<lawnjelly> I'll have another look tomorrow as it is bedtime here.
<lawnjelly> And I'll do a PR to your branch maybe with the debug output code (or you can write some is easy).
<lawnjelly> N is node and L is leaf node by the way.
<lawnjelly> When balanced well it should have more nodes at the top and leafs towards the bottom.
<lawnjelly> Or maybe the optimize routine in bullet isn't able to do that kind of balancing.
<lawnjelly> if it can't the Box2D or randy gaul's can I think.

I'll take another look now and see if I can figure out why it is not balancing.

@lawnjelly
Copy link
Member

Further debugging shows the reason why balance isn't working:

optimize_incremental
N [-1, -1, -1, 1, 1.00001, 1.00001]
	L [-1, -1, -1, 1, 1.00001, 1.00001]
	N [-1, -1, -1, 1, 1.00001, 1.00001]
		L [-1, -1, -1, 1, 1.00001, 1.00001]
		N [-1, -1, -1, 1, 1.00001, 1.00001]
			L [-1, -1, -1, 1, 1.00001, 1.00001]
			N [-1, -1, -1, 1, 1.00001, 1.00001]
				L [-1, -1, -1, 1, 1.00001, 1.00001]
				N [-1, -1, -1, 1, 1.00001, 1.00001]
					L [-1, -1, -1, 1, 1.00001, 1.00001]
					N [-1, -1, -1, 1, 1.00001, 1.00001]
						L [-1, -1, -1, 1, 1.00001, 1.00001]
						N [-1, -1, -1, 1, 1.00001, 1.00001]
							L [-1, -1, -1, 1, 1.00001, 1.00001]
							L [-1, -1, -1, 1, 1.00001, 1.00001]

This is showing the volumes for each node. The volumes are incorrect. Presumably they are in local space, perhaps before local transform, not in world space.

@lawnjelly
Copy link
Member

renderer_scene_cull, line 1073 (_update_instance()), the aabbs should presumably be transformed_aabbs as follows:

			p_instance->indexer_id = p_instance->scenario->indexers[Scenario::INDEXER_GEOMETRY].insert(p_instance->transformed_aabb, p_instance);
		} else {
			p_instance->indexer_id = p_instance->scenario->indexers[Scenario::INDEXER_VOLUMES].insert(p_instance->transformed_aabb, p_instance);

The update function in the bvh doesn't appear to be being called at all, as far as I can tell so far, only the insert, so that is another thing which we can fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants