style cleanup: assignment & indentation.

This commit is contained in:
Campbell Barton
2012-06-09 18:56:12 +00:00
parent c6cffe98fa
commit 2c1abe1f58
32 changed files with 500 additions and 484 deletions

View File

@@ -172,8 +172,8 @@ static void display()
static void resize(int width, int height)
{
options.width= width;
options.height= height;
options.width = width;
options.height = height;
if(options.session)
options.session->reset(session_buffer_params(), options.session_params.samples);
@@ -197,8 +197,8 @@ static int files_parse(int argc, const char *argv[])
static void options_parse(int argc, const char **argv)
{
options.width= 0;
options.height= 0;
options.width = 0;
options.height = 0;
options.filepath = "";
options.session = NULL;
options.quiet = false;

View File

@@ -222,14 +222,14 @@ static void blender_camera_viewplane(BlenderCamera *bcam, int width, int height,
}
if(horizontal_fit) {
*aspectratio= xratio/yratio;
xaspect= *aspectratio;
yaspect= 1.0f;
*aspectratio = xratio/yratio;
xaspect = *aspectratio;
yaspect = 1.0f;
}
else {
*aspectratio= yratio/xratio;
xaspect= 1.0f;
yaspect= *aspectratio;
*aspectratio = yratio/xratio;
xaspect = 1.0f;
yaspect = *aspectratio;
}
/* modify aspect for orthographic scale */

View File

@@ -46,7 +46,7 @@ static void create_mesh(Scene *scene, Mesh *mesh, BL::Mesh b_mesh, const vector<
float3 *N = attr_N->data_float3();
for(b_mesh.vertices.begin(v); v != b_mesh.vertices.end(); ++v, ++N)
*N= get_float3(v->normal());
*N = get_float3(v->normal());
/* create faces */
BL::Mesh::tessfaces_iterator f;
@@ -175,7 +175,7 @@ static void create_subd_mesh(Mesh *mesh, BL::Mesh b_mesh, PointerRNA *cmesh, con
for(b_mesh.tessfaces.begin(f); f != b_mesh.tessfaces.end(); ++f) {
int4 vi = get_int4(f->vertices_raw());
int n= (vi[3] == 0)? 3: 4;
int n = (vi[3] == 0) ? 3: 4;
//int shader = used_shaders[f->material_index()];
if(n == 4)

View File

@@ -145,7 +145,7 @@ void BlenderSync::sync_particles(Object *ob, BL::Object b_ob)
for(b_ob.particle_systems.begin(b_psys); b_psys != b_ob.particle_systems.end(); ++b_psys) {
if (use_particle_system(*b_psys)) {
BL::ParticleSystem::particles_iterator b_pa;
for(b_psys->particles.begin(b_pa), index=0; b_pa != b_psys->particles.end(); ++b_pa, ++index) {
for(b_psys->particles.begin(b_pa), index = 0; b_pa != b_psys->particles.end(); ++b_pa, ++index) {
if(use_particle(*b_pa)) {
Particle pa;

View File

@@ -193,7 +193,8 @@ CCLDeviceInfo *compute_device_list(DeviceType type)
foreach(DeviceInfo& info, devices) {
if(info.type == type ||
(info.type == DEVICE_MULTI && info.multi_devices[0].type == type)) {
(info.type == DEVICE_MULTI && info.multi_devices[0].type == type))
{
CCLDeviceInfo cinfo = {info.id.c_str(), info.description.c_str(), i++};
device_list.push_back(cinfo);
}
@@ -214,7 +215,7 @@ CCL_NAMESPACE_END
void *CCL_python_module_init()
{
PyObject *mod= PyModule_Create(&ccl::module);
PyObject *mod = PyModule_Create(&ccl::module);
#ifdef WITH_OSL
PyModule_AddObject(mod, "with_osl", Py_True);

View File

@@ -83,8 +83,8 @@ void BlenderSession::create_session()
SessionParams session_params = BlenderSync::get_session_params(b_userpref, b_scene, background);
/* reset status/progress */
last_status= "";
last_progress= -1.0f;
last_status = "";
last_progress = -1.0f;
/* create scene */
scene = new Scene(scene_params);
@@ -292,7 +292,8 @@ void BlenderSession::synchronize()
SessionParams session_params = BlenderSync::get_session_params(b_userpref, b_scene, background);
if(session->params.modified(session_params) ||
scene->params.modified(scene_params)) {
scene->params.modified(scene_params))
{
free_session();
create_session();
session->start();

View File

@@ -784,7 +784,9 @@ void BlenderSync::sync_lamps()
if(b_lamp->type() == BL::Lamp::type_POINT ||
b_lamp->type() == BL::Lamp::type_SPOT ||
b_lamp->type() == BL::Lamp::type_AREA)
{
strength = 100.0f;
}
closure = graph->add(new EmissionNode());
closure->input("Color")->value = get_float3(b_lamp->color());

View File

@@ -105,10 +105,13 @@ bool BlenderSync::sync_recalc()
BL::BlendData::worlds_iterator b_world;
for(b_data.worlds.begin(b_world); b_world != b_data.worlds.end(); ++b_world)
for(b_data.worlds.begin(b_world); b_world != b_data.worlds.end(); ++b_world) {
if(world_map == b_world->ptr.data &&
(b_world->is_updated() || (b_world->node_tree() && b_world->node_tree().is_updated())))
{
world_recalc = true;
}
}
bool recalc =
shader_map.has_recalc() ||

View File

@@ -52,7 +52,7 @@ int BVHNode::getSubtreeSize(BVH_STAT stat) const
}
if(!is_leaf())
for(int i=0;i<num_children();i++)
for(int i = 0; i < num_children(); i++)
cnt += get_child(i)->getSubtreeSize(stat);
return cnt;
@@ -60,7 +60,7 @@ int BVHNode::getSubtreeSize(BVH_STAT stat) const
void BVHNode::deleteSubtree()
{
for(int i=0;i<num_children();i++)
for(int i = 0; i < num_children(); i++)
if(get_child(i))
get_child(i)->deleteSubtree();
@@ -71,7 +71,7 @@ float BVHNode::computeSubtreeSAHCost(const BVHParams& p, float probability) cons
{
float SAH = probability * p.cost(num_children(), num_triangles());
for(int i=0;i<num_children();i++) {
for(int i = 0; i < num_children(); i++) {
BVHNode *child = get_child(i);
SAH += child->computeSubtreeSAHCost(p, probability * child->m_bounds.safe_area()/m_bounds.safe_area());
}

View File

@@ -49,9 +49,9 @@ __device void differential_dudv(differential *du, differential *dv, float3 dPdu,
* mainly used for differentials of arbitrary mesh attributes. */
/* find most stable axis to project to 2D */
float xn= fabsf(Ng.x);
float yn= fabsf(Ng.y);
float zn= fabsf(Ng.z);
float xn = fabsf(Ng.x);
float yn = fabsf(Ng.y);
float zn = fabsf(Ng.z);
if(zn < xn || zn < yn) {
if(yn < xn || yn < zn) {

View File

@@ -137,10 +137,13 @@ __device_inline float path_state_terminate_probability(KernelGlobals *kg, PathSt
(state->diffuse_bounce >= kernel_data.integrator.max_diffuse_bounce) ||
(state->glossy_bounce >= kernel_data.integrator.max_glossy_bounce) ||
(state->transmission_bounce >= kernel_data.integrator.max_transmission_bounce))
{
return 0.0f;
else if(state->bounce <= kernel_data.integrator.min_bounce)
}
else if(state->bounce <= kernel_data.integrator.min_bounce) {
return 1.0f;
}
}
/* probalistic termination */
return average(throughput);

View File

@@ -47,7 +47,7 @@ __device float fresnel_dielectric(float eta, const float3 N,
float cos = dot(N, I), neta;
float3 Nn;
// compute reflection
*R =(2 * cos)* N - I;
*R = (2 * cos)* N - I;
#ifdef __RAY_DIFFERENTIALS__
*dRdx = (2 * dot(N, dIdx)) * N - dIdx;
*dRdy = (2 * dot(N, dIdy)) * N - dIdy;
@@ -65,18 +65,18 @@ __device float fresnel_dielectric(float eta, const float3 N,
Nn = -N;
*is_inside = true;
}
*R =(2 * cos)* Nn - I;
*R = (2 * cos)* Nn - I;
float arg = 1 -(neta * neta *(1 -(cos * cos)));
if(arg < 0) {
*T= make_float3(0.0f, 0.0f, 0.0f);
*T = make_float3(0.0f, 0.0f, 0.0f);
#ifdef __RAY_DIFFERENTIALS__
*dTdx= make_float3(0.0f, 0.0f, 0.0f);
*dTdy= make_float3(0.0f, 0.0f, 0.0f);
*dTdx = make_float3(0.0f, 0.0f, 0.0f);
*dTdy = make_float3(0.0f, 0.0f, 0.0f);
#endif
return 1; // total internal reflection
} else {
float dnp = sqrtf(arg);
float nK =(neta * cos)- dnp;
float nK = (neta * cos)- dnp;
*T = -(neta * I)+(nK * Nn);
#ifdef __RAY_DIFFERENTIALS__
*dTdx = -(neta * dIdx) + ((neta - neta * neta * cos / dnp) * dot(dIdx, Nn)) * Nn;
@@ -85,8 +85,8 @@ __device float fresnel_dielectric(float eta, const float3 N,
// compute Fresnel terms
float cosTheta1 = cos; // N.R
float cosTheta2 = -dot(Nn, *T);
float pPara =(cosTheta1 - eta * cosTheta2)/(cosTheta1 + eta * cosTheta2);
float pPerp =(eta * cosTheta1 - cosTheta2)/(eta * cosTheta1 + cosTheta2);
float pPara = (cosTheta1 - eta * cosTheta2)/(cosTheta1 + eta * cosTheta2);
float pPerp = (eta * cosTheta1 - cosTheta2)/(eta * cosTheta1 + cosTheta2);
return 0.5f * (pPara * pPara + pPerp * pPerp);
}
}
@@ -99,8 +99,8 @@ __device float fresnel_dielectric_cos(float cosi, float eta)
float g = eta * eta - 1 + c * c;
if(g > 0) {
g = sqrtf(g);
float A =(g - c)/(g + c);
float B =(c *(g + c)- 1)/(c *(g - c)+ 1);
float A = (g - c)/(g + c);
float B = (c *(g + c)- 1)/(c *(g - c)+ 1);
return 0.5f * A * A *(1 + B * B);
}
return 1.0f; // TIR(no refracted component)
@@ -110,10 +110,10 @@ __device float fresnel_conductor(float cosi, float eta, float k)
{
float tmp_f = eta * eta + k * k;
float tmp = tmp_f * cosi * cosi;
float Rparl2 =(tmp -(2.0f * eta * cosi)+ 1)/
(tmp +(2.0f * eta * cosi)+ 1);
float Rperp2 =(tmp_f -(2.0f * eta * cosi)+ cosi * cosi)/
(tmp_f +(2.0f * eta * cosi)+ cosi * cosi);
float Rparl2 = (tmp - (2.0f * eta * cosi) + 1)/
(tmp + (2.0f * eta * cosi) + 1);
float Rperp2 = (tmp_f - (2.0f * eta * cosi) + cosi * cosi)/
(tmp_f + (2.0f * eta * cosi) + cosi * cosi);
return(Rparl2 + Rperp2) * 0.5f;
}

View File

@@ -24,9 +24,9 @@ __device float svm_gradient(float3 p, NodeGradientType type)
{
float x, y, z;
x= p.x;
y= p.y;
z= p.z;
x = p.x;
y = p.y;
z = p.z;
if(type == NODE_BLEND_LINEAR) {
return x;

View File

@@ -34,39 +34,39 @@ __device_noinline float3 svm_magic(float3 p, int n, float distortion)
y *= distortion;
if(n > 1) {
x= cosf(x-y-z);
x = cosf(x-y-z);
x *= distortion;
if(n > 2) {
z= sinf(-x-y-z);
z = sinf(-x-y-z);
z *= distortion;
if(n > 3) {
x= -cosf(-x+y-z);
x = -cosf(-x+y-z);
x *= distortion;
if(n > 4) {
y= -sinf(-x+y+z);
y = -sinf(-x+y+z);
y *= distortion;
if(n > 5) {
y= -cosf(-x+y+z);
y = -cosf(-x+y+z);
y *= distortion;
if(n > 6) {
x= cosf(x+y+z);
x = cosf(x+y+z);
x *= distortion;
if(n > 7) {
z= sinf(x+y-z);
z = sinf(x+y-z);
z *= distortion;
if(n > 8) {
x= -cosf(-x-y+z);
x = -cosf(-x-y+z);
x *= distortion;
if(n > 9) {
y= -sinf(x-y+z);
y = -sinf(x-y+z);
y *= distortion;
}
}

View File

@@ -248,8 +248,8 @@ __device float3 svm_mix_soft(float t, float3 col1, float3 col2)
{
float tm = 1.0f - t;
float3 one= make_float3(1.0f, 1.0f, 1.0f);
float3 scr= one - (one - col2)*(one - col1);
float3 one = make_float3(1.0f, 1.0f, 1.0f);
float3 scr = one - (one - col2)*(one - col1);
return tm*col1 + t*((one - col1)*col2*col1 + col1*scr);
}
@@ -259,19 +259,19 @@ __device float3 svm_mix_linear(float t, float3 col1, float3 col2)
float3 outcol = col1;
if(col2.x > 0.5f)
outcol.x= col1.x + t*(2.0f*(col2.x - 0.5f));
outcol.x = col1.x + t*(2.0f*(col2.x - 0.5f));
else
outcol.x= col1.x + t*(2.0f*(col2.x) - 1.0f);
outcol.x = col1.x + t*(2.0f*(col2.x) - 1.0f);
if(col2.y > 0.5f)
outcol.y= col1.y + t*(2.0f*(col2.y - 0.5f));
outcol.y = col1.y + t*(2.0f*(col2.y - 0.5f));
else
outcol.y= col1.y + t*(2.0f*(col2.y) - 1.0f);
outcol.y = col1.y + t*(2.0f*(col2.y) - 1.0f);
if(col2.z > 0.5f)
outcol.z= col1.z + t*(2.0f*(col2.z - 0.5f));
outcol.z = col1.z + t*(2.0f*(col2.z - 0.5f));
else
outcol.z= col1.z + t*(2.0f*(col2.z) - 1.0f);
outcol.z = col1.z + t*(2.0f*(col2.z) - 1.0f);
return outcol;
}

View File

@@ -221,7 +221,7 @@ __device_noinline float noise_turbulence(float3 p, NodeNoiseBasis basis, float o
int i, n;
octaves = clamp(octaves, 0.0f, 16.0f);
n= (int)octaves;
n = (int)octaves;
for(i = 0; i <= n; i++) {
float t = noise_basis(fscale*p, basis);

View File

@@ -38,7 +38,7 @@ __device_noinline float4 svm_voronoi(NodeVoronoiColoring coloring, float scale,
}
else {
color = cellnoise_color(pa[0]);
fac= average(color);
fac = average(color);
}
return make_float4(color.x, color.y, color.z, fac);

View File

@@ -27,9 +27,9 @@ __device_noinline float svm_wave(NodeWaveType type, float3 p, float scale, float
p *= scale;
if(type == NODE_WAVE_BANDS)
n= (p.x + p.y + p.z)*10.0f;
n = (p.x + p.y + p.z) * 10.0f;
else /* if(type == NODE_WAVE_RINGS) */
n= len(p)*20.0f;
n = len(p) * 20.0f;
if(distortion != 0.0f)
n += distortion * noise_turbulence(p*dscale, NODE_NOISE_PERLIN, detail, 0);

View File

@@ -74,10 +74,13 @@ bool Attribute::same_storage(TypeDesc a, TypeDesc b)
if(a == TypeDesc::TypeColor || a == TypeDesc::TypePoint ||
a == TypeDesc::TypeVector || a == TypeDesc::TypeNormal)
{
if(b == TypeDesc::TypeColor || b == TypeDesc::TypePoint ||
b == TypeDesc::TypeVector || b == TypeDesc::TypeNormal)
{
return true;
}
}
return false;
}
@@ -286,11 +289,14 @@ bool AttributeRequestSet::modified(const AttributeRequestSet& other)
for(size_t j = 0; j < requests.size() && !found; j++)
if(requests[i].name == other.requests[j].name &&
requests[i].std == other.requests[j].std)
{
found = true;
}
if(!found)
if(!found) {
return true;
}
}
return false;
}

View File

@@ -117,8 +117,8 @@ void RenderBuffers::reset(Device *device, BufferParams& params_)
uint *init_state = rng_state.resize(params.width, params.height);
int x, y, width = params.width, height = params.height;
for(x=0; x<width; x++)
for(y=0; y<height; y++)
for(x = 0; x < width; x++)
for(y = 0; y < height; y++)
init_state[x + y*width] = hash_int_2d(params.full_x+x, params.full_y+y);
device->mem_alloc(rng_state, MEM_READ_WRITE);

View File

@@ -199,7 +199,7 @@ void Camera::device_update(Device *device, DeviceScene *dscene, Scene *scene)
kcam->bladesrotation = bladesrotation;
/* motion blur */
kcam->shuttertime= (need_motion == Scene::MOTION_BLUR)? shuttertime: 0.0f;
kcam->shuttertime = (need_motion == Scene::MOTION_BLUR) ? shuttertime: 0.0f;
/* type */
kcam->type = type;

View File

@@ -73,17 +73,17 @@ static vector<float> filter_table(FilterType type, float width)
/* compute cumulative distribution function */
filter_table_cdf[0] = 0.0f;
for(i=0; i<filter_table_size; i++) {
for(i = 0; i < filter_table_size; i++) {
float x = i*width*0.5f/(filter_table_size-1);
float y = filter_func(x, width);
filter_table_cdf[i+1] += filter_table_cdf[i] + fabsf(y);
}
for(i=0; i<=filter_table_size; i++)
for(i = 0; i <= filter_table_size; i++)
filter_table_cdf[i] /= filter_table_cdf[filter_table_size];
/* create importance sampling table */
for(i=0; i<=half_size; i++) {
for(i = 0; i <= half_size; i++) {
float x = i/(float)half_size;
int index = upper_bound(filter_table_cdf.begin(), filter_table_cdf.end(), x) - filter_table_cdf.begin();
float t;

View File

@@ -44,7 +44,7 @@ public:
float3 min, max;
bool use_minmax;
enum Mapping { NONE=0, X=1, Y=2, Z=3 };
enum Mapping { NONE = 0, X = 1, Y = 2, Z = 3 };
Mapping x_mapping, y_mapping, z_mapping;
enum Projection { FLAT, CUBE, TUBE, SPHERE };

View File

@@ -365,7 +365,7 @@ string MD5Hash::get_hex()
finish(digest);
for(int i=0; i<16; i++)
for(int i = 0; i < 16; i++)
sprintf(buf + i*2, "%02X", digest[i]);
buf[sizeof(buf)-1] = '\0';

View File

@@ -44,7 +44,7 @@ public:
bool append_file(const string& filepath);
string get_hex();
protected:
protected:
void process(const uint8_t *data);
void finish(uint8_t digest[16]);

View File

@@ -13,29 +13,29 @@
#ifndef CLCC_GENERATE_DOCUMENTATION
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#define VC_EXTRALEAN
#include <windows.h>
# define WIN32_LEAN_AND_MEAN
# define VC_EXTRALEAN
# include <windows.h>
typedef HMODULE CLCC_DYNLIB_HANDLE;
#define CLCC_DYNLIB_OPEN LoadLibrary
#define CLCC_DYNLIB_CLOSE FreeLibrary
#define CLCC_DYNLIB_IMPORT GetProcAddress
# define CLCC_DYNLIB_OPEN LoadLibrary
# define CLCC_DYNLIB_CLOSE FreeLibrary
# define CLCC_DYNLIB_IMPORT GetProcAddress
#else
#include <dlfcn.h>
# include <dlfcn.h>
typedef void* CLCC_DYNLIB_HANDLE;
#define CLCC_DYNLIB_OPEN(path) dlopen(path, RTLD_NOW | RTLD_GLOBAL)
#define CLCC_DYNLIB_CLOSE dlclose
#define CLCC_DYNLIB_IMPORT dlsym
# define CLCC_DYNLIB_OPEN(path) dlopen(path, RTLD_NOW | RTLD_GLOBAL)
# define CLCC_DYNLIB_CLOSE dlclose
# define CLCC_DYNLIB_IMPORT dlsym
#endif
#else
//typedef implementation_defined CLCC_DYNLIB_HANDLE;
//#define CLCC_DYNLIB_OPEN(path) implementation_defined
//#define CLCC_DYNLIB_CLOSE implementation_defined
//#define CLCC_DYNLIB_IMPORT implementation_defined
// typedef implementation_defined CLCC_DYNLIB_HANDLE;
//# define CLCC_DYNLIB_OPEN(path) implementation_defined
//# define CLCC_DYNLIB_CLOSE implementation_defined
//# define CLCC_DYNLIB_IMPORT implementation_defined
#endif
CCL_NAMESPACE_BEGIN

View File

@@ -55,7 +55,7 @@ static void view_display_text(int x, int y, const char *text)
glRasterPos3f(x, y, 0);
for(c=text; *c != '\0'; c++)
for(c = text; *c != '\0'; c++)
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10, *c);
}