image: remove unneeded area query
This commit is contained in:
parent
da496d8162
commit
9db4dd5b08
@ -49,7 +49,6 @@ namespace util { namespace image {
|
|||||||
buffer<T> downsample (float factor) const;
|
buffer<T> downsample (float factor) const;
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
constexpr size_t area (void) const;
|
|
||||||
constexpr extent2u extent (void) const;
|
constexpr extent2u extent (void) const;
|
||||||
|
|
||||||
constexpr bool is_packed (void) const;
|
constexpr bool is_packed (void) const;
|
||||||
|
@ -20,15 +20,6 @@
|
|||||||
#define __UTIL_IMAGE_IPP
|
#define __UTIL_IMAGE_IPP
|
||||||
|
|
||||||
namespace util { namespace image {
|
namespace util { namespace image {
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
template <typename T>
|
|
||||||
constexpr size_t
|
|
||||||
buffer<T>::area (void) const
|
|
||||||
{
|
|
||||||
return w * h;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T>
|
||||||
constexpr extent2u
|
constexpr extent2u
|
||||||
|
@ -98,7 +98,7 @@ hydraulic_erode (util::image::buffer<float> &height, const unsigned ticks)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// evaporate water, deposit sediment
|
// evaporate water, deposit sediment
|
||||||
for (size_t i = 0; i < water.area (); ++i) {
|
for (size_t i = 0; i < water.extent ().area (); ++i) {
|
||||||
water[i] -= EVAPORATION;
|
water[i] -= EVAPORATION;
|
||||||
height[i] += SOLUBILITY * EVAPORATION;
|
height[i] += SOLUBILITY * EVAPORATION;
|
||||||
}
|
}
|
||||||
@ -107,8 +107,8 @@ hydraulic_erode (util::image::buffer<float> &height, const unsigned ticks)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// forcibly evaporate all remaining water.
|
// forcibly evaporate all remaining water.
|
||||||
CHECK_EQ (water.area (), height.area ());
|
CHECK_EQ (water.extent ().area (), height.extent ().area ());
|
||||||
for (size_t i = 0; i < water.area (); ++i)
|
for (size_t i = 0; i < water.extent ().area (); ++i)
|
||||||
height[i] += water[i] * SOLUBILITY;
|
height[i] += water[i] * SOLUBILITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +252,7 @@ adjust_ocean (util::image::buffer<float> &height,
|
|||||||
buckets[size_t (h * 255u)]++;
|
buckets[size_t (h * 255u)]++;
|
||||||
|
|
||||||
size_t pivot = 0;
|
size_t pivot = 0;
|
||||||
for (size_t accum = 0, target = size_t (percentage * height.area ()); pivot < buckets.size (); ++pivot) {
|
for (size_t accum = 0, target = size_t (percentage * height.extent ().area ()); pivot < buckets.size (); ++pivot) {
|
||||||
accum += buckets[pivot];
|
accum += buckets[pivot];
|
||||||
if (accum > target)
|
if (accum > target)
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user