style cleanup

This commit is contained in:
Campbell Barton
2012-06-04 22:44:58 +00:00
parent f94123a5c6
commit 2d290040a1
22 changed files with 1682 additions and 1635 deletions

View File

@@ -87,12 +87,14 @@ public:
ClosureParam closure_background_params[] = {
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(GenericBackgroundClosure) };
CLOSURE_FINISH_PARAM(GenericBackgroundClosure)
};
CLOSURE_PREPARE(closure_background_prepare, GenericBackgroundClosure)
ClosureParam closure_holdout_params[] = {
CLOSURE_FINISH_PARAM(HoldoutClosure) };
CLOSURE_FINISH_PARAM(HoldoutClosure)
};
CLOSURE_PREPARE(closure_holdout_prepare, HoldoutClosure)

View File

@@ -156,7 +156,8 @@ public:
domega_in_dy = (2 * m_N.dot(domega_out_dy)) * m_N - domega_out_dy;
domega_in_dx *= 125;
domega_in_dy *= 125;
} else
}
else
pdf = 0;
return Labels::REFLECT;
}
@@ -169,7 +170,8 @@ ClosureParam bsdf_ashikhmin_velvet_params[] = {
CLOSURE_VECTOR_PARAM(AshikhminVelvetClosure, m_N),
CLOSURE_FLOAT_PARAM(AshikhminVelvetClosure, m_sigma),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(AshikhminVelvetClosure) };
CLOSURE_FINISH_PARAM(AshikhminVelvetClosure)
};
CLOSURE_PREPARE(bsdf_ashikhmin_velvet_prepare, AshikhminVelvetClosure)

View File

@@ -97,7 +97,8 @@ public:
domega_in_dy = (2 * m_N.dot(domega_out_dy)) * m_N - domega_out_dy;
domega_in_dx *= 125;
domega_in_dy *= 125;
} else
}
else
pdf = 0;
return Labels::REFLECT;
}
@@ -160,7 +161,8 @@ public:
domega_in_dy = (2 * m_N.dot(domega_out_dy)) * m_N - domega_out_dy;
domega_in_dx *= -125;
domega_in_dy *= -125;
} else
}
else
pdf = 0;
return Labels::TRANSMIT;
}
@@ -169,12 +171,14 @@ public:
ClosureParam bsdf_diffuse_params[] = {
CLOSURE_VECTOR_PARAM(DiffuseClosure, m_N),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM (DiffuseClosure) };
CLOSURE_FINISH_PARAM(DiffuseClosure)
};
ClosureParam bsdf_translucent_params[] = {
CLOSURE_VECTOR_PARAM(TranslucentClosure, m_N),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM (TranslucentClosure) };
CLOSURE_FINISH_PARAM(TranslucentClosure)
};
CLOSURE_PREPARE(bsdf_diffuse_prepare, DiffuseClosure)
CLOSURE_PREPARE(bsdf_translucent_prepare, TranslucentClosure)

View File

