Changeset 896 for cpp/common
- Timestamp:
- 11/30/19 01:30:22 (5 years ago)
- Location:
- cpp/common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/common/nonstd_math.cpp
r867 r896 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-201 5Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2019 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 5 5 #include "nonstd_math.h" 6 6 7 RandomGenerator &rndGetInstance()7 RandomGenerator &rndGetInstance() 8 8 { 9 9 static RandomGenerator rnd(0); -
cpp/common/nonstd_math.h
r835 r896 1 1 // This file is a part of Framsticks SDK. http://www.framsticks.com/ 2 // Copyright (C) 1999-201 8Maciej Komosinski and Szymon Ulatowski.2 // Copyright (C) 1999-2019 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 4 … … 21 21 //random number generator: 22 22 #include "random.h" 23 RandomGenerator &rndGetInstance();23 RandomGenerator &rndGetInstance(); 24 24 25 #define rnd01 (rndGetInstance().getDouble()) 26 #define rnd0N(limit) (rndGetInstance().getDouble()*(limit)) 27 #define randomN(limit) ((unsigned int)(rndGetInstance().getDouble()*(limit))) 28 #define setRandomSeed(seed) rndGetInstance().setSeed(seed) 29 #define setRandomRandomSeed() rndGetInstance().randomize() 30 25 inline double rndDouble(double limit_exclusive) { return rndGetInstance().getDouble() * limit_exclusive; } 26 inline unsigned int rndUint(unsigned int limit_exclusive) { return (unsigned int)(rndGetInstance().getDouble() * limit_exclusive); } //returns random from 0..limit_exclusive-1 27 inline void rndSetSeed(unsigned int seed) { rndGetInstance().setSeed(seed); } 28 inline unsigned int rndRandomizeSeed() { return rndGetInstance().randomize(); } 31 29 32 30 //floating point specific numbers … … 66 64 void fpExceptDisable(); 67 65 66 // std::lerp can be used since c++20 (and has some guaranteed properties probably better than this basic formula) but apparently it is not a template 67 template <typename Value, typename Linear> Value universal_lerp(Value a,Value b,Linear t) {return a*(1-t)+b*t;} 68 68 69 #endif 69 70 -
cpp/common/random.h
r886 r896 2 2 // Copyright (C) 1999-2018 Maciej Komosinski and Szymon Ulatowski. 3 3 // See LICENSE.txt for details. 4 #ifndef _COMMON_RANDOM_H_ 5 #define _COMMON_RANDOM_H_ 4 6 5 7 #ifdef _MSC_VER … … 140 142 } 141 143 }; 144 #endif
Note: See TracChangeset
for help on using the changeset viewer.