1 #ifndef OPEN_SIMPLEX_NOISE_H__ 2 #define OPEN_SIMPLEX_NOISE_H__ 3 4 /* 5 * OpenSimplex (Simplectic) Noise in C. 6 * Ported to C from Kurt Spencer's java implementation by Stephen M. Cameron 7 * 8 * v1.1 (October 6, 2014) 9 * - Ported to C 10 * 11 * v1.1 (October 5, 2014) 12 * - Added 2D and 4D implementations. 13 * - Proper gradient sets for all dimensions, from a 14 * dimensionally-generalizable scheme with an actual 15 * rhyme and reason behind it. 16 * - Removed default permutation array in favor of 17 * default seed. 18 * - Changed seed-based constructor to be independent 19 * of any particular randomization library, so results 20 * will be the same when ported to other languages. 21 */ 22 23 #if ((__GNUC_STDC_INLINE__) || (__STDC_VERSION__ >= 199901L)) 24 #include <stdint.h> 25 #define INLINE inline 26 #elif (defined (_MSC_VER) || defined (__GNUC_GNU_INLINE__)) 27 #include <stdint.h> 28 #define INLINE __inline 29 #else 30 /* ANSI C doesn't have inline or stdint.h. */ 31 #define INLINE 32 #endif 33 34 #ifdef __cplusplus 35 extern "C" { 36 #endif 37 38 // -- GODOT start -- 39 // Modified to work without allocating memory, also removed some unused function. 40 41 struct osn_context { 42 int16_t perm[256]; 43 int16_t permGradIndex3D[256]; 44 }; 45 46 int open_simplex_noise(int64_t seed, struct osn_context *ctx); 47 //int open_simplex_noise_init_perm(struct osn_context *ctx, int16_t p[], int nelements); 48 // -- GODOT end -- 49 void open_simplex_noise_free(struct osn_context *ctx); 50 double open_simplex_noise2(struct osn_context *ctx, double x, double y); 51 double open_simplex_noise3(struct osn_context *ctx, double x, double y, double z); 52 double open_simplex_noise4(struct osn_context *ctx, double x, double y, double z, double w); 53 54 #ifdef __cplusplus 55 } 56 #endif 57 58 #endif 59