Skip to content

Minimal build fix #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.1.5 -- September 17, 2024

- Fix build config

1.1.4 -- August 1, 2017

- Fix Python 3 crash
Expand Down
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Copyright (c) 2017, Zev Benjamin <zev@strangersgate.com>
"""

__version__ = "1.1.4"
__version__ = "1.1.5"

from . import _perlin, _simplex

Expand Down
34 changes: 17 additions & 17 deletions _simplex.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ typedef struct _NoiseArgs {
float
noise2(float x, float y)
{
int i1, j1, I, J, c;
int i1, j1, II, J, c;
float s = (x + y) * F2;
float i = floorf(x + s);
float j = floorf(y + s);
Expand All @@ -66,11 +66,11 @@ noise2(float x, float y)
xx[1] = xx[0] - i1 + G2;
yy[1] = yy[0] - j1 + G2;

I = (int) i & 255;
II = (int) i & 255;
J = (int) j & 255;
g[0] = PERM[I + PERM[J]] % 12;
g[1] = PERM[I + i1 + PERM[J + j1]] % 12;
g[2] = PERM[I + 1 + PERM[J + 1]] % 12;
g[0] = PERM[II + PERM[J]] % 12;
g[1] = PERM[II + i1 + PERM[J + j1]] % 12;
g[2] = PERM[II + 1 + PERM[J + 1]] % 12;

for (c = 0; c <= 2; c++)
f[c] = 0.5f - xx[c]*xx[c] - yy[c]*yy[c];
Expand All @@ -92,7 +92,7 @@ noise2(float x, float y)
float
noise3(float x, float y, float z)
{
int c, o1[3], o2[3], g[4], I, J, K;
int c, o1[3], o2[3], g[4], II, J, K;
float f[4], noise[4] = {0.0f, 0.0f, 0.0f, 0.0f};
float s = (x + y + z) * F3;
float i = floorf(x + s);
Expand Down Expand Up @@ -136,13 +136,13 @@ noise3(float x, float y, float z)
pos[1][c] = pos[0][c] - o1[c] + G3;
}

I = (int) i & 255;
II = (int) i & 255;
J = (int) j & 255;
K = (int) k & 255;
g[0] = PERM[I + PERM[J + PERM[K]]] % 12;
g[1] = PERM[I + o1[0] + PERM[J + o1[1] + PERM[o1[2] + K]]] % 12;
g[2] = PERM[I + o2[0] + PERM[J + o2[1] + PERM[o2[2] + K]]] % 12;
g[3] = PERM[I + 1 + PERM[J + 1 + PERM[K + 1]]] % 12;
g[0] = PERM[II + PERM[J + PERM[K]]] % 12;
g[1] = PERM[II + o1[0] + PERM[J + o1[1] + PERM[o1[2] + K]]] % 12;
g[2] = PERM[II + o2[0] + PERM[J + o2[1] + PERM[o2[2] + K]]] % 12;
g[3] = PERM[II + 1 + PERM[J + 1 + PERM[K + 1]]] % 12;

for (c = 0; c <= 3; c++) {
f[c] = 0.6f - pos[c][0]*pos[c][0] - pos[c][1]*pos[c][1] - pos[c][2]*pos[c][2];
Expand Down Expand Up @@ -226,15 +226,15 @@ noise4(float x, float y, float z, float w) {
float z4 = z0 - 1.0f + 4.0f*G4;
float w4 = w0 - 1.0f + 4.0f*G4;

int I = (int)i & 255;
int II = (int)i & 255;
int J = (int)j & 255;
int K = (int)k & 255;
int L = (int)l & 255;
int gi0 = PERM[I + PERM[J + PERM[K + PERM[L]]]] & 0x1f;
int gi1 = PERM[I + i1 + PERM[J + j1 + PERM[K + k1 + PERM[L + l1]]]] & 0x1f;
int gi2 = PERM[I + i2 + PERM[J + j2 + PERM[K + k2 + PERM[L + l2]]]] & 0x1f;
int gi3 = PERM[I + i3 + PERM[J + j3 + PERM[K + k3 + PERM[L + l3]]]] & 0x1f;
int gi4 = PERM[I + 1 + PERM[J + 1 + PERM[K + 1 + PERM[L + 1]]]] & 0x1f;
int gi0 = PERM[II + PERM[J + PERM[K + PERM[L]]]] & 0x1f;
int gi1 = PERM[II + i1 + PERM[J + j1 + PERM[K + k1 + PERM[L + l1]]]] & 0x1f;
int gi2 = PERM[II + i2 + PERM[J + j2 + PERM[K + k2 + PERM[L + l2]]]] & 0x1f;
int gi3 = PERM[II + i3 + PERM[J + j3 + PERM[K + k3 + PERM[L + l3]]]] & 0x1f;
int gi4 = PERM[II + 1 + PERM[J + 1 + PERM[K + 1 + PERM[L + 1]]]] & 0x1f;
float t0, t1, t2, t3, t4;

t0 = 0.6f - x0*x0 - y0*y0 - z0*z0 - w0*w0;
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools", "numpy"]
build-backend = "setuptools.build_meta"
14 changes: 4 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import sys

from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext as _build_ext

class build_ext(_build_ext):
def finalize_options(self):
_build_ext.finalize_options(self)
# Prevent numpy from thinking it is still in its setup process:
__builtins__.__NUMPY_SETUP__ = False
import numpy
self.include_dirs.append(numpy.get_include())
import numpy

if sys.platform != 'win32':
compile_args = ['-funroll-loops']
Expand All @@ -19,7 +12,7 @@ def finalize_options(self):

setup(
name='vec_noise',
version='1.1.4',
version='1.1.5',
description='Vectorized Perlin noise for Python',
long_description='''\
This is a fork of Casey Duncan's noise library that vectorizes all of the noise
Expand Down Expand Up @@ -60,13 +53,14 @@ def finalize_options(self):
packages=['vec_noise'],
setup_requires=['numpy'],
install_requires=['numpy'],
cmdclass={'build_ext': build_ext},
ext_modules=[
Extension('vec_noise._simplex', ['_simplex.c'],
extra_compile_args=compile_args,
include_dirs=[numpy.get_include()],
),
Extension('vec_noise._perlin', ['_perlin.c'],
extra_compile_args=compile_args,
include_dirs=[numpy.get_include()],
)
],
)