0
$\begingroup$

I'm writing a window generator script.

Here is a current version of my script: https://gist.github.com/romanvolodin/3bfd349795443118a2298819349a0b3c

Windows config: https://gist.github.com/romanvolodin/60055b1593a3c4c6d52e017cfd9696be

Script's algorithm looks like this (in short):

  • Read json config
  • Build a wall object
  • Build window's inner part
  • Get vertex normals on the edge of a window
  • For every window build window's decoration

In my scene I have a mesh object ('profile') which is define the decor profile. enter image description here

To build a window decor, I copy given profile several times to window vertex position and orient it in vertex normal direction.

enter image description here

And then I bridge them together. Kind of 'profile along path'.

I have a super weird bug - the most of the time I get distorted geometry. Something corrupt my normal's data. But sometimes the script works correctly (at 0:07, 1:06, 1:28, 1:37, 1:45, 2:12): https://www.youtube.com/watch?v=I6wysGzIQfU

Also, only 4 windows at the beginning are distorted, 5th and next look just nice. (These crumpled objects at the origin are four first windows.)

enter image description here

enter image description here

enter image description here

Here is more.

In my script I print normal's positions. Then I add a new Bmesh object. And then I print normal's positions again.

    # ...
    windows_edge_normals = get_windows_edge_normals(windows_vertex_positions)

    for i, window_normals in enumerate(windows_edge_normals, start=1):
        print("before", i)
        for num, normal in enumerate(window_normals):
            vert_co, vert_normal = normal
            print(
                "   co: {}\n"
                "normal {}".format(vert_co, vert_normal)
            )

    for i, window_normals in enumerate(windows_edge_normals, start=1):
        print("after", i)
        bm = bmesh.new()
        last_profile = None
        for num, normal in enumerate(window_normals):
            vert_co, vert_normal = normal
            print(
                "   co: {}\n"
                "normal {}".format(vert_co, vert_normal)
            )
    # ...

And the result is completely different! (Note: 'before' is green and on the right, 'after' red on the left, see link) https://www.diffchecker.com/9YEV3moY

Why?! I've just added a new Bmesh!

So the question is - what I'm doing wrong? Should I delete previous bmeshes explicitly (the wall and inner parts)? Or it's a bug in Blender? Any help will be appreciated.

$\endgroup$
7
  • 1
    $\begingroup$ If you are placing the trim profile simply rotated 45º at the bottom corners of the windows that will inevitably lead to distortions. That is a geometry problem, not a bug in your code. See related blender.stackexchange.com/questions/56079/… $\endgroup$ Oct 8, 2018 at 18:39
  • $\begingroup$ Please see the video. The corners are ok, but first 4 windows not. $\endgroup$ Oct 8, 2018 at 18:57
  • $\begingroup$ Looking good. Try updating normals example1 Example2 $\endgroup$
    – batFINGER
    Oct 9, 2018 at 6:34
  • $\begingroup$ I've tried to add bm.normal_update() right after bm = bmesh.new() (line 463) and here is what I've got: when I start fresh Blender and run my script the first time, I get no errors. On next runs I get glitches just like described above. It looks like a memory issue. $\endgroup$ Oct 9, 2018 at 13:35
  • $\begingroup$ Hi, to look into this issue I'd need run the code inside Blender. Could you make all files available to reproduce the error? $\endgroup$
    – ideasman42
    Oct 24, 2018 at 6:11

0

You must log in to answer this question.

Browse other questions tagged .