package speiger.src.coreengine.math.smooth;

import speiger.src.coreengine.math.vector.floats.Vec3f;

public class SmoothVec3f
{
	Vec3f value = Vec3f.mutable();
	Vec3f target = Vec3f.mutable();
	Vec3f helper = Vec3f.mutable();
	float agility = 0F;
	
	public SmoothVec3f(float agility) {
		this.agility = agility;
	}
	
	public SmoothVec3f(Vec3f vec, float agility) {
		value.set(vec);
		target.set(vec);
		this.agility = agility;
	}
	
	public boolean isDone() { return isDone(0.0005F); }
	public boolean isDone(float limit) { return target.distanceToSquared(value) <= limit; }
	public void update(float delta) { value.add(target.difference(value, helper).multiply(agility * delta)); }
	
	public void setTarget(Vec3f value) { target.set(value); }
	public void setTarget(float x, float y, float z) { target.set(x, y, z); }
	
	public void addTarget(Vec3f value) { target.add(value); }
	public void addTarget(float x, float y, float z) { target.add(x, y, z); }
	
	public Vec3f getTarget() { return target.copy(); }
	public Vec3f getValue() { return value.copy();}
	
	public void forceFinish() { value.set(target); }
}
