diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-07-09 14:33:09 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-07-09 14:33:09 +0400 |
commit | ffd99470015e3fb9a3246ec7a4c112b8eca3b17d (patch) | |
tree | 3824e2c3b4df0785e94e47750de5daf8e43218a7 /source/blender | |
parent | cb72095090217a40131a4481927290d6e6c49222 (diff) | |
parent | 0966a3b191f124eb2fd7a7241c860feaad65ef7a (diff) |
Merging r48740 through r48749 from trunk into soc-2011-tomato
Diffstat (limited to 'source/blender')
22 files changed, 728 insertions, 727 deletions
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index 18932ffdac8..364d5f90af3 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -40,10 +40,10 @@ void BLF_exit(void); void BLF_cache_clear(void); int BLF_load(const char *name); -int BLF_load_mem(const char *name, unsigned char *mem, int mem_size); +int BLF_load_mem(const char *name, const unsigned char *mem, int mem_size); int BLF_load_unique(const char *name); -int BLF_load_mem_unique(const char *name, unsigned char *mem, int mem_size); +int BLF_load_mem_unique(const char *name, const unsigned char *mem, int mem_size); void BLF_unload(const char *name); diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 70794a11ff2..683ef3f821c 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -227,7 +227,7 @@ void BLF_metrics_attach(int fontid, unsigned char *mem, int mem_size) } } -int BLF_load_mem(const char *name, unsigned char *mem, int mem_size) +int BLF_load_mem(const char *name, const unsigned char *mem, int mem_size) { FontBLF *font; int i; @@ -262,7 +262,7 @@ int BLF_load_mem(const char *name, unsigned char *mem, int mem_size) return i; } -int BLF_load_mem_unique(const char *name, unsigned char *mem, int mem_size) +int BLF_load_mem_unique(const char *name, const unsigned char *mem, int mem_size) { FontBLF *font; int i; diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 6ab942f4e4d..945565e22a9 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -560,12 +560,12 @@ void blf_font_attach_from_mem(FontBLF *font, const unsigned char *mem, int mem_s FT_Open_Args open; open.flags = FT_OPEN_MEMORY; - open.memory_base = (FT_Byte *)mem; + open.memory_base = (const FT_Byte *)mem; open.memory_size = mem_size; FT_Attach_Stream(font->face, &open); } -FontBLF *blf_font_new_from_mem(const char *name, unsigned char *mem, int mem_size) +FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int mem_size) { FontBLF *font; FT_Error err; diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h index f43fa8a7458..ba66fce8374 100644 --- a/source/blender/blenfont/intern/blf_internal.h +++ b/source/blender/blenfont/intern/blf_internal.h @@ -47,7 +47,7 @@ int blf_font_init(void); void blf_font_exit(void); struct FontBLF *blf_font_new(const char *name, const char *filename); -struct FontBLF *blf_font_new_from_mem(const char *name, unsigned char *mem, int mem_size); +struct FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int mem_size); void blf_font_attach_from_mem(struct FontBLF *font, const unsigned char *mem, int mem_size); void blf_font_size(struct FontBLF *font, int size, int dpi); diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 488b5901071..de367b6b4d0 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -322,6 +322,8 @@ typedef struct MovieClipCache { /* cache for stable shot */ struct { + ImBuf *reference_ibuf; + ImBuf *ibuf; int framenr; int postprocess_flag; @@ -695,9 +697,6 @@ static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *u MovieTrackingCamera *camera = &clip->tracking.camera; ImBuf *postproc_ibuf = NULL; - if (cache->postprocessed.ibuf) - IMB_freeImBuf(cache->postprocessed.ibuf); - cache->postprocessed.framenr = user->framenr; cache->postprocessed.flag = postprocess_flag; @@ -735,13 +734,10 @@ static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *u IMB_refImBuf(postproc_ibuf); - cache->postprocessed.ibuf = postproc_ibuf; + if (cache->postprocessed.ibuf) + IMB_freeImBuf(cache->postprocessed.ibuf); - if (cache->stabilized.ibuf) { - /* force stable buffer be re-calculated */ - IMB_freeImBuf(cache->stabilized.ibuf); - cache->stabilized.ibuf = NULL; - } + cache->postprocessed.ibuf = postproc_ibuf; return postproc_ibuf; } @@ -817,7 +813,8 @@ ImBuf *BKE_movieclip_get_postprocessed_ibuf(MovieClip *clip, MovieClipUser *user return movieclip_get_postprocessed_ibuf(clip, user, clip->flag, postprocess_flag, 0); } -static ImBuf *get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, int framenr, int postprocess_flag) +static ImBuf *get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, ImBuf *reference_ibuf, + int framenr, int postprocess_flag) { MovieClipCache *cache = clip->cache; MovieTracking *tracking = &clip->tracking; @@ -836,6 +833,9 @@ static ImBuf *get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, int if (!cache->stabilized.ibuf || cache->stabilized.framenr != framenr) return NULL; + if (cache->stabilized.reference_ibuf != reference_ibuf) + return NULL; + /* cached ibuf used different proxy settings */ if (cache->stabilized.render_flag != render_flag || cache->stabilized.proxy != proxy) return NULL; @@ -876,13 +876,8 @@ static ImBuf *put_stabilized_frame_to_cache(MovieClip *clip, MovieClipUser *user float tloc[2], tscale, tangle; int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, framenr); - if (cache->stabilized.ibuf) - IMB_freeImBuf(cache->stabilized.ibuf); - stableibuf = BKE_tracking_stabilize_frame(&clip->tracking, clip_framenr, ibuf, tloc, &tscale, &tangle); - cache->stabilized.ibuf = stableibuf; - copy_v2_v2(cache->stabilized.loc, tloc); cache->stabilized.scale = tscale; @@ -902,6 +897,11 @@ static ImBuf *put_stabilized_frame_to_cache(MovieClip *clip, MovieClipUser *user cache->stabilized.postprocess_flag = postprocess_flag; + if (cache->stabilized.ibuf) + IMB_freeImBuf(cache->stabilized.ibuf); + + cache->stabilized.ibuf = stableibuf; + IMB_refImBuf(stableibuf); return stableibuf; @@ -921,7 +921,7 @@ ImBuf *BKE_movieclip_get_stable_ibuf(MovieClip *clip, MovieClipUser *user, float if (clip->tracking.stabilization.flag & TRACKING_2D_STABILIZATION) { MovieClipCache *cache = clip->cache; - stableibuf = get_stable_cached_frame(clip, user, framenr, postprocess_flag); + stableibuf = get_stable_cached_frame(clip, user, ibuf, framenr, postprocess_flag); if (!stableibuf) stableibuf = put_stabilized_frame_to_cache(clip, user, ibuf, framenr, postprocess_flag); diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index b6a56e64dcf..f22c25766df 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -193,12 +193,11 @@ BMLoop *BM_loop_other_vert_loop(BMLoop *l, BMVert *v) * Get the first loop of a vert. Uses the same initialization code for the first loop of the * iterator API */ - BMLoop *BM_vert_find_first_loop(BMVert *v) { BMEdge *e; - if(!v || !v->e) + if (!v || !v->e) return NULL; e = bmesh_disk_faceedge_find_first(v->e, v); @@ -208,7 +207,6 @@ BMLoop *BM_vert_find_first_loop(BMVert *v) /** * Returns TRUE if the vertex is used in a given face. */ - int BM_vert_in_face(BMFace *f, BMVert *v) { BMLoop *l_iter, *l_first; diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp index f11ecc7f16d..1eee797b51c 100644 --- a/source/blender/collada/EffectExporter.cpp +++ b/source/blender/collada/EffectExporter.cpp @@ -173,7 +173,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob) { // create a list of indices to textures of type TEX_IMAGE std::vector<int> tex_indices; - if(this->export_settings->include_material_textures) + if (this->export_settings->include_material_textures) createTextureIndices(ma, tex_indices); openEffect(translate_id(id_name(ma)) + "-effect"); diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index eb02fc97596..07f3498580c 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -180,6 +180,3 @@ void mesh_deform_bind(struct Scene *scene, #endif #endif /* __ED_ARMATURE_H__ */ - - - diff --git a/source/blender/editors/space_view3d/drawanimviz.c b/source/blender/editors/space_view3d/drawanimviz.c index 4fc3edb521e..5f312ff7fca 100644 --- a/source/blender/editors/space_view3d/drawanimviz.c +++ b/source/blender/editors/space_view3d/drawanimviz.c @@ -43,7 +43,6 @@ #include "DNA_view3d_types.h" #include "DNA_object_types.h" -#include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_dlrbTree.h" @@ -64,8 +63,8 @@ /* ************************************ Motion Paths ************************************* */ /* TODO: - * - options to draw paths with lines - * - include support for editing the path verts */ + * - options to draw paths with lines + * - include support for editing the path verts */ /* Set up drawing environment for drawing motion paths */ void draw_motion_paths_init(View3D *v3d, ARegion *ar) @@ -80,7 +79,7 @@ void draw_motion_paths_init(View3D *v3d, ARegion *ar) /* Draw the given motion path for an Object or a Bone * - assumes that the viewport has already been initialized properly - * i.e. draw_motion_paths_init() has been called + * i.e. draw_motion_paths_init() has been called */ void draw_motion_path_instance(Scene *scene, Object *ob, bPoseChannel *pchan, bAnimVizSettings *avs, bMotionPath *mpath) @@ -135,10 +134,10 @@ void draw_motion_path_instance(Scene *scene, /* draw curve-line of path */ glShadeModel(GL_SMOOTH); - glBegin(GL_LINE_STRIP); + glBegin(GL_LINE_STRIP); for (i = 0, mpv = mpv_start; i < len; i++, mpv++) { short sel = (pchan) ? (pchan->bone->flag & BONE_SELECTED) : (ob->flag & SELECT); - float intensity; /* how faint */ + float intensity; /* how faint */ /* set color * - more intense for active/selected bones, less intense for unselected bones @@ -223,7 +222,7 @@ void draw_motion_path_instance(Scene *scene, UI_ThemeColor(TH_TEXT_HI); } - // XXX, this isn't up to date but probably should be kept so. + /* XXX, this isn't up to date but probably should be kept so. */ invert_m4_m4(ob->imat, ob->obmat); /* Draw frame numbers at each framestep value */ diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index cdaf7d5690f..48b3672c144 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -686,13 +686,13 @@ static void draw_sphere_bone_dist(float smat[][4], float imat[][4], bPoseChannel tailvec = headvec; tail = head; zero_v3(dirvec); - dirvec[0] = 0.00001; // XXX. weak but ok + dirvec[0] = 0.00001; /* XXX. weak but ok */ } else if (tail - view_dist > head) { headvec = tailvec; head = tail; zero_v3(dirvec); - dirvec[0] = 0.00001; // XXX. weak but ok + dirvec[0] = 0.00001; /* XXX. weak but ok */ } } @@ -1019,7 +1019,7 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned /* Draw root point if we are not connected */ if ((boneflag & BONE_CONNECTED) == 0) { - if (G.f & G_PICKSEL) { // no bitmap in selection mode, crashes 3d cards... + if (G.f & G_PICKSEL) { /* no bitmap in selection mode, crashes 3d cards... */ glLoadName(id | BONESEL_ROOT); glBegin(GL_POINTS); glVertex3f(0.0f, 0.0f, 0.0f); @@ -1151,7 +1151,7 @@ static void draw_b_bone(const short dt, int armflag, int boneflag, short constfl glScalef(length, length, length); draw_bone_points(dt, armflag, boneflag, id); glPopMatrix(); - length *= 0.95f; // make vertices visible + length *= 0.95f; /* make vertices visible */ } /* colors for modes */ @@ -1225,7 +1225,7 @@ static void draw_wire_bone_segments(bPoseChannel *pchan, Mat4 *bbones, float len glBegin(GL_LINES); glVertex3f(0.0f, 0.0f, 0.0f); glVertex3f(0.0f, dlen, 0.0f); - glEnd(); // GL_LINES + glEnd(); /* GL_LINES */ glPopMatrix(); } @@ -1266,7 +1266,7 @@ static void draw_wire_bone(const short dt, int armflag, int boneflag, short cons glScalef(length, length, length); draw_bone_points(dt, armflag, boneflag, id); glPopMatrix(); - length *= 0.95f; // make vertices visible + length *= 0.95f; /* make vertices visible */ } /* this chunk not in object mode */ @@ -1416,7 +1416,9 @@ static void pchan_draw_IK_root_lines(bPoseChannel *pchan, short only_temp) /* Find the chain's root */ while (parchan->parent) { segcount++; - if (segcount == data->rootbone || segcount > 255) break; // 255 is weak + if (segcount == data->rootbone || segcount > 255) { + break; /* 255 is weak */ + } parchan = parchan->parent; } if (parchan) @@ -1440,13 +1442,13 @@ static void pchan_draw_IK_root_lines(bPoseChannel *pchan, short only_temp) /* Find the chain's root */ while (parchan->parent) { segcount++; - // FIXME: revise the breaking conditions - if (segcount == data->chainlen || segcount > 255) break; // 255 is weak + /* FIXME: revise the breaking conditions */ + if (segcount == data->chainlen || segcount > 255) break; /* 255 is weak */ parchan = parchan->parent; } - if (parchan) // XXX revise the breaking conditions to only stop at the tail? + if (parchan) /* XXX revise the breaking conditions to only stop at the tail? */ glVertex3fv(parchan->pose_head); - + glEnd(); setlinestyle(0); } @@ -1594,7 +1596,7 @@ static void draw_pose_dofs(Object *ob) theta = RAD2DEGF(0.5f * (pchan->limitmin[2] + pchan->limitmax[2])); glRotatef(theta, 0.0f, 0.0f, 1.0f); - glColor3ub(50, 50, 255); // blue, Z axis limit + glColor3ub(50, 50, 255); /* blue, Z axis limit */ glBegin(GL_LINE_STRIP); for (a = -16; a <= 16; a++) { /* *0.5f here comes from M_PI/360.0f when rotations were still in degrees */ @@ -1611,14 +1613,14 @@ static void draw_pose_dofs(Object *ob) glEnd(); glRotatef(-theta, 0.0f, 0.0f, 1.0f); - } + } if (pchan->ikflag & BONE_IK_XLIMIT) { /* OpenGL requires rotations in degrees; so we're taking the average angle here */ theta = RAD2DEGF(0.5f * (pchan->limitmin[0] + pchan->limitmax[0])); glRotatef(theta, 1.0f, 0.0f, 0.0f); - glColor3ub(255, 50, 50); // Red, X axis limit + glColor3ub(255, 50, 50); /* Red, X axis limit */ glBegin(GL_LINE_STRIP); for (a = -16; a <= 16; a++) { /* *0.5f here comes from M_PI/360.0f when rotations were still in degrees */ @@ -1792,7 +1794,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, } if (index != -1) - index += 0x10000; // pose bones count in higher 2 bytes only + index += 0x10000; /* pose bones count in higher 2 bytes only */ } /* very very confusing... but in object mode, solid draw, we cannot do glLoadName yet, @@ -1861,7 +1863,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, } if (index != -1) - index += 0x10000; // pose bones count in higher 2 bytes only + index += 0x10000; /* pose bones count in higher 2 bytes only */ } /* stick or wire bones have not been drawn yet so don't clear object selection in this case */ if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE) == 0 && draw_wire) { @@ -1900,11 +1902,11 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, const short constflag = pchan->constflag; if ((do_dashed & 1) && (pchan->parent)) { /* Draw a line from our root to the parent's tip - * - only if V3D_HIDE_HELPLINES is enabled... + * - only if V3D_HIDE_HELPLINES is enabled... */ if ( (do_dashed & 2) && ((bone->flag & BONE_CONNECTED) == 0) ) { if (arm->flag & ARM_POSEMODE) { - glLoadName(index & 0xFFFF); // object tag, for bordersel optim + glLoadName(index & 0xFFFF); /* object tag, for bordersel optim */ UI_ThemeColor(TH_WIRE); } setlinestyle(3); @@ -1922,15 +1924,15 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, if (constflag & PCHAN_HAS_IK) { if (bone->flag & BONE_SELECTED) { if (constflag & PCHAN_HAS_TARGET) glColor3ub(200, 120, 0); - else glColor3ub(200, 200, 50); // add theme! - + else glColor3ub(200, 200, 50); /* add theme! */ + glLoadName(index & 0xFFFF); pchan_draw_IK_root_lines(pchan, !(do_dashed & 2)); } } else if (constflag & PCHAN_HAS_SPLINEIK) { if (bone->flag & BONE_SELECTED) { - glColor3ub(150, 200, 50); // add theme! + glColor3ub(150, 200, 50); /* add theme! */ glLoadName(index & 0xFFFF); pchan_draw_IK_root_lines(pchan, !(do_dashed & 2)); @@ -2205,7 +2207,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt) /* offset to parent */ if (eBone->parent) { UI_ThemeColor(TH_WIRE); - glLoadName(-1); // -1 here is OK! + glLoadName(-1); /* -1 here is OK! */ setlinestyle(3); glBegin(GL_LINES); @@ -2227,7 +2229,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt) /* finally names and axes */ if (arm->flag & (ARM_DRAWNAMES | ARM_DRAWAXES)) { - // patch for several 3d cards (IBM mostly) that crash on GL_SELECT with text drawing + /* patch for several 3d cards (IBM mostly) that crash on GL_SELECT with text drawing */ if ((G.f & G_PICKSEL) == 0) { float vec[3]; unsigned char col[4]; @@ -2574,7 +2576,7 @@ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, const float white[4] = {1.0f, 1.0f, 1.0f, 1.0f}; glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white); glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); - glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); // only for lighting... + glFrontFace((ob->transflag & OB_NEG_SCALE) ? GL_CW : GL_CCW); /* only for lighting... */ } /* arm->flag is being used to detect mode... */ diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 19696b2b0e0..38109c3048e 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -71,7 +71,7 @@ #include "ED_mesh.h" #include "ED_uvedit.h" -#include "view3d_intern.h" // own include +#include "view3d_intern.h" /* own include */ /* user data structures for derived mesh callbacks */ typedef struct drawMeshFaceSelect_userData { @@ -214,7 +214,7 @@ void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm) dm->drawMappedEdges(dm, draw_mesh_face_select__setSelectOpts, &data); setlinestyle(0); - bglPolygonOffset(rv3d->dist, 0.0); // resets correctly now, even after calling accumulated offsets + bglPolygonOffset(rv3d->dist, 0.0); /* resets correctly now, even after calling accumulated offsets */ BLI_edgehash_free(data.eh, NULL); } @@ -223,7 +223,7 @@ void draw_mesh_face_select(RegionView3D *rv3d, Mesh *me, DerivedMesh *dm) static Material *give_current_material_or_def(Object *ob, int matnr) { - extern Material defmaterial; // render module abuse... + extern Material defmaterial; /* render module abuse... */ Material *ma = give_current_material(ob, matnr); return ma ? ma : &defmaterial; @@ -248,7 +248,7 @@ static int set_draw_settings_cached(int clearcache, MTFace *texface, Material *m static int c_lit; static int c_has_texface; - Object *litob = NULL; //to get mode to turn off mipmap in painting mode + Object *litob = NULL; /* to get mode to turn off mipmap in painting mode */ int backculled = GEMAT_BACKCULL; int alphablend = 0; int textured = 0; @@ -317,7 +317,7 @@ static int set_draw_settings_cached(int clearcache, MTFace *texface, Material *m if (lit != c_lit || ma != c_ma) { if (lit) { float spec[4]; - if (!ma) ma = give_current_material_or_def(NULL, 0); //default material + if (!ma) ma = give_current_material_or_def(NULL, 0); /* default material */ spec[0] = ma->spec * ma->specr; spec[1] = ma->spec * ma->specg; @@ -345,7 +345,7 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, O unsigned char obcol[4]; int is_tex, solidtex; - // XXX scene->obedit warning + /* XXX scene->obedit warning */ /* texture draw is abused for mask selection mode, do this so wire draw * with face selection in weight paint is not lit. */ @@ -705,8 +705,8 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl) - // The BM_FONT handling is in the gpu module, shared with the - // game engine, was duplicated previously + /* The BM_FONT handling is in the gpu module, shared with the + * game engine, was duplicated previously */ set_property_valstr(prop, string); characters = strlen(string); @@ -1062,7 +1062,7 @@ void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *d * rather than the shading, this is also forced in wire view */ bglPolygonOffset(rv3d->dist, 1.0); - glDepthMask(0); // disable write in zbuffer, selected edge wires show better + glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */ glEnable(GL_BLEND); glColor4ub(255, 255, 255, 96); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 7f7970382bc..b651dfcb8db 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -35,7 +35,7 @@ #include "DNA_camera_types.h" #include "DNA_curve_types.h" -#include "DNA_constraint_types.h" // for drawing constraint +#include "DNA_constraint_types.h" /* for drawing constraint */ #include "DNA_lamp_types.h" #include "DNA_lattice_types.h" #include "DNA_material_types.h" @@ -56,10 +56,10 @@ #include "BLI_rand.h" #include "BLI_utildefines.h" -#include "BKE_anim.h" //for the where_on_path function +#include "BKE_anim.h" /* for the where_on_path function */ #include "BKE_armature.h" #include "BKE_camera.h" -#include "BKE_constraint.h" // for the get_constraint_target function +#include "BKE_constraint.h" /* for the get_constraint_target function */ #include "BKE_curve.h" #include "BKE_DerivedMesh.h" #include "BKE_deform.h" @@ -108,7 +108,7 @@ #include "wm_subwindow.h" #include "BLF_api.h" -#include "view3d_intern.h" // own include +#include "view3d_intern.h" /* own include */ typedef enum eWireDrawMode { OBDRAW_WIRE_OFF = 0, @@ -2781,7 +2781,7 @@ static void draw_em_fancy_verts(Scene *scene, View3D *v3d, Object *obedit, ToolSettings *ts = scene->toolsettings; int sel; - if (v3d->zbuf) glDepthMask(0); // disable write in zbuffer, zbuf select + if (v3d->zbuf) glDepthMask(0); /* disable write in zbuffer, zbuf select */ for (sel = 0; sel < 2; sel++) { unsigned char col[4], fcol[4]; @@ -3202,8 +3202,8 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE); } - // Setup for drawing wire over, disable zbuffer - // write to show selected edge wires better + /* Setup for drawing wire over, disable zbuffer + * write to show selected edge wires better */ UI_ThemeColor(TH_WIRE); bglPolygonOffset(rv3d->dist, 1.0); @@ -3222,18 +3222,18 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, UI_GetThemeColor4ubv(TH_FACE, col1); UI_GetThemeColor4ubv(TH_FACE_SELECT, col2); UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col3); - + glEnable(GL_BLEND); - glDepthMask(0); // disable write in zbuffer, needed for nice transp - + glDepthMask(0); /* disable write in zbuffer, needed for nice transp */ + /* don't draw unselected faces, only selected, this is MUCH nicer when texturing */ if (check_object_draw_texture(scene, v3d, dt)) col1[3] = 0; - + draw_dm_faces_sel(em, cageDM, col1, col2, col3, efa_act); glDisable(GL_BLEND); - glDepthMask(1); // restore write in zbuffer + glDepthMask(1); /* restore write in zbuffer */ } else if (efa_act) { /* even if draw faces is off it would be nice to draw the stipple face @@ -3242,15 +3242,15 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, unsigned char col1[4], col2[4], col3[4]; col1[3] = col2[3] = 0; /* don't draw */ UI_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, col3); - + glEnable(GL_BLEND); - glDepthMask(0); // disable write in zbuffer, needed for nice transp - + glDepthMask(0); /* disable write in zbuffer, needed for nice transp */ + draw_dm_faces_sel(em, cageDM, col1, col2, col3, efa_act); glDisable(GL_BLEND); - glDepthMask(1); // restore write in zbuffer - + glDepthMask(1); /* restore write in zbuffer */ + } /* here starts all fancy draw-extra over */ @@ -3583,7 +3583,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D */ if (dt != OB_WIRE && (draw_wire == OBDRAW_WIRE_ON_DEPTH)) { bglPolygonOffset(rv3d->dist, 1.0); - glDepthMask(0); // disable write in zbuffer, selected edge wires show better + glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */ } if (((v3d->flag2 & V3D_RENDER_OVERRIDE) && v3d->drawtype >= OB_SOLID) == 0) @@ -3818,7 +3818,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob, if (ob->transflag & OB_NEG_SCALE) glFrontFace(GL_CW); else glFrontFace(GL_CCW); - if (ob->type == OB_MBALL) { // mball always smooth shaded + if (ob->type == OB_MBALL) { /* mball always smooth shaded */ glShadeModel(GL_SMOOTH); } @@ -5639,8 +5639,8 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, while (nr-- > 0) { /* accounts for empty bevel lists */ const float fac = bevp->radius * ts->normalsize; - float vec_a[3]; // Offset perpendicular to the curve - float vec_b[3]; // Delta along the curve + float vec_a[3]; /* Offset perpendicular to the curve */ + float vec_b[3]; /* Delta along the curve */ vec_a[0] = fac; vec_a[1] = 0.0f; @@ -5736,7 +5736,7 @@ static void draw_empty_cone(float size) } /* draw points on curve speed handles */ -#if 0 // XXX old animation system stuff +#if 0 /* XXX old animation system stuff */ static void curve_draw_speed(Scene *scene, Object *ob) { Curve *cu = ob->data; @@ -5765,7 +5765,7 @@ static void curve_draw_speed(Scene *scene, Object *ob) glPointSize(1.0); bglEnd(); } -#endif // XXX old animation system stuff +#endif /* XXX old animation system stuff */ static void draw_textcurs(float textcurs[4][2]) @@ -6009,7 +6009,7 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) /* calculus here, is reused in PFIELD_FORCE */ invert_m4_m4(imat, rv3d->viewmatob); -// normalize_v3(imat[0]); // we don't do this because field doesnt scale either... apart from wind! +// normalize_v3(imat[0]); /* we don't do this because field doesnt scale either... apart from wind! */ // normalize_v3(imat[1]); if (pd->forcefield == PFIELD_WIND) { @@ -6383,8 +6383,8 @@ static void drawWireExtra(Scene *scene, RegionView3D *rv3d, Object *ob) } bglPolygonOffset(rv3d->dist, 1.0); - glDepthMask(0); // disable write in zbuffer, selected edge wires show better - + glDepthMask(0); /* disable write in zbuffer, selected edge wires show better */ + if (ELEM3(ob->type, OB_FONT, OB_CURVE, OB_SURF)) { Curve *cu = ob->data; if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) { @@ -6990,7 +6990,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short #endif } - // only draw domains + /* only draw domains */ if (smd->domain && smd->domain->fluid) { if (CFRA < smd->domain->point_cache[0]->startframe) { /* don't show smoke before simulation starts, this could be made an option in the future */ @@ -7408,7 +7408,7 @@ static DMDrawOption bbs_mesh_solid_hide__setDrawOpts(void *userData, int index) } } -// must have called WM_set_framebuffer_index_color beforehand +/* must have called WM_set_framebuffer_index_color beforehand */ static DMDrawOption bbs_mesh_solid_hide2__setDrawOpts(void *userData, int index) { Mesh *me = userData; @@ -7462,11 +7462,11 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec bglPolygonOffset(rv3d->dist, 1.0); - // we draw edges always, for loop (select) tools + /* we draw edges always, for loop (select) tools */ bbs_mesh_wire(em, dm, bm_solidoffs); bm_wireoffs = bm_solidoffs + em->bm->totedge; - // we draw verts if vert select mode or if in transform (for snap). + /* we draw verts if vert select mode or if in transform (for snap). */ if ((ts->selectmode & SCE_SELECT_VERTEX) || (G.moving & G_TRANSFORM_EDIT)) { bbs_mesh_verts(em, dm, bm_wireoffs); bm_vertoffs = bm_wireoffs + em->bm->totvert; diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c index 60b3b911b1b..2c2d4039225 100644 --- a/source/blender/editors/space_view3d/drawvolume.c +++ b/source/blender/editors/space_view3d/drawvolume.c @@ -45,7 +45,7 @@ #include "BLI_rand.h" #include "BKE_curve.h" -#include "BKE_constraint.h" // for the get_constraint_target function +#include "BKE_constraint.h" /* for the get_constraint_target function */ #include "BKE_DerivedMesh.h" #include "BKE_displist.h" #include "BKE_effect.h" @@ -148,7 +148,7 @@ static int intersect_edges(float *points, float a, float b, float c, float d, fl static int convex(const float p0[3], const float up[3], const float a[3], const float b[3]) { - // Vec3 va = a-p0, vb = b-p0; + /* Vec3 va = a-p0, vb = b-p0; */ float va[3], vb[3], tmp[3]; sub_v3_v3v3(va, a, p0); sub_v3_v3v3(vb, b, p0); @@ -175,7 +175,7 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r {1.0f, 1.0f, -1.0f}, {-1.0f, 1.0f, -1.0f}, {-1.0f, -1.0f, -1.0f}, {1.0f, -1.0f, -1.0f} }; - // edges have the form edges[n][0][xyz] + t*edges[n][1][xyz] + /* edges have the form edges[n][0][xyz] + t*edges[n][1][xyz] */ float edges[12][2][3] = { {{1.0f, 1.0f, -1.0f}, {0.0f, 0.0f, 2.0f}}, {{-1.0f, 1.0f, -1.0f}, {0.0f, 0.0f, 2.0f}}, @@ -226,54 +226,54 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r sub_v3_v3v3(size, max, min); - // maxx, maxy, maxz + /* maxx, maxy, maxz */ cv[0][0] = max[0]; cv[0][1] = max[1]; cv[0][2] = max[2]; - // minx, maxy, maxz + /* minx, maxy, maxz */ cv[1][0] = min[0]; cv[1][1] = max[1]; cv[1][2] = max[2]; - // minx, miny, maxz + /* minx, miny, maxz */ cv[2][0] = min[0]; cv[2][1] = min[1]; cv[2][2] = max[2]; - // maxx, miny, maxz + /* maxx, miny, maxz */ cv[3][0] = max[0]; cv[3][1] = min[1]; cv[3][2] = max[2]; - // maxx, maxy, minz + /* maxx, maxy, minz */ cv[4][0] = max[0]; cv[4][1] = max[1]; cv[4][2] = min[2]; - // minx, maxy, minz + /* minx, maxy, minz */ cv[5][0] = min[0]; cv[5][1] = max[1]; cv[5][2] = min[2]; - // minx, miny, minz + /* minx, miny, minz */ cv[6][0] = min[0]; cv[6][1] = min[1]; cv[6][2] = min[2]; - // maxx, miny, minz + /* maxx, miny, minz */ cv[7][0] = max[0]; cv[7][1] = min[1]; cv[7][2] = min[2]; - copy_v3_v3(edges[0][0], cv[4]); // maxx, maxy, minz - copy_v3_v3(edges[1][0], cv[5]); // minx, maxy, minz - copy_v3_v3(edges[2][0], cv[6]); // minx, miny, minz - copy_v3_v3(edges[3][0], cv[7]); // maxx, miny, minz + copy_v3_v3(edges[0][0], cv[4]); /* maxx, maxy, minz */ + copy_v3_v3(edges[1][0], cv[5]); /* minx, maxy, minz */ + copy_v3_v3(edges[2][0], cv[6]); /* minx, miny, minz */ + copy_v3_v3(edges[3][0], cv[7]); /* maxx, miny, minz */ - copy_v3_v3(edges[4][0], cv[3]); // maxx, miny, maxz - copy_v3_v3(edges[5][0], cv[2]); // minx, miny, maxz - copy_v3_v3(edges[6][0], cv[6]); // minx, miny, minz - copy_v3_v3(edges[7][0], cv[7]); // maxx, miny, minz + copy_v3_v3(edges[4][0], cv[3]); /* maxx, miny, maxz */ + copy_v3_v3(edges[5][0], cv[2]); /* minx, miny, maxz */ + copy_v3_v3(edges[6][0], cv[6]); /* minx, miny, minz */ + copy_v3_v3(edges[7][0], cv[7]); /* maxx, miny, minz */ - copy_v3_v3(edges[8][0], cv[1]); // minx, maxy, maxz - copy_v3_v3(edges[9][0], cv[2]); // minx, miny, maxz - copy_v3_v3(edges[10][0], cv[6]); // minx, miny, minz - copy_v3_v3(edges[11][0], cv[5]); // minx, maxy, minz + copy_v3_v3(edges[8][0], cv[1]); /* minx, maxy, maxz */ + copy_v3_v3(edges[9][0], cv[2]); /* minx, miny, maxz */ + copy_v3_v3(edges[10][0], cv[6]); /* minx, miny, minz */ + copy_v3_v3(edges[11][0], cv[5]); /* minx, maxy, minz */ // printf("size x: %f, y: %f, z: %f\n", size[0], size[1], size[2]); // printf("min[2]: %f, max[2]: %f\n", min[2], max[2]); @@ -311,11 +311,11 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r printf("%f, %f, %f\n", rv3d->viewinv[2][0], rv3d->viewinv[2][1], rv3d->viewinv[2][2]); #endif - // get view vector + /* get view vector */ copy_v3_v3(viewnormal, rv3d->viewinv[2]); normalize_v3(viewnormal); - // find cube vertex that is closest to the viewer + /* find cube vertex that is closest to the viewer */ for (i = 0; i < 8; i++) { float x, y, z; @@ -346,9 +346,9 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prog); glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)strlen(text), text); - // cell spacing + /* cell spacing */ glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, dx, dx, dx, 1.0); - // custom parameter for smoke style (higher = thicker) + /* custom parameter for smoke style (higher = thicker) */ glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, 7.0, 7.0, 7.0, 1.0); } else @@ -366,10 +366,10 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r cor[2] = (float)res[2] / (float)power_of_2_max_i(res[2]); } - // our slices are defined by the plane equation a*x + b*y +c*z + d = 0 - // (a,b,c), the plane normal, are given by viewdir - // d is the parameter along the view direction. the first d is given by - // inserting previously found vertex into the plane equation + /* our slices are defined by the plane equation a*x + b*y +c*z + d = 0 + * (a,b,c), the plane normal, are given by viewdir + * d is the parameter along the view direction. the first d is given by + * inserting previously found vertex into the plane equation */ /* d0 = (viewnormal[0]*cv[i][0] + viewnormal[1]*cv[i][1] + viewnormal[2]*cv[i][2]); */ /* UNUSED */ ds = (ABS(viewnormal[0]) * size[0] + ABS(viewnormal[1]) * size[1] + ABS(viewnormal[2]) * size[2]); @@ -395,8 +395,8 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r // printf("my d: %f\n", d); - // intersect_edges returns the intersection points of all cube edges with - // the given plane that lie within the cube + /* intersect_edges returns the intersection points of all cube edges with + * the given plane that lie within the cube */ numpoints = intersect_edges(points, viewnormal[0], viewnormal[1], viewnormal[2], -d, edges); // printf("points: %d\n", numpoints); @@ -404,7 +404,7 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r if (numpoints > 2) { copy_v3_v3(p0, points); - // sort points to get a convex polygon + /* sort points to get a convex polygon */ for (i = 1; i < numpoints - 1; i++) { for (j = i + 1; j < numpoints; j++) { if (!convex(p0, viewnormal, &points[j * 3], &points[i * 3])) { @@ -454,4 +454,3 @@ void draw_volume(ARegion *ar, GPUTexture *tex, float min[3], float max[3], int r glDepthMask(GL_TRUE); } } - diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index a6948222d93..88d08d937be 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -62,7 +62,7 @@ #include "UI_resources.h" -#include "view3d_intern.h" // own include +#include "view3d_intern.h" /* own include */ /* ******************** manage regions ********************* */ @@ -1016,7 +1016,7 @@ static void space_view3d_listener(struct ScrArea *sa, struct wmNotifier *wmn) break; } - // removed since BKE_image_user_frame_calc is now called in view3d_draw_bgpic because screen_ops doesnt call the notifier. + /* removed since BKE_image_user_frame_calc is now called in view3d_draw_bgpic because screen_ops doesnt call the notifier. */ #if 0 if (wmn->category == NC_SCENE && wmn->data == ND_FRAME) { View3D *v3d = area->spacedata.first; @@ -1172,7 +1172,7 @@ void ED_spacetype_view3d(void) /* regions: listview/buttons */ art = MEM_callocN(sizeof(ARegionType), "spacetype view3d buttons region"); art->regionid = RGN_TYPE_UI; - art->prefsizex = 180; // XXX + art->prefsizex = 180; /* XXX */ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; art->listener = view3d_buttons_area_listener; art->init = view3d_buttons_area_init; @@ -1184,8 +1184,8 @@ void ED_spacetype_view3d(void) /* regions: tool(bar) */ art = MEM_callocN(sizeof(ARegionType), "spacetype view3d tools region"); art->regionid = RGN_TYPE_TOOLS; - art->prefsizex = 160; // XXX - art->prefsizey = 50; // XXX + art->prefsizex = 160; /* XXX */ + art->prefsizey = 50; /* XXX */ art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; art->listener = view3d_buttons_area_listener; art->init = view3d_tools_area_init; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 3079719efe0..1ace4688991 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -28,7 +28,6 @@ * \ingroup spview3d */ - #include <string.h> #include <stdio.h> #include <math.h> @@ -65,7 +64,7 @@ #include "BKE_movieclip.h" #include "RE_engine.h" -#include "RE_pipeline.h" // make_stars +#include "RE_pipeline.h" /* make_stars */ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" @@ -92,8 +91,7 @@ #include "GPU_material.h" #include "GPU_extensions.h" -#include "view3d_intern.h" // own include - +#include "view3d_intern.h" /* own include */ static void star_stuff_init_func(void) @@ -299,7 +297,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** dx = fabs(x - (wx) * fx / fw); if (dx == 0) dx = fabs(y - (wy) * fy / fw); - glDepthMask(0); // disable write in zbuffer + glDepthMask(0); /* disable write in zbuffer */ /* check zoom out */ UI_ThemeColor(TH_GRID); @@ -361,7 +359,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** drawgrid_draw(ar, wx, wy, x, y, dx); } } - else { // start blending out + else { /* start blending out */ UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX_D * 6.0)); drawgrid_draw(ar, wx, wy, x, y, dx); @@ -369,7 +367,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** drawgrid_draw(ar, wx, wy, x, y, sublines * dx); } } - else { // start blending out (GRID_MIN_PX < dx < (GRID_MIN_PX*10)) + else { /* start blending out (GRID_MIN_PX < dx < (GRID_MIN_PX*10)) */ UI_ThemeColorBlend(TH_BACK, TH_GRID, dx / (GRID_MIN_PX_D * 6.0)); drawgrid_draw(ar, wx, wy, x, y, dx); @@ -378,10 +376,10 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** } } else { - if (dx > (GRID_MIN_PX_D * 10.0)) { // start blending in + if (dx > (GRID_MIN_PX_D * 10.0)) { /* start blending in */ rv3d->gridview /= sublines; dx /= sublines; - if (dx > (GRID_MIN_PX_D * 10.0)) { // start blending in + if (dx > (GRID_MIN_PX_D * 10.0)) { /* start blending in */ rv3d->gridview /= sublines; dx /= sublines; if (dx > (GRID_MIN_PX_D * 10.0)) { @@ -435,7 +433,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char ** fdrawline(x, 0.0, x, (float)ar->winy); - glDepthMask(1); // enable write in zbuffer + glDepthMask(1); /* enable write in zbuffer */ } #undef GRID_MIN_PX @@ -473,7 +471,8 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) grid_scale = ED_view3d_grid_scale(scene, v3d, grid_unit); grid = gridlines * grid_scale; - if (v3d->zbuf && scene->obedit) glDepthMask(0); // for zbuffer-select + if (v3d->zbuf && scene->obedit) + glDepthMask(0); /* for zbuffer-select */ UI_GetThemeColor3ubv(TH_GRID, col_grid); @@ -665,10 +664,10 @@ static void draw_view_axis(RegionView3D *rv3d) /* draw center and axis of rotation for ongoing 3D mouse navigation */ static void draw_rotation_guide(RegionView3D *rv3d) { - float o[3]; // center of rotation - float end[3]; // endpoints for drawing + float o[3]; /* center of rotation */ + float end[3]; /* endpoints for drawing */ - float color[4] = {0.0f, 0.4235f, 1.0f, 1.0f}; // bright blue so it matches device LEDs + float color[4] = {0.0f, 0.4235f, 1.0f, 1.0f}; /* bright blue so it matches device LEDs */ negate_v3_v3(o, rv3d->ofs); @@ -677,25 +676,25 @@ static void draw_rotation_guide(RegionView3D *rv3d) glShadeModel(GL_SMOOTH); glPointSize(5); glEnable(GL_POINT_SMOOTH); - glDepthMask(0); // don't overwrite zbuf + glDepthMask(0); /* don't overwrite zbuf */ if (rv3d->rot_angle != 0.f) { - // -- draw rotation axis -- + /* -- draw rotation axis -- */ float scaled_axis[3]; const float scale = rv3d->dist; mul_v3_v3fl(scaled_axis, rv3d->rot_axis, scale); glBegin(GL_LINE_STRIP); - color[3] = 0.f; // more transparent toward the ends + color[3] = 0.f; /* more transparent toward the ends */ glColor4fv(color); add_v3_v3v3(end, o, scaled_axis); glVertex3fv(end); - // color[3] = 0.2f + fabsf(rv3d->rot_angle); // modulate opacity with angle + // color[3] = 0.2f + fabsf(rv3d->rot_angle); /* modulate opacity with angle */ // ^^ neat idea, but angle is frame-rate dependent, so it's usually close to 0.2 - color[3] = 0.5f; // more opaque toward the center + color[3] = 0.5f; /* more opaque toward the center */ glColor4fv(color); glVertex3fv(o); @@ -705,7 +704,7 @@ static void draw_rotation_guide(RegionView3D *rv3d) glVertex3fv(end); glEnd(); - // -- draw ring around rotation center -- + /* -- draw ring around rotation center -- */ { #define ROT_AXIS_DETAIL 13 @@ -714,7 +713,7 @@ static void draw_rotation_guide(RegionView3D *rv3d) float angle; int i; - float q[4]; // rotate ring so it's perpendicular to axis + float q[4]; /* rotate ring so it's perpendicular to axis */ const int upright = fabsf(rv3d->rot_axis[2]) >= 0.95f; if (!upright) { const float up[3] = {0.f, 0.f, 1.f}; @@ -725,7 +724,7 @@ static void draw_rotation_guide(RegionView3D *rv3d) axis_angle_to_quat(q, vis_axis, vis_angle); } - color[3] = 0.25f; // somewhat faint + color[3] = 0.25f; /* somewhat faint */ glColor4fv(color); glBegin(GL_LINE_LOOP); for (i = 0, angle = 0.f; i < ROT_AXIS_DETAIL; ++i, angle += step) { @@ -743,21 +742,23 @@ static void draw_rotation_guide(RegionView3D *rv3d) #undef ROT_AXIS_DETAIL } - color[3] = 1.f; // solid dot + color[3] = 1.0f; /* solid dot */ } else - color[3] = 0.5f; // see-through dot + color[3] = 0.5f; /* see-through dot */ - // -- draw rotation center -- + /* -- draw rotation center -- */ glColor4fv(color); glBegin(GL_POINTS); glVertex3fv(o); glEnd(); - // find screen coordinates for rotation center, then draw pretty icon - // mul_m4_v3(rv3d->persinv, rot_center); - // UI_icon_draw(rot_center[0], rot_center[1], ICON_NDOF_TURN); - // ^^ just playing around, does not work + /* find screen coordinates for rotation center, then draw pretty icon */ +#if 0 + mul_m4_v3(rv3d->persinv, rot_center); + UI_icon_draw(rot_center[0], rot_center[1], ICON_NDOF_TURN); +#endif + /* ^^ just playing around, does not work */ glDisable(GL_BLEND); glDisable(GL_POINT_SMOOTH); @@ -1319,12 +1320,14 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) if (!(v3d->flag & V3D_INVALID_BACKBUF) ) return; -// if (test) { -// if (qtest()) { -// addafterqueue(ar->win, BACKBUFDRAW, 1); -// return; -// } -// } +#if 0 + if (test) { + if (qtest()) { + addafterqueue(ar->win, BACKBUFDRAW, 1); + return; + } + } +#endif if (v3d->drawtype > OB_WIRE) v3d->zbuf = TRUE; @@ -1370,7 +1373,7 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) ED_view3d_clipping_disable(); /* it is important to end a view in a transform compatible with buttons */ -// persp(PERSP_WIN); // set ortho +// persp(PERSP_WIN); /* set ortho */ } @@ -1493,20 +1496,20 @@ unsigned int view3d_sample_backbuf_rect(ViewContext *vc, const int mval[2], int for (a = 0; a < 2; a++) { for (b = 0; b < nr; b++, distance++) { - if (*tbuf && *tbuf >= min && *tbuf < max) { //we got a hit + if (*tbuf && *tbuf >= min && *tbuf < max) { /* we got a hit */ if (strict) { indexok = indextest(handle, *tbuf - min + 1); if (indexok) { *dist = (short) sqrt( (float)distance); index = *tbuf - min + 1; goto exit; - } + } } else { - *dist = (short) sqrt( (float)distance); // XXX, this distance is wrong - - index = *tbuf - min + 1; // messy yah, but indices start at 1 + *dist = (short) sqrt( (float)distance); /* XXX, this distance is wrong - */ + index = *tbuf - min + 1; /* messy yah, but indices start at 1 */ goto exit; - } + } } tbuf += (dirvec[rc][0] + dirvec[rc][1]); @@ -1912,7 +1915,7 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas tbase.flag = OB_FROMDUPLI | base->flag; lb = object_duplilist(scene, base->object); - // BLI_sortlist(lb, dupli_ob_sort); // might be nice to have if we have a dupli list with mixed objects. + // BLI_sortlist(lb, dupli_ob_sort); /* might be nice to have if we have a dupli list with mixed objects. */ dob = dupli_step(lb->first); if (dob) dob_next = dupli_step(dob->next); @@ -2174,7 +2177,7 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (*func)(void *)) glClear(GL_DEPTH_BUFFER_BIT); glLoadMatrixf(rv3d->viewmat); -// persp(PERSP_STORE); // store correct view for persp(PERSP_VIEW) calls +// persp(PERSP_STORE); /* store correct view for persp(PERSP_VIEW) calls */ if (rv3d->rflag & RV3D_CLIPPING) { ED_view3d_clipping_set(rv3d); @@ -2640,7 +2643,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, glPopMatrix(); - // XXX, without this the sequencer flickers with opengl draw enabled, need to find out why - campbell + /* XXX, without this the sequencer flickers with opengl draw enabled, need to find out why - campbell */ glColor4ub(255, 255, 255, 255); G.f &= ~G_RENDER_OGL; @@ -2686,9 +2689,6 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, GPU_offscreen_read_pixels(ofs, GL_FLOAT, ibuf->rect_float); else if (ibuf->rect) GPU_offscreen_read_pixels(ofs, GL_UNSIGNED_BYTE, ibuf->rect); - - //if ((scene->r.stamp & R_STAMP_ALL) && (scene->r.stamp & R_STAMP_DRAW)) - // BKE_stamp_buf(scene, NULL, rr->rectf, rr->rectx, rr->recty, 4); /* unbind */ GPU_offscreen_unbind(ofs); @@ -2951,7 +2951,7 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const glEnable(GL_MULTISAMPLE_ARB); #endif - // needs to be done always, gridview is adjusted in drawgrid() now + /* needs to be done always, gridview is adjusted in drawgrid() now */ rv3d->gridview = v3d->grid; if ((rv3d->view == RV3D_VIEW_USER) || (rv3d->persp != RV3D_ORTHO)) { @@ -3049,7 +3049,7 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const /* Transp and X-ray afterdraw stuff */ if (v3d->afterdraw_transp.first) view3d_draw_transp(scene, ar, v3d); - if (v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); // clears zbuffer if it is used! + if (v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); /* clears zbuffer if it is used! */ if (v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(scene, ar, v3d, 1); ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); @@ -3078,7 +3078,7 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const } if ((U.ndof_flag & NDOF_SHOW_GUIDE) && (rv3d->viewlock != RV3D_LOCKED) && (rv3d->persp != RV3D_CAMOB)) - // TODO: draw something else (but not this) during fly mode + /* TODO: draw something else (but not this) during fly mode */ draw_rotation_guide(rv3d); } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 218aa71d621..97123767211 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -81,7 +81,7 @@ #include "PIL_time.h" /* smoothview */ -#include "view3d_intern.h" // own include +#include "view3d_intern.h" /* own include */ /* ********************** view3d_edit: view manipulations ********************* */ @@ -444,7 +444,7 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event) float my_pivot[3]; /* view */ float dvec[3]; - // locals for dist correction + /* locals for dist correction */ float mat[3][3]; float upvec[3]; @@ -1517,13 +1517,13 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom, fac = -fac; } - // oldstyle zoom + /* oldstyle zoom */ zfac = 1.0f + ((fac / 20.0f) * time_step); vod->timer_lastdraw = time; } else if (viewzoom == USER_ZOOM_SCALE) { int ctr[2], len1, len2; - // method which zooms based on how far you move the mouse + /* method which zooms based on how far you move the mouse */ ctr[0] = (vod->ar->winrct.xmax + vod->ar->winrct.xmin) / 2; ctr[1] = (vod->ar->winrct.ymax + vod->ar->winrct.ymin) / 2; @@ -2100,7 +2100,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in new_ofs[1] = -(min[1] + max[1]) / 2.0f; new_ofs[2] = -(min[2] + max[2]) / 2.0f; - // correction for window aspect ratio + /* correction for window aspect ratio */ if (ar->winy > 2 && ar->winx > 2) { size = (float)ar->winx / (float)ar->winy; if (size < 1.0f) size = 1.0f / size; @@ -3402,7 +3402,7 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *eve if (mval[0] != IS_CLIPPED) { short depth_used = 0; - if (U.uiflag & USER_ORBIT_ZBUF) { /* maybe this should be accessed some other way */ + if (U.uiflag & USER_ORBIT_ZBUF) { /* maybe this should be accessed some other way */ view3d_operator_needs_opengl(C); if (ED_view3d_autodist(scene, ar, v3d, event->mval, fp)) depth_used = 1; @@ -3596,7 +3596,7 @@ int ED_view3d_autodist(Scene *scene, ARegion *ar, View3D *v3d, const int mval[2] return 1; } -int ED_view3d_autodist_init(Scene *scene, ARegion *ar, View3D *v3d, int mode) //, float *autodist ) +int ED_view3d_autodist_init(Scene *scene, ARegion *ar, View3D *v3d, int mode) { /* Get Z Depths, needed for perspective, nice for ortho */ switch (mode) { @@ -3611,9 +3611,9 @@ int ED_view3d_autodist_init(Scene *scene, ARegion *ar, View3D *v3d, int mode) // return 1; } -// no 4x4 sampling, run view_autodist_init first +/* no 4x4 sampling, run view_autodist_init first */ int ED_view3d_autodist_simple(ARegion *ar, const int mval[2], float mouse_worldloc[3], - int margin, float *force_depth) //, float *autodist ) + int margin, float *force_depth) { bglMats mats; /* ZBuffer depth vars, could cache? */ float depth; diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 95cc37d9f87..40837d00409 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -513,7 +513,7 @@ static void flyEvent(FlyInfo *fly, wmEvent *event) } break; case P_FINISHING: - // stop keeping track of 3D mouse position + /* stop keeping track of 3D mouse position */ #ifdef NDOF_FLY_DEBUG puts("stop keeping track of 3D mouse position"); #endif diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index eb202497260..465279ee6ed 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -115,8 +115,8 @@ static void do_view3d_header_buttons(bContext *C, void *arg, int event); #define B_REDR 122 #define B_NOP 123 -// XXX quickly ported across -static void handle_view3d_lock(bContext *C) +/* XXX quickly ported across */ +static void handle_view3d_lock(bContext *C) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index f9ebd4e39c1..f12e7683668 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -92,9 +92,9 @@ #include "UI_interface.h" #include "UI_resources.h" -#include "view3d_intern.h" // own include +#include "view3d_intern.h" /* own include */ -// TODO: should return whether there is valid context to continue +/* TODO: should return whether there is valid context to continue */ void view3d_set_viewcontext(bContext *C, ViewContext *vc) { memset(vc, 0, sizeof(ViewContext)); @@ -1825,7 +1825,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, i unsigned int *col; /* color in buffer */ int bone_only; int bone_selected = 0; - int totobj = MAXPICKBUF; // XXX solve later + int totobj = MAXPICKBUF; /* XXX solve later */ short hits; if ((ob) && (ob->mode & OB_MODE_POSE)) @@ -2370,7 +2370,7 @@ static void lattice_circle_select(ViewContext *vc, int select, const int mval[2] } -// NOTE: pose-bone case is copied from editbone case... +/* NOTE: pose-bone case is copied from editbone case... */ static short pchan_circle_doSelectJoint(void *userData, bPoseChannel *pchan, int x, int y) { CircleSelectUserData *data = userData; @@ -2403,7 +2403,7 @@ static void pose_circle_select(ViewContext *vc, int select, const int mval[2], f ED_view3d_init_mats_rv3d(vc->obact, vc->rv3d); /* for foreach's screen/vert projection */ /* check each PoseChannel... */ - // TODO: could be optimized at some point + /* TODO: could be optimized at some point */ for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { short sco1[2], sco2[2], didpoint = 0; float vec[3]; @@ -2475,7 +2475,7 @@ static void armature_circle_select(ViewContext *vc, int select, const int mval[2 ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */ /* check each EditBone... */ - // TODO: could be optimized at some point + /* TODO: could be optimized at some point */ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { short sco1[2], sco2[2], didpoint = 0; float vec[3]; @@ -2497,7 +2497,7 @@ static void armature_circle_select(ViewContext *vc, int select, const int mval[2 didpoint = 1; /* only if the endpoints didn't get selected, deal with the middle of the bone too */ - // XXX should we just do this always? + /* XXX should we just do this always? */ if ( (didpoint == 0) && edge_inside_circle(mval[0], mval[1], rad, sco1[0], sco1[1], sco2[0], sco2[1]) ) { if (select) ebone->flag |= BONE_TIPSEL | BONE_ROOTSEL | BONE_SELECTED; diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 1991d4bce4f..fc97b9bbb36 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -102,7 +102,7 @@ static void special_transvert_update(Object *obedit) if (obedit->type == OB_MESH) { Mesh *me = obedit->data; - BM_mesh_normals_update(me->edit_btmesh->bm, TRUE); // does face centers too + BM_mesh_normals_update(me->edit_btmesh->bm, TRUE); /* does face centers too */ } else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { Curve *cu = obedit->data; @@ -223,8 +223,8 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod float total, center[3], centroid[3]; int a; - tottrans = 0; // global! - + tottrans = 0; /* global! */ + INIT_MINMAX(min, max); zero_v3(centroid); @@ -239,7 +239,7 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod /* abuses vertex index all over, set, just set dirty here, * perhaps this could use its own array instead? - campbell */ - // transform now requires awareness for select mode, so we tag the f1 flags in verts + /* transform now requires awareness for select mode, so we tag the f1 flags in verts */ tottrans = 0; if (em->selectmode & SCE_SELECT_VERTEX) { BM_ITER_MESH (eve, &iter, bm, BM_VERTS_OF_MESH) { @@ -304,7 +304,7 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod copy_v3_v3(tv->oldloc, eve->co); tv->loc = eve->co; if (eve->no[0] != 0.0f || eve->no[1] != 0.0f || eve->no[2] != 0.0f) - tv->nor = eve->no; // note this is a hackish signal (ton) + tv->nor = eve->no; /* note this is a hackish signal (ton) */ tv->flag = BM_elem_index_get(eve) & SELECT; tv++; a++; @@ -794,8 +794,8 @@ static int snap_curs_to_grid(bContext *C, wmOperator *UNUSED(op)) curs[1] = gridf * floorf(0.5f + curs[1] / gridf); curs[2] = gridf * floorf(0.5f + curs[2] / gridf); - WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); // hrm - + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); /* hrm */ + return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index b4350847552..bc41ecd1dc5 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -71,7 +71,7 @@ #include "RNA_access.h" #include "RNA_define.h" -#include "view3d_intern.h" // own include +#include "view3d_intern.h" /* own include */ /* use this call when executing an operator, * event system doesn't set for each event the @@ -184,7 +184,7 @@ void smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Objec /* original values */ if (oldcamera) { - sms.orig_dist = rv3d->dist; // below function does weird stuff with it... + sms.orig_dist = rv3d->dist; /* below function does weird stuff with it... */ ED_view3d_from_object(oldcamera, sms.orig_ofs, sms.orig_quat, &sms.orig_dist, &sms.orig_lens); } else { @@ -1100,14 +1100,14 @@ static void obmat_to_viewmat(View3D *v3d, RegionView3D *rv3d, Object *ob, short rv3d->dist = 0.0; ED_view3d_from_object(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); - smooth_view(NULL, NULL, NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); // XXX - + smooth_view(NULL, NULL, NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); /* XXX */ + rv3d->persp = RV3D_CAMOB; /* just to be polite, not needed */ } else { mat3_to_quat(new_quat, tmat); - smooth_view(NULL, NULL, NULL, NULL, NULL, NULL, new_quat, NULL, NULL); // XXX + smooth_view(NULL, NULL, NULL, NULL, NULL, NULL, new_quat, NULL, NULL); /* XXX */ } } else { @@ -1211,7 +1211,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b /* case not a border select */ if (input->xmin == input->xmax) { - rect.xmin = input->xmin - 12; // seems to be default value for bones only now + rect.xmin = input->xmin - 12; /* seems to be default value for bones only now */ rect.xmax = input->xmin + 12; rect.ymin = input->ymin - 12; rect.ymax = input->ymin + 12; @@ -1252,7 +1252,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b else { Base *base; - v3d->xray = TRUE; // otherwise it postpones drawing + v3d->xray = TRUE; /* otherwise it postpones drawing */ for (base = scene->base.first; base; base = base->next) { if (base->lay & v3d->lay) { @@ -1294,7 +1294,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b } } } - v3d->xray = FALSE; // restore + v3d->xray = FALSE; /* restore */ } glPopName(); /* see above (pushname) */ @@ -1313,8 +1313,8 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b if (vc->rv3d->rflag & RV3D_CLIPPING) ED_view3d_clipping_disable(); - if (hits < 0) printf("Too many objects in select buffer\n"); // XXX make error message - + if (hits < 0) printf("Too many objects in select buffer\n"); /* XXX make error message */ + return hits; } @@ -1392,29 +1392,31 @@ int ED_view3d_scene_layer_set(int lay, const int *values, int *active) return lay; } -static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa) +static int view3d_localview_init(Main *bmain, Scene *scene, ScrArea *sa, ReportList *reports) { View3D *v3d = sa->spacedata.first; Base *base; float size = 0.0, min[3], max[3], box[3]; unsigned int locallay; - int ok = 0; + int ok = FALSE; - if (v3d->localvd) return; + if (v3d->localvd) { + return ok; + } INIT_MINMAX(min, max); locallay = free_localbit(bmain); if (locallay == 0) { - printf("Sorry, no more than 8 localviews\n"); // XXX error - ok = 0; + BKE_reportf(reports, RPT_ERROR, "No more than 8 localviews"); + ok = FALSE; } else { if (scene->obedit) { BKE_object_minmax(scene->obedit, min, max); - ok = 1; + ok = TRUE; BASACT->lay |= locallay; scene->obedit->lay = BASACT->lay; @@ -1425,7 +1427,7 @@ static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa) BKE_object_minmax(base->object, min, max); base->lay |= locallay; base->object->lay = base->lay; - ok = 1; + ok = TRUE; } } } @@ -1437,7 +1439,7 @@ static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa) if (size <= 0.01f) size = 0.01f; } - if (ok) { + if (ok == TRUE) { ARegion *ar; v3d->localvd = MEM_mallocN(sizeof(View3D), "localview"); @@ -1460,7 +1462,7 @@ static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa) if (rv3d->persp == RV3D_ORTHO) rv3d->dist *= 0.7f; - // correction for window aspect ratio + /* correction for window aspect ratio */ if (ar->winy > 2 && ar->winx > 2) { float asp = (float)ar->winx / (float)ar->winy; if (asp < 1.0f) asp = 1.0f / asp; @@ -1486,9 +1488,10 @@ static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa) if (base->object != scene->obedit) base->flag |= SELECT; base->object->lay = base->lay; } - } + } } + return ok; } static void restore_localviewdata(ScrArea *sa, int free) @@ -1531,7 +1534,7 @@ static void restore_localviewdata(ScrArea *sa, int free) } } -static void endlocalview(Main *bmain, Scene *scene, ScrArea *sa) +static int view3d_localview_exit(Main *bmain, Scene *scene, ScrArea *sa) { View3D *v3d = sa->spacedata.first; struct Base *base; @@ -1541,7 +1544,7 @@ static void endlocalview(Main *bmain, Scene *scene, ScrArea *sa) locallay = v3d->lay & 0xFF000000; - restore_localviewdata(sa, 1); // 1 = free + restore_localviewdata(sa, 1); /* 1 = free */ /* for when in other window the layers have changed */ if (v3d->scenelock) v3d->lay = scene->lay; @@ -1559,23 +1562,38 @@ static void endlocalview(Main *bmain, Scene *scene, ScrArea *sa) } DAG_on_visible_update(bmain, FALSE); + + return TRUE; } + else { + return FALSE; + } } -static int localview_exec(bContext *C, wmOperator *UNUSED(unused)) +static int localview_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + ScrArea *sa = CTX_wm_area(C); View3D *v3d = CTX_wm_view3d(C); + int change; - if (v3d->localvd) - endlocalview(CTX_data_main(C), CTX_data_scene(C), CTX_wm_area(C)); - else - initlocalview(CTX_data_main(C), CTX_data_scene(C), CTX_wm_area(C)); + if (v3d->localvd) { + change = view3d_localview_exit(bmain, scene, sa); + } + else { + change = view3d_localview_init(bmain, scene, sa, op->reports); + } - DAG_id_type_tag(bmain, ID_OB); - ED_area_tag_redraw(CTX_wm_area(C)); - - return OPERATOR_FINISHED; + if (change) { + DAG_id_type_tag(bmain, ID_OB); + ED_area_tag_redraw(CTX_wm_area(C)); + + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } } void VIEW3D_OT_localview(wmOperatorType *ot) @@ -1681,7 +1699,7 @@ static void game_set_commmandline_options(GameData *gm) } } -#endif // WITH_GAMEENGINE +#endif /* WITH_GAMEENGINE */ static int game_engine_poll(bContext *C) { @@ -1722,7 +1740,7 @@ int ED_view3d_context_activate(bContext *C) if (!ar) return 0; - // bad context switch .. + /* bad context switch .. */ CTX_wm_area_set(C, sa); CTX_wm_region_set(C, ar); @@ -1741,7 +1759,7 @@ static int game_engine_exec(bContext *C, wmOperator *op) (void)op; /* unused */ - // bad context switch .. + /* bad context switch .. */ if (!ED_view3d_context_activate(C)) return OPERATOR_CANCELLED; @@ -1854,11 +1872,11 @@ static void UNUSED_FUNCTION(view3d_align_axis_to_vector)(View3D *v3d, RegionView rv3d->persp = RV3D_PERSP; rv3d->dist = 0.0; ED_view3d_from_object(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); - smooth_view(NULL, NULL, NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); // XXX + smooth_view(NULL, NULL, NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); /* XXX */ } else { if (rv3d->persp == RV3D_CAMOB) rv3d->persp = RV3D_PERSP; /* switch out of camera mode */ - smooth_view(NULL, NULL, NULL, NULL, NULL, NULL, new_quat, NULL, NULL); // XXX + smooth_view(NULL, NULL, NULL, NULL, NULL, NULL, new_quat, NULL, NULL); /* XXX */ } } diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index 5e80370a6f0..bbdcfbb5a73 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -97,8 +97,8 @@ extern struct Render R; void shade_input_init_material(ShadeInput *shi) { /* note, keep this synced with render_types.h */ - memcpy(&shi->r, &shi->mat->r, 23*sizeof(float)); - shi->har= shi->mat->har; + memcpy(&shi->r, &shi->mat->r, 23 * sizeof(float)); + shi->har = shi->mat->har; } /* also used as callback for nodes */ @@ -106,16 +106,16 @@ void shade_input_init_material(ShadeInput *shi) void shade_material_loop(ShadeInput *shi, ShadeResult *shr) { - shade_lamp_loop(shi, shr); /* clears shr */ + shade_lamp_loop(shi, shr); /* clears shr */ - if (shi->translucency!=0.0f) { + if (shi->translucency != 0.0f) { ShadeResult shr_t; - float fac= shi->translucency; + float fac = shi->translucency; shade_input_init_material(shi); negate_v3_v3(shi->vn, shi->vno); negate_v3(shi->facenor); - shi->depth++; /* hack to get real shadow now */ + shi->depth++; /* hack to get real shadow now */ shade_lamp_loop(shi, &shr_t); shi->depth--; @@ -133,17 +133,17 @@ void shade_material_loop(ShadeInput *shi, ShadeResult *shr) } /* depth >= 1 when ray-shading */ - if (shi->depth==0 || shi->volume_depth > 0) { + if (shi->depth == 0 || shi->volume_depth > 0) { if (R.r.mode & R_RAYTRACE) { - if (shi->ray_mirror!=0.0f || ((shi->mode & MA_TRANSP) && (shi->mode & MA_RAYTRANSP) && shr->alpha!=1.0f)) { + if (shi->ray_mirror != 0.0f || ((shi->mode & MA_TRANSP) && (shi->mode & MA_RAYTRANSP) && shr->alpha != 1.0f)) { /* ray trace works on combined, but gives pass info */ ray_trace(shi, shr); } } /* disable adding of sky for raytransp */ if ((shi->mode & MA_TRANSP) && (shi->mode & MA_RAYTRANSP)) - if ((shi->layflag & SCE_LAY_SKY) && (R.r.alphamode==R_ADDSKY)) - shr->alpha= 1.0f; + if ((shi->layflag & SCE_LAY_SKY) && (R.r.alphamode == R_ADDSKY)) + shr->alpha = 1.0f; } if (R.r.mode & R_RAYTRACE) { @@ -181,38 +181,38 @@ void shade_input_do_shade(ShadeInput *shi, ShadeResult *shr) } /* copy additional passes */ - if (shi->passflag & (SCE_PASS_VECTOR|SCE_PASS_NORMAL)) { + if (shi->passflag & (SCE_PASS_VECTOR | SCE_PASS_NORMAL)) { copy_v4_v4(shr->winspeed, shi->winspeed); copy_v3_v3(shr->nor, shi->vn); } /* MIST */ - if ((shi->passflag & SCE_PASS_MIST) || ((R.wrld.mode & WO_MIST) && (shi->mat->mode & MA_NOMIST)==0)) { + if ((shi->passflag & SCE_PASS_MIST) || ((R.wrld.mode & WO_MIST) && (shi->mat->mode & MA_NOMIST) == 0)) { if (R.r.mode & R_ORTHO) - shr->mist= mistfactor(-shi->co[2], shi->co); + shr->mist = mistfactor(-shi->co[2], shi->co); else - shr->mist= mistfactor(len_v3(shi->co), shi->co); + shr->mist = mistfactor(len_v3(shi->co), shi->co); } - else shr->mist= 0.0f; + else shr->mist = 0.0f; - if ((R.wrld.mode & WO_MIST) && (shi->mat->mode & MA_NOMIST)==0 ) { - alpha= shr->mist; + if ((R.wrld.mode & WO_MIST) && (shi->mat->mode & MA_NOMIST) == 0) { + alpha = shr->mist; } - else alpha= 1.0f; + else alpha = 1.0f; /* add mist and premul color */ - if (shr->alpha!=1.0f || alpha!=1.0f) { - float fac= alpha*(shr->alpha); - shr->combined[3]= fac; + if (shr->alpha != 1.0f || alpha != 1.0f) { + float fac = alpha * (shr->alpha); + shr->combined[3] = fac; - if (shi->mat->material_type!= MA_TYPE_VOLUME) + if (shi->mat->material_type != MA_TYPE_VOLUME) mul_v3_fl(shr->combined, fac); } else - shr->combined[3]= 1.0f; + shr->combined[3] = 1.0f; /* add z */ - shr->z= -shi->co[2]; + shr->z = -shi->co[2]; /* RAYHITS */ #if 0 @@ -258,28 +258,28 @@ void vlr_set_uv_indices(VlakRen *vlr, int *i1, int *i2, int *i3) /* indices 0 1 2 3 only */ void shade_input_set_triangle_i(ShadeInput *shi, ObjectInstanceRen *obi, VlakRen *vlr, short i1, short i2, short i3) { - VertRen **vpp= &vlr->v1; + VertRen **vpp = &vlr->v1; - shi->vlr= vlr; - shi->obi= obi; - shi->obr= obi->obr; + shi->vlr = vlr; + shi->obi = obi; + shi->obr = obi->obr; - shi->v1= vpp[i1]; - shi->v2= vpp[i2]; - shi->v3= vpp[i3]; - - shi->i1= i1; - shi->i2= i2; - shi->i3= i3; + shi->v1 = vpp[i1]; + shi->v2 = vpp[i2]; + shi->v3 = vpp[i3]; + + shi->i1 = i1; + shi->i2 = i2; + shi->i3 = i3; /* note, shi->mat is set in node shaders */ - shi->mat= shi->mat_override?shi->mat_override:vlr->mat; + shi->mat = shi->mat_override ? shi->mat_override : vlr->mat; - shi->osatex= (shi->mat->texco & TEXCO_OSA); - shi->mode= shi->mat->mode_l; /* or-ed result for all nodes */ + shi->osatex = (shi->mat->texco & TEXCO_OSA); + shi->mode = shi->mat->mode_l; /* or-ed result for all nodes */ /* facenormal copy, can get flipped */ - shi->flippednor= 0; + shi->flippednor = 0; RE_vlakren_get_normal(&R, obi, vlr, shi->facenor); /* calculate vertexnormals */ @@ -303,12 +303,12 @@ void shade_input_set_triangle_i(ShadeInput *shi, ObjectInstanceRen *obi, VlakRen /* copy data from face to ShadeInput, scanline case */ void shade_input_set_triangle(ShadeInput *shi, volatile int obi, volatile int facenr, int UNUSED(normal_flip)) { - if (facenr>0) { - shi->obi= &R.objectinstance[obi]; - shi->obr= shi->obi->obr; - shi->facenr= (facenr-1) & RE_QUAD_MASK; - if ( shi->facenr < shi->obr->totvlak ) { - VlakRen *vlr= RE_findOrAddVlak(shi->obr, shi->facenr); + if (facenr > 0) { + shi->obi = &R.objectinstance[obi]; + shi->obr = shi->obi->obr; + shi->facenr = (facenr - 1) & RE_QUAD_MASK; + if (shi->facenr < shi->obr->totvlak) { + VlakRen *vlr = RE_findOrAddVlak(shi->obr, shi->facenr); if (facenr & RE_QUAD_OFFS) shade_input_set_triangle_i(shi, shi->obi, vlr, 0, 2, 3); @@ -316,10 +316,10 @@ void shade_input_set_triangle(ShadeInput *shi, volatile int obi, volatile int fa shade_input_set_triangle_i(shi, shi->obi, vlr, 0, 1, 2); } else - shi->vlr= NULL; /* general signal we got sky */ + shi->vlr = NULL; /* general signal we got sky */ } else - shi->vlr= NULL; /* general signal we got sky */ + shi->vlr = NULL; /* general signal we got sky */ } /* full osa case: copy static info */ @@ -333,18 +333,18 @@ void shade_input_copy_triangle(ShadeInput *shi, ShadeInput *from) void shade_input_set_strand(ShadeInput *shi, StrandRen *strand, StrandPoint *spoint) { /* note, shi->mat is set in node shaders */ - shi->mat= shi->mat_override? shi->mat_override: strand->buffer->ma; + shi->mat = shi->mat_override ? shi->mat_override : strand->buffer->ma; - shi->osatex= (shi->mat->texco & TEXCO_OSA); - shi->mode= shi->mat->mode_l; /* or-ed result for all nodes */ + shi->osatex = (shi->mat->texco & TEXCO_OSA); + shi->mode = shi->mat->mode_l; /* or-ed result for all nodes */ /* shade_input_set_viewco equivalent */ copy_v3_v3(shi->co, spoint->co); copy_v3_v3(shi->view, shi->co); normalize_v3(shi->view); - shi->xs= (int)spoint->x; - shi->ys= (int)spoint->y; + shi->xs = (int)spoint->x; + shi->ys = (int)spoint->y; if (shi->osatex || (R.r.mode & R_SHADOW)) { copy_v3_v3(shi->dxco, spoint->dtco); @@ -376,27 +376,27 @@ void shade_input_set_strand(ShadeInput *shi, StrandRen *strand, StrandPoint *spo void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert *svert, StrandPoint *spoint) { - StrandBuffer *strandbuf= strand->buffer; - ObjectRen *obr= strandbuf->obr; + StrandBuffer *strandbuf = strand->buffer; + ObjectRen *obr = strandbuf->obr; StrandVert *sv; - int mode= shi->mode; /* or-ed result for all nodes */ - short texco= shi->mat->texco; + int mode = shi->mode; /* or-ed result for all nodes */ + short texco = shi->mat->texco; if ((shi->mat->texco & TEXCO_REFL)) { /* shi->dxview, shi->dyview, not supported */ } - if (shi->osatex && (texco & (TEXCO_NORM|TEXCO_REFL))) { + if (shi->osatex && (texco & (TEXCO_NORM | TEXCO_REFL))) { /* not supported */ } - if (mode & (MA_TANGENT_V|MA_NORMAP_TANG)) { + if (mode & (MA_TANGENT_V | MA_NORMAP_TANG)) { copy_v3_v3(shi->tang, spoint->tan); copy_v3_v3(shi->nmaptang, spoint->tan); } if (mode & MA_STR_SURFDIFF) { - float *surfnor= RE_strandren_get_surfnor(obr, strand, 0); + float *surfnor = RE_strandren_get_surfnor(obr, strand, 0); if (surfnor) copy_v3_v3(shi->surfnor, surfnor); @@ -404,21 +404,21 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert copy_v3_v3(shi->surfnor, shi->vn); if (shi->mat->strand_surfnor > 0.0f) { - shi->surfdist= 0.0f; - for (sv=strand->vert; sv!=svert; sv++) - shi->surfdist+=len_v3v3(sv->co, (sv+1)->co); - shi->surfdist += spoint->t*len_v3v3(sv->co, (sv+1)->co); + shi->surfdist = 0.0f; + for (sv = strand->vert; sv != svert; sv++) + shi->surfdist += len_v3v3(sv->co, (sv + 1)->co); + shi->surfdist += spoint->t * len_v3v3(sv->co, (sv + 1)->co); } } if (R.r.mode & R_SPEED) { float *speed; - speed= RE_strandren_get_winspeed(shi->obi, strand, 0); + speed = RE_strandren_get_winspeed(shi->obi, strand, 0); if (speed) copy_v4_v4(shi->winspeed, speed); else - shi->winspeed[0]= shi->winspeed[1]= shi->winspeed[2]= shi->winspeed[3]= 0.0f; + shi->winspeed[0] = shi->winspeed[1] = shi->winspeed[2] = shi->winspeed[3] = 0.0f; } /* shade_input_set_shade_texco equivalent */ @@ -441,109 +441,109 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert } if (texco & TEXCO_STRAND) { - shi->strandco= spoint->strandco; + shi->strandco = spoint->strandco; if (shi->osatex) { - shi->dxstrand= spoint->dtstrandco; - shi->dystrand= 0.0f; + shi->dxstrand = spoint->dtstrandco; + shi->dystrand = 0.0f; } } - if ((texco & TEXCO_UV) || (mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE))) { + if ((texco & TEXCO_UV) || (mode & (MA_VERTEXCOL | MA_VERTEXCOLP | MA_FACETEXTURE))) { MCol *mcol; float *uv; char *name; int i; - shi->totuv= 0; - shi->totcol= 0; - shi->actuv= obr->actmtface; - shi->actcol= obr->actmcol; + shi->totuv = 0; + shi->totcol = 0; + shi->actuv = obr->actmtface; + shi->actcol = obr->actmcol; - if (mode & (MA_VERTEXCOL|MA_VERTEXCOLP)) { - for (i=0; (mcol=RE_strandren_get_mcol(obr, strand, i, &name, 0)); i++) { - ShadeInputCol *scol= &shi->col[i]; - char *cp= (char*)mcol; + if (mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) { + for (i = 0; (mcol = RE_strandren_get_mcol(obr, strand, i, &name, 0)); i++) { + ShadeInputCol *scol = &shi->col[i]; + char *cp = (char *)mcol; shi->totcol++; - scol->name= name; + scol->name = name; - scol->col[0]= cp[3]/255.0f; - scol->col[1]= cp[2]/255.0f; - scol->col[2]= cp[1]/255.0f; - scol->col[3]= cp[0]/255.0f; + scol->col[0] = cp[3] / 255.0f; + scol->col[1] = cp[2] / 255.0f; + scol->col[2] = cp[1] / 255.0f; + scol->col[3] = cp[0] / 255.0f; } if (shi->totcol) { - shi->vcol[0]= shi->col[shi->actcol].col[0]; - shi->vcol[1]= shi->col[shi->actcol].col[1]; - shi->vcol[2]= shi->col[shi->actcol].col[2]; - shi->vcol[3]= shi->col[shi->actcol].col[3]; + shi->vcol[0] = shi->col[shi->actcol].col[0]; + shi->vcol[1] = shi->col[shi->actcol].col[1]; + shi->vcol[2] = shi->col[shi->actcol].col[2]; + shi->vcol[3] = shi->col[shi->actcol].col[3]; } else { - shi->vcol[0]= 0.0f; - shi->vcol[1]= 0.0f; - shi->vcol[2]= 0.0f; - shi->vcol[3]= 0.0f; + shi->vcol[0] = 0.0f; + shi->vcol[1] = 0.0f; + shi->vcol[2] = 0.0f; + shi->vcol[3] = 0.0f; } } - for (i=0; (uv=RE_strandren_get_uv(obr, strand, i, &name, 0)); i++) { - ShadeInputUV *suv= &shi->uv[i]; + for (i = 0; (uv = RE_strandren_get_uv(obr, strand, i, &name, 0)); i++) { + ShadeInputUV *suv = &shi->uv[i]; shi->totuv++; - suv->name= name; + suv->name = name; if (strandbuf->overrideuv == i) { - suv->uv[0]= -1.0f; - suv->uv[1]= spoint->strandco; - suv->uv[2]= 0.0f; + suv->uv[0] = -1.0f; + suv->uv[1] = spoint->strandco; + suv->uv[2] = 0.0f; } else { - suv->uv[0]= -1.0f + 2.0f*uv[0]; - suv->uv[1]= -1.0f + 2.0f*uv[1]; - suv->uv[2]= 0.0f; /* texture.c assumes there are 3 coords */ + suv->uv[0] = -1.0f + 2.0f * uv[0]; + suv->uv[1] = -1.0f + 2.0f * uv[1]; + suv->uv[2] = 0.0f; /* texture.c assumes there are 3 coords */ } if (shi->osatex) { - suv->dxuv[0]= 0.0f; - suv->dxuv[1]= 0.0f; - suv->dyuv[0]= 0.0f; - suv->dyuv[1]= 0.0f; + suv->dxuv[0] = 0.0f; + suv->dxuv[1] = 0.0f; + suv->dyuv[0] = 0.0f; + suv->dyuv[1] = 0.0f; } - if ((mode & MA_FACETEXTURE) && i==obr->actmtface) { - if ((mode & (MA_VERTEXCOL|MA_VERTEXCOLP))==0) { - shi->vcol[0]= 1.0f; - shi->vcol[1]= 1.0f; - shi->vcol[2]= 1.0f; - shi->vcol[3]= 1.0f; + if ((mode & MA_FACETEXTURE) && i == obr->actmtface) { + if ((mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) == 0) { + shi->vcol[0] = 1.0f; + shi->vcol[1] = 1.0f; + shi->vcol[2] = 1.0f; + shi->vcol[3] = 1.0f; } } } if (shi->totuv == 0) { - ShadeInputUV *suv= &shi->uv[0]; + ShadeInputUV *suv = &shi->uv[0]; - suv->uv[0]= 0.0f; - suv->uv[1]= spoint->strandco; - suv->uv[2]= 0.0f; /* texture.c assumes there are 3 coords */ + suv->uv[0] = 0.0f; + suv->uv[1] = spoint->strandco; + suv->uv[2] = 0.0f; /* texture.c assumes there are 3 coords */ if (mode & MA_FACETEXTURE) { /* no tface? set at 1.0f */ - shi->vcol[0]= 1.0f; - shi->vcol[1]= 1.0f; - shi->vcol[2]= 1.0f; - shi->vcol[3]= 1.0f; + shi->vcol[0] = 1.0f; + shi->vcol[1] = 1.0f; + shi->vcol[2] = 1.0f; + shi->vcol[3] = 1.0f; } } } if (texco & TEXCO_NORM) { - shi->orn[0]= -shi->vn[0]; - shi->orn[1]= -shi->vn[1]; - shi->orn[2]= -shi->vn[2]; + shi->orn[0] = -shi->vn[0]; + shi->orn[1] = -shi->vn[1]; + shi->orn[2] = -shi->vn[2]; } if (texco & TEXCO_STRESS) { @@ -551,27 +551,27 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert } if (texco & TEXCO_TANGENT) { - if ((mode & MA_TANGENT_V)==0) { + if ((mode & MA_TANGENT_V) == 0) { /* just prevent surprises */ - shi->tang[0]= shi->tang[1]= shi->tang[2]= 0.0f; - shi->nmaptang[0]= shi->nmaptang[1]= shi->nmaptang[2]= 0.0f; + shi->tang[0] = shi->tang[1] = shi->tang[2] = 0.0f; + shi->nmaptang[0] = shi->nmaptang[1] = shi->nmaptang[2] = 0.0f; } } } /* this only avalailable for scanline renders */ - if (shi->depth==0) { + if (shi->depth == 0) { if (texco & TEXCO_WINDOW) { - shi->winco[0]= -1.0f + 2.0f*spoint->x/(float)R.winx; - shi->winco[1]= -1.0f + 2.0f*spoint->y/(float)R.winy; - shi->winco[2]= 0.0f; + shi->winco[0] = -1.0f + 2.0f * spoint->x / (float)R.winx; + shi->winco[1] = -1.0f + 2.0f * spoint->y / (float)R.winy; + shi->winco[2] = 0.0f; /* not supported */ if (shi->osatex) { - shi->dxwin[0]= 0.0f; - shi->dywin[1]= 0.0f; - shi->dxwin[0]= 0.0f; - shi->dywin[1]= 0.0f; + shi->dxwin[0] = 0.0f; + shi->dywin[1] = 0.0f; + shi->dxwin[0] = 0.0f; + shi->dywin[1] = 0.0f; } } @@ -581,7 +581,7 @@ void shade_input_set_strand_texco(ShadeInput *shi, StrandRen *strand, StrandVert } if (shi->do_manage) { - if (mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE)) { + if (mode & (MA_VERTEXCOL | MA_VERTEXCOLP | MA_FACETEXTURE)) { srgb_to_linearrgb_v3_v3(shi->vcol, shi->vcol); } } @@ -615,37 +615,37 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float v /* ortho viewplane cannot intersect using view vector originating in (0,0,0) */ if (R.r.mode & R_ORTHO) { /* x and y 3d coordinate can be derived from pixel coord and winmat */ - float fx= 2.0f/(R.winx*R.winmat[0][0]); - float fy= 2.0f/(R.winy*R.winmat[1][1]); + float fx = 2.0f / (R.winx * R.winmat[0][0]); + float fy = 2.0f / (R.winy * R.winmat[1][1]); - co[0]= (x - 0.5f*R.winx)*fx - R.winmat[3][0]/R.winmat[0][0]; - co[1]= (y - 0.5f*R.winy)*fy - R.winmat[3][1]/R.winmat[1][1]; + co[0] = (x - 0.5f * R.winx) * fx - R.winmat[3][0] / R.winmat[0][0]; + co[1] = (y - 0.5f * R.winy) * fy - R.winmat[3][1] / R.winmat[1][1]; /* using a*x + b*y + c*z = d equation, (a b c) is normal */ - if (shi->facenor[2]!=0.0f) - co[2]= (dface - shi->facenor[0]*co[0] - shi->facenor[1]*co[1])/shi->facenor[2]; + if (shi->facenor[2] != 0.0f) + co[2] = (dface - shi->facenor[0] * co[0] - shi->facenor[1] * co[1]) / shi->facenor[2]; else - co[2]= 0.0f; + co[2] = 0.0f; if (dxco && dyco) { - dxco[0]= fx; - dxco[1]= 0.0f; - if (shi->facenor[2]!=0.0f) - dxco[2]= -(shi->facenor[0]*fx)/shi->facenor[2]; + dxco[0] = fx; + dxco[1] = 0.0f; + if (shi->facenor[2] != 0.0f) + dxco[2] = -(shi->facenor[0] * fx) / shi->facenor[2]; else - dxco[2]= 0.0f; + dxco[2] = 0.0f; - dyco[0]= 0.0f; - dyco[1]= fy; - if (shi->facenor[2]!=0.0f) - dyco[2]= -(shi->facenor[1]*fy)/shi->facenor[2]; + dyco[0] = 0.0f; + dyco[1] = fy; + if (shi->facenor[2] != 0.0f) + dyco[2] = -(shi->facenor[1] * fy) / shi->facenor[2]; else - dyco[2]= 0.0f; + dyco[2] = 0.0f; if (dxyview) { - if (co[2]!=0.0f) fac= 1.0f/co[2]; else fac= 0.0f; - dxyview[0]= -R.viewdx*fac; - dxyview[1]= -R.viewdy*fac; + if (co[2] != 0.0f) fac = 1.0f / co[2]; else fac = 0.0f; + dxyview[0] = -R.viewdx * fac; + dxyview[1] = -R.viewdy * fac; } } } @@ -653,30 +653,30 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float v float div; div = dot_v3v3(shi->facenor, view); - if (div!=0.0f) fac= dface/div; - else fac= 0.0f; + if (div != 0.0f) fac = dface / div; + else fac = 0.0f; - co[0]= fac*view[0]; - co[1]= fac*view[1]; - co[2]= fac*view[2]; + co[0] = fac * view[0]; + co[1] = fac * view[1]; + co[2] = fac * view[2]; /* pixel dx/dy for render coord */ if (dxco && dyco) { - float u= dface/(div - R.viewdx*shi->facenor[0]); - float v= dface/(div - R.viewdy*shi->facenor[1]); + float u = dface / (div - R.viewdx * shi->facenor[0]); + float v = dface / (div - R.viewdy * shi->facenor[1]); - dxco[0]= co[0]- (view[0]-R.viewdx)*u; - dxco[1]= co[1]- (view[1])*u; - dxco[2]= co[2]- (view[2])*u; - - dyco[0]= co[0]- (view[0])*v; - dyco[1]= co[1]- (view[1]-R.viewdy)*v; - dyco[2]= co[2]- (view[2])*v; + dxco[0] = co[0] - (view[0] - R.viewdx) * u; + dxco[1] = co[1] - (view[1]) * u; + dxco[2] = co[2] - (view[2]) * u; + + dyco[0] = co[0] - (view[0]) * v; + dyco[1] = co[1] - (view[1] - R.viewdy) * v; + dyco[2] = co[2] - (view[2]) * v; if (dxyview) { - if (fac!=0.0f) fac= 1.0f/fac; - dxyview[0]= -R.viewdx*fac; - dxyview[1]= -R.viewdy*fac; + if (fac != 0.0f) fac = 1.0f / fac; + dxyview[0] = -R.viewdx * fac; + dxyview[1] = -R.viewdy * fac; } } } @@ -693,24 +693,24 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float v /* from scanline pixel coordinates to 3d coordinates, requires set_triangle */ void shade_input_set_viewco(ShadeInput *shi, float x, float y, float xs, float ys, float z) { - float *dxyview= NULL, *dxco= NULL, *dyco= NULL; + float *dxyview = NULL, *dxco = NULL, *dyco = NULL; /* currently in use for dithering (soft shadow), node preview, irregular shad */ - shi->xs= (int)xs; - shi->ys= (int)ys; + shi->xs = (int)xs; + shi->ys = (int)ys; /* original scanline coordinate without jitter */ - shi->scanco[0]= x; - shi->scanco[1]= y; - shi->scanco[2]= z; + shi->scanco[0] = x; + shi->scanco[1] = y; + shi->scanco[2] = z; /* check if we need derivatives */ if (shi->osatex || (R.r.mode & R_SHADOW)) { - dxco= shi->dxco; - dyco= shi->dyco; + dxco = shi->dxco; + dyco = shi->dyco; if ((shi->mat->texco & TEXCO_REFL)) - dxyview= &shi->dxview; + dxyview = &shi->dxview; } shade_input_calc_viewco(shi, xs, ys, z, shi->view, dxyview, shi->co, dxco, dyco); @@ -719,7 +719,7 @@ void shade_input_set_viewco(ShadeInput *shi, float x, float y, float xs, float y /* calculate U and V, for scanline (silly render face u and v are in range -1 to 0) */ void shade_input_set_uv(ShadeInput *shi) { - VlakRen *vlr= shi->vlr; + VlakRen *vlr = shi->vlr; if ((vlr->flag & R_SMOOTH) || (shi->mat->texco & NEED_UV) || (shi->passflag & SCE_PASS_UV)) { float v1[3], v2[3], v3[3]; @@ -735,25 +735,25 @@ void shade_input_set_uv(ShadeInput *shi) } /* exception case for wire render of edge */ - if (vlr->v2==vlr->v3) { + if (vlr->v2 == vlr->v3) { float lend, lenc; - lend= len_v3v3(v2, v1); - lenc= len_v3v3(shi->co, v1); + lend = len_v3v3(v2, v1); + lenc = len_v3v3(shi->co, v1); - if (lend==0.0f) { - shi->u=shi->v= 0.0f; + if (lend == 0.0f) { + shi->u = shi->v = 0.0f; } else { - shi->u= - (1.0f - lenc/lend); - shi->v= 0.0f; + shi->u = -(1.0f - lenc / lend); + shi->v = 0.0f; } if (shi->osatex) { - shi->dx_u= 0.0f; - shi->dx_v= 0.0f; - shi->dy_u= 0.0f; - shi->dy_v= 0.0f; + shi->dx_u = 0.0f; + shi->dx_v = 0.0f; + shi->dy_u = 0.0f; + shi->dy_v = 0.0f; } } else { @@ -765,21 +765,21 @@ void shade_input_set_uv(ShadeInput *shi) axis_dominant_v3(&axis1, &axis2, shi->facenor); /* compute u,v and derivatives */ - t00= v3[axis1]-v1[axis1]; t01= v3[axis2]-v1[axis2]; - t10= v3[axis1]-v2[axis1]; t11= v3[axis2]-v2[axis2]; + t00 = v3[axis1] - v1[axis1]; t01 = v3[axis2] - v1[axis2]; + t10 = v3[axis1] - v2[axis1]; t11 = v3[axis2] - v2[axis2]; - detsh= (t00*t11-t10*t01); - detsh= (detsh != 0.0f)? 1.0f/detsh: 0.0f; - t00*= detsh; t01*=detsh; - t10*=detsh; t11*=detsh; + detsh = (t00 * t11 - t10 * t01); + detsh = (detsh != 0.0f) ? 1.0f / detsh : 0.0f; + t00 *= detsh; t01 *= detsh; + t10 *= detsh; t11 *= detsh; - shi->u= (shi->co[axis1]-v3[axis1])*t11-(shi->co[axis2]-v3[axis2])*t10; - shi->v= (shi->co[axis2]-v3[axis2])*t00-(shi->co[axis1]-v3[axis1])*t01; + shi->u = (shi->co[axis1] - v3[axis1]) * t11 - (shi->co[axis2] - v3[axis2]) * t10; + shi->v = (shi->co[axis2] - v3[axis2]) * t00 - (shi->co[axis1] - v3[axis1]) * t01; if (shi->osatex) { - shi->dx_u= shi->dxco[axis1]*t11- shi->dxco[axis2]*t10; - shi->dx_v= shi->dxco[axis2]*t00- shi->dxco[axis1]*t01; - shi->dy_u= shi->dyco[axis1]*t11- shi->dyco[axis2]*t10; - shi->dy_v= shi->dyco[axis2]*t00- shi->dyco[axis1]*t01; + shi->dx_u = shi->dxco[axis1] * t11 - shi->dxco[axis2] * t10; + shi->dx_v = shi->dxco[axis2] * t00 - shi->dxco[axis1] * t01; + shi->dy_u = shi->dyco[axis1] * t11 - shi->dyco[axis2] * t10; + shi->dy_v = shi->dyco[axis2] * t00 - shi->dyco[axis1] * t01; } /* u and v are in range -1 to 0, we allow a little bit extra but not too much, screws up speedvectors */ @@ -791,8 +791,8 @@ void shade_input_set_uv(ShadeInput *shi) void shade_input_set_normals(ShadeInput *shi) { - float u= shi->u, v= shi->v; - float l= 1.0f+u+v; + float u = shi->u, v = shi->v; + float l = 1.0f + u + v; shi->flippednor = 0; @@ -800,13 +800,13 @@ void shade_input_set_normals(ShadeInput *shi) if (!(shi->vlr->flag & R_TANGENT)) { if (dot_v3v3(shi->facenor, shi->view) < 0.0f) { negate_v3(shi->facenor); - shi->flippednor= 1; + shi->flippednor = 1; } } /* calculate vertexnormals */ if (shi->vlr->flag & R_SMOOTH) { - float *n1= shi->n1, *n2= shi->n2, *n3= shi->n3; + float *n1 = shi->n1, *n2 = shi->n2, *n3 = shi->n3; if (shi->flippednor) { negate_v3(n1); @@ -814,9 +814,9 @@ void shade_input_set_normals(ShadeInput *shi) negate_v3(n3); } - shi->vn[0]= l*n3[0]-u*n1[0]-v*n2[0]; - shi->vn[1]= l*n3[1]-u*n1[1]-v*n2[1]; - shi->vn[2]= l*n3[2]-u*n1[2]-v*n2[2]; + shi->vn[0] = l * n3[0] - u * n1[0] - v * n2[0]; + 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) */ copy_v3_v3(shi->nmapnorm, shi->vn); @@ -840,16 +840,16 @@ void shade_input_set_normals(ShadeInput *shi) /* XXX shi->flippednor messes up otherwise */ void shade_input_set_vertex_normals(ShadeInput *shi) { - float u= shi->u, v= shi->v; - float l= 1.0f+u+v; + float u = shi->u, v = shi->v; + float l = 1.0f + u + v; /* calculate vertexnormals */ if (shi->vlr->flag & R_SMOOTH) { - float *n1= shi->n1, *n2= shi->n2, *n3= shi->n3; + const float *n1 = shi->n1, *n2 = shi->n2, *n3 = shi->n3; - shi->vn[0]= l*n3[0]-u*n1[0]-v*n2[0]; - shi->vn[1]= l*n3[1]-u*n1[1]-v*n2[1]; - shi->vn[2]= l*n3[2]-u*n1[2]-v*n2[2]; + shi->vn[0] = l * n3[0] - u * n1[0] - v * n2[0]; + 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) */ copy_v3_v3(shi->nmapnorm, shi->vn); @@ -869,73 +869,61 @@ void shade_input_set_vertex_normals(ShadeInput *shi) /* use by raytrace, sss, bake to flip into the right direction */ void shade_input_flip_normals(ShadeInput *shi) { - shi->facenor[0]= -shi->facenor[0]; - shi->facenor[1]= -shi->facenor[1]; - shi->facenor[2]= -shi->facenor[2]; - - shi->vn[0]= -shi->vn[0]; - shi->vn[1]= -shi->vn[1]; - shi->vn[2]= -shi->vn[2]; - - shi->vno[0]= -shi->vno[0]; - shi->vno[1]= -shi->vno[1]; - shi->vno[2]= -shi->vno[2]; - - shi->nmapnorm[0] = -shi->nmapnorm[0]; - shi->nmapnorm[1] = -shi->nmapnorm[1]; - shi->nmapnorm[2] = -shi->nmapnorm[2]; - - shi->flippednor= !shi->flippednor; + negate_v3(shi->facenor); + negate_v3(shi->vn); + negate_v3(shi->vno); + negate_v3(shi->nmapnorm); + shi->flippednor = !shi->flippednor; } void shade_input_set_shade_texco(ShadeInput *shi) { - ObjectInstanceRen *obi= shi->obi; - ObjectRen *obr= shi->obr; - VertRen *v1= shi->v1, *v2= shi->v2, *v3= shi->v3; - float u= shi->u, v= shi->v; - float l= 1.0f+u+v, dl; - int mode= shi->mode; /* or-ed result for all nodes */ - short texco= shi->mat->texco; + ObjectInstanceRen *obi = shi->obi; + ObjectRen *obr = shi->obr; + VertRen *v1 = shi->v1, *v2 = shi->v2, *v3 = shi->v3; + float u = shi->u, v = shi->v; + float l = 1.0f + u + v, dl; + int mode = shi->mode; /* or-ed result for all nodes */ + short texco = shi->mat->texco; /* calculate dxno */ if (shi->vlr->flag & R_SMOOTH) { - if (shi->osatex && (texco & (TEXCO_NORM|TEXCO_REFL)) ) { - float *n1= shi->n1, *n2= shi->n2, *n3= shi->n3; + if (shi->osatex && (texco & (TEXCO_NORM | TEXCO_REFL)) ) { + float *n1 = shi->n1, *n2 = shi->n2, *n3 = shi->n3; - dl= shi->dx_u+shi->dx_v; - shi->dxno[0]= dl*n3[0]-shi->dx_u*n1[0]-shi->dx_v*n2[0]; - shi->dxno[1]= dl*n3[1]-shi->dx_u*n1[1]-shi->dx_v*n2[1]; - shi->dxno[2]= dl*n3[2]-shi->dx_u*n1[2]-shi->dx_v*n2[2]; - dl= shi->dy_u+shi->dy_v; - shi->dyno[0]= dl*n3[0]-shi->dy_u*n1[0]-shi->dy_v*n2[0]; - shi->dyno[1]= dl*n3[1]-shi->dy_u*n1[1]-shi->dy_v*n2[1]; - shi->dyno[2]= dl*n3[2]-shi->dy_u*n1[2]-shi->dy_v*n2[2]; + dl = shi->dx_u + shi->dx_v; + shi->dxno[0] = dl * n3[0] - shi->dx_u * n1[0] - shi->dx_v * n2[0]; + shi->dxno[1] = dl * n3[1] - shi->dx_u * n1[1] - shi->dx_v * n2[1]; + shi->dxno[2] = dl * n3[2] - shi->dx_u * n1[2] - shi->dx_v * n2[2]; + dl = shi->dy_u + shi->dy_v; + shi->dyno[0] = dl * n3[0] - shi->dy_u * n1[0] - shi->dy_v * n2[0]; + shi->dyno[1] = dl * n3[1] - shi->dy_u * n1[1] - shi->dy_v * n2[1]; + shi->dyno[2] = dl * n3[2] - shi->dy_u * n1[2] - shi->dy_v * n2[2]; } } /* calc tangents */ - if (mode & (MA_TANGENT_V|MA_NORMAP_TANG) || R.flag & R_NEED_TANGENT) { + if (mode & (MA_TANGENT_V | MA_NORMAP_TANG) || R.flag & R_NEED_TANGENT) { float *tangent, *s1, *s2, *s3; float tl, tu, tv; if (shi->vlr->flag & R_SMOOTH) { - tl= l; - tu= u; - tv= v; + tl = l; + tu = u; + tv = v; } else { /* qdn: flat faces have tangents too, * could pick either one, using average here */ - tl= 1.0f/3.0f; - tu= -1.0f/3.0f; - tv= -1.0f/3.0f; + tl = 1.0f / 3.0f; + tu = -1.0f / 3.0f; + tv = -1.0f / 3.0f; } - shi->tang[0]= shi->tang[1]= shi->tang[2]= 0.0f; - shi->nmaptang[0]= shi->nmaptang[1]= shi->nmaptang[2]= 0.0f; + shi->tang[0] = shi->tang[1] = shi->tang[2] = 0.0f; + shi->nmaptang[0] = shi->nmaptang[1] = shi->nmaptang[2] = 0.0f; if (mode & MA_TANGENT_V) { s1 = RE_vertren_get_tangent(obr, v1, 0); @@ -943,9 +931,9 @@ void shade_input_set_shade_texco(ShadeInput *shi) s3 = RE_vertren_get_tangent(obr, v3, 0); if (s1 && s2 && s3) { - shi->tang[0]= (tl*s3[0] - tu*s1[0] - tv*s2[0]); - shi->tang[1]= (tl*s3[1] - tu*s1[1] - tv*s2[1]); - shi->tang[2]= (tl*s3[2] - tu*s1[2] - tv*s2[2]); + shi->tang[0] = (tl * s3[0] - tu * s1[0] - tv * s2[0]); + shi->tang[1] = (tl * s3[1] - tu * s1[1] - tv * s2[1]); + shi->tang[2] = (tl * s3[2] - tu * s1[2] - tv * s2[2]); if (obi->flag & R_TRANSFORMED) mul_m3_v3(obi->nmat, shi->tang); @@ -956,17 +944,17 @@ void shade_input_set_shade_texco(ShadeInput *shi) } if (mode & MA_NORMAP_TANG || R.flag & R_NEED_TANGENT) { - tangent= RE_vlakren_get_nmap_tangent(obr, shi->vlr, 0); + tangent = RE_vlakren_get_nmap_tangent(obr, shi->vlr, 0); if (tangent) { - int j1= shi->i1, j2= shi->i2, j3= shi->i3; + int j1 = shi->i1, j2 = shi->i2, j3 = shi->i3; float c0[3], c1[3], c2[3]; vlr_set_uv_indices(shi->vlr, &j1, &j2, &j3); - copy_v3_v3(c0, &tangent[j1*4]); - copy_v3_v3(c1, &tangent[j2*4]); - copy_v3_v3(c2, &tangent[j3*4]); + copy_v3_v3(c0, &tangent[j1 * 4]); + 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 */ @@ -978,19 +966,19 @@ void shade_input_set_shade_texco(ShadeInput *shi) /* 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]); + 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. */ - shi->nmaptang[3]= tangent[j1*4+3]; + shi->nmaptang[3] = tangent[j1 * 4 + 3]; } } } if (mode & MA_STR_SURFDIFF) { - float *surfnor= RE_vlakren_get_surfnor(obr, shi->vlr, 0); + float *surfnor = RE_vlakren_get_surfnor(obr, shi->vlr, 0); if (surfnor) { copy_v3_v3(shi->surfnor, surfnor); @@ -1000,29 +988,29 @@ void shade_input_set_shade_texco(ShadeInput *shi) else copy_v3_v3(shi->surfnor, shi->vn); - shi->surfdist= 0.0f; + shi->surfdist = 0.0f; } if (R.r.mode & R_SPEED) { float *s1, *s2, *s3; - s1= RE_vertren_get_winspeed(obi, v1, 0); - s2= RE_vertren_get_winspeed(obi, v2, 0); - s3= RE_vertren_get_winspeed(obi, v3, 0); + s1 = RE_vertren_get_winspeed(obi, v1, 0); + s2 = RE_vertren_get_winspeed(obi, v2, 0); + s3 = RE_vertren_get_winspeed(obi, v3, 0); if (s1 && s2 && s3) { - shi->winspeed[0]= (l*s3[0] - u*s1[0] - v*s2[0]); - shi->winspeed[1]= (l*s3[1] - u*s1[1] - v*s2[1]); - shi->winspeed[2]= (l*s3[2] - u*s1[2] - v*s2[2]); - shi->winspeed[3]= (l*s3[3] - u*s1[3] - v*s2[3]); + shi->winspeed[0] = (l * s3[0] - u * s1[0] - v * s2[0]); + shi->winspeed[1] = (l * s3[1] - u * s1[1] - v * s2[1]); + shi->winspeed[2] = (l * s3[2] - u * s1[2] - v * s2[2]); + shi->winspeed[3] = (l * s3[3] - u * s1[3] - v * s2[3]); } else { - shi->winspeed[0]= shi->winspeed[1]= shi->winspeed[2]= shi->winspeed[3]= 0.0f; + shi->winspeed[0] = shi->winspeed[1] = shi->winspeed[2] = shi->winspeed[3] = 0.0f; } } /* pass option forces UV calc */ if (shi->passflag & SCE_PASS_UV) - texco |= (NEED_UV|TEXCO_UV); + texco |= (NEED_UV | TEXCO_UV); /* texture coordinates. shi->dxuv shi->dyuv have been set */ if (texco & NEED_UV) { @@ -1031,23 +1019,23 @@ void shade_input_set_shade_texco(ShadeInput *shi) if (v1->orco) { float *o1, *o2, *o3; - o1= v1->orco; - o2= v2->orco; - o3= v3->orco; - - shi->lo[0]= l*o3[0]-u*o1[0]-v*o2[0]; - shi->lo[1]= l*o3[1]-u*o1[1]-v*o2[1]; - shi->lo[2]= l*o3[2]-u*o1[2]-v*o2[2]; + o1 = v1->orco; + o2 = v2->orco; + o3 = v3->orco; + + shi->lo[0] = l * o3[0] - u * o1[0] - v * o2[0]; + shi->lo[1] = l * o3[1] - u * o1[1] - v * o2[1]; + shi->lo[2] = l * o3[2] - u * o1[2] - v * o2[2]; if (shi->osatex) { - dl= shi->dx_u+shi->dx_v; - shi->dxlo[0]= dl*o3[0]-shi->dx_u*o1[0]-shi->dx_v*o2[0]; - shi->dxlo[1]= dl*o3[1]-shi->dx_u*o1[1]-shi->dx_v*o2[1]; - shi->dxlo[2]= dl*o3[2]-shi->dx_u*o1[2]-shi->dx_v*o2[2]; - dl= shi->dy_u+shi->dy_v; - shi->dylo[0]= dl*o3[0]-shi->dy_u*o1[0]-shi->dy_v*o2[0]; - shi->dylo[1]= dl*o3[1]-shi->dy_u*o1[1]-shi->dy_v*o2[1]; - shi->dylo[2]= dl*o3[2]-shi->dy_u*o1[2]-shi->dy_v*o2[2]; + dl = shi->dx_u + shi->dx_v; + shi->dxlo[0] = dl * o3[0] - shi->dx_u * o1[0] - shi->dx_v * o2[0]; + shi->dxlo[1] = dl * o3[1] - shi->dx_u * o1[1] - shi->dx_v * o2[1]; + shi->dxlo[2] = dl * o3[2] - shi->dx_u * o1[2] - shi->dx_v * o2[2]; + dl = shi->dy_u + shi->dy_v; + shi->dylo[0] = dl * o3[0] - shi->dy_u * o1[0] - shi->dy_v * o2[0]; + shi->dylo[1] = dl * o3[1] - shi->dy_u * o1[1] - shi->dy_v * o2[1]; + shi->dylo[2] = dl * o3[2] - shi->dy_u * o1[2] - shi->dy_v * o2[2]; } } @@ -1066,113 +1054,113 @@ void shade_input_set_shade_texco(ShadeInput *shi) } if (texco & TEXCO_STRAND) { - shi->strandco= (l*v3->accum - u*v1->accum - v*v2->accum); + shi->strandco = (l * v3->accum - u * v1->accum - v * v2->accum); if (shi->osatex) { - dl= shi->dx_u+shi->dx_v; - shi->dxstrand= dl*v3->accum-shi->dx_u*v1->accum-shi->dx_v*v2->accum; - dl= shi->dy_u+shi->dy_v; - shi->dystrand= dl*v3->accum-shi->dy_u*v1->accum-shi->dy_v*v2->accum; + dl = shi->dx_u + shi->dx_v; + shi->dxstrand = dl * v3->accum - shi->dx_u * v1->accum - shi->dx_v * v2->accum; + dl = shi->dy_u + shi->dy_v; + shi->dystrand = dl * v3->accum - shi->dy_u * v1->accum - shi->dy_v * v2->accum; } } - if ((texco & TEXCO_UV) || (mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE))) { - VlakRen *vlr= shi->vlr; + if ((texco & TEXCO_UV) || (mode & (MA_VERTEXCOL | MA_VERTEXCOLP | MA_FACETEXTURE))) { + VlakRen *vlr = shi->vlr; MTFace *tface; MCol *mcol; char *name; - int i, j1=shi->i1, j2=shi->i2, j3=shi->i3; + int i, j1 = shi->i1, j2 = shi->i2, j3 = shi->i3; /* uv and vcols are not copied on split, so set them according vlr divide flag */ vlr_set_uv_indices(vlr, &j1, &j2, &j3); - shi->totuv= 0; - shi->totcol= 0; - shi->actuv= obr->actmtface; - shi->actcol= obr->actmcol; + shi->totuv = 0; + shi->totcol = 0; + shi->actuv = obr->actmtface; + shi->actcol = obr->actmcol; - if (mode & (MA_VERTEXCOL|MA_VERTEXCOLP)) { - for (i=0; (mcol=RE_vlakren_get_mcol(obr, vlr, i, &name, 0)); i++) { - ShadeInputCol *scol= &shi->col[i]; + if (mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) { + for (i = 0; (mcol = RE_vlakren_get_mcol(obr, vlr, i, &name, 0)); i++) { + ShadeInputCol *scol = &shi->col[i]; char *cp1, *cp2, *cp3; float a[3]; shi->totcol++; - scol->name= name; + scol->name = name; - cp1= (char *)(mcol+j1); - cp2= (char *)(mcol+j2); - cp3= (char *)(mcol+j3); + cp1 = (char *)(mcol + j1); + cp2 = (char *)(mcol + j2); + cp3 = (char *)(mcol + j3); /* alpha values */ - a[0] = ((float)cp1[0])/255.f; - a[1] = ((float)cp2[0])/255.f; - a[2] = ((float)cp3[0])/255.f; - scol->col[3]= l*a[2] - u*a[0] - v*a[1]; + a[0] = ((float)cp1[0]) / 255.f; + a[1] = ((float)cp2[0]) / 255.f; + a[2] = ((float)cp3[0]) / 255.f; + scol->col[3] = l * a[2] - u * a[0] - v * a[1]; /* sample premultiplied color value */ - scol->col[0]= (l*((float)cp3[3])*a[2] - u*((float)cp1[3])*a[0] - v*((float)cp2[3])*a[1])/255.f; - scol->col[1]= (l*((float)cp3[2])*a[2] - u*((float)cp1[2])*a[0] - v*((float)cp2[2])*a[1])/255.f; - scol->col[2]= (l*((float)cp3[1])*a[2] - u*((float)cp1[1])*a[0] - v*((float)cp2[1])*a[1])/255.f; + scol->col[0] = (l * ((float)cp3[3]) * a[2] - u * ((float)cp1[3]) * a[0] - v * ((float)cp2[3]) * a[1]) / 255.f; + scol->col[1] = (l * ((float)cp3[2]) * a[2] - u * ((float)cp1[2]) * a[0] - v * ((float)cp2[2]) * a[1]) / 255.f; + scol->col[2] = (l * ((float)cp3[1]) * a[2] - u * ((float)cp1[1]) * a[0] - v * ((float)cp2[1]) * a[1]) / 255.f; /* if not zero alpha, restore non-multiplied color */ if (scol->col[3]) { - mul_v3_fl(scol->col, 1.0f/scol->col[3]); + mul_v3_fl(scol->col, 1.0f / scol->col[3]); } } if (shi->totcol) { - shi->vcol[0]= shi->col[shi->actcol].col[0]; - shi->vcol[1]= shi->col[shi->actcol].col[1]; - shi->vcol[2]= shi->col[shi->actcol].col[2]; - shi->vcol[3]= shi->col[shi->actcol].col[3]; + shi->vcol[0] = shi->col[shi->actcol].col[0]; + shi->vcol[1] = shi->col[shi->actcol].col[1]; + shi->vcol[2] = shi->col[shi->actcol].col[2]; + shi->vcol[3] = shi->col[shi->actcol].col[3]; } else { - shi->vcol[0]= 0.0f; - shi->vcol[1]= 0.0f; - shi->vcol[2]= 0.0f; - shi->vcol[3]= 1.0f; + shi->vcol[0] = 0.0f; + shi->vcol[1] = 0.0f; + shi->vcol[2] = 0.0f; + shi->vcol[3] = 1.0f; } } - for (i=0; (tface=RE_vlakren_get_tface(obr, vlr, i, &name, 0)); i++) { - ShadeInputUV *suv= &shi->uv[i]; + for (i = 0; (tface = RE_vlakren_get_tface(obr, vlr, i, &name, 0)); i++) { + ShadeInputUV *suv = &shi->uv[i]; float *uv1, *uv2, *uv3; shi->totuv++; - suv->name= name; + suv->name = name; - uv1= tface->uv[j1]; - uv2= tface->uv[j2]; - uv3= tface->uv[j3]; - - suv->uv[0]= -1.0f + 2.0f*(l*uv3[0]-u*uv1[0]-v*uv2[0]); - suv->uv[1]= -1.0f + 2.0f*(l*uv3[1]-u*uv1[1]-v*uv2[1]); - suv->uv[2]= 0.0f; /* texture.c assumes there are 3 coords */ + uv1 = tface->uv[j1]; + uv2 = tface->uv[j2]; + uv3 = tface->uv[j3]; + + suv->uv[0] = -1.0f + 2.0f * (l * uv3[0] - u * uv1[0] - v * uv2[0]); + suv->uv[1] = -1.0f + 2.0f * (l * uv3[1] - u * uv1[1] - v * uv2[1]); + suv->uv[2] = 0.0f; /* texture.c assumes there are 3 coords */ if (shi->osatex) { float duv[2]; - dl= shi->dx_u+shi->dx_v; - duv[0]= shi->dx_u; - duv[1]= shi->dx_v; - - suv->dxuv[0]= 2.0f*(dl*uv3[0]-duv[0]*uv1[0]-duv[1]*uv2[0]); - suv->dxuv[1]= 2.0f*(dl*uv3[1]-duv[0]*uv1[1]-duv[1]*uv2[1]); - - dl= shi->dy_u+shi->dy_v; - duv[0]= shi->dy_u; - duv[1]= shi->dy_v; - - suv->dyuv[0]= 2.0f*(dl*uv3[0]-duv[0]*uv1[0]-duv[1]*uv2[0]); - suv->dyuv[1]= 2.0f*(dl*uv3[1]-duv[0]*uv1[1]-duv[1]*uv2[1]); + dl = shi->dx_u + shi->dx_v; + duv[0] = shi->dx_u; + duv[1] = shi->dx_v; + + suv->dxuv[0] = 2.0f * (dl * uv3[0] - duv[0] * uv1[0] - duv[1] * uv2[0]); + suv->dxuv[1] = 2.0f * (dl * uv3[1] - duv[0] * uv1[1] - duv[1] * uv2[1]); + + dl = shi->dy_u + shi->dy_v; + duv[0] = shi->dy_u; + duv[1] = shi->dy_v; + + suv->dyuv[0] = 2.0f * (dl * uv3[0] - duv[0] * uv1[0] - duv[1] * uv2[0]); + suv->dyuv[1] = 2.0f * (dl * uv3[1] - duv[0] * uv1[1] - duv[1] * uv2[1]); } - if ((mode & MA_FACETEXTURE) && i==obr->actmtface) { - if ((mode & (MA_VERTEXCOL|MA_VERTEXCOLP))==0) { - shi->vcol[0]= 1.0f; - shi->vcol[1]= 1.0f; - shi->vcol[2]= 1.0f; - shi->vcol[3]= 1.0f; + if ((mode & MA_FACETEXTURE) && i == obr->actmtface) { + if ((mode & (MA_VERTEXCOL | MA_VERTEXCOLP)) == 0) { + shi->vcol[0] = 1.0f; + shi->vcol[1] = 1.0f; + shi->vcol[2] = 1.0f; + shi->vcol[3] = 1.0f; } if (tface->tpage) { render_realtime_texture(shi, tface->tpage); @@ -1182,79 +1170,79 @@ void shade_input_set_shade_texco(ShadeInput *shi) } - shi->dupliuv[0]= -1.0f + 2.0f*obi->dupliuv[0]; - shi->dupliuv[1]= -1.0f + 2.0f*obi->dupliuv[1]; - shi->dupliuv[2]= 0.0f; + shi->dupliuv[0] = -1.0f + 2.0f * obi->dupliuv[0]; + shi->dupliuv[1] = -1.0f + 2.0f * obi->dupliuv[1]; + shi->dupliuv[2] = 0.0f; if (shi->totuv == 0) { - ShadeInputUV *suv= &shi->uv[0]; + ShadeInputUV *suv = &shi->uv[0]; - suv->uv[0]= 2.0f*(u+.5f); - suv->uv[1]= 2.0f*(v+.5f); - suv->uv[2]= 0.0f; /* texture.c assumes there are 3 coords */ + suv->uv[0] = 2.0f * (u + .5f); + suv->uv[1] = 2.0f * (v + .5f); + suv->uv[2] = 0.0f; /* texture.c assumes there are 3 coords */ if (mode & MA_FACETEXTURE) { /* no tface? set at 1.0f */ - shi->vcol[0]= 1.0f; - shi->vcol[1]= 1.0f; - shi->vcol[2]= 1.0f; - shi->vcol[3]= 1.0f; + shi->vcol[0] = 1.0f; + shi->vcol[1] = 1.0f; + shi->vcol[2] = 1.0f; + shi->vcol[3] = 1.0f; } } } if (texco & TEXCO_NORM) { - shi->orn[0]= -shi->vn[0]; - shi->orn[1]= -shi->vn[1]; - shi->orn[2]= -shi->vn[2]; + shi->orn[0] = -shi->vn[0]; + shi->orn[1] = -shi->vn[1]; + shi->orn[2] = -shi->vn[2]; } if (texco & TEXCO_STRESS) { float *s1, *s2, *s3; - s1= RE_vertren_get_stress(obr, v1, 0); - s2= RE_vertren_get_stress(obr, v2, 0); - s3= RE_vertren_get_stress(obr, v3, 0); + s1 = RE_vertren_get_stress(obr, v1, 0); + s2 = RE_vertren_get_stress(obr, v2, 0); + s3 = RE_vertren_get_stress(obr, v3, 0); if (s1 && s2 && s3) { - shi->stress= l*s3[0] - u*s1[0] - v*s2[0]; - if (shi->stress<1.0f) shi->stress-= 1.0f; - else shi->stress= (shi->stress-1.0f)/shi->stress; + shi->stress = l * s3[0] - u * s1[0] - v * s2[0]; + if (shi->stress < 1.0f) shi->stress -= 1.0f; + else shi->stress = (shi->stress - 1.0f) / shi->stress; } - else shi->stress= 0.0f; + else shi->stress = 0.0f; } if (texco & TEXCO_TANGENT) { - if ((mode & MA_TANGENT_V)==0) { + if ((mode & MA_TANGENT_V) == 0) { /* just prevent surprises */ - shi->tang[0]= shi->tang[1]= shi->tang[2]= 0.0f; - shi->nmaptang[0]= shi->nmaptang[1]= shi->nmaptang[2]= 0.0f; + shi->tang[0] = shi->tang[1] = shi->tang[2] = 0.0f; + shi->nmaptang[0] = shi->nmaptang[1] = shi->nmaptang[2] = 0.0f; } } } /* this only avalailable for scanline renders */ - if (shi->depth==0) { - float x= shi->xs; - float y= shi->ys; + if (shi->depth == 0) { + float x = shi->xs; + float y = shi->ys; if (texco & TEXCO_WINDOW) { - shi->winco[0]= -1.0f + 2.0f*x/(float)R.winx; - shi->winco[1]= -1.0f + 2.0f*y/(float)R.winy; - shi->winco[2]= 0.0f; + shi->winco[0] = -1.0f + 2.0f * x / (float)R.winx; + shi->winco[1] = -1.0f + 2.0f * y / (float)R.winy; + shi->winco[2] = 0.0f; if (shi->osatex) { - shi->dxwin[0]= 2.0f/(float)R.winx; - shi->dywin[1]= 2.0f/(float)R.winy; - shi->dxwin[1]= shi->dxwin[2]= 0.0f; - shi->dywin[0]= shi->dywin[2]= 0.0f; + shi->dxwin[0] = 2.0f / (float)R.winx; + shi->dywin[1] = 2.0f / (float)R.winy; + shi->dxwin[1] = shi->dxwin[2] = 0.0f; + shi->dywin[0] = shi->dywin[2] = 0.0f; } } if (texco & TEXCO_STICKY) { float *s1, *s2, *s3; - s1= RE_vertren_get_sticky(obr, v1, 0); - s2= RE_vertren_get_sticky(obr, v2, 0); - s3= RE_vertren_get_sticky(obr, v3, 0); + s1 = RE_vertren_get_sticky(obr, v1, 0); + s2 = RE_vertren_get_sticky(obr, v2, 0); + s3 = RE_vertren_get_sticky(obr, v3, 0); if (s1 && s2 && s3) { float obwinmat[4][4], winmat[4][4], ho1[4], ho2[4], ho3[4]; @@ -1263,7 +1251,7 @@ void shade_input_set_shade_texco(ShadeInput *shi) float s00, s01, s10, s11, detsh; /* old globals, localized now */ - Zmulx= ((float)R.winx)/2.0f; Zmuly= ((float)R.winy)/2.0f; + Zmulx = ((float)R.winx) / 2.0f; Zmuly = ((float)R.winy) / 2.0f; zbuf_make_winmat(&R, winmat); if (shi->obi->flag & R_TRANSFORMED) @@ -1275,40 +1263,40 @@ void shade_input_set_shade_texco(ShadeInput *shi) zbuf_render_project(obwinmat, v2->co, ho2); zbuf_render_project(obwinmat, v3->co, ho3); - s00= ho3[0]/ho3[3] - ho1[0]/ho1[3]; - s01= ho3[1]/ho3[3] - ho1[1]/ho1[3]; - s10= ho3[0]/ho3[3] - ho2[0]/ho2[3]; - s11= ho3[1]/ho3[3] - ho2[1]/ho2[3]; - - detsh= s00*s11-s10*s01; - detsh= (detsh != 0.0f)? 1.0f/detsh: 0.0f; - s00*= detsh; s01*=detsh; - s10*=detsh; s11*=detsh; + s00 = ho3[0] / ho3[3] - ho1[0] / ho1[3]; + s01 = ho3[1] / ho3[3] - ho1[1] / ho1[3]; + s10 = ho3[0] / ho3[3] - ho2[0] / ho2[3]; + s11 = ho3[1] / ho3[3] - ho2[1] / ho2[3]; + + detsh = s00 * s11 - s10 * s01; + detsh = (detsh != 0.0f) ? 1.0f / detsh : 0.0f; + s00 *= detsh; s01 *= detsh; + s10 *= detsh; s11 *= detsh; /* recalc u and v again */ - hox= x/Zmulx -1.0f; - hoy= y/Zmuly -1.0f; - u= (hox - ho3[0]/ho3[3])*s11 - (hoy - ho3[1]/ho3[3])*s10; - v= (hoy - ho3[1]/ho3[3])*s00 - (hox - ho3[0]/ho3[3])*s01; - l= 1.0f+u+v; - - shi->sticky[0]= l*s3[0]-u*s1[0]-v*s2[0]; - shi->sticky[1]= l*s3[1]-u*s1[1]-v*s2[1]; - shi->sticky[2]= 0.0f; + hox = x / Zmulx - 1.0f; + hoy = y / Zmuly - 1.0f; + u = (hox - ho3[0] / ho3[3]) * s11 - (hoy - ho3[1] / ho3[3]) * s10; + v = (hoy - ho3[1] / ho3[3]) * s00 - (hox - ho3[0] / ho3[3]) * s01; + l = 1.0f + u + v; + + shi->sticky[0] = l * s3[0] - u * s1[0] - v * s2[0]; + shi->sticky[1] = l * s3[1] - u * s1[1] - v * s2[1]; + shi->sticky[2] = 0.0f; if (shi->osatex) { float dxuv[2], dyuv[2]; - dxuv[0]= s11/Zmulx; - dxuv[1]= - s01/Zmulx; - dyuv[0]= - s10/Zmuly; - dyuv[1]= s00/Zmuly; - - dl= dxuv[0] + dxuv[1]; - shi->dxsticky[0]= dl*s3[0] - dxuv[0]*s1[0] - dxuv[1]*s2[0]; - shi->dxsticky[1]= dl*s3[1] - dxuv[0]*s1[1] - dxuv[1]*s2[1]; - dl= dyuv[0] + dyuv[1]; - shi->dysticky[0]= dl*s3[0] - dyuv[0]*s1[0] - dyuv[1]*s2[0]; - shi->dysticky[1]= dl*s3[1] - dyuv[0]*s1[1] - dyuv[1]*s2[1]; + dxuv[0] = s11 / Zmulx; + dxuv[1] = -s01 / Zmulx; + dyuv[0] = -s10 / Zmuly; + dyuv[1] = s00 / Zmuly; + + dl = dxuv[0] + dxuv[1]; + shi->dxsticky[0] = dl * s3[0] - dxuv[0] * s1[0] - dxuv[1] * s2[0]; + shi->dxsticky[1] = dl * s3[1] - dxuv[0] * s1[1] - dxuv[1] * s2[1]; + dl = dyuv[0] + dyuv[1]; + shi->dysticky[0] = dl * s3[0] - dyuv[0] * s1[0] - dyuv[1] * s2[0]; + shi->dysticky[1] = dl * s3[1] - dyuv[0] * s1[1] - dyuv[1] * s2[1]; } } } @@ -1319,7 +1307,7 @@ void shade_input_set_shade_texco(ShadeInput *shi) * else un-initialized values are used */ if (shi->do_manage) { - if (mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE)) { + if (mode & (MA_VERTEXCOL | MA_VERTEXCOLP | MA_FACETEXTURE)) { srgb_to_linearrgb_v3_v3(shi->vcol, shi->vcol); } } @@ -1334,16 +1322,16 @@ void shade_input_initialize(ShadeInput *shi, RenderPart *pa, RenderLayer *rl, in memset(shi, 0, sizeof(ShadeInput)); - shi->sample= sample; - shi->thread= pa->thread; - shi->do_preview= (R.r.scemode & R_MATNODE_PREVIEW) != 0; - shi->do_manage= (R.r.color_mgt_flag & R_COLOR_MANAGEMENT); - shi->lay= rl->lay; - shi->layflag= rl->layflag; - shi->passflag= rl->passflag; - shi->combinedflag= ~rl->pass_xor; - shi->mat_override= rl->mat_override; - shi->light_override= rl->light_override; + shi->sample = sample; + shi->thread = pa->thread; + shi->do_preview = (R.r.scemode & R_MATNODE_PREVIEW) != 0; + shi->do_manage = (R.r.color_mgt_flag & R_COLOR_MANAGEMENT); + shi->lay = rl->lay; + shi->layflag = rl->layflag; + shi->passflag = rl->passflag; + shi->combinedflag = ~rl->pass_xor; + shi->mat_override = rl->mat_override; + shi->light_override = rl->light_override; // shi->rl= rl; /* note shi.depth==0 means first hit, not raytracing */ @@ -1354,9 +1342,9 @@ void shade_sample_initialize(ShadeSample *ssamp, RenderPart *pa, RenderLayer *rl { int a, tot; - tot= R.osa==0?1:R.osa; + tot = R.osa == 0 ? 1 : R.osa; - for (a=0; a<tot; a++) { + for (a = 0; a < tot; a++) { shade_input_initialize(&ssamp->shi[a], pa, rl, a); memset(&ssamp->shr[a], 0, sizeof(ShadeResult)); } @@ -1372,16 +1360,16 @@ void shade_samples_do_AO(ShadeSample *ssamp) if (!(R.r.mode & R_RAYTRACE) && !(R.wrld.ao_gather_method == WO_AOGATHER_APPROX)) return; - if (R.wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) { - ShadeInput *shi= &ssamp->shi[0]; + if (R.wrld.mode & (WO_AMB_OCC | WO_ENV_LIGHT | WO_INDIRECT_LIGHT)) { + ShadeInput *shi = &ssamp->shi[0]; int sample; - if (((shi->passflag & SCE_PASS_COMBINED) && (shi->combinedflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) || - (shi->passflag & (SCE_PASS_AO|SCE_PASS_ENVIRONMENT|SCE_PASS_INDIRECT))) + if (((shi->passflag & SCE_PASS_COMBINED) && (shi->combinedflag & (SCE_PASS_AO | SCE_PASS_ENVIRONMENT | SCE_PASS_INDIRECT))) || + (shi->passflag & (SCE_PASS_AO | SCE_PASS_ENVIRONMENT | SCE_PASS_INDIRECT))) { - for (sample=0; sample<ssamp->tot; shi++, sample++) + for (sample = 0; sample < ssamp->tot; shi++, sample++) if (!(shi->mode & MA_SHLESS)) - ambient_occlusion(shi); /* stores in shi->ao[] */ + ambient_occlusion(shi); /* stores in shi->ao[] */ } } } @@ -1392,55 +1380,55 @@ void shade_samples_fill_with_ps(ShadeSample *ssamp, PixStr *ps, int x, int y) ShadeInput *shi; float xs, ys; - ssamp->tot= 0; + ssamp->tot = 0; - for (shi= ssamp->shi; ps; ps= ps->next) { + for (shi = ssamp->shi; ps; ps = ps->next) { shade_input_set_triangle(shi, ps->obi, ps->facenr, 1); - if (shi->vlr) { /* NULL happens for env material or for 'all z' */ - unsigned short curmask= ps->mask; + if (shi->vlr) { /* NULL happens for env material or for 'all z' */ + unsigned short curmask = ps->mask; /* full osa is only set for OSA renders */ if (shi->vlr->flag & R_FULL_OSA) { - short shi_cp= 0, samp; + short shi_cp = 0, samp; - for (samp=0; samp<R.osa; samp++) { - if (curmask & (1<<samp)) { + for (samp = 0; samp < R.osa; samp++) { + if (curmask & (1 << samp)) { /* zbuffer has this inverse corrected, ensures xs,ys are inside pixel */ - xs= (float)x + R.jit[samp][0] + 0.5f; - ys= (float)y + R.jit[samp][1] + 0.5f; + xs = (float)x + R.jit[samp][0] + 0.5f; + ys = (float)y + R.jit[samp][1] + 0.5f; if (shi_cp) - shade_input_copy_triangle(shi, shi-1); + shade_input_copy_triangle(shi, shi - 1); - shi->mask= (1<<samp); + shi->mask = (1 << samp); // shi->rl= ssamp->rlpp[samp]; - shi->samplenr= R.shadowsamplenr[shi->thread]++; /* this counter is not being reset per pixel */ + shi->samplenr = R.shadowsamplenr[shi->thread]++; /* this counter is not being reset per pixel */ shade_input_set_viewco(shi, x, y, xs, ys, (float)ps->z); shade_input_set_uv(shi); - if (shi_cp==0) + if (shi_cp == 0) shade_input_set_normals(shi); else /* XXX shi->flippednor messes up otherwise */ shade_input_set_vertex_normals(shi); - shi_cp= 1; + shi_cp = 1; shi++; } } } else { if (R.osa) { - short b= R.samples->centmask[curmask]; - xs= (float)x + R.samples->centLut[b & 15] + 0.5f; - ys= (float)y + R.samples->centLut[b>>4] + 0.5f; + short b = R.samples->centmask[curmask]; + xs = (float)x + R.samples->centLut[b & 15] + 0.5f; + ys = (float)y + R.samples->centLut[b >> 4] + 0.5f; } else { - xs= (float)x + 0.5f; - ys= (float)y + 0.5f; + xs = (float)x + 0.5f; + ys = (float)y + 0.5f; } - shi->mask= curmask; - shi->samplenr= R.shadowsamplenr[shi->thread]++; + shi->mask = curmask; + shi->samplenr = R.shadowsamplenr[shi->thread]++; shade_input_set_viewco(shi, x, y, xs, ys, (float)ps->z); shade_input_set_uv(shi); shade_input_set_normals(shi); @@ -1448,8 +1436,8 @@ void shade_samples_fill_with_ps(ShadeSample *ssamp, PixStr *ps, int x, int y) } /* total sample amount, shi->sample is static set in initialize */ - if (shi!=ssamp->shi) - ssamp->tot= (shi-1)->sample + 1; + if (shi != ssamp->shi) + ssamp->tot = (shi - 1)->sample + 1; } } } @@ -1460,24 +1448,24 @@ int shade_samples(ShadeSample *ssamp, PixStr *ps, int x, int y) shade_samples_fill_with_ps(ssamp, ps, x, y); if (ssamp->tot) { - ShadeInput *shi= ssamp->shi; - ShadeResult *shr= ssamp->shr; + ShadeInput *shi = ssamp->shi; + ShadeResult *shr = ssamp->shr; int samp; /* if shadow or AO? */ shade_samples_do_AO(ssamp); /* if shade (all shadepinputs have same passflag) */ - if (ssamp->shi[0].passflag & ~(SCE_PASS_Z|SCE_PASS_INDEXOB|SCE_PASS_INDEXMA)) { + if (ssamp->shi[0].passflag & ~(SCE_PASS_Z | SCE_PASS_INDEXOB | SCE_PASS_INDEXMA)) { - for (samp=0; samp<ssamp->tot; samp++, shi++, shr++) { + for (samp = 0; samp < ssamp->tot; samp++, shi++, shr++) { shade_input_set_shade_texco(shi); shade_input_do_shade(shi, shr); } } else if (shi->passflag & SCE_PASS_Z) { - for (samp=0; samp<ssamp->tot; samp++, shi++, shr++) - shr->z= -shi->co[2]; + for (samp = 0; samp < ssamp->tot; samp++, shi++, shr++) + shr->z = -shi->co[2]; } return 1; |