zturtleman / mm3d

Maverick Model 3D is a 3D model editor and animator for games.
https://clover.moe/mm3d
GNU General Public License v2.0
115 stars 23 forks source link

Improve normals face out performance #67

Open zturtleman opened 5 years ago

zturtleman commented 5 years ago

The FaceOutCommand has an understatement:

// TODO this is slow, see if we can speed it up

[Mick Pearson] made a note to look at it, but at a glance it looks the programmer was just too lazy to refactor it correctly, in favor of brute-forcing their CPU.

Originally posted by @mick-p1982 in https://github.com/zturtleman/mm3d/issues/66#issuecomment-523410128

m-7761 commented 5 years ago

I will fix it. I just made a comment on an aside. The library is pretty funky. Today I've been removing numerous files from the mm3dcore and libmm3d code, since a lot of it appears to be junk. At this moment I'm looking at local_array.h and local_ptr.h that appear to be identical except for their name.

They are little used. There is a lot of code that sees no use. The few places those are used can probably use unique_ptr. Or just be refactored. There's a lot of files that are just one declaration, and matching definition files, that may be two lines of code. It creates the appearance there are like 400 files in the project. It takes more time to remove this stuff than to add it. I wonder if the code evolved until parts that once saw use no longer saw use, but were not cleaned out, or if it was just a habit to generate so many files that don't really contribute to the code's mission.

I'm sure I'm devoting hundreds of hours to this project. I've long lost track. I hope my work can be folded back into the code here to make the project better off. I'm sure there is a lot of junk code on open-source websites. What we really need is more quality code. Good habits creates foundations for the future... bad habits create wastelands, junkyards, hell holes. Despite the plethora of 3d model suites out there, there's not really much in the way of open-source projects.

EDITED: Hold the phone, there's release_ptr.h too. Edited, actually I think this one is different in that it calls release. I think there others may use delete and delete[] now. I have to dig them out of the trash to find out. (EDITED: They are. No comments/documentation. release_ptr isn't technically needed. It should be removed... the library uses "release" to manage heap ownership. The classes that use it are implementing themselves, in which case they can't possibly use a different heap.) EDITED: After implementing this, it occurred to me that the filters shouldn't even be allocating their own options. Maybe it's a throwback. Sorry to go so off-topic. Don't mean too, but I want to talk about things sometimes without making an Issue out of it.