Class ScyllaRoundedBoxShape
Parametric box with uniformly rounded edges and corners. Each of the cube's twelve edges is replaced by a quarter-cylinder of CornerRadius, and each of the eight corners by an eighth-sphere. The flat face panels are inset by CornerRadius so they meet the curved seams cleanly.
Inherited Members
Namespace: Scylla.Core.Util.Geom
Assembly: ScyllaCore.dll
Syntax
[AddComponentMenu("Scylla/Geometry/Rounded Box")]
public sealed class ScyllaRoundedBoxShape : ScyllaShapeBase3D
Remarks
Distinct from ScyllaBoxShape: a Scylla box has hard 90° edges with six independent face quads; a rounded box has continuous curvature at every edge and corner, suitable for blockout / prototype geometry where a soft beveled silhouette is desired (wall tiles, crates, props, UI panels in 3D).
The mesh emits 26 surface groups (6 face panels + 12 edge strips + 8 corner patches).
Vertices at the seams between groups are duplicated, but the analytic normal at each
vertex is the surface normal at that point, so the lit shading is continuous across
seams without artifacts. CornerRadius is clamped to half the smallest
box dimension; CornerSegments is clamped to [1, 32].
For per-face coloring, ColoringMode selects between FrameAndPanels (default, 2 resolver indices: framing = edges + corners, panels = the 6 flat faces) and PerSurfaceGroup (26 resolver indices, one per surface group).
Properties
ColoringMode
Selects the per-face color granularity used when a IFaceColorResolver is active. FrameAndPanels (the default) emits 2 resolver indices for the entire shape; PerSurfaceGroup emits 26. Geometry is identical in all modes; only the per-vertex color assignment changes. Setting this property triggers an immediate mesh rebuild.
Declaration
public RoundedBoxColoringMode ColoringMode { get; set; }
Property Value
| Type | Description |
|---|---|
| RoundedBoxColoringMode |
CornerRadius
Radius of the rounded edges and corners in mesh units. Clamped to half the smallest
box dimension at build time so the flat face panels never collapse. Set to 0
to produce a sharp-edged box (functionally equivalent to ScyllaBoxShape
but with slightly more geometry). Setting this property triggers an immediate mesh rebuild.
Declaration
public float CornerRadius { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
CornerSegments
Number of subdivisions per quarter-arc on each rounded edge strip and corner sphere
patch. Higher values produce smoother curvature at the cost of extra geometry. Clamped
to [1, 32] when set and at build time. Setting this property triggers an immediate mesh rebuild.
Declaration
public int CornerSegments { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Depth
Box size along the Z axis in mesh units. Shorthand for Size.Depth.
Values below 0.0001 are clamped when set and at build time.
Setting this triggers an immediate mesh rebuild.
Declaration
public float Depth { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Height
Box size along the Y axis in mesh units. Shorthand for Size.Height.
Values below 0.0001 are clamped when set and at build time.
Setting this triggers an immediate mesh rebuild.
Declaration
public float Height { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Size
Outer box dimensions as a Size3D. Components below 0.0001 are
clamped when set and at build time. Setting any axis changes the overall shape and
triggers an immediate mesh rebuild. The Width,
Height, and Depth accessors are shorthand for the
individual Size3D components.
Declaration
public Size3D Size { get; set; }
Property Value
| Type | Description |
|---|---|
| Size3D |
Width
Box size along the X axis in mesh units. Shorthand for Size.Width.
Values below 0.0001 are clamped when set and at build time.
Setting this triggers an immediate mesh rebuild.
Declaration
public float Width { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
Methods
Build(Mesh, Size3D, float, int, RoundedBoxColoringMode, IFaceColorResolver)
Populates target with a parametric rounded box mesh. Existing
mesh data is overwritten. cornerRadius is clamped to half the
smallest dimension; cornerSegments is clamped to [1, 32].
Declaration
public static void Build(Mesh target, Size3D size, float cornerRadius, int cornerSegments, RoundedBoxColoringMode coloringMode = RoundedBoxColoringMode.FrameAndPanels, IFaceColorResolver resolver = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Mesh | target | Destination mesh. Must be non-null. |
| Size3D | size | Outer box dimensions on each axis. Each component is clamped to a minimum of |
| float | cornerRadius | Edge / corner rounding radius. |
| int | cornerSegments | Subdivisions per quarter-arc. |
| RoundedBoxColoringMode | coloringMode | Selects how the resolver indices are assigned. FrameAndPanels
(the default) uses two indices total - |
| IFaceColorResolver | resolver | Optional per-face color resolver. When non-null, a per-vertex color channel is emitted with one solid color per logical face. When null, no color channel is written. |
BuildMesh(Mesh)
Subclass extension point: write vertex / triangle / normal / uv data into
target from the shape's serialized parameters. The base class
calls Clear(bool) before invoking this method and
UnityEngine.Mesh.RecalculateBounds() afterwards, so subclasses should not invoke
either themselves.
Declaration
protected override void BuildMesh(Mesh target)
Parameters
| Type | Name | Description |
|---|---|---|
| Mesh | target | The owned mesh to populate. Already cleared by the base class. |
Overrides
GetMeshName()
Returns the shape's mesh name as it should appear on the generated mesh asset. Defaults to the subclass type name; override to provide a friendlier label.
Declaration
protected override string GetMeshName()
Returns
| Type | Description |
|---|---|
| string | A short identifier for the generated mesh, used as UnityEngine.Object.name. |
Overrides
TryAttachPrimitiveCollider()
Subclass extension point: when ColliderMode is
MatchingPrimitive, obtain the appropriate primitive
collider through GetOrAddManagedCollider<T>(), size it to the current
parameters, and return true. Return false to let the base class fall
back to UnityEngine.MeshCollider.
Declaration
protected override bool TryAttachPrimitiveCollider()
Returns
| Type | Description |
|---|---|
| bool |
|
Overrides
Remarks
Runs on every rebuild. Always go through GetOrAddManagedCollider<T>()
rather than AddComponent: it reuses the collider from the previous rebuild,
so the override only has to update its size and center. A collider added directly
is not tracked by the shape and a new one would be added on every rebuild.