-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathopen-simplex-noise.h
58 lines (50 loc) · 1.71 KB
/
open-simplex-noise.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef OPEN_SIMPLEX_NOISE_H__
#define OPEN_SIMPLEX_NOISE_H__
/*
* OpenSimplex (Simplectic) Noise in C.
* Ported to C from Kurt Spencer's java implementation by Stephen M. Cameron
*
* v1.1 (October 6, 2014)
* - Ported to C
*
* v1.1 (October 5, 2014)
* - Added 2D and 4D implementations.
* - Proper gradient sets for all dimensions, from a
* dimensionally-generalizable scheme with an actual
* rhyme and reason behind it.
* - Removed default permutation array in favor of
* default seed.
* - Changed seed-based constructor to be independent
* of any particular randomization library, so results
* will be the same when ported to other languages.
*/
#if ((__GNUC_STDC_INLINE__) || (__STDC_VERSION__ >= 199901L))
#include <stdint.h>
#define INLINE inline
#elif (defined (_MSC_VER) || defined (__GNUC_GNU_INLINE__))
#include <stdint.h>
#define INLINE __inline
#else
/* ANSI C doesn't have inline or stdint.h. */
#define INLINE
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* You can override this to be float if you want by adding -DOSNFLOAT=float to CFLAGS
* It is not as well tested with floats though.
*/
#ifndef OSNFLOAT
#define OSNFLOAT double
#endif
struct osn_context;
int open_simplex_noise(int64_t seed, struct osn_context **ctx);
void open_simplex_noise_free(struct osn_context *ctx);
int open_simplex_noise_init_perm(struct osn_context *ctx, int16_t p[], int nelements);
OSNFLOAT open_simplex_noise2(const struct osn_context *ctx, OSNFLOAT x, OSNFLOAT y);
OSNFLOAT open_simplex_noise3(const struct osn_context *ctx, OSNFLOAT x, OSNFLOAT y, OSNFLOAT z);
OSNFLOAT open_simplex_noise4(const struct osn_context *ctx, OSNFLOAT x, OSNFLOAT y, OSNFLOAT z, OSNFLOAT w);
#ifdef __cplusplus
}
#endif
#endif