Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
ofux committed Apr 26, 2019
2 parents 54d0d80 + a0c389e commit 888df32
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Operations/Paint.cs
Expand Up @@ -14,6 +14,7 @@ public class Paint : IOperation
protected Vector3i from;
protected Vector3i to;
protected double radiusSquared;
protected UnitConverter converter;

// Empty constructor needed by serialization
public Paint()
Expand Down Expand Up @@ -85,7 +86,7 @@ public IOperation Merge(IOperation other)

public int FindAffectedColliders(Collider[] collidersBuffer)
{
return 0;
return Physics.OverlapSphereNonAlloc((Vector3)converter.VoxelToUnityPosition(voxelPosition), (float) converter.VoxelToUnityDisance(voxelRadius), collidersBuffer);
}

public virtual void OnOperationDone()
Expand All @@ -107,6 +108,7 @@ public override string ToString()

protected void Init(UltimateTerrain uTerrain)
{
converter = uTerrain.Converter;
var halfSize = new Vector3i(voxelRadius, voxelRadius, voxelRadius);
from = voxelPosition - halfSize;
to = voxelPosition + halfSize;
Expand Down
13 changes: 11 additions & 2 deletions VoxelTypeFunctions/TopSidesNoLerpColorsVoxelTypeFunctions.cs
Expand Up @@ -10,20 +10,29 @@ namespace UltimateTerrains
[Serializable]
public class TopSidesNoLerpColorsVoxelTypeFunctions : AbstractVoxelTypeFunctions
{
[SerializeField] private Color topColor = Color.clear;
[SerializeField] private Color sidesColor = Color.clear;
[SerializeField] private Color32 topColor = Color.clear;
[SerializeField] private Vector4 topUv2 = Color.clear;
[SerializeField] private Color32 sidesColor = Color.clear;
[SerializeField] private Vector4 sidesUv2 = Color.clear;
[SerializeField] private float slopeLimit = 0f;

public override Color32 GetVertexColor(Vector3d meshWorldPosition, Vector3 vertexPosition, Vector3 vertexNormal)
{
return vertexNormal.y < slopeLimit ? sidesColor : topColor;
}

public override Vector4 GetVertexUVW2(Vector3d meshWorldPosition, Vector3 vertexPosition, Vector3 vertexNormal)
{
return vertexNormal.y < slopeLimit ? sidesUv2 : topUv2;
}

public override void OnEditorGUI(UltimateTerrain uTerrain, VoxelType voxelType)
{
#if UNITY_EDITOR
topColor = EditorGUILayout.ColorField("Top Color:", topColor);
topUv2 = EditorGUILayout.ColorField("Top UV2 (x=r, y=g, z=b, w=a):", topUv2);
sidesColor = EditorGUILayout.ColorField("Sides Color:", sidesColor);
sidesUv2 = EditorGUILayout.ColorField("Sides UV2 (x=r, y=g, z=b, w=a):", sidesUv2);
slopeLimit = EditorGUILayout.Slider("Slope limit:", slopeLimit, -1f, 1f);
#endif
}
Expand Down

0 comments on commit 888df32

Please sign in to comment.