MARUI-PlugIn/BlenderXR

Translating in face edit mode does not work as expected

Opened this issue · 1 comments

I am running on Windows 10 with a Valve Index, and tested on the BlenderXR_Windows_20200506.zip download, and a compiled version of this repository.

I loop cut a cube into multiple faces. If I change to face edit mode and select all faces on the same side, it is expected that the faces remain flat but the edges and corners do not translate at the same rate as the inner vertices.

This is what happens:

blenderxr_translate

This is what is expected:

blenderxr_translate_expected

This seems to work fine in edge and vertex edit modes.

So after more testing I found this also happens in edge select mode as well, but not in vertex select mode.

But I also found the cause of and the solution to this issue. It looks like when applying the transform it will repeat the same transform on a vertex that is shared between selected faces or edges.

If a vertex is connected to 4 selected faces, it will be transformed 4 times.

The solution that works in my testing is to, rather than iterate the mesh faces and then transform their vertices, just iterate the mesh vertices and transform the ones in the selection. So for for example, instead of the if (ts->selectmode & SCE_SELECT_EDGE) etc, just do the one for vertices no matter the select mode, basically just do this for all select modes:

BMVert *v;
BM_ITER_MESH(v, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(v, BM_ELEM_SELECT)) {
float *co = v->co;
memcpy((float*)&temp1, co, sizeof(float) * 3);
mul_v3_m4v3(co, delta.m, (float*)&temp1);
}
}

It seems this same pattern is done in lots of places including in the extrude widget.