@@ -213,7 +213,8 @@ public:
#endif
}
}
} else {
}
else {
// CAUTION: the i and o variables are inverted relative to the paper
// eq. 39 - compute actual refractive direction
Vec3 R, dRdx, dRdy;
@@ -274,7 +275,8 @@ public:
Vec3 m_N;
float m_ab; // width parameter (roughness)
float m_eta; // index of refraction (for fresnel term)
MicrofacetBeckmannClosure() : BSDFClosure(Labels::GLOSSY, Refractive ? Back : Front) { }
MicrofacetBeckmannClosure() : BSDFClosure(Labels::GLOSSY, Refractive ? Back : Front) {
}
void setup()
{
@@ -287,7 +289,9 @@ public:
m_eta == comp->m_eta && BSDFClosure::mergeable(other);
}
size_t memsize () const { return sizeof(*this); }
size_t memsize() const {
return sizeof(*this);
}
const char *name() const {
return Refractive ? "microfacet_beckmann_refraction"
@@ -441,7 +445,8 @@ public:
#endif
}
}
} else {
}
else {
// CAUTION: the i and o variables are inverted relative to the paper
// eq. 39 - compute actual refractive direction
Vec3 R, dRdx, dRdy;
@@ -502,27 +507,31 @@ ClosureParam bsdf_microfacet_ggx_params[] = {
CLOSURE_VECTOR_PARAM(MicrofacetGGXClosure<0>, m_N),
CLOSURE_FLOAT_PARAM(MicrofacetGGXClosure<0>, m_ag),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(MicrofacetGGXClosure<0>) };
CLOSURE_FINISH_PARAM(MicrofacetGGXClosure<0>)
};
ClosureParam bsdf_microfacet_ggx_refraction_params[] = {
CLOSURE_VECTOR_PARAM(MicrofacetGGXClosure<1>, m_N),
CLOSURE_FLOAT_PARAM(MicrofacetGGXClosure<1>, m_ag),
CLOSURE_FLOAT_PARAM(MicrofacetGGXClosure<1>, m_eta),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(MicrofacetGGXClosure<1>) };
CLOSURE_FINISH_PARAM(MicrofacetGGXClosure<1>)
};
ClosureParam bsdf_microfacet_beckmann_params[] = {
CLOSURE_VECTOR_PARAM(MicrofacetBeckmannClosure<0>, m_N),
CLOSURE_FLOAT_PARAM(MicrofacetBeckmannClosure<0>, m_ab),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(MicrofacetBeckmannClosure<0>) };
CLOSURE_FINISH_PARAM(MicrofacetBeckmannClosure<0>)
};
ClosureParam bsdf_microfacet_beckmann_refraction_params[] = {
CLOSURE_VECTOR_PARAM(MicrofacetBeckmannClosure<1>, m_N),
CLOSURE_FLOAT_PARAM(MicrofacetBeckmannClosure<1>, m_ab),
CLOSURE_FLOAT_PARAM(MicrofacetBeckmannClosure<1>, m_eta),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(MicrofacetBeckmannClosure<1>) };
CLOSURE_FINISH_PARAM(MicrofacetBeckmannClosure<1>)
};
CLOSURE_PREPARE(bsdf_microfacet_ggx_prepare, MicrofacetGGXClosure<0>)
CLOSURE_PREPARE(bsdf_microfacet_ggx_refraction_prepare, MicrofacetGGXClosure<1>)

View File

@@ -100,7 +100,8 @@ public:
ClosureParam bsdf_reflection_params[] = {
CLOSURE_VECTOR_PARAM(ReflectionClosure, m_N),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(ReflectionClosure) };
CLOSURE_FINISH_PARAM(ReflectionClosure)
};
CLOSURE_PREPARE(bsdf_reflection_prepare, ReflectionClosure)

View File

@@ -112,7 +112,8 @@ ClosureParam bsdf_refraction_params[] = {
CLOSURE_VECTOR_PARAM(RefractionClosure, m_N),
CLOSURE_FLOAT_PARAM(RefractionClosure, m_eta),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(RefractionClosure) };
CLOSURE_FINISH_PARAM(RefractionClosure)
};
CLOSURE_PREPARE(bsdf_refraction_prepare, RefractionClosure)

View File

@@ -89,7 +89,8 @@ public:
ClosureParam bsdf_transparent_params[] = {
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(TransparentClosure) };
CLOSURE_FINISH_PARAM(TransparentClosure)
};
CLOSURE_PREPARE(bsdf_transparent_prepare, TransparentClosure)

View File

@@ -134,19 +134,22 @@ public:
float tanPhi = alphaRatio * tanf((float) M_PI_2 * val);
cosPhi = 1 / sqrtf(1 + tanPhi * tanPhi);
sinPhi = tanPhi * cosPhi;
} else if (randu < 0.5) {
}
else if (randu < 0.5) {
float val = 1 - 4 * (0.5f - randu);
float tanPhi = alphaRatio * tanf((float) M_PI_2 * val);
// phi = (float) M_PI - phi;
cosPhi = -1 / sqrtf(1 + tanPhi * tanPhi);
sinPhi = -tanPhi * cosPhi;
} else if (randu < 0.75f) {
}
else if (randu < 0.75f) {
float val = 4 * (randu - 0.5f);
float tanPhi = alphaRatio * tanf((float) M_PI_2 * val);
//phi = (float) M_PI + phi;
cosPhi = -1 / sqrtf(1 + tanPhi * tanPhi);
sinPhi = tanPhi * cosPhi;
} else {
}
else {
float val = 1 - 4 * (1 - randu);
float tanPhi = alphaRatio * tanf((float) M_PI_2 * val);
// phi = 2 * (float) M_PI - phi;
@@ -214,7 +217,8 @@ ClosureParam bsdf_ward_params[] = {
CLOSURE_FLOAT_PARAM(WardClosure, m_ax),
CLOSURE_FLOAT_PARAM(WardClosure, m_ay),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(WardClosure) };
CLOSURE_FINISH_PARAM(WardClosure)
};
CLOSURE_PREPARE(bsdf_ward_prepare, WardClosure)

