// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.server.core.modules.physics.util;

import javax.annotation.Nonnull;
import com.hypixel.hytale.math.vector.Vector3d;

public class ForceProviderStandardState
{
    public double displacedMass;
    public double dragCoefficient;
    public double gravity;
    public final Vector3d nextTickVelocity;
    public final Vector3d externalVelocity;
    public final Vector3d externalAcceleration;
    public final Vector3d externalForce;
    public final Vector3d externalImpulse;
    
    public ForceProviderStandardState() {
        this.nextTickVelocity = new Vector3d();
        this.externalVelocity = new Vector3d();
        this.externalAcceleration = new Vector3d();
        this.externalForce = new Vector3d();
        this.externalImpulse = new Vector3d();
        this.nextTickVelocity.assign(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE);
    }
    
    public void convertToForces(final double dt, final double mass) {
        this.externalForce.addScaled(this.externalAcceleration, 1.0 / mass);
        this.externalForce.addScaled(this.externalImpulse, 1.0 / dt);
        this.externalAcceleration.assign(Vector3d.ZERO);
        this.externalImpulse.assign(Vector3d.ZERO);
    }
    
    public void updateVelocity(@Nonnull final Vector3d velocity) {
        if (this.nextTickVelocity.x < Double.MAX_VALUE) {
            velocity.assign(this.nextTickVelocity);
            this.nextTickVelocity.assign(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE);
        }
        velocity.add(this.externalVelocity);
        this.externalVelocity.assign(Vector3d.ZERO);
    }
    
    public void clear() {
        this.externalForce.assign(Vector3d.ZERO);
    }
}
