Skip to content

Commit

Permalink
Add additional polyLimit param
Browse files Browse the repository at this point in the history
  • Loading branch information
clexmond committed Aug 26, 2024
1 parent c4e5df9 commit e6d8d2a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@influenceth/sdk",
"version": "2.3.2",
"version": "2.3.3",
"description": "Influence SDK",
"type": "module",
"module": "./build/index.js",
Expand Down
5 changes: 3 additions & 2 deletions src/lib/asteroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { constants } from '@influenceth/astro';

import procedural from '../utils/procedural.js';
import { SIMPLEX_POLY_FIT } from '../constants.js';
import { percentileByOctaves, recursiveSNoise } from '../utils/simplex.js';
import { percentileByOctaves, recursiveSNoise, SIMPLEX_OCTAVES } from '../utils/simplex.js';
import Product from './product.js';

/**
Expand Down Expand Up @@ -595,6 +595,7 @@ const getAbundanceMapSettings = (asteroidId, resourceId, abundances) => {
const radiusRatio = radius / MAX_RADIUS;
const pointScale = RESOURCE_SIZE_BASE + (RESOURCE_SIZE_MUL * radiusRatio);
const polyParams = SIMPLEX_POLY_FIT[octaves];
const polyLimit = 1 - Number(SIMPLEX_OCTAVES[octaves][0][2]) / 2 ** 32;

const resourceSeed = ec.starkCurve.poseidonHashMany(
[BigInt(asteroidId), BigInt(resourceId), BigInt(abundances)]
Expand All @@ -612,7 +613,7 @@ const getAbundanceMapSettings = (asteroidId, resourceId, abundances) => {
const zShift = procedural.realBetween(zSeed, lowShift, highShift);

const abundance = getAbundances(abundances)[resourceId];
return { abundance, octaves, polyParams, pointScale, pointShift: [xShift, yShift, zShift] };
return { abundance, octaves, polyParams, polyLimit, pointScale, pointShift: [xShift, yShift, zShift] };
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/utils/simplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const recursiveSNoise = (p, pers, octaves) => {
return noise;
};

const SIMPLEX_OCTAVES = {
export const SIMPLEX_OCTAVES = {
2: [
[ 848946201n, 0n, 573229616n, 848946201n ],
[ 968908012n, 42949673n, 848946201n, 968908012n ],
Expand Down
6 changes: 3 additions & 3 deletions test/lib/asteroid.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ describe('Asteroid library', function () {

it('should calculate abundance map params', function () {
const abundances = 90591218639619085331542389405307898768942017548859450482229248055n;
let settings = asteroid.getAbundanceMapSettings(1, 42, 1, abundances);
let settings = asteroid.getAbundanceMapSettings(1, 1, abundances);
expect(settings.octaves).to.equal(6);
settings = asteroid.getAbundanceMapSettings(104, 42, 1, abundances);
settings = asteroid.getAbundanceMapSettings(104, 1, abundances);
expect(settings.octaves).to.equal(3);
settings = asteroid.getAbundanceMapSettings(250000, 42, 1, 0.25);
settings = asteroid.getAbundanceMapSettings(250000, 1, abundances);
expect(settings.octaves).to.equal(2);
});

Expand Down

0 comments on commit e6d8d2a

Please sign in to comment.