Search Unity

Problem subdivide objects

Discussion in 'World Building' started by ftejada, Sep 20, 2018.

  1. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    695
    Hi!

    I have followed its course

    and when trying to subdivide objects, but with some objects I get this error by console and I do not know very well what I am doing wrong:

    NullReferenceException: Object reference not set to an instance of an object
    ProBuilder.MeshOperations.pb_ConnectEdges.Connect (ProBuilder.Core.pb_Object pb, IEnumerable`1 edges, ProBuilder.Core.pb_Face[]& addedFaces, ProBuilder.Core.pb_Edge[]& connections, Boolean returnFaces, Boolean returnEdges, System.Collections.Generic.HashSet`1 faceMask) (at C:/Users/karlh/procore/probuilder/probuilder2.0/Assets/ProCore/ProBuilder/Classes/ClassesEditing/pb_ConnectEdges.cs:164)
    ProBuilder.MeshOperations.pb_ConnectEdges.Connect (ProBuilder.Core.pb_Object pb, IEnumerable`1 faces, ProBuilder.Core.pb_Face[]& subdividedFaces) (at C:/Users/karlh/procore/probuilder/probuilder2.0/Assets/ProCore/ProBuilder/Classes/ClassesEditing/pb_ConnectEdges.cs:41)
    ProBuilder.MeshOperations.pb_Subdivide.Subdivide (ProBuilder.Core.pb_Object pb, IList`1 faces, ProBuilder.Core.pb_Face[]& subdividedFaces) (at C:/Users/karlh/procore/probuilder/probuilder2.0/Assets/ProCore/ProBuilder/Classes/ClassesEditing/pb_Subdivide.cs:34)
    ProBuilder.MeshOperations.pb_Subdivide.Subdivide (ProBuilder.Core.pb_Object pb) (at C:/Users/karlh/procore/probuilder/probuilder2.0/Assets/ProCore/ProBuilder/Classes/ClassesEditing/pb_Subdivide.cs:22)
    ProBuilder.EditorCore.pb_MenuCommands.MenuSubdivide (ProBuilder.Core.pb_Object[] selection) (at C:/Users/karlh/procore/probuilder/probuilder2.0/Assets/ProCore/ProBuilder/Editor/EditorCore/pb_MenuCommands.cs:1614)
    ProBuilder.Actions.SubdivideObject.DoAction () (at C:/Users/karlh/procore/probuilder/probuilder2.0/Assets/ProCore/ProBuilder/Editor/EditorCore/MenuActions/Object/SubdivideObject.cs:29)
    ProBuilder.EditorCore.pb_MenuAction.DoButton (Boolean isHorizontal, Boolean showOptions, UnityEngine.Rect& optionsRect, UnityEngine.GUILayoutOption[] layoutOptions) (at C:/Users/karlh/procore/probuilder/probuilder2.0/Assets/ProCore/ProBuilder/Editor/EditorCore/pb_MenuAction.cs:289)
    ProBuilder.EditorCore.pb_EditorToolbar.OnGUI () (at C:/Users/karlh/procore/probuilder/probuilder2.0/Assets/ProCore/ProBuilder/Editor/EditorCore/pb_EditorToolbar.cs:365)
    ProBuilder.EditorCore.pb_Editor.OnGUI () (at C:/Users/karlh/procore/probuilder/probuilder2.0/Assets/ProCore/ProBuilder/Editor/EditorCore/pb_Editor.cs:377)
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
    UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:295)
    UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:288)
    UnityEditor.HostView.InvokeOnGUI (Rect onGUIPosition) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:255)

    Can someone tell me why I get these errors?

    Greetings and thanks in advance
     
  2. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Hi, thanks for posting here! :)

    Can you tell us the exact version of Unity and ProBuilder that you are using? Also, can you show a screenshot of the object you are subdividing, when the error occurs? Thanks!
     
    ftejada likes this.
  3. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    695
    I regret the delay in answering but I am out of work and I almost do not have internet access ...

    The Unity version is 2018.2.8 ...

    Here I put some screenshots of the object:
    ProbuiderProblem1.jpg ProbuiderProblem2.jpg


    regards
     
  4. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    695
  5. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Hi, sorry for the wait! The mesh looks ok. I'm not sure what would cause the error. I don't see your version of ProBuilder though- make sure you are using the version from the Package Manager, not the Asset Store?
     
  6. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    695
    Thanks for answering @gabrielw_unity .
    I think I remember that the version I installed was through PackageManager. But since some weeks ago this may be my memory fails me ...
    I leave you a photo in case you see it clearer ...

    Probuilder.jpg

    As it is a Learning project, I could send you a copy in case it helps you find the problem.

    regards
     
  7. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Hi! Sure, that would be perfect! :)
     
  8. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    695
  9. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Ah, this might be the issue- it's one part, at least. There is a face on the floor (see image) that has incorrect geometry (not your fault, ProBuilder should have fixed this, sorry).

    That yellow face selected is a single face, but it has an edge going through it...should be impossible, definitely a problem. I'll try cleaning that up...

    upload_2018-10-17_10-47-32.png
     
  10. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Ok! Yep, there were several of these faces, and many n-gons, which I think were causing Subdivide to fail. To fix this:

    1. Go through your object, and find any ngons (faces with more than 4 edges), and use the "Connect Vertices" tool to connect points and reduce them to quads (4 edges) or tris (3 edges).
    2. If you try to connect two verts and the object goes black or throws an error, hit UNDO, and delete the ngon. Then, rebuild it as quads and/or tris by using Bridge Edges.

    In the future, try to keep your models using only Quads, tris if necessary. This will keep your mesh clean and less likely to have issues.

    Hope that helps! :)
     
    Minous likes this.
  11. ftejada

    ftejada

    Joined:
    Jul 1, 2015
    Posts:
    695
    I will look and try what you tell me these days.

    On the other hand, will this error be corrected in some way in a future patch?

    regards
     
  12. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Hi! Yes, we are working on it :)
     
    ftejada likes this.