use of ValkyrienWarfareBase.API.IBlockForceProvider in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class PhysicsCalculations method calculateForces.
public void calculateForces() {
double modifiedDrag = Math.pow(drag, physTickSpeed / .05D);
linearMomentum.multiply(modifiedDrag);
angularVelocity.multiply(modifiedDrag);
if (PhysicsSettings.doGravity) {
addForceAtPoint(new Vector(0, 0, 0), ValkyrienWarfareMod.gravity.getProduct(mass * physTickSpeed));
}
addQueuedForces();
Collections.shuffle(activeForcePositions);
Vector blockForce = new Vector();
Vector inBodyWO = new Vector();
Vector crossVector = new Vector();
if (PhysicsSettings.doPhysicsBlocks) {
for (BlockPos pos : activeForcePositions) {
IBlockState state = parent.VKChunkCache.getBlockState(pos);
Block blockAt = state.getBlock();
BigBastardMath.getBodyPosWithOrientation(pos, centerOfMass, parent.coordTransform.lToWRotation, inBodyWO);
BlockForce.basicForces.getForceFromState(state, pos, worldObj, physTickSpeed, parent, blockForce);
if (blockForce != null) {
if (blockAt instanceof IBlockForceProvider) {
Vector otherPosition = ((IBlockForceProvider) blockAt).getBlockForcePosition(worldObj, pos, state, parent.wrapper, physTickSpeed);
if (otherPosition != null) {
BigBastardMath.getBodyPosWithOrientation(otherPosition, centerOfMass, parent.coordTransform.lToWRotation, inBodyWO);
}
}
addForceAtPoint(inBodyWO, blockForce, crossVector);
} else {
}
}
}
if (PhysicsSettings.doBalloons) {
for (BalloonProcessor balloon : parent.balloonManager.balloonProcessors) {
balloon.tickBalloonTemperatures(physTickSpeed, this);
Vector balloonForce = balloon.getBalloonForce(physTickSpeed, this);
Vector balloonCenterInBody = balloon.getForceCenter();
BigBastardMath.getBodyPosWithOrientation(balloonCenterInBody, centerOfMass, parent.coordTransform.lToWRotation, inBodyWO);
addForceAtPoint(inBodyWO, balloonForce, crossVector);
}
}
convertTorqueToVelocity();
}
use of ValkyrienWarfareBase.API.IBlockForceProvider in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class BlockForce method getForceFromState.
public void getForceFromState(IBlockState state, BlockPos pos, World world, double secondsToApply, PhysicsObject obj, Vector toSet) {
Block block = state.getBlock();
if (block instanceof IBlockForceProvider) {
Vector forceVector = ((IBlockForceProvider) block).getBlockForce(world, pos, state, obj.wrapper, secondsToApply);
if (forceVector == null) {
toSet.zero();
return;
}
boolean isInLocal = ((IBlockForceProvider) block).isForceLocalCoords(world, pos, state, secondsToApply);
if (isInLocal) {
RotationMatrices.applyTransform(obj.coordTransform.lToWRotation, forceVector);
}
toSet.X = forceVector.X;
toSet.Y = forceVector.Y;
toSet.Z = forceVector.Z;
return;
}
Force force = basicForces.blocksToForces.get(block);
if (force != null) {
toSet.X = force.X * secondsToApply;
toSet.Y = force.Y * secondsToApply;
toSet.Z = force.Z * secondsToApply;
} else {
toSet.zero();
}
}
use of ValkyrienWarfareBase.API.IBlockForceProvider in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class BlockForce method getForceFromState.
public Vector getForceFromState(IBlockState state, BlockPos pos, World world, double secondsToApply, PhysicsObject obj) {
Block block = state.getBlock();
if (block instanceof IBlockForceProvider) {
Vector forceVector = ((IBlockForceProvider) block).getBlockForce(world, pos, state, obj.wrapper, secondsToApply);
if (forceVector == null) {
return null;
}
boolean isInLocal = ((IBlockForceProvider) block).isForceLocalCoords(world, pos, state, secondsToApply);
if (isInLocal) {
RotationMatrices.applyTransform(obj.coordTransform.lToWRotation, forceVector);
}
return forceVector;
}
Force force = basicForces.blocksToForces.get(block);
if (force != null) {
return force.getProduct(secondsToApply);
} else {
return null;
}
}
Aggregations