Skip to content
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

implement density functions for terrain generation #98

Merged
merged 11 commits into from
Oct 14, 2024

Conversation

kralverde
Copy link
Contributor

WIP

This PR has the end goal of generating plains biomes

@kralverde
Copy link
Contributor Author

I bit off more than I can chew. Here is another stepping stone towards chunk generation: the density functions. I will keep on working towards terrain generation.

@kralverde kralverde marked this pull request as ready for review September 28, 2024 04:22
@kralverde kralverde changed the title begin the long road to plains biomes implement density functions for terrain generation Sep 28, 2024
pumpkin-core/src/math/mod.rs Outdated Show resolved Hide resolved
Comment on lines +26 to +55
fn sample_2d(sampler: &SimplexNoiseSampler, x: i32, z: i32) -> f32 {
let i = x / 2;
let j = z / 2;
let k = x % 2;
let l = z % 2;

let f = 100f32 - ((x * x + z * z) as f32).sqrt() * 8f32;
let mut f = f.clamp(-100f32, 80f32);

for m in -12..=12 {
for n in -12..=12 {
let o = (i + m) as i64;
let p = (j + n) as i64;

if (o * o + p * p) > 4096i64
&& sampler.sample_2d(o as f64, p as f64) < -0.9f32 as f64
{
let g = ((o as f32).abs() * 3439f32 + (p as f32).abs() * 147f32) % 13f32 + 9f32;
let h = (k - m * 2) as f32;
let q = (l - n * 2) as f32;
let r = 100f32 - (h * h + q * q).sqrt() * g;
let s = r.clamp(-100f32, 80f32);

f = f.max(s);
}
}
}

f
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is is vanilla ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@Snowiiii
Copy link
Member

Snowiiii commented Oct 3, 2024

I see you almost have function1, function2 function3... everywhere. Did you got this code from somewhere or why var names are so weird?

@kralverde
Copy link
Contributor Author

kralverde commented Oct 3, 2024

Straight from Java lol, i am not entirely sure what they do. seems like they are just reused code for generating splines

@Snowiiii
Copy link
Member

Snowiiii commented Oct 7, 2024

I don't like if someone just copies Java code and then even say that he don't know what the code does. So you said your goal is to have the Plains biome generation working. Do you need everything here for this, Or is something missing ?

@kralverde
Copy link
Contributor Author

Yeah, it's not ideal. I can do a re-write once I have a better idea of everything that is going on. This is needed for all generation, so is a stepping stone to plains generation

@kralverde
Copy link
Contributor Author

Not knowing is a bad way of putting it. I know what they do; they're just reused and are pretty basic so I don't know what to name them

@Snowiiii
Copy link
Member

Snowiiii commented Oct 8, 2024

I would like to have good function names at least

@kralverde
Copy link
Contributor Author

Functions have been renamed

@Snowiiii
Copy link
Member

noice, can you may fix the conflicts ?
then it should be ready to merge

@kralverde
Copy link
Contributor Author

rebased, should be good

@Snowiiii Snowiiii merged commit c111d6f into Pumpkin-MC:master Oct 14, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants