More work on MechanicalGrid

This commit is contained in:
Calclavia 2014-11-19 15:20:50 +08:00
parent 3f03890d4e
commit c668057295
2 changed files with 4 additions and 3 deletions

View file

@ -57,7 +57,7 @@ class MechanicalGrid extends GridNode[NodeMechanical](classOf[NodeMechanical]) w
}
)
getNodes.foreach(n => recurse(Seq(n)))
getNodes.filter(n => n.bufferTorque != 0 && n.bufferAngularVelocity != 0).foreach(n => recurse(Seq(n)))
/*
//Find all nodes that are currently producing energy
@ -105,8 +105,8 @@ class MechanicalGrid extends GridNode[NodeMechanical](classOf[NodeMechanical]) w
val prev = passed(passed.size - 2)
val ratio = curr.radius / prev.radius
val invert = if (curr.inverseRotation(prev)) 1 else -1
curr._torque += prev.torque * ratio * invert
curr._angularVelocity += prev.angularVelocity / ratio * invert
curr._torque += passed(0).torque * ratio * invert
curr._angularVelocity += passed(0).angularVelocity / ratio * invert
}
else
{

View file

@ -76,6 +76,7 @@ class NodeMechanical(parent: INodeProvider) extends NodeGrid[NodeMechanical](par
override def rotate(torque: Double)
{
bufferTorque += torque
bufferAngularVelocity += torque
}
def power: Double = torque * angularVelocity