doxygen: prevent GPL license block from being parsed as doxygen comment.
[blender.git] / source / blender / render / intern / source / rendercore.c
index 81c6d0e..2901573 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/*
  * $Id$
  *
  * ***** BEGIN GPL LICENSE BLOCK *****
@@ -43,7 +43,7 @@
 #include "BLI_threads.h"
 #include "BLI_utildefines.h"
 
-#include "BKE_utildefines.h"
+
 
 #include "DNA_image_types.h"
 #include "DNA_lamp_types.h"
@@ -61,6 +61,8 @@
 #include "IMB_imbuf.h"
 
 /* local include */
+#include "rayintersection.h"
+#include "rayobject.h"
 #include "renderpipeline.h"
 #include "render_types.h"
 #include "renderdatabase.h"
@@ -71,7 +73,6 @@
 #include "shading.h"
 #include "sss.h"
 #include "zbuf.h"
-#include "RE_raytrace.h"
 
 #include "PIL_time.h"
 
@@ -2081,24 +2082,10 @@ static void bake_mask_clear( ImBuf *ibuf, char *mask, char val )
 
 static void bake_set_shade_input(ObjectInstanceRen *obi, VlakRen *vlr, ShadeInput *shi, int quad, int isect, int x, int y, float u, float v)
 {
-       if(isect) {
-               /* raytrace intersection with different u,v than scanconvert */
-               if(vlr->v4) {
-                       if(quad)
-                               shade_input_set_triangle_i(shi, obi, vlr, 2, 1, 3);
-                       else
-                               shade_input_set_triangle_i(shi, obi, vlr, 0, 1, 3);
-               }
-               else
-                       shade_input_set_triangle_i(shi, obi, vlr, 0, 1, 2);
-       }
-       else {
-               /* regular scanconvert */
-               if(quad) 
-                       shade_input_set_triangle_i(shi, obi, vlr, 0, 2, 3);
-               else
-                       shade_input_set_triangle_i(shi, obi, vlr, 0, 1, 2);
-       }
+       if(quad) 
+               shade_input_set_triangle_i(shi, obi, vlr, 0, 2, 3);
+       else
+               shade_input_set_triangle_i(shi, obi, vlr, 0, 1, 2);
                
        /* cache for shadow */
        shi->samplenr= R.shadowsamplenr[shi->thread]++;
@@ -2173,12 +2160,14 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int quad, int
                                if(tvn && ttang) {
                                        VECCOPY(mat[0], ttang);
                                        cross_v3_v3v3(mat[1], tvn, ttang);
+                                       mul_v3_fl(mat[1], ttang[3]);
                                        VECCOPY(mat[2], tvn);
                                }
                                else {
                                        VECCOPY(mat[0], shi->nmaptang);
-                                       cross_v3_v3v3(mat[1], shi->vn, shi->nmaptang);
-                                       VECCOPY(mat[2], shi->vn);
+                                       cross_v3_v3v3(mat[1], shi->nmapnorm, shi->nmaptang);
+                                       mul_v3_fl(mat[1], shi->nmaptang[3]);
+                                       VECCOPY(mat[2], shi->nmapnorm);
                                }
 
                                invert_m3_m3(imat, mat);
@@ -2287,19 +2276,19 @@ static int bake_intersect_tree(RayObject* raytree, Isect* isect, float *start, f
        /* 'dir' is always normalized */
        VECADDFAC(isect->start, start, dir, -R.r.bake_biasdist);                                        
 
-       isect->vec[0] = dir[0]*maxdist*sign;
-       isect->vec[1] = dir[1]*maxdist*sign;
-       isect->vec[2] = dir[2]*maxdist*sign;
+       isect->dir[0] = dir[0]*sign;
+       isect->dir[1] = dir[1]*sign;
+       isect->dir[2] = dir[2]*sign;
 
-       isect->labda = maxdist;
+       isect->dist = maxdist;
 
        hit = RE_rayobject_raycast(raytree, isect);
        if(hit) {
-               hitco[0] = isect->start[0] + isect->labda*isect->vec[0];
-               hitco[1] = isect->start[1] + isect->labda*isect->vec[1];
-               hitco[2] = isect->start[2] + isect->labda*isect->vec[2];
+               hitco[0] = isect->start[0] + isect->dist*isect->dir[0];
+               hitco[1] = isect->start[1] + isect->dist*isect->dir[1];
+               hitco[2] = isect->start[2] + isect->dist*isect->dir[2];
 
-               *dist= len_v3v3(start, hitco);
+               *dist= isect->dist;
        }
 
        return hit;
@@ -2360,7 +2349,7 @@ static void do_bake_shade(void *handle, int x, int y, float u, float v)
        VlakRen *vlr= bs->vlr;
        ObjectInstanceRen *obi= bs->obi;
        Object *ob= obi->obr->ob;
-       float l, *v1, *v2, *v3, tvn[3], ttang[3];
+       float l, *v1, *v2, *v3, tvn[3], ttang[4];
        int quad;
        ShadeSample *ssamp= &bs->ssamp;
        ShadeInput *shi= ssamp->shi;
@@ -2399,8 +2388,8 @@ static void do_bake_shade(void *handle, int x, int y, float u, float v)
 
        if(bs->type==RE_BAKE_NORMALS && R.r.bake_normal_space==R_BAKE_SPACE_TANGENT) {
                shade_input_set_shade_texco(shi);
-               VECCOPY(tvn, shi->vn);
-               VECCOPY(ttang, shi->nmaptang);
+               VECCOPY(tvn, shi->nmapnorm);
+               QUATCOPY(ttang, shi->nmaptang);
        }
 
        /* if we are doing selected to active baking, find point on other face */