public void GenerateMatrix()
{
size = unclampedSize;
size.x *= Mathf.Sign (size.x);
//size.y *= Mathf.Sign (size.y);
size.y *= Mathf.Sign (size.y);
//Clamp the nodeSize at 0.1
nodeSize = Mathf.Clamp (nodeSize,size.x/1024F,Mathf.Infinity);//nodeSize < 0.1F ? 0.1F : nodeSize;
nodeSize = Mathf.Clamp (nodeSize,size.y/1024F,Mathf.Infinity);
size.x = size.x < nodeSize ? nodeSize : size.x;
//size.y = size.y < 0.1F ? 0.1F : size.y;
size.y = size.y < nodeSize ? nodeSize : size.y;
boundsMatrix.SetTRS (center,Quaternion.Euler (rotation),new Vector3 (aspectRatio,1,1));
//bounds.center = boundsMatrix.MultiplyPoint (Vector3.up*height*0.5F);
//bounds.size = new Vector3 (width*nodeSize,height,depth*nodeSize);
width = Mathf.FloorToInt (size.x / nodeSize);
depth = Mathf.FloorToInt (size.y / nodeSize);
if (Mathf.Approximately (size.x / nodeSize,Mathf.CeilToInt (size.x / nodeSize))) {
width = Mathf.CeilToInt (size.x / nodeSize);
}
if (Mathf.Approximately (size.y / nodeSize,Mathf.CeilToInt (size.y / nodeSize))) {
depth = Mathf.CeilToInt (size.y / nodeSize);
}
//height = size.y;
matrix.SetTRS (boundsMatrix.MultiplyPoint3x4 (-new Vector3 (size.x,0,size.y)*0.5F),Quaternion.Euler(rotation), new Vector3 (nodeSize*aspectRatio,1,nodeSize));
}