mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
fix coding-stype
This commit is contained in:
parent
2012838899
commit
df3023db30
196 changed files with 2510 additions and 3945 deletions
|
@ -24,7 +24,8 @@ namespace sprout {
|
|||
// bilinear_interpolate
|
||||
//
|
||||
template<typename Color, typename Unit>
|
||||
inline SPROUT_CONSTEXPR Color bilinear_interpolate(
|
||||
inline SPROUT_CONSTEXPR Color
|
||||
bilinear_interpolate(
|
||||
Color const& c00, Color const& c01, Color const& c10, Color const& c11,
|
||||
Unit const& u, Unit const& v
|
||||
)
|
||||
|
|
|
@ -15,16 +15,18 @@ namespace sprout {
|
|||
// reflection
|
||||
//
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR auto color(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<0>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<0>(sprout::forward<T>(t)))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
color(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<0>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<0>(sprout::forward<T>(t)))
|
||||
{
|
||||
return sprout::darkroom::access::get<0>(sprout::forward<T>(t));
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR auto reflection(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<1>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<1>(sprout::forward<T>(t)))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
reflection(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::darkroom::access::get<1>(sprout::forward<T>(t))))
|
||||
-> decltype(sprout::darkroom::access::get<1>(sprout::forward<T>(t)))
|
||||
{
|
||||
return sprout::darkroom::access::get<1>(sprout::forward<T>(t));
|
||||
}
|
||||
|
@ -34,14 +36,18 @@ namespace sprout {
|
|||
// calc_reflection
|
||||
//
|
||||
template<typename Image, typename Unit>
|
||||
inline SPROUT_CONSTEXPR auto calc_color(Image&& t, Unit const& u, Unit const& v) SPROUT_NOEXCEPT
|
||||
-> decltype(sprout::forward<Image>(t).template operator()(u, v))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
calc_color(Image&& t, Unit const& u, Unit const& v)
|
||||
SPROUT_NOEXCEPT
|
||||
-> decltype(sprout::forward<Image>(t).template operator()(u, v))
|
||||
{
|
||||
return sprout::forward<Image>(t).template operator()(u, v);
|
||||
}
|
||||
template<typename Image, typename Unit>
|
||||
inline SPROUT_CONSTEXPR auto calc_reflection(Image&& t, Unit const& u, Unit const& v) SPROUT_NOEXCEPT
|
||||
-> decltype(sprout::forward<Image>(t).template operator()(u, v))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
calc_reflection(Image&& t, Unit const& u, Unit const& v)
|
||||
SPROUT_NOEXCEPT
|
||||
-> decltype(sprout::forward<Image>(t).template operator()(u, v))
|
||||
{
|
||||
return sprout::forward<Image>(t).template operator()(u, v);
|
||||
}
|
||||
|
@ -50,11 +56,12 @@ namespace sprout {
|
|||
// calc_material
|
||||
//
|
||||
template<typename Material, typename Unit>
|
||||
inline SPROUT_CONSTEXPR auto calc_material(Material const& mat, Unit const& u, Unit const& v)
|
||||
-> decltype(sprout::tuples::make_tuple(
|
||||
sprout::darkroom::materials::calc_color(sprout::darkroom::materials::color(mat), u, v),
|
||||
sprout::darkroom::materials::calc_reflection(sprout::darkroom::materials::reflection(mat), u, v)
|
||||
))
|
||||
inline SPROUT_CONSTEXPR auto
|
||||
calc_material(Material const& mat, Unit const& u, Unit const& v)
|
||||
-> decltype(sprout::tuples::make_tuple(
|
||||
sprout::darkroom::materials::calc_color(sprout::darkroom::materials::color(mat), u, v),
|
||||
sprout::darkroom::materials::calc_reflection(sprout::darkroom::materials::reflection(mat), u, v)
|
||||
))
|
||||
{
|
||||
return sprout::tuples::make_tuple(
|
||||
sprout::darkroom::materials::calc_color(sprout::darkroom::materials::color(mat), u, v),
|
||||
|
|
|
@ -17,7 +17,8 @@ namespace sprout {
|
|||
typedef Element result_type;
|
||||
typedef Scale unit_type;
|
||||
private:
|
||||
static SPROUT_CONSTEXPR unit_type fmod(unit_type const& n, unit_type const& d) {
|
||||
static SPROUT_CONSTEXPR unit_type
|
||||
fmod(unit_type const& n, unit_type const& d) {
|
||||
return n - std::intmax_t(n / d) * d;
|
||||
}
|
||||
private:
|
||||
|
@ -26,24 +27,19 @@ namespace sprout {
|
|||
unit_type scale_;
|
||||
private:
|
||||
template<typename Unit>
|
||||
SPROUT_CONSTEXPR result_type calc_1(Unit const& u, Unit const& v) const {
|
||||
return (u >= 0 && v >= 0) || (u < 0 && v < 0)
|
||||
? elem1_
|
||||
: elem2_
|
||||
;
|
||||
SPROUT_CONSTEXPR result_type
|
||||
calc_1(Unit const& u, Unit const& v) const {
|
||||
return (u >= 0 && v >= 0) || (u < 0 && v < 0) ? elem1_ : elem2_;
|
||||
}
|
||||
public:
|
||||
SPROUT_CONSTEXPR plaid_element(
|
||||
result_type const& elem1,
|
||||
result_type const& elem2,
|
||||
unit_type const& scale = 1
|
||||
)
|
||||
SPROUT_CONSTEXPR plaid_element(result_type const& elem1, result_type const& elem2, unit_type const& scale = 1)
|
||||
: elem1_(elem1)
|
||||
, elem2_(elem2)
|
||||
, scale_(scale)
|
||||
{}
|
||||
template<typename Unit>
|
||||
SPROUT_CONSTEXPR result_type operator()(Unit const& u, Unit const& v) const {
|
||||
SPROUT_CONSTEXPR result_type
|
||||
operator()(Unit const& u, Unit const& v) const {
|
||||
return calc_1(
|
||||
(u < 0
|
||||
? scale_ + fmod(u, scale_)
|
||||
|
@ -79,11 +75,10 @@ namespace sprout {
|
|||
inline SPROUT_CONSTEXPR sprout::tuples::tuple<
|
||||
sprout::darkroom::materials::plaid_element<Color>,
|
||||
sprout::darkroom::materials::plaid_element<Reflection>
|
||||
> make_plaid_material_image(
|
||||
Color const& col1,
|
||||
Color const& col2,
|
||||
Reflection const& ref1,
|
||||
Reflection const& ref2
|
||||
>
|
||||
make_plaid_material_image(
|
||||
Color const& col1, Color const& col2,
|
||||
Reflection const& ref1, Reflection const& ref2
|
||||
)
|
||||
{
|
||||
return sprout::tuples::make_tuple(
|
||||
|
@ -95,11 +90,10 @@ namespace sprout {
|
|||
inline SPROUT_CONSTEXPR sprout::tuples::tuple<
|
||||
sprout::darkroom::materials::plaid_element<Color, Unit>,
|
||||
sprout::darkroom::materials::plaid_element<Reflection, Unit>
|
||||
> make_plaid_material_image(
|
||||
Color const& col1,
|
||||
Color const& col2,
|
||||
Reflection const& ref1,
|
||||
Reflection const& ref2,
|
||||
>
|
||||
make_plaid_material_image(
|
||||
Color const& col1, Color const& col2,
|
||||
Reflection const& ref1, Reflection const& ref2,
|
||||
Unit const& scale
|
||||
)
|
||||
{
|
||||
|
|
|
@ -45,22 +45,28 @@ namespace sprout {
|
|||
interpolation_type::values interpolation_value_;
|
||||
texture_map_placement::values placement_value_;
|
||||
private:
|
||||
SPROUT_CONSTEXPR bool is_nearest() const {
|
||||
SPROUT_CONSTEXPR bool
|
||||
is_nearest() const {
|
||||
return interpolation_value_ == interpolation_type::nearest_neighbor;
|
||||
}
|
||||
SPROUT_CONSTEXPR bool is_bilinear() const {
|
||||
SPROUT_CONSTEXPR bool
|
||||
is_bilinear() const {
|
||||
return interpolation_value_ == interpolation_type::bilinear;
|
||||
}
|
||||
SPROUT_CONSTEXPR bool is_bicubic() const {
|
||||
SPROUT_CONSTEXPR bool
|
||||
is_bicubic() const {
|
||||
return interpolation_value_ == interpolation_type::bicubic;
|
||||
}
|
||||
SPROUT_CONSTEXPR bool is_tile() const {
|
||||
SPROUT_CONSTEXPR bool
|
||||
is_tile() const {
|
||||
return placement_value_ == texture_map_placement::tile;
|
||||
}
|
||||
SPROUT_CONSTEXPR bool is_once() const {
|
||||
SPROUT_CONSTEXPR bool
|
||||
is_once() const {
|
||||
return placement_value_ == texture_map_placement::once;
|
||||
}
|
||||
SPROUT_CONSTEXPR result_type get_color(unit_type const& x, unit_type const& y) const {
|
||||
SPROUT_CONSTEXPR result_type
|
||||
get_color(unit_type const& x, unit_type const& y) const {
|
||||
return is_tile()
|
||||
? texture_.get()(
|
||||
x < 0
|
||||
|
@ -78,11 +84,13 @@ namespace sprout {
|
|||
;
|
||||
}
|
||||
template<typename Unit>
|
||||
SPROUT_CONSTEXPR result_type calc_nearest(Unit const& x, Unit const& y) const {
|
||||
SPROUT_CONSTEXPR result_type
|
||||
calc_nearest(Unit const& x, Unit const& y) const {
|
||||
return get_color(x, y);
|
||||
}
|
||||
template<typename Unit>
|
||||
SPROUT_CONSTEXPR result_type calc_bilinear_1(
|
||||
SPROUT_CONSTEXPR result_type
|
||||
calc_bilinear_1(
|
||||
Unit const& x, Unit const& x0,
|
||||
Unit const& y, Unit const& y0
|
||||
) const
|
||||
|
@ -94,24 +102,24 @@ namespace sprout {
|
|||
);
|
||||
}
|
||||
template<typename Unit>
|
||||
SPROUT_CONSTEXPR result_type calc_bilinear(Unit const& x, Unit const& y) const {
|
||||
SPROUT_CONSTEXPR result_type
|
||||
calc_bilinear(Unit const& x, Unit const& y) const {
|
||||
return calc_bilinear_1(
|
||||
x, sprout::floor(x),
|
||||
y, sprout::floor(y)
|
||||
);
|
||||
}
|
||||
template<typename Unit>
|
||||
SPROUT_CONSTEXPR result_type calc(Unit const& x, Unit const& y) const {
|
||||
SPROUT_CONSTEXPR result_type
|
||||
calc(Unit const& x, Unit const& y) const {
|
||||
return is_nearest() ? calc_nearest(x, y)
|
||||
: calc_bilinear(x, y)
|
||||
;
|
||||
}
|
||||
public:
|
||||
explicit SPROUT_CONSTEXPR texture_map(
|
||||
texture_type const& texture,
|
||||
unit_type const& scale = 1,
|
||||
unit_type const& offset_u = 0,
|
||||
unit_type const& offset_v = 0,
|
||||
texture_type const& texture, unit_type const& scale = 1,
|
||||
unit_type const& offset_u = 0, unit_type const& offset_v = 0,
|
||||
result_type const& default_color = result_type(),
|
||||
interpolation_type::values interpolation_value = interpolation_type::nearest_neighbor,
|
||||
texture_map_placement::values placement_value = texture_map_placement::tile
|
||||
|
@ -125,7 +133,8 @@ namespace sprout {
|
|||
, placement_value_(placement_value)
|
||||
{}
|
||||
template<typename Unit>
|
||||
SPROUT_CONSTEXPR result_type operator()(Unit const& u, Unit const& v) const {
|
||||
SPROUT_CONSTEXPR result_type
|
||||
operator()(Unit const& u, Unit const& v) const {
|
||||
return calc(
|
||||
(u - offset_u_ + scale_ / 2) / scale_ * texture_.get().width(),
|
||||
(-(v - offset_v_) + scale_ / 2) / scale_ * texture_.get().height()
|
||||
|
@ -143,10 +152,8 @@ namespace sprout {
|
|||
template<typename Texture, typename Unit>
|
||||
inline SPROUT_CONSTEXPR sprout::darkroom::materials::texture_map<Texture, Unit>
|
||||
make_texture_map(
|
||||
Texture const& texture,
|
||||
Unit const& scale,
|
||||
Unit const& offset_u = 0,
|
||||
Unit const& offset_v = 0,
|
||||
Texture const& texture, Unit const& scale,
|
||||
Unit const& offset_u = 0, Unit const& offset_v = 0,
|
||||
typename sprout::darkroom::materials::texture_map<Texture, Unit>::result_type const& default_color
|
||||
= typename sprout::darkroom::materials::texture_map<Texture, Unit>::result_typ()
|
||||
,
|
||||
|
|
|
@ -21,7 +21,8 @@ namespace sprout {
|
|||
: elem_(elem)
|
||||
{}
|
||||
template<typename Unit>
|
||||
SPROUT_CONSTEXPR result_type operator()(Unit const&, Unit const&) const {
|
||||
SPROUT_CONSTEXPR result_type
|
||||
operator()(Unit const&, Unit const&) const {
|
||||
return elem_;
|
||||
}
|
||||
};
|
||||
|
@ -40,7 +41,8 @@ namespace sprout {
|
|||
inline SPROUT_CONSTEXPR sprout::tuples::tuple<
|
||||
sprout::darkroom::materials::uniform_element<Color>,
|
||||
sprout::darkroom::materials::uniform_element<Reflection>
|
||||
> make_uniform_material_image(Color const& col, Reflection const& ref) {
|
||||
>
|
||||
make_uniform_material_image(Color const& col, Reflection const& ref) {
|
||||
return sprout::tuples::make_tuple(
|
||||
sprout::darkroom::materials::make_uniform(col),
|
||||
sprout::darkroom::materials::make_uniform(ref)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue