public Status AddBoxObstacle(Vector3 center, Vector3 halfExtents, float yRadians, out int result) { result = 0; if (m_nreqs >= DetourTileCache.MAX_REQUESTS) { return(Status.DT_FAILURE | Status.DT_BUFFER_TOO_SMALL); } int ob = -1; if (m_nextFreeObstacle >= 0) { ob = m_nextFreeObstacle; m_nextFreeObstacle = m_obstacles[ob].Next; m_obstacles[ob].Next = -1; } if (ob == -1) { return(Status.DT_FAILURE); } float coshalf = (float)Math.Cos(0.5f * yRadians); float sinhalf = (float)Math.Sin(-0.5f * yRadians); var rotAux = new Vector2(coshalf * sinhalf, coshalf * coshalf - 0.5f); int salt = m_obstacles[ob].Salt; m_obstacles[ob] = new TileCacheObstacle { Salt = salt, State = ObstacleState.DT_OBSTACLE_PROCESSING, Type = ObstacleType.DT_OBSTACLE_ORIENTED_BOX, OrientedBox = new ObstacleOrientedBox { Center = center, HalfExtents = halfExtents, RotAux = rotAux, } }; var req = new ObstacleRequest { Action = ObstacleRequestAction.REQUEST_ADD, NRef = GetObstacleRef(m_obstacles[ob]) }; m_reqs[m_nreqs++] = req; result = req.NRef; return(Status.DT_SUCCESS); }
public Status AddObstacle(Vector3 pos, float radius, float height, out int result) { result = 0; if (m_nreqs >= DetourTileCache.MAX_REQUESTS) { return(Status.DT_FAILURE | Status.DT_BUFFER_TOO_SMALL); } int ob = -1; if (m_nextFreeObstacle >= 0) { ob = m_nextFreeObstacle; m_nextFreeObstacle = m_obstacles[ob].Next; m_obstacles[ob].Next = -1; } if (ob == -1) { return(Status.DT_FAILURE); } int salt = m_obstacles[ob].Salt; m_obstacles[ob] = new TileCacheObstacle { Salt = salt, State = ObstacleState.DT_OBSTACLE_PROCESSING, Type = ObstacleType.DT_OBSTACLE_CYLINDER, Cylinder = new ObstacleCylinder { Pos = pos, Radius = radius, Height = height } }; var req = new ObstacleRequest { Action = ObstacleRequestAction.REQUEST_ADD, NRef = GetObstacleRef(m_obstacles[ob]), }; m_reqs[m_nreqs++] = req; result = req.NRef; return(Status.DT_SUCCESS); }
public Status AddBoxObstacle(Vector3 bmin, Vector3 bmax, out int result) { result = 0; if (m_nreqs >= DetourTileCache.MAX_REQUESTS) { return(Status.DT_FAILURE | Status.DT_BUFFER_TOO_SMALL); } int ob = -1; if (m_nextFreeObstacle >= 0) { ob = m_nextFreeObstacle; m_nextFreeObstacle = m_obstacles[ob].Next; m_obstacles[ob].Next = -1; } if (ob == -1) { return(Status.DT_FAILURE); } int salt = m_obstacles[ob].Salt; m_obstacles[ob] = new TileCacheObstacle { Salt = salt, State = ObstacleState.DT_OBSTACLE_PROCESSING, Type = ObstacleType.DT_OBSTACLE_BOX, Box = new ObstacleBox { BMin = bmin, BMax = bmax } }; var req = new ObstacleRequest { Action = ObstacleRequestAction.REQUEST_ADD, NRef = GetObstacleRef(m_obstacles[ob]) }; m_reqs[m_nreqs++] = req; result = req.NRef; return(Status.DT_SUCCESS); }
public Status RemoveObstacle(int r) { if (r == 0) { return(Status.DT_SUCCESS); } if (m_nreqs >= DetourTileCache.MAX_REQUESTS) { return(Status.DT_FAILURE | Status.DT_BUFFER_TOO_SMALL); } var req = new ObstacleRequest { Action = ObstacleRequestAction.REQUEST_REMOVE, NRef = r }; m_reqs[m_nreqs++] = req; return(Status.DT_SUCCESS); }