mirror of
https://github.com/celisej567/metaballs.git
synced 2026-09-09 20:22:58 +03:00
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.
43 lines
1.1 KiB
C#
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;
|
|
}
|
|
}
|
|
}
|