Files
metaballs/Assets/metaball/Scripts/MetaBall.cs
celisej567 76e4be1dc1 A lot of diffrerent things
Now containers will have different meshes.
Added Bouncing Ball in context menu.
Added Metaballs namespace.
Added QuakeFastSqrt function instead default sqrt in .compute shader.

Fixed some bugs.

Bug: actuall you can't use more then one Conteiner, because for some reason only one work at one time. It will show, but not updates.
2023-03-23 19:18:07 +03:00

43 lines
1.1 KiB
C#

using UnityEngine;
using System.Collections;
namespace MetaBalls
{
[ExecuteInEditMode]
public class MetaBall : MonoBehaviour
{
public float radius = 0.09f;
public bool negativeBall;
[HideInInspector]
public float factor = 1;
Vector3 voidSize;
public bool DrawGizmos;
public virtual void OnDrawGizmos()
{
if (!DrawGizmos)
return;
if (voidSize != GetComponentInParent<Container>().transform.localScale)
{
voidSize = GetComponentInParent<Container>().transform.localScale;
}
Gizmos.color = Color.green;
Gizmos.DrawWireSphere(transform.position, radius * Mathf.Min(voidSize.x, voidSize.y, voidSize.z));
}
public virtual void Start()
{
this.factor = (this.negativeBall ? -1 : 1) * this.radius * this.radius;
}
public virtual void Update()
{
this.factor = (this.negativeBall ? -1 : 1) * this.radius * this.radius;
}
}
}