public void Validate() { if (!IsValid) { return; } if (brushOutline.polygons == null) { return; } if (surfaceDefinition == null) { surfaceDefinition = new ChiselSurfaceDefinition(); } surfaceDefinition.EnsureSize(brushOutline.polygons.Length); // Temporary fix for misformed brushes for (int i = 0; i < brushOutline.polygons.Length; i++) { brushOutline.polygons[i].surfaceID = i; } brushOutline.CalculatePlanes(); }
public void Validate() { if (surfaceDefinition == null) { surfaceDefinition = new ChiselSurfaceDefinition(); } stepHeight = Mathf.Max(kMinStepHeight, stepHeight); innerDiameter = Mathf.Min(outerDiameter - kMinStairsDepth, innerDiameter); innerDiameter = Mathf.Max(kMinInnerDiameter, innerDiameter); outerDiameter = Mathf.Max(innerDiameter + kMinStairsDepth, outerDiameter); outerDiameter = Mathf.Max(kMinOuterDiameter, outerDiameter); height = Mathf.Max(stepHeight, Mathf.Abs(height)) * (height < 0 ? -1 : 1); treadHeight = Mathf.Max(0, treadHeight); nosingDepth = Mathf.Max(0, nosingDepth); nosingWidth = Mathf.Max(0, nosingWidth); riserDepth = Mathf.Max(kMinRiserDepth, riserDepth); rotation = Mathf.Max(kMinRotation, Mathf.Abs(rotation)) * (rotation < 0 ? -1 : 1); innerSegments = Mathf.Max(kMinSegments, innerSegments); outerSegments = Mathf.Max(kMinSegments, outerSegments); surfaceDefinition.EnsureSize(8); }
public void Validate() { if (surfaceDefinition == null) { surfaceDefinition = new ChiselSurfaceDefinition(); } surfaceDefinition.EnsureSize(6); }
public void Validate() { if (surfaceDefinition == null) { surfaceDefinition = new ChiselSurfaceDefinition(); } if (surfaceDefinition.EnsureSize((int)SurfaceSides.TotalSides)) { var defaultRenderMaterial = ChiselMaterialManager.DefaultWallMaterial; var defaultPhysicsMaterial = ChiselMaterialManager.DefaultPhysicsMaterial; surfaceDefinition.surfaces[(int)SurfaceSides.Top].brushMaterial = ChiselBrushMaterial.CreateInstance(ChiselMaterialManager.DefaultFloorMaterial, defaultPhysicsMaterial); surfaceDefinition.surfaces[(int)SurfaceSides.Bottom].brushMaterial = ChiselBrushMaterial.CreateInstance(ChiselMaterialManager.DefaultFloorMaterial, defaultPhysicsMaterial); surfaceDefinition.surfaces[(int)SurfaceSides.Left].brushMaterial = ChiselBrushMaterial.CreateInstance(ChiselMaterialManager.DefaultWallMaterial, defaultPhysicsMaterial); surfaceDefinition.surfaces[(int)SurfaceSides.Right].brushMaterial = ChiselBrushMaterial.CreateInstance(ChiselMaterialManager.DefaultWallMaterial, defaultPhysicsMaterial); surfaceDefinition.surfaces[(int)SurfaceSides.Front].brushMaterial = ChiselBrushMaterial.CreateInstance(ChiselMaterialManager.DefaultWallMaterial, defaultPhysicsMaterial); surfaceDefinition.surfaces[(int)SurfaceSides.Back].brushMaterial = ChiselBrushMaterial.CreateInstance(ChiselMaterialManager.DefaultWallMaterial, defaultPhysicsMaterial); surfaceDefinition.surfaces[(int)SurfaceSides.Tread].brushMaterial = ChiselBrushMaterial.CreateInstance(ChiselMaterialManager.DefaultTreadMaterial, defaultPhysicsMaterial); surfaceDefinition.surfaces[(int)SurfaceSides.Step].brushMaterial = ChiselBrushMaterial.CreateInstance(ChiselMaterialManager.DefaultStepMaterial, defaultPhysicsMaterial); for (int i = 0; i < surfaceDefinition.surfaces.Length; i++) { if (surfaceDefinition.surfaces[i].brushMaterial == null) { surfaceDefinition.surfaces[i].brushMaterial = ChiselBrushMaterial.CreateInstance(defaultRenderMaterial, defaultPhysicsMaterial); } } } stepHeight = Mathf.Max(kMinStepHeight, stepHeight); stepDepth = Mathf.Clamp(stepDepth, kMinStepDepth, absDepth); treadHeight = Mathf.Max(0, treadHeight); nosingDepth = Mathf.Max(0, nosingDepth); nosingWidth = Mathf.Max(0, nosingWidth); width = Mathf.Max(kMinWidth, absWidth) * (width < 0 ? -1 : 1); depth = Mathf.Max(stepDepth, absDepth) * (depth < 0 ? -1 : 1); riserDepth = Mathf.Max(kMinRiserDepth, riserDepth); sideDepth = Mathf.Max(0, sideDepth); sideWidth = Mathf.Max(kMinSideWidth, sideWidth); sideHeight = Mathf.Max(0, sideHeight); var realHeight = Mathf.Max(stepHeight, absHeight); var maxPlateauHeight = realHeight - stepHeight; plateauHeight = Mathf.Clamp(plateauHeight, 0, maxPlateauHeight); var totalSteps = Mathf.Max(1, Mathf.FloorToInt((realHeight - plateauHeight + kStepSmudgeValue) / stepHeight)); var totalStepHeight = totalSteps * stepHeight; plateauHeight = Mathf.Max(0, realHeight - totalStepHeight); stepDepth = Mathf.Clamp(stepDepth, kMinStepDepth, absDepth / totalSteps); }
public void Validate() { if (!IsValid) { return; } if (version != kLatestVersion) { version = kLatestVersion; surfaceDefinition = null; } if (surfaceDefinition == null) { surfaceDefinition = new ChiselSurfaceDefinition(); surfaceDefinition.EnsureSize(brushOutline.polygons.Length); if (brushOutline.polygons.Length > 0) { for (int p = 0; p < brushOutline.polygons.Length; p++) { surfaceDefinition.surfaces[p].surfaceDescription = brushOutline.polygons[p].surface.surfaceDescription; surfaceDefinition.surfaces[p].brushMaterial = brushOutline.polygons[p].surface.brushMaterial; } } } else { surfaceDefinition.EnsureSize(brushOutline.polygons.Length); } // Temporary fix for misformed brushes for (int i = 0; i < brushOutline.polygons.Length; i++) { brushOutline.polygons[i].surfaceID = i; } brushOutline.CalculatePlanes(); // If the brush is concave, we set the generator to not be valid, so that when we commit, it will be reverted validState = brushOutline.HasVolume() && // TODO: implement this, so we know if a brush is a 0D/1D/2D shape !brushOutline.IsConcave() && // TODO: eventually allow concave shapes !brushOutline.IsSelfIntersecting(); // TODO: in which case this needs to be implemented // TODO: shouldn't do this all the time: { // Detect if outline is inside-out and if so, just invert all polygons. isInsideOut = brushOutline.IsInsideOut(); if (isInsideOut) { brushOutline.Invert(); isInsideOut = false; } } }
public void Validate() { if (surfaceDefinition == null) { surfaceDefinition = new ChiselSurfaceDefinition(); } curveSegments = Mathf.Max(curveSegments, 2); revolveSegments = Mathf.Max(revolveSegments, 1); totalAngle = Mathf.Clamp(totalAngle, 1, 360); // TODO: constants surfaceDefinition.EnsureSize(6); }
public void Validate() { if (surfaceDefinition == null) { surfaceDefinition = new ChiselSurfaceDefinition(); } if (shape == null) { shape = new Curve2D(kDefaultShape); } int sides = shape.controlPoints.Length; surfaceDefinition.EnsureSize(2 + sides); }
public void Validate() { if (surfaceDefinition == null) { surfaceDefinition = new ChiselSurfaceDefinition(); } diameterXYZ.x = Mathf.Max(kMinDiameter, Mathf.Abs(diameterXYZ.x)); diameterXYZ.y = Mathf.Max(0, Mathf.Abs(diameterXYZ.y)) * (diameterXYZ.y < 0 ? -1 : 1); diameterXYZ.z = Mathf.Max(kMinDiameter, Mathf.Abs(diameterXYZ.z)); horizontalSegments = Mathf.Max(horizontalSegments, 3); verticalSegments = Mathf.Max(verticalSegments, 1); surfaceDefinition.EnsureSize(6); }
public void Validate() { if (surfaceDefinition == null) { surfaceDefinition = new ChiselSurfaceDefinition(); } tubeWidth = Mathf.Max(tubeWidth, kMinTubeDiameter); tubeHeight = Mathf.Max(tubeHeight, kMinTubeDiameter); outerDiameter = Mathf.Max(outerDiameter, tubeWidth * 2); horizontalSegments = Mathf.Max(horizontalSegments, 3); verticalSegments = Mathf.Max(verticalSegments, 3); totalAngle = Mathf.Clamp(totalAngle, 1, 360); // TODO: constants surfaceDefinition.EnsureSize(6); }
public void Validate() { if (!IsValid) { return; } if (brushOutline.polygons == null) { return; } if (surfaceDefinition == null) { surfaceDefinition = new ChiselSurfaceDefinition(); } surfaceDefinition.EnsureSize(brushOutline.polygons.Length); }
public void Validate() { if (surfaceDefinition == null) { surfaceDefinition = new ChiselSurfaceDefinition(); } topHeight = Mathf.Max(topHeight, 0); bottomHeight = Mathf.Max(bottomHeight, 0); height = Mathf.Max(topHeight + bottomHeight, Mathf.Abs(height)) * (height < 0 ? -1 : 1); diameterX = Mathf.Max(Mathf.Abs(diameterX), kMinDiameter); diameterZ = Mathf.Max(Mathf.Abs(diameterZ), kMinDiameter); topSegments = Mathf.Max(topSegments, 0); bottomSegments = Mathf.Max(bottomSegments, 0); sides = Mathf.Max(sides, 3); surfaceDefinition.EnsureSize(2 + sides); }
public void Validate() { if (surfaceDefinition == null) { surfaceDefinition = new ChiselSurfaceDefinition(); } topLength = Mathf.Max(topLength, 0); bottomLength = Mathf.Max(bottomLength, 0); length = Mathf.Max(Mathf.Abs(length), (haveRoundedTop ? topLength : 0) + (haveRoundedBottom ? bottomLength : 0)); length = Mathf.Max(Mathf.Abs(length), kMinLength); height = Mathf.Max(Mathf.Abs(height), kMinHeight); diameter = Mathf.Max(Mathf.Abs(diameter), kMinDiameter); topSides = Mathf.Max(topSides, 1); bottomSides = Mathf.Max(bottomSides, 1); var sides = 2 + Mathf.Max(topSides, 1) + Mathf.Max(bottomSides, 1); surfaceDefinition.EnsureSize(2 + sides); }
public void Validate() { if (surfaceDefinition == null) { surfaceDefinition = new ChiselSurfaceDefinition(); } top.Validate(); bottom.Validate(); sides = Mathf.Max(3, sides); if (surfaceDefinition.EnsureSize(2 + sides)) { // Top plane surfaceDefinition.surfaces[0].surfaceDescription.UV0 = UVMatrix.centered; // Bottom plane surfaceDefinition.surfaces[1].surfaceDescription.UV0 = UVMatrix.centered; float radius = top.diameterX * 0.5f; float angle = (360.0f / sides); float sideLength = (2 * Mathf.Sin((angle / 2.0f) * Mathf.Deg2Rad)) * radius; // Side planes for (int i = 2; i < 2 + sides; i++) { var uv0 = UVMatrix.identity; uv0.U.w = ((i - 2) + 0.5f) * sideLength; // TODO: align with bottom //uv0.V.w = 0.5f; surfaceDefinition.surfaces[i].surfaceDescription.UV0 = uv0; surfaceDefinition.surfaces[i].surfaceDescription.smoothingGroup = smoothingGroup; } } }