I was just thinking about this the other day actually. My thoughts went something like this:
- Make sure you have plenty of nodes. (if the game is tile based, you should be covered)
- Each frame (or every several frames) find the nodes within a certain distance of the player and raycast to them. If the raycast hits them mark the node with the current timestamp. If you have multiple points you want to hide from, you can have a counter that increments for each raycast.
- When searching for a path, multiply the edge weight by a certain factor if the destination node is marked with the current timestamp. (increase the factor based on the counter if you are using one)
By marking nodes with a timestamp, you only need to worry about marking the nodes the raycasts could actually hit. You don't need to clear and raycast every node again. It also allows you to use a spatial index of some sort easily if you have one ready. (presumably you do if you are raycasting or have other collisions.)
If raycasts are really expensive in your engine, you could add a cone of vision and simply reject nodes that are not in the cone using a simple dot product. This would probably work Ok in a 3D game where the player has a limited cone of vision, but not so much in a 2D game or a 3rd person game.