So so close to getting my visibility polygon working. I'm using an SFML triangle fan with all the vertex points sorted by angle size with position 0 set to the mouse coords and the last element set to element 2, I needed to do this to fill in the gap for the last triangle.
However; a triangle appears to be missing at certain locations, see video.
I suspect that I'm having an out by one issue with my loop. I've tried rearranging a few numbers but this is the closest I can get.
https://streamable.com/d46yihsf::VertexArray visibilityPolygon(sf::TriangleFan, vectorAngleContainer.size() + 1);
visibilityPolygon[0] = ray[0].position;
for (int i = 1; i <= vectorAngleContainer.size(); i++)
{
visibilityPolygon[i] = sf::Vertex(sf::Vector2f(vectorAngleContainer[i-1].position.x, vectorAngleContainer[i-1].position.y), sf::Color::Red);
}
visibilityPolygon[vectorAngleContainer.size()] = visibilityPolygon[1].position;
vectorAngleContainer() is a vector of structs that holds a point and and angle.