Search Unity

Polybrush prefab brush issue

Discussion in 'World Building' started by Reorso, Oct 21, 2018.

  1. Reorso

    Reorso

    Joined:
    Mar 7, 2016
    Posts:
    3
    Polybrush prefab brush paints at random coordinates on the mesh, I'm painting on a low-poly mesh and when i paint prefabs I can see the brush displaying correctly and on the hierarchy new clone get created, but not in the scene. after sercing for some time i found that they are randomly generating on the surface of the mesh. using unity 2018.2.3 personal, on the screenshot i'm clicking the right button of the mouse and you can see some prefabs near the generated near the coordinate. thanks in advance!
     

    Attached Files:

  2. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Hi! Sorry about that, no longer an issue in the upcoming Polybrush 1.x release!
     
    Reorso likes this.
  3. zachlindblad

    zachlindblad

    Joined:
    Sep 29, 2016
    Posts:
    39
    Hey, @gabrielw_unity I'm still seeing this issue in polybrush 1.0.1, are there any work arounds available? Guessing it has something to do with scaled meshes?
     
  4. zachlindblad

    zachlindblad

    Joined:
    Sep 29, 2016
    Posts:
    39
    Well... found a hacky fix for now, the issue is with the brush settings radius being applied on the verts in local space when it's shown in editor in world space (as well as most likely desired to be defined in world space if you want a consistent radius across objects). If anybody else has this problem, either reduce your brush radius or you can make the beginning of the function "PlaceGameObject" in BrushModePrefab.cs look like this:

    Code (CSharp):
    1.         void PlaceGameObject(PolyRaycastHit hit, PrefabAndSettings prefabAndSettings, BrushTarget target, BrushSettings settings)
    2.         {
    3.             if(prefabAndSettings == null)
    4.                 return;
    5.  
    6.             GameObject prefab = prefabAndSettings.gameObject;
    7.             Vector3 worldScale = target.gameObject.transform.lossyScale;
    8.             float avgScale = (worldScale.x+worldScale.y+worldScale.z)/3f;
    9.             Ray ray = RandomRay(hit.position, hit.normal, settings.radius/avgScale, settings.falloff, settings.falloffCurve);
    10.  
    (also since it's now in package manager you'll need to copy the package from packagecache to the packages folder to get the changes to stick)
     
    Last edited: Dec 11, 2019
    tealendril likes this.
  5. ngerbens

    ngerbens

    Joined:
    Nov 20, 2017
    Posts:
    33
    Having the same issue too. Thank you very much for posting the cause and solution. Very helpful.
     
    zachlindblad likes this.
  6. SunderRaj

    SunderRaj

    Joined:
    Mar 12, 2018
    Posts:
    1
    Amazing it's still an issue now. Incredibly frustrating.