DKL9 GitList
Repositories
DKL9 home
voxels
Code
Commits
Branches
Tags
Search
Tree:
b5dd445
Branches
Tags
master
voxels
libs.py
Faster raycast, better mapgen and much better HUD
dkl9
commited
b5dd445
at 2025-174 14:21:36
libs.py
Blame
History
Raw
from OpenGL.GL import * import itertools import numpy as np import pygame FLOAT = np.float32 VOXEL_TYPE = np.uint8 def vec(l): return np.array(l, dtype=FLOAT) RED = vec([1.0, 0.0, 0.0, 1.0]) YELLOW = vec([1.0, 1.0, 0.0, 1.0]) GREEN = vec([0.0, 1.0, 0.0, 1.0]) def normalize(v): norm = np.linalg.norm(v) return v / norm if norm > 0 else v def roll_vec3(l, k): match k: case 1: l[:] = [l[2], l[0], l[1]] case 2: l[:] = [l[1], l[2], l[0]] def axis2offset(a, x=1): o = [0, 0, x * np.sign(a)] roll_vec3(o, abs(a)) return o