| Line |
Branch |
Exec |
Source |
| 1 |
|
|
#include "bindings.h" |
| 2 |
|
|
#include "common.h" |
| 3 |
|
|
|
| 4 |
|
|
#include "terraingen/noise/fractal.h" |
| 5 |
|
|
#include "terraingen/noise/hash.h" |
| 6 |
|
|
#include "terraingen/noise/noise_layers.h" |
| 7 |
|
|
#include "terraingen/noise/perlin.h" |
| 8 |
|
|
#include "terraingen/noise/simplex.h" |
| 9 |
|
|
#include "terraingen/noise/validate.h" |
| 10 |
|
|
#include "terraingen/noise/value.h" |
| 11 |
|
|
#include "terraingen/noise/worley.h" |
| 12 |
|
|
#include "terraingen/sources/synthetic_terrain.h" |
| 13 |
|
|
|
| 14 |
|
|
#include <nanobind/ndarray.h> |
| 15 |
|
|
#include <nanobind/operators.h> |
| 16 |
|
|
|
| 17 |
|
|
#include <cstdint> |
| 18 |
|
|
#include <stdexcept> |
| 19 |
|
|
#include <string> |
| 20 |
|
|
#include <vector> |
| 21 |
|
|
|
| 22 |
|
|
namespace terraingen::python { |
| 23 |
|
|
|
| 24 |
|
|
namespace { |
| 25 |
|
|
|
| 26 |
|
|
using InputArray = nb::ndarray<const float, nb::device::cpu, nb::c_contig>; |
| 27 |
|
|
using InputArray64 = nb::ndarray<const double, nb::device::cpu, nb::c_contig>; |
| 28 |
|
|
using OutputArray = nb::ndarray<nb::numpy, float>; |
| 29 |
|
|
|
| 30 |
|
|
/// @brief The shape shared by every array, or an error naming them. |
| 31 |
|
|
template <typename Array, typename... More> |
| 32 |
|
47 |
std::vector<std::size_t> SameShape(const char* names, const Array& first, const More&... more) { |
| 33 |
2/2
std::vector<unsigned long, std::allocator<unsigned long> > terraingen::python::(anonymous namespace)::SameShape<nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig>, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig>, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> >(char const*, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&):
✓ Branch 2 taken 8 times.
std::vector<unsigned long, std::allocator<unsigned long> > terraingen::python::(anonymous namespace)::SameShape<nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig>, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> >(char const*, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&):
✓ Branch 2 taken 39 times.
|
47 |
std::vector<std::size_t> shape(first.ndim()); |
| 34 |
4/4
std::vector<unsigned long, std::allocator<unsigned long> > terraingen::python::(anonymous namespace)::SameShape<nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig>, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig>, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> >(char const*, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&):
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 8 times.
std::vector<unsigned long, std::allocator<unsigned long> > terraingen::python::(anonymous namespace)::SameShape<nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig>, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> >(char const*, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&):
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 39 times.
|
129 |
for (std::size_t i = 0; i < first.ndim(); ++i) { |
| 35 |
|
82 |
shape[i] = first.shape(i); |
| 36 |
|
|
} |
| 37 |
|
47 |
const auto matches = [&](const Array& other) { |
| 38 |
|
|
if (other.ndim() != first.ndim()) { |
| 39 |
|
|
return false; |
| 40 |
|
|
} |
| 41 |
|
|
for (std::size_t i = 0; i < first.ndim(); ++i) { |
| 42 |
|
|
if (other.shape(i) != first.shape(i)) { |
| 43 |
|
|
return false; |
| 44 |
|
|
} |
| 45 |
|
|
} |
| 46 |
|
|
return true; |
| 47 |
|
|
}; |
| 48 |
10/11
std::vector<unsigned long, std::allocator<unsigned long> > terraingen::python::(anonymous namespace)::SameShape<nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig>, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig>, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> >(char const*, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&):
✓ Branch 1 taken 8 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 1 time.
✓ Branch 6 taken 7 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 1 time.
✓ Branch 11 taken 7 times.
std::vector<unsigned long, std::allocator<unsigned long> > terraingen::python::(anonymous namespace)::SameShape<nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig>, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> >(char const*, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&):
✓ Branch 1 taken 39 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 37 times.
|
47 |
if (!(matches(more) && ...)) { |
| 49 |
6/6
std::vector<unsigned long, std::allocator<unsigned long> > terraingen::python::(anonymous namespace)::SameShape<nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig>, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig>, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> >(char const*, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&):
✓ Branch 2 taken 1 time.
✓ Branch 5 taken 1 time.
✓ Branch 8 taken 1 time.
std::vector<unsigned long, std::allocator<unsigned long> > terraingen::python::(anonymous namespace)::SameShape<nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig>, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> >(char const*, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&):
✓ Branch 2 taken 2 times.
✓ Branch 5 taken 2 times.
✓ Branch 8 taken 2 times.
|
9 |
throw std::invalid_argument(std::string(names) + " must have the same shape"); |
| 50 |
|
|
} |
| 51 |
|
88 |
return shape; |
| 52 |
|
3 |
} |
| 53 |
|
|
|
| 54 |
|
|
/// @brief A new float32 array of `shape`, owning `data`. |
| 55 |
|
48 |
OutputArray NewArray(const std::vector<std::size_t>& shape, std::size_t count, float*& data) { |
| 56 |
2/3
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 4 taken 48 times.
|
48 |
data = new float[count]; |
| 57 |
2/3
✓ Branch 2 taken 48 times.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
|
96 |
nb::capsule owner(data, [](void* p) noexcept { delete[] static_cast<float*>(p); }); |
| 58 |
1/1
✓ Branch 4 taken 48 times.
|
96 |
return OutputArray(data, shape.size(), shape.data(), owner); |
| 59 |
|
48 |
} |
| 60 |
|
|
|
| 61 |
|
|
/// @brief `fn(x, y)` at each point of two float32 arrays of one shape, without the GIL. |
| 62 |
|
37 |
template <typename Fn> OutputArray Evaluate(const InputArray& x, const InputArray& y, Fn fn) { |
| 63 |
5/5
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate<terraingen::python::(anonymous namespace)::BindFractal(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&) const::{lambda(float, float)#1}>(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindFractal(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&) const::{lambda(float, float)#1}):
✓ Branch 1 taken 28 times.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate<terraingen::python::(anonymous namespace)::BindLayerEvaluation(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&) const::{lambda(float, float)#1}>(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindLayerEvaluation(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&) const::{lambda(float, float)#1}):
✓ Branch 1 taken 3 times.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate<terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::PerlinAt>(nanobind::module_&, char const*, char const*)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(float, float)#1}>(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::PerlinAt>(nanobind::module_&, char const*, char const*)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(float, float)#1}):
✓ Branch 1 taken 1 time.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate<terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::SimplexAt>(nanobind::module_&, char const*, char const*)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(float, float)#1}>(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::SimplexAt>(nanobind::module_&, char const*, char const*)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(float, float)#1}):
✓ Branch 1 taken 3 times.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate<terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::ValueAt>(nanobind::module_&, char const*, char const*)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(float, float)#1}>(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::ValueAt>(nanobind::module_&, char const*, char const*)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(float, float)#1}):
✓ Branch 1 taken 1 time.
|
37 |
const std::vector<std::size_t> shape = SameShape("x and y", x, y); |
| 64 |
|
36 |
float* out = nullptr; |
| 65 |
10/10
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate<terraingen::python::(anonymous namespace)::BindFractal(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&) const::{lambda(float, float)#1}>(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindFractal(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&) const::{lambda(float, float)#1}):
✓ Branch 1 taken 28 times.
✓ Branch 4 taken 28 times.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate<terraingen::python::(anonymous namespace)::BindLayerEvaluation(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&) const::{lambda(float, float)#1}>(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindLayerEvaluation(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&) const::{lambda(float, float)#1}):
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate<terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::PerlinAt>(nanobind::module_&, char const*, char const*)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(float, float)#1}>(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::PerlinAt>(nanobind::module_&, char const*, char const*)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(float, float)#1}):
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate<terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::SimplexAt>(nanobind::module_&, char const*, char const*)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(float, float)#1}>(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::SimplexAt>(nanobind::module_&, char const*, char const*)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(float, float)#1}):
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate<terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::ValueAt>(nanobind::module_&, char const*, char const*)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(float, float)#1}>(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::ValueAt>(nanobind::module_&, char const*, char const*)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(float, float)#1}):
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
36 |
OutputArray result = NewArray(shape, x.size(), out); |
| 66 |
|
|
{ |
| 67 |
|
36 |
nb::gil_scoped_release release; |
| 68 |
15/15
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate<terraingen::python::(anonymous namespace)::BindFractal(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&) const::{lambda(float, float)#1}>(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindFractal(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&) const::{lambda(float, float)#1}):
✓ Branch 1 taken 44828 times.
✓ Branch 3 taken 44800 times.
✓ Branch 4 taken 28 times.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate<terraingen::python::(anonymous namespace)::BindLayerEvaluation(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&) const::{lambda(float, float)#1}>(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindLayerEvaluation(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&) const::{lambda(float, float)#1}):
✓ Branch 1 taken 158 times.
✓ Branch 3 taken 155 times.
✓ Branch 4 taken 3 times.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate<terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::PerlinAt>(nanobind::module_&, char const*, char const*)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(float, float)#1}>(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::PerlinAt>(nanobind::module_&, char const*, char const*)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(float, float)#1}):
✓ Branch 1 taken 43 times.
✓ Branch 3 taken 42 times.
✓ Branch 4 taken 1 time.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate<terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::SimplexAt>(nanobind::module_&, char const*, char const*)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(float, float)#1}>(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::SimplexAt>(nanobind::module_&, char const*, char const*)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(float, float)#1}):
✓ Branch 1 taken 67 times.
✓ Branch 3 taken 64 times.
✓ Branch 4 taken 3 times.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate<terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::ValueAt>(nanobind::module_&, char const*, char const*)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(float, float)#1}>(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::ValueAt>(nanobind::module_&, char const*, char const*)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(float, float)#1}):
✓ Branch 1 taken 43 times.
✓ Branch 3 taken 42 times.
✓ Branch 4 taken 1 time.
|
45139 |
for (std::size_t i = 0; i < x.size(); ++i) { |
| 69 |
2/2
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate<terraingen::python::(anonymous namespace)::BindFractal(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&) const::{lambda(float, float)#1}>(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindFractal(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&) const::{lambda(float, float)#1}):
✓ Branch 3 taken 44800 times.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate<terraingen::python::(anonymous namespace)::BindLayerEvaluation(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&) const::{lambda(float, float)#1}>(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindLayerEvaluation(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&) const::{lambda(float, float)#1}):
✓ Branch 3 taken 155 times.
|
45103 |
out[i] = fn(x.data()[i], y.data()[i]); |
| 70 |
|
|
} |
| 71 |
|
36 |
} |
| 72 |
|
72 |
return result; |
| 73 |
|
36 |
} |
| 74 |
|
|
|
| 75 |
|
|
/// @brief `fn(x, y, z)` at each point of three float64 arrays of one shape, as float32. |
| 76 |
|
|
template <typename Fn> |
| 77 |
|
7 |
OutputArray Evaluate3(const InputArray64& x, const InputArray64& y, const InputArray64& z, Fn fn) { |
| 78 |
4/4
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate3<terraingen::python::(anonymous namespace)::BindBasisNoise3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(double, double, double)#1}>(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindBasisNoise3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(double, double, double)#1}):
✓ Branch 1 taken 1 time.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate3<terraingen::python::(anonymous namespace)::BindBasisNoise3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#2}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(double, double, double)#1}>(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindBasisNoise3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#2}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(double, double, double)#1}):
✓ Branch 1 taken 2 times.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate3<terraingen::python::(anonymous namespace)::BindFractal3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&) const::{lambda(double, double, double)#1}>(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindFractal3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&) const::{lambda(double, double, double)#1}):
✓ Branch 1 taken 2 times.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate3<terraingen::python::(anonymous namespace)::BindFractal3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&) const::{lambda(double, double, double)#1}>(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindFractal3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&) const::{lambda(double, double, double)#1}):
✓ Branch 1 taken 1 time.
|
7 |
const std::vector<std::size_t> shape = SameShape("x, y and z", x, y, z); |
| 79 |
|
6 |
float* out = nullptr; |
| 80 |
8/8
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate3<terraingen::python::(anonymous namespace)::BindBasisNoise3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(double, double, double)#1}>(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindBasisNoise3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(double, double, double)#1}):
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate3<terraingen::python::(anonymous namespace)::BindBasisNoise3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#2}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(double, double, double)#1}>(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindBasisNoise3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#2}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(double, double, double)#1}):
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate3<terraingen::python::(anonymous namespace)::BindFractal3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&) const::{lambda(double, double, double)#1}>(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindFractal3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&) const::{lambda(double, double, double)#1}):
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate3<terraingen::python::(anonymous namespace)::BindFractal3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&) const::{lambda(double, double, double)#1}>(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindFractal3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&) const::{lambda(double, double, double)#1}):
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
|
6 |
OutputArray result = NewArray(shape, x.size(), out); |
| 81 |
|
|
{ |
| 82 |
|
6 |
nb::gil_scoped_release release; |
| 83 |
12/12
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate3<terraingen::python::(anonymous namespace)::BindBasisNoise3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(double, double, double)#1}>(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindBasisNoise3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(double, double, double)#1}):
✓ Branch 1 taken 4 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 1 time.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate3<terraingen::python::(anonymous namespace)::BindBasisNoise3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#2}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(double, double, double)#1}>(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindBasisNoise3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#2}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(double, double, double)#1}):
✓ Branch 1 taken 15 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 2 times.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate3<terraingen::python::(anonymous namespace)::BindFractal3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&) const::{lambda(double, double, double)#1}>(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindFractal3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&) const::{lambda(double, double, double)#1}):
✓ Branch 1 taken 8 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 2 times.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate3<terraingen::python::(anonymous namespace)::BindFractal3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&) const::{lambda(double, double, double)#1}>(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindFractal3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&) const::{lambda(double, double, double)#1}):
✓ Branch 1 taken 4 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 1 time.
|
31 |
for (std::size_t i = 0; i < x.size(); ++i) { |
| 84 |
4/4
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate3<terraingen::python::(anonymous namespace)::BindBasisNoise3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(double, double, double)#1}>(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindBasisNoise3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(double, double, double)#1}):
✓ Branch 4 taken 3 times.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate3<terraingen::python::(anonymous namespace)::BindBasisNoise3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#2}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(double, double, double)#1}>(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindBasisNoise3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#2}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(double, double, double)#1}):
✓ Branch 4 taken 13 times.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate3<terraingen::python::(anonymous namespace)::BindFractal3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&) const::{lambda(double, double, double)#1}>(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindFractal3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::FractalParams const&) const::{lambda(double, double, double)#1}):
✓ Branch 4 taken 6 times.
nanobind::ndarray<nanobind::numpy, float> terraingen::python::(anonymous namespace)::Evaluate3<terraingen::python::(anonymous namespace)::BindFractal3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&) const::{lambda(double, double, double)#1}>(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::python::(anonymous namespace)::BindFractal3(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, terraingen::SyntheticTerrainParams const&) const::{lambda(double, double, double)#1}):
✓ Branch 4 taken 3 times.
|
25 |
out[i] = fn(x.data()[i], y.data()[i], z.data()[i]); |
| 85 |
|
|
} |
| 86 |
|
6 |
} |
| 87 |
|
12 |
return result; |
| 88 |
|
6 |
} |
| 89 |
|
|
|
| 90 |
|
44 |
void BindHashes(nb::module_& m) { |
| 91 |
2/2
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
|
44 |
m.def("pcg_hash", &PcgHash, "v"_a, "PCG hash of one 32-bit word (Jarzynski and Olano 2020)."); |
| 92 |
1/1
✓ Branch 1 taken 44 times.
|
44 |
m.def( |
| 93 |
|
|
"pcg3d_hash", |
| 94 |
|
✗ |
[](std::uint32_t x, std::uint32_t y, std::uint32_t z) { |
| 95 |
|
1 |
const UVec3 h = Pcg3dHash(UVec3{x, y, z}); |
| 96 |
1/1
✓ Branch 1 taken 1 time.
|
2 |
return nb::make_tuple(h.x, h.y, h.z); |
| 97 |
|
|
}, |
| 98 |
3/3
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
|
44 |
"x"_a, "y"_a, "z"_a, "pcg3d hash of three 32-bit words (Jarzynski and Olano 2020)."); |
| 99 |
2/2
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
|
44 |
m.def("hash_to_unit_float", &HashToUnitFloat, "hash"_a, |
| 100 |
|
|
"Map a hash to a float in [0, 1) using its top 24 bits."); |
| 101 |
|
44 |
} |
| 102 |
|
|
|
| 103 |
|
|
/// @brief Binds `name` for arrays and for one point. |
| 104 |
|
|
template <float (*Noise)(float, float, std::uint32_t)> |
| 105 |
|
132 |
void BindScalarNoise(nb::module_& m, const char* name, const char* doc) { |
| 106 |
3/3
void terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::PerlinAt>(nanobind::module_&, char const*, char const*):
✓ Branch 1 taken 44 times.
void terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::SimplexAt>(nanobind::module_&, char const*, char const*):
✓ Branch 1 taken 44 times.
void terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::ValueAt>(nanobind::module_&, char const*, char const*):
✓ Branch 1 taken 44 times.
|
132 |
m.def( |
| 107 |
|
|
name, |
| 108 |
|
✗ |
[](const InputArray& x, const InputArray& y, std::uint32_t seed) { |
| 109 |
|
|
return Evaluate(x, y, [seed](float px, float py) { return Noise(px, py, seed); }); |
| 110 |
|
|
}, |
| 111 |
9/9
void terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::PerlinAt>(nanobind::module_&, char const*, char const*):
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
void terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::SimplexAt>(nanobind::module_&, char const*, char const*):
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
void terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::ValueAt>(nanobind::module_&, char const*, char const*):
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
|
132 |
"x"_a, "y"_a, "seed"_a, doc); |
| 112 |
3/3
void terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::PerlinAt>(nanobind::module_&, char const*, char const*):
✓ Branch 1 taken 44 times.
void terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::SimplexAt>(nanobind::module_&, char const*, char const*):
✓ Branch 1 taken 44 times.
void terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::ValueAt>(nanobind::module_&, char const*, char const*):
✓ Branch 1 taken 44 times.
|
132 |
m.def( |
| 113 |
6/6
void terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::PerlinAt>(nanobind::module_&, char const*, char const*):
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
void terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::SimplexAt>(nanobind::module_&, char const*, char const*):
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
void terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::ValueAt>(nanobind::module_&, char const*, char const*):
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
|
132 |
name, [](float x, float y, std::uint32_t seed) { return Noise(x, y, seed); }, "x"_a, "y"_a, |
| 114 |
3/3
void terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::PerlinAt>(nanobind::module_&, char const*, char const*):
✓ Branch 1 taken 44 times.
void terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::SimplexAt>(nanobind::module_&, char const*, char const*):
✓ Branch 1 taken 44 times.
void terraingen::python::(anonymous namespace)::BindScalarNoise<&terraingen::python::(anonymous namespace)::ValueAt>(nanobind::module_&, char const*, char const*):
✓ Branch 1 taken 44 times.
|
132 |
"seed"_a); |
| 115 |
|
132 |
} |
| 116 |
|
|
|
| 117 |
|
25685 |
float PerlinAt(float x, float y, std::uint32_t seed) { |
| 118 |
|
25685 |
return PerlinNoise2(x, y, seed); |
| 119 |
|
|
} |
| 120 |
|
|
|
| 121 |
|
25708 |
float SimplexAt(float x, float y, std::uint32_t seed) { |
| 122 |
|
25708 |
return SimplexNoise2(x, y, seed); |
| 123 |
|
|
} |
| 124 |
|
|
|
| 125 |
|
25686 |
float ValueAt(float x, float y, std::uint32_t seed) { |
| 126 |
|
25686 |
return ValueNoise2(x, y, seed); |
| 127 |
|
|
} |
| 128 |
|
|
|
| 129 |
|
|
/// F1, F2 and the cell value of `worley(i)` for each of `count` points, as arrays of `shape`. |
| 130 |
|
|
template <typename Worley> |
| 131 |
|
2 |
nb::tuple WorleyArrays(const std::vector<std::size_t>& shape, std::size_t count, |
| 132 |
|
|
const Worley& worley) { |
| 133 |
|
2 |
float* f1 = nullptr; |
| 134 |
|
2 |
float* f2 = nullptr; |
| 135 |
|
2 |
float* value = nullptr; |
| 136 |
2/2
nanobind::tuple terraingen::python::(anonymous namespace)::WorleyArrays<terraingen::python::(anonymous namespace)::BindBasisNoise(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(unsigned long)#1}>(std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, terraingen::python::(anonymous namespace)::BindBasisNoise(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(unsigned long)#1} const&):
✓ Branch 1 taken 1 time.
nanobind::tuple terraingen::python::(anonymous namespace)::WorleyArrays<terraingen::python::(anonymous namespace)::BindBasisNoise(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(unsigned long)#1}>(std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, terraingen::python::(anonymous namespace)::BindBasisNoise(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(unsigned long)#1} const&):
✓ Branch 1 taken 1 time.
|
2 |
OutputArray first = NewArray(shape, count, f1); |
| 137 |
2/2
nanobind::tuple terraingen::python::(anonymous namespace)::WorleyArrays<terraingen::python::(anonymous namespace)::BindBasisNoise(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(unsigned long)#1}>(std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, terraingen::python::(anonymous namespace)::BindBasisNoise(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(unsigned long)#1} const&):
✓ Branch 1 taken 1 time.
nanobind::tuple terraingen::python::(anonymous namespace)::WorleyArrays<terraingen::python::(anonymous namespace)::BindBasisNoise(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(unsigned long)#1}>(std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, terraingen::python::(anonymous namespace)::BindBasisNoise(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(unsigned long)#1} const&):
✓ Branch 1 taken 1 time.
|
2 |
OutputArray second = NewArray(shape, count, f2); |
| 138 |
2/2
nanobind::tuple terraingen::python::(anonymous namespace)::WorleyArrays<terraingen::python::(anonymous namespace)::BindBasisNoise(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(unsigned long)#1}>(std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, terraingen::python::(anonymous namespace)::BindBasisNoise(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(unsigned long)#1} const&):
✓ Branch 1 taken 1 time.
nanobind::tuple terraingen::python::(anonymous namespace)::WorleyArrays<terraingen::python::(anonymous namespace)::BindBasisNoise(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(unsigned long)#1}>(std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, terraingen::python::(anonymous namespace)::BindBasisNoise(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(unsigned long)#1} const&):
✓ Branch 1 taken 1 time.
|
2 |
OutputArray cell = NewArray(shape, count, value); |
| 139 |
|
|
{ |
| 140 |
|
2 |
nb::gil_scoped_release release; |
| 141 |
4/4
nanobind::tuple terraingen::python::(anonymous namespace)::WorleyArrays<terraingen::python::(anonymous namespace)::BindBasisNoise(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(unsigned long)#1}>(std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, terraingen::python::(anonymous namespace)::BindBasisNoise(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(unsigned long)#1} const&):
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1 time.
nanobind::tuple terraingen::python::(anonymous namespace)::WorleyArrays<terraingen::python::(anonymous namespace)::BindBasisNoise(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(unsigned long)#1}>(std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, terraingen::python::(anonymous namespace)::BindBasisNoise(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(unsigned long)#1} const&):
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 1 time.
|
34 |
for (std::size_t i = 0; i < count; ++i) { |
| 142 |
2/2
nanobind::tuple terraingen::python::(anonymous namespace)::WorleyArrays<terraingen::python::(anonymous namespace)::BindBasisNoise(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(unsigned long)#1}>(std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, terraingen::python::(anonymous namespace)::BindBasisNoise(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(unsigned long)#1} const&):
✓ Branch 1 taken 20 times.
nanobind::tuple terraingen::python::(anonymous namespace)::WorleyArrays<terraingen::python::(anonymous namespace)::BindBasisNoise(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(unsigned long)#1}>(std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, terraingen::python::(anonymous namespace)::BindBasisNoise(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(unsigned long)#1} const&):
✓ Branch 1 taken 12 times.
|
32 |
const WorleyDistances d = worley(i); |
| 143 |
|
32 |
f1[i] = d.f1; |
| 144 |
|
32 |
f2[i] = d.f2; |
| 145 |
|
32 |
value[i] = d.value; |
| 146 |
|
|
} |
| 147 |
|
2 |
} |
| 148 |
2/2
nanobind::tuple terraingen::python::(anonymous namespace)::WorleyArrays<terraingen::python::(anonymous namespace)::BindBasisNoise(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(unsigned long)#1}>(std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, terraingen::python::(anonymous namespace)::BindBasisNoise(nanobind::module_&)::{lambda(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<double const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(unsigned long)#1} const&):
✓ Branch 1 taken 1 time.
nanobind::tuple terraingen::python::(anonymous namespace)::WorleyArrays<terraingen::python::(anonymous namespace)::BindBasisNoise(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(unsigned long)#1}>(std::vector<unsigned long, std::allocator<unsigned long> > const&, unsigned long, terraingen::python::(anonymous namespace)::BindBasisNoise(nanobind::module_&)::{lambda(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int)#1}::operator()(nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, nanobind::ndarray<float const, nanobind::device::cpu, nanobind::c_contig> const&, unsigned int) const::{lambda(unsigned long)#1} const&):
✓ Branch 1 taken 1 time.
|
4 |
return nb::make_tuple(first, second, cell); |
| 149 |
|
2 |
} |
| 150 |
|
|
|
| 151 |
|
51203 |
nb::tuple WorleyTuple(const WorleyDistances& d) { |
| 152 |
|
51203 |
return nb::make_tuple(d.f1, d.f2, d.value); |
| 153 |
|
|
} |
| 154 |
|
|
|
| 155 |
|
44 |
void BindBasisNoise(nb::module_& m) { |
| 156 |
|
25729 |
BindScalarNoise<&PerlinAt>(m, "perlin_noise2", |
| 157 |
|
|
"Improved Perlin noise (Perlin 2002) in [-1, 1], in lattice units."); |
| 158 |
|
25752 |
BindScalarNoise<&SimplexAt>(m, "simplex_noise2", |
| 159 |
|
|
"Simplex noise (Perlin 2001, Gustavson 2005) in [-1, 1]."); |
| 160 |
|
25730 |
BindScalarNoise<&ValueAt>(m, "value_noise2", "Value noise in [-1, 1], in lattice units."); |
| 161 |
1/1
✓ Branch 1 taken 44 times.
|
44 |
m.def( |
| 162 |
|
|
"worley2", |
| 163 |
|
✗ |
[](const InputArray& x, const InputArray& y, std::uint32_t seed) { |
| 164 |
|
2 |
return WorleyArrays(SameShape("x and y", x, y), x.size(), [&](std::size_t i) { |
| 165 |
|
12 |
return Worley2(x.data()[i], y.data()[i], seed); |
| 166 |
3/3
✓ Branch 1 taken 2 times.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
3 |
}); |
| 167 |
|
|
}, |
| 168 |
3/3
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
|
44 |
"x"_a, "y"_a, "seed"_a, |
| 169 |
|
|
"Worley cellular noise (Worley 1996) in lattice units: the distances (F1, F2) to the " |
| 170 |
|
|
"nearest and second-nearest feature points, and the nearest point's Voronoi cell value in " |
| 171 |
|
|
"[-1, 1)."); |
| 172 |
1/1
✓ Branch 1 taken 44 times.
|
44 |
m.def( |
| 173 |
|
|
"worley2", |
| 174 |
1/1
✓ Branch 2 taken 51202 times.
|
51202 |
[](float x, float y, std::uint32_t seed) { return WorleyTuple(Worley2(x, y, seed)); }, |
| 175 |
3/3
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
|
44 |
"x"_a, "y"_a, "seed"_a); |
| 176 |
1/1
✓ Branch 1 taken 44 times.
|
44 |
m.def( |
| 177 |
|
|
"worley3", |
| 178 |
|
✗ |
[](const InputArray64& x, const InputArray64& y, const InputArray64& z, |
| 179 |
|
|
std::uint32_t seed) { |
| 180 |
|
1 |
return WorleyArrays(SameShape("x, y and z", x, y, z), x.size(), [&](std::size_t i) { |
| 181 |
|
20 |
return Worley3(SplitLatticePrecise3(x.data()[i], y.data()[i], z.data()[i]), seed); |
| 182 |
3/3
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
|
2 |
}); |
| 183 |
|
|
}, |
| 184 |
4/4
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
✓ Branch 10 taken 44 times.
|
44 |
"x"_a, "y"_a, "z"_a, "seed"_a, |
| 185 |
|
|
"3D Worley cellular noise in lattice units, as `worley2`: (F1, F2, cell value); the cell " |
| 186 |
|
|
"is found in double precision."); |
| 187 |
1/1
✓ Branch 1 taken 44 times.
|
44 |
m.def( |
| 188 |
|
|
"worley3", |
| 189 |
|
✗ |
[](double x, double y, double z, std::uint32_t seed) { |
| 190 |
1/1
✓ Branch 3 taken 1 time.
|
1 |
return WorleyTuple(Worley3(SplitLatticePrecise3(x, y, z), seed)); |
| 191 |
|
|
}, |
| 192 |
4/4
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
✓ Branch 10 taken 44 times.
|
44 |
"x"_a, "y"_a, "z"_a, "seed"_a); |
| 193 |
|
44 |
} |
| 194 |
|
|
|
| 195 |
|
44 |
void BindEnums(nb::module_& m) { |
| 196 |
|
88 |
nb::enum_<NoiseBasis>(m, "NoiseBasis", "Single-octave noise a fractal is built from.") |
| 197 |
|
44 |
.value("PERLIN", NoiseBasis::Perlin) |
| 198 |
|
44 |
.value("SIMPLEX", NoiseBasis::Simplex) |
| 199 |
|
44 |
.value("VALUE", NoiseBasis::Value) |
| 200 |
|
44 |
.value("WORLEY_F1", NoiseBasis::WorleyF1) |
| 201 |
|
44 |
.value("WORLEY_F2", NoiseBasis::WorleyF2) |
| 202 |
|
44 |
.value("WORLEY_F2_MINUS_F1", NoiseBasis::WorleyF2MinusF1) |
| 203 |
|
|
.value("VORONOI", NoiseBasis::Voronoi); |
| 204 |
|
88 |
nb::enum_<FractalType>(m, "FractalType", "How octaves of the basis noise are combined.") |
| 205 |
|
44 |
.value("FBM", FractalType::Fbm) |
| 206 |
|
44 |
.value("RIDGED", FractalType::Ridged) |
| 207 |
|
44 |
.value("BILLOW", FractalType::Billow) |
| 208 |
|
|
.value("HYBRID_MULTIFRACTAL", FractalType::HybridMultifractal); |
| 209 |
|
88 |
nb::enum_<LayerBlend>(m, "LayerBlend", |
| 210 |
|
|
"How a layer combines with the height of the layers before it.") |
| 211 |
|
44 |
.value("ADD", LayerBlend::Add) |
| 212 |
|
44 |
.value("MAX", LayerBlend::Max) |
| 213 |
|
44 |
.value("MIN", LayerBlend::Min) |
| 214 |
|
|
.value("MASK", LayerBlend::Mask); |
| 215 |
|
44 |
} |
| 216 |
|
|
|
| 217 |
|
44 |
void BindFractalParams(nb::module_& m) { |
| 218 |
|
✗ |
nb::class_<FractalParams>(m, "FractalParams", |
| 219 |
|
|
"Fractal of a basis noise. Octave i has wavelength " |
| 220 |
|
|
"wavelength / lacunarity**i and weight gain**i.") |
| 221 |
|
44 |
.def( |
| 222 |
|
|
"__init__", |
| 223 |
|
✗ |
[](FractalParams* p, std::uint32_t seed, float wavelength, float amplitude, int octaves, |
| 224 |
|
|
float lacunarity, float gain, NoiseBasis basis, FractalType type, float offset) { |
| 225 |
|
266 |
new (p) FractalParams{seed, wavelength, amplitude, octaves, lacunarity, |
| 226 |
|
133 |
gain, basis, type, offset}; |
| 227 |
|
133 |
}, |
| 228 |
4/4
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
✓ Branch 10 taken 44 times.
|
220 |
"seed"_a = 0u, "wavelength"_a = 1000.0f, "amplitude"_a = 100.0f, "octaves"_a = 8, |
| 229 |
3/3
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
|
176 |
"lacunarity"_a = 2.0f, "gain"_a = 0.5f, "basis"_a = NoiseBasis::Perlin, |
| 230 |
2/2
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
|
132 |
"type"_a = FractalType::Fbm, "offset"_a = 1.0f) |
| 231 |
|
44 |
.def_rw("seed", &FractalParams::seed) |
| 232 |
|
44 |
.def_rw("wavelength", &FractalParams::wavelength, "First-octave wavelength in metres.") |
| 233 |
|
44 |
.def_rw("amplitude", &FractalParams::amplitude, "Maximum absolute height in metres.") |
| 234 |
|
44 |
.def_rw("octaves", &FractalParams::octaves) |
| 235 |
|
44 |
.def_rw("lacunarity", &FractalParams::lacunarity) |
| 236 |
|
44 |
.def_rw("gain", &FractalParams::gain) |
| 237 |
|
44 |
.def_rw("basis", &FractalParams::basis) |
| 238 |
|
44 |
.def_rw("type", &FractalParams::type) |
| 239 |
|
44 |
.def_rw("offset", &FractalParams::offset, "Ridge offset for ridged and hybrid fractals.") |
| 240 |
1/1
✓ Branch 2 taken 44 times.
|
44 |
.def(nb::self == nb::self); |
| 241 |
|
44 |
} |
| 242 |
|
|
|
| 243 |
|
44 |
void BindFractal(nb::module_& m) { |
| 244 |
|
44 |
BindFractalParams(m); |
| 245 |
3/3
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
|
88 |
m.def("gain_from_hurst", &GainFromHurst, "hurst"_a, "lacunarity"_a = 2.0f, |
| 246 |
|
|
"Octave gain lacunarity**(-hurst) that gives Hurst exponent `hurst`."); |
| 247 |
5/5
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
✓ Branch 10 taken 44 times.
✓ Branch 13 taken 44 times.
|
44 |
m.def("basis_noise2", &BasisNoise2, "basis"_a, "x"_a, "y"_a, "seed"_a, |
| 248 |
|
|
"One octave of `basis` noise in [-1, 1], in lattice units."); |
| 249 |
2/2
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
|
44 |
m.def("validate_fractal_params", &ValidateFractalParams, "params"_a, |
| 250 |
|
|
"Raise ValueError if the parameters are unusable."); |
| 251 |
1/1
✓ Branch 1 taken 44 times.
|
44 |
m.def( |
| 252 |
|
|
"fractal2", |
| 253 |
|
✗ |
[](const InputArray& x, const InputArray& y, const FractalParams& params) { |
| 254 |
|
28 |
ValidateFractalParams(params); |
| 255 |
|
|
return Evaluate(x, y, |
| 256 |
|
44828 |
[¶ms](float px, float py) { return Fractal2(px, py, params); }); |
| 257 |
|
|
}, |
| 258 |
3/3
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
|
44 |
"x"_a, "y"_a, "params"_a, "Fractal height in metres at each world position (x, y)."); |
| 259 |
1/1
✓ Branch 1 taken 44 times.
|
44 |
m.def( |
| 260 |
|
|
"fractal2", |
| 261 |
|
✗ |
[](float x, float y, const FractalParams& params) { |
| 262 |
|
102405 |
ValidateFractalParams(params); |
| 263 |
|
102404 |
return Fractal2(x, y, params); |
| 264 |
|
|
}, |
| 265 |
3/3
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
|
44 |
"x"_a, "y"_a, "params"_a); |
| 266 |
|
44 |
} |
| 267 |
|
|
|
| 268 |
|
44 |
void BindNoiseLayer(nb::module_& m) { |
| 269 |
|
44 |
nb::class_<NoiseLayer>(m, "NoiseLayer", |
| 270 |
|
|
"One layer of a synthetic terrain: a fractal, an optional domain warp " |
| 271 |
|
|
"and a blend mode.") |
| 272 |
|
44 |
.def( |
| 273 |
|
|
"__init__", |
| 274 |
|
✗ |
[](NoiseLayer* layer, std::optional<FractalParams> fractal, bool enabled, |
| 275 |
|
|
LayerBlend blend, float warpAmplitude, float warpWavelength) { |
| 276 |
|
282 |
new (layer) NoiseLayer{enabled, fractal.value_or(FractalParams{}), blend, |
| 277 |
|
94 |
warpAmplitude, warpWavelength}; |
| 278 |
|
94 |
}, |
| 279 |
3/3
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
|
176 |
"fractal"_a = nb::none(), "enabled"_a = true, "blend"_a = LayerBlend::Add, |
| 280 |
2/2
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
|
132 |
"warp_amplitude"_a = 0.0f, "warp_wavelength"_a = 500.0f) |
| 281 |
|
44 |
.def_rw("enabled", &NoiseLayer::enabled) |
| 282 |
|
44 |
.def_rw("fractal", &NoiseLayer::fractal) |
| 283 |
|
44 |
.def_rw("blend", &NoiseLayer::blend) |
| 284 |
|
44 |
.def_rw("warp_amplitude", &NoiseLayer::warpAmplitude, "Domain warp in metres; 0 is off.") |
| 285 |
|
44 |
.def_rw("warp_wavelength", &NoiseLayer::warpWavelength, "Warp field wavelength in metres.") |
| 286 |
1/1
✓ Branch 2 taken 44 times.
|
44 |
.def(nb::self == nb::self); |
| 287 |
2/2
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
|
44 |
m.attr("MAX_NOISE_LAYERS") = kMaxNoiseLayers; |
| 288 |
2/2
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
|
44 |
m.def("validate_noise_layer", &ValidateNoiseLayer, "layer"_a, |
| 289 |
|
|
"Raise ValueError if the layer is unusable."); |
| 290 |
|
44 |
} |
| 291 |
|
|
|
| 292 |
|
44 |
void BindLayerEvaluation(nb::module_& m) { |
| 293 |
1/1
✓ Branch 1 taken 44 times.
|
44 |
m.def( |
| 294 |
|
|
"evaluate_noise_layers", |
| 295 |
|
✗ |
[](const InputArray& x, const InputArray& y, const SyntheticTerrainParams& params) { |
| 296 |
|
3 |
ValidateSyntheticTerrain(params); |
| 297 |
|
155 |
return Evaluate(x, y, [¶ms](float px, float py) { |
| 298 |
|
155 |
return EvaluateNoiseLayers(px, py, params.layers.data(), params.layers.size()); |
| 299 |
|
3 |
}); |
| 300 |
|
|
}, |
| 301 |
3/3
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
|
44 |
"x"_a, "y"_a, "params"_a, "Height in metres of the layer stack at each world position."); |
| 302 |
1/1
✓ Branch 1 taken 44 times.
|
44 |
m.def( |
| 303 |
|
|
"evaluate_noise_layer", |
| 304 |
|
✗ |
[](float x, float y, const NoiseLayer& layer) { |
| 305 |
|
1 |
ValidateNoiseLayer(layer); |
| 306 |
|
1 |
return EvaluateNoiseLayer(x, y, layer); |
| 307 |
|
|
}, |
| 308 |
3/3
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
|
44 |
"x"_a, "y"_a, "layer"_a, |
| 309 |
|
|
"The normalized value in [-1, 1] of one layer at world position (x, y), before amplitude " |
| 310 |
|
|
"and blending."); |
| 311 |
1/1
✓ Branch 1 taken 44 times.
|
44 |
m.def( |
| 312 |
|
|
"domain_warp2", |
| 313 |
|
✗ |
[](float x, float y, const NoiseLayer& layer) { |
| 314 |
1/1
✓ Branch 1 taken 1 time.
|
1 |
const WarpOffset2 offset = DomainWarp2(x, y, layer); |
| 315 |
1/1
✓ Branch 1 taken 1 time.
|
2 |
return nb::make_tuple(offset.dx, offset.dy); |
| 316 |
|
|
}, |
| 317 |
3/3
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
|
44 |
"x"_a, "y"_a, "layer"_a, |
| 318 |
|
|
"The domain warp offset (dx, dy) in metres a layer applies at world position (x, y)."); |
| 319 |
|
44 |
} |
| 320 |
|
|
|
| 321 |
|
44 |
void BindBasisNoise3(nb::module_& m) { |
| 322 |
1/1
✓ Branch 1 taken 44 times.
|
44 |
m.def( |
| 323 |
|
|
"perlin_noise3", |
| 324 |
|
✗ |
[](const InputArray64& x, const InputArray64& y, const InputArray64& z, |
| 325 |
|
|
std::uint32_t seed) { |
| 326 |
|
3 |
return Evaluate3(x, y, z, [seed](double px, double py, double pz) { |
| 327 |
|
3 |
return PerlinNoise3Precise(px, py, pz, seed); |
| 328 |
|
2 |
}); |
| 329 |
|
|
}, |
| 330 |
4/4
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
✓ Branch 10 taken 44 times.
|
44 |
"x"_a, "y"_a, "z"_a, "seed"_a, |
| 331 |
|
|
"3D improved Perlin noise in [-1, 1] at each point, in lattice units; the cell is found in " |
| 332 |
|
|
"double precision, so it stays exact far from the origin."); |
| 333 |
5/5
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
✓ Branch 10 taken 44 times.
✓ Branch 13 taken 44 times.
|
44 |
m.def("perlin_noise3", &PerlinNoise3Precise, "x"_a, "y"_a, "z"_a, "seed"_a); |
| 334 |
1/1
✓ Branch 1 taken 44 times.
|
44 |
m.def( |
| 335 |
|
|
"value_noise3", |
| 336 |
|
✗ |
[](double x, double y, double z, std::uint32_t seed) { |
| 337 |
|
1 |
return ValueNoise3(SplitLatticePrecise3(x, y, z), seed); |
| 338 |
|
|
}, |
| 339 |
4/4
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
✓ Branch 10 taken 44 times.
|
44 |
"x"_a, "y"_a, "z"_a, "seed"_a, "3D value noise in [-1, 1], in lattice units."); |
| 340 |
1/1
✓ Branch 1 taken 44 times.
|
44 |
m.def( |
| 341 |
|
|
"simplex_noise3", |
| 342 |
|
✗ |
[](const InputArray64& x, const InputArray64& y, const InputArray64& z, |
| 343 |
|
|
std::uint32_t seed) { |
| 344 |
|
13 |
return Evaluate3(x, y, z, [seed](double px, double py, double pz) { |
| 345 |
|
13 |
return SimplexNoise3(SplitLatticePrecise3(px, py, pz), seed); |
| 346 |
|
2 |
}); |
| 347 |
|
|
}, |
| 348 |
4/4
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
✓ Branch 10 taken 44 times.
|
44 |
"x"_a, "y"_a, "z"_a, "seed"_a, |
| 349 |
|
|
"3D simplex noise in [-1, 1] at each point, in lattice units; the cell is found in double " |
| 350 |
|
|
"precision, so it stays exact far from the origin."); |
| 351 |
1/1
✓ Branch 1 taken 44 times.
|
44 |
m.def( |
| 352 |
|
|
"simplex_noise3", |
| 353 |
|
✗ |
[](double x, double y, double z, std::uint32_t seed) { |
| 354 |
|
1 |
return SimplexNoise3(SplitLatticePrecise3(x, y, z), seed); |
| 355 |
|
|
}, |
| 356 |
4/4
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
✓ Branch 10 taken 44 times.
|
44 |
"x"_a, "y"_a, "z"_a, "seed"_a); |
| 357 |
1/1
✓ Branch 1 taken 44 times.
|
44 |
m.def( |
| 358 |
|
|
"basis_noise3", |
| 359 |
|
✗ |
[](NoiseBasis basis, std::int32_t ix, std::int32_t iy, std::int32_t iz, float fx, float fy, |
| 360 |
|
|
float fz, std::uint32_t seed) { |
| 361 |
|
2 |
return BasisNoise3(basis, LatticePoint3{ix, iy, iz, fx, fy, fz}, seed); |
| 362 |
|
|
}, |
| 363 |
8/8
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
✓ Branch 10 taken 44 times.
✓ Branch 13 taken 44 times.
✓ Branch 16 taken 44 times.
✓ Branch 19 taken 44 times.
✓ Branch 22 taken 44 times.
|
44 |
"basis"_a, "ix"_a, "iy"_a, "iz"_a, "fx"_a, "fy"_a, "fz"_a, "seed"_a, |
| 364 |
|
|
"One octave of 3D `basis` noise at lattice cell (ix, iy, iz) plus fraction (fx, fy, fz)."); |
| 365 |
|
44 |
} |
| 366 |
|
|
|
| 367 |
|
44 |
void BindFractal3(nb::module_& m) { |
| 368 |
1/1
✓ Branch 1 taken 44 times.
|
44 |
m.def( |
| 369 |
|
|
"fractal3", |
| 370 |
|
✗ |
[](const InputArray64& x, const InputArray64& y, const InputArray64& z, |
| 371 |
|
|
const FractalParams& params) { |
| 372 |
|
2 |
ValidateFractalParams(params); |
| 373 |
|
6 |
return Evaluate3(x, y, z, [¶ms](double px, double py, double pz) { |
| 374 |
|
6 |
return Fractal3(px, py, pz, params); |
| 375 |
|
2 |
}); |
| 376 |
|
|
}, |
| 377 |
4/4
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
✓ Branch 10 taken 44 times.
|
44 |
"x"_a, "y"_a, "z"_a, "params"_a, |
| 378 |
|
|
"Fractal height in metres at each 3D world position (m), as noise on a sphere uses it."); |
| 379 |
1/1
✓ Branch 1 taken 44 times.
|
44 |
m.def( |
| 380 |
|
|
"fractal3", |
| 381 |
|
✗ |
[](double x, double y, double z, const FractalParams& params) { |
| 382 |
|
1 |
ValidateFractalParams(params); |
| 383 |
|
1 |
return Fractal3(x, y, z, params); |
| 384 |
|
|
}, |
| 385 |
4/4
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
✓ Branch 10 taken 44 times.
|
44 |
"x"_a, "y"_a, "z"_a, "params"_a); |
| 386 |
1/1
✓ Branch 1 taken 44 times.
|
44 |
m.def( |
| 387 |
|
|
"evaluate_noise_layers3", |
| 388 |
|
✗ |
[](const InputArray64& x, const InputArray64& y, const InputArray64& z, |
| 389 |
|
|
const SyntheticTerrainParams& params) { |
| 390 |
|
1 |
ValidateSyntheticTerrain(params); |
| 391 |
|
3 |
return Evaluate3(x, y, z, [¶ms](double px, double py, double pz) { |
| 392 |
|
3 |
return EvaluateNoiseLayers3(px, py, pz, params.layers.data(), params.layers.size()); |
| 393 |
|
1 |
}); |
| 394 |
|
|
}, |
| 395 |
4/4
✓ Branch 1 taken 44 times.
✓ Branch 4 taken 44 times.
✓ Branch 7 taken 44 times.
✓ Branch 10 taken 44 times.
|
44 |
"x"_a, "y"_a, "z"_a, "params"_a, |
| 396 |
|
|
"Height in metres of the layer stack at each 3D world position (m)."); |
| 397 |
|
44 |
} |
| 398 |
|
|
|
| 399 |
|
|
} // namespace |
| 400 |
|
|
|
| 401 |
|
44 |
void BindNoise(nb::module_& m) { |
| 402 |
|
44 |
BindHashes(m); |
| 403 |
|
44 |
BindBasisNoise(m); |
| 404 |
|
44 |
BindEnums(m); |
| 405 |
|
44 |
BindFractal(m); |
| 406 |
|
44 |
BindNoiseLayer(m); |
| 407 |
|
44 |
BindLayerEvaluation(m); |
| 408 |
|
44 |
BindBasisNoise3(m); |
| 409 |
|
44 |
BindFractal3(m); |
| 410 |
|
44 |
} |
| 411 |
|
|
|
| 412 |
|
|
} // namespace terraingen::python |
| 413 |
|
|
|