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

Adds shim for rust noise library, exposing 2d perlin noise functions #28

Merged
merged 7 commits into from
May 6, 2020

Conversation

4dplanner
Copy link
Contributor

@4dplanner 4dplanner commented May 4, 2020

Provides an interface to get 2d perlin noise generated by the rust noise library.

Gives one function:

  • rustg_perlin_noise_get_at_coordinates(seed, x, y): takes an integer seed and floating-point coordinates, and returns a floating-point value in the range [0,1].

benchmarked with this code:

/client/New()
	foo()

/proc/foo()
	set waitfor = 0
	world.log << "hello"


	var/start_time = world.timeofday
	var/list/heights = list()
	for(var/x = 0; x < 255; x++)
		for(var/y = 0; y < 255; y++)
			var/height = rustg_perlin_noise_get_at_coordinates("123123", "[x/255]", "[y/255]")
			if(x == 239)
				world.log << height
			heights.Add(height)

	var/end_time = world.timeofday
	world.log << "we took [end_time - start_time] to generate [length(heights)] values"

giving on my pc a result of we took 4 to generate 65025 values

@SpaceManiac
Copy link
Contributor

Any objections to making it one function that accepts (seed, x, y)? The Perlin struct can continue to be cached, but I don't see a need to introduce formal state

@SpaceManiac
Copy link
Contributor

Functionality looks good, will ponder whether I care about the naming overnight

@SpaceManiac SpaceManiac merged commit 552dff4 into tgstation:master May 6, 2020
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