载入中...
搜索中...
未找到
FoliageCluster.cpp
浏览该文件的文档.
24V3 cross(V3 a, V3 b) { return {a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x}; }
31float randomRange(std::mt19937 &rng, float lo, float hi) { return std::uniform_real_distribution<float>(lo, hi)(rng); }
60std::vector<V2> samplePlaneCentres(std::uint32_t seed, float radius, float minDistance, int maxLeaves) {
68 const float capSpacing = std::sqrt(2.f * kPi * radius * radius / (std::sqrt(3.f) * float(maxLeaves)));
72 const int squareBudget = int(1.3f * float(maxLeaves) * squareArea / std::max(kPi * radius * radius, 1e-6f)) + 8;
95void addPetal(MeshBuild &out, V3 center, V3 right, V3 forward, float size, float roll, float u0, float u1,
107 const V3 p = add(center, add(mul(axisX, kOutlineX[i] * size), mul(axisY, kOutlineY[i] * size)));
172 cap ? randomRange(rng, 0.f, 2.f * kPi) : yawPhase + (float(index) + randomRange(rng, 0.2f, 0.8f)) * yawStep;
175 const float tilt = cap ? ((index & 1) ? 1.f : -1.f) * randomRange(rng, 62.f, 86.f) * kPi / 180.f
177 const V3 planeNormal{std::sin(yaw) * std::cos(tilt), std::sin(tilt), std::cos(yaw) * std::cos(tilt)};
187 center, add(mul(right, std::cos(offsetAngle) * offsetR), mul(forward, std::sin(offsetAngle) * offsetR)));
189 const std::vector<V2> centers = samplePlaneCentres(desc.seed ^ (std::uint32_t(index + 1) * 2654435761u),
CPU triangle mesh from procedural mesh recipes (e.g. marching cubes). Positions/normals are xyz-packe...
Definition MeshBuild.h:19
std::vector< double > forward(const Policy &p, const Observation &o)
Forward.
Definition Learning.h:65
@ PointSet
Definition EvpackPointGraphLoader.h:12
int addFoliageCluster(MeshBuild &out, const FoliageClusterDesc &desc)
Append one blue-noise leaf cluster to a mesh.
Definition FoliageCluster.cpp:125
PointSet poissonDiskPoints(int width, int depth, float radius, uint32_t seed, int maxPoints)
Bridson blue-noise (Poisson disk) samples in a width x depth area (XZ, y=0).
Definition PointSet.cpp:502
Recipe for one stylized leaf cluster ("foliage card bundle").
Definition FoliageCluster.h:24