@Override
public void update(){
Vec2 shapePos;
Vec2 pAToShape;
Vec2 pBToShape;
Physical dc;
for(int i=creationsInField.size()-1;i>=0;i--){
dc=creationsInField.get(i);
if(dc.isDestroyed()){
creationsInField.remove(i);
}else{
shapePos=dc.getBody().getWorldCenter();
pAToShape=shapePos.sub(vecA);
pBToShape=shapePos.sub(vecB);
if(Vec2.dot(pAToShape, vecAToB)<0){
if(pAToShape.lengthSquared()>ASBOTXConfigs.E_SQUARE){
pAToShape.negateLocal();
pAToShape.normalize();
pAToShape.mulLocal(FORCE_MAGNITUDE);
dc.getBody().applyForce(pAToShape,shapePos);
}
}else if(Vec2.dot(pBToShape, vecBToA)<0){
if(pBToShape.lengthSquared()>ASBOTXConfigs.E_SQUARE){
pBToShape.negateLocal();
pBToShape.normalize();
pBToShape.mulLocal(FORCE_MAGNITUDE);
dc.getBody().applyForce(pBToShape,shapePos);
}
}else{
dc.getBody().applyForce(Vec2.cross(pAToShape,vecAToB)>0?forces[0]:forces[1],shapePos);
}
}
}
}