Scattering from homogeneous objects The form factor in x-ray scattering is defined by
$$P(\mathbf{q})=\left [  \frac{1}{V_{p}} \int_{V_{p}} dV \exp(-i\mathbf{q}\cdot\mathbf{r})\right ]^{2}$$
For a sphere, this becomes
$$P(q)=\left [  \frac{3}{(qR)^{3}}(\sin(qR)-qR\cos(qR))\right ]^{2}$$
But since this is just the Fourier transform of the density distribution, how does it depend on q (or r, in real space) inside a homogeneous object where the density (I think by definition) should be constant?
 A: 
The form factor in x-ray scattering is defined by
$$P(\mathbf{q})=\left [  \frac{1}{V_{p}} \int_{V_{p}} dV \exp(-i\mathbf{q}\cdot\mathbf{r})\right ]^{2}$$


For a sphere, this becomes
$$P(q)=\left [  \frac{3}{(qR)^{3}}(\sin(qR)-qR\cos(qR))\right ]^{2}$$


But since this is just the Fourier transform of the density distribution, how does it depend on q (or r, in real space)...

It depends on $q$ because, by definition, you have explicit dependence on $\vec q$. The angular dependence drops out since the scattering object is spherically symmetric.

...inside a homogeneous object where the density (I think by definition) should be constant?

It doesn't matter that the density of the scattering sphere is constant. The distribution of the scattered probe particles still depends on the size and shape of the scatterer (the sphere). The space traversed by the scattered probe particles is inhomogeneous because it is vacuum most places, but not vacuum where the sphere is.
In other words, what you are literally calculating is proportional to the Fourier transform of the density in all space:
$$
P(\vec q) = \frac{1}{\int dV \rho(\vec r)}
\int dV \rho(\vec r) 
e^{-\vec q\cdot \vec r}
\;,
$$
where the integration is over all space.
The reason why the integration in your post has simple limits is because the density is constant in the region $r<R$ and zero elsewhere:
$$
\rho(\vec r) = \frac{3M}{4\pi R^3}\theta(r - R)
$$
Also, note that the definition of the x-ray scattering form factor doesn't make any reference to "inside" or "outside" the sphere. It is a definition that is independent of such considerations. In practice we don't care about "inside" or "outside" because we always measure the probe particle far away from the scatterer (the sphere). The sphere has an effect because it is not made out of vacuum on the inside.
