> The basic principles in short: TPE uses soft body physics, bodies are modelled as spheres connected by springs but the springs can be made stiff so that the bodies behave almost like rigid bodies, so you can simulate (fake) both soft and rigid physics. Environment in which bodies are placed is modelled by distance functions, i.e. you can in theory create any environment as long as you can create a function that for any point in space returns the closest point to the environment (functions for basic and some more complex shapes are included in TPE).
There’s a bunch of similar stuff with varying degrees of physical accuracy under Position Based Dynamics and the more physically correct eXtended Position Based dynamics. It’s a fun approach.
I did consider using convex volumes for the collision mesh and making checks against the spring ends (point-in-convex is trivial to check) but then i realized that in 3D space convex objects can collide even if both have their vertices outside of each other (consider two cubes that are not aligned to each other having two of their edges touch with one edge being almost perpendicular to the other). The code was already getting too hairy and at that point might as well drop the whole spring idea and do full convex shape collisions with rotation (big can of worms).
Though truth be told, the simplicity of using just springs and spheres is alluring and the issues might be solvable with a large number of spheres (IIRC Nvidia at some point years ago had a physics engine running on GPU where they modeled everything using small spheres). It does help avoid a bunch of stupid bugs that you can easily get with trying to do angular physics [1] :-P
https://gitlab.com/drummyfish/raycastlib
and well, the pedophilia thing.
he self-describes as non-competitive so probably doesn't care, but he could simply be so much more, as a person, and all the ingredients are there. but likely will waste away most of their life as a (in the best case) relatively benign weirdo.
but they are likely in a social situation where nobody will give them that perspective and education. and society certainly isn't set up to detect and help these people on its own.
Anyway, I agree, excellent code, but I worry about this guy. His website(s) have a lot of worrying content - pro-pedophilia, misogynistic, racist, transphobic.
I wish all 3D engines threw out floats.
See the top part of the header file, where all the function and type declarations are? That's the header. Just move everything below it to a c file.
This particular library doesn't seem to follow the STB convention where the implementation is inside an #ifdef IMPLEMENTATION block, but that would be trivial to fix.
Once you have that it's just as trivial to use from other languages as a regular .h/.c library, just include the implementation into a C source file and compile that into a static link library or DLL, then include the declarations (without IMPLEMENTATION define) into your language (if the language can directly include C headers) or use the header to auto-generate the bindings.
For example:
- https://github.com/floooh/sokol-zig
- https://github.com/floooh/sokol-nim
- https://github.com/floooh/sokol-odin
These are all auto-generated from STB-style single-file libraries: https://github.com/floooh/sokol
mv mylib.h mylib.c
gcc -c mylib.c -o mylib.o
Then link it as a .so/.dll or in a .a library. Done you can use it like any other library.https://github.com/nothings/stb
Important difference to typical C++ header-only libs: STB style libs don't use the inline keyword, but instead place the implementation into an ifdef/endif block.
It's really just for easier distribution and integration, and the difference to a single .h/.c pair isn't all that big.
Definitely not big enough to get all riled up about it - the actual problem are libraries that come in dozens of source and header files and with their own build system files, or C++ libraries which put the implementation into inline code, like most C++ stdlib headers (because this increases compilation time for every file which includes such a header).
I do also like easily embeddable tech like imgui, or lua, where you can simply copy the source code in your source tree.
How come we have managed during the last 40 years?
Yeah we managed, I never said the opposite. I only talked about why I liked header-only libs: because I just copy/paste the source in my source tree, regardless of the build system I use.
If I'm using CMake, and a library is using autotools, I'll have to rewrite the lib's build system, and maintain it. I'm too lazy for that.
Nowadays, use cmake + conan/vcpkg as alternative as well.
Do we need to spoon-feed everything?
If I have a template header .hpp and I do not wish to specialize the template function bodies in a .cpp file, the template header function bodies must be declared in the .hpp, right?
Yes it needs to be on the header, however depending on what is the goal, many operations could eventually be delegated to helper functions or PIMPL classes, which aren't fully exposed on the header.
And for the lucky users of VC++ 2022, there is also the option to use modules instead, where templates are then exposed via the module metada.
Thanks for your comment.
I will have to dig in to modules in due course.
Why? Can't you make a shared object just as easily?