Jump to content
Sign in to follow this  

Issue with runtime edition and probuilderized meshes

Recommended Posts

Windows 8.1

Unity 5.3.1f1

ProBuilder 2.4.8f1 (r3764)




Fresh but happy user of ProBuilder. It's doing (almost !) all I need. But when I started to play a bit more with runtime edition capabilities, I noticed an issue and it seems I can't fix it.


I had a working scene with runtine edition working. I imported a large 3D model composed of many meshes, that I all probuilderized (with "conserve faces"). From then, the runtime edition stopped working, as I couldn't select a face anymore on most meshes (and no error messages), and when I was able, it was buggy and I kept getting messages like this :


Mesh.vertices is too small. The supplied vertex array has less vertices than are referenced by the triangles array.
ProBuilder2.Common.pb_Object_Utility:TranslateVertices(pb_Object, Int32[], Vector3)
ProBuilder2.Examples.RuntimeEdit:Update() (at Assets/ProCore/Runtime Editing/RuntimeEdit.cs:423)


Mesh.colors is out of bounds. The supplied array needs to be the same size as the Mesh.vertices array.
ProBuilder2.Examples.RuntimeEdit:Update() (at Assets/ProCore/Runtime Editing/RuntimeEdit.cs:425)


Mesh.uv is out of bounds. The supplied array needs to be the same size as the Mesh.vertices array.
ProBuilder2.Examples.RuntimeEdit:Update() (at Assets/ProCore/Runtime Editing/RuntimeEdit.cs:425)




So I started investigating : I started a new scene of the runtime edition exemple, added a ProBuilder cube, and a Unity cube that I probuilderized. And I noticed that runtime edition on the second doesn't work properly :




I can edit both cube in the editor without issues (except maybe UV, texture isn't repeting as for the ProBuilder shape)  : 4tplK3v.gif


But in runtime it's a different story : mesh breaks, clicking on the selected faces is not registered where it should be... : PHKlAm3.gif

I assume that my first issues with more complex meshes arise from this, as very simple meshes already behave strangely.
I'd be happy to help in solving this issue with every tests or info needed :)
Thanks in advance !

Share this post

Link to post
Share on other sites

Thanks ! This seems to have fixed the issue on my simple exemple. I still have some bizarre selection and on some faces, I still get errors, but at least now it'es properly extruded :




Errors I get when I click the top face : 


Failed setting triangles. Some indices are referencing out of bounds vertices. IndexCount: 6, VertexCount: 4
UnityEngine.Mesh:SetTriangles(Int32[], Int32)
pb_Object:GeometryWithVerticesFaces(Vector3[], pb_Face[])
pb_Object:CreateInstanceWithVerticesFaces(Vector3[], pb_Face[])
ProBuilder2.Examples.RuntimeEdit:RefreshSelectedFacePreview() (at Assets/ProCore/ProBuilder/API Examples/Runtime Editing/RuntimeEdit.cs:225)
ProBuilder2.Examples.RuntimeEdit:Update() (at Assets/ProCore/ProBuilder/API Examples/Runtime Editing/RuntimeEdit.cs:156)
IndexOutOfRangeException: Array index is out of range.
pb_Object.SmoothPerGroups ()
pb_Object.RefreshNormals ()
pb_Object.Refresh ()
pb_Object.GeometryWithVerticesFaces (UnityEngine.Vector3[] v, ProBuilder2.Common.pb_Face[] f)
pb_Object.CreateInstanceWithVerticesFaces (UnityEngine.Vector3[] v, ProBuilder2.Common.pb_Face[] f)
ProBuilder2.Examples.RuntimeEdit.RefreshSelectedFacePreview () (at Assets/ProCore/ProBuilder/API Examples/Runtime Editing/RuntimeEdit.cs:225)
ProBuilder2.Examples.RuntimeEdit.Update () (at Assets/ProCore/ProBuilder/API Examples/Runtime Editing/RuntimeEdit.cs:156)


On my more complex 3D model, I still have meshs where I can't select any face, even if it's probuilderized and have a mesh collider. But others are now correctly selected and can be edited. I guess the issues with some mesh are more related to probuilderize.
What would be your recommandation to ensure best conversion from a mesh ? Is there some guideline to respect in designing the mesh ? What's the best way to convert ? 
Thanks for the fast answer anyhow :)

Share this post

Link to post
Share on other sites

Oh, sorry - I was mistaken.  If it's a ProBuilder-ized model that was made in the Editor it will have been UV2 unwrapped.  That means you need to call ToMesh prior to modifying vertices.  So instead of putting that ToMesh call right before the Refresh call, instead put the currentSelection.pb.ToMesh(); right after the IsValid check.



		public void Update()
			if(Input.GetMouseButtonUp(0) && !Input.GetKey(KeyCode.LeftAlt)) {

						currentSelection.pb.ToMesh();	// Refresh will update the Collision mesh volume, face UVs as applicatble, and normal information.

						// Check if this face has been previously selected, and if so, move the face.
						// Otherwise, just accept this click as a selection.
							previousSelection = new pb_Selection(currentSelection.pb, currentSelection.face);

						Vector3 localNormal = pb_Math.Normal( pbUtil.ValuesWithIndices(currentSelection.pb.vertices, currentSelection.face.distinctIndices) );

							currentSelection.pb.TranslateVertices( currentSelection.face.distinctIndices, localNormal.normalized * -.5f );
							currentSelection.pb.TranslateVertices( currentSelection.face.distinctIndices, localNormal.normalized * .5f );

						currentSelection.pb.Refresh();	// Refresh will update the Collision mesh volume, face UVs as applicatble, and normal information.

						// this create the selected face preview

Share this post

Link to post
Share on other sites

Thanks for the update !


I tried it but can't see any difference in behaviour, and I'm still getting the same errors in the log as in my previous messages.


Is there a special way to "probuilder-ize" to ensure correct behaviour ?


Thanks in advance

Share this post

Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now
Sign in to follow this