浏览代码

fix bug calculating grid local position

/develop/grid-vaiable-names
Ruo-Ping Dong 3 年前
当前提交
6ef766aa
共有 1 个文件被更改,包括 2 次插入4 次删除
  1. 6
      com.unity.ml-agents.extensions/Runtime/Sensors/GridSensor.cs

6
com.unity.ml-agents.extensions/Runtime/Sensors/GridSensor.cs


int m_NumCells;
int m_CellObservationSize;
float m_InverseSphereRadius;
float m_OffsetGridNumSide;
public GridSensor(

float sphereRadiusX = (m_CellScale.x * m_GridNum.x) / Mathf.Sqrt(2);
float sphereRadiusZ = (m_CellScale.z * m_GridNum.z) / Mathf.Sqrt(2);
m_InverseSphereRadius = 1.0f / Mathf.Max(sphereRadiusX, sphereRadiusZ);
m_OffsetGridNumSide = (m_GridNum.z - 1f) / 2f;
}
/// <summary>

/// <param name="cell">The index of the cell</param>
Vector3 CellToLocalPoint(int cellIndex)
{
float x = (cellIndex % m_GridNum.z - m_OffsetGridNumSide) * m_CellScale.x;
float z = (cellIndex / m_GridNum.z - m_OffsetGridNumSide) * m_CellScale.z - (m_GridNum.z - m_GridNum.x);
float x = (cellIndex / m_GridNum.z - m_GridNum.x / 2) * m_CellScale.x;
float z = (cellIndex % m_GridNum.z - m_GridNum.z / 2) * m_CellScale.z;
return new Vector3(x, 0, z);
}

正在加载...
取消
保存