Files
BABA_YAGA/Assets/Plugins/Native/BackroomsNoise/BackroomsNoise.cpp
2026-06-09 22:46:32 +07:00

37 lines
1.1 KiB
C++

#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;
}
}
}