by FrikaC » Tue May 16, 2006 11:36 am
Some of you may remember my old mathlib file I posted several years ago. Well, I got around to updating it. So without further ado:
(Right click and choose Save As)
For those unfamiliar with this file, it provides some sorely missing arithmetic and trigonomic functions to QuakeC: sqrt (square root) cos (cosine) sin (sine) pow (raise to power). In this version I've added min, max, bound, randomvec and bitshift, these emulate the Darkplaces engine features of the same name.
As a bonus, I've also added a large chunk of code to make mathlib use the engine math functions if they are available. So, if you're already using these engine functions, you can plop this file into your project and provide QuakeC alternatives so that your mod is less tied to a specific engine. Or, on the other hand, if you're really unsure about using these engine features for fear of breaking compatability, you can optionally support them.
A warning however about QMB. Although it reports DP_QC_SINCOSSQRTPOW, DP_QC_MINMAXBOUND, DP_QC_RANDOMVEC it appears it's support for the functions pow, min, max, bound and randomvec . If your mod absolutely needs to run in QMB, you can call the mathlib_ equivalents of these functions directly instead. (Pow and randomvec are the only major losses).
Also for testing and as an example, I uploaded which was used to debug the engine features.
For instructions on installing and using mathlib.qc, refer to the comment at the top of the file.
Feedback welcomed.