shteeve3d / blender-wiggle-2

Rewrite of blender-wiggle with new features and physics
GNU General Public License v3.0
727 stars 42 forks source link

Performance issue with collection collision, and some very odd code #52

Open DrakeGator opened 10 months ago

DrakeGator commented 10 months ago

Blender version: 4.0.2

I was having some serious framerate drops in the viewport from 60FPS to 5FPS in a very small scene with only a half dozen very low-poly colliding meshes and I eventually narrowed it down to using the "collection" type of collision. I went digging in the code for it, commenting things out until the performance drop stopped, and it's this code that's causing the issue:

https://github.com/shteeve3d/blender-wiggle-2/blob/b95c560f5713a3c66b3edf786a1470b4d86cd4c3/wiggle_2.py#L474-L486

It's specifically this line:

b.wiggle_collider_collection = bpy.data.collections.get(b.wiggle_collider_collection.name)

which, if I comment it out, the performance issues disappear, and the collision still works fine.

tbh I'm not sure what it's supposed to be doing. The only case in which this line is run is when b.wiggle_collider_collection is not None, and it re-sets it to - as far as I can tell - the same collection that it was already pointing to.

I have no idea why this is slowing things down so much but it doesn't seem to be doing anything useful, but I don't know the Blender API too well so maybe this is working around some issue that I'm unaware of...?

More generally this block of code is strange. The collision_col property is never used outside of this code, and every case other than the first if has no effect (they use bpy.data.collections/objects.get but don't assign the result anywhere). It seems like this was added in this commit and was never changed afterwards. Temporary code that never got removed?

mjjsikora commented 4 months ago

Thanks mate, your suggestion to comment out the code, boosted performance on my machine too. Thank you for sharing that!

Jofoyo commented 4 days ago

This whole section seems to be commentable out, and just looks like orphaned data. In 4.3 this section also breaks collisions outright because you can no longer assign embedded id pointers to properties.