15 #include <wfmath/MersenneTwister.h>
16 #include <wfmath/intersect.h>
43 static const float plant_chance = 0.04f;
44 static const float plant_min_height = 5.f;
45 static const float plant_height_range = 20.f;
70 WFMath::AxisBox<2> bbox(m_area->
bbox());
76 int lx = I_ROUND(bbox.lowCorner().x()),
77 ly = I_ROUND(bbox.lowCorner().y()),
78 hx = I_ROUND(bbox.highCorner().x()),
79 hy = I_ROUND(bbox.highCorner().y());
81 PlantSpecies::const_iterator I;
82 PlantSpecies::const_iterator Iend = m_species.end();
84 for(
int j = ly; j < hy; ++j) {
85 for(
int i = lx; i < hx; ++i) {
89 double prob = m_randCache(i,j);
90 I = m_species.begin();
91 for (; I != Iend; ++I) {
93 if (prob >
species.m_probability) {
102 rng.seed((
int)(prob / I->m_probability * 123456));
104 Plant & plant = m_plants[i][j];
107 (rng.rand<WFMath::CoordType>() - 0.5f) *
species.m_deviation,
108 (rng.rand<WFMath::CoordType>() - 0.5f) *
species.m_deviation);
109 plant.
m_orientation = WFMath::Quaternion(2, rng.rand<WFMath::CoordType>() * 2 * WFMath::numeric_constants<WFMath::CoordType>::pi());