|
|
|
|
|
|
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); |
|
|
|
} |
|
|
|
|
|
|
|