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

RotateTool centers on average instead of min/max #89

Open m-7761 opened 4 years ago

m-7761 commented 4 years ago

Double-vertices, etc. throw off averages. There's lots of code that does center on min/max but it's all pretty funky. I've rewritten it somewhat. Probably would benefit from a utility function or class.

m-7761 commented 4 years ago

The radius of the pivot should be a percentage of the selection's bounding box, instead of fixed, so it is visible at different scales/units.

It's also invisible on a green background, and not very visible on the teal background; so probably it should use the same XOR logic as the bounding box. Which shouldn't be white because that's invisible on gray. I've been using gray. It's less contrast but won't disappear into grays.

m-7761 commented 4 years ago

FWIW there is some trickery if using XOR because the crosshairs formed by the planes of the rotate pivot draw directly on top of themselves, and so cancel each other out. The following depth-compression technique lets the depth-buffer prevent the canceling out.

            glEnable(GL_DEPTH_TEST);
                glDepthRange(0,0);
                glDepthFunc(GL_LESS);
                {
                    //glColor3f(0,1,0);
                    glEnable(GL_COLOR_LOGIC_OP);
                    glColor3ub(0x80,0x80,0x80);
                    glLogicOp(GL_XOR);
                    glTranslated(x,y,z);
                    rotatepoint_draw_manip(scale); //0.25f
                    glTranslated(-x,-y,-z);
                    glDisable(GL_COLOR_LOGIC_OP);
                }
                glDepthRange(0,1);
                glDepthFunc(GL_LEQUAL);

It looks good I think. Not everything can be XOR. Unfortunately.