Basically, if I know $x$, $\theta_1$, and $\theta_2$ in the image below, it is possible to determine $h_1$ and $d$, or do I also need to know $h_2$ first?
If the horizon is visible, then the calculation is easy:
We can write $\tan \theta_1 = \frac{h}{d}$ and $\tan \theta_2 = \frac{h}{d+x}$ from which we can conclude $d = \frac{x}{\frac{\tan \theta_1}{\tan \theta_2}-1}$ and $h = \frac{x\cdot \tan \theta_1 \tan \theta_2}{\tan \theta_1 - \tan \theta_2}$. But I'm stumped by the top case.


In the "obstructed" case, we can construct an alternative figure with values of $\theta_1$, $\theta_2$, and $x$ the same as in your first figure, but different values of $h_1$ and $h_2.$ (Just move the "obstruction" point up and to the left so that the two sides of angle $\theta_1$ are unchanged, but the lower side of angle $\theta_2$ is rotated upward; then the upper side of angle $\theta_2$ also is rotated upward, resulting in an intersection point that is higher.)
So you cannot determine $h_1$ from just $\theta_1$, $\theta_2$, and $x$.
But if you have a line of sight between the two viewpoints, don't measure the angles subtended by the tops of the segments $h_1$ and $h_2,$ measure the angle subtended by the top of $h_1$ and the other viewpoint. Then you have one side and two adjacent angles of a triangle and you can determine all three sides of the triangle, and you can then use trigonometry to compute $h_1$ from the known angles and distances.