I'm coming back to this one after a long while, and finally manager to get this building under cmake-OpenOrbiter:
Here's a nice shot of 64bit Orbiter. Phobos is behaving nicely, as you can see

(this is obviously quite unsurprising, given that
Ajaja's original version is from circa 2008)
The only bit thing I'm still stuck on is what to do with all the VSOP87 code in the orbiter source tree. It's no longer needed with the spice modules, but on the other hand it is an extremely useful reference for implementing a Celbody module in orbiter. Rather than remove it, I'm doing this in the /src/Celbody/CMakeLists.txt
Code:
# Copyright (c) Martin Schweiger
# Licensed under the MIT License
if(SPICE_BUILD)
add_subdirectory(SPICE)
add_subdirectory(Atmosphere)
else()
add_subdirectory(Sol)
add_subdirectory(Vsop87)
add_subdirectory(Moon)
add_subdirectory(Phobos) #Problem for x64
add_subdirectory(Deimos) #Problem for x64
add_subdirectory(Vesta)
add_subdirectory(Galsat)
add_subdirectory(Satsat)
add_subdirectory(Miranda) #Problem for x64
add_subdirectory(Ariel) #Problem for x64
add_subdirectory(Umbriel) #Problem for x64
add_subdirectory(Titania) #Problem for x64
add_subdirectory(Oberon) #Problem for x64
add_subdirectory(Triton) #Problem for x64
add_subdirectory(Proteus) #Problem for x64
add_subdirectory(Nereid) #Problem for x64
endif()
I do need to put together some detailed documentation on how to use this. Out of the box it should be a massive improvement in planet/moon position position/velocity accuracy, but as far as potential for addons goes, it should be super easy to add additional spice moons/TNOs/asteroids etc, and update for future versions of ephemerides are published. I was able to update update the DE440 (25 June 2020) kernels to DE442 (13 May 2024), which adds some improvements to the Uranus barycenter.
I'm not feeling super organized at the moment, and I'd like to to a bunch of testing before considering merging this, but I'm hopeful it makes it into the full release.
A few items, in case there are questions:
- The code that makes this work is by @Ajaja and NAIF not me. I'm just doing the integration
- Info on SPICE https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/Tutorials/pdf/individual_docs/03_spice_overview.pdf
- The module that this change adds (spice.dll/spice.so) is still just an a derived version of the CELBODY2 class (just like the VSOP87 modules were). The only difference is that it's a single module for all bodies, you just load different kernels (file containing the ephemeris/ides data), which is specified in the celbody's config file.
- I'm not currently building cspice from source, partially because there are ~2200 .c and .h files that would need to be added to the Orbiter source tree, and also because NAIF customized a bunch of these files x86 vs.64 and for MSVC vs. GCC, and I would need to conditionally include the at least 4 full copies of 2200 files, which seemed absord. I had a bunch of problems actually getting it to build because of a static/extern linkage problem too, so I'm just conditionally linking to the .lib/.a files for now. In theory the origionally Fortran 77 source could be included and the C89 source for cspice could be generated using f2c...but this is where I gave up.