update map gen
This commit is contained in:
36
Assets/Plugins/Native/BackroomsNoise/BackroomsNoise.cpp
Normal file
36
Assets/Plugins/Native/BackroomsNoise/BackroomsNoise.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "FastNoiseLite.h"
|
||||
#include <vector>
|
||||
|
||||
#define EXPORT_API __declspec(dllexport)
|
||||
|
||||
extern "C" {
|
||||
EXPORT_API void* CreateNoiseGenerator(int seed, float frequency, int noiseType) {
|
||||
FastNoiseLite* noise = new FastNoiseLite(seed);
|
||||
noise->SetFrequency(frequency);
|
||||
noise->SetNoiseType((FastNoiseLite::NoiseType)noiseType);
|
||||
return (void*)noise;
|
||||
}
|
||||
|
||||
EXPORT_API float GetNoiseValue(void* handle, float x, float z) {
|
||||
if (!handle) return 0.0f;
|
||||
FastNoiseLite* noise = (FastNoiseLite*)handle;
|
||||
return noise->GetNoise(x, z);
|
||||
}
|
||||
|
||||
EXPORT_API void GetNoiseBuffer(void* handle, float startX, float startZ, int width, int depth, float* buffer) {
|
||||
if (!handle || !buffer) return;
|
||||
FastNoiseLite* noise = (FastNoiseLite*)handle;
|
||||
|
||||
for (int z = 0; z < depth; z++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
buffer[z * width + x] = noise->GetNoise(startX + x, startZ + z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EXPORT_API void DestroyNoiseGenerator(void* handle) {
|
||||
if (handle) {
|
||||
delete (FastNoiseLite*)handle;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user