From cfb7aee017d95137e19b7b006d9393b5d6a935d4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 7 Jul 2012 22:51:57 +0000 Subject: style cleanup --- source/blender/blenkernel/intern/CCGSubSurf.c | 4 +- source/blender/blenkernel/intern/anim_sys.c | 16 +- source/blender/blenkernel/intern/bmfont.c | 6 +- source/blender/blenkernel/intern/booleanops_mesh.c | 28 +- source/blender/blenkernel/intern/brush.c | 2 +- source/blender/blenkernel/intern/constraint.c | 12 +- source/blender/blenkernel/intern/customdata.c | 4 +- source/blender/blenkernel/intern/depsgraph.c | 14 +- source/blender/blenkernel/intern/dynamicpaint.c | 4 +- source/blender/blenkernel/intern/effect.c | 16 +- source/blender/blenkernel/intern/fcurve.c | 8 +- source/blender/blenkernel/intern/fmodifier.c | 8 +- source/blender/blenkernel/intern/font.c | 70 +- source/blender/blenkernel/intern/library.c | 4 +- source/blender/blenkernel/intern/nla.c | 18 +- source/blender/blenkernel/intern/object.c | 12 +- source/blender/blenkernel/intern/packedFile.c | 36 +- source/blender/blenkernel/intern/particle.c | 4 +- source/blender/blenkernel/intern/property.c | 4 +- source/blender/blenkernel/intern/scene.c | 10 +- source/blender/blenkernel/intern/seqeffects.c | 8 +- source/blender/blenkernel/intern/sequencer.c | 2 +- source/blender/blenkernel/intern/texture.c | 4 +- source/blender/blenkernel/intern/writeffmpeg.c | 12 +- source/blender/blenlib/intern/BLI_ghash.c | 2 - source/blender/blenlib/intern/BLI_kdopbvh.c | 243 ++--- source/blender/blenlib/intern/DLRB_tree.c | 4 +- source/blender/blenlib/intern/fileops.c | 16 +- source/blender/blenlib/intern/freetypefont.c | 124 +-- source/blender/blenlib/intern/math_geom.c | 92 +- source/blender/blenlib/intern/math_rotation.c | 12 +- source/blender/blenlib/intern/noise.c | 30 +- source/blender/blenlib/intern/string.c | 9 +- source/blender/blenlib/intern/voxel.c | 9 +- source/blender/blenlib/intern/winstuff.c | 4 +- source/blender/editors/armature/armature_ops.c | 2 +- source/blender/editors/armature/editarmature.c | 4 +- source/blender/editors/armature/poseUtils.c | 2 +- source/blender/editors/armature/poselib.c | 4 +- source/blender/editors/curve/editfont.c | 6 +- source/blender/editors/gpencil/drawgpencil.c | 4 +- source/blender/editors/gpencil/gpencil_edit.c | 12 +- source/blender/editors/gpencil/gpencil_paint.c | 16 +- source/blender/editors/interface/interface.c | 12 +- source/blender/editors/interface/interface_anim.c | 2 +- source/blender/editors/interface/interface_draw.c | 4 +- .../blender/editors/interface/interface_handlers.c | 6 +- source/blender/editors/interface/resources.c | 6 +- source/blender/editors/interface/view2d.c | 4 +- source/blender/editors/interface/view2d_ops.c | 2 +- source/blender/editors/io/io_collada.c | 4 +- source/blender/editors/io/io_ops.c | 2 +- source/blender/editors/mask/mask_editaction.c | 2 +- source/blender/editors/mesh/meshtools.c | 6 +- source/blender/editors/object/object_constraint.c | 6 +- source/blender/editors/object/object_edit.c | 2 +- source/blender/editors/object/object_modifier.c | 4 +- source/blender/editors/render/render_opengl.c | 13 +- source/blender/editors/screen/area.c | 18 +- source/blender/editors/space_image/image_ops.c | 2 +- source/blender/gpu/intern/gpu_material.c | 4 +- source/blender/ikplugin/intern/iksolver_plugin.c | 4 +- source/blender/imbuf/intern/allocimbuf.c | 6 +- source/blender/imbuf/intern/anim_movie.c | 18 +- source/blender/imbuf/intern/imageprocess.c | 22 +- source/blender/imbuf/intern/indexer.c | 12 +- source/blender/imbuf/intern/indexer_dv.c | 6 +- source/blender/imbuf/intern/jp2.c | 2 +- source/blender/imbuf/intern/jpeg.c | 14 +- source/blender/imbuf/intern/png.c | 34 +- source/blender/imbuf/intern/radiance_hdr.c | 4 +- source/blender/imbuf/intern/tiff.c | 2 +- source/blender/makesdna/intern/makesdna.c | 28 +- source/blender/modifiers/intern/MOD_boolean_util.c | 116 +-- source/blender/modifiers/intern/MOD_collision.c | 24 +- .../blender/modifiers/intern/MOD_fluidsim_util.c | 84 +- source/blender/modifiers/intern/MOD_smoke.c | 4 +- source/blender/python/intern/bpy_interface.c | 4 +- source/blender/python/intern/gpu.c | 6 +- source/blender/quicktime/apple/quicktime_export.c | 64 +- .../blender/render/intern/source/convertblender.c | 76 +- source/blender/render/intern/source/envmap.c | 4 +- .../blender/render/intern/source/external_engine.c | 4 +- source/blender/render/intern/source/imagetexture.c | 249 ++--- source/blender/render/intern/source/occlusion.c | 1006 ++++++++++---------- source/blender/render/intern/source/rayshade.c | 46 +- .../blender/render/intern/source/render_result.c | 2 +- .../blender/render/intern/source/render_texture.c | 239 ++--- source/blender/render/intern/source/rendercore.c | 12 +- source/blender/render/intern/source/shadbuf.c | 6 +- source/blender/render/intern/source/shadeinput.c | 18 +- source/blender/render/intern/source/shadeoutput.c | 38 +- source/blender/render/intern/source/sunsky.c | 12 +- .../blender/render/intern/source/volume_precache.c | 2 +- source/blender/render/intern/source/volumetric.c | 2 +- source/blender/render/intern/source/voxeldata.c | 2 +- source/blender/render/intern/source/zbuf.c | 14 +- source/blender/windowmanager/intern/wm_cursors.c | 2 +- 98 files changed, 1607 insertions(+), 1581 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 35bf4c0961f..c456840637a 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -2210,7 +2210,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) VertDataAdd(co, r, ss); } - // edge flags cleared later + /* edge flags cleared later */ } for (ptrIdx = 0; ptrIdx < numEffectedV; ptrIdx++) { CCGVert *v = effectedV[ptrIdx]; @@ -2337,7 +2337,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) VertDataAdd(nCo, r, ss); } - // vert flags cleared later + /* vert flags cleared later */ } if (ss->useAgeCounts) { diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index f7b18ce557a..8e8c98a38e4 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -936,7 +936,7 @@ KS_Path *BKE_keyingset_find_path(KeyingSet *ks, ID *id, const char group_name[], /* group */ if (group_name) { - // FIXME: these checks need to be coded... for now, it's not too important though + /* FIXME: these checks need to be coded... for now, it's not too important though */ } /* if all aspects are ok, return */ @@ -1116,11 +1116,13 @@ void BKE_keyingsets_free(ListBase *list) static short animsys_remap_path(AnimMapper *UNUSED(remap), char *path, char **dst) { /* is there a valid remapping table to use? */ - //if (remap) { - /* find a matching entry... to use to remap */ - // ...TODO... - //} - +#if 0 + if (remap) { + /* find a matching entry... to use to remap */ + /* ...TODO... */ + } +#endif + /* nothing suitable found, so just set dst to look at path (i.e. no alloc/free needed) */ *dst = path; return 0; @@ -1997,7 +1999,7 @@ void nladata_flush_channels(ListBase *channels) RNA_property_enum_set(ptr, prop, (int)value); break; default: - // can't do anything with other types of property.... + /* can't do anything with other types of property.... */ break; } } diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c index e85fe83b752..722dc1834dd 100644 --- a/source/blender/blenkernel/intern/bmfont.c +++ b/source/blender/blenkernel/intern/bmfont.c @@ -107,7 +107,7 @@ void readBitmapFontVersion0(ImBuf * ibuf, unsigned char * rect, int step) buffer[i] = rect[index]; index += step; if (index >= linelength) { - // we've read one line, no skip to the line *before* that + /* we've read one line, no skip to the line *before* that */ rect -= linelength; index -= linelength; } @@ -118,7 +118,7 @@ void readBitmapFontVersion0(ImBuf * ibuf, unsigned char * rect, int step) bmfont = MEM_mallocN(bytes, "readBitmapFontVersion0:bmfont"); index = 0; - // first read the header + /* first read the header */ bmfont->magic[0] = buffer[index++]; bmfont->magic[1] = buffer[index++]; bmfont->magic[2] = buffer[index++]; @@ -278,7 +278,7 @@ void matrixGlyph(ImBuf * ibuf, unsigned short unicode, *centerx = bmfont->glyphs[0].locx / (float) ibuf->x; *centery = (ibuf->y - bmfont->glyphs[0].locy) / (float) ibuf->y; - // 2.0 units is the default size of an object + /* 2.0 units is the default size of an object */ *movey = 1.0f - *sizey + 2.0f * (bmfont->glyphs[index].ofsy - bmfont->glyphs[0].ofsy) / (float) bmfont->glyphs[0].sizey; *movex = *sizex - 1.0f + 2.0f * (bmfont->glyphs[index].ofsx - bmfont->glyphs[0].ofsx) / (float) bmfont->glyphs[0].sizex; diff --git a/source/blender/blenkernel/intern/booleanops_mesh.c b/source/blender/blenkernel/intern/booleanops_mesh.c index 972793227a8..be79077bb58 100644 --- a/source/blender/blenkernel/intern/booleanops_mesh.c +++ b/source/blender/blenkernel/intern/booleanops_mesh.c @@ -44,19 +44,19 @@ CSG_DestroyMeshDescriptor( CSG_MeshDescriptor *mesh ) { - // Call mesh descriptors destroy function.... + /* Call mesh descriptors destroy function.... */ mesh->m_destroy_func(mesh); } - -// Destroy function for blender mesh internals. + +/* Destroy function for blender mesh internals. */ static void CSG_DestroyBlenderMeshInternals( CSG_MeshDescriptor *mesh ) { - // Free face and vertex iterators. - FreeMeshDescriptors(&(mesh->m_face_iterator),&(mesh->m_vertex_iterator)); + /* Free face and vertex iterators. */ + FreeMeshDescriptors(&(mesh->m_face_iterator),&(mesh->m_vertex_iterator)); } @@ -140,18 +140,18 @@ CSG_AddMeshToBlender( invert_m4_m4(inv_mat,mesh->base->object->obmat); - // Create a new blender mesh object - using 'base' as - // a template for the new object. + /* Create a new blender mesh object - using 'base' as + * a template for the new object. */ ob_new= AddNewBlenderMesh(mesh->base); me_new = ob_new->data; - // make sure the iterators are reset. + /* make sure the iterators are reset. */ mesh->m_face_iterator.Reset(mesh->m_face_iterator.it); mesh->m_vertex_iterator.Reset(mesh->m_vertex_iterator.it); - // iterate through results of operation and insert into new object - // see subsurf.c + /* iterate through results of operation and insert into new object + * see subsurf.c */ ConvertCSGDescriptorsToMeshObject( ob_new, @@ -195,8 +195,8 @@ CSG_PerformOp( output->base = mesh1->base; if (output->m_descriptor.user_face_vertex_data_size) { - // Then use the only interp function supported - success = + /* Then use the only interp function supported */ + success = CSG_PerformBooleanOperation( bool_op, op_type, @@ -225,8 +225,8 @@ CSG_PerformOp( bool_op = NULL; return 0; } - - // get the ouput mesh descriptors. + + /* get the ouput mesh descriptors. */ CSG_OutputFaceDescriptor(bool_op,&(output->m_face_iterator)); CSG_OutputVertexDescriptor(bool_op,&(output->m_vertex_iterator)); diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 741d4b729ae..53a9057116c 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -1074,7 +1074,7 @@ void BKE_brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2], const int radius = BKE_brush_size_get(scene, brush); const int diameter = 2 * radius; - // find random position within a circle of diameter 1 + /* find random position within a circle of diameter 1 */ do { rand_pos[0] = BLI_frand() - 0.5f; rand_pos[1] = BLI_frand() - 0.5f; diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 93c9ea06084..c2b38442a6b 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -2163,7 +2163,7 @@ static void actcon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintT Object workob; /* evaluate using workob */ - // FIXME: we don't have any consistent standards on limiting effects on object... + /* FIXME: we don't have any consistent standards on limiting effects on object... */ what_does_obaction(cob->ob, &workob, NULL, data->act, NULL, t); BKE_object_to_mat4(&workob, ct->matrix); } @@ -2623,7 +2623,7 @@ static void distlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t } /* if soft-distance is enabled, start fading once owner is dist-soft from the target */ else if (data->flag & LIMITDIST_USESOFT) { - // FIXME: there's a problem with "jumping" when this kicks in + /* FIXME: there's a problem with "jumping" when this kicks in */ if (dist >= (data->dist - data->soft)) { sfac = (float)(data->soft * (1.0f - expf(-(dist - data->dist) / data->soft)) + data->dist); if (dist != 0.0f) sfac /= dist; @@ -2989,7 +2989,7 @@ static void rbj_new_data(void *cdata) { bRigidBodyJointConstraint *data = (bRigidBodyJointConstraint *)cdata; - // removed code which set target of this constraint + /* removed code which set target of this constraint */ data->type = 1; } @@ -3608,7 +3608,7 @@ static void damptrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t if (normalize_v3(tarvec) == 0.0f) { /* the target is sitting on the owner, so just make them use the same direction vectors */ - // FIXME: or would it be better to use the pure direction vector? + /* FIXME: or would it be better to use the pure direction vector? */ copy_v3_v3(tarvec, obvec); //copy_v3_v3(tarvec, track_dir_vecs[data->trackflag]); } @@ -3839,7 +3839,7 @@ static void pivotcon_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *ta } /* get rotation matrix representing the rotation of the owner */ - // TODO: perhaps we might want to include scaling based on the pivot too? + /* TODO: perhaps we might want to include scaling based on the pivot too? */ copy_m3_m4(rotMat, cob->matrix); normalize_m3(rotMat); @@ -4395,7 +4395,7 @@ static bConstraint *add_new_constraint_internal(const char *name, short type) } else { /* if no name is provided, use the generic "Const" name */ - // NOTE: any constraint type that gets here really shouldn't get added... + /* NOTE: any constraint type that gets here really shouldn't get added... */ newName = (name && name[0]) ? name : "Const"; } diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index f551b2d18a4..8dd3b3da705 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -337,12 +337,12 @@ static void layerSwap_tface(void *data, const int *corner_indices) copy_v2_v2(uv[j], tf->uv[source_index]); - // swap pinning flags around + /* swap pinning flags around */ if (tf->unwrap & pin_flags[source_index]) { unwrap |= pin_flags[j]; } - // swap selection flags around + /* swap selection flags around */ if (tf->flag & sel_flags[source_index]) { flag |= sel_flags[j]; } diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index a64cab5d2fc..1092f877283 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -320,7 +320,7 @@ static void dag_add_driver_relation(AnimData *adt, DagForest *dag, DagNode *node DRIVER_TARGETS_USED_LOOPER(dvar) { if (dtar->id) { - // FIXME: other data types need to be added here so that they can work! + /* FIXME: other data types need to be added here so that they can work! */ if (GS(dtar->id->name) == ID_OB) { Object *ob = (Object *)dtar->id; @@ -399,8 +399,8 @@ static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Objec Base *base; DagNode *node2; - // would be nice to have a list of colliders here - // so for now walk all objects in scene check 'same layer rule' + /* would be nice to have a list of colliders here + * so for now walk all objects in scene check 'same layer rule' */ for (base = scene->base.first; base; base = base->next) { if ((base->lay & ob->lay) && base->object->pd) { Object *ob1 = base->object; @@ -858,7 +858,7 @@ DagForest *build_dag(Main *bmain, Scene *sce, short mask) } } - // cycle detection and solving + /* cycle detection and solving */ // solve_cycles(dag); return dag; @@ -1567,7 +1567,7 @@ DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob) node = dag_find_node(dag, ob); - // need to go over the whole dag for adj list + /* need to go over the whole dag for adj list */ nqueue = queue_create(node->ancestor_count); node1 = dag->DagNode.first; @@ -2205,8 +2205,8 @@ static int object_modifiers_use_time(Object *ob) return 1; } - // XXX: also, should check NLA strips, though for now assume that nobody uses - // that and we can omit that for performance reasons... + /* XXX: also, should check NLA strips, though for now assume that nobody uses + * that and we can omit that for performance reasons... */ } return 0; diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index dd5751c5d1f..8122f9bf617 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -3417,7 +3417,9 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface, sampleStrength *= sample_factor; } - else continue; + else { + continue; + } /* velocity brush, only do on main sample */ if (brush->flags & MOD_DPAINT_USES_VELOCITY && ss == 0 && brushVelocity) { diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index b32ac24084f..a4e7676c602 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -393,7 +393,7 @@ void pd_point_from_soft(Scene *scene, float *loc, float *vel, int index, Effecte // triangle - ray callback function static void eff_tri_ray_hit(void *UNUSED(userData), int UNUSED(index), const BVHTreeRay *UNUSED(ray), BVHTreeRayHit *hit) { - // whenever we hit a bounding box, we don't check further + /* whenever we hit a bounding box, we don't check further */ hit->dist = -1; hit->index = 1; } @@ -418,24 +418,24 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect negate_v3_v3(norm, efd->vec_to_point); len = normalize_v3(norm); - // check all collision objects + /* check all collision objects */ for (col = colls->first; col; col = col->next) { CollisionModifierData *collmd = col->collmd; if (col->ob == eff->ob) continue; - + if (collmd->bvhtree) { BVHTreeRayHit hit; - + hit.index = -1; hit.dist = len + FLT_EPSILON; - - // check if the way is blocked + + /* check if the way is blocked */ if (BLI_bvhtree_ray_cast(collmd->bvhtree, point->loc, norm, 0.0f, &hit, eff_tri_ray_hit, NULL)>=0) { absorption= col->ob->pd->absorption; - // visibility is only between 0 and 1, calculated from 1-absorption + /* visibility is only between 0 and 1, calculated from 1-absorption */ visibility *= CLAMPIS(1.0f-absorption, 0.0f, 1.0f); if (visibility <= 0.0f) @@ -1006,7 +1006,7 @@ void pdDoEffectors(ListBase *effectors, ListBase *colliders, EffectorWeights *we do_physical_effector(eff, &efd, point, force); - // for softbody backward compatibility + /* for softbody backward compatibility */ if (point->flag & PE_WIND_AS_SPEED && impulse) { sub_v3_v3v3(temp2, force, temp1); sub_v3_v3v3(impulse, impulse, temp2); diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 2da8c22e28b..38c1709d79a 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -422,7 +422,7 @@ int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, short if (loopbreaker == (maxloop - 1)) { printf("Error: binarysearch_bezt_index() was taking too long\n"); - // include debug info + /* include debug info */ printf("\tround = %d: start = %d, end = %d, arraylen = %d\n", loopbreaker, start, end, arraylen); } @@ -1159,7 +1159,7 @@ static float dvar_eval_locDiff(ChannelDriver *driver, DriverVar *dvar) float loc2[3] = {0.0f, 0.0f, 0.0f}; /* get two location values */ - // NOTE: for now, these are all just worldspace + /* NOTE: for now, these are all just worldspace */ DRIVER_TARGETS_USED_LOOPER(dvar) { /* get pointer to loc values to store in */ @@ -1206,7 +1206,7 @@ static float dvar_eval_locDiff(ChannelDriver *driver, DriverVar *dvar) /* object */ if (dtar->flag & DTAR_FLAG_LOCALSPACE) { if (dtar->flag & DTAR_FLAG_LOCAL_CONSTS) { - // XXX: this should practically be the same as transform space... + /* XXX: this should practically be the same as transform space... */ float mat[4][4]; /* extract transform just like how the constraints do it! */ @@ -1796,7 +1796,7 @@ static int findzero(float x, float q0, float q1, float q2, float q3, float *o) c = c0; if (a != 0.0) { - // discriminant + /* discriminant */ p = b * b - 4 * a * c; if (p > 0) { diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index d95bbf94b58..cefcbdd2762 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -433,7 +433,7 @@ static void fcm_envelope_verify(FModifier *fcm) /* if the are points, perform bubble-sort on them, as user may have changed the order */ if (env->data) { - // XXX todo... + /* XXX todo... */ } } @@ -539,7 +539,7 @@ static float fcm_cycles_time(FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), int cycles = 0, ofs = 0; /* check if modifier is first in stack, otherwise disable ourself... */ - // FIXME... + /* FIXME... */ if (fcm->prev) { fcm->flag |= FMODIFIER_FLAG_DISABLED; return evaltime; @@ -883,7 +883,7 @@ static void fcm_stepped_new_data(void *mdata) FMod_Stepped *data = (FMod_Stepped *)mdata; /* just need to set the step-size to 2-frames by default */ - // XXX: or would 5 be more normal? + /* XXX: or would 5 be more normal? */ data->step_size = 2.0f; } @@ -1104,7 +1104,7 @@ int remove_fmodifier(ListBase *modifiers, FModifier *fcm) return 1; } else { - // XXX this case can probably be removed some day, as it shouldn't happen... + /* XXX this case can probably be removed some day, as it shouldn't happen... */ printf("remove_fmodifier() - no modifier stack given\n"); MEM_freeN(fcm); return 0; diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 5d33c8fbcbf..050f921998d 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -133,7 +133,7 @@ struct TmpFont *BKE_vfont_find_tmpfont(VFont *vfont) if (vfont == NULL) return NULL; - // Try finding the font from font list + /* Try finding the font from font list */ tmpfnt = ttfdata.first; while (tmpfnt) { if (tmpfnt->vfont == vfont) @@ -150,28 +150,28 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont) if (vfont == NULL) return NULL; - // Try finding the font from font list + /* Try finding the font from font list */ tmpfnt = BKE_vfont_find_tmpfont(vfont); - - // And then set the data + + /* And then set the data */ if (!vfont->data) { PackedFile *pf; - + if (strcmp(vfont->name, FO_BUILTIN_NAME) == 0) { pf = get_builtin_packedfile(); } else { if (vfont->packedfile) { pf = vfont->packedfile; - - // We need to copy a tmp font to memory unless it is already there + + /* We need to copy a tmp font to memory unless it is already there */ if (!tmpfnt) { tpf = MEM_callocN(sizeof(*tpf), "PackedFile"); tpf->data = MEM_mallocN(pf->size, "packFile"); tpf->size = pf->size; memcpy(tpf->data, pf->data, pf->size); - - // Add temporary packed file to globals + + /* Add temporary packed file to globals */ tmpfnt = (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); tmpfnt->pf = tpf; tmpfnt->vfont = vfont; @@ -183,8 +183,8 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont) if (!tmpfnt) { tpf = newPackedFile(NULL, vfont->name, ID_BLEND_PATH(bmain, &vfont->id)); - - // Add temporary packed file to globals + + /* Add temporary packed file to globals */ tmpfnt = (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); tmpfnt->pf = tpf; tmpfnt->vfont = vfont; @@ -251,21 +251,21 @@ VFont *BKE_vfont_load(Main *bmain, const char *name) } BLI_strncpy(vfont->name, name, sizeof(vfont->name)); - // if autopack is on store the packedfile in de font structure + /* if autopack is on store the packedfile in de font structure */ if (!is_builtin && (G.fileflags & G_AUTOPACK)) { vfont->packedfile = pf; } - - // Do not add FO_BUILTIN_NAME to temporary listbase + + /* Do not add FO_BUILTIN_NAME to temporary listbase */ if (strcmp(filename, FO_BUILTIN_NAME)) { tmpfnt = (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); tmpfnt->pf = tpf; tmpfnt->vfont = vfont; BLI_addtail(&ttfdata, tmpfnt); - } + } } - - // Free the packed file + + /* Free the packed file */ if (!vfont || vfont->packedfile != pf) { freePackedFile(pf); } @@ -390,11 +390,11 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo che = find_vfont_char(vfd, character); - // Select the glyph data + /* Select the glyph data */ if (che) nu1 = che->nurbsbase.first; - // Create the character + /* Create the character */ while (nu1) { bezt1 = nu1->bezt; if (bezt1) { @@ -508,7 +508,7 @@ int BKE_vfont_select_get(Object *ob, int *start, int *end) static float char_width(Curve *cu, VChar *che, CharInfo *info) { - // The character wasn't found, propably ascii = 0, then the width shall be 0 as well + /* The character wasn't found, propably ascii = 0, then the width shall be 0 as well */ if (che == NULL) { return 0.0f; } @@ -543,20 +543,20 @@ struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int if (ob->type != OB_FONT) return NULL; - // Set font data + /* Set font data */ cu = (Curve *) ob->data; vfont = cu->vfont; - + if (cu->str == NULL) return NULL; if (vfont == NULL) return NULL; - // Create unicode string + /* Create unicode string */ utf8len = BLI_strlen_utf8(cu->str); mem = MEM_callocN(((utf8len + 1) * sizeof(wchar_t)), "convertedmem"); - + BLI_strncpy_wchar_from_utf8(mem, cu->str, utf8len + 1); - // Count the wchar_t string length + /* Count the wchar_t string length */ slen = wcslen(mem); if (cu->ulheight == 0.0f) @@ -612,7 +612,7 @@ struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int curbox = 0; for (i = 0; i <= slen; i++) { makebreak: - // Characters in the list + /* Characters in the list */ info = &(custrinfo[i]); ascii = mem[i]; if (info->flag & CU_CHINFO_SMALLCAPS) { @@ -664,7 +664,7 @@ makebreak: twidth = char_width(cu, che, info); - // Calculate positions + /* Calculate positions */ if ((tb->w != 0.0f) && (ct->dobreak == 0) && ((xof - (tb->x / cu->fsize) + twidth) * cu->fsize) > tb->w + cu->xof * cu->fsize) { // fprintf(stderr, "linewidth exceeded: %c%c%c...\n", mem[i], mem[i+1], mem[i+2]); for (j = i; j && (mem[j] != '\n') && (mem[j] != '\r') && (chartransdata[j].dobreak == 0); j--) { @@ -762,7 +762,7 @@ makebreak: } else wsfac = 1.0f; - // Set the width of the character + /* Set the width of the character */ twidth = char_width(cu, che, info); xof += (twidth * wsfac * (1.0f + (info->kern / 40.0f)) ) + xtrax; @@ -781,10 +781,10 @@ makebreak: if (ascii == '\n' || ascii == '\r' || ct->dobreak) cu->lines++; } - // linedata is now: width of line - // linedata2 is now: number of characters - // linedata3 is now: maxlen of that line - // linedata4 is now: number of whitespaces of line + /* linedata is now: width of line + * linedata2 is now: number of characters + * linedata3 is now: maxlen of that line + * linedata4 is now: number of whitespaces of line */ if (cu->spacemode != CU_LEFT) { ct = chartransdata; @@ -1023,7 +1023,7 @@ makebreak: /* printf("Error: Illegal material index (%d) in text object, setting to 0\n", info->mat_nr); */ info->mat_nr = 0; } - // We do not want to see any character for \n or \r + /* We do not want to see any character for \n or \r */ if (cha != '\n' && cha != '\r') buildchar(bmain, cu, cha, info, ct->xof, ct->yof, ct->rot, i); @@ -1035,8 +1035,8 @@ makebreak: { uloverlap = xtrax + 0.1f; } - // Find the character, the characters has to be in the memory already - // since character checking has been done earlier already. + /* Find the character, the characters has to be in the memory already + * since character checking has been done earlier already. */ che = find_vfont_char(vfd, cha); twidth = char_width(cu, che, info); diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 6e6891684c9..f3ef01425dd 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1342,7 +1342,7 @@ static void lib_indirect_test_id(ID *id, Library *lib) int a; #if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */ - // XXX old animation system! -------------------------------------- + /* XXX old animation system! -------------------------------------- */ { bActionStrip *strip; for (strip = ob->nlastrips.first; strip; strip = strip->next) { @@ -1351,7 +1351,7 @@ static void lib_indirect_test_id(ID *id, Library *lib) LIBTAG(strip->ipo); } } - // XXX: new animation system needs something like this? + /* XXX: new animation system needs something like this? */ #endif for (a = 0; a < ob->totcol; a++) { diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 84943172cbc..d62b03b5060 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -407,7 +407,7 @@ static float nlastrip_get_frame_actionclip(NlaStrip *strip, float cframe, short /* reversed = play strip backwards */ if (strip->flag & NLASTRIP_FLAG_REVERSE) { - // FIXME: this won't work right with Graph Editor? + /* FIXME: this won't work right with Graph Editor? */ if (mode == NLATIME_CONVERT_MAP) { return strip->end - scale * (cframe - strip->actstart); } @@ -1154,7 +1154,7 @@ static short nlastrip_is_first(AnimData *adt, NlaStrip *strip) return 0; /* check other tracks to see if they have a strip that's earlier */ - // TODO: or should we check that the strip's track is also the first? + /* TODO: or should we check that the strip's track is also the first? */ for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { /* only check the first strip, assuming that they're all in order */ ns = nlt->strips.first; @@ -1234,7 +1234,7 @@ void BKE_nlastrip_validate_fcurves(NlaStrip *strip) /* store path - make copy, and store that */ fcu->rna_path = BLI_strdupn("influence", 9); - // TODO: insert a few keyframes to ensure default behavior? + /* TODO: insert a few keyframes to ensure default behavior? */ } } @@ -1255,7 +1255,7 @@ void BKE_nlastrip_validate_fcurves(NlaStrip *strip) /* store path - make copy, and store that */ fcu->rna_path = BLI_strdupn("strip_time", 10); - // TODO: insert a few keyframes to ensure default behavior? + /* TODO: insert a few keyframes to ensure default behavior? */ } } } @@ -1340,7 +1340,7 @@ static void nlastrip_get_endpoint_overlaps(NlaStrip *strip, NlaTrack *track, flo /* find strips that overlap over the start/end of the given strip, * but which don't cover the entire length */ - // TODO: this scheme could get quite slow for doing this on many strips... + /* TODO: this scheme could get quite slow for doing this on many strips... */ for (nls = track->strips.first; nls; nls = nls->next) { /* check if strip overlaps (extends over or exactly on) the entire range of the strip we're validating */ if ((nls->start <= strip->start) && (nls->end >= strip->end)) { @@ -1443,7 +1443,7 @@ void BKE_nla_validate_state(AnimData *adt) /* apart from 'nothing' option which user has to explicitly choose, we don't really know if * we should be overwriting the extend setting (but assume that's what the user wanted) */ - // TODO: 1 solution is to tie this in with auto-blending... + /* TODO: 1 solution is to tie this in with auto-blending... */ if (strip->extendmode != NLASTRIP_EXTEND_NOTHING) { /* 1) First strip must be set to extend hold, otherwise, stuff before acts dodgy * 2) Only overwrite extend mode if *not* changing it will most probably result in @@ -1505,7 +1505,7 @@ void BKE_nla_action_pushdown(AnimData *adt) /* not first, so extend mode can only be NLASTRIP_EXTEND_HOLD_FORWARD not NLASTRIP_EXTEND_HOLD, * so that it doesn't override strips in previous tracks */ - // FIXME: this needs to be more automated, since user can rearrange strips + /* FIXME: this needs to be more automated, since user can rearrange strips */ strip->extendmode = NLASTRIP_EXTEND_HOLD_FORWARD; } @@ -1632,8 +1632,8 @@ void BKE_nla_tweakmode_exit(AnimData *adt) if ((adt->flag & ADT_NLA_EDIT_ON) == 0) return; - // TODO: need to sync the user-strip with the new state of the action! - + /* TODO: need to sync the user-strip with the new state of the action! */ + /* for all Tracks, clear the 'disabled' flag * for all Strips, clear the 'tweak-user' flag */ diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index a7a6dd1d5cd..2ba2ad7bd6e 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1958,8 +1958,8 @@ static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[] break; } - // total - mul_serie_m4(tmat, totmat, ob->parentinv, + /* total */ + mul_serie_m4(tmat, totmat, ob->parentinv, NULL, NULL, NULL, NULL, NULL, NULL); mul_serie_m4(obmat, tmat, locmat, NULL, NULL, NULL, NULL, NULL, NULL); @@ -1968,7 +1968,7 @@ static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[] } else { - // external usable originmat + /* external usable originmat */ copy_m3_m4(originmat, tmat); /* origin, for help line */ @@ -2503,7 +2503,7 @@ void BKE_object_handle_update(Scene *scene, Object *ob) /* XXX new animsys warning: depsgraph tag OB_RECALC_DATA should not skip drivers, * which is only in BKE_object_where_is_calc now */ - // XXX: should this case be OB_RECALC_OB instead? + /* XXX: should this case be OB_RECALC_OB instead? */ if (ob->recalc & OB_RECALC_ALL) { if (G.debug & G_DEBUG) @@ -2539,7 +2539,7 @@ void BKE_object_handle_update(Scene *scene, Object *ob) if (adt) { /* evaluate drivers - datalevel */ - // XXX: for mesh types, should we push this to derivedmesh instead? + /* XXX: for mesh types, should we push this to derivedmesh instead? */ BKE_animsys_evaluate_animdata(scene, data_id, adt, ctime, ADT_RECALC_DRIVERS); } @@ -3163,7 +3163,7 @@ struct LinkNode *BKE_object_relational_superset(struct Scene *scene, eObjectSet /* iterate over all selected and visible objects */ for (base = scene->base.first; base; base = base->next) { if (objectSet == OB_SET_ALL) { - // as we get all anyways just add it + /* as we get all anyways just add it */ Object *ob = base->object; obrel_list_add(&links, ob); } diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index a2c89967f44..52acbeb94e5 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -132,7 +132,7 @@ int countPackedFiles(Main *bmain) bSound *sound; int count = 0; - // let's check if there are packed files... + /* let's check if there are packed files... */ for (ima = bmain->image.first; ima; ima = ima->id.next) if (ima->packedfile) count++; @@ -181,13 +181,13 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char //XXX waitcursor(1); - // convert relative filenames to absolute filenames - + /* convert relative filenames to absolute filenames */ + BLI_strncpy(name, filename, sizeof(name)); BLI_path_abs(name, basepath); - - // open the file - // and create a PackedFile structure + + /* open the file + * and create a PackedFile structure */ file = BLI_open(name, O_BINARY | O_RDONLY, 0); if (file <= 0) { @@ -197,8 +197,8 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char filelen = BLI_file_descriptor_size(file); if (filelen == 0) { - // MEM_mallocN complains about MEM_mallocN(0, "bla"); - // we don't care.... + /* MEM_mallocN complains about MEM_mallocN(0, "bla"); + * we don't care.... */ data = MEM_mallocN(1, "packFile"); } else { @@ -294,7 +294,7 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i } } - // make sure the path to the file exists... + /* make sure the path to the file exists... */ BLI_make_existing_file(name); file = BLI_open(name, O_BINARY + O_WRONLY + O_CREAT + O_TRUNC, 0666); @@ -354,23 +354,23 @@ int checkPackedFile(const char *filename, PackedFile *pf) ret_val = PF_DIFFERS; } else { - // we'll have to compare the two... - + /* we'll have to compare the two... */ + file = BLI_open(name, O_BINARY | O_RDONLY, 0); if (file < 0) { ret_val = PF_NOFILE; } else { ret_val = PF_EQUAL; - + for (i = 0; i < pf->size; i += sizeof(buf)) { len = pf->size - i; if (len > sizeof(buf)) { len = sizeof(buf); } - + if (read(file, buf, len) != len) { - // read error ... + /* read error ... */ ret_val = PF_DIFFERS; break; } @@ -412,24 +412,24 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na temp = abs_name; break; case PF_USE_LOCAL: - // if file exists use it + /* if file exists use it */ if (BLI_exists(local_name)) { temp = local_name; break; } - // else fall through and create it + /* else fall through and create it */ case PF_WRITE_LOCAL: if (writePackedFile(reports, local_name, pf, 1) == RET_OK) { temp = local_name; } break; case PF_USE_ORIGINAL: - // if file exists use it + /* if file exists use it */ if (BLI_exists(abs_name)) { temp = abs_name; break; } - // else fall through and create it + /* else fall through and create it */ case PF_WRITE_ORIGINAL: if (writePackedFile(reports, abs_name, pf, 1) == RET_OK) { temp = abs_name; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index a1fe1f7b8a9..dcd1a797a7a 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -546,7 +546,7 @@ void psys_free(Object *ob, ParticleSystem *psys) psys->totchild = 0; } - // check if we are last non-visible particle system + /* check if we are last non-visible particle system */ for (tpsys = ob->particlesystem.first; tpsys; tpsys = tpsys->next) { if (tpsys->part) { if (ELEM(tpsys->part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { @@ -555,7 +555,7 @@ void psys_free(Object *ob, ParticleSystem *psys) } } } - // clear do-not-draw-flag + /* clear do-not-draw-flag */ if (!nr) ob->transflag &= ~OB_DUPLIPARTS; diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c index b82521504dd..46ddce4b51b 100644 --- a/source/blender/blenkernel/intern/property.c +++ b/source/blender/blenkernel/intern/property.c @@ -223,8 +223,8 @@ int compare_property(bProperty *prop, const char *str) case GPROP_FLOAT: case GPROP_TIME: - // WARNING: untested for GPROP_TIME - // function isn't used currently + /* WARNING: untested for GPROP_TIME + * function isn't used currently */ fvalue = *((float *)&prop->data); ftest = (float)atof(str); if (fvalue > ftest) return 1; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 3d81275bb06..6f24eadd1b6 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -257,10 +257,10 @@ void BKE_scene_free(Scene *sce) /* do not free objects! */ if (sce->gpd) { -#if 0 // removed since this can be invalid memory when freeing everything - // since the grease pencil data is freed before the scene. - // since grease pencil data is not (yet?), shared between objects - // its probably safe not to do this, some save and reload will free this. +#if 0 /* removed since this can be invalid memory when freeing everything */ + /* since the grease pencil data is freed before the scene. + * since grease pencil data is not (yet?), shared between objects + * its probably safe not to do this, some save and reload will free this. */ sce->gpd->id.us--; #endif sce->gpd = NULL; @@ -1060,7 +1060,7 @@ void BKE_scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) sound_set_cfra(sce->r.cfra); /* clear animation overrides */ - // XXX TODO... + /* XXX TODO... */ for (sce_iter = sce; sce_iter; sce_iter = sce_iter->set) { if (sce_iter->theDag == NULL) diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 6e5149d7924..2e2f0e54792 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -1848,7 +1848,7 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x TransformVars *transform = (TransformVars *)seq->effectdata; float scale_x, scale_y, translate_x, translate_y, rotate_radians; - // Scale + /* Scale */ if (transform->uniform_scale) { scale_x = scale_y = transform->ScalexIni; } @@ -1857,7 +1857,7 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x scale_y = transform->ScaleyIni; } - // Translate + /* Translate */ if (!transform->percent) { float rd_s = (scene->r.size / 100.0f); @@ -1868,8 +1868,8 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x translate_x = x * (transform->xIni / 100.0f) + (x / 2.0f); translate_y = y * (transform->yIni / 100.0f) + (y / 2.0f); } - - // Rotate + + /* Rotate */ rotate_radians = DEG2RADF(transform->rotIni); transform_image(x, y, ibuf1, out, scale_x, scale_y, translate_x, translate_y, rotate_radians, transform->interpolation); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 78ccdc425e5..902eeefd934 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2528,7 +2528,7 @@ static ImBuf *seq_render_strip_stack( #if 0 /* commentind since this breaks keyframing, since it resets the value on draw */ if (scene->r.cfra != cfra) { - // XXX for prefetch and overlay offset!..., very bad!!! + /* XXX for prefetch and overlay offset!..., very bad!!! */ AnimData *adt = BKE_animdata_from_id(&scene->id); BKE_animsys_evaluate_animdata(scene, &scene->id, adt, cfra, ADT_RECALC_ANIM); } diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 7081a642b8a..5bad69c2e8d 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -1413,11 +1413,11 @@ int BKE_texture_dependsOnTime(const struct Tex *texture) return 1; } else if (texture->adt) { - // assume anything in adt means the texture is animated + /* assume anything in adt means the texture is animated */ return 1; } else if (texture->type == TEX_NOISE) { - // noise always varies with time + /* noise always varies with time */ return 1; } return 0; diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index f72942df8b3..f22fd74baf4 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -516,7 +516,7 @@ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex c->qmax = 51; } - // Keep lossless encodes in the RGB domain. + /* Keep lossless encodes in the RGB domain. */ if (codec_id == CODEC_ID_HUFFYUV) { /* HUFFYUV was PIX_FMT_YUV422P before */ c->pix_fmt = PIX_FMT_RGB32; @@ -572,12 +572,12 @@ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex } if (codec_id == CODEC_ID_QTRLE) { - // normally it should be enough to have buffer with actual image size, - // but some codecs like QTRLE might store extra information in this buffer, - // so it should be a way larger + /* normally it should be enough to have buffer with actual image size, + * but some codecs like QTRLE might store extra information in this buffer, + * so it should be a way larger */ - // maximum video buffer size is 6-bytes per pixel, plus DPX header size (1664) - // (from FFmpeg sources) + /* maximum video buffer size is 6-bytes per pixel, plus DPX header size (1664) + * (from FFmpeg sources) */ int size = c->width * c->height; video_buffersize = 7 * size + 10000; } diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index 4bcedb06fb0..844407f9e06 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -35,8 +35,6 @@ #include "MEM_guardedalloc.h" -// #include "BLI_blenlib.h" - #include "BLI_utildefines.h" #include "BLI_mempool.h" #include "BLI_ghash.h" diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index 6a4ee64ebcd..046e5c3587c 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -52,7 +52,7 @@ typedef struct BVHNode { struct BVHNode **children; - struct BVHNode *parent; // some user defined traversed need that + struct BVHNode *parent; /* some user defined traversed need that */ struct BVHNode *skip[2]; float *bv; /* Bounding volume of all nodes, max 13 axis */ int index; /* face, edge, vertex index */ @@ -104,16 +104,15 @@ typedef struct BVHRayCastData { BVHTreeRayHit hit; } BVHRayCastData; -////////////////////////////////////////m -//////////////////////////////////////////////////////////////////////// -// Bounding Volume Hierarchy Definition -// -// Notes: From OBB until 26-DOP --> all bounding volumes possible, just choose type below -// Notes: You have to choose the type at compile time ITM -// Notes: You can choose the tree type --> binary, quad, octree, choose below -//////////////////////////////////////////////////////////////////////// +/* + * Bounding Volume Hierarchy Definition + * + * Notes: From OBB until 26-DOP --> all bounding volumes possible, just choose type below + * Notes: You have to choose the type at compile time ITM + * Notes: You can choose the tree type --> binary, quad, octree, choose below + */ static float KDOP_AXES[13][3] = { {1.0, 0, 0}, {0, 1.0, 0}, {0, 0, 1.0}, {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, -1.0}, @@ -188,13 +187,15 @@ static int ADJUST_MEMORY(void *local_memblock, void **memblock, int new_size, in } #endif -////////////////////////////////////////////////////////////////////////////////////////////////////// -// Introsort -// with permission deriven from the following Java code: -// http://ralphunden.net/content/tutorials/a-guide-to-introsort/ -// and he derived it from the SUN STL -////////////////////////////////////////////////////////////////////////////////////////////////////// +/* + * Introsort + * with permission deriven from the following Java code: + * http://ralphunden.net/content/tutorials/a-guide-to-introsort/ + * and he derived it from the SUN STL + */ + //static int size_threshold = 16; + /* * Common methods for all algorithms */ @@ -336,9 +337,9 @@ static void sort_along_axis(BVHTree *tree, int start, int end, int axis) } #endif -//after a call to this function you can expect one of: -// every node to left of a[n] are smaller or equal to it -// every node to the right of a[n] are greater or equal to it +/* after a call to this function you can expect one of: + * - every node to left of a[n] are smaller or equal to it + * - every node to the right of a[n] are greater or equal to it */ static int partition_nth_element(BVHNode **a, int _begin, int _end, int n, int axis) { int begin = _begin, end = _end, cut; @@ -354,7 +355,7 @@ static int partition_nth_element(BVHNode **a, int _begin, int _end, int n, int a return n; } -////////////////////////////////////////////////////////////////////////////////////////////////////// +/* --- */ static void build_skip_links(BVHTree *tree, BVHNode *node, BVHNode *left, BVHNode *right) { int i; @@ -381,8 +382,8 @@ static void create_kdop_hull(BVHTree *tree, BVHNode *node, const float *co, int float *bv = node->bv; int i, k; - // don't init boudings for the moving case - if (!moving) { + /* don't init boudings for the moving case */ + if (!moving) { for (i = tree->start_axis; i < tree->stop_axis; i++) { bv[2 * i] = FLT_MAX; bv[2 * i + 1] = -FLT_MAX; @@ -401,7 +402,7 @@ static void create_kdop_hull(BVHTree *tree, BVHNode *node, const float *co, int } } -// depends on the fact that the BVH's for each face is already build +/* depends on the fact that the BVH's for each face is already build */ static void refit_kdop_hull(BVHTree *tree, BVHNode *node, int start, int end) { float newmin, newmax; @@ -429,31 +430,31 @@ static void refit_kdop_hull(BVHTree *tree, BVHNode *node, int start, int end) } -// only supports x,y,z axis in the moment -// but we should use a plain and simple function here for speed sake +/* only supports x,y,z axis in the moment + * but we should use a plain and simple function here for speed sake */ static char get_largest_axis(float *bv) { float middle_point[3]; - middle_point[0] = (bv[1]) - (bv[0]); // x axis - middle_point[1] = (bv[3]) - (bv[2]); // y axis - middle_point[2] = (bv[5]) - (bv[4]); // z axis + middle_point[0] = (bv[1]) - (bv[0]); /* x axis */ + middle_point[1] = (bv[3]) - (bv[2]); /* y axis */ + middle_point[2] = (bv[5]) - (bv[4]); /* z axis */ if (middle_point[0] > middle_point[1]) { if (middle_point[0] > middle_point[2]) - return 1; // max x axis + return 1; /* max x axis */ else - return 5; // max z axis + return 5; /* max z axis */ } else { if (middle_point[1] > middle_point[2]) - return 3; // max y axis + return 3; /* max y axis */ else - return 5; // max z axis + return 5; /* max z axis */ } } -// bottom-up update of bvh node BV -// join the children on the parent BV +/* bottom-up update of bvh node BV + * join the children on the parent BV */ static void node_join(BVHTree *tree, BVHNode *node) { int i, j; @@ -466,11 +467,11 @@ static void node_join(BVHTree *tree, BVHNode *node) for (i = 0; i < tree->tree_type; i++) { if (node->children[i]) { for (j = tree->start_axis; j < tree->stop_axis; j++) { - // update minimum - if (node->children[i]->bv[(2 * j)] < node->bv[(2 * j)]) + /* update minimum */ + if (node->children[i]->bv[(2 * j)] < node->bv[(2 * j)]) node->bv[(2 * j)] = node->children[i]->bv[(2 * j)]; - - // update maximum + + /* update maximum */ if (node->children[i]->bv[(2 * j) + 1] > node->bv[(2 * j) + 1]) node->bv[(2 * j) + 1] = node->children[i]->bv[(2 * j) + 1]; } @@ -523,7 +524,7 @@ static void verify_tree(BVHTree *tree) { int i, j, check = 0; - // check the pointer list + /* check the pointer list */ for (i = 0; i < tree->totleaf; i++) { if (tree->nodes[i]->parent == NULL) { @@ -543,7 +544,7 @@ static void verify_tree(BVHTree *tree) } } - // check the leaf list + /* check the leaf list */ for (i = 0; i < tree->totleaf; i++) { if (tree->nodearray[i].parent == NULL) { @@ -567,8 +568,8 @@ static void verify_tree(BVHTree *tree) } #endif -//Helper data and structures to build a min-leaf generalized implicit tree -//This code can be easily reduced (basicly this is only method to calculate pow(k, n) in O(1).. and stuff like that) +/* Helper data and structures to build a min-leaf generalized implicit tree + * This code can be easily reduced (basicly this is only method to calculate pow(k, n) in O(1).. and stuff like that) */ typedef struct BVHBuildHelper { int tree_type; /* */ int totleafs; /* */ @@ -589,7 +590,7 @@ static void build_implicit_tree_helper(BVHTree *tree, BVHBuildHelper *data) data->totleafs = tree->totleaf; data->tree_type = tree->tree_type; - //Calculate the smallest tree_type^n such that tree_type^n >= num_leafs + /* Calculate the smallest tree_type^n such that tree_type^n >= num_leafs */ for (data->leafs_per_child[0] = 1; data->leafs_per_child[0] < data->totleafs; data->leafs_per_child[0] *= data->tree_type) @@ -599,7 +600,7 @@ static void build_implicit_tree_helper(BVHTree *tree, BVHBuildHelper *data) data->branches_on_level[0] = 1; - //We could stop the loop first (but I am lazy to find out when) + /* We could stop the loop first (but I am lazy to find out when) */ for (depth = 1; depth < 32; depth++) { data->branches_on_level[depth] = data->branches_on_level[depth - 1] * data->tree_type; data->leafs_per_child[depth] = data->leafs_per_child[depth - 1] / data->tree_type; @@ -700,18 +701,18 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array, int i; const int tree_type = tree->tree_type; - const int tree_offset = 2 - tree->tree_type; //this value is 0 (on binary trees) and negative on the others + const int tree_offset = 2 - tree->tree_type; /* this value is 0 (on binary trees) and negative on the others */ const int num_branches = implicit_needed_branches(tree_type, num_leafs); BVHBuildHelper data; int depth; - // set parent from root node to NULL + /* set parent from root node to NULL */ BVHNode *tmp = branches_array + 0; tmp->parent = NULL; - //Most of bvhtree code relies on 1-leaf trees having at least one branch - //We handle that special case here + /*Most of bvhtree code relies on 1-leaf trees having at least one branch + *We handle that special case here */ if (num_leafs == 1) { BVHNode *root = branches_array + 0; refit_kdop_hull(tree, root, 0, num_leafs); @@ -722,17 +723,17 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array, return; } - branches_array--; //Implicit trees use 1-based indexs - + branches_array--; /* Implicit trees use 1-based indexs */ + build_implicit_tree_helper(tree, &data); - //Loop tree levels (log N) loops + /* Loop tree levels (log N) loops */ for (i = 1, depth = 1; i <= num_branches; i = i * tree_type + tree_offset, depth++) { const int first_of_next_level = i * tree_type + tree_offset; - const int end_j = MIN2(first_of_next_level, num_branches + 1); //index of last branch on this level + const int end_j = MIN2(first_of_next_level, num_branches + 1); /* index of last branch on this level */ int j; - //Loop all branches on this level + /* Loop all branches on this level */ #pragma omp parallel for private(j) schedule(static) for (j = i; j < end_j; j++) { int k; @@ -744,34 +745,34 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array, int parent_leafs_begin = implicit_leafs_index(&data, depth, parent_level_index); int parent_leafs_end = implicit_leafs_index(&data, depth, parent_level_index + 1); - //This calculates the bounding box of this branch - //and chooses the largest axis as the axis to divide leafs + /* This calculates the bounding box of this branch + * and chooses the largest axis as the axis to divide leafs */ refit_kdop_hull(tree, parent, parent_leafs_begin, parent_leafs_end); split_axis = get_largest_axis(parent->bv); - //Save split axis (this can be used on raytracing to speedup the query time) + /* Save split axis (this can be used on raytracing to speedup the query time) */ parent->main_axis = split_axis / 2; - //Split the childs along the split_axis, note: its not needed to sort the whole leafs array - //Only to assure that the elements are partioned on a way that each child takes the elements - //it would take in case the whole array was sorted. - //Split_leafs takes care of that "sort" problem. + /* Split the childs along the split_axis, note: its not needed to sort the whole leafs array + * Only to assure that the elements are partioned on a way that each child takes the elements + * it would take in case the whole array was sorted. + * Split_leafs takes care of that "sort" problem. */ nth_positions[0] = parent_leafs_begin; nth_positions[tree_type] = parent_leafs_end; for (k = 1; k < tree_type; k++) { int child_index = j * tree_type + tree_offset + k; - int child_level_index = child_index - first_of_next_level; //child level index + int child_level_index = child_index - first_of_next_level; /* child level index */ nth_positions[k] = implicit_leafs_index(&data, depth + 1, child_level_index); } split_leafs(leafs_array, nth_positions, tree_type, split_axis); - //Setup children and totnode counters - //Not really needed but currently most of BVH code relies on having an explicit children structure + /* Setup children and totnode counters + * Not really needed but currently most of BVH code relies on having an explicit children structure */ for (k = 0; k < tree_type; k++) { int child_index = j * tree_type + tree_offset + k; - int child_level_index = child_index - first_of_next_level; //child level index + int child_level_index = child_index - first_of_next_level; /* child level index */ int child_leafs_begin = implicit_leafs_index(&data, depth + 1, child_level_index); int child_leafs_end = implicit_leafs_index(&data, depth + 1, child_level_index + 1); @@ -803,20 +804,20 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis) BVHTree *tree; int numnodes, i; - // theres not support for trees below binary-trees :P + /* theres not support for trees below binary-trees :P */ if (tree_type < 2) return NULL; - + if (tree_type > MAX_TREETYPE) return NULL; tree = (BVHTree *)MEM_callocN(sizeof(BVHTree), "BVHTree"); - //tree epsilon must be >= FLT_EPSILON - //so that tangent rays can still hit a bounding volume.. - //this bug would show up when casting a ray aligned with a kdop-axis and with an edge of 2 faces + /* tree epsilon must be >= FLT_EPSILON + * so that tangent rays can still hit a bounding volume.. + * this bug would show up when casting a ray aligned with a kdop-axis and with an edge of 2 faces */ epsilon = MAX2(FLT_EPSILON, epsilon); - + if (tree) { tree->epsilon = epsilon; tree->tree_type = tree_type; @@ -910,59 +911,59 @@ void BLI_bvhtree_balance(BVHTree *tree) BVHNode *branches_array = tree->nodearray + tree->totleaf; BVHNode **leafs_array = tree->nodes; - //This function should only be called once (some big bug goes here if its being called more than once per tree) + /* This function should only be called once (some big bug goes here if its being called more than once per tree) */ assert(tree->totbranch == 0); - //Build the implicit tree + /* Build the implicit tree */ non_recursive_bvh_div_nodes(tree, branches_array, leafs_array, tree->totleaf); - //current code expects the branches to be linked to the nodes array - //we perform that linkage here + /*current code expects the branches to be linked to the nodes array + *we perform that linkage here */ tree->totbranch = implicit_needed_branches(tree->tree_type, tree->totleaf); for (i = 0; i < tree->totbranch; i++) tree->nodes[tree->totleaf + i] = branches_array + i; build_skip_links(tree, tree->nodes[tree->totleaf], NULL, NULL); - //bvhtree_info(tree); + /* bvhtree_info(tree); */ } int BLI_bvhtree_insert(BVHTree *tree, int index, const float *co, int numpoints) { int i; BVHNode *node = NULL; - - // insert should only possible as long as tree->totbranch is 0 + + /* insert should only possible as long as tree->totbranch is 0 */ if (tree->totbranch > 0) return 0; - + if (tree->totleaf + 1 >= MEM_allocN_len(tree->nodes) / sizeof(*(tree->nodes))) return 0; - - // TODO check if have enough nodes in array - + + /* TODO check if have enough nodes in array */ + node = tree->nodes[tree->totleaf] = &(tree->nodearray[tree->totleaf]); tree->totleaf++; - + create_kdop_hull(tree, node, co, numpoints, 0); node->index = index; - - // inflate the bv with some epsilon + + /* inflate the bv with some epsilon */ for (i = tree->start_axis; i < tree->stop_axis; i++) { - node->bv[(2 * i)] -= tree->epsilon; // minimum - node->bv[(2 * i) + 1] += tree->epsilon; // maximum + node->bv[(2 * i)] -= tree->epsilon; /* minimum */ + node->bv[(2 * i) + 1] += tree->epsilon; /* maximum */ } return 1; } -// call before BLI_bvhtree_update_tree() +/* call before BLI_bvhtree_update_tree() */ int BLI_bvhtree_update_node(BVHTree *tree, int index, const float *co, const float *co_moving, int numpoints) { int i; BVHNode *node = NULL; - // check if index exists + /* check if index exists */ if (index > tree->totleaf) return 0; @@ -982,12 +983,12 @@ int BLI_bvhtree_update_node(BVHTree *tree, int index, const float *co, const flo return 1; } -// call BLI_bvhtree_update_node() first for every node/point/triangle +/* call BLI_bvhtree_update_node() first for every node/point/triangle */ void BLI_bvhtree_update_tree(BVHTree *tree) { - //Update bottom=>top - //TRICKY: the way we build the tree all the childs have an index greater than the parent - //This allows us todo a bottom up update by starting on the biger numbered branch + /* Update bottom=>top + * TRICKY: the way we build the tree all the childs have an index greater than the parent + * This allows us todo a bottom up update by starting on the biger numbered branch */ BVHNode **root = tree->nodes + tree->totleaf; BVHNode **index = tree->nodes + tree->totleaf + tree->totbranch - 1; @@ -1004,8 +1005,8 @@ float BLI_bvhtree_getepsilon(BVHTree *tree) /* * BLI_bvhtree_overlap - */ -// overlap - is it possbile for 2 bv's to collide ? + * + * overlap - is it possbile for 2 bv's to collide ? */ static int tree_overlap(BVHNode *node1, BVHNode *node2, int start_axis, int stop_axis) { float *bv1 = node1->bv; @@ -1016,31 +1017,31 @@ static int tree_overlap(BVHNode *node1, BVHNode *node2, int start_axis, int stop bv1 += start_axis << 1; bv2 += start_axis << 1; - // test all axis if min + max overlap + /* test all axis if min + max overlap */ for (; bv1 != bv1_end; bv1 += 2, bv2 += 2) { - if ((*(bv1) > *(bv2 + 1)) || (*(bv2) > *(bv1 + 1))) + if ((*(bv1) > *(bv2 + 1)) || (*(bv2) > *(bv1 + 1))) return 0; } - + return 1; } static void traverse(BVHOverlapData *data, BVHNode *node1, BVHNode *node2) { int j; - + if (tree_overlap(node1, node2, data->start_axis, data->stop_axis)) { - // check if node1 is a leaf + /* check if node1 is a leaf */ if (!node1->totnode) { - // check if node2 is a leaf + /* check if node2 is a leaf */ if (!node2->totnode) { - + if (node1 == node2) { return; } - + if (data->i >= data->max_overlap) { - // try to make alloc'ed memory bigger + /* try to make alloc'ed memory bigger */ data->overlap = realloc(data->overlap, sizeof(BVHTreeOverlap) * data->max_overlap * 2); if (!data->overlap) { @@ -1222,14 +1223,14 @@ PUSH_HEAP_BODY(NodeDistance, NodeDistance_priority, heap, heap_size) static void NodeDistance_pop_heap(NodeDistance *heap, int heap_size) POP_HEAP_BODY(NodeDistance, NodeDistance_priority, heap, heap_size) -//NN function that uses an heap.. this functions leads to an optimal number of min-distance -//but for normal tri-faces and BV 6-dop.. a simple dfs with local heuristics (as implemented -//in source/blender/blenkernel/intern/shrinkwrap.c) works faster. -// -//It may make sense to use this function if the callback queries are very slow.. or if its impossible -//to get a nice heuristic -// -//this function uses "malloc/free" instead of the MEM_* because it intends to be openmp safe +/* NN function that uses an heap.. this functions leads to an optimal number of min-distance + * but for normal tri-faces and BV 6-dop.. a simple dfs with local heuristics (as implemented + * in source/blender/blenkernel/intern/shrinkwrap.c) works faster. + * + * It may make sense to use this function if the callback queries are very slow.. or if its impossible + * to get a nice heuristic + * + * this function uses "malloc/free" instead of the MEM_* because it intends to be openmp safe */ static void bfs_find_nearest(BVHNearestData *data, BVHNode *node) { int i; @@ -1327,11 +1328,11 @@ int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *n data.nearest.dist = FLT_MAX; } - //dfs search + /* dfs search */ if (root) dfs_find_nearest_begin(&data, root); - //copy back results + /* copy back results */ if (nearest) { memcpy(nearest, &data.nearest, sizeof(*nearest)); } @@ -1347,7 +1348,7 @@ int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *n */ -//Determines the distance that the ray must travel to hit the bounding volume of the given node +/* Determines the distance that the ray must travel to hit the bounding volume of the given node */ static float ray_nearest_hit(BVHRayCastData *data, float *bv) { int i; @@ -1382,11 +1383,11 @@ static float ray_nearest_hit(BVHRayCastData *data, float *bv) return low; } -//Determines the distance that the ray must travel to hit the bounding volume of the given node -//Based on Tactical Optimization of Ray/Box Intersection, by Graham Fyffe -//[http://tog.acm.org/resources/RTNews/html/rtnv21n1.html#art9] -// -//TODO this doens't has data->ray.radius in consideration +/* Determines the distance that the ray must travel to hit the bounding volume of the given node + * Based on Tactical Optimization of Ray/Box Intersection, by Graham Fyffe + * [http://tog.acm.org/resources/RTNews/html/rtnv21n1.html#art9] + * + * TODO this doens't has data->ray.radius in consideration */ static float fast_ray_nearest_hit(const BVHRayCastData *data, const BVHNode *node) { const float *bv = node->bv; @@ -1413,8 +1414,8 @@ static void dfs_raycast(BVHRayCastData *data, BVHNode *node) { int i; - //ray-bv is really fast.. and simple tests revealed its worth to test it - //before calling the ray-primitive functions + /* ray-bv is really fast.. and simple tests revealed its worth to test it + * before calling the ray-primitive functions */ /* XXX: temporary solution for particles until fast_ray_nearest_hit supports ray.radius */ float dist = (data->ray.radius > 0.0f) ? ray_nearest_hit(data, node->bv) : fast_ray_nearest_hit(data, node); if (dist >= data->hit.dist) return; @@ -1430,7 +1431,7 @@ static void dfs_raycast(BVHRayCastData *data, BVHNode *node) } } else { - //pick loop direction to dive into the tree (based on ray direction and split axis) + /* pick loop direction to dive into the tree (based on ray direction and split axis) */ if (data->ray_dot_axis[(int)node->main_axis] > 0.0f) { for (i = 0; i != node->totnode; i++) { dfs_raycast(data, node->children[i]); diff --git a/source/blender/blenlib/intern/DLRB_tree.c b/source/blender/blenlib/intern/DLRB_tree.c index 62d3b4e448c..c8c2ad35380 100644 --- a/source/blender/blenlib/intern/DLRB_tree.c +++ b/source/blender/blenlib/intern/DLRB_tree.c @@ -230,7 +230,7 @@ DLRBT_Node *BLI_dlrbTree_search_prev(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_c return node; /* return the previous node otherwise */ - // NOTE: what happens if there is no previous node? + /* NOTE: what happens if there is no previous node? */ return node->prev; } @@ -257,7 +257,7 @@ DLRBT_Node *BLI_dlrbTree_search_next(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_c return node; /* return the previous node otherwise */ - // NOTE: what happens if there is no previous node? + /* NOTE: what happens if there is no previous node? */ return node->next; } diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index 5f564f71646..7aa956a0548 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -274,12 +274,12 @@ int BLI_move(const char *file, const char *to) { int err; - // windows doesn't support moveing to a directory - // it has to be 'mv filename filename' and not - // 'mv filename destdir' + /* windows doesn't support moveing to a directory + * it has to be 'mv filename filename' and not + * 'mv filename destdir' */ BLI_strncpy(str, to, sizeof(str)); - // points 'to' to a directory ? + /* points 'to' to a directory ? */ if (BLI_last_slash(str) == (str + strlen(str) - 1)) { if (BLI_last_slash(file) != NULL) { strcat(str, BLI_last_slash(file) + 1); @@ -305,12 +305,12 @@ int BLI_copy(const char *file, const char *to) { int err; - // windows doesn't support copying to a directory - // it has to be 'cp filename filename' and not - // 'cp filename destdir' + /* windows doesn't support copying to a directory + * it has to be 'cp filename filename' and not + * 'cp filename destdir' */ BLI_strncpy(str, to, sizeof(str)); - // points 'to' to a directory ? + /* points 'to' to a directory ? */ if (BLI_last_slash(str) == (str + strlen(str) - 1)) { if (BLI_last_slash(file) != NULL) { strcat(str, BLI_last_slash(file) + 1); diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index 10eeda96b5d..a499f9a81ea 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -71,55 +71,55 @@ static FT_Error err; static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vfd) { - // Blender + /* Blender */ struct Nurb *nu; struct VChar *che; struct BezTriple *bezt; - - // Freetype2 + + /* Freetype2 */ FT_GlyphSlot glyph; FT_UInt glyph_index; FT_Outline ftoutline; float scale, height; float dx, dy; int j, k, l, m = 0; - - // adjust font size + + /* adjust font size */ height = ((double) face->bbox.yMax - (double) face->bbox.yMin); if (height != 0.0f) scale = 1.0f / height; else scale = 1.0f / 1000.0f; - - // - // Generate the character 3D data - // - // Get the FT Glyph index and load the Glyph + + /* + * Generate the character 3D data + * + * Get the FT Glyph index and load the Glyph */ glyph_index = FT_Get_Char_Index(face, charcode); err = FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP); - - // If loading succeeded, convert the FT glyph to the internal format + + /* If loading succeeded, convert the FT glyph to the internal format */ if (!err) { int *npoints; int *onpoints; - - // First we create entry for the new character to the character list + + /* First we create entry for the new character to the character list */ che = (VChar *) MEM_callocN(sizeof(struct VChar), "objfnt_char"); BLI_addtail(&vfd->characters, che); - - // Take some data for modifying purposes + + /* Take some data for modifying purposes */ glyph = face->glyph; ftoutline = glyph->outline; - - // Set the width and character code + + /* Set the width and character code */ che->index = charcode; che->width = glyph->advance.x * scale; - - // Start converting the FT data + + /* Start converting the FT data */ npoints = (int *)MEM_callocN((ftoutline.n_contours) * sizeof(int), "endpoints"); onpoints = (int *)MEM_callocN((ftoutline.n_contours) * sizeof(int), "onpoints"); - // calculate total points of each contour + /* calculate total points of each contour */ for (j = 0; j < ftoutline.n_contours; j++) { if (j == 0) npoints[j] = ftoutline.contours[j] + 1; @@ -127,7 +127,7 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf npoints[j] = ftoutline.contours[j] - ftoutline.contours[j - 1]; } - // get number of on-curve points for beziertriples (including conic virtual on-points) + /* get number of on-curve points for beziertriples (including conic virtual on-points) */ for (j = 0; j < ftoutline.n_contours; j++) { for (k = 0; k < npoints[j]; k++) { l = (j > 0) ? (k + ftoutline.contours[j - 1] + 1) : k; @@ -145,9 +145,9 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf } } - //contour loop, bezier & conic styles merged + /* contour loop, bezier & conic styles merged */ for (j = 0; j < ftoutline.n_contours; j++) { - // add new curve + /* add new curve */ nu = (Nurb *)MEM_callocN(sizeof(struct Nurb), "objfnt_nurb"); bezt = (BezTriple *)MEM_callocN((onpoints[j]) * sizeof(BezTriple), "objfnt_bezt"); BLI_addtail(&che->nurbsbase, nu); @@ -159,26 +159,26 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf nu->flagu = CU_NURB_CYCLIC; nu->bezt = bezt; - //individual curve loop, start-end + /* individual curve loop, start-end */ for (k = 0; k < npoints[j]; k++) { if (j > 0) l = k + ftoutline.contours[j - 1] + 1; else l = k; if (k == 0) m = l; - - //virtual conic on-curve points + + /* virtual conic on-curve points */ if (k < npoints[j] - 1) { if (ftoutline.tags[l] == FT_Curve_Tag_Conic && ftoutline.tags[l + 1] == FT_Curve_Tag_Conic) { dx = (ftoutline.points[l].x + ftoutline.points[l + 1].x) * scale / 2.0f; dy = (ftoutline.points[l].y + ftoutline.points[l + 1].y) * scale / 2.0f; - //left handle + /* left handle */ bezt->vec[0][0] = (dx + (2 * ftoutline.points[l].x) * scale) / 3.0f; bezt->vec[0][1] = (dy + (2 * ftoutline.points[l].y) * scale) / 3.0f; - //midpoint (virtual on-curve point) + /* midpoint (virtual on-curve point) */ bezt->vec[1][0] = dx; bezt->vec[1][1] = dy; - //right handle + /* right handle */ bezt->vec[2][0] = (dx + (2 * ftoutline.points[l + 1].x) * scale) / 3.0f; bezt->vec[2][1] = (dy + (2 * ftoutline.points[l + 1].y) * scale) / 3.0f; @@ -188,9 +188,9 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf } } - //on-curve points + /* on-curve points */ if (ftoutline.tags[l] == FT_Curve_Tag_On) { - //left handle + /* left handle */ if (k > 0) { if (ftoutline.tags[l - 1] == FT_Curve_Tag_Cubic) { bezt->vec[0][0] = ftoutline.points[l - 1].x * scale; @@ -208,7 +208,7 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf bezt->h1 = HD_VECT; } } - else { //first point on curve + else { /* first point on curve */ if (ftoutline.tags[ftoutline.contours[j]] == FT_Curve_Tag_Cubic) { bezt->vec[0][0] = ftoutline.points[ftoutline.contours[j]].x * scale; bezt->vec[0][1] = ftoutline.points[ftoutline.contours[j]].y * scale; @@ -226,11 +226,11 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf } } - //midpoint (on-curve point) + /* midpoint (on-curve point) */ bezt->vec[1][0] = ftoutline.points[l].x * scale; bezt->vec[1][1] = ftoutline.points[l].y * scale; - //right handle + /* right handle */ if (k < (npoints[j] - 1)) { if (ftoutline.tags[l + 1] == FT_Curve_Tag_Cubic) { bezt->vec[2][0] = ftoutline.points[l + 1].x * scale; @@ -248,7 +248,7 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf bezt->h2 = HD_VECT; } } - else { //last point on curve + else { /* last point on curve */ if (ftoutline.tags[m] == FT_Curve_Tag_Cubic) { bezt->vec[2][0] = ftoutline.points[m].x * scale; bezt->vec[2][1] = ftoutline.points[m].y * scale; @@ -294,17 +294,17 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf static int objchr_to_ftvfontdata(VFont *vfont, FT_ULong charcode) { - // Freetype2 + /* Freetype2 */ FT_Face face; struct TmpFont *tf; - - // Find the correct FreeType font + + /* Find the correct FreeType font */ tf = BKE_vfont_find_tmpfont(vfont); - - // What, no font found. Something strange here + + /* What, no font found. Something strange here */ if (!tf) return FALSE; - - // Load the font to memory + + /* Load the font to memory */ if (tf->pf) { err = FT_New_Memory_Face(library, tf->pf->data, @@ -318,17 +318,17 @@ static int objchr_to_ftvfontdata(VFont *vfont, FT_ULong charcode) return FALSE; } - // Read the char + /* Read the char */ freetypechar_to_vchar(face, charcode, vfont->data); - // And everything went ok + /* And everything went ok */ return TRUE; } static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) { - // Variables + /* Variables */ FT_Face face; FT_ULong charcode = 0, lcode; FT_UInt glyph_index; @@ -343,7 +343,7 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) int n; #endif - // load the freetype font + /* load the freetype font */ err = FT_New_Memory_Face(library, pf->data, pf->size, @@ -366,22 +366,22 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) if (!found) { return NULL; } - // now, select the charmap for the face object + /* now, select the charmap for the face object */ err = FT_Set_Charmap(face, found); if (err) { return NULL; } #endif - // allocate blender font + /* allocate blender font */ vfd = MEM_callocN(sizeof(*vfd), "FTVFontData"); - // get the name + /* get the name */ fontname = FT_Get_Postscript_Name(face); BLI_strncpy(vfd->name, (fontname == NULL) ? "" : fontname, sizeof(vfd->name)); - // Extract the first 256 character from TTF + /* Extract the first 256 character from TTF */ lcode = charcode = FT_Get_First_Char(face, &glyph_index); - // No charmap found from the ttf so we need to figure it out + /* No charmap found from the ttf so we need to figure it out */ if (glyph_index == 0) { FT_CharMap found = NULL; FT_CharMap charmap; @@ -403,15 +403,15 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) lcode = charcode = FT_Get_First_Char(face, &glyph_index); } - // Load characters + /* Load characters */ while (charcode < 256) { - // Generate the font data + /* Generate the font data */ freetypechar_to_vchar(face, charcode, vfd); - // Next glyph + /* Next glyph */ charcode = FT_Get_Next_Char(face, charcode, &glyph_index); - // Check that we won't start infinite loop + /* Check that we won't start infinite loop */ if (charcode <= lcode) break; lcode = charcode; @@ -457,7 +457,7 @@ static int check_freetypefont(PackedFile *pf) if (!found) { return 0; } - // now, select the charmap for the face object + /* now, select the charmap for the face object */ err = FT_Set_Charmap(face, found); if (err) { return 0; } #endif @@ -511,21 +511,21 @@ int BLI_vfontchar_from_freetypefont(VFont *vfont, unsigned long character) if (!vfont) return FALSE; - // Init Freetype + /* Init Freetype */ err = FT_Init_FreeType(&library); if (err) { - //XXX error("Failed to load the Freetype font library"); + /* XXX error("Failed to load the Freetype font library"); */ return 0; } - // Load the character + /* Load the character */ success = objchr_to_ftvfontdata(vfont, character); if (success == FALSE) return FALSE; - // Free Freetype + /* Free Freetype */ FT_Done_FreeType(library); - // Ahh everything ok + /* Ahh everything ok */ return TRUE; } diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 402aacf369a..a7ffb95172e 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -554,29 +554,29 @@ static short IsectLLPt2Df(const float x0, const float y0, const float x1, const * compute slopes, note the cludge for infinity, however, this will * be close enough */ - if (fabs(x1 - x0) > 0.000001) + if (fabs(x1 - x0) > 0.000001f) m1 = (y1 - y0) / (x1 - x0); else - return -1; /*m1 = (float)1e+10;*/ // close enough to infinity + return -1; /*m1 = (float)1e+10;*/ /* close enough to infinity */ - if (fabs(x3 - x2) > 0.000001) + if (fabs(x3 - x2) > 0.000001f) m2 = (y3 - y2) / (x3 - x2); else - return -1; /*m2 = (float)1e+10;*/ // close enough to infinity + return -1; /*m2 = (float)1e+10;*/ /* close enough to infinity */ - if (fabs(m1 - m2) < 0.000001) + if (fabs(m1 - m2) < 0.000001f) return -1; /* parallel lines */ - // compute constants + /* compute constants */ c1 = (y0 - m1 * x0); c2 = (y2 - m2 * x2); - // compute the inverse of the determinate + /* compute the inverse of the determinate */ det_inv = 1.0f / (-m1 + m2); - // use Kramers rule to compute xi and yi + /* use Kramers rule to compute xi and yi */ *xi = ((-c2 + c1) * det_inv); *yi = ((m2 * c1 - m1 * c2) * det_inv); @@ -1123,15 +1123,17 @@ int isect_axial_line_tri_v3(const int axis, const float p1[3], const float p2[3] float u, v, f; int a0 = axis, a1 = (axis + 1) % 3, a2 = (axis + 2) % 3; - //return isect_line_tri_v3(p1,p2,v0,v1,v2,lambda); +#if 0 + return isect_line_tri_v3(p1,p2,v0,v1,v2,lambda); - ///* first a simple bounding box test */ - //if (MIN3(v0[a1],v1[a1],v2[a1]) > p1[a1]) return 0; - //if (MIN3(v0[a2],v1[a2],v2[a2]) > p1[a2]) return 0; - //if (MAX3(v0[a1],v1[a1],v2[a1]) < p1[a1]) return 0; - //if (MAX3(v0[a2],v1[a2],v2[a2]) < p1[a2]) return 0; + /* first a simple bounding box test */ + if (MIN3(v0[a1],v1[a1],v2[a1]) > p1[a1]) return 0; + if (MIN3(v0[a2],v1[a2],v2[a2]) > p1[a2]) return 0; + if (MAX3(v0[a1],v1[a1],v2[a1]) < p1[a1]) return 0; + if (MAX3(v0[a2],v1[a2],v2[a2]) < p1[a2]) return 0; - ///* then a full intersection test */ + /* then a full intersection test */ +#endif sub_v3_v3v3(e1, v1, v0); sub_v3_v3v3(e2, v2, v0); @@ -1331,9 +1333,9 @@ int isect_ray_aabb(const IsectRayAABBData *data, const float bb_min[3], if (tzmin > tmin) tmin = tzmin; - // XXX jwilkins: tmax does not need to be updated since we don't use it - // keeping this here for future reference - //if (tzmax < tmax) tmax = tzmax; + /* XXX jwilkins: tmax does not need to be updated since we don't use it + * keeping this here for future reference */ + //if (tzmax < tmax) tmax = tzmax; if (tmin_out) (*tmin_out) = tmin; @@ -2803,21 +2805,21 @@ static int ff_visible_quad(const float p[3], const float n[3], if (sd[0] > 0) { if (sd[1] > 0) { if (sd[2] > 0) { - // +++ + /* +++ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // ++- + /* ++- */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); vec_add_dir(q3, v0, v2, (sd[0] / (sd[0] - sd[2]))); } else { - // ++0 + /* ++0 */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -2826,21 +2828,21 @@ static int ff_visible_quad(const float p[3], const float n[3], } else if (sd[1] < 0) { if (sd[2] > 0) { - // +-+ + /* +-+ */ copy_v3_v3(q0, v0); vec_add_dir(q1, v0, v1, (sd[0] / (sd[0] - sd[1]))); vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q3, v2); } else if (sd[2] < 0) { - // +-- + /* +-- */ copy_v3_v3(q0, v0); vec_add_dir(q1, v0, v1, (sd[0] / (sd[0] - sd[1]))); vec_add_dir(q2, v0, v2, (sd[0] / (sd[0] - sd[2]))); copy_v3_v3(q3, q2); } else { - // +-0 + /* +-0 */ copy_v3_v3(q0, v0); vec_add_dir(q1, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q2, v2); @@ -2849,21 +2851,21 @@ static int ff_visible_quad(const float p[3], const float n[3], } else { if (sd[2] > 0) { - // +0+ + /* +0+ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // +0- + /* +0- */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); vec_add_dir(q2, v0, v2, (sd[0] / (sd[0] - sd[2]))); copy_v3_v3(q3, q2); } else { - // +00 + /* +00 */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -2874,21 +2876,21 @@ static int ff_visible_quad(const float p[3], const float n[3], else if (sd[0] < 0) { if (sd[1] > 0) { if (sd[2] > 0) { - // -++ + /* -++ */ vec_add_dir(q0, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); vec_add_dir(q3, v0, v2, (sd[0] / (sd[0] - sd[2]))); } else if (sd[2] < 0) { - // -+- + /* -+- */ vec_add_dir(q0, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q1, v1); vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q3, q2); } else { - // -+0 + /* -+0 */ vec_add_dir(q0, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -2897,35 +2899,35 @@ static int ff_visible_quad(const float p[3], const float n[3], } else if (sd[1] < 0) { if (sd[2] > 0) { - // --+ + /* --+ */ vec_add_dir(q0, v0, v2, (sd[0] / (sd[0] - sd[2]))); vec_add_dir(q1, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // --- + /* --- */ return 0; } else { - // --0 + /* --0 */ return 0; } } else { if (sd[2] > 0) { - // -0+ + /* -0+ */ vec_add_dir(q0, v0, v2, (sd[0] / (sd[0] - sd[2]))); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // -0- + /* -0- */ return 0; } else { - // -00 + /* -00 */ return 0; } } @@ -2933,21 +2935,21 @@ static int ff_visible_quad(const float p[3], const float n[3], else { if (sd[1] > 0) { if (sd[2] > 0) { - // 0++ + /* 0++ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // 0+- + /* 0+- */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q3, q2); } else { - // 0+0 + /* 0+0 */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -2956,35 +2958,35 @@ static int ff_visible_quad(const float p[3], const float n[3], } else if (sd[1] < 0) { if (sd[2] > 0) { - // 0-+ + /* 0-+ */ copy_v3_v3(q0, v0); vec_add_dir(q1, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // 0-- + /* 0-- */ return 0; } else { - // 0-0 + /* 0-0 */ return 0; } } else { if (sd[2] > 0) { - // 00+ + /* 00+ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // 00- + /* 00- */ return 0; } else { - // 000 + /* 000 */ return 0; } } diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index f1e08993825..ab5601fc2dc 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -1199,12 +1199,12 @@ typedef struct RotOrderInfo { */ static RotOrderInfo rotOrders[] = { /* i, j, k, n */ - {{0, 1, 2}, 0}, // XYZ - {{0, 2, 1}, 1}, // XZY - {{1, 0, 2}, 1}, // YXZ - {{1, 2, 0}, 0}, // YZX - {{2, 0, 1}, 0}, // ZXY - {{2, 1, 0}, 1} // ZYX + {{0, 1, 2}, 0}, /* XYZ */ + {{0, 2, 1}, 1}, /* XZY */ + {{1, 0, 2}, 1}, /* YXZ */ + {{1, 2, 0}, 0}, /* YZX */ + {{2, 0, 1}, 0}, /* ZXY */ + {{2, 1, 0}, 1} /* ZYX */ }; /* Get relevant pointer to rotation order set from the array diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c index 2ff0b564592..859bb66073c 100644 --- a/source/blender/blenlib/intern/noise.c +++ b/source/blender/blenlib/intern/noise.c @@ -282,8 +282,8 @@ static float npfade(float t) static float grad(int hash, float x, float y, float z) { - int h = hash & 15; // CONVERT LO 4 BITS OF HASH CODE - float u = h < 8 ? x : y, // INTO 12 GRADIENT DIRECTIONS. + int h = hash & 15; /* CONVERT LO 4 BITS OF HASH CODE */ + float u = h < 8 ? x : y, /* INTO 12 GRADIENT DIRECTIONS. */ v = h < 4 ? y : h == 12 || h == 14 ? x : z; return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v); } @@ -293,21 +293,21 @@ static float newPerlin(float x, float y, float z) { int A, AA, AB, B, BA, BB; float u = floor(x), v = floor(y), w = floor(z); - int X = ((int)u) & 255, Y = ((int)v) & 255, Z = ((int)w) & 255; // FIND UNIT CUBE THAT CONTAINS POINT - x -= u; // FIND RELATIVE X,Y,Z - y -= v; // OF POINT IN CUBE. + int X = ((int)u) & 255, Y = ((int)v) & 255, Z = ((int)w) & 255; /* FIND UNIT CUBE THAT CONTAINS POINT */ + x -= u; /* FIND RELATIVE X,Y,Z */ + y -= v; /* OF POINT IN CUBE. */ z -= w; - u = npfade(x); // COMPUTE FADE CURVES - v = npfade(y); // FOR EACH OF X,Y,Z. + u = npfade(x); /* COMPUTE FADE CURVES */ + v = npfade(y); /* FOR EACH OF X,Y,Z. */ w = npfade(z); - A = hash[X ]+Y; AA = hash[A]+Z; AB = hash[A+1]+Z; // HASH COORDINATES OF - B = hash[X+1]+Y; BA = hash[B]+Z; BB = hash[B+1]+Z; // THE 8 CUBE CORNERS, - return lerp(w, lerp(v, lerp(u, grad(hash[AA ], x, y, z ), // AND ADD - grad(hash[BA ], x - 1, y, z )), // BLENDED - lerp(u, grad(hash[AB ], x, y - 1, z ), // RESULTS - grad(hash[BB ], x - 1, y - 1, z ))), // FROM 8 - lerp(v, lerp(u, grad(hash[AA + 1], x, y, z - 1), // CORNERS - grad(hash[BA + 1], x - 1, y, z - 1)), // OF CUBE + A = hash[X ]+Y; AA = hash[A]+Z; AB = hash[A+1]+Z; /* HASH COORDINATES OF */ + B = hash[X+1]+Y; BA = hash[B]+Z; BB = hash[B+1]+Z; /* THE 8 CUBE CORNERS, */ + return lerp(w, lerp(v, lerp(u, grad(hash[AA ], x, y, z ), /* AND ADD */ + grad(hash[BA ], x - 1, y, z )), /* BLENDED */ + lerp(u, grad(hash[AB ], x, y - 1, z ), /* RESULTS */ + grad(hash[BB ], x - 1, y - 1, z ))), /* FROM 8 */ + lerp(v, lerp(u, grad(hash[AA + 1], x, y, z - 1), /* CORNERS */ + grad(hash[BA + 1], x - 1, y, z - 1)), /* OF CUBE */ lerp(u, grad(hash[AB + 1], x, y - 1, z - 1), grad(hash[BB + 1], x - 1, y - 1, z - 1)))); } diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index e73899ce929..d86d151b1ef 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -178,8 +178,8 @@ char *BLI_getQuotedStr(const char *str, const char *prefix) startMatch = strstr(str, prefix) + prefixLen + 1; /* get the end point (i.e. where the next occurance of " is after the starting point) */ - endMatch = strchr(startMatch, '"'); // " NOTE: this comment here is just so that my text editor still shows the functions ok... - + endMatch = strchr(startMatch, '"'); /* " NOTE: this comment here is just so that my text editor still shows the functions ok... */ + /* return the slice indicated */ return BLI_strdupn(startMatch, (size_t)(endMatch - startMatch)); } @@ -187,8 +187,9 @@ char *BLI_getQuotedStr(const char *str, const char *prefix) /* Replaces all occurrences of oldText with newText in str, returning a new string that doesn't * contain the 'replaced' occurrences. */ -// A rather wasteful string-replacement utility, though this shall do for now... -// Feel free to replace this with an even safe + nicer alternative + +/* A rather wasteful string-replacement utility, though this shall do for now... + * Feel free to replace this with an even safe + nicer alternative */ char *BLI_replacestr(char *str, const char *oldText, const char *newText) { DynStr *ds = NULL; diff --git a/source/blender/blenlib/intern/voxel.c b/source/blender/blenlib/intern/voxel.c index 3a8705bbbba..bc775cb8f0c 100644 --- a/source/blender/blenlib/intern/voxel.c +++ b/source/blender/blenlib/intern/voxel.c @@ -56,15 +56,18 @@ float BLI_voxel_sample_nearest(float *data, const int res[3], const float co[3]) return D(data, res, xi, yi, zi); } -// returns highest integer <= x as integer (slightly faster than floor()) +/* returns highest integer <= x as integer (slightly faster than floor()) */ BLI_INLINE int FLOORI(float x) { const int r = (int)x; return ((x >= 0.f) || (float)r == x) ? r : (r - 1); } -// clamp function, cannot use the CLAMPIS macro, it sometimes returns unwanted results apparently related to gcc optimization flag -fstrict-overflow which is enabled at -O2 -// this causes the test (x + 2) < 0 with int x == 2147483647 to return false (x being an integer, x + 2 should wrap around to -2147483647 so the test < 0 should return true, which it doesn't) +/* clamp function, cannot use the CLAMPIS macro, it sometimes returns unwanted results apparently related to + * gcc optimization flag -fstrict-overflow which is enabled at -O2 + * + * this causes the test (x + 2) < 0 with int x == 2147483647 to return false (x being an integer, + * x + 2 should wrap around to -2147483647 so the test < 0 should return true, which it doesn't) */ BLI_INLINE int _clamp(int a, int b, int c) { return (a < b) ? b : ((a > c) ? c : a); diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index e34150ee4f2..0dc4d3c2db6 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -98,10 +98,10 @@ void RegisterBlendExtension(void) printf("Registering file extension..."); GetModuleFileName(0, BlPath, MAX_PATH); - // root is HKLM by default + /* root is HKLM by default */ lresult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Classes", 0, KEY_ALL_ACCESS, &root); if (lresult != ERROR_SUCCESS) { - // try HKCU on failure + /* try HKCU on failure */ usr_mode = TRUE; lresult = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Classes", 0, KEY_ALL_ACCESS, &root); if (lresult != ERROR_SUCCESS) diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index 173f74a1db7..c19904d39ac 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -218,7 +218,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SKETCH_OT_delete", DELKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SKETCH_OT_finish_stroke", RIGHTMOUSE, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SKETCH_OT_cancel_stroke", ESCKEY, KM_PRESS, 0, 0); - // Already part of view3d select + /* Already part of view3d select */ //WM_keymap_add_item(keymap, "SKETCH_OT_select", SELECTMOUSE, KM_PRESS, 0, 0); /* sketch poll checks mode */ diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index d4c28b2fb6d..2a3f2182fdf 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -1402,7 +1402,7 @@ static void selectconnected_posebonechildren(Object *ob, Bone *bone, int extend) if (!(bone->flag & BONE_CONNECTED) || (bone->flag & BONE_UNSELECTABLE)) return; - // XXX old cruft! use notifiers instead + /* XXX old cruft! use notifiers instead */ //select_actionchannel_by_name (ob->action, bone->name, !(shift)); if (extend) @@ -5404,7 +5404,7 @@ static int hide_unselected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr bArmature *arm = ob->data; if (arm->layer & bone->layer) { - // hrm... typo here? + /* hrm... typo here? */ if ((bone->flag & BONE_SELECTED) == 0) { bone->flag |= BONE_HIDDEN_P; if (arm->act_bone == bone) diff --git a/source/blender/editors/armature/poseUtils.c b/source/blender/editors/armature/poseUtils.c index 4e0398168d3..e2e3c49e7e0 100644 --- a/source/blender/editors/armature/poseUtils.c +++ b/source/blender/editors/armature/poseUtils.c @@ -185,7 +185,7 @@ void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob) /* old optimize trick... this enforces to bypass the depgraph * - note: code copied from transform_generics.c -> recalcData() */ - // FIXME: shouldn't this use the builtin stuff? + /* FIXME: shouldn't this use the builtin stuff? */ if ((arm->flag & ARM_DELAYDEFORM) == 0) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */ else diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index 4c19161576c..23c987c3536 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -472,8 +472,8 @@ static int poselib_add_exec(bContext *C, wmOperator *op) BLI_uniquename(&act->markers, marker, "Pose", '.', offsetof(TimeMarker, name), sizeof(marker->name)); /* use Keying Set to determine what to store for the pose */ - // FIXME: in the past, the Keying Set respected selections (LocRotScale), but the current one doesn't (WholeCharacter) - // so perhaps we need either a new Keying Set, or just to add overrides here... + /* FIXME: in the past, the Keying Set respected selections (LocRotScale), but the current one doesn't + * (WholeCharacter) so perhaps we need either a new Keying Set, or just to add overrides here... */ ANIM_apply_keyingset(C, NULL, act, ks, MODIFYKEY_MODE_INSERT, (float)frame); /* store new 'active' pose number */ diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index d0c5774a200..bb66b1f4347 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -753,7 +753,7 @@ static int paste_selection(Object *obedit, ReportList *reports) EditFont *ef = cu->editfont; int len = wcslen(ef->copybuf); - // Verify that the copy buffer => [copy buffer len] + cu->len < MAXTEXT + /* Verify that the copy buffer => [copy buffer len] + cu->len < MAXTEXT */ if (cu->len + len <= MAXTEXT) { if (len) { int size = (cu->len * sizeof(wchar_t)) - (cu->pos * sizeof(wchar_t)) + sizeof(wchar_t); @@ -1773,10 +1773,10 @@ static void *editFont_to_undoFont(void *ecu, void *UNUSED(obdata)) EditFont *ef = cu->editfont; char *str; - // The undo buffer includes [MAXTEXT+6]=actual string and [MAXTEXT+4]*sizeof(CharInfo)=charinfo + /* The undo buffer includes [MAXTEXT+6]=actual string and [MAXTEXT+4]*sizeof(CharInfo)=charinfo */ str = MEM_callocN((MAXTEXT + 6) * sizeof(wchar_t) + (MAXTEXT + 4) * sizeof(CharInfo), "string undo"); - // Copy the string and string information + /* Copy the string and string information */ memcpy(str + 4, ef->textbuf, (cu->len + 1) * sizeof(wchar_t)); memcpy(str + 4 + (cu->len + 1) * sizeof(wchar_t), ef->textbufinfo, cu->len * sizeof(CharInfo)); diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 6d113cbb924..bc912fc8c76 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -683,7 +683,7 @@ void draw_gpencil_2dimage(const bContext *C) { /* just draw using standard scaling (settings here are currently ignored anyways) */ - // FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled + /* FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled */ offsx = 0; offsy = 0; sizex = ar->winx; @@ -740,7 +740,7 @@ void draw_gpencil_view2d(const bContext *C, short onlyv2d) if (gpd == NULL) return; /* special hack for Image Editor */ - // FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled + /* FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled */ if (ELEM(sa->spacetype, SPACE_IMAGE, SPACE_CLIP)) dflag |= GP_DRAWDATA_IEDITHACK; diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 3f53f0403d7..949f92c68e9 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -93,8 +93,8 @@ bGPdata **gpencil_data_get_pointers(const bContext *C, PointerRNA *ptr) { Object *ob = CTX_data_active_object(C); - // TODO: we can include other data-types such as bones later if need be... - + /* TODO: we can include other data-types such as bones later if need be... */ + /* just in case no active object */ if (ob) { /* for now, as long as there's an object, default to using that in 3D-View */ @@ -126,18 +126,18 @@ bGPdata **gpencil_data_get_pointers(const bContext *C, PointerRNA *ptr) SpaceSeq *sseq = (SpaceSeq *)CTX_wm_space_data(C); /* for now, Grease Pencil data is associated with the space (actually preview region only) */ - // XXX our convention for everything else is to link to data though... + /* XXX our convention for everything else is to link to data though... */ if (ptr) RNA_pointer_create(screen_id, &RNA_SpaceSequenceEditor, sseq, ptr); return &sseq->gpd; } break; - + case SPACE_IMAGE: /* Image/UV Editor */ { SpaceImage *sima = (SpaceImage *)CTX_wm_space_data(C); - + /* for now, Grease Pencil data is associated with the space... */ - // XXX our convention for everything else is to link to data though... + /* XXX our convention for everything else is to link to data though... */ if (ptr) RNA_pointer_create(screen_id, &RNA_SpaceImageEditor, sima, ptr); return &sima->gpd; } diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 8c20d2a9450..fd98dd83a7d 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1623,12 +1623,12 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, wmEvent *event) } else p = op->customdata; - - // TODO: set any additional settings that we can take from the events? - // TODO? if tablet is erasing, force eraser to be on? - - // TODO: move cursor setting stuff to stroke-start so that paintmode can be changed midway... - + + /* TODO: set any additional settings that we can take from the events? + * TODO? if tablet is erasing, force eraser to be on? */ + + /* TODO: move cursor setting stuff to stroke-start so that paintmode can be changed midway... */ + /* if eraser is on, draw radial aid */ if (p->paintmode == GP_PAINTMODE_ERASER) { gpencil_draw_toggle_eraser_cursor(C, p, TRUE); @@ -1692,8 +1692,8 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) //printf("\t\tGP - start stroke\n"); /* we may need to set up paint env again if we're resuming */ - // XXX: watch it with the paintmode! in future, it'd be nice to allow changing paint-mode when in sketching-sessions - // XXX: with tablet events, we may event want to check for eraser here, for nicer tablet support + /* XXX: watch it with the paintmode! in future, it'd be nice to allow changing paint-mode when in sketching-sessions */ + /* XXX: with tablet events, we may event want to check for eraser here, for nicer tablet support */ if (gp_session_initdata(C, p)) gp_paint_initstroke(p, p->paintmode); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 49d56d427ba..1c5cc7528fe 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -524,8 +524,8 @@ static void ui_draw_links(uiBlock *block) uiBut *but; uiLinkLine *line; - // Draw the inactive lines (lines with neither button being hovered over). - // As we go, remember if we see any active or selected lines. + /* Draw the inactive lines (lines with neither button being hovered over). + * As we go, remember if we see any active or selected lines. */ int foundselectline = 0; int foundactiveline = 0; for (but = block->buttons.first; but; but = but->next) { @@ -542,8 +542,8 @@ static void ui_draw_links(uiBlock *block) } } - // Draw any active lines (lines with either button being hovered over). - // Do this last so they appear on top of inactive lines. + /* Draw any active lines (lines with either button being hovered over). + * Do this last so they appear on top of inactive lines. */ if (foundactiveline) { for (but = block->buttons.first; but; but = but->next) { if (but->type == LINK && but->link) { @@ -2486,7 +2486,7 @@ static void ui_block_do_align_but(uiBut *first, short nr) /* merge coordinates */ if (prev) { - // simple cases + /* simple cases */ if (rows == 0) { but->x1 = (prev->x2 + but->x1) / 2.0f; prev->x2 = but->x1; @@ -3432,7 +3432,7 @@ int uiButGetUnitType(uiBut *but) /* own unit define always takes precedence over RNA provided, allowing for overriding * default value provided in RNA in a few special cases (i.e. Active Keyframe in Graph Edit) */ - // XXX: this doesn't allow clearing unit completely, though the same could be said for icons + /* XXX: this doesn't allow clearing unit completely, though the same could be said for icons */ if ((ownUnit != 0) || (but->rnaprop == NULL)) { return ownUnit << 16; } diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c index de555d1d50e..3099fcb2b40 100644 --- a/source/blender/editors/interface/interface_anim.c +++ b/source/blender/editors/interface/interface_anim.c @@ -141,7 +141,7 @@ int ui_but_anim_expression_create(uiBut *but, const char *str) } /* make sure we have animdata for this */ - // FIXME: until materials can be handled by depsgraph, don't allow drivers to be created for them + /* FIXME: until materials can be handled by depsgraph, don't allow drivers to be created for them */ id = (ID *)but->rnapoin.id.data; if ((id == NULL) || (GS(id->name) == ID_MA) || (GS(id->name) == ID_TE)) { if (G.debug & G_DEBUG) diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 801daf6bb4b..e576b71e442 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -441,7 +441,7 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w w = (rect->xmax - rect->xmin); h = (rect->ymax - rect->ymin); - // prevent drawing outside widget area + /* prevent drawing outside widget area */ glGetIntegerv(GL_SCISSOR_BOX, scissor); glScissor(ar->winrct.xmin + rect->xmin, ar->winrct.ymin + rect->ymin, w, h); #endif @@ -509,7 +509,7 @@ static void ui_draw_but_CHARTAB(uiBut *but) /* Set the font, in case it is not FO_BUILTIN_NAME font */ if (G.selfont && strcmp(G.selfont->name, FO_BUILTIN_NAME)) { - // Is the font file packed, if so then use the packed file + /* Is the font file packed, if so then use the packed file */ if (G.selfont->packedfile) { pf = G.selfont->packedfile; FTF_SetFont(pf->data, pf->size, 14.0); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 78d0b6aa002..18b256d061d 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -804,7 +804,7 @@ static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to) break; } - // only works if the sensor and the actuator are from the same object + /* only works if the sensor and the actuator are from the same object */ if (!act_iter) return; /* (3) add a new controller */ @@ -3810,7 +3810,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt static int in_scope_resize_zone(uiBut *but, int UNUSED(x), int y) { - // bottom corner return (x > but->x2 - SCOPE_RESIZE_PAD) && (y < but->y1 + SCOPE_RESIZE_PAD); + /* bottom corner return (x > but->x2 - SCOPE_RESIZE_PAD) && (y < but->y1 + SCOPE_RESIZE_PAD); */ return (y < but->y1 + SCOPE_RESIZE_PAD); } @@ -4566,7 +4566,7 @@ static int ui_but_menu(bContext *C, uiBut *but) /* keyboard shortcuts */ if ((kmi) && ISKEYBOARD(kmi->type)) { - // would rather use a block but, but gets weirdly positioned... + /* would rather use a block but, but gets weirdly positioned... */ //uiDefBlockBut(block, menu_change_shortcut, but, "Change Shortcut", 0, 0, uiLayoutGetWidth(layout), UI_UNIT_Y, ""); but2 = uiDefIconTextBut(block, BUT, 0, 0, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Change Shortcut"), diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 2e8117ea640..1d7a423a15a 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -91,7 +91,7 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo if (btheme) { - // first check for ui buttons theme + /* first check for ui buttons theme */ if (colorid < TH_THEMEUI) { switch (colorid) { @@ -936,7 +936,7 @@ void UI_SetTheme(int spacetype, int regionid) theme_regionid = RGN_TYPE_WINDOW; } else { - // later on, a local theme can be found too + /* later on, a local theme can be found too */ theme_active = U.themes.first; theme_spacetype = spacetype; theme_regionid = regionid; @@ -1353,7 +1353,7 @@ void init_userdef_do_versions(void) for (btheme = U.themes.first; btheme; btheme = btheme->next) { /* check for (alpha == 0) is safe, then color was never set */ if (btheme->ttime.back[3] == 0) { - // copied from ui_theme_init_default + /* copied from ui_theme_init_default */ btheme->ttime = btheme->tv3d; rgba_char_args_set_fl(btheme->ttime.back, 0.45, 0.45, 0.45, 1.0); rgba_char_args_set_fl(btheme->ttime.grid, 0.36, 0.36, 0.36, 1.0); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 392aae1632d..47e91f4c659 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -91,7 +91,7 @@ static void view2d_masks(View2D *v2d) v2d->mask.ymax = v2d->winy - 1; #if 0 - // XXX see above + /* XXX see above */ v2d->scroll &= ~(V2D_SCROLL_HORIZONTAL_HIDE | V2D_SCROLL_VERTICAL_HIDE); /* check size if: */ if (v2d->scroll & V2D_SCROLL_HORIZONTAL) @@ -203,7 +203,7 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) v2d->cur = v2d->tot; /* scrollers - should we have these by default? */ - // XXX for now, we don't override this, or set it either! + /* XXX for now, we don't override this, or set it either! */ } break; diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index a1f9ad08378..3be41d1f46e 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1133,7 +1133,7 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op) */ float zoom, center, size; - // TODO: is this zoom factor calculation valid? It seems to produce same results everytime... + /* TODO: is this zoom factor calculation valid? It seems to produce same results everytime... */ if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) { size = (v2d->cur.xmax - v2d->cur.xmin); zoom = size / (rect.xmax - rect.xmin); diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index 77808d0a00d..6e4da6b7e88 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -174,7 +174,7 @@ void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) uiItemR(row, imfptr, "include_armatures", 0, NULL, ICON_NONE); uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected")); - // Texture options + /* Texture options */ box = uiLayoutBox(layout); row = uiLayoutRow(box, FALSE); uiItemL(row, IFACE_("Texture Options:"), ICON_TEXTURE_DATA); @@ -192,7 +192,7 @@ void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) uiItemR(row, imfptr, "use_texture_copies", 1, NULL, ICON_NONE); - // Armature options + /* Armature options */ box = uiLayoutBox(layout); row = uiLayoutRow(box, FALSE); uiItemL(row, IFACE_("Armature Options:"), ICON_ARMATURE_DATA); diff --git a/source/blender/editors/io/io_ops.c b/source/blender/editors/io/io_ops.c index b724db6e737..d2b0ddd4e7e 100644 --- a/source/blender/editors/io/io_ops.c +++ b/source/blender/editors/io/io_ops.c @@ -37,7 +37,7 @@ void ED_operatortypes_io(void) { #ifdef WITH_COLLADA - // Collada operators: + /* Collada operators: */ WM_operatortype_append(WM_OT_collada_export); WM_operatortype_append(WM_OT_collada_import); #endif diff --git a/source/blender/editors/mask/mask_editaction.c b/source/blender/editors/mask/mask_editaction.c index 3836b393bf8..6124947e3b9 100644 --- a/source/blender/editors/mask/mask_editaction.c +++ b/source/blender/editors/mask/mask_editaction.c @@ -243,7 +243,7 @@ void ED_masklayer_frames_duplicate(MaskLayer *masklay) mask_shape_dupe = BKE_mask_layer_shape_duplicate(masklay_shape); masklay_shape->flag &= ~MASK_SHAPE_SELECT; - // XXX - how to handle duplicate frames? + /* XXX - how to handle duplicate frames? */ BLI_insertlinkafter(&masklay->splines_shapes, masklay_shape, mask_shape_dupe); } } diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index cdbf5751ea1..044c23092bd 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -265,11 +265,11 @@ int join_mesh_exec(bContext *C, wmOperator *op) key->totkey++; if (key->totkey == 1) key->refkey = kbn; - // XXX 2.5 Animato + /* XXX 2.5 Animato */ #if 0 /* also, copy corresponding ipo-curve to ipo-block if applicable */ if (me->key->ipo && key->ipo) { - // FIXME... this is a luxury item! + /* FIXME... this is a luxury item! */ puts("FIXME: ignoring IPO's when joining shapekeys on Meshes for now..."); } #endif @@ -530,7 +530,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) /* free temp copy of destination shapekeys (if applicable) */ if (nkey) { - // XXX 2.5 Animato + /* XXX 2.5 Animato */ #if 0 /* free it's ipo too - both are not actually freed from memory yet as ID-blocks */ if (nkey->ipo) { diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 4e1c8df975c..be25c79ba25 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -718,7 +718,7 @@ static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con, unit_m4(invmat); /* try to find a pose channel - assume that this is the constraint owner */ - // TODO: get from context instead? + /* TODO: get from context instead? */ if (ob && ob->pose) pchan = BKE_pose_channel_active(ob); @@ -974,7 +974,7 @@ void ED_object_constraint_set_active(Object *ob, bConstraint *con) ListBase *lb = get_constraint_lb(ob, con, NULL); /* lets be nice and escape if its active already */ - // NOTE: this assumes that the stack doesn't have other active ones set... + /* NOTE: this assumes that the stack doesn't have other active ones set... */ if ((lb && con) && (con->flag & CONSTRAINT_ACTIVE)) return; @@ -1787,7 +1787,7 @@ static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op)) { bConstraint *con, *next; - // TODO: should we be checking if these contraints were local before we try and remove them? + /* TODO: should we be checking if these contraints were local before we try and remove them? */ for (con = pchan->constraints.first; con; con = next) { next = con->next; if (con->type == CONSTRAINT_TYPE_KINEMATIC) { diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index e48fe8d3eda..b5e85c3712b 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1145,7 +1145,7 @@ static int object_calculate_paths_invoke(bContext *C, wmOperator *op, wmEvent *U } /* show popup dialog to allow editing of range... */ - // FIXME: hardcoded dimensions here are just arbitrary + /* FIXME: hardcoded dimensions here are just arbitrary */ return WM_operator_props_dialog_popup(C, op, 200, 200); } diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index aab3d8afb22..3d9e62b1a16 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1353,7 +1353,7 @@ void OBJECT_OT_multires_external_save(wmOperatorType *ot) ot->description = "Save displacements to an external file"; ot->idname = "OBJECT_OT_multires_external_save"; - // XXX modifier no longer in context after file browser .. ot->poll = multires_poll; + /* XXX modifier no longer in context after file browser .. ot->poll = multires_poll; */ ot->exec = multires_external_save_exec; ot->invoke = multires_external_save_invoke; ot->poll = multires_poll; @@ -1375,7 +1375,7 @@ static int multires_external_pack_exec(bContext *C, wmOperator *UNUSED(op)) if (!CustomData_external_test(&me->ldata, CD_MDISPS)) return OPERATOR_CANCELLED; - // XXX don't remove.. + /* XXX don't remove.. */ CustomData_external_remove(&me->ldata, &me->id, CD_MDISPS, me->totloop); return OPERATOR_FINISHED; diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index d37a16cb1bb..538b4b3884a 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -477,11 +477,9 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) const short view_context = (oglrender->v3d != NULL); Object *camera = NULL; - /* update animated image textures for gpu, etc, - * call before BKE_scene_update_for_newframe so modifiers with textures don't lag 1 frame */ - ED_image_update_frame(bmain, scene->r.cfra); - /* go to next frame */ + if (CFRA < oglrender->nfra) + CFRA++; while (CFRA < oglrender->nfra) { unsigned int lay = screen_opengl_layers(oglrender); @@ -492,6 +490,10 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) CFRA++; } + /* update animated image textures for gpu, etc, + * call before BKE_scene_update_for_newframe so modifiers with textures don't lag 1 frame */ + ED_image_update_frame(bmain, CFRA); + BKE_scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender)); if (view_context) { @@ -569,10 +571,9 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) /* go to next frame */ oglrender->nfra += scene->r.frame_step; - scene->r.cfra++; /* stop at the end or on error */ - if (scene->r.cfra > PEFRA || !ok) { + if (CFRA >= PEFRA || !ok) { screen_opengl_render_end(C, op->customdata); return 0; } diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 9771fef2d58..a79d38d4081 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1149,7 +1149,7 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand { /* note, add-handler checks if it already exists */ - // XXX it would be good to have boundbox checks for some of these... + /* XXX it would be good to have boundbox checks for some of these... */ if (flag & ED_KEYMAP_UI) { /* user interface widgets */ UI_add_region_handlers(handlers); @@ -1654,7 +1654,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * v2d->scroll |= V2D_SCROLL_HORIZONTAL_HIDE; v2d->scroll &= ~V2D_SCROLL_VERTICAL_HIDE; - // don't jump back when panels close or hide + /* don't jump back when panels close or hide */ if (!newcontext) y = MAX2(-y, -v2d->cur.ymin); else @@ -1669,14 +1669,14 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * //v2d->keepofs &= ~(V2D_LOCKOFS_X|V2D_KEEPOFS_Y); v2d->scroll |= V2D_SCROLL_VERTICAL_HIDE; v2d->scroll &= ~V2D_SCROLL_HORIZONTAL_HIDE; - - // don't jump back when panels close or hide + + /* don't jump back when panels close or hide */ if (!newcontext) x = MAX2(x, v2d->cur.xmax); y = -y; } - // +V2D_SCROLL_HEIGHT is workaround to set the actual height + /* +V2D_SCROLL_HEIGHT is workaround to set the actual height */ UI_view2d_totRect_set(v2d, x + V2D_SCROLL_WIDTH, y + V2D_SCROLL_HEIGHT); /* set the view */ @@ -1698,17 +1698,17 @@ void ED_region_panels_init(wmWindowManager *wm, ARegion *ar) { wmKeyMap *keymap; - // XXX quick hacks for files saved with 2.5 already (i.e. the builtin defaults file) - // scrollbars for button regions + /* XXX quick hacks for files saved with 2.5 already (i.e. the builtin defaults file) + * scrollbars for button regions */ ar->v2d.scroll |= (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); ar->v2d.scroll |= V2D_SCROLL_HORIZONTAL_HIDE; ar->v2d.scroll &= ~V2D_SCROLL_VERTICAL_HIDE; ar->v2d.keepzoom |= V2D_KEEPZOOM; - // correctly initialized User-Prefs? + /* correctly initialized User-Prefs? */ if (!(ar->v2d.align & V2D_ALIGN_NO_POS_Y)) ar->v2d.flag &= ~V2D_IS_INITIALISED; - + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_PANELS_UI, ar->winx, ar->winy); keymap = WM_keymap_find(wm->defaultconf, "View2D Buttons List", 0, 0); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 4ddb336a9f7..ca16558f3a6 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1652,7 +1652,7 @@ static int image_invert_exec(bContext *C, wmOperator *op) Image *ima = CTX_data_edit_image(C); ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); - // flags indicate if this channel should be inverted + /* flags indicate if this channel should be inverted */ const short r = RNA_boolean_get(op->ptr, "invert_r"); const short g = RNA_boolean_get(op->ptr, "invert_g"); const short b = RNA_boolean_get(op->ptr, "invert_b"); diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 78b5219206d..0fad5e47445 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -1032,7 +1032,9 @@ static void do_material_tex(GPUShadeInput *shi) if (tex->imaflag & TEX_USEALPHA) talpha= 1; } - else continue; + else { + continue; + } /* texture output */ if ((rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) { diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c index d544e6501fc..21d50e4a71d 100644 --- a/source/blender/ikplugin/intern/iksolver_plugin.c +++ b/source/blender/ikplugin/intern/iksolver_plugin.c @@ -139,7 +139,7 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t size = MIN2(segcount, tree->totchannel); a = t = 0; while (a < size && t < tree->totchannel) { - // locate first matching channel + /* locate first matching channel */ for (; t < tree->totchannel && tree->pchan[t] != chanlist[segcount - a - 1]; t++) ; if (t >= tree->totchannel) break; @@ -535,7 +535,7 @@ void iksolver_execute_tree(struct Scene *scene, struct Object *ob, struct bPose for (a = 0; a < tree->totchannel; a++) { if (!(tree->pchan[a]->flag & POSE_DONE)) // successive trees can set the flag BKE_pose_where_is_bone(scene, ob, tree->pchan[a], ctime, 1); - // tell blender that this channel was controlled by IK, it's cleared on each BKE_pose_where_is() + /* tell blender that this channel was controlled by IK, it's cleared on each BKE_pose_where_is() */ tree->pchan[a]->flag |= POSE_CHAIN; } /* 5. execute the IK solver */ diff --git a/source/blender/imbuf/intern/allocimbuf.c b/source/blender/imbuf/intern/allocimbuf.c index 68a094c26d0..c717d8eee5a 100644 --- a/source/blender/imbuf/intern/allocimbuf.c +++ b/source/blender/imbuf/intern/allocimbuf.c @@ -424,7 +424,7 @@ ImBuf *IMB_dupImBuf(ImBuf *ibuf1) /* silly trick to copy the entire contents of ibuf1 struct over to ibuf */ tbuf = *ibuf1; - // fix pointers + /* fix pointers */ tbuf.rect = ibuf2->rect; tbuf.rect_float = ibuf2->rect_float; tbuf.encodedbuffer = ibuf2->encodedbuffer; @@ -433,12 +433,12 @@ ImBuf *IMB_dupImBuf(ImBuf *ibuf1) for (a = 0; a < IB_MIPMAP_LEVELS; a++) tbuf.mipmap[a] = NULL; - // set malloc flag + /* set malloc flag */ tbuf.mall = ibuf2->mall; tbuf.c_handle = NULL; tbuf.refcounter = 0; - // for now don't duplicate metadata + /* for now don't duplicate metadata */ tbuf.metadata = NULL; *ibuf2 = tbuf; diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index f0c2d754333..a27aae815da 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -42,8 +42,8 @@ #include #endif -#undef AVIIF_KEYFRAME // redefined in AVI_avi.h -#undef AVIIF_LIST // redefined in AVI_avi.h +#undef AVIIF_KEYFRAME /* redefined in AVI_avi.h */ +#undef AVIIF_LIST /* redefined in AVI_avi.h */ #define FIXCC(fcc) \ { \ @@ -324,10 +324,10 @@ static int startavi(struct anim *anim) if (anim->pgf) { firstvideo = i; - // get stream length + /* get stream length */ anim->avi->header->TotalFrames = AVIStreamLength(anim->pavi[i]); - - // get information about images inside the stream + + /* get information about images inside the stream */ l = sizeof(abFormat); AVIStreamReadFormat(anim->pavi[i], 0, &abFormat, &l); lpbi = (LPBITMAPINFOHEADER)abFormat; @@ -344,12 +344,12 @@ static int startavi(struct anim *anim) } } - // register number of opened avistreams + /* register number of opened avistreams */ anim->avistreams = i; - // - // Couldn't get any video streams out of this file - // + /* + * Couldn't get any video streams out of this file + */ if ((anim->avistreams == 0) || (firstvideo == -1)) { avierror = AVI_ERROR_FORMAT; } diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c index 40f6f36e06b..5114fcb3ae0 100644 --- a/source/blender/imbuf/intern/imageprocess.c +++ b/source/blender/imbuf/intern/imageprocess.c @@ -258,11 +258,11 @@ void bilinear_interpolation_color(struct ImBuf *in, unsigned char *outI, float * y1 = (int)floor(v); y2 = (int)ceil(v); - // sample area entirely outside image? + /* sample area entirely outside image? */ if (x2 < 0 || x1 > in->x - 1 || y2 < 0 || y1 > in->y - 1) return; if (outF) { - // sample including outside of edges of image + /* sample including outside of edges of image */ if (x1 < 0 || y1 < 0) row1 = empty; else row1 = (float *)in->rect_float + in->x * y1 * 4 + 4 * x1; @@ -285,7 +285,7 @@ void bilinear_interpolation_color(struct ImBuf *in, unsigned char *outI, float * outF[3] = ma_mb * row1[3] + a_mb * row3[3] + ma_b * row2[3] + a_b * row4[3]; } if (outI) { - // sample including outside of edges of image + /* sample including outside of edges of image */ if (x1 < 0 || y1 < 0) row1I = emptyI; else row1I = (unsigned char *)in->rect + in->x * y1 * 4 + 4 * x1; @@ -332,18 +332,18 @@ void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char *outI, fl y1 = (int)floor(v); y2 = (int)ceil(v); - // sample area entirely outside image? + /* sample area entirely outside image? */ if (x2 < 0 || x1 > in->x - 1 || y2 < 0 || y1 > in->y - 1) return; - + /* wrap interpolation pixels - main difference from bilinear_interpolation_color */ if (x1 < 0) x1 = in->x + x1; if (y1 < 0) y1 = in->y + y1; - + if (x2 >= in->x) x2 = x2 - in->x; if (y2 >= in->y) y2 = y2 - in->y; if (outF) { - // sample including outside of edges of image + /* sample including outside of edges of image */ row1 = (float *)in->rect_float + in->x * y1 * 4 + 4 * x1; row2 = (float *)in->rect_float + in->x * y2 * 4 + 4 * x1; row3 = (float *)in->rect_float + in->x * y1 * 4 + 4 * x2; @@ -359,7 +359,7 @@ void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char *outI, fl outF[3] = ma_mb * row1[3] + a_mb * row3[3] + ma_b * row2[3] + a_b * row4[3]; } if (outI) { - // sample including outside of edges of image + /* sample including outside of edges of image */ row1I = (unsigned char *)in->rect + in->x * y1 * 4 + 4 * x1; row2I = (unsigned char *)in->rect + in->x * y2 * 4 + 4 * x1; row3I = (unsigned char *)in->rect + in->x * y1 * 4 + 4 * x2; @@ -404,10 +404,10 @@ void neareast_interpolation_color(struct ImBuf *in, unsigned char *outI, float * x1 = (int)(u); y1 = (int)(v); - // sample area entirely outside image? + /* sample area entirely outside image? */ if (x1 < 0 || x1 > in->x - 1 || y1 < 0 || y1 > in->y - 1) return; - - // sample including outside of edges of image + + /* sample including outside of edges of image */ if (x1 < 0 || y1 < 0) { if (outI) { outI[0] = 0; diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index 8b2e27ae1f3..9cf06b08ba4 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -181,12 +181,12 @@ struct anim_index *IMB_indexer_open(const char *name) fseek(fp, 0, SEEK_END); idx->num_entries = (ftell(fp) - 12) / - (sizeof(int) + // framepos - sizeof(unsigned long long) + // seek_pos - sizeof(unsigned long long) + // seek_pos_dts - sizeof(unsigned long long) // pts + (sizeof(int) + /* framepos */ + sizeof(unsigned long long) + /* seek_pos */ + sizeof(unsigned long long) + /* seek_pos_dts */ + sizeof(unsigned long long) /* pts */ ); - + fseek(fp, 12, SEEK_SET); idx->entries = MEM_callocN(sizeof(struct anim_index_entry) * @@ -472,7 +472,7 @@ static struct proxy_output_ctx *alloc_proxy_output_ffmpeg( char fname[FILE_MAX]; int ffmpeg_quality; - // JPEG requires this + /* JPEG requires this */ width = round_up(width, 8); height = round_up(height, 8); diff --git a/source/blender/imbuf/intern/indexer_dv.c b/source/blender/imbuf/intern/indexer_dv.c index 0090577062f..4c6b750aa41 100644 --- a/source/blender/imbuf/intern/indexer_dv.c +++ b/source/blender/imbuf/intern/indexer_dv.c @@ -129,7 +129,7 @@ static void parse_packet(indexer_dv_context *This, unsigned char *p) b = bitstream_new(p + 1); switch (type) { - case 0x62: // Record date + case 0x62: /* Record date */ parse_num(&b, 8); This->rec_curr_day = parse_bcd(&b, 6); parse_num(&b, 2); @@ -144,7 +144,7 @@ static void parse_packet(indexer_dv_context *This, unsigned char *p) } This->got_record_date = 1; break; - case 0x63: // Record time + case 0x63: /* Record time */ This->rec_curr_frame = parse_bcd(&b, 6); parse_num(&b, 2); This->rec_curr_second = parse_bcd(&b, 7); @@ -322,7 +322,7 @@ static void proc_frame(indexer_dv_context *This, } } else if (This->ref_time_read_new == This->ref_time_read) { - // do nothing + /* do nothing */ } else { This->gap_start = This->ref_time_read; diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index 3008c233718..6477d40d695 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -880,7 +880,7 @@ int imb_savejp2(struct ImBuf *ibuf, const char *name, int flags) parameters.tcp_rates[0] = ((100 - quality) / 90.0f * 99.0f) + 1; - parameters.tcp_numlayers = 1; // only one resolution + parameters.tcp_numlayers = 1; /* only one resolution */ parameters.cp_disto_alloc = 1; image = ibuftoimage(ibuf, ¶meters); diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c index 47555302a59..03c949bc3d1 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.c @@ -86,9 +86,9 @@ int imb_is_a_jpeg(unsigned char *mem) return 0; } -//---------------------------------------------------------- -// JPG ERROR HANDLING -//---------------------------------------------------------- +/*---------------------------------------------------------- + * JPG ERROR HANDLING + *---------------------------------------------------------- */ typedef struct my_error_mgr { struct jpeg_error_mgr pub; /* "public" fields */ @@ -112,9 +112,9 @@ static void jpeg_error(j_common_ptr cinfo) longjmp(err->setjmp_buffer, 1); } -//---------------------------------------------------------- -// INPUT HANDLER FROM MEMORY -//---------------------------------------------------------- +/*---------------------------------------------------------- + * INPUT HANDLER FROM MEMORY + *---------------------------------------------------------- */ typedef struct { unsigned char *buffer; @@ -159,7 +159,7 @@ static void skip_input_data(j_decompress_ptr cinfo, long num_bytes) my_src_ptr src = (my_src_ptr) cinfo->src; if (num_bytes > 0) { - // prevent skipping over file end + /* prevent skipping over file end */ size_t skip_size = (size_t)num_bytes <= src->pub.bytes_in_buffer ? num_bytes : src->pub.bytes_in_buffer; src->pub.next_input_byte = src->pub.next_input_byte + skip_size; diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index 2aed1485700..928eb219ea5 100644 --- a/source/blender/imbuf/intern/png.c +++ b/source/blender/imbuf/intern/png.c @@ -73,7 +73,7 @@ static void WriteData(png_structp png_ptr, png_bytep data, png_size_t length) { ImBuf *ibuf = (ImBuf *) png_get_io_ptr(png_ptr); - // if buffer is to small increase it. + /* if buffer is to small increase it. */ while (ibuf->encodedsize + length > ibuf->encodedbuffersize) { imb_enlargeencodedbufferImBuf(ibuf); } @@ -144,7 +144,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) return 0; } - // copy image data + /* copy image data */ pixels = MEM_mallocN(ibuf->x * ibuf->y * bytesperpixel * sizeof(unsigned char), "pixels"); if (pixels == NULL) { @@ -186,7 +186,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) } if (flags & IB_mem) { - // create image in memory + /* create image in memory */ imb_addencodedbufferImBuf(ibuf); ibuf->encodedsize = 0; @@ -218,7 +218,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) png_set_compression_level(png_ptr, compression); - // png image settings + /* png image settings */ png_set_IHDR(png_ptr, info_ptr, ibuf->x, @@ -261,10 +261,10 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) png_set_pHYs(png_ptr, info_ptr, (unsigned int)(ibuf->ppm[0] + 0.5), (unsigned int)(ibuf->ppm[1] + 0.5), PNG_RESOLUTION_METER); } - // write the file header information + /* write the file header information */ png_write_info(png_ptr, info_ptr); - // allocate memory for an array of row-pointers + /* allocate memory for an array of row-pointers */ row_pointers = (png_bytepp) MEM_mallocN(ibuf->y * sizeof(png_bytep), "row_pointers"); if (row_pointers == NULL) { printf("imb_savepng: Cannot allocate row-pointers array for file '%s'\n", name); @@ -276,19 +276,19 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) return 0; } - // set the individual row-pointers to point at the correct offsets + /* set the individual row-pointers to point at the correct offsets */ for (i = 0; i < ibuf->y; i++) { row_pointers[ibuf->y - 1 - i] = (png_bytep) ((unsigned char *)pixels + (i * ibuf->x) * bytesperpixel * sizeof(unsigned char)); } - // write out the entire image data in one call + /* write out the entire image data in one call */ png_write_image(png_ptr, row_pointers); - // write the additional chunks to the PNG file (not really needed) + /* write the additional chunks to the PNG file (not really needed) */ png_write_end(png_ptr, info_ptr); - // clean up + /* clean up */ MEM_freeN(pixels); MEM_freeN(row_pointers); png_destroy_write_struct(&png_ptr, &info_ptr); @@ -419,14 +419,14 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) longjmp(png_jmpbuf(png_ptr), 1); } - // allocate memory for an array of row-pointers + /* allocate memory for an array of row-pointers */ row_pointers = (png_bytepp) MEM_mallocN(ibuf->y * sizeof(png_uint_16p), "row_pointers"); if (row_pointers == NULL) { printf("Cannot allocate row-pointers array\n"); longjmp(png_jmpbuf(png_ptr), 1); } - // set the individual row-pointers to point at the correct offsets + /* set the individual row-pointers to point at the correct offsets */ for (i = 0; i < ibuf->y; i++) { row_pointers[ibuf->y - 1 - i] = (png_bytep) ((png_uint_16 *)pixels16 + (i * ibuf->x) * bytesperpixel); @@ -434,7 +434,7 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) png_read_image(png_ptr, row_pointers); - // copy image data + /* copy image data */ to_float = ibuf->rect_float; from16 = pixels16; @@ -487,14 +487,14 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) longjmp(png_jmpbuf(png_ptr), 1); } - // allocate memory for an array of row-pointers + /* allocate memory for an array of row-pointers */ row_pointers = (png_bytepp) MEM_mallocN(ibuf->y * sizeof(png_bytep), "row_pointers"); if (row_pointers == NULL) { printf("Cannot allocate row-pointers array\n"); longjmp(png_jmpbuf(png_ptr), 1); } - // set the individual row-pointers to point at the correct offsets + /* set the individual row-pointers to point at the correct offsets */ for (i = 0; i < ibuf->y; i++) { row_pointers[ibuf->y - 1 - i] = (png_bytep) ((unsigned char *)pixels + (i * ibuf->x) * bytesperpixel * sizeof(unsigned char)); @@ -502,7 +502,7 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) png_read_image(png_ptr, row_pointers); - // copy image data + /* copy image data */ to = (unsigned char *) ibuf->rect; from = pixels; @@ -555,7 +555,7 @@ ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) png_read_end(png_ptr, info_ptr); } - // clean up + /* clean up */ if (pixels) MEM_freeN(pixels); if (pixels16) diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c index 29c2e63637d..2ba1ebf90b5 100644 --- a/source/blender/imbuf/intern/radiance_hdr.c +++ b/source/blender/imbuf/intern/radiance_hdr.c @@ -163,8 +163,8 @@ static void FLOAT2RGBE(fCOLOR fcol, RGBE rgbe) int imb_is_a_hdr(unsigned char *buf) { - // For recognition, Blender only loads first 32 bytes, so use #?RADIANCE id instead - // update: actually, the 'RADIANCE' part is just an optional program name, the magic word is really only the '#?' part + /* For recognition, Blender only loads first 32 bytes, so use #?RADIANCE id instead */ + /* update: actually, the 'RADIANCE' part is just an optional program name, the magic word is really only the '#?' part */ //if (strstr((char*)buf, "#?RADIANCE")) return 1; if (strstr((char *)buf, "#?")) return 1; // if (strstr((char*)buf, "32-bit_rle_rgbe")) return 1; diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 615b420429a..cc57ffff812 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -466,7 +466,7 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image, int premul) if (success) { ibuf->profile = (bitspersample == 32) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_SRGB; -// Code seems to be not needed for 16 bits tif, on PPC G5 OSX (ton) + /* Code seems to be not needed for 16 bits tif, on PPC G5 OSX (ton) */ if (bitspersample < 16) if (ENDIAN_ORDER == B_ENDIAN) IMB_convert_rgba_to_abgr(tmpibuf); diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index 09cb22683a7..6436d04f54f 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -64,8 +64,8 @@ /* headers around with more freedom. */ static const char *includefiles[] = { - // if you add files here, please add them at the end - // of makesdna.c (this file) as well + /* if you add files here, please add them at the end + * of makesdna.c (this file) as well */ "DNA_listBase.h", "DNA_vec_types.h", @@ -80,8 +80,8 @@ static const char *includefiles[] = { "DNA_lamp_types.h", "DNA_material_types.h", "DNA_vfont_types.h", - // if you add files here, please add them at the end - // of makesdna.c (this file) as well + /* if you add files here, please add them at the end + * of makesdna.c (this file) as well */ "DNA_meta_types.h", "DNA_curve_types.h", "DNA_mesh_types.h", @@ -122,8 +122,8 @@ static const char *includefiles[] = { "DNA_particle_types.h", "DNA_cloth_types.h", "DNA_gpencil_types.h", - // if you add files here, please add them at the end - // of makesdna.c (this file) as well + /* if you add files here, please add them at the end + * of makesdna.c (this file) as well */ "DNA_windowmanager_types.h", "DNA_anim_types.h", "DNA_boid_types.h", @@ -134,7 +134,7 @@ static const char *includefiles[] = { "DNA_dynamicpaint_types.h", "DNA_mask_types.h", - // empty string to indicate end of includefiles + /* empty string to indicate end of includefiles */ "" }; @@ -450,7 +450,7 @@ static int preprocess_include(char *maindata, int len) memcpy(temp, maindata, len); - // remove all c++ comments + /* remove all c++ comments */ /* replace all enters/tabs/etc with spaces */ cp = temp; a = len; @@ -829,8 +829,8 @@ static int calculate_structlens(int firststruct) else { typelens[structtype] = len; alphalens[structtype] = alphalen; - // two ways to detect if a struct contains a pointer: - // has_pointer is set or alphalen != len + /* two ways to detect if a struct contains a pointer: + * has_pointer is set or alphalen != len */ if (has_pointer || alphalen != len) { if (alphalen % 8) { printf("Sizeerror 8 in struct: %s (add %d bytes)\n", types[structtype], alphalen % 8); @@ -972,7 +972,7 @@ static int make_structDNA(char *baseDirectory, FILE *file) add_type("uint64_t", 8); /* SDNA_TYPE_UINT64 */ add_type("void", 0); /* SDNA_TYPE_VOID */ - // the defines above shouldn't be output in the padding file... + /* the defines above shouldn't be output in the padding file... */ firststruct = nr_types; /* add all include files defined in the global array */ @@ -990,7 +990,7 @@ static int make_structDNA(char *baseDirectory, FILE *file) if (debugSDNA) printf("\tFinished scanning %d headers.\n", i); if (calculate_structlens(firststruct)) { - // error + /* error */ return(1); } @@ -1091,7 +1091,7 @@ static int make_structDNA(char *baseDirectory, FILE *file) if (fp == NULL) ; else { - // add all include files defined in the global array + /* add all include files defined in the global array */ for (i = 0; strlen(includefiles[i]); i++) { fprintf(fp, "#include \"%s%s\"\n", baseDirectory, includefiles[i]); } @@ -1168,7 +1168,7 @@ int main(int argc, char **argv) fprintf(file, "unsigned char DNAstr[]= {\n"); if (make_structDNA(baseDirectory, file)) { - // error + /* error */ fclose(file); make_bad_file(argv[1], __LINE__); return_status = 1; diff --git a/source/blender/modifiers/intern/MOD_boolean_util.c b/source/blender/modifiers/intern/MOD_boolean_util.c index 1b4d9444fd9..1402f2203c4 100644 --- a/source/blender/modifiers/intern/MOD_boolean_util.c +++ b/source/blender/modifiers/intern/MOD_boolean_util.c @@ -73,7 +73,7 @@ typedef struct { static void VertexIt_Destruct(CSG_VertexIteratorDescriptor *iterator) { if (iterator->it) { - // deallocate memory for iterator + /* deallocate memory for iterator */ MEM_freeN(iterator->it); iterator->it = 0; } @@ -128,18 +128,18 @@ static void VertexIt_Construct(CSG_VertexIteratorDescriptor *output, DerivedMesh VertexIt *it; if (output == 0) return; - // allocate some memory for blender iterator + /* allocate some memory for blender iterator */ it = (VertexIt *)(MEM_mallocN(sizeof(VertexIt), "Boolean_VIt")); if (it == 0) { return; } - // assign blender specific variables + /* assign blender specific variables */ it->dm = dm; - it->ob = ob; // needed for obmat transformations - + it->ob = ob; /* needed for obmat transformations */ + it->pos = 0; - // assign iterator function pointers. + /* assign iterator function pointers. */ output->Step = VertexIt_Step; output->Fill = VertexIt_Fill; output->Done = VertexIt_Done; @@ -171,14 +171,14 @@ static void FaceIt_Destruct(CSG_FaceIteratorDescriptor *iterator) static int FaceIt_Done(CSG_IteratorPtr it) { - // assume CSG_IteratorPtr is of the correct type. + /* assume CSG_IteratorPtr is of the correct type. */ FaceIt *iterator = (FaceIt *)it; return(iterator->pos >= iterator->dm->getNumTessFaces(iterator->dm)); } static void FaceIt_Fill(CSG_IteratorPtr it, CSG_IFace *face) { - // assume CSG_IteratorPtr is of the correct type. + /* assume CSG_IteratorPtr is of the correct type. */ FaceIt *face_it = (FaceIt *)it; MFace *mfaces = face_it->dm->getTessFaceArray(face_it->dm); MFace *mface = &mfaces[face_it->pos]; @@ -222,12 +222,12 @@ static void FaceIt_Construct( FaceIt *it; if (output == 0) return; - // allocate some memory for blender iterator + /* allocate some memory for blender iterator */ it = (FaceIt *)(MEM_mallocN(sizeof(FaceIt), "Boolean_FIt")); if (it == 0) { return; } - // assign blender specific variables + /* assign blender specific variables */ it->dm = dm; it->offset = offset; it->pos = 0; @@ -256,7 +256,7 @@ static void FaceIt_Construct( } } - // assign iterator function pointers. + /* assign iterator function pointers. */ output->Step = FaceIt_Step; output->Fill = FaceIt_Fill; output->Done = FaceIt_Done; @@ -267,37 +267,37 @@ static void FaceIt_Construct( static Object *AddNewBlenderMesh(Scene *scene, Base *base) { - // This little function adds a new mesh object to the blender object list - // It uses ob to duplicate data as this seems to be easier than creating - // a new one. This new oject contains no faces nor vertices. + /* This little function adds a new mesh object to the blender object list + * It uses ob to duplicate data as this seems to be easier than creating + * a new one. This new oject contains no faces nor vertices. */ Mesh *old_me; Base *basen; Object *ob_new; - // now create a new blender object. - // duplicating all the settings from the previous object - // to the new one. + /* now create a new blender object. + * duplicating all the settings from the previous object + * to the new one. */ ob_new = BKE_object_copy(base->object); - // Ok we don't want to use the actual data from the - // last object, the above function incremented the - // number of users, so decrement it here. + /* Ok we don't want to use the actual data from the + * last object, the above function incremented the + * number of users, so decrement it here. */ old_me = ob_new->data; old_me->id.us--; - // Now create a new base to add into the linked list of - // vase objects. - + /* Now create a new base to add into the linked list of + * vase objects. */ + basen = MEM_mallocN(sizeof(Base), "duplibase"); *basen = *base; BLI_addhead(&scene->base, basen); /* addhead: anders oneindige lus */ basen->object = ob_new; basen->flag &= ~SELECT; - // Initialize the mesh data associated with this object. + /* Initialize the mesh data associated with this object. */ ob_new->data = BKE_mesh_add("Mesh"); - // Finally assign the object type. + /* Finally assign the object type */. ob_new->type = OB_MESH; return ob_new; @@ -314,20 +314,20 @@ static void InterpCSGFace( mface = CDDM_get_tessface(dm, index); orig_mface = orig_dm->getTessFaceArray(orig_dm) + orig_index; - // get the vertex coordinates from the original mesh + /* get the vertex coordinates from the original mesh */ orig_co[0] = (orig_dm->getVertArray(orig_dm) + orig_mface->v1)->co; orig_co[1] = (orig_dm->getVertArray(orig_dm) + orig_mface->v2)->co; orig_co[2] = (orig_dm->getVertArray(orig_dm) + orig_mface->v3)->co; orig_co[3] = (orig_mface->v4) ? (orig_dm->getVertArray(orig_dm) + orig_mface->v4)->co : NULL; - // get the vertex coordinates from the new derivedmesh + /* get the vertex coordinates from the new derivedmesh */ co[0] = CDDM_get_vert(dm, mface->v1)->co; co[1] = CDDM_get_vert(dm, mface->v2)->co; co[2] = CDDM_get_vert(dm, mface->v3)->co; co[3] = (nr == 4) ? CDDM_get_vert(dm, mface->v4)->co : NULL; for (j = 0; j < nr; j++) { - // get coordinate into the space of the original mesh + /* get coordinate into the space of the original mesh */ if (mapmat) mul_v3_m4v3(obco, mapmat, co[j]); else @@ -359,28 +359,28 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( Mesh *me2 = (Mesh *)ob2->data; int i, *origindex_layer; - // create a new DerivedMesh + /* create a new DerivedMesh */ result = CDDM_new(vertex_it->num_elements, 0, face_it->num_elements, 0, 0); CustomData_merge(&dm1->faceData, &result->faceData, CD_MASK_DERIVEDMESH & ~(CD_MASK_NORMAL | CD_MASK_POLYINDEX | CD_MASK_ORIGINDEX), CD_DEFAULT, face_it->num_elements); CustomData_merge(&dm2->faceData, &result->faceData, CD_MASK_DERIVEDMESH & ~(CD_MASK_NORMAL | CD_MASK_POLYINDEX | CD_MASK_ORIGINDEX), CD_DEFAULT, face_it->num_elements); - // step through the vertex iterators: + /* step through the vertex iterators: */ for (i = 0; !vertex_it->Done(vertex_it->it); i++) { CSG_IVertex csgvert; MVert *mvert = CDDM_get_vert(result, i); - // retrieve a csg vertex from the boolean module + /* retrieve a csg vertex from the boolean module */ vertex_it->Fill(vertex_it->it, &csgvert); vertex_it->Step(vertex_it->it); - // we have to map the vertex coordinates back in the coordinate frame - // of the resulting object, since it was computed in world space + /* we have to map the vertex coordinates back in the coordinate frame + * of the resulting object, since it was computed in world space */ mul_v3_m4v3(mvert->co, parinv, csgvert.position); } - // a hash table to remap materials to indices + /* a hash table to remap materials to indices */ material_hash = BLI_ghash_ptr_new("CSG_mat gh"); if (mat) @@ -388,7 +388,7 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( origindex_layer = result->getTessFaceDataArray(result, CD_ORIGINDEX); - // step through the face iterators + /* step through the face iterators */ for (i = 0; !face_it->Done(face_it->it); i++) { Mesh *orig_me; Object *orig_ob; @@ -397,27 +397,27 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( MFace *mface; int orig_index, mat_nr; - // retrieve a csg face from the boolean module + /* retrieve a csg face from the boolean module */ face_it->Fill(face_it->it, &csgface); face_it->Step(face_it->it); - // find the original mesh and data + /* find the original mesh and data */ orig_ob = (csgface.orig_face < dm1->getNumTessFaces(dm1)) ? ob1 : ob2; orig_dm = (csgface.orig_face < dm1->getNumTessFaces(dm1)) ? dm1 : dm2; orig_me = (orig_ob == ob1) ? me1 : me2; orig_index = (orig_ob == ob1) ? csgface.orig_face : csgface.orig_face - dm1->getNumTessFaces(dm1); - // copy all face layers, including mface + /* copy all face layers, including mface */ CustomData_copy_data(&orig_dm->faceData, &result->faceData, orig_index, i, 1); - // set mface + /* set mface */ mface = CDDM_get_tessface(result, i); mface->v1 = csgface.vertex_index[0]; mface->v2 = csgface.vertex_index[1]; mface->v3 = csgface.vertex_index[2]; mface->v4 = (csgface.vertex_number == 4) ? csgface.vertex_index[3] : 0; - // set material, based on lookup in hash table + /* set material, based on lookup in hash table */ orig_mat = give_current_material(orig_ob, mface->mat_nr + 1); if (mat && orig_mat) { @@ -431,11 +431,11 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( } else if (orig_mat) { if (orig_ob == ob1) { - // No need to change materian index for faces from left operand + /* No need to change materian index for faces from left operand */ } else { - // for faces from right operand checn if there's needed material in left operand and if it is, - // use index of that material, otherwise fallback to first material (material with index=0) + /* for faces from right operand checn if there's needed material in left operand and if it is, + * use index of that material, otherwise fallback to first material (material with index=0) */ if (!BLI_ghash_haskey(material_hash, orig_mat)) { int a; @@ -521,27 +521,27 @@ static DerivedMesh *NewBooleanDerivedMesh_intern( if (dm == NULL || dm_select == NULL) return 0; if (!dm->getNumTessFaces(dm) || !dm_select->getNumTessFaces(dm_select)) return 0; - // we map the final object back into ob's local coordinate space. For this - // we need to compute the inverse transform from global to ob (inv_mat), - // and the transform from ob to ob_select for use in interpolation (map_mat) + /* we map the final object back into ob's local coordinate space. For this + * we need to compute the inverse transform from global to ob (inv_mat), + * and the transform from ob to ob_select for use in interpolation (map_mat) */ invert_m4_m4(inv_mat, ob->obmat); mult_m4_m4m4(map_mat, inv_mat, ob_select->obmat); invert_m4_m4(inv_mat, ob_select->obmat); { - // interface with the boolean module: - // - // the idea is, we pass the boolean module verts and faces using the - // provided descriptors. once the boolean operation is performed, we - // get back output descriptors, from which we then build a DerivedMesh + /* interface with the boolean module: + * + * the idea is, we pass the boolean module verts and faces using the + * provided descriptors. once the boolean operation is performed, we + * get back output descriptors, from which we then build a DerivedMesh */ CSG_VertexIteratorDescriptor vd_1, vd_2; CSG_FaceIteratorDescriptor fd_1, fd_2; CSG_OperationType op_type; CSG_BooleanOperation *bool_op; - // work out the operation they chose and pick the appropriate - // enum from the csg module. + /* work out the operation they chose and pick the appropriate + * enum from the csg module. */ switch (int_op_type) { case 1: op_type = e_csg_intersection; break; case 2: op_type = e_csg_union; break; @@ -549,13 +549,13 @@ static DerivedMesh *NewBooleanDerivedMesh_intern( case 4: op_type = e_csg_classify; break; default: op_type = e_csg_intersection; } - + BuildMeshDescriptors(dm_select, ob_select, 0, &fd_1, &vd_1); BuildMeshDescriptors(dm, ob, dm_select->getNumTessFaces(dm_select), &fd_2, &vd_2); bool_op = CSG_NewBooleanFunction(); - // perform the operation + /* perform the operation */ if (CSG_PerformBooleanOperation(bool_op, op_type, fd_1, vd_1, fd_2, vd_2)) { CSG_VertexIteratorDescriptor vd_o; CSG_FaceIteratorDescriptor fd_o; @@ -563,12 +563,12 @@ static DerivedMesh *NewBooleanDerivedMesh_intern( CSG_OutputFaceDescriptor(bool_op, &fd_o); CSG_OutputVertexDescriptor(bool_op, &vd_o); - // iterate through results of operation and insert - // into new object + /* iterate through results of operation and insert + * into new object */ result = ConvertCSGDescriptorsToDerivedMesh( &fd_o, &vd_o, inv_mat, map_mat, mat, totmat, dm_select, ob_select, dm, ob); - // free up the memory + /* free up the memory */ CSG_FreeVertexDescriptor(&vd_o); CSG_FreeFaceDescriptor(&fd_o); } diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c index 609d70b6e98..45296e322b5 100644 --- a/source/blender/modifiers/intern/MOD_collision.c +++ b/source/blender/modifiers/intern/MOD_collision.c @@ -140,15 +140,15 @@ static void deformVerts(ModifierData *md, Object *ob, if ((current_time > collmd->time_xnew) || (BKE_ptcache_get_continue_physics())) { unsigned int i; - // check if mesh has changed + /* check if mesh has changed */ if (collmd->x && (numverts != collmd->numverts)) freeData((ModifierData *)collmd); - + if (collmd->time_xnew == -1000) { /* first time */ - collmd->x = dm->dupVertArray(dm); // frame start position - + collmd->x = dm->dupVertArray(dm); /* frame start position */ + for (i = 0; i < numverts; i++) { - // we save global positions + /* we save global positions */ mul_m4_v3(ob->obmat, collmd->x[i].co); } @@ -164,22 +164,22 @@ static void deformVerts(ModifierData *md, Object *ob, collmd->mfaces = dm->dupTessFaceArray(dm); collmd->numfaces = dm->getNumTessFaces(dm); - // create bounding box hierarchy + /* create bounding box hierarchy */ collmd->bvhtree = bvhtree_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->x, numverts, ob->pd->pdef_sboft); - + collmd->time_x = collmd->time_xnew = current_time; } else if (numverts == collmd->numverts) { - // put positions to old positions + /* put positions to old positions */ tempVert = collmd->x; collmd->x = collmd->xnew; collmd->xnew = tempVert; collmd->time_x = collmd->time_xnew; - + memcpy(collmd->xnew, dm->getVertArray(dm), numverts * sizeof(MVert)); - + for (i = 0; i < numverts; i++) { - // we save global positions + /* we save global positions */ mul_m4_v3(ob->obmat, collmd->xnew[i].co); } @@ -200,7 +200,7 @@ static void deformVerts(ModifierData *md, Object *ob, collmd->bvhtree = bvhtree_build_from_mvert(collmd->mfaces, collmd->numfaces, collmd->current_x, numverts, ob->pd->pdef_sboft); } else { - // recalc static bounding boxes + /* recalc static bounding boxes */ bvhtree_update_from_mvert(collmd->bvhtree, collmd->mfaces, collmd->numfaces, collmd->current_x, collmd->current_xnew, collmd->numverts, 1); } diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index a33d80bcd35..1c98880c3db 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -96,20 +96,20 @@ void fluidsim_init(FluidsimModifierData *fluidmd) fss->animRate = 1.0; fss->gstar = 0.005; // used as normgstar fss->maxRefine = -1; - // maxRefine is set according to resolutionxyz during bake + /* maxRefine is set according to resolutionxyz during bake */ - // fluid/inflow settings - // fss->iniVel --> automatically set to 0 + /* fluid/inflow settings + * fss->iniVel --> automatically set to 0 */ modifier_path_init(fss->surfdataPath, sizeof(fss->surfdataPath), "cache_fluid"); - // first init of bounding box - // no bounding box needed - - // todo - reuse default init from elbeem! + /* first init of bounding box */ + /* no bounding box needed */ + + /* todo - reuse default init from elbeem! */ fss->typeFlags = OB_FSBND_PARTSLIP | OB_FSSG_NOOBS; fss->domainNovecgen = 0; - fss->volumeInitType = 1; // volume + fss->volumeInitType = 1; /* volume */ fss->partSlipValue = 0.2; fss->generateTracers = 0; @@ -118,8 +118,8 @@ void fluidsim_init(FluidsimModifierData *fluidmd) fss->surfaceSubdivs = 0.0; fss->particleInfSize = 0.0; fss->particleInfAlpha = 0.0; - - // init fluid control settings + + /* init fluid control settings */ fss->attractforceStrength = 0.2; fss->attractforceRadius = 0.75; fss->velocityforceStrength = 0.2; @@ -179,27 +179,27 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam const short mp_mat_nr = mp_example->mat_nr; const char mp_flag = mp_example->flag; - // ------------------------------------------------ - // get numverts + numfaces first - // ------------------------------------------------ + /* ------------------------------------------------ + * get numverts + numfaces first + * ------------------------------------------------ */ gzf = BLI_gzopen(filename, "rb"); if (!gzf) { return NULL; } - // read numverts + /* read numverts */ gotBytes = gzread(gzf, &wri, sizeof(wri)); numverts = wri; - // skip verts + /* skip verts */ gotBytes = gzseek(gzf, numverts * 3 * sizeof(float), SEEK_CUR) != -1; - // read number of normals + /* read number of normals */ if (gotBytes) gotBytes = gzread(gzf, &wri, sizeof(wri)); - // skip normals + /* skip normals */ gotBytes = gzseek(gzf, numverts * 3 * sizeof(float), SEEK_CUR) != -1; /* get no. of triangles */ @@ -208,7 +208,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam numfaces = wri; gzclose(gzf); - // ------------------------------------------------ + /* ------------------------------------------------ */ if (!numfaces || !numverts || !gotBytes) return NULL; @@ -225,16 +225,16 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam return NULL; } - // read numverts + /* read numverts */ gotBytes = gzread(gzf, &wri, sizeof(wri)); - // read vertex position from file + /* read vertex position from file */ mv = CDDM_get_verts(dm); for (i = 0; i < numverts; i++, mv++) gotBytes = gzread(gzf, mv->co, sizeof(float) * 3); - // should be the same as numverts + /* should be the same as numverts */ gotBytes = gzread(gzf, &wri, sizeof(wri)); if (wri != numverts) { if (dm) @@ -251,7 +251,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam return NULL; } - // read normals from file (but don't save them yet) + /* read normals from file (but don't save them yet) */ for (i = numverts, no_s = normals; i > 0; i--, no_s += 3) { gotBytes = gzread(gzf, no, sizeof(float) * 3); normal_float_to_short_v3(no_s, no); @@ -269,7 +269,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam return NULL; } - // read triangles from file + /* read triangles from file */ mp = CDDM_get_polys(dm); ml = CDDM_get_loops(dm); for (i = 0; i < numfaces; i++, mp++, ml += 3) { @@ -333,7 +333,7 @@ void fluid_get_bb(MVert *mvert, int totvert, float obmat[][4], if (vec[2] > bbez) { bbez = vec[2]; } } - // return values... + /* return values... */ if (start) { start[0] = bbsx; start[1] = bbsy; @@ -377,7 +377,7 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh * int totvert = dm->getNumVerts(dm); FluidVertexVelocity *velarray = NULL; - // mesh and vverts have to be valid from loading... + /* mesh and vverts have to be valid from loading... */ if (fss->meshVelocities) MEM_freeN(fss->meshVelocities); @@ -393,8 +393,8 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh * velarray = fss->meshVelocities; - // .bobj.gz, correct filename - // 87654321 + /* .bobj.gz, correct filename + * 87654321 */ filename[len - 6] = 'v'; filename[len - 5] = 'e'; filename[len - 4] = 'l'; @@ -461,8 +461,8 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, BLI_path_abs(targetFile, modifier_path_relbase(ob)); BLI_path_frame(targetFile, curFrame, 0); // fixed #frame-no - // assign material + flags to new dm - // if there's no faces in original dm, keep materials and flags unchanged + /* assign material + flags to new dm + * if there's no faces in original dm, keep materials and flags unchanged */ mpoly = orgdm->getPolyArray(orgdm); if (mpoly) { mp_example = *mpoly; @@ -472,7 +472,7 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, dm = fluidsim_read_obj(targetFile, &mp_example); if (!dm) { - // switch, abort background rendering when fluidsim mesh is missing + /* switch, abort background rendering when fluidsim mesh is missing */ const char *strEnvName2 = "BLENDER_ELBEEMBOBJABORT"; // from blendercall.cpp if (G.background == 1) { @@ -486,13 +486,13 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, } } - // display org. object upon failure which is in dm + /* display org. object upon failure which is in dm */ return NULL; } - // load vertex velocities, if they exist... - // TODO? use generate flag as loading flag as well? - // warning, needs original .bobj.gz mesh loading filename + /* load vertex velocities, if they exist... + * TODO? use generate flag as loading flag as well? + * warning, needs original .bobj.gz mesh loading filename */ if (displaymode == 3) { fluidsim_read_vel_cache(fluidmd, dm, targetFile); } @@ -519,20 +519,20 @@ DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Scene *scene, framenr = (int)scene->r.cfra; - // only handle fluidsim domains + /* only handle fluidsim domains */ if (fluidmd && fluidmd->fss && (fluidmd->fss->type != OB_FLUIDSIM_DOMAIN)) return dm; - - // sanity check + + /* sanity check */ if (!fluidmd || (fluidmd && !fluidmd->fss)) return dm; - + fss = fluidmd->fss; - - // timescale not supported yet - // clmd->sim_parms->timescale= timescale; - // support reversing of baked fluid frames here + /* timescale not supported yet + * clmd->sim_parms->timescale= timescale; */ + + /* support reversing of baked fluid frames here */ if ((fss->flag & OB_FLUIDSIM_REVERSE) && (fss->lastgoodframe >= 0)) { framenr = fss->lastgoodframe - framenr + 1; CLAMP(framenr, 1, fss->lastgoodframe); diff --git a/source/blender/modifiers/intern/MOD_smoke.c b/source/blender/modifiers/intern/MOD_smoke.c index 7092ef04d0f..b9b3b89e06d 100644 --- a/source/blender/modifiers/intern/MOD_smoke.c +++ b/source/blender/modifiers/intern/MOD_smoke.c @@ -117,7 +117,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, if (go->ob) { SmokeModifierData *smd2 = (SmokeModifierData *)modifiers_findByType(go->ob, eModifierType_Smoke); - // check for initialized smoke object + /* check for initialized smoke object */ if (smd2 && (smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow) { DagNode *curNode = dag_get_node(forest, go->ob); dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Smoke Flow"); @@ -130,7 +130,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, if (go->ob) { SmokeModifierData *smd2 = (SmokeModifierData *)modifiers_findByType(go->ob, eModifierType_Smoke); - // check for initialized smoke object + /* check for initialized smoke object */ if (smd2 && (smd2->type & MOD_SMOKE_TYPE_COLL) && smd2->coll) { DagNode *curNode = dag_get_node(forest, go->ob); dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Smoke Coll"); diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index ac9ff4c8ef5..93f49fd72c9 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -303,7 +303,7 @@ void BPY_python_end(void) PyGILState_Ensure(); /* finalizing, no need to grab the state */ - // free other python data. + /* free other python data. */ pyrna_free_types(); /* clear all python data from structs */ @@ -317,7 +317,7 @@ void BPY_python_end(void) Py_Finalize(); #ifdef TIME_PY_RUN - // measure time since py started + /* measure time since py started */ bpy_timer = PIL_check_seconds_timer() - bpy_timer; printf("*bpy stats* - "); diff --git a/source/blender/python/intern/gpu.c b/source/blender/python/intern/gpu.c index e5f45ca7736..7e2da5b1818 100644 --- a/source/blender/python/intern/gpu.c +++ b/source/blender/python/intern/gpu.c @@ -83,7 +83,7 @@ PyInit_gpu(void) if (m == NULL) return NULL; - // device constants + /* device constants */ PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_OBJECT_VIEWMAT); PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_OBJECT_MAT); PY_MODULE_ADD_CONSTANT(m, GPU_DYNAMIC_OBJECT_VIEWIMAT); @@ -187,13 +187,13 @@ static PyObject *GPU_export_shader(PyObject *UNUSED(self), PyObject *args, PyObj return NULL; } - // we can call our internal function at last: + /* we can call our internal function at last: */ shader = GPU_shader_export(scene, material); if (!shader) { PyErr_SetString(PyExc_RuntimeError, "cannot export shader"); return NULL; } - // build a dictionary + /* build a dictionary */ result = PyDict_New(); if (shader->fragment) { PY_DICT_ADD_STRING(result, shader, fragment); diff --git a/source/blender/quicktime/apple/quicktime_export.c b/source/blender/quicktime/apple/quicktime_export.c index ab1192bfdfc..659fd997c1f 100644 --- a/source/blender/quicktime/apple/quicktime_export.c +++ b/source/blender/quicktime/apple/quicktime_export.c @@ -202,7 +202,7 @@ static OSErr QT_SaveCodecSettingsToScene(RenderData *rd, ReportList *reports) QuicktimeCodecData *qcd = rd->qtcodecdata; - // check if current scene already has qtcodec settings, and clear them + /* check if current scene already has qtcodec settings, and clear them */ if (qcd) { free_qtcodecdata(qcd); } @@ -210,26 +210,26 @@ static OSErr QT_SaveCodecSettingsToScene(RenderData *rd, ReportList *reports) qcd = rd->qtcodecdata = MEM_callocN(sizeof(QuicktimeCodecData), "QuicktimeCodecData"); } - // obtain all current codec settings + /* obtain all current codec settings */ SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); SCSetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); SCSetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); - // retreive codecdata from quicktime in a atomcontainer + /* retreive codecdata from quicktime in a atomcontainer */ myErr = SCGetSettingsAsAtomContainer(qtdata->theComponent, &myContainer); if (myErr != noErr) { - BKE_reportf(reports, RPT_ERROR, "Quicktime: SCGetSettingsAsAtomContainer failed\n"); + BKE_reportf(reports, RPT_ERROR, "Quicktime: SCGetSettingsAsAtomContainer failed\n"); goto bail; } - // get the size of the atomcontainer + /* get the size of the atomcontainer */ mySize = GetHandleSize((Handle)myContainer); - // lock and convert the atomcontainer to a *valid* pointer + /* lock and convert the atomcontainer to a *valid* pointer */ QTLockContainer(myContainer); myPtr = *(Handle)myContainer; - // copy the Quicktime data into the blender qtcodecdata struct + /* copy the Quicktime data into the blender qtcodecdata struct */ if (myPtr) { qcd->cdParms = MEM_mallocN(mySize, "qt.cdParms"); memcpy(qcd->cdParms, myPtr, mySize); @@ -258,21 +258,21 @@ static OSErr QT_GetCodecSettingsFromScene(RenderData *rd, ReportList *reports) QuicktimeCodecData *qcd = rd->qtcodecdata; - // if there is codecdata in the blendfile, convert it to a Quicktime handle + /* if there is codecdata in the blendfile, convert it to a Quicktime handle */ if (qcd) { myHandle = NewHandle(qcd->cdSize); PtrToHand(qcd->cdParms, &myHandle, qcd->cdSize); } - // restore codecsettings to the quicktime component + /* restore codecsettings to the quicktime component */ if (qcd->cdParms && qcd->cdSize) { myErr = SCSetSettingsFromAtomContainer((GraphicsExportComponent)qtdata->theComponent, (QTAtomContainer)myHandle); if (myErr != noErr) { - BKE_reportf(reports, RPT_ERROR, "Quicktime: SCSetSettingsFromAtomContainer failed\n"); + BKE_reportf(reports, RPT_ERROR, "Quicktime: SCSetSettingsFromAtomContainer failed\n"); goto bail; } - // update runtime codecsettings for use with the codec dialog + /* update runtime codecsettings for use with the codec dialog */ SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); @@ -312,22 +312,22 @@ static OSErr QT_AddUserDataTextToMovie(Movie theMovie, char *theText, OSType the long myLength = strlen(theText); OSErr myErr = noErr; - // get the movie's user data list + /* get the movie's user data list */ myUserData = GetMovieUserData(theMovie); if (myUserData == NULL) return(paramErr); - - // copy the specified text into a new handle + + /* copy the specified text into a new handle */ myHandle = NewHandleClear(myLength); if (myHandle == NULL) return(MemError()); BlockMoveData(theText, *myHandle, myLength); - // add the data to the movie's user data + /* add the data to the movie's user data */ myErr = AddUserDataText(myUserData, myHandle, theType, 1, (short)GetScriptManagerVariable(smRegionCode)); - // clean up + /* clean up */ DisposeHandle(myHandle); return(myErr); } @@ -408,9 +408,9 @@ static void QT_StartAddVideoSamplesToMedia(const Rect *trackFrame, int rectx, in SCDefaultPixMapSettings(qtdata->theComponent, qtexport->thePixMap, true); - // workaround for crash with H.264, which requires an upgrade to - // the new callback based api for proper encoding, but that's not - // really compatible with rendering out frames sequentially + /* workaround for crash with H.264, which requires an upgrade to + * the new callback based api for proper encoding, but that's not + * really compatible with rendering out frames sequentially */ gTemporalSettings = qtdata->gTemporalSettings; if (qtdata->gSpatialSettings.codecType == kH264CodecType) { if (gTemporalSettings.temporalQuality != codecMinQuality) { @@ -662,7 +662,7 @@ void free_qtcomponentdata(void) static void check_renderbutton_framerate(RenderData *rd, ReportList *reports) { - // to keep float framerates consistent between the codec dialog and frs/sec button. + /* to keep float framerates consistent between the codec dialog and frs/sec button. */ OSErr err; err = SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); @@ -722,17 +722,17 @@ void quicktime_verify_image_type(RenderData *rd, ImageFormatData *imf) int get_qtcodec_settings(RenderData *rd, ReportList *reports) { OSErr err = noErr; - // erase any existing codecsetting + /* erase any existing codecsetting */ if (qtdata) { if (qtdata->theComponent) CloseComponent(qtdata->theComponent); free_qtcomponentdata(); } - // allocate new + /* allocate new */ qtdata = MEM_callocN(sizeof(QuicktimeComponentData), "QuicktimeComponentData"); qtdata->theComponent = OpenDefaultComponent(StandardCompressionType, StandardCompressionSubType); - // get previous selected codecsetting, from qtatom or detailed settings + /* get previous selected codecsetting, from qtatom or detailed settings */ if (rd->qtcodecdata && rd->qtcodecdata->cdParms) { QT_GetCodecSettingsFromScene(rd, reports); } @@ -774,17 +774,17 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); RenderData *rd = &scene->r; - // erase any existing codecsetting + /* erase any existing codecsetting */ if (qtdata) { if (qtdata->theComponent) CloseComponent(qtdata->theComponent); free_qtcomponentdata(); } - - // allocate new + + /* allocate new */ qtdata = MEM_callocN(sizeof(QuicktimeComponentData), "QuicktimeComponentData"); qtdata->theComponent = OpenDefaultComponent(StandardCompressionType, StandardCompressionSubType); - - // get previous selected codecsetting, from qtatom or detailed settings + + /* get previous selected codecsetting, from qtatom or detailed settings */ if (rd->qtcodecdata && rd->qtcodecdata->cdParms) { QT_GetCodecSettingsFromScene(rd, op->reports); } @@ -813,14 +813,14 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op) err = SCSetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); CheckError(err, "SCSetInfo3 error", op->reports); } - // put up the dialog box - it needs to be called from the main thread + /* put up the dialog box - it needs to be called from the main thread */ err = SCRequestSequenceSettings(qtdata->theComponent); - + if (err == scUserCancelled) { return OPERATOR_FINISHED; } - // update runtime codecsettings for use with the codec dialog + /* update runtime codecsettings for use with the codec dialog */ SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); @@ -843,7 +843,7 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op) QT_SaveCodecSettingsToScene(rd, op->reports); - // framerate jugglin' + /* framerate jugglin' */ if (qtdata->gTemporalSettings.frameRate == 1571553) { // 23.98 fps qtdata->kVideoTimeScale = 24000; qtdata->duration = 1001; diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index d21a22f553b..cb6a0fd1198 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -525,7 +525,7 @@ typedef struct { } SRenderMeshToTangent; -// interface +/* interface */ #include "mikktspace.h" static int GetNumFaces(const SMikkTSpaceContext * pContext) @@ -1029,7 +1029,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par static int second=0; sub_v3_v3v3(nor, vec, vec1); - normalize_v3(nor); // nor needed as tangent + normalize_v3(nor); /* nor needed as tangent */ cross_v3_v3v3(cross, vec, nor); /* turn cross in pixelsize */ @@ -1089,7 +1089,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par add_v3_v3(vlr->v1->co, cross); copy_v3_v3(vlr->v1->n, nor); vlr->v1->orco= sd->orco; - vlr->v1->accum= -1.0f; // accum abuse for strand texco + vlr->v1->accum = -1.0f; /* accum abuse for strand texco */ copy_v3_v3(vlr->v2->co, vec); sub_v3_v3v3(vlr->v2->co, vlr->v2->co, cross); @@ -1101,8 +1101,8 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par add_v3_v3(vlr->v4->co, cross); copy_v3_v3(vlr->v4->n, nor); vlr->v4->orco= sd->orco; - vlr->v4->accum= 1.0f; // accum abuse for strand texco - + vlr->v4->accum = 1.0f; /* accum abuse for strand texco */ + copy_v3_v3(vlr->v3->co, vec1); sub_v3_v3v3(vlr->v3->co, vlr->v3->co, cross); copy_v3_v3(vlr->v3->n, nor); @@ -1163,7 +1163,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par add_v3_v3(v1->co, cross); copy_v3_v3(v1->n, nor); v1->orco= sd->orco; - v1->accum= -1.0f; // accum abuse for strand texco + v1->accum = -1.0f; /* accum abuse for strand texco */ copy_v3_v3(v2->co, vec); sub_v3_v3v3(v2->co, v2->co, cross); @@ -1180,11 +1180,11 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par vlr->v2= v2; vlr->v3= RE_findOrAddVert(obr, obr->totvert++); vlr->v4= RE_findOrAddVert(obr, obr->totvert++); - - v1= vlr->v4; // cycle - v2= vlr->v3; // cycle - + v1= vlr->v4; /* cycle */ + v2= vlr->v3; /* cycle */ + + if (sd->adapt) { second=0; copy_v3_v3(anor, nor); @@ -1209,9 +1209,9 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par vlr->v2= v2; vlr->v3= RE_findOrAddVert(obr, obr->totvert++); vlr->v4= RE_findOrAddVert(obr, obr->totvert++); - - v1= vlr->v4; // cycle - v2= vlr->v3; // cycle + + v1= vlr->v4; /* cycle */ + v2= vlr->v3; /* cycle */ copy_v3_v3(anor, nor); copy_v3_v3(avec, vec); @@ -1225,8 +1225,8 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par add_v3_v3(vlr->v4->co, cross); copy_v3_v3(vlr->v4->n, nor); vlr->v4->orco= sd->orco; - vlr->v4->accum= -1.0f + 2.0f*sd->time; // accum abuse for strand texco - + vlr->v4->accum= -1.0f + 2.0f * sd->time; /* accum abuse for strand texco */ + copy_v3_v3(vlr->v3->co, vec); sub_v3_v3v3(vlr->v3->co, vlr->v3->co, cross); copy_v3_v3(vlr->v3->n, nor); @@ -1309,7 +1309,7 @@ static void static_particle_wire(ObjectRen *obr, Material *ma, const float vec[3 vlr->v3= vlr->v2; vlr->v4= NULL; - v1= vlr->v2; // cycle + v1= vlr->v2; /* cycle */ copy_v3_v3(v1->co, vec); sub_v3_v3v3(vlr->n, vec, vec1); @@ -1630,12 +1630,12 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem /* 2.1 setup material stff */ ma= give_render_material(re, ob, part->omat); -#if 0 // XXX old animation system +#if 0 /* XXX old animation system */ if (ma->ipo) { calc_ipo(ma->ipo, cfra); execute_ipo((ID *)ma, ma->ipo); } -#endif // XXX old animation system +#endif /* XXX old animation system */ hasize = ma->hasize; seed = ma->seed1; @@ -2087,10 +2087,10 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem strandbuf->surface= cache_strand_surface(re, obr, psmd->dm, mat, timeoffset); /* 4. clean up */ -#if 0 // XXX old animation system +#if 0 /* XXX old animation system */ if (ma) do_mat_ipo(re->scene, ma); -#endif // XXX old animation system - +#endif /* XXX old animation system */ + if (orco1) MEM_freeN(sd.orco); @@ -3267,7 +3267,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) int a, a1, ok, vertofs; int end, do_autosmooth = FALSE, totvert = 0; int use_original_normals = FALSE; - int recalc_normals = 0; // false by default + int recalc_normals = 0; /* false by default */ int negative_scale; me= ob->data; @@ -3471,7 +3471,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) int t; mtf= RE_vlakren_get_tface(obr, vlr, mtfn++, &name, 1); mtface= (MTFace*)layer->data; - *mtf= mtface[a]; // copy face info + *mtf = mtface[a]; /* copy face info */ for (vindex=0; vindexuv[vindex][t]=mtface[a].uv[rev_tab[vindex]][t]; @@ -3733,7 +3733,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) lar->shdwb= la->shdwb; lar->k= la->k; - // area + /* area */ lar->ray_samp= la->ray_samp; lar->ray_sampy= la->ray_sampy; lar->ray_sampz= la->ray_sampz; @@ -3784,7 +3784,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) } area_lamp_vectors(lar); - init_jitter_plane(lar); // subsamples + init_jitter_plane(lar); /* subsamples */ } else if (lar->type==LA_SUN) { lar->ray_totsamp= lar->ray_samp*lar->ray_samp; @@ -3819,7 +3819,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) memcpy(lar->mtex, la->mtex, MAX_MTEX*sizeof(void *)); - lar->lay= ob->lay & 0xFFFFFF; // higher 8 bits are localview layers + lar->lay = ob->lay & 0xFFFFFF; /* higher 8 bits are localview layers */ lar->falloff_type = la->falloff_type; lar->ld1= la->att1; @@ -3904,7 +3904,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) /* Per lamp, one shadow buffer is made. */ lar->bufflag= la->bufflag; copy_m4_m4(mat, ob->obmat); - initshadowbuf(re, lar, mat); // mat is altered + initshadowbuf(re, lar, mat); /* mat is altered */ } @@ -4247,8 +4247,8 @@ static void check_non_flat_quads(ObjectRen *obr) xn = dot_v3v3(nor, vlr->n); - if (ABS(xn) < 0.999995f ) { // checked on noisy fractal grid - + if (ABS(xn) < 0.999995f ) { /* checked on noisy fractal grid */ + float d1, d2; vlr1= RE_vlakren_copy(obr, vlr); @@ -5478,7 +5478,7 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float * else ver++; - // get fluid velocity + /* get fluid velocity */ fsvec[3] = 0.0f; //fsvec[0] = fsvec[1] = fsvec[2] = fsvec[3] = 0.0; fsvec[2] = 2.0f; // NT fixed test for (j=0;j<3;j++) fsvec[j] = velarray[a].vel[j]; @@ -5490,31 +5490,31 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float * fsvec[2] = avgvel[2]; } - // transform (=rotate) to cam space + /* transform (=rotate) to cam space */ camco[0] = dot_v3v3(imat[0], fsvec); camco[1] = dot_v3v3(imat[1], fsvec); camco[2] = dot_v3v3(imat[2], fsvec); - // get homogenous coordinates + /* get homogenous coordinates */ projectvert(camco, winmat, hoco); projectvert(ver->co, winmat, ho); /* now map hocos to screenspace, uses very primitive clip still */ - // use ho[3] of original vertex, xy component of vel. direction + /* use ho[3] of original vertex, xy component of vel. direction */ if (ho[3]<0.1f) div= 10.0f; else div= 1.0f/ho[3]; zco[0]= zmulx*hoco[0]*div; zco[1]= zmuly*hoco[1]*div; - // maximize speed as usual + /* maximize speed as usual */ len= zco[0]*zco[0] + zco[1]*zco[1]; if (len > winsq) { len= winroot/sqrtf(len); zco[0]*= len; zco[1]*= len; } - + speed= RE_vertren_get_winspeed(obi, ver, 1); - // set both to the same value + /* set both to the same value */ speed[0]= speed[2]= zco[0]; speed[1]= speed[3]= zco[1]; //if (a < 20) fprintf(stderr,"speed %d %f,%f | camco %f,%f,%f | hoco %f,%f,%f,%f\n", a, speed[0], speed[1], camco[0],camco[1], camco[2], hoco[0],hoco[1], hoco[2],hoco[3]); // NT DEBUG @@ -5651,7 +5651,7 @@ void RE_Database_FromScene_Vectors(Render *re, Main *bmain, Scene *sce, unsigned continue; } - // NT check for fluidsim special treatment + /* NT check for fluidsim special treatment */ fluidmd = (FluidsimModifierData *)modifiers_findByType(obi->ob, eModifierType_Fluidsim); if (fluidmd && fluidmd->fss && (fluidmd->fss->type & OB_FLUIDSIM_DOMAIN)) { /* use preloaded per vertex simulation data, only does calculation for step=1 */ @@ -5664,7 +5664,7 @@ void RE_Database_FromScene_Vectors(Render *re, Main *bmain, Scene *sce, unsigned calculate_speedvectors(re, obi, oldobi->vectors, step); else printf("Warning: object %s has different amount of vertices or strands on other frame\n", obi->ob->id.name+2); - } // not fluidsim + } /* not fluidsim */ oldobi= oldobi->next; } diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index 61de4d39585..5879a9bd66d 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -49,7 +49,7 @@ #include "BKE_library.h" #include "BKE_main.h" -#include "BKE_image.h" // BKE_imbuf_write +#include "BKE_image.h" /* BKE_imbuf_write */ #include "BKE_texture.h" @@ -579,7 +579,7 @@ void make_envmaps(Render *re) re->display_clear(re->dch, re->result); // re->flag |= R_REDRAW_PRV; } - // restore + /* restore */ re->r.mode |= trace; } diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c index e3eab0c3b34..75206f10f84 100644 --- a/source/blender/render/intern/source/external_engine.c +++ b/source/blender/render/intern/source/external_engine.c @@ -192,7 +192,7 @@ void RE_engine_update_result(RenderEngine *engine, RenderResult *result) Render *re = engine->re; if (result) { - result->renlay = result->layers.first; // weak, draws first layer always + result->renlay = result->layers.first; /* weak, draws first layer always */ re->display_draw(re->ddh, result, NULL); } } @@ -210,7 +210,7 @@ void RE_engine_end_result(RenderEngine *engine, RenderResult *result) /* draw */ if (!re->test_break(re->tbh)) { - result->renlay = result->layers.first; // weak, draws first layer always + result->renlay = result->layers.first; /* weak, draws first layer always */ re->display_draw(re->ddh, result, NULL); } diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index dcc09c92bb0..a0ba2a82ead 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -231,13 +231,13 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul if (texres->nor) { if (tex->imaflag & TEX_NORMALMAP) { - // qdn: normal from color - // The invert of the red channel is to make - // the normal map compliant with the outside world. - // It needs to be done because in Blender - // the normal used in the renderer points inward. It is generated - // this way in calc_vertexnormals(). Should this ever change - // this negate must be removed. + /* qdn: normal from color + * The invert of the red channel is to make + * the normal map compliant with the outside world. + * It needs to be done because in Blender + * the normal used in the renderer points inward. It is generated + * this way in calc_vertexnormals(). Should this ever change + * this negate must be removed. */ texres->nor[0] = -2.f*(texres->tr - 0.5f); texres->nor[1] = 2.f*(texres->tg - 0.5f); texres->nor[2] = 2.f*(texres->tb - 0.5f); @@ -619,36 +619,36 @@ static void boxsample(ImBuf *ibuf, float minx, float miny, float maxx, float max } } -//----------------------------------------------------------------------------------------------------------------- -// from here, some functions only used for the new filtering +/*----------------------------------------------------------------------------------------------------------------- + * from here, some functions only used for the new filtering */ -// anisotropic filters, data struct used instead of long line of (possibly unused) func args +/* anisotropic filters, data struct used instead of long line of (possibly unused) func args */ typedef struct afdata_t { float dxt[2], dyt[2]; int intpol, extflag; - // feline only + /* feline only */ float majrad, minrad, theta; int iProbes; float dusc, dvsc; } afdata_t; -// this only used here to make it easier to pass extend flags as single int -enum {TXC_XMIR=1, TXC_YMIR, TXC_REPT, TXC_EXTD}; +/* this only used here to make it easier to pass extend flags as single int */ +enum {TXC_XMIR = 1, TXC_YMIR, TXC_REPT, TXC_EXTD}; -// similar to ibuf_get_color() but clips/wraps coords according to repeat/extend flags -// returns true if out of range in clipmode +/* similar to ibuf_get_color() but clips/wraps coords according to repeat/extend flags + * returns true if out of range in clipmode */ static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extflag) { int clip = 0; switch (extflag) { - case TXC_XMIR: // y rep + case TXC_XMIR: /* y rep */ x %= 2*ibuf->x; x += x < 0 ? 2*ibuf->x : 0; x = x >= ibuf->x ? 2*ibuf->x - x - 1 : x; y %= ibuf->y; y += y < 0 ? ibuf->y : 0; break; - case TXC_YMIR: // x rep + case TXC_YMIR: /* x rep */ x %= ibuf->x; x += x < 0 ? ibuf->x : 0; y %= 2*ibuf->y; @@ -665,11 +665,12 @@ static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extf y %= ibuf->y; y += (y < 0) ? ibuf->y : 0; break; - default: { // as extend, if clipped, set alpha to 0.0 - if (x < 0) { x = 0; } // TXF alpha: clip = 1; } - if (x >= ibuf->x) { x = ibuf->x - 1; } // TXF alpha: clip = 1; } - if (y < 0) { y = 0; } // TXF alpha: clip = 1; } - if (y >= ibuf->y) { y = ibuf->y - 1; } // TXF alpha: clip = 1; } + default: + { /* as extend, if clipped, set alpha to 0.0 */ + if (x < 0) { x = 0; } /* TXF alpha: clip = 1; } */ + if (x >= ibuf->x) { x = ibuf->x - 1; } /* TXF alpha: clip = 1; } */ + if (y < 0) { y = 0; } /* TXF alpha: clip = 1; } */ + if (y >= ibuf->y) { y = ibuf->y - 1; } /* TXF alpha: clip = 1; } */ } } @@ -694,7 +695,7 @@ static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extf return clip; } -// as above + bilerp +/* as above + bilerp */ static int ibuf_get_color_clip_bilerp(float col[4], ImBuf *ibuf, float u, float v, int intpol, int extflag) { if (intpol) { @@ -749,12 +750,12 @@ static void area_sample(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata texr->tr *= xsd; texr->tg *= xsd; texr->tb *= xsd; - // clipping can be ignored if alpha used, texr->ta already includes filtered edge + /* clipping can be ignored if alpha used, texr->ta already includes filtered edge */ texr->ta = texr->talpha ? texr->ta*xsd : (clip ? cw*xsd : 1.f); } -// table of (exp(ar) - exp(a)) / (1 - exp(a)) for r in range [0, 1] and a = -2 -// used instead of actual gaussian, otherwise at high texture magnifications circular artifacts are visible +/* table of (exp(ar) - exp(a)) / (1 - exp(a)) for r in range [0, 1] and a = -2 + * used instead of actual gaussian, otherwise at high texture magnifications circular artifacts are visible */ #define EWA_MAXIDX 255 static float EWA_WTS[EWA_MAXIDX + 1] = { 1.f, 0.990965f, 0.982f, 0.973105f, 0.96428f, 0.955524f, 0.946836f, 0.938216f, 0.929664f, @@ -791,9 +792,9 @@ static float EWA_WTS[EWA_MAXIDX + 1] = 0.00754159f, 0.00625989f, 0.00498819f, 0.00372644f, 0.00247454f, 0.00123242f, 0.f }; -// test if a float value is 'nan' -// there is a C99 function for this: isnan(), but blender seems to use C90 (according to gcc warns), -// and may not be supported by other compilers either +/* test if a float value is 'nan' + * there is a C99 function for this: isnan(), but blender seems to use C90 (according to gcc warns), + * and may not be supported by other compilers either */ #ifndef ISNAN #define ISNAN(x) ((x) != (x)) #endif @@ -802,7 +803,7 @@ static float EWA_WTS[EWA_MAXIDX + 1] = static void radangle2imp(float a2, float b2, float th, float* A, float* B, float* C, float* F) { float ct2 = cosf(th); - const float st2 = 1.f - ct2*ct2; // <- sin(th)^2 + const float st2 = 1.0f - ct2 * ct2; /* <- sin(th)^2 */ ct2 *= ct2; *A = a2*st2 + b2*ct2; *B = (b2 - a2)*sinf(2.f*th); @@ -810,10 +811,10 @@ static void radangle2imp(float a2, float b2, float th, float* A, float* B, float *F = a2*b2; } -// all tests here are done to make sure possible overflows are hopefully minimized +/* all tests here are done to make sure possible overflows are hopefully minimized */ static void imp2radangle(float A, float B, float C, float F, float* a, float* b, float* th, float* ecc) { - if (F <= 1e-5f) { // use arbitrary major radius, zero minor, infinite eccentricity + if (F <= 1e-5f) { /* use arbitrary major radius, zero minor, infinite eccentricity */ *a = sqrtf(A > C ? A : C); *b = 0.f; *ecc = 1e10f; @@ -833,31 +834,31 @@ static void imp2radangle(float A, float B, float C, float F, float* a, float* b, *b = sqrtf(F2 / d); *ecc = *a / *b; } - // incr theta by 0.5*pi (angle of major axis) + /* incr theta by 0.5*pi (angle of major axis) */ *th = 0.5f*(atan2f(B, AmC) + (float)M_PI); } } static void ewa_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata_t* AFD) { - // scaling dxt/dyt by full resolution can cause overflow because of huge A/B/C and esp. F values, - // scaling by aspect ratio alone does the opposite, so try something in between instead... + /* scaling dxt/dyt by full resolution can cause overflow because of huge A/B/C and esp. F values, + * scaling by aspect ratio alone does the opposite, so try something in between instead... */ const float ff2 = ibuf->x, ff = sqrtf(ff2), q = ibuf->y / ff; const float Ux = AFD->dxt[0]*ff, Vx = AFD->dxt[1]*q, Uy = AFD->dyt[0]*ff, Vy = AFD->dyt[1]*q; float A = Vx*Vx + Vy*Vy; float B = -2.f*(Ux*Vx + Uy*Vy); float C = Ux*Ux + Uy*Uy; float F = A*C - B*B*0.25f; - float a, b, th, ecc, a2, b2, ue, ve, U0, V0, DDQ, U, ac1, ac2, BU, d; // TXF alpha: cw = 0.f; - int u, v, u1, u2, v1, v2; // TXF alpha: clip = 0; - - // The so-called 'high' quality ewa method simply adds a constant of 1 to both A & C, - // so the ellipse always covers at least some texels. But since the filter is now always larger, - // it also means that everywhere else it's also more blurry then ideally should be the case. - // So instead here the ellipse radii are modified instead whenever either is too low. - // Use a different radius based on interpolation switch, just enough to anti-alias when interpolation is off, - // and slightly larger to make result a bit smoother than bilinear interpolation when interpolation is on - // (minimum values: const float rmin = intpol ? 1.f : 0.5f;) + float a, b, th, ecc, a2, b2, ue, ve, U0, V0, DDQ, U, ac1, ac2, BU, d; /* TXF alpha: cw = 0.f; */ + int u, v, u1, u2, v1, v2; /* TXF alpha: clip = 0; */ + + /* The so-called 'high' quality ewa method simply adds a constant of 1 to both A & C, + * so the ellipse always covers at least some texels. But since the filter is now always larger, + * it also means that everywhere else it's also more blurry then ideally should be the case. + * So instead here the ellipse radii are modified instead whenever either is too low. + * Use a different radius based on interpolation switch, just enough to anti-alias when interpolation is off, + * and slightly larger to make result a bit smoother than bilinear interpolation when interpolation is on + * (minimum values: const float rmin = intpol ? 1.f : 0.5f;) */ const float rmin = (AFD->intpol ? 1.5625f : 0.765625f)/ff2; imp2radangle(A, B, C, F, &a, &b, &th, &ecc); if ((b2 = b*b) < rmin) { @@ -903,8 +904,8 @@ static void ewa_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata_t* float tc[4]; const float wt = EWA_WTS[(Q < 0.f) ? 0 : (unsigned int)Q]; /*const int out =*/ ibuf_get_color_clip(tc, ibuf, u, v, AFD->extflag); - // TXF alpha: clip |= out; - // TXF alpha: cw += out ? 0.f : wt; + /* TXF alpha: clip |= out; + * TXF alpha: cw += out ? 0.f : wt; */ texr->tr += tc[0]*wt; texr->tg += tc[1]*wt; texr->tb += tc[2]*wt; @@ -916,13 +917,13 @@ static void ewa_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata_t* } } - // d should hopefully never be zero anymore + /* d should hopefully never be zero anymore */ d = 1.f/d; texr->tr *= d; texr->tg *= d; texr->tb *= d; - // clipping can be ignored if alpha used, texr->ta already includes filtered edge - texr->ta = texr->talpha ? texr->ta*d : 1.f; // TXF alpha (clip ? cw*d : 1.f); + /* clipping can be ignored if alpha used, texr->ta already includes filtered edge */ + texr->ta = texr->talpha ? texr->ta*d : 1.f; /* TXF alpha (clip ? cw*d : 1.f); */ } static void feline_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata_t* AFD) @@ -931,11 +932,11 @@ static void feline_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata const float ll = ((AFD->majrad == AFD->minrad) ? 2.f*AFD->majrad : 2.f*(AFD->majrad - AFD->minrad)) / (maxn ? (float)maxn : 1.f); float du = maxn ? cosf(AFD->theta)*ll : 0.f; float dv = maxn ? sinf(AFD->theta)*ll : 0.f; - //const float D = -0.5f*(du*du + dv*dv) / (AFD->majrad*AFD->majrad); + /* const float D = -0.5f*(du*du + dv*dv) / (AFD->majrad*AFD->majrad); */ const float D = (EWA_MAXIDX + 1)*0.25f*(du*du + dv*dv) / (AFD->majrad*AFD->majrad); - float d; // TXF alpha: cw = 0.f; - int n; // TXF alpha: clip = 0; - // have to use same scaling for du/dv here as for Ux/Vx/Uy/Vy (*after* D calc.) + float d; /* TXF alpha: cw = 0.f; */ + int n; /* TXF alpha: clip = 0; */ + /* have to use same scaling for du/dv here as for Ux/Vx/Uy/Vy (*after* D calc.) */ du *= AFD->dusc; dv *= AFD->dvsc; d = texr->tr = texr->tb = texr->tg = texr->ta = 0.f; @@ -943,12 +944,12 @@ static void feline_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata float tc[4]; const float hn = n*0.5f; const float u = fx + hn*du, v = fy + hn*dv; - //const float wt = expf(n*n*D); - // can use ewa table here too + /*const float wt = expf(n*n*D); + * can use ewa table here too */ const float wt = EWA_WTS[(int)(n*n*D)]; /*const int out =*/ ibuf_get_color_clip_bilerp(tc, ibuf, ibuf->x*u, ibuf->y*v, AFD->intpol, AFD->extflag); - // TXF alpha: clip |= out; - // TXF alpha: cw += out ? 0.f : wt; + /* TXF alpha: clip |= out; + * TXF alpha: cw += out ? 0.f : wt; */ texr->tr += tc[0]*wt; texr->tg += tc[1]*wt; texr->tb += tc[2]*wt; @@ -960,7 +961,7 @@ static void feline_eval(TexResult* texr, ImBuf* ibuf, float fx, float fy, afdata texr->tr *= d; texr->tg *= d; texr->tb *= d; - // clipping can be ignored if alpha used, texr->ta already includes filtered edge + /* clipping can be ignored if alpha used, texr->ta already includes filtered edge */ texr->ta = texr->talpha ? texr->ta*d : 1.f; // TXF alpha: (clip ? cw*d : 1.f); } #undef EWA_MAXIDX @@ -970,8 +971,8 @@ static void alpha_clip_aniso(ImBuf *ibuf, float minx, float miny, float maxx, fl float alphaclip; rctf rf; - // TXF apha: we're doing the same alphaclip here as boxsample, but i'm doubting - // if this is actually correct for the all the filtering algorithms .. + /* TXF apha: we're doing the same alphaclip here as boxsample, but i'm doubting + * if this is actually correct for the all the filtering algorithms .. */ if (!(extflag == TXC_REPT || extflag == TXC_EXTD)) { rf.xmin = minx*(ibuf->x); @@ -1040,13 +1041,13 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex texres->tin = texres->ta = texres->tr = texres->tg = texres->tb = 0.f; - // we need to set retval OK, otherwise texture code generates normals itself... + /* we need to set retval OK, otherwise texture code generates normals itself... */ retval = texres->nor ? 3 : 1; - // quick tests + /* quick tests */ if (ibuf==NULL && ima==NULL) return retval; - if (ima) { // hack for icon render + if (ima) { /* hack for icon render */ if ((ima->ibufs.first == NULL) && (R.r.scemode & R_NO_IMAGE_LOAD)) return retval; ibuf = BKE_image_get_ibuf(ima, &tex->iuser); } @@ -1079,18 +1080,18 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex } } - // pixel coordinates + /* pixel coordinates */ minx = MIN3(dxt[0], dyt[0], dxt[0] + dyt[0]); maxx = MAX3(dxt[0], dyt[0], dxt[0] + dyt[0]); miny = MIN3(dxt[1], dyt[1], dxt[1] + dyt[1]); maxy = MAX3(dxt[1], dyt[1], dxt[1] + dyt[1]); - // tex_sharper has been removed + /* tex_sharper has been removed */ minx = (maxx - minx)*0.5f; miny = (maxy - miny)*0.5f; if (tex->imaflag & TEX_FILTER_MIN) { - // make sure the filtersize is minimal in pixels (normal, ref map can have miniature pixel dx/dy) + /* make sure the filtersize is minimal in pixels (normal, ref map can have miniature pixel dx/dy) */ const float addval = (0.5f * tex->filtersize) / (float)MIN2(ibuf->x, ibuf->y); if (addval > minx) minx = addval; if (addval > miny) miny = addval; @@ -1107,9 +1108,9 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex if (tex->imaflag & TEX_IMAROT) { float t; SWAP(float, minx, miny); - // must rotate dxt/dyt 90 deg - // yet another blender problem is that swapping X/Y axes (or any tex proj switches) should do something similar, - // but it doesn't, it only swaps coords, so filter area will be incorrect in those cases. + /* must rotate dxt/dyt 90 deg + * yet another blender problem is that swapping X/Y axes (or any tex proj switches) should do something similar, + * but it doesn't, it only swaps coords, so filter area will be incorrect in those cases. */ t = dxt[0]; dxt[0] = dxt[1]; dxt[1] = -t; @@ -1118,11 +1119,11 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex dyt[1] = -t; } - // side faces of unit-cube + /* side faces of unit-cube */ minx = (minx > 0.25f) ? 0.25f : ((minx < 1e-5f) ? 1e-5f : minx); miny = (miny > 0.25f) ? 0.25f : ((miny < 1e-5f) ? 1e-5f : miny); - // repeat and clip + /* repeat and clip */ if (tex->extend == TEX_REPEAT) { if ((tex->flag & (TEX_REPEAT_XMIR | TEX_REPEAT_YMIR)) == (TEX_REPEAT_XMIR | TEX_REPEAT_YMIR)) @@ -1139,7 +1140,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex if (tex->extend == TEX_CHECKER) { int xs = (int)floorf(fx), ys = (int)floorf(fy); - // both checkers available, no boundary exceptions, checkerdist will eat aliasing + /* both checkers available, no boundary exceptions, checkerdist will eat aliasing */ if ((tex->flag & TEX_CHECKER_ODD) && (tex->flag & TEX_CHECKER_EVEN)) { fx -= xs; fy -= ys; @@ -1166,7 +1167,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex fy -= ys; } } - // scale around center, (0.5, 0.5) + /* scale around center, (0.5, 0.5) */ if (tex->checkerdist < 1.f) { const float omcd = 1.f / (1.f - tex->checkerdist); fx = (fx - 0.5f)*omcd + 0.5f; @@ -1195,34 +1196,34 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex intpol = tex->imaflag & TEX_INTERPOL; - // warning no return! + /* warning no return! */ if ((R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields)) ibuf->rect += ibuf->x*ibuf->y; - // struct common data + /* struct common data */ copy_v2_v2(AFD.dxt, dxt); copy_v2_v2(AFD.dyt, dyt); AFD.intpol = intpol; AFD.extflag = extflag; - // brecht: added stupid clamping here, large dx/dy can give very large - // filter sizes which take ages to render, it may be better to do this - // more intelligently later in the code .. probably it's not noticeable + /* brecht: added stupid clamping here, large dx/dy can give very large + * filter sizes which take ages to render, it may be better to do this + * more intelligently later in the code .. probably it's not noticeable */ if (AFD.dxt[0]*AFD.dxt[0] + AFD.dxt[1]*AFD.dxt[1] > 2.0f*2.0f) mul_v2_fl(AFD.dxt, 2.0f/len_v2(AFD.dxt)); if (AFD.dyt[0]*AFD.dyt[0] + AFD.dyt[1]*AFD.dyt[1] > 2.0f*2.0f) mul_v2_fl(AFD.dyt, 2.0f/len_v2(AFD.dyt)); - // choice: + /* choice: */ if (tex->imaflag & TEX_MIPMAP) { ImBuf *previbuf, *curibuf; float levf; int maxlev; ImBuf* mipmaps[IB_MIPMAP_LEVELS + 1]; - // modify ellipse minor axis if too eccentric, use for area sampling as well - // scaling dxt/dyt as done in pbrt is not the same - // (as in ewa_eval(), scale by sqrt(ibuf->x) to maximize precision) + /* modify ellipse minor axis if too eccentric, use for area sampling as well + * scaling dxt/dyt as done in pbrt is not the same + * (as in ewa_eval(), scale by sqrt(ibuf->x) to maximize precision) */ const float ff = sqrtf(ibuf->x), q = ibuf->y/ff; const float Ux = dxt[0]*ff, Vx = dxt[1]*q, Uy = dyt[0]*ff, Vy = dyt[1]*q; const float A = Vx*Vx + Vy*Vy; @@ -1248,7 +1249,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex AFD.dusc = 1.f/ff; AFD.dvsc = ff / (float)ibuf->y; } - else { // EWA & area + else { /* EWA & area */ if (ecc > (float)tex->afmax) b = a / (float)tex->afmax; b *= ff; } @@ -1264,8 +1265,8 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex curmap++; } - // mipmap level - if (levf < 0.f) { // original image only + /* mipmap level */ + if (levf < 0.f) { /* original image only */ previbuf = curibuf = mipmaps[0]; levf = 0.f; } @@ -1281,39 +1282,39 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex levf -= floorf(levf); } - // filter functions take care of interpolation themselves, no need to modify dxt/dyt here + /* filter functions take care of interpolation themselves, no need to modify dxt/dyt here */ if (texres->nor && ((tex->imaflag & TEX_NORMALMAP) == 0)) { - // color & normal + /* color & normal */ filterfunc(texres, curibuf, fx, fy, &AFD); val1 = texres->tr + texres->tg + texres->tb; filterfunc(&texr, curibuf, fx + dxt[0], fy + dxt[1], &AFD); val2 = texr.tr + texr.tg + texr.tb; filterfunc(&texr, curibuf, fx + dyt[0], fy + dyt[1], &AFD); val3 = texr.tr + texr.tg + texr.tb; - // don't switch x or y! + /* don't switch x or y! */ texres->nor[0] = val1 - val2; texres->nor[1] = val1 - val3; - if (previbuf != curibuf) { // interpolate + if (previbuf != curibuf) { /* interpolate */ filterfunc(&texr, previbuf, fx, fy, &AFD); - // rgb + /* rgb */ texres->tr += levf*(texr.tr - texres->tr); texres->tg += levf*(texr.tg - texres->tg); texres->tb += levf*(texr.tb - texres->tb); texres->ta += levf*(texr.ta - texres->ta); - // normal + /* normal */ val1 += levf*((texr.tr + texr.tg + texr.tb) - val1); filterfunc(&texr, previbuf, fx + dxt[0], fy + dxt[1], &AFD); val2 += levf*((texr.tr + texr.tg + texr.tb) - val2); filterfunc(&texr, previbuf, fx + dyt[0], fy + dyt[1], &AFD); val3 += levf*((texr.tr + texr.tg + texr.tb) - val3); - texres->nor[0] = val1 - val2; // vals have been interpolated above! + texres->nor[0] = val1 - val2; /* vals have been interpolated above! */ texres->nor[1] = val1 - val3; } } - else { // color + else { /* color */ filterfunc(texres, curibuf, fx, fy, &AFD); - if (previbuf != curibuf) { // interpolate + if (previbuf != curibuf) { /* interpolate */ filterfunc(&texr, previbuf, fx, fy, &AFD); texres->tr += levf*(texr.tr - texres->tr); texres->tg += levf*(texr.tg - texres->tg); @@ -1324,8 +1325,8 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex alpha_clip_aniso(ibuf, fx-minx, fy-miny, fx+minx, fy+miny, extflag, texres); } } - else { // no mipmap - // filter functions take care of interpolation themselves, no need to modify dxt/dyt here + else { /* no mipmap */ + /* filter functions take care of interpolation themselves, no need to modify dxt/dyt here */ if (tex->texfilter == TXF_FELINE) { const float ff = sqrtf(ibuf->x), q = ibuf->y/ff; const float Ux = dxt[0]*ff, Vx = dxt[1]*q, Uy = dyt[0]*ff, Vy = dyt[1]*q; @@ -1340,7 +1341,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex a = MAX2(a, 1.f); b = MAX2(b, 1.f); fProbes = 2.f*(a / b) - 1.f; - // no limit to number of Probes here + /* no limit to number of Probes here */ AFD.iProbes = (int)floorf(fProbes + 0.5f); if (AFD.iProbes < fProbes) b = 2.f*a / (float)(AFD.iProbes + 1); AFD.majrad = a/ff; @@ -1350,14 +1351,14 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex AFD.dvsc = ff / (float)ibuf->y; } if (texres->nor && ((tex->imaflag & TEX_NORMALMAP) == 0)) { - // color & normal + /* color & normal */ filterfunc(texres, ibuf, fx, fy, &AFD); val1 = texres->tr + texres->tg + texres->tb; filterfunc(&texr, ibuf, fx + dxt[0], fy + dxt[1], &AFD); val2 = texr.tr + texr.tg + texr.tb; filterfunc(&texr, ibuf, fx + dyt[0], fy + dyt[1], &AFD); val3 = texr.tr + texr.tg + texr.tb; - // don't switch x or y! + /* don't switch x or y! */ texres->nor[0] = val1 - val2; texres->nor[1] = val1 - val3; } @@ -1376,23 +1377,23 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex if ((R.flag & R_SEC_FIELD) && (ibuf->flags & IB_fields)) ibuf->rect -= ibuf->x*ibuf->y; - if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) { // normal from color - // The invert of the red channel is to make - // the normal map compliant with the outside world. - // It needs to be done because in Blender - // the normal used in the renderer points inward. It is generated - // this way in calc_vertexnormals(). Should this ever change - // this negate must be removed. + if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) { /* normal from color */ + /* The invert of the red channel is to make + * the normal map compliant with the outside world. + * It needs to be done because in Blender + * the normal used in the renderer points inward. It is generated + * this way in calc_vertexnormals(). Should this ever change + * this negate must be removed. */ texres->nor[0] = -2.f*(texres->tr - 0.5f); texres->nor[1] = 2.f*(texres->tg - 0.5f); texres->nor[2] = 2.f*(texres->tb - 0.5f); } - - // de-premul, this is being premulled in shade_input_do_shade() - // TXF: this currently does not (yet?) work properly, destroys edge AA in clip/checker mode, so for now commented out - // also disabled in imagewraposa() to be able to compare results with blender's default texture filtering - // brecht: tried to fix this, see "TXF alpha" comments + /* de-premul, this is being premulled in shade_input_do_shade() + * TXF: this currently does not (yet?) work properly, destroys edge AA in clip/checker mode, so for now commented out + * also disabled in imagewraposa() to be able to compare results with blender's default texture filtering */ + + /* brecht: tried to fix this, see "TXF alpha" comments */ if (texres->ta != 1.f && (texres->ta > 1e-4f)) { fx = 1.f/texres->ta; @@ -1414,12 +1415,12 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const float maxd, pixsize, val1, val2, val3; int curmap, retval, imaprepeat, imapextend; - // TXF: since dxt/dyt might be modified here and since they might be needed after imagewraposa() call, - // make a local copy here so that original vecs remain untouched + /* TXF: since dxt/dyt might be modified here and since they might be needed after imagewraposa() call, + * make a local copy here so that original vecs remain untouched */ copy_v3_v3(dxt, DXT); copy_v3_v3(dyt, DYT); - // anisotropic filtering + /* anisotropic filtering */ if (tex->texfilter != TXF_BOX) return imagewraposa_aniso(tex, ima, ibuf, texvec, dxt, dyt, texres); @@ -1530,7 +1531,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const xs= (int)floor(fx); ys= (int)floor(fy); - // both checkers available, no boundary exceptions, checkerdist will eat aliasing + /* both checkers available, no boundary exceptions, checkerdist will eat aliasing */ if ( (tex->flag & TEX_CHECKER_ODD) && (tex->flag & TEX_CHECKER_EVEN) ) { fx-= xs; fy-= ys; @@ -1765,18 +1766,18 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const } if (texres->nor && (tex->imaflag & TEX_NORMALMAP)) { - // qdn: normal from color - // The invert of the red channel is to make - // the normal map compliant with the outside world. - // It needs to be done because in Blender - // the normal used in the renderer points inward. It is generated - // this way in calc_vertexnormals(). Should this ever change - // this negate must be removed. + /* qdn: normal from color + * The invert of the red channel is to make + * the normal map compliant with the outside world. + * It needs to be done because in Blender + * the normal used in the renderer points inward. It is generated + * this way in calc_vertexnormals(). Should this ever change + * this negate must be removed. */ texres->nor[0] = -2.f*(texres->tr - 0.5f); texres->nor[1] = 2.f*(texres->tg - 0.5f); texres->nor[2] = 2.f*(texres->tb - 0.5f); } - + /* de-premul, this is being premulled in shade_input_do_shade() */ if (texres->ta!=1.0f && texres->ta>1e-4f) { fx= 1.0f/texres->ta; diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c index 8c7f9d9c349..e8765b4c3ac 100644 --- a/source/blender/render/intern/source/occlusion.c +++ b/source/blender/render/intern/source/occlusion.c @@ -96,11 +96,11 @@ typedef struct OccNode { typedef struct OcclusionTree { MemArena *arena; - float (*co)[3]; /* temporary during build */ + float (*co)[3]; /* temporary during build */ - OccFace *face; /* instance and face indices */ - float *occlusion; /* occlusion for faces */ - float (*rad)[3]; /* radiance for faces */ + OccFace *face; /* instance and face indices */ + float *occlusion; /* occlusion for faces */ + float (*rad)[3]; /* radiance for faces */ OccNode *root; @@ -137,35 +137,35 @@ typedef struct OcclusionBuildThread { /* ------------------------- Shading --------------------------- */ -extern Render R; // meh +extern Render R; /* meh */ static void occ_shade(ShadeSample *ssamp, ObjectInstanceRen *obi, VlakRen *vlr, float *rad) { - ShadeInput *shi= ssamp->shi; - ShadeResult *shr= ssamp->shr; + ShadeInput *shi = ssamp->shi; + ShadeResult *shr = ssamp->shr; float l, u, v, *v1, *v2, *v3; /* init */ if (vlr->v4) { - shi->u= u= 0.5f; - shi->v= v= 0.5f; + shi->u = u = 0.5f; + shi->v = v = 0.5f; } else { - shi->u= u= 1.0f/3.0f; - shi->v= v= 1.0f/3.0f; + shi->u = u = 1.0f / 3.0f; + shi->v = v = 1.0f / 3.0f; } /* setup render coordinates */ - v1= vlr->v1->co; - v2= vlr->v2->co; - v3= vlr->v3->co; + v1 = vlr->v1->co; + v2 = vlr->v2->co; + v3 = vlr->v3->co; /* renderco */ - l= 1.0f-u-v; + l = 1.0f - u - v; - shi->co[0]= l*v3[0]+u*v1[0]+v*v2[0]; - shi->co[1]= l*v3[1]+u*v1[1]+v*v2[1]; - shi->co[2]= l*v3[2]+u*v1[2]+v*v2[2]; + shi->co[0] = l * v3[0] + u * v1[0] + v * v2[0]; + shi->co[1] = l * v3[1] + u * v1[1] + v * v2[1]; + shi->co[2] = l * v3[2] + u * v1[2] + v * v2[2]; shade_input_set_triangle_i(shi, obi, vlr, 0, 1, 2); @@ -176,8 +176,8 @@ static void occ_shade(ShadeSample *ssamp, ObjectInstanceRen *obi, VlakRen *vlr, /* cache for shadow */ shi->samplenr++; - shi->xs= 0; /* TODO */ - shi->ys= 0; + shi->xs = 0; /* TODO */ + shi->ys = 0; shade_input_set_normals(shi); @@ -195,9 +195,9 @@ static void occ_shade(ShadeSample *ssamp, ObjectInstanceRen *obi, VlakRen *vlr, } /* init material vars */ - // note, keep this synced with render_types.h - memcpy(&shi->r, &shi->mat->r, 23*sizeof(float)); - shi->har= shi->mat->har; + /* note, keep this synced with render_types.h */ + memcpy(&shi->r, &shi->mat->r, 23 * sizeof(float)); + shi->har = shi->mat->har; /* render */ shade_input_set_shade_texco(shi); @@ -213,18 +213,18 @@ static void occ_build_shade(Render *re, OcclusionTree *tree) VlakRen *vlr; int a; - R= *re; + R = *re; /* setup shade sample with correct passes */ memset(&ssamp, 0, sizeof(ShadeSample)); - ssamp.shi[0].lay= re->lay; - ssamp.shi[0].passflag= SCE_PASS_DIFFUSE|SCE_PASS_RGBA; - ssamp.shi[0].combinedflag= ~(SCE_PASS_SPEC); - ssamp.tot= 1; + ssamp.shi[0].lay = re->lay; + ssamp.shi[0].passflag = SCE_PASS_DIFFUSE | SCE_PASS_RGBA; + ssamp.shi[0].combinedflag = ~(SCE_PASS_SPEC); + ssamp.tot = 1; - for (a=0; atotface; a++) { - obi= &R.objectinstance[tree->face[a].obi]; - vlr= RE_findOrAddVlak(obi->obr, tree->face[a].facenr); + for (a = 0; a < tree->totface; a++) { + obi = &R.objectinstance[tree->face[a].obi]; + vlr = RE_findOrAddVlak(obi->obr, tree->face[a].facenr); occ_shade(&ssamp, obi, vlr, tree->rad[a]); } @@ -233,20 +233,20 @@ static void occ_build_shade(Render *re, OcclusionTree *tree) /* ------------------------- Spherical Harmonics --------------------------- */ /* Use 2nd order SH => 9 coefficients, stored in this order: - * 0 = (0,0), - * 1 = (1,-1), 2 = (1,0), 3 = (1,1), - * 4 = (2,-2), 5 = (2,-1), 6 = (2,0), 7 = (2,1), 8 = (2,2) */ +* 0 = (0,0), +* 1 = (1,-1), 2 = (1,0), 3 = (1,1), +* 4 = (2,-2), 5 = (2,-1), 6 = (2,0), 7 = (2,1), 8 = (2,2) */ static void sh_copy(float *shresult, float *sh) { - memcpy(shresult, sh, sizeof(float)*9); + memcpy(shresult, sh, sizeof(float) * 9); } static void sh_mul(float *sh, float f) { int i; - for (i=0; i<9; i++) + for (i = 0; i < 9; i++) sh[i] *= f; } @@ -254,8 +254,8 @@ static void sh_add(float *shresult, float *sh1, float *sh2) { int i; - for (i=0; i<9; i++) - shresult[i]= sh1[i] + sh2[i]; + for (i = 0; i < 9; i++) + shresult[i] = sh1[i] + sh2[i]; } static void sh_from_disc(float *n, float area, float *shresult) @@ -264,21 +264,21 @@ static void sh_from_disc(float *n, float area, float *shresult) * "An Efficient Representation for Irradiance Environment Maps" */ float sh[9], x, y, z; - x= n[0]; - y= n[1]; - z= n[2]; + x = n[0]; + y = n[1]; + z = n[2]; - sh[0]= 0.282095f; + sh[0] = 0.282095f; - sh[1]= 0.488603f*y; - sh[2]= 0.488603f*z; - sh[3]= 0.488603f*x; - - sh[4]= 1.092548f*x*y; - sh[5]= 1.092548f*y*z; - sh[6]= 0.315392f*(3.0f*z*z - 1.0f); - sh[7]= 1.092548f*x*z; - sh[8]= 0.546274f*(x*x - y*y); + sh[1] = 0.488603f * y; + sh[2] = 0.488603f * z; + sh[3] = 0.488603f * x; + + sh[4] = 1.092548f * x * y; + sh[5] = 1.092548f * y * z; + sh[6] = 0.315392f * (3.0f * z * z - 1.0f); + sh[7] = 1.092548f * x * z; + sh[8] = 0.546274f * (x * x - y * y); sh_mul(sh, area); sh_copy(shresult, sh); @@ -292,16 +292,16 @@ static float sh_eval(float *sh, float *v) static const float c4 = 0.886227f, c5 = 0.247708f; float x, y, z, sum; - x= v[0]; - y= v[1]; - z= v[2]; + x = v[0]; + y = v[1]; + z = v[2]; - sum= c1*sh[8]*(x*x - y*y); - sum += c3*sh[6]*z*z; - sum += c4*sh[0]; - sum += -c5*sh[6]; - sum += 2.0f*c1*(sh[4]*x*y + sh[7]*x*z + sh[5]*y*z); - sum += 2.0f*c2*(sh[3]*x + sh[1]*y + sh[2]*z); + sum = c1 * sh[8] * (x * x - y * y); + sum += c3 * sh[6] * z * z; + sum += c4 * sh[0]; + sum += -c5 * sh[6]; + sum += 2.0f * c1 * (sh[4] * x * y + sh[7] * x * z + sh[5] * y * z); + sum += 2.0f * c2 * (sh[3] * x + sh[1] * y + sh[2] * z); return sum; } @@ -314,8 +314,8 @@ static void occ_face(const OccFace *face, float co[3], float normal[3], float *a VlakRen *vlr; float v1[3], v2[3], v3[3], v4[3]; - obi= &R.objectinstance[face->obi]; - vlr= RE_findOrAddVlak(obi->obr, face->facenr); + obi = &R.objectinstance[face->obi]; + vlr = RE_findOrAddVlak(obi->obr, face->facenr); if (co) { if (vlr->v4) @@ -328,9 +328,9 @@ static void occ_face(const OccFace *face, float co[3], float normal[3], float *a } if (normal) { - normal[0]= -vlr->n[0]; - normal[1]= -vlr->n[1]; - normal[2]= -vlr->n[2]; + normal[0] = -vlr->n[0]; + normal[1] = -vlr->n[1]; + normal[2] = -vlr->n[2]; if (obi->flag & R_TRANSFORMED) mul_m3_v3(obi->nmat, normal); @@ -351,9 +351,9 @@ static void occ_face(const OccFace *face, float co[3], float normal[3], float *a /* todo: correct area for instances */ if (vlr->v4) - *area= area_quad_v3(v1, v2, v3, v4); + *area = area_quad_v3(v1, v2, v3, v4); else - *area= area_tri_v3(v1, v2, v3); + *area = area_tri_v3(v1, v2, v3); } } @@ -361,25 +361,25 @@ static void occ_sum_occlusion(OcclusionTree *tree, OccNode *node) { OccNode *child; float occ, area, totarea, rad[3]; - int a, b, indirect= tree->doindirect; + int a, b, indirect = tree->doindirect; - occ= 0.0f; - totarea= 0.0f; + occ = 0.0f; + totarea = 0.0f; if (indirect) zero_v3(rad); - for (b=0; bchildflag & (1<child[b].face; + for (b = 0; b < TOTCHILD; b++) { + if (node->childflag & (1 << b)) { + a = node->child[b].face; occ_face(&tree->face[a], 0, 0, &area); - occ += area*tree->occlusion[a]; + occ += area * tree->occlusion[a]; if (indirect) madd_v3_v3fl(rad, tree->rad[a], area); totarea += area; } else if (node->child[b].node) { - child= node->child[b].node; + child = node->child[b].node; occ_sum_occlusion(tree, child); - occ += child->area*child->occlusion; + occ += child->area * child->occlusion; if (indirect) madd_v3_v3fl(rad, child->rad, child->area); totarea += child->area; } @@ -387,16 +387,16 @@ static void occ_sum_occlusion(OcclusionTree *tree, OccNode *node) if (totarea != 0.0f) { occ /= totarea; - if (indirect) mul_v3_fl(rad, 1.0f/totarea); + if (indirect) mul_v3_fl(rad, 1.0f / totarea); } - node->occlusion= occ; + node->occlusion = occ; if (indirect) copy_v3_v3(node->rad, rad); } static int occ_find_bbox_axis(OcclusionTree *tree, int begin, int end, float *min, float *max) { - float len, maxlen= -1.0f; + float len, maxlen = -1.0f; int a, axis = 0; INIT_MINMAX(min, max); @@ -405,12 +405,12 @@ static int occ_find_bbox_axis(OcclusionTree *tree, int begin, int end, float *mi minmax_v3v3_v3(min, max, tree->co[a]); } - for (a=0; a<3; a++) { - len= max[a] - min[a]; + for (a = 0; a < 3; a++) { + len = max[a] - min[a]; if (len > maxlen) { - maxlen= len; - axis= a; + maxlen = len; + axis = a; } } @@ -422,21 +422,21 @@ static void occ_node_from_face(OccFace *face, OccNode *node) float n[3]; occ_face(face, node->co, n, &node->area); - node->dco= 0.0f; + node->dco = 0.0f; sh_from_disc(n, node->area, node->sh); } static void occ_build_dco(OcclusionTree *tree, OccNode *node, const float co[3], float *dco) { int b; - for (b=0; bchildflag & (1<face+node->child[b].face, nco, NULL, NULL); + if (node->childflag & (1 << b)) { + occ_face(tree->face + node->child[b].face, nco, NULL, NULL); } else if (node->child[b].node) { - OccNode *child= node->child[b].node; + OccNode *child = node->child[b].node; occ_build_dco(tree, child, co, dco); copy_v3_v3(nco, child->co); } @@ -445,9 +445,9 @@ static void occ_build_dco(OcclusionTree *tree, OccNode *node, const float co[3], } sub_v3_v3v3(d, nco, co); - dist= dot_v3v3(d, d); + dist = dot_v3v3(d, d); if (dist > *dco) - *dco= dist; + *dco = dist; } } @@ -459,12 +459,12 @@ static void occ_build_split(OcclusionTree *tree, int begin, int end, int *split) /* split in middle of boundbox. this seems faster than median split * on complex scenes, possibly since it avoids two distant faces to * be in the same node better? */ - axis= occ_find_bbox_axis(tree, begin, end, min, max); - mid= 0.5f*(min[axis]+max[axis]); + axis = occ_find_bbox_axis(tree, begin, end, min, max); + mid = 0.5f * (min[axis] + max[axis]); - a= begin; - enda= end; - while (aco[a][axis] > mid) { enda--; SWAP(OccFace, tree->face[a], tree->face[enda]); @@ -476,7 +476,7 @@ static void occ_build_split(OcclusionTree *tree, int begin, int end, int *split) a++; } - *split= enda; + *split = enda; } static void occ_build_8_split(OcclusionTree *tree, int begin, int end, int *offset, int *count) @@ -488,7 +488,7 @@ static void occ_build_8_split(OcclusionTree *tree, int begin, int end, int *offs /* force split if none found, to deal with degenerate geometry */ if (splitx == begin || splitx == end) - splitx= (begin+end)/2; + splitx = (begin + end) / 2; occ_build_split(tree, begin, splitx, &splity[0]); occ_build_split(tree, splitx, end, &splity[1]); @@ -498,25 +498,25 @@ static void occ_build_8_split(OcclusionTree *tree, int begin, int end, int *offs occ_build_split(tree, splitx, splity[1], &splitz[2]); occ_build_split(tree, splity[1], end, &splitz[3]); - offset[0]= begin; - offset[1]= splitz[0]; - offset[2]= splity[0]; - offset[3]= splitz[1]; - offset[4]= splitx; - offset[5]= splitz[2]; - offset[6]= splity[1]; - offset[7]= splitz[3]; - - for (b=0; b<7; b++) - count[b]= offset[b+1] - offset[b]; - count[7]= end - offset[7]; + offset[0] = begin; + offset[1] = splitz[0]; + offset[2] = splity[0]; + offset[3] = splitz[1]; + offset[4] = splitx; + offset[5] = splitz[2]; + offset[6] = splity[1]; + offset[7] = splitz[3]; + + for (b = 0; b < 7; b++) + count[b] = offset[b + 1] - offset[b]; + count[7] = end - offset[7]; } static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, int end, int depth); static void *exec_occ_build(void *data) { - OcclusionBuildThread *othread= (OcclusionBuildThread*)data; + OcclusionBuildThread *othread = (OcclusionBuildThread *)data; occ_build_recursive(othread->tree, othread->node, othread->begin, othread->end, othread->depth); @@ -529,17 +529,17 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i OcclusionBuildThread othreads[BLENDER_MAX_THREADS]; OccNode *child, tmpnode; /* OccFace *face; */ - int a, b, totthread=0, offset[TOTCHILD], count[TOTCHILD]; + int a, b, totthread = 0, offset[TOTCHILD], count[TOTCHILD]; /* add a new node */ - node->occlusion= 1.0f; + node->occlusion = 1.0f; /* leaf node with only children */ if (end - begin <= TOTCHILD) { - for (a=begin, b=0; aface[a]; */ - node->child[b].face= a; - node->childflag |= (1<child[b].face = a; + node->childflag |= (1 << b); } } else { @@ -549,40 +549,40 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i if (depth == 1 && tree->dothreadedbuild) BLI_init_threads(&threads, exec_occ_build, tree->totbuildthread); - for (b=0; bchild[b].node= NULL; + node->child[b].node = NULL; } else if (count[b] == 1) { /* face= &tree->face[offset[b]]; */ - node->child[b].face= offset[b]; - node->childflag |= (1<child[b].face = offset[b]; + node->childflag |= (1 << b); } else { if (tree->dothreadedbuild) BLI_lock_thread(LOCK_CUSTOM1); - child= BLI_memarena_alloc(tree->arena, sizeof(OccNode)); - node->child[b].node= child; + child = BLI_memarena_alloc(tree->arena, sizeof(OccNode)); + node->child[b].node = child; /* keep track of maximum depth for stack */ - if (depth+1 > tree->maxdepth) - tree->maxdepth= depth+1; + if (depth + 1 > tree->maxdepth) + tree->maxdepth = depth + 1; if (tree->dothreadedbuild) BLI_unlock_thread(LOCK_CUSTOM1); if (depth == 1 && tree->dothreadedbuild) { - othreads[totthread].tree= tree; - othreads[totthread].node= child; - othreads[totthread].begin= offset[b]; - othreads[totthread].end= offset[b]+count[b]; - othreads[totthread].depth= depth+1; + othreads[totthread].tree = tree; + othreads[totthread].node = child; + othreads[totthread].begin = offset[b]; + othreads[totthread].end = offset[b] + count[b]; + othreads[totthread].depth = depth + 1; BLI_insert_thread(&threads, &othreads[totthread]); totthread++; } else - occ_build_recursive(tree, child, offset[b], offset[b]+count[b], depth+1); + occ_build_recursive(tree, child, offset[b], offset[b] + count[b], depth + 1); } } @@ -591,13 +591,13 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i } /* combine area, position and sh */ - for (b=0; bchildflag & (1<face+node->child[b].face, &tmpnode); + for (b = 0; b < TOTCHILD; b++) { + if (node->childflag & (1 << b)) { + child = &tmpnode; + occ_node_from_face(tree->face + node->child[b].face, &tmpnode); } else { - child= node->child[b].node; + child = node->child[b].node; } if (child) { @@ -608,10 +608,10 @@ static void occ_build_recursive(OcclusionTree *tree, OccNode *node, int begin, i } if (node->area != 0.0f) - mul_v3_fl(node->co, 1.0f/node->area); + mul_v3_fl(node->co, 1.0f / node->area); /* compute maximum distance from center */ - node->dco= 0.0f; + node->dco = 0.0f; if (node->area > 0.0f) occ_build_dco(tree, node, node->co, &node->dco); } @@ -623,10 +623,10 @@ static void occ_build_sh_normalize(OccNode *node) int b; if (node->area != 0.0f) - sh_mul(node->sh, 1.0f/node->area); + sh_mul(node->sh, 1.0f / node->area); - for (b=0; bchildflag & (1<childflag & (1 << b)) ; else if (node->child[b].node) occ_build_sh_normalize(node->child[b].node); } @@ -638,18 +638,18 @@ static OcclusionTree *occ_tree_build(Render *re) ObjectInstanceRen *obi; ObjectRen *obr; Material *ma; - VlakRen *vlr= NULL; + VlakRen *vlr = NULL; int a, b, c, totface; /* count */ - totface= 0; - for (obi=re->instancetable.first; obi; obi=obi->next) { - obr= obi->obr; - for (a=0; atotvlak; a++) { - if ((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; + totface = 0; + for (obi = re->instancetable.first; obi; obi = obi->next) { + obr = obi->obr; + for (a = 0; a < obr->totvlak; a++) { + if ((a & 255) == 0) vlr = obr->vlaknodes[a >> 8].vlak; else vlr++; - ma= vlr->mat; + ma = vlr->mat; if ((ma->shade_flag & MA_APPROX_OCCLUSION) && (ma->material_type == MA_TYPE_SURFACE)) totface++; @@ -659,41 +659,41 @@ static OcclusionTree *occ_tree_build(Render *re) if (totface == 0) return NULL; - tree= MEM_callocN(sizeof(OcclusionTree), "OcclusionTree"); - tree->totface= totface; + tree = MEM_callocN(sizeof(OcclusionTree), "OcclusionTree"); + tree->totface = totface; /* parameters */ - tree->error= get_render_aosss_error(&re->r, re->wrld.ao_approx_error); - tree->distfac= (re->wrld.aomode & WO_AODIST)? re->wrld.aodistfac: 0.0f; - tree->doindirect= (re->wrld.ao_indirect_energy > 0.0f && re->wrld.ao_indirect_bounces > 0); + tree->error = get_render_aosss_error(&re->r, re->wrld.ao_approx_error); + tree->distfac = (re->wrld.aomode & WO_AODIST) ? re->wrld.aodistfac : 0.0f; + tree->doindirect = (re->wrld.ao_indirect_energy > 0.0f && re->wrld.ao_indirect_bounces > 0); /* allocation */ - tree->arena= BLI_memarena_new(0x8000 * sizeof(OccNode), "occ tree arena"); + tree->arena = BLI_memarena_new(0x8000 * sizeof(OccNode), "occ tree arena"); BLI_memarena_use_calloc(tree->arena); if (re->wrld.aomode & WO_AOCACHE) - tree->cache= MEM_callocN(sizeof(OcclusionCache)*BLENDER_MAX_THREADS, "OcclusionCache"); + tree->cache = MEM_callocN(sizeof(OcclusionCache) * BLENDER_MAX_THREADS, "OcclusionCache"); - tree->face= MEM_callocN(sizeof(OccFace)*totface, "OcclusionFace"); - tree->co= MEM_callocN(sizeof(float)*3*totface, "OcclusionCo"); - tree->occlusion= MEM_callocN(sizeof(float)*totface, "OcclusionOcclusion"); + tree->face = MEM_callocN(sizeof(OccFace) * totface, "OcclusionFace"); + tree->co = MEM_callocN(sizeof(float) * 3 * totface, "OcclusionCo"); + tree->occlusion = MEM_callocN(sizeof(float) * totface, "OcclusionOcclusion"); if (tree->doindirect) - tree->rad= MEM_callocN(sizeof(float)*3*totface, "OcclusionRad"); + tree->rad = MEM_callocN(sizeof(float) * 3 * totface, "OcclusionRad"); /* make array of face pointers */ - for (b=0, c=0, obi=re->instancetable.first; obi; obi=obi->next, c++) { - obr= obi->obr; - for (a=0; atotvlak; a++) { - if ((a & 255)==0) vlr= obr->vlaknodes[a>>8].vlak; + for (b = 0, c = 0, obi = re->instancetable.first; obi; obi = obi->next, c++) { + obr = obi->obr; + for (a = 0; a < obr->totvlak; a++) { + if ((a & 255) == 0) vlr = obr->vlaknodes[a >> 8].vlak; else vlr++; - ma= vlr->mat; + ma = vlr->mat; if ((ma->shade_flag & MA_APPROX_OCCLUSION) && (ma->material_type == MA_TYPE_SURFACE)) { - tree->face[b].obi= c; - tree->face[b].facenr= a; - tree->occlusion[b]= 1.0f; + tree->face[b].obi = c; + tree->face[b].facenr = a; + tree->occlusion[b] = 1.0f; occ_face(&tree->face[b], tree->co[b], NULL, NULL); b++; } @@ -701,12 +701,12 @@ static OcclusionTree *occ_tree_build(Render *re) } /* threads */ - tree->totbuildthread= (re->r.threads > 1 && totface > 10000)? 8: 1; - tree->dothreadedbuild= (tree->totbuildthread > 1); + tree->totbuildthread = (re->r.threads > 1 && totface > 10000) ? 8 : 1; + tree->dothreadedbuild = (tree->totbuildthread > 1); /* recurse */ - tree->root= BLI_memarena_alloc(tree->arena, sizeof(OccNode)); - tree->maxdepth= 1; + tree->root = BLI_memarena_alloc(tree->arena, sizeof(OccNode)); + tree->maxdepth = 1; occ_build_recursive(tree, tree->root, 0, totface, 1); if (tree->doindirect) { @@ -715,12 +715,12 @@ static OcclusionTree *occ_tree_build(Render *re) } MEM_freeN(tree->co); - tree->co= NULL; + tree->co = NULL; occ_build_sh_normalize(tree->root); - for (a=0; astack[a]= MEM_callocN(sizeof(OccNode)*TOTCHILD*(tree->maxdepth+1), "OccStack"); + for (a = 0; a < BLENDER_MAX_THREADS; a++) + tree->stack[a] = MEM_callocN(sizeof(OccNode) * TOTCHILD * (tree->maxdepth + 1), "OccStack"); return tree; } @@ -731,7 +731,7 @@ static void occ_free_tree(OcclusionTree *tree) if (tree) { if (tree->arena) BLI_memarena_free(tree->arena); - for (a=0; astack[a]) MEM_freeN(tree->stack[a]); if (tree->occlusion) MEM_freeN(tree->occlusion); @@ -749,36 +749,38 @@ static float occ_solid_angle(OccNode *node, const float v[3], float d2, float in float dotreceive, dotemit; float ev[3]; - ev[0]= -v[0]*invd2; - ev[1]= -v[1]*invd2; - ev[2]= -v[2]*invd2; - dotemit= sh_eval(node->sh, ev); - dotreceive= dot_v3v3(receivenormal, v)*invd2; + ev[0] = -v[0] * invd2; + ev[1] = -v[1] * invd2; + ev[2] = -v[2] * invd2; + dotemit = sh_eval(node->sh, ev); + dotreceive = dot_v3v3(receivenormal, v) * invd2; CLAMP(dotemit, 0.0f, 1.0f); CLAMP(dotreceive, 0.0f, 1.0f); - return ((node->area*dotemit*dotreceive)/(d2 + node->area*INVPI))*INVPI; + return ((node->area * dotemit * dotreceive) / (d2 + node->area * INVPI)) * INVPI; } -static void VecAddDir(float result[3], const float v1[3], const float v2[3], const float fac) +static void vec_add_dir(float r[3], const float v1[3], const float v2[3], const float fac) { - result[0]= v1[0] + fac*(v2[0] - v1[0]); - result[1]= v1[1] + fac*(v2[1] - v1[1]); - result[2]= v1[2] + fac*(v2[2] - v1[2]); + r[0] = v1[0] + fac * (v2[0] - v1[0]); + r[1] = v1[1] + fac * (v2[1] - v1[1]); + r[2] = v1[2] + fac * (v2[2] - v1[2]); } -static int occ_visible_quad(float *p, const float n[3], const float v0[3], const float *v1, const float *v2, float q0[3], float q1[3], float q2[3], float q3[3]) +static int occ_visible_quad(const float p[3], const float n[3], + const float v0[3], const float v1[3], const float v2[3], + float q0[3], float q1[3], float q2[3], float q3[3]) { static const float epsilon = 1e-6f; float c, sd[3]; - c= dot_v3v3(n, p); + c = dot_v3v3(n, p); /* signed distances from the vertices to the plane. */ - sd[0]= dot_v3v3(n, v0) - c; - sd[1]= dot_v3v3(n, v1) - c; - sd[2]= dot_v3v3(n, v2) - c; + sd[0] = dot_v3v3(n, v0) - c; + sd[1] = dot_v3v3(n, v1) - c; + sd[2] = dot_v3v3(n, v2) - c; if (fabsf(sd[0]) < epsilon) sd[0] = 0.0f; if (fabsf(sd[1]) < epsilon) sd[1] = 0.0f; @@ -787,21 +789,21 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const if (sd[0] > 0) { if (sd[1] > 0) { if (sd[2] > 0) { - // +++ + /* +++ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // ++- + /* ++- */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); - VecAddDir(q2, v1, v2, (sd[1]/(sd[1]-sd[2]))); - VecAddDir(q3, v0, v2, (sd[0]/(sd[0]-sd[2]))); + vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); + vec_add_dir(q3, v0, v2, (sd[0] / (sd[0] - sd[2]))); } else { - // ++0 + /* ++0 */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -810,44 +812,44 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const } else if (sd[1] < 0) { if (sd[2] > 0) { - // +-+ + /* +-+ */ copy_v3_v3(q0, v0); - VecAddDir(q1, v0, v1, (sd[0]/(sd[0]-sd[1]))); - VecAddDir(q2, v1, v2, (sd[1]/(sd[1]-sd[2]))); + vec_add_dir(q1, v0, v1, (sd[0] / (sd[0] - sd[1]))); + vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q3, v2); } else if (sd[2] < 0) { - // +-- + /* +-- */ copy_v3_v3(q0, v0); - VecAddDir(q1, v0, v1, (sd[0]/(sd[0]-sd[1]))); - VecAddDir(q2, v0, v2, (sd[0]/(sd[0]-sd[2]))); + vec_add_dir(q1, v0, v1, (sd[0] / (sd[0] - sd[1]))); + vec_add_dir(q2, v0, v2, (sd[0] / (sd[0] - sd[2]))); copy_v3_v3(q3, q2); } else { - // +-0 + /* +-0 */ copy_v3_v3(q0, v0); - VecAddDir(q1, v0, v1, (sd[0]/(sd[0]-sd[1]))); + vec_add_dir(q1, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } } else { if (sd[2] > 0) { - // +0+ + /* +0+ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // +0- + /* +0- */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); - VecAddDir(q2, v0, v2, (sd[0]/(sd[0]-sd[2]))); + vec_add_dir(q2, v0, v2, (sd[0] / (sd[0] - sd[2]))); copy_v3_v3(q3, q2); } else { - // +00 + /* +00 */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -858,22 +860,22 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const else if (sd[0] < 0) { if (sd[1] > 0) { if (sd[2] > 0) { - // -++ - VecAddDir(q0, v0, v1, (sd[0]/(sd[0]-sd[1]))); + /* -++ */ + vec_add_dir(q0, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); - VecAddDir(q3, v0, v2, (sd[0]/(sd[0]-sd[2]))); + vec_add_dir(q3, v0, v2, (sd[0] / (sd[0] - sd[2]))); } else if (sd[2] < 0) { - // -+- - VecAddDir(q0, v0, v1, (sd[0]/(sd[0]-sd[1]))); + /* -+- */ + vec_add_dir(q0, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q1, v1); - VecAddDir(q2, v1, v2, (sd[1]/(sd[1]-sd[2]))); + vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q3, q2); } else { - // -+0 - VecAddDir(q0, v0, v1, (sd[0]/(sd[0]-sd[1]))); + /* -+0 */ + vec_add_dir(q0, v0, v1, (sd[0] / (sd[0] - sd[1]))); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); @@ -881,35 +883,35 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const } else if (sd[1] < 0) { if (sd[2] > 0) { - // --+ - VecAddDir(q0, v0, v2, (sd[0]/(sd[0]-sd[2]))); - VecAddDir(q1, v1, v2, (sd[1]/(sd[1]-sd[2]))); + /* --+ */ + vec_add_dir(q0, v0, v2, (sd[0] / (sd[0] - sd[2]))); + vec_add_dir(q1, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // --- + /* --- */ return 0; } else { - // --0 + /* --0 */ return 0; } } else { if (sd[2] > 0) { - // -0+ - VecAddDir(q0, v0, v2, (sd[0]/(sd[0]-sd[2]))); + /* -0+ */ + vec_add_dir(q0, v0, v2, (sd[0] / (sd[0] - sd[2]))); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // -0- + /* -0- */ return 0; } else { - // -00 + /* -00 */ return 0; } } @@ -917,21 +919,21 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const else { if (sd[1] > 0) { if (sd[2] > 0) { - // 0++ + /* 0++ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // 0+- + /* 0+- */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); - VecAddDir(q2, v1, v2, (sd[1]/(sd[1]-sd[2]))); + vec_add_dir(q2, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q3, q2); } else { - // 0+0 + /* 0+0 */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); @@ -940,35 +942,35 @@ static int occ_visible_quad(float *p, const float n[3], const float v0[3], const } else if (sd[1] < 0) { if (sd[2] > 0) { - // 0-+ + /* 0-+ */ copy_v3_v3(q0, v0); - VecAddDir(q1, v1, v2, (sd[1]/(sd[1]-sd[2]))); + vec_add_dir(q1, v1, v2, (sd[1] / (sd[1] - sd[2]))); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // 0-- + /* 0-- */ return 0; } else { - // 0-0 + /* 0-0 */ return 0; } } else { if (sd[2] > 0) { - // 00+ + /* 00+ */ copy_v3_v3(q0, v0); copy_v3_v3(q1, v1); copy_v3_v3(q2, v2); copy_v3_v3(q3, q2); } else if (sd[2] < 0) { - // 00- + /* 00- */ return 0; } else { - // 000 + /* 000 */ return 0; } } @@ -995,49 +997,49 @@ static vFloat vec_splat_float(float val) static float occ_quad_form_factor(float *p, float *n, float *q0, float *q1, float *q2, float *q3) { vFloat vcos, rlen, vrx, vry, vrz, vsrx, vsry, vsrz, gx, gy, gz, vangle; - vUInt8 rotate = (vUInt8) {4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3}; + vUInt8 rotate = (vUInt8) {4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3}; vFloatResult vresult; float result; /* compute r* */ - vrx = (vFloat) {q0[0], q1[0], q2[0], q3[0]} - vec_splat_float(p[0]); - vry = (vFloat) {q0[1], q1[1], q2[1], q3[1]} - vec_splat_float(p[1]); - vrz = (vFloat) {q0[2], q1[2], q2[2], q3[2]} - vec_splat_float(p[2]); + vrx = (vFloat) {q0[0], q1[0], q2[0], q3[0]} -vec_splat_float(p[0]); + vry = (vFloat) {q0[1], q1[1], q2[1], q3[1]} -vec_splat_float(p[1]); + vrz = (vFloat) {q0[2], q1[2], q2[2], q3[2]} -vec_splat_float(p[2]); /* normalize r* */ - rlen = vec_rsqrte(vrx*vrx + vry*vry + vrz*vrz + vec_splat_float(1e-16f)); - vrx = vrx*rlen; - vry = vry*rlen; - vrz = vrz*rlen; + rlen = vec_rsqrte(vrx * vrx + vry * vry + vrz * vrz + vec_splat_float(1e-16f)); + vrx = vrx * rlen; + vry = vry * rlen; + vrz = vrz * rlen; /* rotate r* for cross and dot */ - vsrx= vec_perm(vrx, vrx, rotate); - vsry= vec_perm(vry, vry, rotate); - vsrz= vec_perm(vrz, vrz, rotate); + vsrx = vec_perm(vrx, vrx, rotate); + vsry = vec_perm(vry, vry, rotate); + vsrz = vec_perm(vrz, vrz, rotate); /* cross product */ - gx = vsry*vrz - vsrz*vry; - gy = vsrz*vrx - vsrx*vrz; - gz = vsrx*vry - vsry*vrx; + gx = vsry * vrz - vsrz * vry; + gy = vsrz * vrx - vsrx * vrz; + gz = vsrx * vry - vsry * vrx; /* normalize */ - rlen = vec_rsqrte(gx*gx + gy*gy + gz*gz + vec_splat_float(1e-16f)); - gx = gx*rlen; - gy = gy*rlen; - gz = gz*rlen; + rlen = vec_rsqrte(gx * gx + gy * gy + gz * gz + vec_splat_float(1e-16f)); + gx = gx * rlen; + gy = gy * rlen; + gz = gz * rlen; /* angle */ - vcos = vrx*vsrx + vry*vsry + vrz*vsrz; - vcos= vec_max(vec_min(vcos, vec_splat_float(1.0f)), vec_splat_float(-1.0f)); - vangle= vacosf(vcos); + vcos = vrx * vsrx + vry * vsry + vrz * vsrz; + vcos = vec_max(vec_min(vcos, vec_splat_float(1.0f)), vec_splat_float(-1.0f)); + vangle = vacosf(vcos); /* dot */ - vresult.v = (vec_splat_float(n[0])*gx + - vec_splat_float(n[1])*gy + - vec_splat_float(n[2])*gz)*vangle; + vresult.v = (vec_splat_float(n[0]) * gx + + vec_splat_float(n[1]) * gy + + vec_splat_float(n[2]) * gz) * vangle; - result= (vresult.f[0] + vresult.f[1] + vresult.f[2] + vresult.f[3])*(0.5f/(float)M_PI); - result= MAX2(result, 0.0f); + result = (vresult.f[0] + vresult.f[1] + vresult.f[2] + vresult.f[3]) * (0.5f / (float)M_PI); + result = MAX2(result, 0.0f); return result; } @@ -1053,8 +1055,8 @@ static float occ_quad_form_factor(float *p, float *n, float *q0, float *q1, floa static __m128 sse_approx_acos(__m128 x) { /* needs a better approximation than taylor expansion of acos, since that - * gives big erros for near 1.0 values, sqrt(2*x)*acos(1-x) should work - * better, see http://www.tom.womack.net/projects/sse-fast-arctrig.html */ + * gives big erros for near 1.0 values, sqrt(2*x)*acos(1-x) should work + * better, see http://www.tom.womack.net/projects/sse-fast-arctrig.html */ return _mm_set_ps1(1.0f); } @@ -1076,36 +1078,36 @@ static float occ_quad_form_factor(float *p, float *n, float *q0, float *q1, floa rz = qz - _mm_set_ps1(p[2]); /* normalize r */ - rlen = _mm_rsqrt_ps(rx*rx + ry*ry + rz*rz + _mm_set_ps1(1e-16f)); - rx = rx*rlen; - ry = ry*rlen; - rz = rz*rlen; + rlen = _mm_rsqrt_ps(rx * rx + ry * ry + rz * rz + _mm_set_ps1(1e-16f)); + rx = rx * rlen; + ry = ry * rlen; + rz = rz * rlen; /* cross product */ - srx = _mm_shuffle_ps(rx, rx, _MM_SHUFFLE(0,3,2,1)); - sry = _mm_shuffle_ps(ry, ry, _MM_SHUFFLE(0,3,2,1)); - srz = _mm_shuffle_ps(rz, rz, _MM_SHUFFLE(0,3,2,1)); + srx = _mm_shuffle_ps(rx, rx, _MM_SHUFFLE(0, 3, 2, 1)); + sry = _mm_shuffle_ps(ry, ry, _MM_SHUFFLE(0, 3, 2, 1)); + srz = _mm_shuffle_ps(rz, rz, _MM_SHUFFLE(0, 3, 2, 1)); - gx = sry*rz - srz*ry; - gy = srz*rx - srx*rz; - gz = srx*ry - sry*rx; + gx = sry * rz - srz * ry; + gy = srz * rx - srx * rz; + gz = srx * ry - sry * rx; /* normalize g */ - glen = _mm_rsqrt_ps(gx*gx + gy*gy + gz*gz + _mm_set_ps1(1e-16f)); - gx = gx*glen; - gy = gy*glen; - gz = gz*glen; + glen = _mm_rsqrt_ps(gx * gx + gy * gy + gz * gz + _mm_set_ps1(1e-16f)); + gx = gx * glen; + gy = gy * glen; + gz = gz * glen; /* compute angle */ - rcos = rx*srx + ry*sry + rz*srz; - rcos= _mm_max_ps(_mm_min_ps(rcos, _mm_set_ps1(1.0f)), _mm_set_ps1(-1.0f)); + rcos = rx * srx + ry * sry + rz * srz; + rcos = _mm_max_ps(_mm_min_ps(rcos, _mm_set_ps1(1.0f)), _mm_set_ps1(-1.0f)); angle = sse_approx_cos(rcos); - aresult = (_mm_set_ps1(n[0])*gx + _mm_set_ps1(n[1])*gy + _mm_set_ps1(n[2])*gz)*angle; + aresult = (_mm_set_ps1(n[0]) * gx + _mm_set_ps1(n[1]) * gy + _mm_set_ps1(n[2]) * gz) * angle; /* sum together */ - result= (fresult[0] + fresult[1] + fresult[2] + fresult[3])*(0.5f/(float)M_PI); - result= MAX2(result, 0.0f); + result = (fresult[0] + fresult[1] + fresult[2] + fresult[3]) * (0.5f / (float)M_PI); + result = MAX2(result, 0.0f); return result; } @@ -1116,10 +1118,10 @@ static void normalizef(float *n) { float d; - d= dot_v3v3(n, n); + d = dot_v3v3(n, n); if (d > 1.0e-35F) { - d= 1.0f/sqrtf(d); + d = 1.0f / sqrtf(d); n[0] *= d; n[1] *= d; @@ -1147,18 +1149,18 @@ static float occ_quad_form_factor(const float p[3], const float n[3], const floa cross_v3_v3v3(g2, r3, r2); normalizef(g2); cross_v3_v3v3(g3, r0, r3); normalizef(g3); - a1= saacosf(dot_v3v3(r0, r1)); - a2= saacosf(dot_v3v3(r1, r2)); - a3= saacosf(dot_v3v3(r2, r3)); - a4= saacosf(dot_v3v3(r3, r0)); + a1 = saacosf(dot_v3v3(r0, r1)); + a2 = saacosf(dot_v3v3(r1, r2)); + a3 = saacosf(dot_v3v3(r2, r3)); + a4 = saacosf(dot_v3v3(r3, r0)); - dot1= dot_v3v3(n, g0); - dot2= dot_v3v3(n, g1); - dot3= dot_v3v3(n, g2); - dot4= dot_v3v3(n, g3); + dot1 = dot_v3v3(n, g0); + dot2 = dot_v3v3(n, g1); + dot3 = dot_v3v3(n, g2); + dot4 = dot_v3v3(n, g3); - result= (a1*dot1 + a2*dot2 + a3*dot3 + a4*dot4)*0.5f/(float)M_PI; - result= MAX2(result, 0.0f); + result = (a1 * dot1 + a2 * dot2 + a3 * dot3 + a4 * dot4) * 0.5f / (float)M_PI; + result = MAX2(result, 0.0f); return result; } @@ -1167,10 +1169,10 @@ static float occ_form_factor(OccFace *face, float *p, float *n) { ObjectInstanceRen *obi; VlakRen *vlr; - float v1[3], v2[3], v3[3], v4[3], q0[3], q1[3], q2[3], q3[3], contrib= 0.0f; + float v1[3], v2[3], v3[3], v4[3], q0[3], q1[3], q2[3], q3[3], contrib = 0.0f; - obi= &R.objectinstance[face->obi]; - vlr= RE_findOrAddVlak(obi->obr, face->facenr); + obi = &R.objectinstance[face->obi]; + vlr = RE_findOrAddVlak(obi->obr, face->facenr); copy_v3_v3(v1, vlr->v1->co); copy_v3_v3(v2, vlr->v2->co); @@ -1214,103 +1216,103 @@ static void occ_lookup(OcclusionTree *tree, int thread, OccFace *exclude, if (bentn) copy_v3_v3(bentn, n); - error= tree->error; - distfac= tree->distfac; + error = tree->error; + distfac = tree->distfac; - resultocc= 0.0f; + resultocc = 0.0f; zero_v3(resultrad); /* init stack */ - stack= tree->stack[thread]; - stack[0]= tree->root; - totstack= 1; + stack = tree->stack[thread]; + stack[0] = tree->root; + totstack = 1; while (totstack) { /* pop point off the stack */ - node= stack[--totstack]; + node = stack[--totstack]; sub_v3_v3v3(v, node->co, p); - d2= dot_v3v3(v, v) + 1e-16f; - emitarea= MAX2(node->area, node->dco); + d2 = dot_v3v3(v, v) + 1e-16f; + emitarea = MAX2(node->area, node->dco); - if (d2*error > emitarea) { + if (d2 * error > emitarea) { if (distfac != 0.0f) { - fac= 1.0f/(1.0f + distfac*d2); + fac = 1.0f / (1.0f + distfac * d2); if (fac < 0.01f) continue; } else - fac= 1.0f; + fac = 1.0f; /* accumulate occlusion from spherical harmonics */ - invd2 = 1.0f/sqrtf(d2); - weight= occ_solid_angle(node, v, d2, invd2, n); + invd2 = 1.0f / sqrtf(d2); + weight = occ_solid_angle(node, v, d2, invd2, n); if (rad) - madd_v3_v3fl(resultrad, node->rad, weight*fac); + madd_v3_v3fl(resultrad, node->rad, weight * fac); weight *= node->occlusion; if (bentn) { - bentn[0] -= weight*invd2*v[0]; - bentn[1] -= weight*invd2*v[1]; - bentn[2] -= weight*invd2*v[2]; + bentn[0] -= weight * invd2 * v[0]; + bentn[1] -= weight * invd2 * v[1]; + bentn[2] -= weight * invd2 * v[2]; } - resultocc += weight*fac; + resultocc += weight * fac; } else { /* traverse into children */ - for (b=0; bchildflag & (1<child[b].face; - face= &tree->face[f]; + for (b = 0; b < TOTCHILD; b++) { + if (node->childflag & (1 << b)) { + f = node->child[b].face; + face = &tree->face[f]; /* accumulate occlusion with face form factor */ if (!exclude || !(face->obi == exclude->obi && face->facenr == exclude->facenr)) { if (bentn || distfac != 0.0f) { occ_face(face, co, NULL, NULL); sub_v3_v3v3(v, co, p); - d2= dot_v3v3(v, v) + 1e-16f; + d2 = dot_v3v3(v, v) + 1e-16f; - fac= (distfac == 0.0f)? 1.0f: 1.0f/(1.0f + distfac*d2); + fac = (distfac == 0.0f) ? 1.0f : 1.0f / (1.0f + distfac * d2); if (fac < 0.01f) continue; } else - fac= 1.0f; + fac = 1.0f; - weight= occ_form_factor(face, p, n); + weight = occ_form_factor(face, p, n); if (rad) - madd_v3_v3fl(resultrad, tree->rad[f], weight*fac); + madd_v3_v3fl(resultrad, tree->rad[f], weight * fac); weight *= tree->occlusion[f]; if (bentn) { - invd2= 1.0f/sqrtf(d2); - bentn[0] -= weight*invd2*v[0]; - bentn[1] -= weight*invd2*v[1]; - bentn[2] -= weight*invd2*v[2]; + invd2 = 1.0f / sqrtf(d2); + bentn[0] -= weight * invd2 * v[0]; + bentn[1] -= weight * invd2 * v[1]; + bentn[2] -= weight * invd2 * v[2]; } - resultocc += weight*fac; + resultocc += weight * fac; } } else if (node->child[b].node) { /* push child on the stack */ - stack[totstack++]= node->child[b].node; + stack[totstack++] = node->child[b].node; } } } } - if (occ) *occ= resultocc; + if (occ) *occ = resultocc; if (rad) copy_v3_v3(rad, resultrad); #if 0 if (rad && exclude) { int a; - for (a=0; atotface; a++) + for (a = 0; a < tree->totface; a++) if ((tree->face[a].obi == exclude->obi && tree->face[a].facenr == exclude->facenr)) copy_v3_v3(rad, tree->rad[a]); } @@ -1323,18 +1325,18 @@ static void occ_compute_bounces(Render *re, OcclusionTree *tree, int totbounce) float (*rad)[3], (*sum)[3], (*tmp)[3], co[3], n[3], occ; int bounce, i; - rad= MEM_callocN(sizeof(float)*3*tree->totface, "OcclusionBounceRad"); - sum= MEM_dupallocN(tree->rad); + rad = MEM_callocN(sizeof(float) * 3 * tree->totface, "OcclusionBounceRad"); + sum = MEM_dupallocN(tree->rad); - for (bounce=1; bouncetotface; i++) { + for (bounce = 1; bounce < totbounce; bounce++) { + for (i = 0; i < tree->totface; i++) { occ_face(&tree->face[i], co, n, NULL); madd_v3_v3fl(co, n, 1e-8f); occ_lookup(tree, 0, &tree->face[i], co, n, &occ, rad[i], NULL); - rad[i][0]= MAX2(rad[i][0], 0.0f); - rad[i][1]= MAX2(rad[i][1], 0.0f); - rad[i][2]= MAX2(rad[i][2], 0.0f); + rad[i][0] = MAX2(rad[i][0], 0.0f); + rad[i][1] = MAX2(rad[i][1], 0.0f); + rad[i][2] = MAX2(rad[i][2], 0.0f); add_v3_v3(sum[i], rad[i]); if (re->test_break(re->tbh)) @@ -1344,16 +1346,16 @@ static void occ_compute_bounces(Render *re, OcclusionTree *tree, int totbounce) if (re->test_break(re->tbh)) break; - tmp= tree->rad; - tree->rad= rad; - rad= tmp; + tmp = tree->rad; + tree->rad = rad; + rad = tmp; occ_sum_occlusion(tree, tree->root); } MEM_freeN(rad); MEM_freeN(tree->rad); - tree->rad= sum; + tree->rad = sum; if (!re->test_break(re->tbh)) occ_sum_occlusion(tree, tree->root); @@ -1364,10 +1366,10 @@ static void occ_compute_passes(Render *re, OcclusionTree *tree, int totpass) float *occ, co[3], n[3]; int pass, i; - occ= MEM_callocN(sizeof(float)*tree->totface, "OcclusionPassOcc"); + occ = MEM_callocN(sizeof(float) * tree->totface, "OcclusionPassOcc"); - for (pass=0; passtotface; i++) { + for (pass = 0; pass < totpass; pass++) { + for (i = 0; i < tree->totface; i++) { occ_face(&tree->face[i], co, n, NULL); negate_v3(n); madd_v3_v3fl(co, n, 1e-8f); @@ -1380,10 +1382,10 @@ static void occ_compute_passes(Render *re, OcclusionTree *tree, int totpass) if (re->test_break(re->tbh)) break; - for (i=0; itotface; i++) { + for (i = 0; i < tree->totface; i++) { tree->occlusion[i] -= occ[i]; //MAX2(1.0f-occ[i], 0.0f); if (tree->occlusion[i] < 0.0f) - tree->occlusion[i]= 0.0f; + tree->occlusion[i] = 0.0f; } occ_sum_occlusion(tree, tree->root); @@ -1399,25 +1401,25 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, float nn[3], bn[3], fac, occ, occlusion, correction, rad[3]; int envcolor; - envcolor= re->wrld.aocolor; + envcolor = re->wrld.aocolor; if (onlyshadow) - envcolor= WO_AOPLAIN; + envcolor = WO_AOPLAIN; negate_v3_v3(nn, n); - occ_lookup(tree, thread, exclude, co, nn, &occ, (tree->doindirect)? rad: NULL, (env && envcolor)? bn: NULL); + occ_lookup(tree, thread, exclude, co, nn, &occ, (tree->doindirect) ? rad : NULL, (env && envcolor) ? bn : NULL); - correction= re->wrld.ao_approx_correction; + correction = re->wrld.ao_approx_correction; - occlusion= (1.0f-correction)*(1.0f-occ); + occlusion = (1.0f - correction) * (1.0f - occ); CLAMP(occlusion, 0.0f, 1.0f); if (correction != 0.0f) - occlusion += correction*expf(-occ); + occlusion += correction * expf(-occ); if (env) { /* sky shading using bent normal */ if (ELEM(envcolor, WO_AOSKYCOL, WO_AOSKYTEX)) { - fac= 0.5f * (1.0f + dot_v3v3(bn, re->grvec)); + fac = 0.5f * (1.0f + dot_v3v3(bn, re->grvec)); env[0] = (1.0f - fac) * re->wrld.horr + fac * re->wrld.zenr; env[1] = (1.0f - fac) * re->wrld.horg + fac * re->wrld.zeng; env[2] = (1.0f - fac) * re->wrld.horb + fac * re->wrld.zenb; @@ -1425,28 +1427,28 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, mul_v3_fl(env, occlusion); } else { - env[0]= occlusion; - env[1]= occlusion; - env[2]= occlusion; + env[0] = occlusion; + env[1] = occlusion; + env[2] = occlusion; } #if 0 - else { /* WO_AOSKYTEX */ + else { /* WO_AOSKYTEX */ float dxyview[3]; - bn[0]= -bn[0]; - bn[1]= -bn[1]; - bn[2]= -bn[2]; - dxyview[0]= 1.0f; - dxyview[1]= 1.0f; - dxyview[2]= 0.0f; + bn[0] = -bn[0]; + bn[1] = -bn[1]; + bn[2] = -bn[2]; + dxyview[0] = 1.0f; + dxyview[1] = 1.0f; + dxyview[2] = 0.0f; shadeSkyView(ao, co, bn, dxyview); } #endif } if (ao) { - ao[0]= occlusion; - ao[1]= occlusion; - ao[2]= occlusion; + ao[0] = occlusion; + ao[1] = occlusion; + ao[2] = occlusion; } if (tree->doindirect) copy_v3_v3(indirect, rad); @@ -1468,7 +1470,7 @@ static OcclusionCacheSample *find_occ_sample(OcclusionCache *cache, int x, int y if (x < 0 || x >= cache->w || y < 0 || y >= cache->h) return NULL; else - return &cache->sample[y*cache->w + x]; + return &cache->sample[y * cache->w + x]; } static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int y, int thread, float *ao, float *env, float *indirect) @@ -1483,14 +1485,14 @@ static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int return 0; /* first try to find a sample in the same pixel */ - cache= &tree->cache[thread]; + cache = &tree->cache[thread]; if (cache->sample && cache->step) { - sample= &cache->sample[(y-cache->y)*cache->w + (x-cache->x)]; + sample = &cache->sample[(y - cache->y) * cache->w + (x - cache->x)]; if (sample->filled) { sub_v3_v3v3(d, sample->co, co); - dist2= dot_v3v3(d, d); - if (dist2 < 0.5f*sample->dist2 && dot_v3v3(sample->n, n) > 0.98f) { + dist2 = dot_v3v3(d, d); + if (dist2 < 0.5f * sample->dist2 && dot_v3v3(sample->n, n) > 0.98f) { copy_v3_v3(ao, sample->ao); copy_v3_v3(env, sample->env); copy_v3_v3(indirect, sample->indirect); @@ -1502,18 +1504,18 @@ static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int return 0; /* try to interpolate between 4 neighboring pixels */ - samples[0]= find_occ_sample(cache, x, y); - samples[1]= find_occ_sample(cache, x+cache->step, y); - samples[2]= find_occ_sample(cache, x, y+cache->step); - samples[3]= find_occ_sample(cache, x+cache->step, y+cache->step); + samples[0] = find_occ_sample(cache, x, y); + samples[1] = find_occ_sample(cache, x + cache->step, y); + samples[2] = find_occ_sample(cache, x, y + cache->step); + samples[3] = find_occ_sample(cache, x + cache->step, y + cache->step); - for (i=0; i<4; i++) + for (i = 0; i < 4; i++) if (!samples[i] || !samples[i]->filled) return 0; /* require intensities not being too different */ - mino= MIN4(samples[0]->intensity, samples[1]->intensity, samples[2]->intensity, samples[3]->intensity); - maxo= MAX4(samples[0]->intensity, samples[1]->intensity, samples[2]->intensity, samples[3]->intensity); + mino = MIN4(samples[0]->intensity, samples[1]->intensity, samples[2]->intensity, samples[3]->intensity); + maxo = MAX4(samples[0]->intensity, samples[1]->intensity, samples[2]->intensity, samples[3]->intensity); if (maxo - mino > 0.05f) return 0; @@ -1522,29 +1524,29 @@ static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int zero_v3(ao); zero_v3(env); zero_v3(indirect); - totw= 0.0f; + totw = 0.0f; - x1= samples[0]->x; - y1= samples[0]->y; - x2= samples[3]->x; - y2= samples[3]->y; + x1 = samples[0]->x; + y1 = samples[0]->y; + x2 = samples[3]->x; + y2 = samples[3]->y; - tx= (float)(x2 - x)/(float)(x2 - x1); - ty= (float)(y2 - y)/(float)(y2 - y1); + tx = (float)(x2 - x) / (float)(x2 - x1); + ty = (float)(y2 - y) / (float)(y2 - y1); - wb[3]= (1.0f-tx)*(1.0f-ty); - wb[2]= (tx)*(1.0f-ty); - wb[1]= (1.0f-tx)*(ty); - wb[0]= tx*ty; + wb[3] = (1.0f - tx) * (1.0f - ty); + wb[2] = (tx) * (1.0f - ty); + wb[1] = (1.0f - tx) * (ty); + wb[0] = tx * ty; - for (i=0; i<4; i++) { + for (i = 0; i < 4; i++) { sub_v3_v3v3(d, samples[i]->co, co); //dist2= dot_v3v3(d, d); - wz[i]= 1.0f; //(samples[i]->dist2/(1e-4f + dist2)); - wn[i]= pow(dot_v3v3(samples[i]->n, n), 32.0f); + wz[i] = 1.0f; //(samples[i]->dist2/(1e-4f + dist2)); + wn[i] = pow(dot_v3v3(samples[i]->n, n), 32.0f); - w= wb[i]*wn[i]*wz[i]; + w = wb[i] * wn[i] * wz[i]; totw += w; madd_v3_v3fl(ao, samples[i]->ao, w); @@ -1553,7 +1555,7 @@ static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int } if (totw >= 0.9f) { - totw= 1.0f/totw; + totw = 1.0f / totw; mul_v3_fl(ao, totw); mul_v3_fl(env, totw); mul_v3_fl(indirect, totw); @@ -1565,18 +1567,18 @@ static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int static void sample_occ_surface(ShadeInput *shi) { - StrandRen *strand= shi->strand; - StrandSurface *mesh= strand->buffer->surface; + StrandRen *strand = shi->strand; + StrandSurface *mesh = strand->buffer->surface; int *face, *index = RE_strandren_get_face(shi->obr, strand, 0); float w[4], *co1, *co2, *co3, *co4; if (mesh && mesh->face && mesh->co && mesh->ao && index) { - face= mesh->face[*index]; + face = mesh->face[*index]; - co1= mesh->co[face[0]]; - co2= mesh->co[face[1]]; - co3= mesh->co[face[2]]; - co4= (face[3])? mesh->co[face[3]]: NULL; + co1 = mesh->co[face[0]]; + co2 = mesh->co[face[1]]; + co3 = mesh->co[face[2]]; + co4 = (face[3]) ? mesh->co[face[3]] : NULL; interp_weights_face_v3(w, co1, co2, co3, co4, strand->vert->co); @@ -1600,9 +1602,9 @@ static void sample_occ_surface(ShadeInput *shi) } } else { - shi->ao[0]= 1.0f; - shi->ao[1]= 1.0f; - shi->ao[2]= 1.0f; + shi->ao[0] = 1.0f; + shi->ao[1] = 1.0f; + shi->ao[2] = 1.0f; zero_v3(shi->env); zero_v3(shi->indirect); } @@ -1612,20 +1614,20 @@ static void sample_occ_surface(ShadeInput *shi) static void *exec_strandsurface_sample(void *data) { - OcclusionThread *othread= (OcclusionThread*)data; - Render *re= othread->re; - StrandSurface *mesh= othread->mesh; + OcclusionThread *othread = (OcclusionThread *)data; + Render *re = othread->re; + StrandSurface *mesh = othread->mesh; float ao[3], env[3], indirect[3], co[3], n[3], *co1, *co2, *co3, *co4; int a, *face; - for (a=othread->begin; aend; a++) { - face= mesh->face[a]; - co1= mesh->co[face[0]]; - co2= mesh->co[face[1]]; - co3= mesh->co[face[2]]; + for (a = othread->begin; a < othread->end; a++) { + face = mesh->face[a]; + co1 = mesh->co[face[0]]; + co2 = mesh->co[face[1]]; + co3 = mesh->co[face[2]]; if (face[3]) { - co4= mesh->co[face[3]]; + co4 = mesh->co[face[3]]; mid_v3_v3v3(co, co1, co3); normal_quad_v3(n, co1, co2, co3, co4); @@ -1655,12 +1657,12 @@ void make_occ_tree(Render *re) int a, totface, totthread, *face, *count; /* ugly, needed for occ_face */ - R= *re; + R = *re; - re->i.infostr= "Occlusion preprocessing"; + re->i.infostr = "Occlusion preprocessing"; re->stats_draw(re->sdh, &re->i); - re->occlusiontree= tree= occ_tree_build(re); + re->occlusiontree = tree = occ_tree_build(re); if (tree) { if (re->wrld.ao_approx_passes > 0) @@ -1668,26 +1670,26 @@ void make_occ_tree(Render *re) if (tree->doindirect && (re->wrld.mode & WO_INDIRECT_LIGHT)) occ_compute_bounces(re, tree, re->wrld.ao_indirect_bounces); - for (mesh=re->strandsurface.first; mesh; mesh=mesh->next) { + for (mesh = re->strandsurface.first; mesh; mesh = mesh->next) { if (!mesh->face || !mesh->co || !mesh->ao) continue; - count= MEM_callocN(sizeof(int)*mesh->totvert, "OcclusionCount"); - faceao= MEM_callocN(sizeof(float)*3*mesh->totface, "StrandSurfFaceAO"); - faceenv= MEM_callocN(sizeof(float)*3*mesh->totface, "StrandSurfFaceEnv"); - faceindirect= MEM_callocN(sizeof(float)*3*mesh->totface, "StrandSurfFaceIndirect"); - - totthread= (mesh->totface > 10000)? re->r.threads: 1; - totface= mesh->totface/totthread; - for (a=0; atotface: (a+1)*totface; + count = MEM_callocN(sizeof(int) * mesh->totvert, "OcclusionCount"); + faceao = MEM_callocN(sizeof(float) * 3 * mesh->totface, "StrandSurfFaceAO"); + faceenv = MEM_callocN(sizeof(float) * 3 * mesh->totface, "StrandSurfFaceEnv"); + faceindirect = MEM_callocN(sizeof(float) * 3 * mesh->totface, "StrandSurfFaceIndirect"); + + totthread = (mesh->totface > 10000) ? re->r.threads : 1; + totface = mesh->totface / totthread; + for (a = 0; a < totthread; a++) { + othreads[a].re = re; + othreads[a].faceao = faceao; + othreads[a].faceenv = faceenv; + othreads[a].faceindirect = faceindirect; + othreads[a].thread = a; + othreads[a].mesh = mesh; + othreads[a].begin = a * totface; + othreads[a].end = (a == totthread - 1) ? mesh->totface : (a + 1) * totface; } if (totthread == 1) { @@ -1696,14 +1698,14 @@ void make_occ_tree(Render *re) else { BLI_init_threads(&threads, exec_strandsurface_sample, totthread); - for (a=0; atotface; a++) { - face= mesh->face[a]; + for (a = 0; a < mesh->totface; a++) { + face = mesh->face[a]; copy_v3_v3(ao, faceao[a]); copy_v3_v3(env, faceenv[a]); @@ -1730,11 +1732,11 @@ void make_occ_tree(Render *re) } } - for (a=0; atotvert; a++) { + for (a = 0; a < mesh->totvert; a++) { if (count[a]) { - mul_v3_fl(mesh->ao[a], 1.0f/count[a]); - mul_v3_fl(mesh->env[a], 1.0f/count[a]); - mul_v3_fl(mesh->indirect[a], 1.0f/count[a]); + mul_v3_fl(mesh->ao[a], 1.0f / count[a]); + mul_v3_fl(mesh->env[a], 1.0f / count[a]); + mul_v3_fl(mesh->indirect[a], 1.0f / count[a]); } } @@ -1756,7 +1758,7 @@ void free_occ(Render *re) void sample_occ(Render *re, ShadeInput *shi) { - OcclusionTree *tree= re->occlusiontree; + OcclusionTree *tree = re->occlusiontree; OcclusionCache *cache; OcclusionCacheSample *sample; OccFace exclude; @@ -1767,91 +1769,91 @@ void sample_occ(Render *re, ShadeInput *shi) sample_occ_surface(shi); } /* try to get result from the cache if possible */ - else if (shi->depth!=0 || !sample_occ_cache(tree, shi->co, shi->vno, shi->xs, shi->ys, shi->thread, shi->ao, shi->env, shi->indirect)) { + else if (shi->depth != 0 || !sample_occ_cache(tree, shi->co, shi->vno, shi->xs, shi->ys, shi->thread, shi->ao, shi->env, shi->indirect)) { /* no luck, let's sample the occlusion */ - exclude.obi= shi->obi - re->objectinstance; - exclude.facenr= shi->vlr->index; - onlyshadow= (shi->mat->mode & MA_ONLYSHADOW); + exclude.obi = shi->obi - re->objectinstance; + exclude.facenr = shi->vlr->index; + onlyshadow = (shi->mat->mode & MA_ONLYSHADOW); sample_occ_tree(re, tree, &exclude, shi->co, shi->vno, shi->thread, onlyshadow, shi->ao, shi->env, shi->indirect); /* fill result into sample, each time */ if (tree->cache) { - cache= &tree->cache[shi->thread]; + cache = &tree->cache[shi->thread]; if (cache->sample && cache->step) { - sample= &cache->sample[(shi->ys-cache->y)*cache->w + (shi->xs-cache->x)]; + sample = &cache->sample[(shi->ys - cache->y) * cache->w + (shi->xs - cache->x)]; copy_v3_v3(sample->co, shi->co); copy_v3_v3(sample->n, shi->vno); copy_v3_v3(sample->ao, shi->ao); copy_v3_v3(sample->env, shi->env); copy_v3_v3(sample->indirect, shi->indirect); - sample->intensity= MAX3(sample->ao[0], sample->ao[1], sample->ao[2]); - sample->intensity= MAX2(sample->intensity, MAX3(sample->env[0], sample->env[1], sample->env[2])); - sample->intensity= MAX2(sample->intensity, MAX3(sample->indirect[0], sample->indirect[1], sample->indirect[2])); - sample->dist2= dot_v3v3(shi->dxco, shi->dxco) + dot_v3v3(shi->dyco, shi->dyco); - sample->filled= 1; + sample->intensity = MAX3(sample->ao[0], sample->ao[1], sample->ao[2]); + sample->intensity = MAX2(sample->intensity, MAX3(sample->env[0], sample->env[1], sample->env[2])); + sample->intensity = MAX2(sample->intensity, MAX3(sample->indirect[0], sample->indirect[1], sample->indirect[2])); + sample->dist2 = dot_v3v3(shi->dxco, shi->dxco) + dot_v3v3(shi->dyco, shi->dyco); + sample->filled = 1; } } } } else { - shi->ao[0]= 1.0f; - shi->ao[1]= 1.0f; - shi->ao[2]= 1.0f; + shi->ao[0] = 1.0f; + shi->ao[1] = 1.0f; + shi->ao[2] = 1.0f; - shi->env[0]= 0.0f; - shi->env[1]= 0.0f; - shi->env[2]= 0.0f; + shi->env[0] = 0.0f; + shi->env[1] = 0.0f; + shi->env[2] = 0.0f; - shi->indirect[0]= 0.0f; - shi->indirect[1]= 0.0f; - shi->indirect[2]= 0.0f; + shi->indirect[0] = 0.0f; + shi->indirect[1] = 0.0f; + shi->indirect[2] = 0.0f; } } void cache_occ_samples(Render *re, RenderPart *pa, ShadeSample *ssamp) { - OcclusionTree *tree= re->occlusiontree; + OcclusionTree *tree = re->occlusiontree; PixStr ps; OcclusionCache *cache; OcclusionCacheSample *sample; OccFace exclude; ShadeInput *shi; - intptr_t *rd=NULL; - int *ro=NULL, *rp=NULL, *rz=NULL, onlyshadow; + intptr_t *rd = NULL; + int *ro = NULL, *rp = NULL, *rz = NULL, onlyshadow; int x, y, step = CACHE_STEP; if (!tree->cache) return; - cache= &tree->cache[pa->thread]; - cache->w= pa->rectx; - cache->h= pa->recty; - cache->x= pa->disprect.xmin; - cache->y= pa->disprect.ymin; - cache->step= step; - cache->sample= MEM_callocN(sizeof(OcclusionCacheSample)*cache->w*cache->h, "OcclusionCacheSample"); - sample= cache->sample; + cache = &tree->cache[pa->thread]; + cache->w = pa->rectx; + cache->h = pa->recty; + cache->x = pa->disprect.xmin; + cache->y = pa->disprect.ymin; + cache->step = step; + cache->sample = MEM_callocN(sizeof(OcclusionCacheSample) * cache->w * cache->h, "OcclusionCacheSample"); + sample = cache->sample; if (re->osa) { - rd= pa->rectdaps; + rd = pa->rectdaps; } else { /* fake pixel struct for non-osa */ - ps.next= NULL; - ps.mask= 0xFFFF; + ps.next = NULL; + ps.mask = 0xFFFF; - ro= pa->recto; - rp= pa->rectp; - rz= pa->rectz; + ro = pa->recto; + rp = pa->rectp; + rz = pa->rectz; } /* compute a sample at every step pixels */ - for (y=pa->disprect.ymin; ydisprect.ymax; y++) { - for (x=pa->disprect.xmin; xdisprect.xmax; x++, sample++, rd++, ro++, rp++, rz++) { - if (!(((x - pa->disprect.xmin + step) % step) == 0 || x == pa->disprect.xmax-1)) + for (y = pa->disprect.ymin; y < pa->disprect.ymax; y++) { + for (x = pa->disprect.xmin; x < pa->disprect.xmax; x++, sample++, rd++, ro++, rp++, rz++) { + if (!(((x - pa->disprect.xmin + step) % step) == 0 || x == pa->disprect.xmax - 1)) continue; - if (!(((y - pa->disprect.ymin + step) % step) == 0 || y == pa->disprect.ymax-1)) + if (!(((y - pa->disprect.ymin + step) % step) == 0 || y == pa->disprect.ymax - 1)) continue; if (re->osa) { @@ -1862,17 +1864,17 @@ void cache_occ_samples(Render *re, RenderPart *pa, ShadeSample *ssamp) else { if (!*rp) continue; - ps.obi= *ro; - ps.facenr= *rp; - ps.z= *rz; + ps.obi = *ro; + ps.facenr = *rp; + ps.z = *rz; shade_samples_fill_with_ps(ssamp, &ps, x, y); } - shi= ssamp->shi; + shi = ssamp->shi; if (shi->vlr) { - onlyshadow= (shi->mat->mode & MA_ONLYSHADOW); - exclude.obi= shi->obi - re->objectinstance; - exclude.facenr= shi->vlr->index; + onlyshadow = (shi->mat->mode & MA_ONLYSHADOW); + exclude.obi = shi->obi - re->objectinstance; + exclude.facenr = shi->vlr->index; sample_occ_tree(re, tree, &exclude, shi->co, shi->vno, shi->thread, onlyshadow, shi->ao, shi->env, shi->indirect); copy_v3_v3(sample->co, shi->co); @@ -1880,13 +1882,13 @@ void cache_occ_samples(Render *re, RenderPart *pa, ShadeSample *ssamp) copy_v3_v3(sample->ao, shi->ao); copy_v3_v3(sample->env, shi->env); copy_v3_v3(sample->indirect, shi->indirect); - sample->intensity= MAX3(sample->ao[0], sample->ao[1], sample->ao[2]); - sample->intensity= MAX2(sample->intensity, MAX3(sample->env[0], sample->env[1], sample->env[2])); - sample->intensity= MAX2(sample->intensity, MAX3(sample->indirect[0], sample->indirect[1], sample->indirect[2])); - sample->dist2= dot_v3v3(shi->dxco, shi->dxco) + dot_v3v3(shi->dyco, shi->dyco); - sample->x= shi->xs; - sample->y= shi->ys; - sample->filled= 1; + sample->intensity = MAX3(sample->ao[0], sample->ao[1], sample->ao[2]); + sample->intensity = MAX2(sample->intensity, MAX3(sample->env[0], sample->env[1], sample->env[2])); + sample->intensity = MAX2(sample->intensity, MAX3(sample->indirect[0], sample->indirect[1], sample->indirect[2])); + sample->dist2 = dot_v3v3(shi->dxco, shi->dxco) + dot_v3v3(shi->dyco, shi->dyco); + sample->x = shi->xs; + sample->y = shi->ys; + sample->filled = 1; } if (re->test_break(re->tbh)) @@ -1897,18 +1899,18 @@ void cache_occ_samples(Render *re, RenderPart *pa, ShadeSample *ssamp) void free_occ_samples(Render *re, RenderPart *pa) { - OcclusionTree *tree= re->occlusiontree; + OcclusionTree *tree = re->occlusiontree; OcclusionCache *cache; if (tree->cache) { - cache= &tree->cache[pa->thread]; + cache = &tree->cache[pa->thread]; if (cache->sample) MEM_freeN(cache->sample); - cache->w= 0; - cache->h= 0; - cache->step= 0; + cache->w = 0; + cache->h = 0; + cache->step = 0; } } diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index f11e5d22574..8a936545903 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -99,7 +99,7 @@ static RayObject* RE_rayobject_create(Render *re, int type, int size) RayObject * res = NULL; if (type == R_RAYSTRUCTURE_AUTO) { - //TODO + /* TODO */ //if (detect_simd()) #ifdef __SSE__ type = BLI_cpu_support_sse2()? R_RAYSTRUCTURE_SIMD_SVBVH: R_RAYSTRUCTURE_VBVH; @@ -216,12 +216,12 @@ static int is_raytraceable(Render *re, ObjectInstanceRen *obi) RayObject* makeraytree_object(Render *re, ObjectInstanceRen *obi) { - //TODO - // out-of-memory safeproof - // break render - // update render stats + /*TODO + * out-of-memory safeproof + * break render + * update render stats */ ObjectRen *obr = obi->obr; - + if (obr->raytree == NULL) { RayObject *raytree; RayFace *face = NULL; @@ -421,8 +421,8 @@ void makeraytree(Render *re) re->stats_draw(re->sdh, &re->i); } else { - //Calculate raytree max_size - //This is ONLY needed to kept a bogus behavior of SUN and HEMI lights + /* Calculate raytree max_size + * This is ONLY needed to kept a bogus behavior of SUN and HEMI lights */ INIT_MINMAX(min, max); RE_rayobject_merge_bb(re->raytree, min, max); for (i=0; i<3; i++) { @@ -739,8 +739,8 @@ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, con tracol[0]= shi.r; tracol[1]= shi.g; tracol[2]= shi.b; - tracol[3]= col[3]; // we pass on and accumulate alpha - + tracol[3]= col[3]; /* we pass on and accumulate alpha */ + if ((shi.mat->mode & MA_TRANSP) && (shi.mat->mode & MA_RAYTRANSP)) { /* don't overwrite traflag, it's value is used in mirror reflection */ int new_traflag = traflag; @@ -883,12 +883,12 @@ static void DP_energy(float *table, float vec[2], int tot, float xsize, float ys } vec[0] += 0.1f*min*result[0]/(float)tot; vec[1] += 0.1f*min*result[1]/(float)tot; - // cyclic clamping + /* cyclic clamping */ vec[0]= vec[0] - xsize*floorf(vec[0]/xsize + 0.5f); vec[1]= vec[1] - ysize*floorf(vec[1]/ysize + 0.5f); } -// random offset of 1 in 2 +/* random offset of 1 in 2 */ static void jitter_plane_offset(float *jitter1, float *jitter2, int tot, float sizex, float sizey, float ofsx, float ofsy) { float dsizex= sizex*ofsx; @@ -974,10 +974,10 @@ static float *give_jitter_plane(LampRen *lar, int thread, int xs, int ys) static void halton_sample(double *ht_invprimes, double *ht_nums, double *v) { - // incremental halton sequence generator, from: - // "Instant Radiosity", Keller A. + /* incremental halton sequence generator, from: + * "Instant Radiosity", Keller A. */ unsigned int i; - + for (i = 0; i < 2; i++) { double r = fabs((1.0 - ht_nums[i]) - 1e-10); @@ -1812,7 +1812,7 @@ static float *sphere_sampler(int type, int resol, int thread, int xs, int ys, in float *sphere; int a; - // always returns table + /* always returns table */ sphere= threadsafe_table_sphere(0, thread, xs, ys, tot); /* total random sampling. NOT THREADSAFE! (should be removed, is not useful) */ @@ -1827,7 +1827,7 @@ static float *sphere_sampler(int type, int resol, int thread, int xs, int ys, in float *sphere; float *vec1; - // returns table if xs and ys were equal to last call, and not resetting + /* returns table if xs and ys were equal to last call, and not resetting */ sphere= (reset)? NULL: threadsafe_table_sphere(1, thread, xs, ys, tot); if (sphere==NULL) { float cosfi, sinfi, cost, sint; @@ -1836,7 +1836,7 @@ static float *sphere_sampler(int type, int resol, int thread, int xs, int ys, in sphere= threadsafe_table_sphere(0, thread, xs, ys, tot); - // random rotation + /* random rotation */ ang= BLI_thread_frand(thread); sinfi= sin(ang); cosfi= cos(ang); ang= BLI_thread_frand(thread); @@ -2056,7 +2056,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float ao[3], float env[3]) * for strand render we always require a new sampler because x/y are not set */ vec= sphere_sampler(R.wrld.aomode, resol, shi->thread, shi->xs, shi->ys, shi->strand != NULL); - // warning: since we use full sphere now, and dotproduct is below, we do twice as much + /* warning: since we use full sphere now, and dotproduct is below, we do twice as much */ tot= 2*resol*resol; if (envcolor == WO_AOSKYTEX) { @@ -2116,7 +2116,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float ao[3], float env[3]) skyadded++; } } - // samples + /* samples */ vec+= 3; } @@ -2436,7 +2436,7 @@ static void ray_shadow_jitter(ShadeInput *shi, LampRen *lar, const float lampco[ shadfac[3] /= div; } else { - // sqrt makes nice umbra effect + /* sqrt makes nice umbra effect */ if (lar->ray_samp_type & LA_SAMP_UMBRA) shadfac[3]= sqrt(1.0f-fac/div); else @@ -2501,8 +2501,8 @@ void ray_shadow(ShadeInput *shi, LampRen *lar, float shadfac[4]) isec.orig.ob = shi->obi; isec.orig.face = shi->vlr; - shadfac[3]= 1.0f; // 1.0=full light - + shadfac[3]= 1.0f; /* 1.0=full light */ + /* set up isec.dir */ copy_v3_v3(isec.start, shi->co); sub_v3_v3v3(isec.dir, lampco, isec.start); diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index 8e8483839b1..ddb24e134df 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -459,7 +459,7 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf rl->lay_zmask = srl->lay_zmask; rl->lay_exclude = srl->lay_exclude; rl->layflag = srl->layflag; - rl->passflag = srl->passflag; // for debugging: srl->passflag|SCE_PASS_RAYHITS; + rl->passflag = srl->passflag; /* for debugging: srl->passflag | SCE_PASS_RAYHITS; */ rl->pass_xor = srl->pass_xor; rl->light_override = srl->light_override; rl->mat_override = srl->mat_override; diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 39577bf8da8..c8ef3e4a8dd 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -244,7 +244,7 @@ static int clouds(Tex *tex, float *texvec, TexResult *texres) texres->tin = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); if (texres->nor!=NULL) { - // calculate bumpnormal + /* calculate bumpnormal */ texres->nor[0] = BLI_gTurbulence(tex->noisesize, texvec[0] + tex->nabla, texvec[1], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); texres->nor[1] = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1] + tex->nabla, texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); texres->nor[2] = BLI_gTurbulence(tex->noisesize, texvec[0], texvec[1], texvec[2] + tex->nabla, tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); @@ -254,8 +254,8 @@ static int clouds(Tex *tex, float *texvec, TexResult *texres) } if (tex->stype==TEX_COLOR) { - // in this case, int. value should really be computed from color, - // and bumpnormal from that, would be too slow, looks ok as is + /* in this case, int. value should really be computed from color, + * and bumpnormal from that, would be too slow, looks ok as is */ texres->tr = texres->tin; texres->tg = BLI_gTurbulence(tex->noisesize, texvec[1], texvec[0], texvec[2], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); texres->tb = BLI_gTurbulence(tex->noisesize, texvec[1], texvec[2], texvec[0], tex->noisedepth, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); @@ -538,8 +538,8 @@ static float mg_mFractalOrfBmTex(Tex *tex, float *texvec, TexResult *texres) texres->tin = tex->ns_outscale*mgravefunc(texvec[0], texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis); if (texres->nor!=NULL) { - float offs= tex->nabla/tex->noisesize; // also scaling of texvec - + float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */ + /* calculate bumpnormal */ texres->nor[0] = tex->ns_outscale*mgravefunc(texvec[0] + offs, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis); texres->nor[1] = tex->ns_outscale*mgravefunc(texvec[0], texvec[1] + offs, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->noisebasis); @@ -568,8 +568,8 @@ static float mg_ridgedOrHybridMFTex(Tex *tex, float *texvec, TexResult *texres) texres->tin = tex->ns_outscale*mgravefunc(texvec[0], texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis); if (texres->nor!=NULL) { - float offs= tex->nabla/tex->noisesize; // also scaling of texvec - + float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */ + /* calculate bumpnormal */ texres->nor[0] = tex->ns_outscale*mgravefunc(texvec[0] + offs, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis); texres->nor[1] = tex->ns_outscale*mgravefunc(texvec[0], texvec[1] + offs, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->mg_gain, tex->noisebasis); @@ -593,8 +593,8 @@ static float mg_HTerrainTex(Tex *tex, float *texvec, TexResult *texres) texres->tin = tex->ns_outscale*mg_HeteroTerrain(texvec[0], texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis); if (texres->nor!=NULL) { - float offs= tex->nabla/tex->noisesize; // also scaling of texvec - + float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */ + /* calculate bumpnormal */ texres->nor[0] = tex->ns_outscale*mg_HeteroTerrain(texvec[0] + offs, texvec[1], texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis); texres->nor[1] = tex->ns_outscale*mg_HeteroTerrain(texvec[0], texvec[1] + offs, texvec[2], tex->mg_H, tex->mg_lacunarity, tex->mg_octaves, tex->mg_offset, tex->noisebasis); @@ -618,8 +618,8 @@ static float mg_distNoiseTex(Tex *tex, float *texvec, TexResult *texres) texres->tin = mg_VLNoise(texvec[0], texvec[1], texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2); if (texres->nor!=NULL) { - float offs= tex->nabla/tex->noisesize; // also scaling of texvec - + float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */ + /* calculate bumpnormal */ texres->nor[0] = mg_VLNoise(texvec[0] + offs, texvec[1], texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2); texres->nor[1] = mg_VLNoise(texvec[0], texvec[1] + offs, texvec[2], tex->dist_amount, tex->noisebasis, tex->noisebasis2); @@ -688,7 +688,7 @@ static float voronoiTex(Tex *tex, float *texvec, TexResult *texres) } if (texres->nor!=NULL) { - float offs= tex->nabla/tex->noisesize; // also scaling of texvec + float offs= tex->nabla/tex->noisesize; /* also scaling of texvec */ /* calculate bumpnormal */ voronoi(texvec[0] + offs, texvec[1], texvec[2], da, pa, tex->vn_mexp, tex->vn_distm); @@ -745,7 +745,7 @@ static int cubemap_glob(const float n[3], float x, float y, float z, float *adr1 int ret; if (n==NULL) { - nor[0]= x; nor[1]= y; nor[2]= z; // use local render coord + nor[0]= x; nor[1]= y; nor[2]= z; /* use local render coord */ } else { copy_v3_v3(nor, n); @@ -1026,7 +1026,7 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, const float n[3], if (tex->xrepeat>1) { float origf= fx *= tex->xrepeat; - // TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call + /* TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call */ if (tex->texfilter == TXF_BOX) { if (fx>1.0f) fx -= (int)(fx); else if (fx<0.0f) fx+= 1-(int)(fx); @@ -1046,7 +1046,7 @@ static void do_2d_mapping(MTex *mtex, float *t, VlakRen *vlr, const float n[3], if (tex->yrepeat>1) { float origf= fy *= tex->yrepeat; - // TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call + /* TXF: omit mirror here, see comments in do_material_tex() after do_2d_mapping() call */ if (tex->texfilter == TXF_BOX) { if (fy>1.0f) fy -= (int)(fy); else if (fy<0.0f) fy+= 1-(int)(fy); @@ -1512,9 +1512,9 @@ float texture_value_blend(float tex, float out, float fact, float facg, int blen static void texco_mapping(ShadeInput* shi, Tex* tex, MTex* mtex, float* co, float* dx, float* dy, float* texvec, float* dxt, float* dyt) { - // new: first swap coords, then map, then trans/scale + /* new: first swap coords, then map, then trans/scale */ if (tex->type == TEX_IMAGE) { - // placement + /* placement */ texvec[0] = mtex->projx ? co[mtex->projx - 1] : 0.f; texvec[1] = mtex->projy ? co[mtex->projy - 1] : 0.f; texvec[2] = mtex->projz ? co[mtex->projz - 1] : 0.f; @@ -1538,7 +1538,7 @@ static void texco_mapping(ShadeInput* shi, Tex* tex, MTex* mtex, float* co, floa } do_2d_mapping(mtex, texvec, shi->vlr, shi->facenor, dxt, dyt); - // translate and scale + /* translate and scale */ texvec[0] = mtex->size[0]*(texvec[0] - 0.5f) + mtex->ofs[0] + 0.5f; texvec[1] = mtex->size[1]*(texvec[1] - 0.5f) + mtex->ofs[1] + 0.5f; if (shi->osatex) { @@ -1549,13 +1549,13 @@ static void texco_mapping(ShadeInput* shi, Tex* tex, MTex* mtex, float* co, floa } /* problem: repeat-mirror is not a 'repeat' but 'extend' in imagetexture.c */ - // TXF: bug was here, only modify texvec when repeat mode set, old code affected other modes too. - // New texfilters solve mirroring differently so that it also works correctly when - // textures are scaled (sizeXYZ) as well as repeated. See also modification in do_2d_mapping(). - // (since currently only done in osa mode, results will look incorrect without osa TODO) + /* TXF: bug was here, only modify texvec when repeat mode set, old code affected other modes too. + * New texfilters solve mirroring differently so that it also works correctly when + * textures are scaled (sizeXYZ) as well as repeated. See also modification in do_2d_mapping(). + * (since currently only done in osa mode, results will look incorrect without osa TODO) */ if (tex->extend == TEX_REPEAT && (tex->flag & TEX_REPEAT_XMIR)) { if (tex->texfilter == TXF_BOX) - texvec[0] -= floorf(texvec[0]); // this line equivalent to old code, same below + texvec[0] -= floorf(texvec[0]); /* this line equivalent to old code, same below */ else if (texvec[0] < 0.f || texvec[0] > 1.f) { const float tx = 0.5f*texvec[0]; texvec[0] = 2.f*(tx - floorf(tx)); @@ -1573,8 +1573,8 @@ static void texco_mapping(ShadeInput* shi, Tex* tex, MTex* mtex, float* co, floa } } - else { // procedural - // placement + else { /* procedural */ + /* placement */ texvec[0] = mtex->size[0]*(mtex->projx ? (co[mtex->projx - 1] + mtex->ofs[0]) : mtex->ofs[0]); texvec[1] = mtex->size[1]*(mtex->projy ? (co[mtex->projy - 1] + mtex->ofs[1]) : mtex->ofs[1]); texvec[2] = mtex->size[2]*(mtex->projz ? (co[mtex->projz - 1] + mtex->ofs[2]) : mtex->ofs[2]); @@ -1617,11 +1617,16 @@ static void compatible_bump_init(CompatibleBump *compat_bump) static void compatible_bump_uv_derivs(CompatibleBump *compat_bump, ShadeInput *shi, MTex *mtex, int i) { - // uvmapping only, calculation of normal tangent u/v partial derivatives - // (should not be here, dudnu, dudnv, dvdnu & dvdnv should probably be part of ShadeInputUV struct, - // nu/nv in ShadeInput and this calculation should then move to shadeinput.c, shade_input_set_shade_texco() func.) - // NOTE: test for shi->obr->ob here, since vlr/obr/obi can be 'fake' when called from fastshade(), another reason to move it.. - // NOTE: shi->v1 is NULL when called from displace_render_vert, assigning verts in this case is not trivial because the shi quad face side is not know. + /* uvmapping only, calculation of normal tangent u/v partial derivatives + * (should not be here, dudnu, dudnv, dvdnu & dvdnv should probably be part of ShadeInputUV struct, + * nu/nv in ShadeInput and this calculation should then move to shadeinput.c, + * shade_input_set_shade_texco() func.) */ + + /* NOTE: test for shi->obr->ob here, + * since vlr/obr/obi can be 'fake' when called from fastshade(), another reason to move it.. */ + + /* NOTE: shi->v1 is NULL when called from displace_render_vert, + * assigning verts in this case is not trivial because the shi quad face side is not know. */ if ((mtex->texflag & MTEX_COMPAT_BUMP) && shi->obr && shi->obr->ob && shi->v1) { if (mtex->mapto & (MAP_NORM|MAP_WARP) && !((mtex->tex->type==TEX_IMAGE) && (mtex->tex->imaflag & TEX_NORMALMAP))) { MTFace* tf = RE_vlakren_get_tface(shi->obr, shi->vlr, i, NULL, 0); @@ -1629,9 +1634,9 @@ static void compatible_bump_uv_derivs(CompatibleBump *compat_bump, ShadeInput *s vlr_set_uv_indices(shi->vlr, &j1, &j2, &j3); - // compute ortho basis around normal + /* compute ortho basis around normal */ if (!compat_bump->nunvdone) { - // render normal is negated + /* render normal is negated */ compat_bump->nn[0] = -shi->vn[0]; compat_bump->nn[1] = -shi->vn[1]; compat_bump->nn[2] = -shi->vn[2]; @@ -1672,32 +1677,32 @@ static void compatible_bump_uv_derivs(CompatibleBump *compat_bump, ShadeInput *s static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, MTex *mtex, Tex *tex, TexResult *texres, float Tnor, float *co, float *dx, float *dy, float *texvec, float *dxt, float *dyt) { - TexResult ttexr = {0, 0, 0, 0, 0, texres->talpha, NULL}; // temp TexResult + TexResult ttexr = {0, 0, 0, 0, 0, texres->talpha, NULL}; /* temp TexResult */ float tco[3], texv[3], cd, ud, vd, du, dv, idu, idv; const int fromrgb = ((tex->type == TEX_IMAGE) || ((tex->flag & TEX_COLORBAND)!=0)); const float bf = -0.04f*Tnor*mtex->norfac; int rgbnor; - // disable internal bump eval + /* disable internal bump eval */ float* nvec = texres->nor; texres->nor = NULL; - // du & dv estimates, constant value defaults + /* du & dv estimates, constant value defaults */ du = dv = 0.01f; - // compute ortho basis around normal + /* compute ortho basis around normal */ if (!compat_bump->nunvdone) { - // render normal is negated + /* render normal is negated */ negate_v3_v3(compat_bump->nn, shi->vn); ortho_basis_v3v3_v3(compat_bump->nu, compat_bump->nv, compat_bump->nn); compat_bump->nunvdone = TRUE; } - // two methods, either constant based on main image resolution, - // (which also works without osa, though of course not always good (or even very bad) results), - // or based on tex derivative max values (osa only). Not sure which is best... + /* two methods, either constant based on main image resolution, + * (which also works without osa, though of course not always good (or even very bad) results), + * or based on tex derivative max values (osa only). Not sure which is best... */ if (!shi->osatex && (tex->type == TEX_IMAGE) && tex->ima) { - // in case we have no proper derivatives, fall back to - // computing du/dv it based on image size + /* in case we have no proper derivatives, fall back to + * computing du/dv it based on image size */ ImBuf* ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser); if (ibuf) { du = 1.f/(float)ibuf->x; @@ -1705,14 +1710,14 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, } } else if (shi->osatex) { - // we have derivatives, can compute proper du/dv - if (tex->type == TEX_IMAGE) { // 2d image, use u & v max. of dx/dy 2d vecs + /* we have derivatives, can compute proper du/dv */ + if (tex->type == TEX_IMAGE) { /* 2d image, use u & v max. of dx/dy 2d vecs */ const float adx[2] = {fabsf(dx[0]), fabsf(dx[1])}; const float ady[2] = {fabsf(dy[0]), fabsf(dy[1])}; du = MAX2(adx[0], ady[0]); dv = MAX2(adx[1], ady[1]); } - else { // 3d procedural, estimate from all dx/dy elems + else { /* 3d procedural, estimate from all dx/dy elems */ const float adx[3] = {fabsf(dx[0]), fabsf(dx[1]), fabsf(dx[2])}; const float ady[3] = {fabsf(dy[0]), fabsf(dy[1]), fabsf(dy[2])}; du = MAX3(adx[0], adx[1], adx[2]); @@ -1720,18 +1725,18 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, } } - // center, main return value + /* center, main return value */ texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt); rgbnor = multitex_mtex(shi, mtex, texvec, dxt, dyt, texres); cd = fromrgb ? (texres->tr + texres->tg + texres->tb)*0.33333333f : texres->tin; if (mtex->texco == TEXCO_UV) { - // for the uv case, use the same value for both du/dv, - // since individually scaling the normal derivatives makes them useless... + /* for the uv case, use the same value for both du/dv, + * since individually scaling the normal derivatives makes them useless... */ du = MIN2(du, dv); idu = (du < 1e-5f) ? bf : (bf/du); - // +u val + /* +u val */ tco[0] = co[0] + compat_bump->dudnu*du; tco[1] = co[1] + compat_bump->dvdnu*du; tco[2] = 0.f; @@ -1739,7 +1744,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, multitex_mtex(shi, mtex, texv, dxt, dyt, &ttexr); ud = idu*(cd - (fromrgb ? (ttexr.tr + ttexr.tg + ttexr.tb)*0.33333333f : ttexr.tin)); - // +v val + /* +v val */ tco[0] = co[0] + compat_bump->dudnv*du; tco[1] = co[1] + compat_bump->dvdnv*du; tco[2] = 0.f; @@ -1773,7 +1778,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, normalize_v3(tv); } - // +u val + /* +u val */ tco[0] = co[0] + tu[0]*du; tco[1] = co[1] + tu[1]*du; tco[2] = co[2] + tu[2]*du; @@ -1781,7 +1786,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, multitex_mtex(shi, mtex, texv, dxt, dyt, &ttexr); ud = idu*(cd - (fromrgb ? (ttexr.tr + ttexr.tg + ttexr.tb)*0.33333333f : ttexr.tin)); - // +v val + /* +v val */ tco[0] = co[0] + tv[0]*dv; tco[1] = co[1] + tv[1]*dv; tco[2] = co[2] + tv[2]*dv; @@ -1790,7 +1795,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, vd = idv*(cd - (fromrgb ? (ttexr.tr + ttexr.tg + ttexr.tb)*0.33333333f : ttexr.tin)); } - // bumped normal + /* bumped normal */ compat_bump->nu[0] += ud*compat_bump->nn[0]; compat_bump->nu[1] += ud*compat_bump->nn[1]; compat_bump->nu[2] += ud*compat_bump->nn[2]; @@ -1812,13 +1817,13 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, typedef struct NTapBump { int init_done; - int iPrevBumpSpace; // 0: uninitialized, 1: objectspace, 2: texturespace, 4: viewspace - // bumpmapping - float vNorg[3]; // backup copy of shi->vn - float vNacc[3]; // original surface normal minus the surface gradient of every bump map which is encountered - float vR1[3], vR2[3]; // cross products (sigma_y, original_normal), (original_normal, sigma_x) - float sgn_det; // sign of the determinant of the matrix {sigma_x, sigma_y, original_normal} - float fPrevMagnitude; // copy of previous magnitude, used for multiple bumps in different spaces + int iPrevBumpSpace; /* 0: uninitialized, 1: objectspace, 2: texturespace, 4: viewspace */ + /* bumpmapping */ + float vNorg[3]; /* backup copy of shi->vn */ + float vNacc[3]; /* original surface normal minus the surface gradient of every bump map which is encountered */ + float vR1[3], vR2[3]; /* cross products (sigma_y, original_normal), (original_normal, sigma_x) */ + float sgn_det; /* sign of the determinant of the matrix {sigma_x, sigma_y, original_normal} */ + float fPrevMagnitude; /* copy of previous magnitude, used for multiple bumps in different spaces */ } NTapBump; static void ntap_bump_init(NTapBump *ntap_bump) @@ -1828,38 +1833,38 @@ static void ntap_bump_init(NTapBump *ntap_bump) static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, Tex *tex, TexResult *texres, float Tnor, float *co, float *dx, float *dy, float *texvec, float *dxt, float *dyt) { - TexResult ttexr = {0, 0, 0, 0, 0, texres->talpha, NULL}; // temp TexResult + TexResult ttexr = {0, 0, 0, 0, 0, texres->talpha, NULL}; /* temp TexResult */ const int fromrgb = ((tex->type == TEX_IMAGE) || ((tex->flag & TEX_COLORBAND)!=0)); - // The negate on Hscale is done because the - // normal in the renderer points inward which corresponds - // to inverting the bump map. The normals are generated - // this way in calc_vertexnormals(). Should this ever change - // this negate must be removed. + /* The negate on Hscale is done because the + * normal in the renderer points inward which corresponds + * to inverting the bump map. The normals are generated + * this way in calc_vertexnormals(). Should this ever change + * this negate must be removed. */ float Hscale = -Tnor*mtex->norfac; int dimx=512, dimy=512; - const int imag_tspace_dimension_x = 1024; // only used for texture space variant + const int imag_tspace_dimension_x = 1024; /* only used for texture space variant */ float aspect = 1.0f; - // 2 channels for 2D texture and 3 for 3D textures. + /* 2 channels for 2D texture and 3 for 3D textures. */ const int nr_channels = (mtex->texco == TEXCO_UV)? 2 : 3; int c, rgbnor, iBumpSpace; float dHdx, dHdy; int found_deriv_map = (tex->type==TEX_IMAGE) && (tex->imaflag & TEX_DERIVATIVEMAP); - // disable internal bump eval in sampler, save pointer + /* disable internal bump eval in sampler, save pointer */ float *nvec = texres->nor; texres->nor = NULL; if (found_deriv_map==0) { if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { if (tex->ima) - Hscale *= 13.0f; // appears to be a sensible default value + Hscale *= 13.0f; /* appears to be a sensible default value */ } else - Hscale *= 0.1f; // factor 0.1 proved to look like the previous bump code + Hscale *= 0.1f; /* factor 0.1 proved to look like the previous bump code */ } if ( !ntap_bump->init_done ) { @@ -1871,7 +1876,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T ntap_bump->init_done = TRUE; } - // resolve image dimensions + /* resolve image dimensions */ if (found_deriv_map || (mtex->texflag&MTEX_BUMP_TEXTURESPACE)!=0) { ImBuf* ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser); if (ibuf) { @@ -1883,7 +1888,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T if (found_deriv_map) { float dBdu, dBdv, auto_bump = 1.0f; - float s = 1; // negate this if flipped texture coordinate + float s = 1; /* negate this if flipped texture coordinate */ texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt); rgbnor = multitex_mtex(shi, mtex, texvec, dxt, dyt, texres); @@ -1895,9 +1900,9 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T float fVirtDim = sqrtf(fabsf((float) (dimx*dimy)*mtex->size[0]*mtex->size[1])); auto_bump /= MAX2(fVirtDim, FLT_EPSILON); } - - // this variant using a derivative map is described here - // http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html + + /* this variant using a derivative map is described here + * http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html */ dBdu = auto_bump*Hscale*dimx*(2*texres->tr-1); dBdv = auto_bump*Hscale*dimy*(2*texres->tg-1); @@ -1905,32 +1910,32 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T dHdy = dBdu*dyt[0] + s * dBdv*dyt[1]; } else if (!(mtex->texflag & MTEX_5TAP_BUMP)) { - // compute height derivatives with respect to output image pixel coordinates x and y + /* compute height derivatives with respect to output image pixel coordinates x and y */ float STll[3], STlr[3], STul[3]; float Hll, Hlr, Hul; texco_mapping(shi, tex, mtex, co, dx, dy, texvec, dxt, dyt); for (c=0; ctr) : texres->tin; - // use ttexr for the other 2 taps + /* use ttexr for the other 2 taps */ multitex_mtex(shi, mtex, STlr, dxt, dyt, &ttexr); Hlr = (fromrgb) ? rgb_to_grayscale(&ttexr.tr) : ttexr.tin; @@ -1955,7 +1960,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T STu[c] = texvec[c] + 0.5f*dyt[c]; } - // clear unused derivatives + /* clear unused derivatives */ for (c=nr_channels; c<3; c++) { STc[c] = 0.0f; STl[c] = 0.0f; @@ -1964,11 +1969,11 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T STu[c] = 0.0f; } - // use texres for the center sample, set rgbnor + /* use texres for the center sample, set rgbnor */ rgbnor = multitex_mtex(shi, mtex, STc, dxt, dyt, texres); /* Hc = (fromrgb) ? rgb_to_grayscale(&texres->tr) : texres->tin; */ /* UNUSED */ - // use ttexr for the other taps + /* use ttexr for the other taps */ multitex_mtex(shi, mtex, STl, dxt, dyt, &ttexr); Hl = (fromrgb) ? rgb_to_grayscale(&ttexr.tr) : ttexr.tin; multitex_mtex(shi, mtex, STr, dxt, dyt, &ttexr); @@ -1982,7 +1987,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T dHdy = Hscale*(Hu - Hd); } - // restore pointer + /* restore pointer */ texres->nor = nvec; /* replaced newbump with code based on listing 1 and 2 of @@ -1994,32 +1999,32 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T else if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) iBumpSpace = 2; else - iBumpSpace = 4; // ViewSpace - + iBumpSpace = 4; /* ViewSpace */ + if ( ntap_bump->iPrevBumpSpace != iBumpSpace ) { - - // initialize normal perturbation vectors + + /* initialize normal perturbation vectors */ int xyz; float fDet, abs_fDet, fMagnitude; - // object2view and inverted matrix + /* object2view and inverted matrix */ float obj2view[3][3], view2obj[3][3], tmp[4][4]; - // local copies of derivatives and normal + /* local copies of derivatives and normal */ float dPdx[3], dPdy[3], vN[3]; copy_v3_v3(dPdx, shi->dxco); copy_v3_v3(dPdy, shi->dyco); copy_v3_v3(vN, ntap_bump->vNorg); if ( mtex->texflag & MTEX_BUMP_OBJECTSPACE ) { - // TODO: these calculations happen for every pixel! - // -> move to shi->obi + /* TODO: these calculations happen for every pixel! + * -> move to shi->obi */ mult_m4_m4m4(tmp, R.viewmat, shi->obr->ob->obmat); - copy_m3_m4(obj2view, tmp); // use only upper left 3x3 matrix + copy_m3_m4(obj2view, tmp); /* use only upper left 3x3 matrix */ invert_m3_m3(view2obj, obj2view); - - // generate the surface derivatives in object space + + /* generate the surface derivatives in object space */ mul_m3_v3(view2obj, dPdx); mul_m3_v3(view2obj, dPdy); - // generate the unit normal in object space + /* generate the unit normal in object space */ mul_transposed_m3_v3(obj2view, vN); normalize_v3(vN); } @@ -2032,7 +2037,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { if (tex->ima) { - // crazy hack solution that gives results similar to normal mapping - part 1 + /* crazy hack solution that gives results similar to normal mapping - part 1 */ normalize_v3(ntap_bump->vR1); normalize_v3(ntap_bump->vR2); abs_fDet = 1.0f; @@ -2041,7 +2046,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T fMagnitude = abs_fDet; if ( mtex->texflag & MTEX_BUMP_OBJECTSPACE ) { - // pre do transform of texres->nor by the inverse transposed of obj2view + /* pre do transform of texres->nor by the inverse transposed of obj2view */ mul_transposed_m3_v3(view2obj, vN); mul_transposed_m3_v3(view2obj, ntap_bump->vR1); mul_transposed_m3_v3(view2obj, ntap_bump->vR2); @@ -2059,7 +2064,7 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T if ( mtex->texflag & MTEX_BUMP_TEXTURESPACE ) { if (tex->ima) { - // crazy hack solution that gives results similar to normal mapping - part 2 + /* crazy hack solution that gives results similar to normal mapping - part 2 */ float vec[2]; const float imag_tspace_dimension_y = aspect*imag_tspace_dimension_x; @@ -2072,11 +2077,11 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T } } - // subtract the surface gradient from vNacc + /* subtract the surface gradient from vNacc */ for (c=0; c<3; c++) { float vSurfGrad_compi = ntap_bump->sgn_det * (dHdx * ntap_bump->vR1[c] + dHdy * ntap_bump->vR2[c]); ntap_bump->vNacc[c] -= vSurfGrad_compi; - texres->nor[c] = ntap_bump->vNacc[c]; // copy + texres->nor[c] = ntap_bump->vNacc[c]; /* copy */ } rgbnor |= TEX_NOR; @@ -2235,7 +2240,9 @@ void do_material_tex(ShadeInput *shi, Render *re) dy[0]= 0.0f; dy[1]= dy[2]= 0.0f; } - else continue; // can happen when texco defines disappear and it renders old files + else { + continue; /* can happen when texco defines disappear and it renders old files */ + } /* the pointer defines if bumping happens */ if (mtex->mapto & (MAP_NORM|MAP_WARP)) { @@ -2319,7 +2326,7 @@ void do_material_tex(ShadeInput *shi, Render *re) texres.nor[2]= f2*co_nor-f1*si; } } - // warping, local space + /* warping, local space */ if (mtex->mapto & MAP_WARP) { float *warpnor= texres.nor, warpnor_[3]; @@ -2335,11 +2342,11 @@ void do_material_tex(ShadeInput *shi, Render *re) } #if 0 if (mtex->texflag & MTEX_VIEWSPACE) { - // rotate to global coords + /* rotate to global coords */ if (mtex->texco==TEXCO_ORCO || mtex->texco==TEXCO_UV) { if (shi->vlr && shi->obr && shi->obr->ob) { float len= normalize_v3(texres.nor); - // can be optimized... (ton) + /* can be optimized... (ton) */ mul_mat3_m4_v3(shi->obr->ob->obmat, texres.nor); mul_mat3_m4_v3(re->viewmat, texres.nor); normalize_v3(texres.nor); @@ -2388,7 +2395,7 @@ void do_material_tex(ShadeInput *shi, Render *re) if (mtex->mapto & MAP_COLMIR) { float mirrfac= mtex->mirrfac*stencilTin; - // exception for envmap only + /* exception for envmap only */ if (tex->type==TEX_ENVMAP && mtex->blendtype==MTEX_BLEND) { fact= texres.tin*mirrfac; facm= 1.0f- fact; @@ -2565,7 +2572,7 @@ void do_material_tex(ShadeInput *shi, Render *re) else if (shi->alpha>1.0f) shi->alpha= 1.0f; } if (mtex->mapto & MAP_HAR) { - float har; // have to map to 0-1 + float har; /* have to map to 0-1 */ float hardfac= mtex->hardfac*stencilTin; har= ((float)shi->har)/128.0f; @@ -2605,7 +2612,7 @@ void do_material_tex(ShadeInput *shi, Render *re) } if ((use_compat_bump || use_ntap_bump || found_nmapping) && (shi->mat->mode & MA_TANGENT_V) != 0) { const float fnegdot = -dot_v3v3(shi->vn, shi->tang); - // apply Gram-Schmidt projection + /* apply Gram-Schmidt projection */ madd_v3_v3fl(shi->tang, shi->vn, fnegdot); normalize_v3(shi->tang); } @@ -2665,12 +2672,14 @@ void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float col_ copy_v3_v3(co, xyz); mul_m4_v3(re->viewinv, co); } - else continue; // can happen when texco defines disappear and it renders old files + else { + continue; /* can happen when texco defines disappear and it renders old files */ + } texres.nor= NULL; - if (tex->type==TEX_IMAGE) { - continue; /* not supported yet */ + if (tex->type == TEX_IMAGE) { + continue; /* not supported yet */ //do_2d_mapping(mtex, texvec, NULL, NULL, dxt, dyt); } else { @@ -3381,7 +3390,7 @@ int externtex(MTex *mtex, const float vec[3], float *tin, float *tr, float *tg, void render_realtime_texture(ShadeInput *shi, Image *ima) { TexResult texr; - static Tex imatex[BLENDER_MAX_THREADS]; // threadsafe + static Tex imatex[BLENDER_MAX_THREADS]; /* threadsafe */ static int firsttime= 1; Tex *tex; float texvec[3], dx[2], dy[2]; @@ -3409,7 +3418,7 @@ void render_realtime_texture(ShadeInput *shi, Image *ima) texvec[0]= 0.5f+0.5f*suv->uv[0]; texvec[1]= 0.5f+0.5f*suv->uv[1]; - texvec[2] = 0.0f; // initalize it because imagewrap looks at it. + texvec[2] = 0.0f; /* initalize it because imagewrap looks at it. */ if (shi->osatex) { dx[0]= 0.5f*suv->dxuv[0]; dx[1]= 0.5f*suv->dxuv[1]; diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 03bea0122cf..63aa6cdd139 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -2098,12 +2098,12 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int UNUSED(qua normalize_v3(nor); /* in case object has scaling */ - // The invert of the red channel is to make - // the normal map compliant with the outside world. - // It needs to be done because in Blender - // the normal used in the renderer points inward. It is generated - // this way in calc_vertexnormals(). Should this ever change - // this negate must be removed. + /* The invert of the red channel is to make + * the normal map compliant with the outside world. + * It needs to be done because in Blender + * the normal used in the renderer points inward. It is generated + * this way in calc_vertexnormals(). Should this ever change + * this negate must be removed. */ shr.combined[0]= (-nor[0])/2.0f + 0.5f; shr.combined[1]= nor[1]/2.0f + 0.5f; shr.combined[2]= nor[2]/2.0f + 0.5f; diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index 93587734e2b..f696f95781b 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -1561,9 +1561,9 @@ static void isb_bsp_split(ISBBranch *root, MemArena *mem) right= root->right= BLI_memarena_alloc(mem, sizeof(ISBBranch)); /* new sample array */ - left->samples= BLI_memarena_alloc(mem, BSPMAX_SAMPLE*sizeof(void *)); - right->samples= samples; // tmp - + left->samples = BLI_memarena_alloc(mem, BSPMAX_SAMPLE*sizeof(void *)); + right->samples = samples; /* tmp */ + /* split samples */ for (a=BSPMAX_SAMPLE-1; a>=0; a--) { int comp= 0; diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index f9b0de5b87d..5e80370a6f0 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -818,7 +818,7 @@ void shade_input_set_normals(ShadeInput *shi) shi->vn[1]= l*n3[1]-u*n1[1]-v*n2[1]; shi->vn[2]= l*n3[2]-u*n1[2]-v*n2[2]; - // use unnormalized normal (closer to games) + /* use unnormalized normal (closer to games) */ copy_v3_v3(shi->nmapnorm, shi->vn); normalize_v3(shi->vn); @@ -851,7 +851,7 @@ void shade_input_set_vertex_normals(ShadeInput *shi) shi->vn[1]= l*n3[1]-u*n1[1]-v*n2[1]; shi->vn[2]= l*n3[2]-u*n1[2]-v*n2[2]; - // use unnormalized normal (closer to games) + /* use unnormalized normal (closer to games) */ copy_v3_v3(shi->nmapnorm, shi->vn); normalize_v3(shi->vn); @@ -968,22 +968,22 @@ void shade_input_set_shade_texco(ShadeInput *shi) copy_v3_v3(c1, &tangent[j2*4]); copy_v3_v3(c2, &tangent[j3*4]); - // keeping tangents normalized at vertex level - // corresponds better to how it's done in game engines + /* keeping tangents normalized at vertex level + * corresponds better to how it's done in game engines */ if (obi->flag & R_TRANSFORMED) { mul_mat3_m4_v3(obi->mat, c0); normalize_v3(c0); mul_mat3_m4_v3(obi->mat, c1); normalize_v3(c1); mul_mat3_m4_v3(obi->mat, c2); normalize_v3(c2); } - - // we don't normalize the interpolated TBN tangent - // corresponds better to how it's done in game engines + + /* we don't normalize the interpolated TBN tangent + * corresponds better to how it's done in game engines */ shi->nmaptang[0]= (tl*c2[0] - tu*c0[0] - tv*c1[0]); shi->nmaptang[1]= (tl*c2[1] - tu*c0[1] - tv*c1[1]); shi->nmaptang[2]= (tl*c2[2] - tu*c0[2] - tv*c1[2]); - // the sign is the same for all 3 vertices of any - // non degenerate triangle. + /* the sign is the same for all 3 vertices of any + * non degenerate triangle. */ shi->nmaptang[3]= tangent[j1*4+3]; } } diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index b208df74de9..e209baa49a8 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -173,7 +173,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) p1[1]= shi->co[1]-lar->co[1]; p1[2]= -lar->co[2]; mul_m3_v3(lar->imat, p1); - copy_v3db_v3fl(npos, p1); // npos is double! + copy_v3db_v3fl(npos, p1); /* npos is double! */ /* pre-scale */ npos[2] *= (double)lar->sh_zfac; @@ -371,11 +371,12 @@ void renderspothalo(ShadeInput *shi, float col[4], float alpha) continue; spothalo(lar, shi, &i); - if (i>0.0f) { - col[3]+= i*alpha; // all premul - col[0]+= i*lar->r*alpha; - col[1]+= i*lar->g*alpha; - col[2]+= i*lar->b*alpha; + if (i > 0.0f) { + const float i_alpha = i * alpha; + col[0] += i_alpha * lar->r; + col[1] += i_alpha * lar->g; + col[2] += i_alpha * lar->b; + col[3] += i_alpha; /* all premul */ } } } @@ -519,7 +520,7 @@ static float area_lamp_energy_multisample(LampRen *lar, const float co[3], float } intens /= (float)lar->ray_totsamp; - return pow(intens*lar->areasize, lar->k); // corrected for buttons size and lar->dist^2 + return pow(intens * lar->areasize, lar->k); /* corrected for buttons size and lar->dist^2 */ } static float spec(float inp, int hard) @@ -932,7 +933,7 @@ static void add_to_diffuse(float *diff, ShadeInput *shi, float is, float r, floa /* MA_RAMP_IN_RESULT is exceptional */ if (ma->rampin_col==MA_RAMP_IN_RESULT) { - // normal add + /* normal add */ diff[0] += r * shi->r; diff[1] += g * shi->g; diff[2] += b * shi->b; @@ -1368,10 +1369,10 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int /* diffuse shaders */ if (lar->mode & LA_NO_DIFF) { - is= 0.0f; // skip shaders + is = 0.0f; /* skip shaders */ } else if (lar->type==LA_HEMI) { - is= 0.5f*inp + 0.5f; + is = 0.5f * inp + 0.5f; } else { @@ -1383,12 +1384,13 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int else if (ma->diff_shader==MA_DIFF_TOON) is= Toon_Diff(vn, lv, view, ma->param[0], ma->param[1]); else if (ma->diff_shader==MA_DIFF_MINNAERT) is= Minnaert_Diff(inp, vn, view, ma->darkness); else if (ma->diff_shader==MA_DIFF_FRESNEL) is= Fresnel_Diff(vn, lv, view, ma->param[0], ma->param[1]); - else is= inp; // Lambert + else is= inp; /* Lambert */ } - + /* 'is' is diffuse */ - if ((ma->shade_flag & MA_CUBIC) && is>0.0f && is<1.0f) - is= 3.0f*is*is - 2.0f*is*is*is; // nicer termination of shades + if ((ma->shade_flag & MA_CUBIC) && is > 0.0f && is < 1.0f) { + is= 3.0f * is * is - 2.0f * is * is * is; /* nicer termination of shades */ + } i= is*phongcorr; @@ -1397,7 +1399,7 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int } i_noshad= i; - vn= shi->vn; // bring back original vector, we use special specular shaders for tangent + vn = shi->vn; /* bring back original vector, we use special specular shaders for tangent */ if (ma->mode & MA_TANGENT_V) vn= shi->tang; @@ -1728,7 +1730,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) return; } - if ( (ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP))== MA_VERTEXCOL ) { // vertexcolor light + if ( (ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP))== MA_VERTEXCOL ) { /* vertexcolor light */ shr->emit[0]= shi->r*(shi->emit+shi->vcol[0]*shi->vcol[3]); shr->emit[1]= shi->g*(shi->emit+shi->vcol[1]*shi->vcol[3]); shr->emit[2]= shi->b*(shi->emit+shi->vcol[2]*shi->vcol[3]); @@ -1749,8 +1751,8 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) if (shi->depth || shi->volume_depth) ambient_occlusion(shi); copy_v3_v3(shr->ao, shi->ao); - copy_v3_v3(shr->env, shi->env); // XXX multiply - copy_v3_v3(shr->indirect, shi->indirect); // XXX multiply + copy_v3_v3(shr->env, shi->env); /* XXX multiply */ + copy_v3_v3(shr->indirect, shi->indirect); /* XXX multiply */ } } } diff --git a/source/blender/render/intern/source/sunsky.c b/source/blender/render/intern/source/sunsky.c index eeefaae856a..ddc7dff7b06 100644 --- a/source/blender/render/intern/source/sunsky.c +++ b/source/blender/render/intern/source/sunsky.c @@ -272,7 +272,7 @@ void GetSkyXYZRadiance(struct SunSky *sunsky, float theta, float phi, float colo gamma = AngleBetween(theta, phi, sunsky->theta, sunsky->phi); - // Compute xyY values + /* Compute xyY values */ x = PerezFunction(sunsky, sunsky->perez_x, theta, gamma, sunsky->zenith_x); y = PerezFunction(sunsky, sunsky->perez_y, theta, gamma, sunsky->zenith_y); Y = 6.666666667e-5f *nfade *hfade *PerezFunction(sunsky, sunsky->perez_Y, theta, gamma, sunsky->zenith_Y); @@ -366,7 +366,7 @@ void InitAtmosphere(struct SunSky *sunSky, float sun_intens, float mief, float r float inscattf, float extincf, float disf) { const float pi = M_PI; - const float n = 1.003f; // refractive index + const float n = 1.003f; /* refractive index */ const float N = 2.545e25; const float pn = 0.035f; const float T = 2.0f; @@ -406,16 +406,16 @@ void InitAtmosphere(struct SunSky *sunSky, float sun_intens, float mief, float r vLambda4[1] = fLambda4[1]; vLambda4[2] = fLambda4[2]; - // Rayleigh scattering constants. + /* Rayleigh scattering constants. */ fTemp = pi * pi * (n * n - 1) * (n * n - 1) * (6 + 3 * pn) / (6 - 7 * pn) / N; fBeta = 8 * fTemp * pi / 3; - + VEC3OPF(sunSky->atm_BetaRay, vLambda4, *, fBeta); fBetaDash = fTemp / 2; VEC3OPF(sunSky->atm_BetaDashRay, vLambda4, *, fBetaDash); - - // Mie scattering constants. + + /* Mie scattering constants. */ fTemp2 = 0.434f * c * (2 * pi) * (2 * pi) * 0.5f; VEC3OPF(sunSky->atm_BetaDashMie, vLambda2, *, fTemp2); diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c index c342f179bd1..8a92695a15e 100644 --- a/source/blender/render/intern/source/volume_precache.c +++ b/source/blender/render/intern/source/volume_precache.c @@ -465,7 +465,7 @@ static void multiple_scattering_diffusion(Render *re, VolumePrecache *vp, Materi -#if 0 // debug stuff +#if 0 /* debug stuff */ static void *vol_precache_part_test(void *data) { VolPrecachePart *pa = data; diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c index e0d3325106a..67e453577e4 100644 --- a/source/blender/render/intern/source/volumetric.c +++ b/source/blender/render/intern/source/volumetric.c @@ -289,7 +289,7 @@ float vol_get_density(struct ShadeInput *shi, const float co[3]) if (shi->mat->mapto_textured & MAP_DENSITY) do_volume_tex(shi, co, MAP_DENSITY, NULL, &density, &R); - // if meta-object, modulate by metadensity without increasing it + /* if meta-object, modulate by metadensity without increasing it */ if (shi->obi->obr->ob->type == OB_MBALL) { const float md = metadensity(shi->obi->obr->ob, co); if (md < 1.f) density *= md; diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c index ee766311a33..d73171648fb 100644 --- a/source/blender/render/intern/source/voxeldata.c +++ b/source/blender/render/intern/source/voxeldata.c @@ -290,7 +290,7 @@ static void init_frame_smoke(VoxelData *vd, float cfra) /* always store copy, as smoke internal data can change */ vd->dataset = MEM_mapallocN(sizeof(float) * (totRes), "smoke data"); memcpy(vd->dataset, density, sizeof(float) * totRes); - } // end of fluid condition + } /* end of fluid condition */ } } diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index fc3dae73d6b..1ebb963a790 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -466,7 +466,7 @@ static void zbuflineAc(ZSpan *zspan, int obi, int zvlnr, const float vec1[3], co vergz= v1[2]; vergz-= zspan->polygon_offset; dz= (v2[2]-v1[2])/dx; - if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow + if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */ rectz= (int *)(zspan->arectz+zspan->rectx*(oldy) +start); rectmask= (int *)(zspan->rectmask+zspan->rectx*(oldy) +start); @@ -537,7 +537,7 @@ static void zbuflineAc(ZSpan *zspan, int obi, int zvlnr, const float vec1[3], co vergz= v1[2]; vergz-= zspan->polygon_offset; dz= (v2[2]-v1[2])/dy; - if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow + if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */ rectz= (int *)( zspan->arectz+ (start)*zspan->rectx+ oldx ); rectmask= (int *)( zspan->rectmask+ (start)*zspan->rectx+ oldx ); @@ -619,7 +619,7 @@ static void zbufline(ZSpan *zspan, int obi, int zvlnr, const float vec1[3], cons vergz= floor(v1[2]); dz= floor((v2[2]-v1[2])/dx); - if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow + if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */ rectz= zspan->rectz + oldy*zspan->rectx+ start; rectp= zspan->rectp + oldy*zspan->rectx+ start; @@ -678,7 +678,7 @@ static void zbufline(ZSpan *zspan, int obi, int zvlnr, const float vec1[3], cons vergz= floor(v1[2]); dz= floor((v2[2]-v1[2])/dy); - if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow + if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */ rectz= zspan->rectz + start*zspan->rectx+ oldx; rectp= zspan->rectp + start*zspan->rectx+ oldx; @@ -749,7 +749,7 @@ static void zbufline_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr), con vergz= floor(v1[2]); dz= floor((v2[2]-v1[2])/dx); - if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow + if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */ rectz= zspan->rectz + oldy*zspan->rectx+ start; if (zspan->rectz1) @@ -806,8 +806,8 @@ static void zbufline_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr), con vergz= floor(v1[2]); dz= floor((v2[2]-v1[2])/dy); - if (vergz>0x50000000 && dz>0) maxtest= 1; // prevent overflow - + if (vergz>0x50000000 && dz>0) maxtest= 1; /* prevent overflow */ + rectz= zspan->rectz + start*zspan->rectx+ oldx; if (zspan->rectz1) rectz1= zspan->rectz1 + start*zspan->rectx+ oldx; diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index 039f3bff4d1..bb985802e23 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -191,7 +191,7 @@ void WM_cursor_grab(wmWindow *win, int wrap, int hide, int *bounds) if ((G.debug & G_DEBUG) == 0) { if (win && win->ghostwin) { const GHOST_TabletData *tabletdata = GHOST_GetTabletData(win->ghostwin); - // Note: There is no tabletdata on Windows if no tablet device is connected. + /* Note: There is no tabletdata on Windows if no tablet device is connected. */ if (!tabletdata) GHOST_SetCursorGrab(win->ghostwin, mode, bounds); else if (tabletdata->Active == GHOST_kTabletModeNone) -- cgit v1.2.3