View File

@@ -212,8 +212,10 @@ public:
domega_in_dy = (2 * m_N.dot(domega_out_dy)) * m_N - domega_out_dy;
domega_in_dx *= 125;
domega_in_dy *= 125;
} else
}
else {
pdf = 0;
}
return Labels::REFLECT;
}
};
@@ -224,13 +226,15 @@ ClosureParam bsdf_westin_backscatter_params[] = {
CLOSURE_VECTOR_PARAM(WestinBackscatterClosure, m_N),
CLOSURE_FLOAT_PARAM(WestinBackscatterClosure, m_roughness),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(WestinBackscatterClosure) };
CLOSURE_FINISH_PARAM(WestinBackscatterClosure)
};
ClosureParam bsdf_westin_sheen_params[] = {
CLOSURE_VECTOR_PARAM(WestinSheenClosure, m_N),
CLOSURE_FLOAT_PARAM(WestinSheenClosure, m_edginess),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(WestinSheenClosure) };
CLOSURE_FINISH_PARAM(WestinSheenClosure)
};
CLOSURE_PREPARE(bsdf_westin_backscatter_prepare, WestinBackscatterClosure)
CLOSURE_PREPARE(bsdf_westin_sheen_prepare, WestinSheenClosure)

View File

@@ -97,7 +97,8 @@ public:
ClosureParam closure_bssrdf_cubic_params[] = {
CLOSURE_COLOR_PARAM(BSSRDFCubicClosure, m_radius),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(BSSRDFCubicClosure) };
CLOSURE_FINISH_PARAM(BSSRDFCubicClosure)
};
CLOSURE_PREPARE(closure_bssrdf_cubic_prepare, BSSRDFCubicClosure)

View File

@@ -72,7 +72,8 @@ public:
ClosureParam closure_debug_params[] = {
CLOSURE_STRING_PARAM(DebugClosure, m_tag),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(DebugClosure) };
CLOSURE_FINISH_PARAM(DebugClosure)
};
CLOSURE_PREPARE(closure_debug_prepare, DebugClosure)

View File

@@ -99,7 +99,8 @@ public:
ClosureParam closure_emission_params[] = {
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(GenericEmissiveClosure) };
CLOSURE_FINISH_PARAM(GenericEmissiveClosure)
};
CLOSURE_PREPARE(closure_emission_prepare, GenericEmissiveClosure)

View File

