Bug fixes
							parent
							
								
									25a72b62a4
								
							
						
					
					
						commit
						cae90a06c4
					
				|  | @ -0,0 +1 @@ | ||||||
|  | .vscode | ||||||
							
								
								
									
										56
									
								
								script.lua
								
								
								
								
							
							
						
						
									
										56
									
								
								script.lua
								
								
								
								
							|  | @ -209,7 +209,11 @@ end | ||||||
| 
 | 
 | ||||||
| -- Get connectivity noise params | -- Get connectivity noise params | ||||||
| function internal.connectivity_noise_params() | function internal.connectivity_noise_params() | ||||||
|     local factor = math.max(1, math.abs(#ns_cavegen.registered_shapes) ^ 0.5) |     local shapes = 0 | ||||||
|  |     for _, _ in pairs(ns_cavegen.registered_shapes) do | ||||||
|  |         shapes = shapes + 1 | ||||||
|  |     end | ||||||
|  |     local factor = math.max(1, math.abs(shapes) ^ 0.5) | ||||||
| 
 | 
 | ||||||
|     return { |     return { | ||||||
|         offset = 50, |         offset = 50, | ||||||
|  | @ -277,8 +281,11 @@ function internal.find_biome_allocations(heat, humidity, va) | ||||||
| 
 | 
 | ||||||
|             if def_d < d then |             if def_d < d then | ||||||
|                 local pos = va:position(i) |                 local pos = va:position(i) | ||||||
|  |                 local contains_x = def.min_pos.x <= pos.x and pos.x <= def.max_pos.x | ||||||
|  |                 local contains_y = def.min_pos.y <= pos.y and pos.y <= def.max_pos.y | ||||||
|  |                 local contains_z = def.min_pos.z <= pos.z and pos.z <= def.max_pos.z | ||||||
| 
 | 
 | ||||||
|                 if VoxelArea:new(def.min_pos, def.max_pos):contains(pos.x, pos.y, pos.z) then |                 if contains_x and contains_y and contains_z then | ||||||
|                     d = def_d |                     d = def_d | ||||||
|                     biome_name = name |                     biome_name = name | ||||||
|                 end |                 end | ||||||
|  | @ -313,9 +320,9 @@ function internal.find_shape_allocations(connectivity, verticality, va) | ||||||
|             ) |             ) | ||||||
| 
 | 
 | ||||||
|             if def_d < d then |             if def_d < d then | ||||||
|                 local pos = va:position(i) |                 local y = va:position(i).y | ||||||
| 
 | 
 | ||||||
|                 if VoxelArea:new(def.min_pos, def.max_pos):contains(pos.x, pos.y, pos.z) then |                 if def.y_min <= y and y <= def.y_max then | ||||||
|                     d = def_d |                     d = def_d | ||||||
|                     shape_name = name |                     shape_name = name | ||||||
|                 end |                 end | ||||||
|  | @ -394,24 +401,18 @@ function internal.generate_perlin_noise(noiseparams, minp, maxp) | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| function internal.generate_shape(def, minp, maxp, va) | function internal.generate_shape(def, minp, maxp, va) | ||||||
|     -- local noise_flat = {} |  | ||||||
| 
 |  | ||||||
|     -- Get random noise if noise_params are given |     -- Get random noise if noise_params are given | ||||||
|     if def.noise_params then |     if def.noise_params then | ||||||
|         return internal.generate_perlin_noise(def.noise_params, minp, maxp) |         return internal.generate_perlin_noise(def.noise_params, minp, maxp) | ||||||
|     else |     else | ||||||
|         return {} |         local noise_flat = {} | ||||||
|         -- for i in va:iterp(minp, maxp) do | 
 | ||||||
|         --     noise_flat[i] = 0 |         for i in va:iterp(minp, maxp) do | ||||||
|         -- end |             noise_flat[i] = 0 | ||||||
|         end |         end | ||||||
| 
 | 
 | ||||||
|     -- -- Update noise with custom defined function |         return noise_flat | ||||||
|     -- for i in va:iterp(minp, maxp) do |     end | ||||||
|     --     noise_flat[i] = def.func(va:position(i), noise_flat[i]) |  | ||||||
|     -- end |  | ||||||
| 
 |  | ||||||
|     -- return noise_flat |  | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| -- Generate verticality noise within given boundaries | -- Generate verticality noise within given boundaries | ||||||
|  | @ -449,6 +450,15 @@ function internal.humidity_noise_params() | ||||||
|     } |     } | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
|  | function internal.log_classified_nodes(classified_nodes) | ||||||
|  |     minetest.debug("Found " .. #classified_nodes.ceiling_decos .. " ceiling decorations") | ||||||
|  |     minetest.debug("Found " .. #classified_nodes.ceilings .. " ceiling nodes") | ||||||
|  |     minetest.debug("Found " .. #classified_nodes.contents .. " content nodes") | ||||||
|  |     minetest.debug("Found " .. #classified_nodes.floors .. " floor nodes") | ||||||
|  |     minetest.debug("Found " .. #classified_nodes.floor_decos .. " floor decorations") | ||||||
|  |     minetest.debug("Found " .. #classified_nodes.walls .. " wall nodes") | ||||||
|  | end | ||||||
|  | 
 | ||||||
| -- Take all necessary steps to execute the mapgen | -- Take all necessary steps to execute the mapgen | ||||||
| function internal.mapgen(vm, minp, maxp, blockseed) | function internal.mapgen(vm, minp, maxp, blockseed) | ||||||
|     -- Create bordered VoxelArea. |     -- Create bordered VoxelArea. | ||||||
|  | @ -480,6 +490,7 @@ function internal.mapgen(vm, minp, maxp, blockseed) | ||||||
| 
 | 
 | ||||||
|     -- Classify various nodes as walls, floors, ceilings |     -- Classify various nodes as walls, floors, ceilings | ||||||
|     local classified_nodes = internal.classify_nodes(used_shapes, bminp, bmaxp) |     local classified_nodes = internal.classify_nodes(used_shapes, bminp, bmaxp) | ||||||
|  |     -- internal.log_classified_nodes(classified_nodes) | ||||||
| 
 | 
 | ||||||
|     -- Draw cave biomes |     -- Draw cave biomes | ||||||
|     local used_biomes = internal.find_biome_allocations(heat, humidity, sva) |     local used_biomes = internal.find_biome_allocations(heat, humidity, sva) | ||||||
|  | @ -582,7 +593,11 @@ end | ||||||
| 
 | 
 | ||||||
| -- Get verticality noise params | -- Get verticality noise params | ||||||
| function internal.verticality_noise_params() | function internal.verticality_noise_params() | ||||||
|     local factor = math.max(1, math.abs(#ns_cavegen.registered_shapes) ^ 0.5) |     local shapes = 0 | ||||||
|  |     for _, _ in pairs(ns_cavegen.registered_shapes) do | ||||||
|  |         shapes = shapes + 1 | ||||||
|  |     end | ||||||
|  |     local factor = math.max(1, math.abs(shapes) ^ 0.5) | ||||||
| 
 | 
 | ||||||
|     return { |     return { | ||||||
|         offset = 50, |         offset = 50, | ||||||
|  | @ -628,7 +643,7 @@ function internal.write_classified_node(vm_data, va, used_biomes, classified_nod | ||||||
| 
 | 
 | ||||||
|         local content_id = biome_to_id[biome] |         local content_id = biome_to_id[biome] | ||||||
| 
 | 
 | ||||||
|         if content_id ~= "" then |         if type(content_id) == "number" then | ||||||
|             local vi = va:index(pos.x, pos.y, pos.z) |             local vi = va:index(pos.x, pos.y, pos.z) | ||||||
|             local vm_node = vm_data[vi] |             local vm_node = vm_data[vi] | ||||||
| 
 | 
 | ||||||
|  | @ -640,6 +655,11 @@ function internal.write_classified_node(vm_data, va, used_biomes, classified_nod | ||||||
|             if ground_content_nodes[vm_node] then |             if ground_content_nodes[vm_node] then | ||||||
|                 vm_data[vi] = content_id |                 vm_data[vi] = content_id | ||||||
|             end |             end | ||||||
|  |         elseif content_id == "air" then | ||||||
|  |             minetest.debug("Biome " .. biome .. "||| BREAAAK") | ||||||
|  |             break | ||||||
|  |         elseif content_id ~= "" and content_id ~= nil and content_id ~= "air" then | ||||||
|  |             minetest.debug("Encountered content ID " .. content_id) | ||||||
|         end |         end | ||||||
|     end |     end | ||||||
| end | end | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue