Skip to content

Commit

Permalink
feat: reduce number of BigInt uses for noise
Browse files Browse the repository at this point in the history
  • Loading branch information
ultraviolet-jordan committed Apr 7, 2024
1 parent f9e3dd0 commit 8ce8fbe
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/js/jagex2/dash3d/World.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ export default class World {

static noise = (x: number, y: number): number => {
const n: number = x + y * 57;
const n1: number = (n << 13) ^ n;
const n2: bigint = (BigInt(n1) * (BigInt(n1) * BigInt(n1) * 15731n + 789221n) + 1376312589n) & 0x7fffffffn;
return Number(n2 >> 19n) & 0xff;
const n1: bigint = BigInt((n << 13) ^ n);
return Number(((n1 * (n1 * n1 * 15731n + 789221n) + 1376312589n) & 0x7fffffffn) >> 19n) & 0xff;
};

static addLoc = (level: number, x: number, z: number, scene: World3D | null, levelHeightmap: Int32Array[][], locs: LinkList, collision: CollisionMap, locId: number, shape: number, angle: number, trueLevel: number): void => {
Expand Down

0 comments on commit 8ce8fbe

Please sign in to comment.