/// <summary>Initializes the struct with default values.</summary>
        public static ParticleSphereShapeOptions Default()
        {
            ParticleSphereShapeOptions value = new ParticleSphereShapeOptions();

            value.radius    = 0f;
            value.thickness = 0f;

            return(value);
        }
        private static void Draw(ParticleSystem component)
        {
            SceneObject so = component.SceneObject;

            // Draw collision planes, if enabled
            Gizmos.Color = Color.Yellow;
            ParticleEvolver[] evolvers = component.Evolvers;
            foreach (var entry in evolvers)
            {
                if (entry is ParticleCollisions collisions)
                {
                    if (collisions.Options.mode == ParticleCollisionMode.Plane)
                    {
                        void DrawPlane(Vector3 position, Vector3 right, Vector3 up, Vector3 forward)
                        {
                            Vector3 topLeft  = position - right + up;
                            Vector3 topRight = position + right + up;
                            Vector3 botLeft  = position - right - up;
                            Vector3 botRight = position + right - up;

                            Gizmos.DrawLine(topLeft, topRight);
                            Gizmos.DrawLine(topRight, botRight);
                            Gizmos.DrawLine(botRight, botLeft);
                            Gizmos.DrawLine(botLeft, topLeft);

                            Gizmos.DrawLine(position, position + forward * 0.4f);
                        }

                        SceneObject[] planeObjects = collisions.PlaneObjects;
                        foreach (var planeSO in planeObjects)
                        {
                            Vector3 position = planeSO.Position;
                            Vector3 right    = planeSO.Rotation.Rotate(Vector3.XAxis);
                            Vector3 up       = planeSO.Rotation.Rotate(Vector3.YAxis);
                            Vector3 forward  = planeSO.Forward;

                            DrawPlane(position, right, up, forward);
                        }

                        Plane[] planes = collisions.Planes;
                        foreach (var plane in planes)
                        {
                            Vector3 right, up;
                            Vector3.OrthogonalComplement(plane.normal, out right, out up);

                            DrawPlane(plane.normal * plane.d, right, up, plane.normal);
                        }
                    }
                }
            }

            // Draw emitter shapes
            Gizmos.Transform = Matrix4.TRS(so.Position, Quaternion.LookRotation(so.Rotation.Forward, so.Rotation.Up), Vector3.One);
            Gizmos.Color     = Color.Green;

            ParticleEmitter[] emitters = component.Emitters;
            foreach (var entry in emitters)
            {
                ParticleEmitterShape shape = entry?.Shape;
                if (shape == null)
                {
                    continue;
                }

                if (shape is ParticleEmitterBoxShape boxShape)
                {
                    Gizmos.DrawWireCube(Vector3.Zero, boxShape.Options.extents);
                }
                else if (shape is ParticleEmitterSphereShape sphereShape)
                {
                    ParticleSphereShapeOptions options = sphereShape.Options;
                    Gizmos.DrawWireSphere(Vector3.Zero, options.radius);

                    if (options.thickness > 0.0f)
                    {
                        float innerRadius = options.radius * (1.0f - MathEx.Clamp01(options.thickness));
                        if (options.thickness < 1.0f)
                        {
                            Gizmos.Color = Color.Green * new Color(0.5f, 0.5f, 0.5f);
                            Gizmos.DrawWireSphere(Vector3.Zero, innerRadius);
                        }

                        Gizmos.Color = Color.Green * new Color(0.25f, 0.25f, 0.25f);
                        Gizmos.DrawLine(Vector3.XAxis * innerRadius, Vector3.XAxis * options.radius);
                        Gizmos.DrawLine(-Vector3.XAxis * innerRadius, -Vector3.XAxis * options.radius);
                        Gizmos.DrawLine(Vector3.YAxis * innerRadius, Vector3.YAxis * options.radius);
                        Gizmos.DrawLine(-Vector3.YAxis * innerRadius, -Vector3.YAxis * options.radius);
                        Gizmos.DrawLine(Vector3.ZAxis * innerRadius, Vector3.ZAxis * options.radius);
                        Gizmos.DrawLine(-Vector3.ZAxis * innerRadius, -Vector3.ZAxis * options.radius);
                    }
                }
                else if (shape is ParticleEmitterHemisphereShape hemisphereShape)
                {
                    ParticleHemisphereShapeOptions options = hemisphereShape.Options;
                    Gizmos.DrawWireHemisphere(Vector3.Zero, options.radius);
                    DrawArcWithThickness(Vector3.Zero, options.radius, new Degree(360.0f), options.thickness, Color.Green);

                    if (options.thickness > 0.0f)
                    {
                        float innerRadius = options.radius * (1.0f - MathEx.Clamp01(options.thickness));
                        if (options.thickness < 1.0f)
                        {
                            Gizmos.Color = Color.Green * new Color(0.5f, 0.5f, 0.5f);
                            Gizmos.DrawWireHemisphere(Vector3.Zero, innerRadius);
                        }

                        Gizmos.Color = Color.Green * new Color(0.25f, 0.25f, 0.25f);
                        Gizmos.DrawLine(Vector3.XAxis * innerRadius, Vector3.XAxis * options.radius);
                        Gizmos.DrawLine(-Vector3.XAxis * innerRadius, -Vector3.XAxis * options.radius);
                        Gizmos.DrawLine(Vector3.YAxis * innerRadius, Vector3.YAxis * options.radius);
                        Gizmos.DrawLine(-Vector3.YAxis * innerRadius, -Vector3.YAxis * options.radius);
                        Gizmos.DrawLine(Vector3.ZAxis * innerRadius, Vector3.ZAxis * options.radius);
                    }
                }
                else if (shape is ParticleEmitterCircleShape circleShape)
                {
                    ParticleCircleShapeOptions options = circleShape.Options;
                    DrawArcWithThickness(Vector3.Zero, options.radius, options.arc, options.thickness, Color.Green);
                }
                else if (shape is ParticleEmitterLineShape lineShape)
                {
                    float halfLength = lineShape.Options.length * 0.5f;
                    Gizmos.DrawLine(new Vector3(-halfLength, 0.0f, 0.0f), new Vector3(halfLength, 0.0f, 0.0f));
                }
                else if (shape is ParticleEmitterRectShape rectShape)
                {
                    Vector2 extents = rectShape.Options.extents;
                    Vector3 right   = new Vector3(extents.x, 0.0f, 0.0f);
                    Vector3 up      = new Vector3(0.0f, extents.y, 0.0f);

                    Vector3 topLeft  = -right + up;
                    Vector3 topRight = right + up;
                    Vector3 botLeft  = -right - up;
                    Vector3 botRight = right - up;

                    Gizmos.DrawLine(topLeft, topRight);
                    Gizmos.DrawLine(topRight, botRight);
                    Gizmos.DrawLine(botRight, botLeft);
                    Gizmos.DrawLine(botLeft, topLeft);
                }
                else if (shape is ParticleEmitterConeShape coneShape)
                {
                    ParticleConeShapeOptions options = coneShape.Options;

                    float  topRadius  = options.radius;
                    float  baseRadius = options.length * MathEx.Tan(options.angle);
                    Radian arc        = options.arc;

                    if (topRadius > 0.0f)
                    {
                        DrawArcWithThickness(Vector3.Zero, topRadius, arc, options.thickness, Color.Green);
                    }

                    DrawArcWithThickness(new Vector3(0.0f, 0.0f, -options.length), baseRadius, arc, options.thickness,
                                         Color.Green);

                    Gizmos.Color = Color.Green;
                    DrawConeBorder(topRadius, baseRadius, arc, options.length);

                    if (options.thickness > 0.0f && options.thickness < 1.0f)
                    {
                        Gizmos.Color = Color.Green * new Color(0.5f, 0.5f, 0.5f);
                        DrawConeBorder(
                            topRadius * (1.0f - MathEx.Clamp01(options.thickness)),
                            baseRadius * (1.0f - MathEx.Clamp01(options.thickness)), arc, options.length);
                    }
                }
                else if (shape is ParticleEmitterStaticMeshShape staticMeshShape)
                {
                    RRef <Mesh> mesh = staticMeshShape.Options.mesh;
                    if (mesh.IsLoaded)
                    {
                        Gizmos.DrawWireMesh(mesh.Value.MeshData);
                    }
                }
                else if (shape is ParticleEmitterSkinnedMeshShape skinnedMeshShape)
                {
                    Renderable renderable = skinnedMeshShape.Options.renderable;
                    if (renderable != null)
                    {
                        RRef <Mesh> mesh = renderable.Mesh;
                        if (mesh.IsLoaded)
                        {
                            Gizmos.DrawWireMesh(mesh.Value.MeshData);
                        }
                    }
                }
            }

            // Draw manual bounds
            if (!component.Settings.UseAutomaticBounds)
            {
                Gizmos.Color = Color.LightGray;

                AABox bounds = component.Settings.CustomBounds;
                Gizmos.DrawWireCube(bounds.Center, bounds.Size * 0.5f);
            }
        }
 private static extern void Internal_create(ParticleEmitterSphereShape managedInstance, ref ParticleSphereShapeOptions desc);
 private static extern void Internal_getOptions(IntPtr thisPtr, out ParticleSphereShapeOptions __output);
 private static extern void Internal_setOptions(IntPtr thisPtr, ref ParticleSphereShapeOptions options);
 /// <summary>Creates a new particle emitter sphere shape.</summary>
 public ParticleEmitterSphereShape(ParticleSphereShapeOptions desc)
 {
     Internal_create(this, ref desc);
 }