Skip to content

Commit

Permalink
Refactored samples
Browse files Browse the repository at this point in the history
  • Loading branch information
BasmanovDaniil committed Jan 6, 2020
1 parent 0b61fbc commit 76093c5
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 35 deletions.
3 changes: 1 addition & 2 deletions Samples~/Breakout/Breakout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,8 @@ private void GenerateLevel()

Vector3 leftEdge = Vector3.left*config.wallWidth/2 +
Vector3.up*(config.wallHeightOffset + y*brickHeight);
for (int i = 0; i < brickSizes.Count; i++)
foreach (var brickSize in brickSizes)
{
var brickSize = brickSizes[i];
var position = leftEdge + Vector3.right*sizeValues[brickSize]/2;

// Randomize the tint of the current brick
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace ProceduralToolkit.Samples.Buildings
{
[CustomEditor(typeof(BuildingGeneratorConfigurator))]
public class BuildingGeneratorConfiguratorEditor : UnityEditor.Editor
public class BuildingGeneratorConfiguratorEditor : Editor
{
private BuildingGeneratorConfigurator generator;

Expand Down
24 changes: 5 additions & 19 deletions Samples~/Buildings/Runtime/ProceduralFacadeElements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,7 @@ protected static CompoundMeshDraft Window(

private static CompoundMeshDraft Windowpane(Vector3 min, Vector3 max, Color frameColor, Color glassColor)
{
Vector3 frameDepth;
Vector3 windowMin;
Vector3 windowWidth;
Vector3 windowHeight;
var frame = WindowpaneFrame(min, max, frameColor, out frameDepth, out windowMin, out windowWidth, out windowHeight);
var frame = WindowpaneFrame(min, max, frameColor, out Vector3 frameDepth, out Vector3 windowMin, out Vector3 windowWidth, out Vector3 windowHeight);
var glass = WindowpaneGlass(frameDepth, windowMin, windowWidth, windowHeight, glassColor);
return new CompoundMeshDraft().Add(frame).Add(glass);
}
Expand All @@ -166,11 +162,7 @@ private static MeshDraft WindowpaneFrame(Vector3 min, Vector3 max, Color frameCo
Vector3 size = max - min;
Vector3 widthVector = size.ToVector3XZ();
Vector3 heightVector = size.ToVector3Y();

Vector3 frameWidth;
Vector3 frameHeight;
Vector3 startPosition;
var frame = WindowpaneFrameRods(min, widthVector, heightVector, out frameWidth, out frameHeight, out frameDepth, out startPosition);
var frame = WindowpaneFrameRods(min, widthVector, heightVector, out Vector3 frameWidth, out Vector3 frameHeight, out frameDepth, out Vector3 startPosition);

windowMin = min + frameWidth + frameHeight;
windowWidth = widthVector - frameWidth*2;
Expand Down Expand Up @@ -279,14 +271,9 @@ private static MeshDraft Balcony(Vector3 origin, float width, Color wallColor)
Vector3 balconyHeight = Vector3.up*BalconyHeight;
Vector3 balconyDepth = Vector3.forward*BalconyDepth;

Vector3 balconyCenter;
var balconyOuter = BalconyOuter(origin, widthVector, balconyHeight, balconyDepth, out balconyCenter);

Vector3 innerWidthOffset;
Vector3 innerWidth;
Vector3 innerDepth;
var balconyOuter = BalconyOuter(origin, widthVector, balconyHeight, balconyDepth, out Vector3 balconyCenter);
var balconyInner = BalconyInner(widthVector, balconyHeight, balconyDepth, balconyCenter,
out innerWidthOffset, out innerWidth, out innerDepth);
out Vector3 innerWidthOffset, out Vector3 innerWidth, out Vector3 innerDepth);

var balconyBorder = BalconyBorder(origin, widthVector, balconyHeight, balconyDepth, innerWidthOffset, innerWidth, innerDepth);

Expand Down Expand Up @@ -379,8 +366,7 @@ protected static CompoundMeshDraft BalconyGlazed(Vector3 origin, float width, fl

var compoundDraft = new CompoundMeshDraft();

Vector3 balconyCenter;
var balcony = BalconyOuter(origin, widthVector, balconyHeight, balconyDepth, out balconyCenter)
var balcony = BalconyOuter(origin, widthVector, balconyHeight, balconyDepth, out Vector3 balconyCenter)
.Paint(wallColor);
balcony.name = WallDraftName;
compoundDraft.Add(balcony);
Expand Down
6 changes: 2 additions & 4 deletions Samples~/Buildings/Runtime/ProceduralFacadePlanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ private void SetupConstructors(Palette palette)

private ILayout PlanNormalFacade(float facadeWidth, int floors, bool hasAttic, bool leftIsConvex, bool rightIsConvex)
{
float remainder;
List<PanelSize> panelSizes = DivideFacade(facadeWidth, leftIsConvex, rightIsConvex, out remainder);
List<PanelSize> panelSizes = DivideFacade(facadeWidth, leftIsConvex, rightIsConvex, out float remainder);
bool hasBalconies = RandomE.Chance(0.5f);

var vertical = CreateNormalFacadeVertical(panelSizes, 0, panelSizes.Count, floors, hasAttic, hasBalconies);
Expand All @@ -114,8 +113,7 @@ private ILayout PlanNormalFacade(float facadeWidth, int floors, bool hasAttic, b
private ILayout PlanEntranceFacade(float facadeWidth, int floors, float entranceInterval, bool hasAttic, bool leftIsConvex,
bool rightIsConvex)
{
float remainder;
List<PanelSize> panelSizes = DivideFacade(facadeWidth, leftIsConvex, rightIsConvex, out remainder);
List<PanelSize> panelSizes = DivideFacade(facadeWidth, leftIsConvex, rightIsConvex, out float remainder);
bool hasBalconies = RandomE.Chance(0.5f);

commonConstructors[PanelType.Entrance] = constructors[PanelType.Entrance].GetRandom();
Expand Down
2 changes: 1 addition & 1 deletion Samples~/Chairs/Editor/ChairGeneratorConfiguratorEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace ProceduralToolkit.Samples
{
[CustomEditor(typeof(ChairGeneratorConfigurator))]
public class ChairGeneratorConfiguratorEditor : UnityEditor.Editor
public class ChairGeneratorConfiguratorEditor : Editor
{
private ChairGeneratorConfigurator generator;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace ProceduralToolkit.Samples
{
[CustomEditor(typeof(LowPolyTerrainGeneratorConfigurator))]
public class LowPolyTerrainGeneratorConfiguratorEditor : UnityEditor.Editor
public class LowPolyTerrainGeneratorConfiguratorEditor : Editor
{
private LowPolyTerrainGeneratorConfigurator generator;

Expand Down
5 changes: 1 addition & 4 deletions Samples~/Mazes/MazeGeneratorConfigurator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,7 @@ private IEnumerator GenerateCoroutine()

private void DrawEdge(Maze.Edge edge)
{
Vector2Int position;
int width;
int height;
MazeGenerator.EdgeToRect(edge, wallSize, roomSize, out position, out width, out height);
MazeGenerator.EdgeToRect(edge, wallSize, roomSize, out Vector2Int position, out int width, out int height);

Color color;
if (useGradient)
Expand Down
6 changes: 3 additions & 3 deletions Samples~/SDF/ImageSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ private void Awake()
SetDebug(true);
}

private void SelectImage(Image image)
private void SelectImage(Image selectedImage)
{
for (int i = 0; i < images.Count; i++)
foreach (var image in images)
{
images[i].enabled = images[i] == image;
image.enabled = image == selectedImage;
}
}

Expand Down

0 comments on commit 76093c5

Please sign in to comment.