@@ -172,7 +172,9 @@ void fresnel (vector I, normal N, float eta,
output float Kr, output float Kt,
output vector R, output vector T)
{
float sqr(float x) { return x*x; }
float sqr(float x) {
return x * x;
}
float c = dot(I, N);
if (c < 0)
c = -c;
@@ -189,7 +191,8 @@ void fresnel (vector I, normal N, float eta,
// OPT: the following recomputes some of the above values, but it
// gives us the same result as if the shader-writer called refract()
T = refract(I, N, eta);
} else {
}
else {
// total internal reflection
Kr = 1.0;
Kt = 0.0;
@@ -327,7 +330,8 @@ color transformc (string from, string to, color x)
color r;
if (s < 0.0001) {
r = v;
} else {
}
else {
h = 6 * (h - floor(h)); // expand to [0..6)
int hi = (int)h;
float f = h - hi;
@@ -351,7 +355,8 @@ color transformc (string from, string to, color x)
color r;
if (v <= 0) {
r = 0;
} else {
}
else {
float min = 2 * l - v;
s = (v - min) / v;
r = hsv_to_rgb(color(h, s, v));
@@ -412,7 +417,9 @@ int strlen (string s) BUILTIN;
int startswith(string s, string prefix) BUILTIN;
int endswith(string s, string suffix) BUILTIN;
string substr(string s, int start, int len) BUILTIN;
string substr (string s, int start) { return substr (s, start, strlen(s)); }
string substr(string s, int start) {
return substr(s, start, strlen(s));
}
// Define concat in terms of shorter concat
string concat(string a, string b, string c) {

View File

@@ -203,7 +203,8 @@ static bool get_mesh_attribute_convert(KernelGlobals *kg, const ShaderData *sd,
return true;
}
else if (attr.type == TypeDesc::TypePoint || attr.type == TypeDesc::TypeVector ||
attr.type == TypeDesc::TypeNormal || attr.type == TypeDesc::TypeColor) {
attr.type == TypeDesc::TypeNormal || attr.type == TypeDesc::TypeColor)
{
float3 tmp[3];
float *fval = (float *)val;
@@ -268,11 +269,14 @@ bool OSLRenderServices::get_attribute(void *renderstate, bool derivatives, ustri
if (tri != ~0) {
if (attr.type == type || (attr.type == TypeDesc::TypeColor &&
(type == TypeDesc::TypePoint || type == TypeDesc::TypeVector || type == TypeDesc::TypeNormal)))
{
return get_mesh_attribute(kg, sd, attr, derivatives, val);
else
}
else {
return get_mesh_attribute_convert(kg, sd, attr, type, derivatives, val);
}
}
}
else {
/* object attribute */
get_object_attribute(attr, derivatives, val);
@@ -308,8 +312,7 @@ void *OSLRenderServices::get_pointcloud_attr_query(ustring *attr_names,
to the query. Just to prevent buffer overruns */
query.capacity = -1;
for(int i = 0; i < nattrs; ++i)
{
for (int i = 0; i < nattrs; ++i) {
query.attr_names[i] = attr_names[i];
TypeDesc element_type = attr_types[i].elementtype();
@@ -321,16 +324,21 @@ void *OSLRenderServices::get_pointcloud_attr_query(ustring *attr_names,
/* convert the OSL (OIIO) type to the equivalent Partio type so
we can do a fast check at query time. */
if(element_type == TypeDesc::TypeFloat)
if (element_type == TypeDesc::TypeFloat) {
query.attr_partio_types[i] = Partio::FLOAT;
else if(element_type == TypeDesc::TypeInt)
}
else if (element_type == TypeDesc::TypeInt) {
query.attr_partio_types[i] = Partio::INT;
}
else if (element_type == TypeDesc::TypeColor || element_type == TypeDesc::TypePoint ||
element_type == TypeDesc::TypeVector || element_type == TypeDesc::TypeNormal)
{
query.attr_partio_types[i] = Partio::VECTOR;
else
}
else {
return NULL; /* report some error of unknown type */
}
}
/* this is valid until the end of RenderServices */
return &query;

View File

@@ -79,8 +79,7 @@ private:
right now it only caches the types already converted to
Partio constants. this is what get_pointcloud_attr_query
returns */
struct AttrQuery
{
struct AttrQuery {
/* names of the attributes to query */
std::vector<ustring> attr_names;
/* types as (enum Partio::ParticleAttributeType) of the

View File

@@ -73,7 +73,8 @@ public:
// didn't quite converge, pick result in the middle of remaining interval
return 0.5f * (lo + hi);
}
SubsurfaceClosure() { }
SubsurfaceClosure() {
}
void setup()
{
@@ -127,7 +128,8 @@ ClosureParam closure_subsurface_params[] = {
CLOSURE_COLOR_PARAM(SubsurfaceClosure, m_mfp),
CLOSURE_COLOR_PARAM(SubsurfaceClosure, m_albedo),
CLOSURE_STRING_KEYPARAM("label"),
CLOSURE_FINISH_PARAM(SubsurfaceClosure) };
CLOSURE_FINISH_PARAM(SubsurfaceClosure)
};
CLOSURE_PREPARE(closure_subsurface_prepare, SubsurfaceClosure)