svn merge ^/trunk/blender -r40720:40872
[blender.git] / source / blender / render / intern / source / convertblender.c
index 28b26ea1cd13796eb75aabfc8cbd6e33c4f26364..c241603f64a4eb29112fb3ea4570e30f98e52970 100644 (file)
@@ -142,7 +142,7 @@ static HaloRen *initstar(Render *re, ObjectRen *obr, float *vec, float hasize)
        har= RE_findOrAddHalo(obr, obr->tothalo++);
        
        /* projectvert is done in function zbufvlaggen again, because of parts */
-       VECCOPY(har->co, vec);
+       copy_v3_v3(har->co, vec);
        har->hasize= hasize;
        
        har->zd= 0.0;
@@ -192,10 +192,10 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void),
        /* minimal free space (starting at camera) */
        starmindist= wrld->starmindist;
        
-       if (stargrid <= 0.10) return;
+       if (stargrid <= 0.10f) return;
        
        if (re) re->flag |= R_HALO;
-       else stargrid *= 1.0                          /* then it draws fewer */
+       else stargrid *= 1.0f;                          /* then it draws fewer */
        
        if(re) invert_m4_m4(mat, re->viewmat);
        else unit_m4(mat);
@@ -267,17 +267,17 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void),
                                                
                                                if (alpha >= clipend) alpha = 0.0;
                                                else if (alpha <= starmindist) alpha = 0.0;
-                                               else if (alpha <= 2.0 * starmindist) {
+                                               else if (alpha <= 2.0f * starmindist) {
                                                        alpha = (alpha - starmindist) / starmindist;
                                                } else {
-                                                       alpha -= 2.0 * starmindist;
-                                                       alpha /= (clipend - 2.0 * starmindist);
-                                                       alpha = 1.0 - alpha;
+                                                       alpha -= 2.0f * starmindist;
+                                                       alpha /= (clipend - 2.0f * starmindist);
+                                                       alpha = 1.0f - alpha;
                                                }
                                        }
                                        
                                        
-                                       if (alpha != 0.0) {
+                                       if (alpha != 0.0f) {
                                                fac = force * BLI_drand();
                                                
                                                har = initstar(re, obr, vec, fac);
@@ -547,7 +547,7 @@ static void GetPosition(const SMikkTSpaceContext * pContext, float fPos[], const
        SRenderMeshToTangent * pMesh = (SRenderMeshToTangent *) pContext->m_pUserData;
        VlakRen *vlr= RE_findOrAddVlak(pMesh->obr, face_num);
        const float *co= (&vlr->v1)[vert_index]->co;
-       VECCOPY(fPos, co);
+       copy_v3_v3(fPos, co);
 }
 
 static void GetTextureCoordinate(const SMikkTSpaceContext * pContext, float fUV[], const int face_num, const int vert_index)
@@ -576,7 +576,7 @@ static void GetNormal(const SMikkTSpaceContext * pContext, float fNorm[], const
        SRenderMeshToTangent * pMesh = (SRenderMeshToTangent *) pContext->m_pUserData;
        VlakRen *vlr= RE_findOrAddVlak(pMesh->obr, face_num);
        const float *n= (&vlr->v1)[vert_index]->n;
-       VECCOPY(fNorm, n);
+       copy_v3_v3(fNorm, n);
 }
 static void SetTSpace(const SMikkTSpaceContext * pContext, const float fvTangent[], const float fSign, const int face_num, const int iVert)
 {
@@ -585,7 +585,7 @@ static void SetTSpace(const SMikkTSpaceContext * pContext, const float fvTangent
        VlakRen *vlr= RE_findOrAddVlak(pMesh->obr, face_num);
        float * ftang= RE_vlakren_get_nmap_tangent(pMesh->obr, vlr, 1);
        if(ftang!=NULL) {
-               VECCOPY(&ftang[iVert*4+0], fvTangent);
+               copy_v3_v3(&ftang[iVert*4+0], fvTangent);
                ftang[iVert*4+3]=fSign;
        }
 }
@@ -632,10 +632,10 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen
                VlakRen *vlr= RE_findOrAddVlak(obr, a);
 
                if((vlr->flag & ME_SMOOTH)==0) {
-                       if(is_zero_v3(vlr->v1->n)) VECCOPY(vlr->v1->n, vlr->n);
-                       if(is_zero_v3(vlr->v2->n)) VECCOPY(vlr->v2->n, vlr->n);
-                       if(is_zero_v3(vlr->v3->n)) VECCOPY(vlr->v3->n, vlr->n);
-                       if(vlr->v4 && is_zero_v3(vlr->v4->n)) VECCOPY(vlr->v4->n, vlr->n);
+                       if(is_zero_v3(vlr->v1->n)) copy_v3_v3(vlr->v1->n, vlr->n);
+                       if(is_zero_v3(vlr->v2->n)) copy_v3_v3(vlr->v2->n, vlr->n);
+                       if(is_zero_v3(vlr->v3->n)) copy_v3_v3(vlr->v3->n, vlr->n);
+                       if(vlr->v4 && is_zero_v3(vlr->v4->n)) copy_v3_v3(vlr->v4->n, vlr->n);
                }
 
                if(do_nmap_tangent) {
@@ -647,17 +647,17 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen
                                float *vtang, *ftang= RE_vlakren_get_nmap_tangent(obr, vlr, 1);
 
                                vtang= find_vertex_tangent(vtangents[v1->index], tface->uv[0]);
-                               VECCOPY(ftang, vtang);
+                               copy_v3_v3(ftang, vtang);
                                normalize_v3(ftang);
                                vtang= find_vertex_tangent(vtangents[v2->index], tface->uv[1]);
-                               VECCOPY(ftang+4, vtang);
+                               copy_v3_v3(ftang+4, vtang);
                                normalize_v3(ftang+4);
                                vtang= find_vertex_tangent(vtangents[v3->index], tface->uv[2]);
-                               VECCOPY(ftang+8, vtang);
+                               copy_v3_v3(ftang+8, vtang);
                                normalize_v3(ftang+8);
                                if(v4) {
                                        vtang= find_vertex_tangent(vtangents[v4->index], tface->uv[3]);
-                                       VECCOPY(ftang+12, vtang);
+                                       copy_v3_v3(ftang+12, vtang);
                                        normalize_v3(ftang+12);
                                }
                                for(k=0; k<4; k++) ftang[4*k+3]=1;
@@ -822,7 +822,7 @@ static void autosmooth(Render *UNUSED(re), ObjectRen *obr, float mat[][4], int d
        if(obr->totvert==0) return;
        asverts= MEM_callocN(sizeof(ASvert)*obr->totvert, "all smooth verts");
        
-       thresh= cos( M_PI*(0.5f+(float)degr)/180.0 );
+       thresh= cosf(DEG2RADF((0.5f + (float)degr)));
        
        /* step zero: give faces normals of original mesh, if this is provided */
        
@@ -981,7 +981,7 @@ static void flag_render_node_material(Render *re, bNodeTree *ntree)
        }
 }
 
-static Material *give_render_material(Render *re, Object *ob, int nr)
+static Material *give_render_material(Render *re, Object *ob, short nr)
 {
        extern Material defmaterial;    /* material.c */
        Material *ma;
@@ -1023,7 +1023,7 @@ typedef struct ParticleStrandData
 }
 ParticleStrandData;
 /* future thread problem... */
-static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, ParticleStrandData *sd, float *vec, float *vec1)
+static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, ParticleStrandData *sd, const float vec[3], const float vec1[3])
 {
        static VertRen *v1= NULL, *v2= NULL;
        VlakRen *vlr= NULL;
@@ -1046,9 +1046,9 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
                float fac;
                if(ma->strand_ease!=0.0f) {
                        if(ma->strand_ease<0.0f)
-                               fac= pow(sd->time, 1.0+ma->strand_ease);
+                               fac= pow(sd->time, 1.0f+ma->strand_ease);
                        else
-                               fac= pow(sd->time, 1.0/(1.0f-ma->strand_ease));
+                               fac= pow(sd->time, 1.0f/(1.0f-ma->strand_ease));
                }
                else fac= sd->time;
 
@@ -1063,7 +1063,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
                                width= w;
 
                        /*cross is the radius of the strand so we want it to be half of full width */
-                       mul_v3_fl(cross,0.5/crosslen);
+                       mul_v3_fl(cross,0.5f/crosslen);
                }
                else
                        width/=w;
@@ -1090,27 +1090,27 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
                vlr->v3= RE_findOrAddVert(obr, obr->totvert++);
                vlr->v4= RE_findOrAddVert(obr, obr->totvert++);
                
-               VECCOPY(vlr->v1->co, vec);
+               copy_v3_v3(vlr->v1->co, vec);
                add_v3_v3(vlr->v1->co, cross);
-               VECCOPY(vlr->v1->n, nor);
+               copy_v3_v3(vlr->v1->n, nor);
                vlr->v1->orco= sd->orco;
                vlr->v1->accum= -1.0f;  // accum abuse for strand texco
                
-               VECCOPY(vlr->v2->co, vec);
+               copy_v3_v3(vlr->v2->co, vec);
                sub_v3_v3v3(vlr->v2->co, vlr->v2->co, cross);
-               VECCOPY(vlr->v2->n, nor);
+               copy_v3_v3(vlr->v2->n, nor);
                vlr->v2->orco= sd->orco;
                vlr->v2->accum= vlr->v1->accum;
 
-               VECCOPY(vlr->v4->co, vec1);
+               copy_v3_v3(vlr->v4->co, vec1);
                add_v3_v3(vlr->v4->co, cross);
-               VECCOPY(vlr->v4->n, nor);
+               copy_v3_v3(vlr->v4->n, nor);
                vlr->v4->orco= sd->orco;
                vlr->v4->accum= 1.0f;   // accum abuse for strand texco
                
-               VECCOPY(vlr->v3->co, vec1);
+               copy_v3_v3(vlr->v3->co, vec1);
                sub_v3_v3v3(vlr->v3->co, vlr->v3->co, cross);
-               VECCOPY(vlr->v3->n, nor);
+               copy_v3_v3(vlr->v3->n, nor);
                vlr->v3->orco= sd->orco;
                vlr->v3->accum= vlr->v4->accum;
 
@@ -1121,7 +1121,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
 
                if(sd->surfnor) {
                        float *snor= RE_vlakren_get_surfnor(obr, vlr, 1);
-                       VECCOPY(snor, sd->surfnor);
+                       copy_v3_v3(snor, sd->surfnor);
                }
 
                if(sd->uvco){
@@ -1156,23 +1156,23 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
        /* first two vertices of a strand */
        else if(sd->first) {
                if(sd->adapt){
-                       VECCOPY(anor, nor);
-                       VECCOPY(avec, vec);
+                       copy_v3_v3(anor, nor);
+                       copy_v3_v3(avec, vec);
                        second=1;
                }
 
                v1= RE_findOrAddVert(obr, obr->totvert++);
                v2= RE_findOrAddVert(obr, obr->totvert++);
                
-               VECCOPY(v1->co, vec);
+               copy_v3_v3(v1->co, vec);
                add_v3_v3(v1->co, cross);
-               VECCOPY(v1->n, nor);
+               copy_v3_v3(v1->n, nor);
                v1->orco= sd->orco;
                v1->accum= -1.0f;       // accum abuse for strand texco
                
-               VECCOPY(v2->co, vec);
+               copy_v3_v3(v2->co, vec);
                sub_v3_v3v3(v2->co, v2->co, cross);
-               VECCOPY(v2->n, nor);
+               copy_v3_v3(v2->n, nor);
                v2->orco= sd->orco;
                v2->accum= v1->accum;
        }
@@ -1192,8 +1192,8 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
                        
                        if(sd->adapt){
                                second=0;
-                               VECCOPY(anor,nor);
-                               VECCOPY(avec,vec);
+                               copy_v3_v3(anor,nor);
+                               copy_v3_v3(avec,vec);
                        }
 
                }
@@ -1218,23 +1218,23 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
                                v1= vlr->v4; // cycle
                                v2= vlr->v3; // cycle
 
-                               VECCOPY(anor,nor);
-                               VECCOPY(avec,vec);
+                               copy_v3_v3(anor,nor);
+                               copy_v3_v3(avec,vec);
                        }
                        else{
                                vlr= RE_findOrAddVlak(obr, obr->totvlak-1);
                        }
                }
        
-               VECCOPY(vlr->v4->co, vec);
+               copy_v3_v3(vlr->v4->co, vec);
                add_v3_v3(vlr->v4->co, cross);
-               VECCOPY(vlr->v4->n, nor);
+               copy_v3_v3(vlr->v4->n, nor);
                vlr->v4->orco= sd->orco;
                vlr->v4->accum= -1.0f + 2.0f*sd->time;  // accum abuse for strand texco
                
-               VECCOPY(vlr->v3->co, vec);
+               copy_v3_v3(vlr->v3->co, vec);
                sub_v3_v3v3(vlr->v3->co, vlr->v3->co, cross);
-               VECCOPY(vlr->v3->n, nor);
+               copy_v3_v3(vlr->v3->n, nor);
                vlr->v3->orco= sd->orco;
                vlr->v3->accum= vlr->v4->accum;
                
@@ -1245,7 +1245,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
 
                if(sd->surfnor) {
                        float *snor= RE_vlakren_get_surfnor(obr, vlr, 1);
-                       VECCOPY(snor, sd->surfnor);
+                       copy_v3_v3(snor, sd->surfnor);
                }
 
                if(sd->uvco){
@@ -1279,7 +1279,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par
        }
 }
 
-static void static_particle_wire(ObjectRen *obr, Material *ma, float *vec, float *vec1, int first, int line)
+static void static_particle_wire(ObjectRen *obr, Material *ma, const float vec[3], const float vec1[3], int first, int line)
 {
        VlakRen *vlr;
        static VertRen *v1;
@@ -1291,13 +1291,13 @@ static void static_particle_wire(ObjectRen *obr, Material *ma, float *vec, float
                vlr->v3= vlr->v2;
                vlr->v4= NULL;
                
-               VECCOPY(vlr->v1->co, vec);
-               VECCOPY(vlr->v2->co, vec1);
+               copy_v3_v3(vlr->v1->co, vec);
+               copy_v3_v3(vlr->v2->co, vec1);
                
                sub_v3_v3v3(vlr->n, vec, vec1);
                normalize_v3(vlr->n);
-               VECCOPY(vlr->v1->n, vlr->n);
-               VECCOPY(vlr->v2->n, vlr->n);
+               copy_v3_v3(vlr->v1->n, vlr->n);
+               copy_v3_v3(vlr->v2->n, vlr->n);
                
                vlr->mat= ma;
                vlr->ec= ME_V1V2;
@@ -1305,7 +1305,7 @@ static void static_particle_wire(ObjectRen *obr, Material *ma, float *vec, float
        }
        else if(first) {
                v1= RE_findOrAddVert(obr, obr->totvert++);
-               VECCOPY(v1->co, vec);
+               copy_v3_v3(v1->co, vec);
        }
        else {
                vlr= RE_findOrAddVlak(obr, obr->totvlak++);
@@ -1315,11 +1315,11 @@ static void static_particle_wire(ObjectRen *obr, Material *ma, float *vec, float
                vlr->v4= NULL;
                
                v1= vlr->v2; // cycle
-               VECCOPY(v1->co, vec);
+               copy_v3_v3(v1->co, vec);
                
                sub_v3_v3v3(vlr->n, vec, vec1);
                normalize_v3(vlr->n);
-               VECCOPY(v1->n, vlr->n);
+               copy_v3_v3(v1->n, vlr->n);
                
                vlr->mat= ma;
                vlr->ec= ME_V1V2;
@@ -1345,7 +1345,10 @@ static void particle_billboard(Render *re, ObjectRen *obr, Material *ma, Particl
        VlakRen *vlr;
        MTFace *mtf;
        float xvec[3], yvec[3], zvec[3], bb_center[3];
+       /* Number of tiles */
        int totsplit = bb->uv_split * bb->uv_split;
+       int tile, x, y;
+       /* Tile offsets */
        float uvx = 0.0f, uvy = 0.0f, uvdx = 1.0f, uvdy = 1.0f, time = 0.0f;
 
        vlr= RE_findOrAddVlak(obr, obr->totvlak++);
@@ -1373,10 +1376,10 @@ static void particle_billboard(Render *re, ObjectRen *obr, Material *ma, Particl
        mul_m4_v3(re->viewmat, vlr->v4->co);
 
        normal_quad_v3( vlr->n,vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co);
-       VECCOPY(vlr->v1->n,vlr->n);
-       VECCOPY(vlr->v2->n,vlr->n);
-       VECCOPY(vlr->v3->n,vlr->n);
-       VECCOPY(vlr->v4->n,vlr->n);
+       copy_v3_v3(vlr->v1->n,vlr->n);
+       copy_v3_v3(vlr->v2->n,vlr->n);
+       copy_v3_v3(vlr->v3->n,vlr->n);
+       copy_v3_v3(vlr->v4->n,vlr->n);
        
        vlr->mat= ma;
        vlr->ec= ME_V2V3;
@@ -1420,11 +1423,14 @@ static void particle_billboard(Render *re, ObjectRen *obr, Material *ma, Particl
                else if(bb->split_offset==PART_BB_OFF_RANDOM)
                        time = (float)fmod(time + bb->random, 1.0f);
 
-               uvx = uvdx * floor((float)(bb->uv_split * bb->uv_split) * (float)fmod((double)time, (double)uvdx));
-               uvy = uvdy * floor((1.0f - time) * (float)bb->uv_split);
-
-               if(fmod(time, 1.0f / bb->uv_split) == 0.0f)
-                       uvy -= uvdy;
+               /* Find the coordinates in tile space (integer), then convert to UV
+                * space (float). Note that Y is flipped. */
+               tile = (int)((time + FLT_EPSILON10) * totsplit);
+               x = tile % bb->uv_split;
+               y = tile / bb->uv_split;
+               y = (bb->uv_split - 1) - y;
+               uvx = uvdx * x;
+               uvy = uvdy * y;
        }
 
        /* normal UVs */
@@ -1464,7 +1470,7 @@ static void particle_normal_ren(short ren_as, ParticleSettings *part, Render *re
 {
        float loc[3], loc0[3], loc1[3], vel[3];
        
-       VECCOPY(loc, state->co);
+       copy_v3_v3(loc, state->co);
 
        if(ren_as != PART_DRAW_BB)
                mul_m4_v3(re->viewmat, loc);
@@ -1475,15 +1481,15 @@ static void particle_normal_ren(short ren_as, ParticleSettings *part, Render *re
                        sd->time = 0.0f;
                        sd->size = hasize;
 
-                       VECCOPY(vel, state->vel);
+                       copy_v3_v3(vel, state->vel);
                        mul_mat3_m4_v3(re->viewmat, vel);
                        normalize_v3(vel);
 
                        if(part->draw & PART_DRAW_VEL_LENGTH)
                                mul_v3_fl(vel, len_v3(state->vel));
 
-                       VECADDFAC(loc0, loc, vel, -part->draw_line[0]);
-                       VECADDFAC(loc1, loc, vel, part->draw_line[1]);
+                       madd_v3_v3v3fl(loc0, loc, vel, -part->draw_line[0]);
+                       madd_v3_v3v3fl(loc1, loc, vel, part->draw_line[1]);
 
                        particle_curve(re, obr, dm, ma, sd, loc0, loc1, seed, pa_co);
 
@@ -1491,8 +1497,8 @@ static void particle_normal_ren(short ren_as, ParticleSettings *part, Render *re
 
                case PART_DRAW_BB:
 
-                       VECCOPY(bb->vec, loc);
-                       VECCOPY(bb->vel, state->vel);
+                       copy_v3_v3(bb->vec, loc);
+                       copy_v3_v3(bb->vel, state->vel);
 
                        particle_billboard(re, obr, ma, bb);
 
@@ -1711,7 +1717,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
                if(part->draw & PART_DRAW_REN_ADAPT) {
                        sd.adapt = 1;
                        sd.adapt_pix = (float)part->adapt_pix;
-                       sd.adapt_angle = cos((float)part->adapt_angle * (float)(M_PI / 180.0));
+                       sd.adapt_angle = cosf(DEG2RADF((float)part->adapt_angle));
                }
 
                if(re->r.renderer==R_INTERN && part->draw&PART_DRAW_REN_STRAND) {
@@ -1722,7 +1728,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
                        strandbuf->winx= re->winx;
                        strandbuf->winy= re->winy;
                        strandbuf->maxdepth= 2;
-                       strandbuf->adaptcos= cos((float)part->adapt_angle*(float)(M_PI/180.0));
+                       strandbuf->adaptcos= cosf(DEG2RADF((float)part->adapt_angle));
                        strandbuf->overrideuv= sd.override_uv;
                        strandbuf->minwidth= ma->strand_min;
 
@@ -1886,7 +1892,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
                        strand= RE_findOrAddStrand(obr, obr->totstrand++);
                        strand->buffer= strandbuf;
                        strand->vert= svert;
-                       VECCOPY(strand->orco, sd.orco);
+                       copy_v3_v3(strand->orco, sd.orco);
 
                        if(dosimplify) {
                                float *ssimplify= RE_strandren_get_simplify(obr, strand, 1);
@@ -1896,7 +1902,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
 
                        if(sd.surfnor) {
                                float *snor= RE_strandren_get_surfnor(obr, strand, 1);
-                               VECCOPY(snor, sd.surfnor);
+                               copy_v3_v3(snor, sd.surfnor);
                        }
 
                        if(dosurfacecache && num >= 0) {
@@ -1939,8 +1945,8 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
                                float time;
 
                                if(k<=max_k){
-                                       VECCOPY(state.co,(cache+k)->co);
-                                       VECCOPY(state.vel,(cache+k)->vel);
+                                       copy_v3_v3(state.co,(cache+k)->co);
+                                       copy_v3_v3(state.vel,(cache+k)->vel);
                                }
                                else
                                        continue;       
@@ -1949,11 +1955,11 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
                                        curlen += len_v3v3((cache+k-1)->co, (cache+k)->co);
                                time= curlen/strandlen;
 
-                               VECCOPY(loc,state.co);
+                               copy_v3_v3(loc,state.co);
                                mul_m4_v3(re->viewmat,loc);
 
                                if(strandbuf) {
-                                       VECCOPY(svert->co, loc);
+                                       copy_v3_v3(svert->co, loc);
                                        svert->strandco= -1.0f + 2.0f*time;
                                        svert++;
                                        strand->totvert++;
@@ -1976,7 +1982,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
                                        if(k)
                                                particle_curve(re, obr, psmd->dm, ma, &sd, loc, loc1, seed, pa_co);
 
-                                       VECCOPY(loc1,loc);
+                                       copy_v3_v3(loc1,loc);
                                }
                        }
 
@@ -1984,8 +1990,8 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
                else {
                        /* render normal particles */
                        if(part->trail_count > 1) {
-                               float length = part->path_end * (1.0 - part->randlength * r_length);
-                               int trail_count = part->trail_count * (1.0 - part->randlength * r_length);
+                               float length = part->path_end * (1.0f - part->randlength * r_length);
+                               int trail_count = part->trail_count * (1.0f - part->randlength * r_length);
                                float ct = (part->draw & PART_ABS_PATH_TIME) ? cfra : pa_time;
                                float dt = length / (trail_count ? (float)trail_count : 1.0f);
 
@@ -2141,7 +2147,7 @@ static void make_render_halos(Render *re, ObjectRen *obr, Mesh *UNUSED(me), int
                if(ok) {
                        hasize= ma->hasize;
 
-                       VECCOPY(vec, mvert->co);
+                       copy_v3_v3(vec, mvert->co);
                        mul_m4_v3(mat, vec);
 
                        if(ma->mode & MA_HALOPUNO) {
@@ -2155,11 +2161,11 @@ static void make_render_halos(Render *re, ObjectRen *obr, Mesh *UNUSED(me), int
                                nor[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn;
                                normalize_v3(nor);
 
-                               VECCOPY(view, vec);
+                               copy_v3_v3(view, vec);
                                normalize_v3(view);
 
                                zn= nor[0]*view[0]+nor[1]*view[1]+nor[2]*view[2];
-                               if(zn>=0.0) hasize= 0.0;
+                               if(zn>=0.0f) hasize= 0.0f;
                                else hasize*= zn*zn*zn*zn;
                        }
 
@@ -2232,9 +2238,9 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve
        int i;
 
        /* shi->co is current render coord, just make sure at least some vector is here */
-       VECCOPY(shi->co, vr->co);
+       copy_v3_v3(shi->co, vr->co);
        /* vertex normal is used for textures type 'col' and 'var' */
-       VECCOPY(shi->vn, vr->n);
+       copy_v3_v3(shi->vn, vr->n);
 
        if(mat)
                mul_m4_v3(mat, shi->co);
@@ -2263,7 +2269,7 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve
 
        /* set all rendercoords, 'texco' is an ORed value for all textures needed */
        if ((texco & TEXCO_ORCO) && (vr->orco)) {
-               VECCOPY(shi->lo, vr->orco);
+               copy_v3_v3(shi->lo, vr->orco);
        }
        if (texco & TEXCO_STICKY) {
                float *sticky= RE_vertren_get_sticky(obr, vr, 0);
@@ -2274,11 +2280,11 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve
                }
        }
        if (texco & TEXCO_GLOB) {
-               VECCOPY(shi->gl, shi->co);
+               copy_v3_v3(shi->gl, shi->co);
                mul_m4_v3(re->viewinv, shi->gl);
        }
        if (texco & TEXCO_NORM) {
-               VECCOPY(shi->orn, shi->vn);
+               copy_v3_v3(shi->orn, shi->vn);
        }
        if(texco & TEXCO_REFL) {
                /* not (yet?) */
@@ -2455,7 +2461,7 @@ static void init_render_mball(Render *re, ObjectRen *obr)
        for(a=0; a<dl->nr; a++, data+=3, nors+=3) {
 
                ver= RE_findOrAddVert(obr, obr->totvert++);
-               VECCOPY(ver->co, data);
+               copy_v3_v3(ver->co, data);
                mul_m4_v3(mat, ver->co);
 
                /* render normals are inverted */
@@ -2534,7 +2540,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar,
        data= dl->verts;
        for (u = 0; u < sizeu; u++) {
                v1 = RE_findOrAddVert(obr, obr->totvert++); /* save this for possible V wrapping */
-               VECCOPY(v1->co, data); data += 3;
+               copy_v3_v3(v1->co, data); data += 3;
                if(orco) {
                        v1->orco= orco; orco+= 3; orcoret++;
                }       
@@ -2542,7 +2548,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar,
                
                for (v = 1; v < sizev; v++) {
                        ver= RE_findOrAddVert(obr, obr->totvert++);
-                       VECCOPY(ver->co, data); data += 3;
+                       copy_v3_v3(ver->co, data); data += 3;
                        if(orco) {
                                ver->orco= orco; orco+= 3; orcoret++;
                        }       
@@ -2551,7 +2557,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar,
                /* if V-cyclic, add extra vertices at end of the row */
                if (dl->flag & DL_CYCL_U) {
                        ver= RE_findOrAddVert(obr, obr->totvert++);
-                       VECCOPY(ver->co, v1->co);
+                       copy_v3_v3(ver->co, v1->co);
                        if(orco) {
                                ver->orco= orco; orco+=3; orcoret++; //orcobase + 3*(u*sizev + 0);
                        }
@@ -2567,7 +2573,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar,
                for (v = 0; v < nsizev; v++) {
                        v1= RE_findOrAddVert(obr, startvert + v);
                        ver= RE_findOrAddVert(obr, obr->totvert++);
-                       VECCOPY(ver->co, v1->co);
+                       copy_v3_v3(ver->co, v1->co);
                        if(orco) {
                                ver->orco= orco; orco+=3; orcoret++; //ver->orco= orcobase + 3*(0*sizev + v);
                        }
@@ -2596,7 +2602,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar,
                        
                        normal_quad_v3( n1,vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co);
                        
-                       VECCOPY(vlr->n, n1);
+                       copy_v3_v3(vlr->n, n1);
                        
                        vlr->mat= matar[ dl->col];
                        vlr->ec= ME_V1V2+ME_V2V3;
@@ -2664,10 +2670,10 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar,
                add_v3_v3(n1, vlr2->n);
                vlr3= RE_findOrAddVlak(obr, UVTOINDEX(sizeu-1, 0)); /* (m,0) */
                add_v3_v3(n1, vlr3->n);
-               VECCOPY(vlr->v3->n, n1);
-               VECCOPY(vlr1->v1->n, n1);
-               VECCOPY(vlr2->v2->n, n1);
-               VECCOPY(vlr3->v4->n, n1);
+               copy_v3_v3(vlr->v3->n, n1);
+               copy_v3_v3(vlr1->v1->n, n1);
+               copy_v3_v3(vlr2->v2->n, n1);
+               copy_v3_v3(vlr3->v4->n, n1);
        }
        for(a = startvert; a < obr->totvert; a++) {
                ver= RE_findOrAddVert(obr, a);
@@ -2682,7 +2688,8 @@ static void init_render_dm(DerivedMesh *dm, Render *re, ObjectRen *obr,
        int timeoffset, float *orco, float mat[4][4])
 {
        Object *ob= obr->ob;
-       int a, a1, end, totvert, vertofs;
+       int a, end, totvert, vertofs;
+       short mat_iter;
        VertRen *ver;
        VlakRen *vlr;
        MVert *mvert = NULL;
@@ -2695,7 +2702,7 @@ static void init_render_dm(DerivedMesh *dm, Render *re, ObjectRen *obr,
 
        for(a=0; a<totvert; a++, mvert++) {
                ver= RE_findOrAddVert(obr, obr->totvert++);
-               VECCOPY(ver->co, mvert->co);
+               copy_v3_v3(ver->co, mvert->co);
                mul_m4_v3(mat, ver->co);
 
                if(orco) {
@@ -2712,16 +2719,16 @@ static void init_render_dm(DerivedMesh *dm, Render *re, ObjectRen *obr,
 
                /* faces in order of color blocks */
                vertofs= obr->totvert - totvert;
-               for(a1=0; (a1<ob->totcol || (a1==0 && ob->totcol==0)); a1++) {
+               for(mat_iter= 0; (mat_iter < ob->totcol || (mat_iter==0 && ob->totcol==0)); mat_iter++) {
 
-                       ma= give_render_material(re, ob, a1+1);
+                       ma= give_render_material(re, ob, mat_iter+1);
                        end= dm->getNumTessFaces(dm);
                        mface= dm->getTessFaceArray(dm);
 
                        for(a=0; a<end; a++, mface++) {
                                int v1, v2, v3, v4, flag;
 
-                               if( mface->mat_nr==a1 ) {
+                               if(mface->mat_nr == mat_iter) {
                                        float len;
 
                                        v1= mface->v1;
@@ -2907,7 +2914,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset)
 
                                for(a=0; a<dl->nr; a++, data+=3) {
                                        ver= RE_findOrAddVert(obr, obr->totvert++);
-                                       VECCOPY(ver->co, data);
+                                       copy_v3_v3(ver->co, data);
 
                                        mul_m4_v3(mat, ver->co);
 
@@ -2973,7 +2980,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset)
                                        while(nr--) {
                                                ver= RE_findOrAddVert(obr, obr->totvert++);
 
-                                               VECCOPY(ver->co, fp);
+                                               copy_v3_v3(ver->co, fp);
                                                mul_m4_v3(mat, ver->co);
                                                fp+= 3;
 
@@ -3334,7 +3341,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset)
 
                for(a=0; a<totvert; a++, mvert++) {
                        ver= RE_findOrAddVert(obr, obr->totvert++);
-                       VECCOPY(ver->co, mvert->co);
+                       copy_v3_v3(ver->co, mvert->co);
                        if(do_autosmooth==0) {  /* autosmooth on original unrotated data to prevent differences between frames */
                                normal_short_to_float_v3(ver->n, mvert->no);
                                mul_m4_v3(mat, ver->co);
@@ -3599,7 +3606,7 @@ static void initshadowbuf(Render *re, LampRen *lar, float mat[][4])
        
        /* bias is percentage, made 2x larger because of correction for angle of incidence */
        /* when a ray is closer to parallel of a face, bias value is increased during render */
-       shb->bias= (0.02*lar->bias)*0x7FFFFFFF;
+       shb->bias= (0.02f*lar->bias)*0x7FFFFFFF;
        
        /* halfway method (average of first and 2nd z) reduces bias issues */
        if(ELEM(lar->buftype, LA_SHADBUF_HALFWAY, LA_SHADBUF_DEEP))
@@ -3610,7 +3617,7 @@ static void initshadowbuf(Render *re, LampRen *lar, float mat[][4])
 
 static void area_lamp_vectors(LampRen *lar)
 {
-       float xsize= 0.5*lar->area_size, ysize= 0.5*lar->area_sizey, multifac;
+       float xsize= 0.5f*lar->area_size, ysize= 0.5f*lar->area_sizey, multifac;
 
        /* make it smaller, so area light can be multisampled */
        multifac= 1.0f/sqrt((float)lar->ray_totsamp);
@@ -3637,7 +3644,7 @@ static void area_lamp_vectors(LampRen *lar)
        lar->area[3][1]= lar->co[1] + xsize*lar->mat[0][1] - ysize*lar->mat[1][1];
        lar->area[3][2]= lar->co[2] + xsize*lar->mat[0][2] - ysize*lar->mat[1][2];      
        /* only for correction button size, matrix size works on energy */
-       lar->areasize= lar->dist*lar->dist/(4.0*xsize*ysize);
+       lar->areasize= lar->dist*lar->dist/(4.0f*xsize*ysize);
 }
 
 /* If lar takes more lamp data, the decoupling will be better. */
@@ -3776,7 +3783,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob)
                        lar->sunsky = (struct SunSky*)MEM_callocN(sizeof(struct SunSky), "sunskyren");
                        lar->sunsky->effect_type = la->sun_effect_type;
                
-                       VECCOPY(vec,ob->obmat[2]);
+                       copy_v3_v3(vec,ob->obmat[2]);
                        normalize_v3(vec);
 
                        InitSunSky(lar->sunsky, la->atm_turbidity, vec, la->horizon_brightness, 
@@ -3791,10 +3798,10 @@ static GroupObject *add_render_lamp(Render *re, Object *ob)
        
        lar->spotsi= la->spotsize;
        if(lar->mode & LA_HALO) {
-               if(lar->spotsi>170.0) lar->spotsi= 170.0;
+               if(lar->spotsi>170.0f) lar->spotsi= 170.0f;
        }
-       lar->spotsi= cos( M_PI*lar->spotsi/360.0 );
-       lar->spotbl= (1.0-lar->spotsi)*la->spotblend;
+       lar->spotsi= cos( M_PI*lar->spotsi/360.0f );
+       lar->spotbl= (1.0f-lar->spotsi)*la->spotblend;
 
        memcpy(lar->mtex, la->mtex, MAX_MTEX*sizeof(void *));
 
@@ -3813,7 +3820,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob)
 
                xn= saacos(lar->spotsi);
                xn= sin(xn)/cos(xn);
-               lar->spottexfac= 1.0/(xn);
+               lar->spottexfac= 1.0f/(xn);
 
                if(lar->mode & LA_ONLYSHADOW) {
                        if((lar->mode & (LA_SHAD_BUF|LA_SHAD_RAY))==0) lar->mode -= LA_ONLYSHADOW;
@@ -3823,7 +3830,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob)
 
        /* set flag for spothalo en initvars */
        if(la->type==LA_SPOT && (la->mode & LA_HALO) && (la->buftype != LA_SHADBUF_DEEP)) {
-               if(la->haint>0.0) {
+               if(la->haint>0.0f) {
                        re->flag |= R_LAMPHALO;
 
                        /* camera position (0,0,0) rotate around lamp */
@@ -3990,12 +3997,12 @@ void init_render_world(Render *re)
                
                cp= (char *)&re->wrld.fastcol;
                
-               cp[0]= 255.0*re->wrld.horr;
-               cp[1]= 255.0*re->wrld.horg;
-               cp[2]= 255.0*re->wrld.horb;
+               cp[0]= 255.0f*re->wrld.horr;
+               cp[1]= 255.0f*re->wrld.horg;
+               cp[2]= 255.0f*re->wrld.horb;
                cp[3]= 1;
                
-               VECCOPY(re->grvec, re->viewmat[2]);
+               copy_v3_v3(re->grvec, re->viewmat[2]);
                normalize_v3(re->grvec);
                copy_m3_m4(re->imat, re->viewinv);
                
@@ -4045,27 +4052,27 @@ static void set_phong_threshold(ObjectRen *obr)
        for(i=0; i<obr->totvlak; i++) {
                vlr= RE_findOrAddVlak(obr, i);
                if(vlr->flag & R_SMOOTH) {
-                       dot= INPR(vlr->n, vlr->v1->n);
+                       dot= dot_v3v3(vlr->n, vlr->v1->n);
                        dot= ABS(dot);
-                       if(dot>0.9) {
+                       if(dot>0.9f) {
                                thresh+= dot; tot++;
                        }
-                       dot= INPR(vlr->n, vlr->v2->n);
+                       dot= dot_v3v3(vlr->n, vlr->v2->n);
                        dot= ABS(dot);
-                       if(dot>0.9) {
+                       if(dot>0.9f) {
                                thresh+= dot; tot++;
                        }
 
-                       dot= INPR(vlr->n, vlr->v3->n);
+                       dot= dot_v3v3(vlr->n, vlr->v3->n);
                        dot= ABS(dot);
-                       if(dot>0.9) {
+                       if(dot>0.9f) {
                                thresh+= dot; tot++;
                        }
 
                        if(vlr->v4) {
-                               dot= INPR(vlr->n, vlr->v4->n);
+                               dot= dot_v3v3(vlr->n, vlr->v4->n);
                                dot= ABS(dot);
-                               if(dot>0.9) {
+                               if(dot>0.9f) {
                                        thresh+= dot; tot++;
                                }
                        }
@@ -4105,7 +4112,7 @@ static void set_fullsample_trace_flag(Render *re, ObjectRen *obr)
                                else if((mode & MA_RAYMIRROR) || ((mode & MA_TRANSP) && (mode & MA_RAYTRANSP))) {
                                        /* for blurry reflect/refract, better to take more samples 
                                         * inside the raytrace than as OSA samples */
-                                       if ((vlr->mat->gloss_mir == 1.0) && (vlr->mat->gloss_tra == 1.0)) 
+                                       if ((vlr->mat->gloss_mir == 1.0f) && (vlr->mat->gloss_tra == 1.0f))
                                                vlr->flag |= R_FULL_OSA;
                                }
                        }
@@ -4221,11 +4228,11 @@ static void check_non_flat_quads(ObjectRen *obr)
                                
                                /* render normals are inverted in render! we calculate normal of single tria here */
                                flen= normal_tri_v3( nor,vlr->v4->co, vlr->v3->co, vlr->v1->co);
-                               if(flen==0.0) normal_tri_v3( nor,vlr->v4->co, vlr->v2->co, vlr->v1->co);
+                               if(flen==0.0f) normal_tri_v3( nor,vlr->v4->co, vlr->v2->co, vlr->v1->co);
                                
                                xn= nor[0]*vlr->n[0] + nor[1]*vlr->n[1] + nor[2]*vlr->n[2];
 
-                               if(ABS(xn) < 0.999995 ) {       // checked on noisy fractal grid
+                               if(ABS(xn) < 0.999995f ) {      // checked on noisy fractal grid
                                        
                                        float d1, d2;
 
@@ -4334,16 +4341,16 @@ static void finalize_render_object(Render *re, ObjectRen *obr, int timeoffset)
                                                strand_minmax(strand, smin, smax, width);
                                        }
 
-                                       VECCOPY(sbound->boundbox[0], smin);
-                                       VECCOPY(sbound->boundbox[1], smax);
+                                       copy_v3_v3(sbound->boundbox[0], smin);
+                                       copy_v3_v3(sbound->boundbox[1], smax);
 
                                        DO_MINMAX(smin, min, max);
                                        DO_MINMAX(smax, min, max);
                                }
                        }
 
-                       VECCOPY(obr->boundbox[0], min);
-                       VECCOPY(obr->boundbox[1], max);
+                       copy_v3_v3(obr->boundbox[0], min);
+                       copy_v3_v3(obr->boundbox[1], max);
                }
        }
 }
@@ -4352,9 +4359,9 @@ static void finalize_render_object(Render *re, ObjectRen *obr, int timeoffset)
 /* Database                                                                                                                                     */
 /* ------------------------------------------------------------------------- */
 
-static int render_object_type(int type) 
+static int render_object_type(short type)
 {
-       return ELEM5(type, OB_FONT, OB_CURVE, OB_SURF, OB_MESH, OB_MBALL);
+       return OB_TYPE_SUPPORT_MATERIAL(type);
 }
 
 static void find_dupli_instances(Render *re, ObjectRen *obr)
@@ -4845,8 +4852,13 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
         * NULL is just for init */
        set_dupli_tex_mat(NULL, NULL, NULL);
 
-       for(SETLOOPER(re->scene, sce_iter, base)) {
-               ob= base->object;
+       /* loop over all objects rather then using SETLOOPER because we may
+        * reference an mtex-mapped object which isnt rendered or is an
+        * empty in a dupli group. We could scan all render material/lamp/world
+        * mtex's for mapto objects but its easier just to set the
+        * 'imat' / 'imat_ren' on all and unlikely to be a performance hit
+       * See bug: [#28744] - campbell */
+       for(ob= re->main->object.first; ob; ob= ob->id.next) {
                /* imat objects has to be done here, since displace can have texture using Object map-input */
                mul_m4_m4m4(mat, ob->obmat, re->viewmat);
                invert_m4_m4(ob->imat_ren, mat);
@@ -4926,7 +4938,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
                                                        /* fill in instance variables for texturing */
                                                        set_dupli_tex_mat(re, obi, dob);
                                                        if(dob->type != OB_DUPLIGROUP) {
-                                                               VECCOPY(obi->dupliorco, dob->orco);
+                                                               copy_v3_v3(obi->dupliorco, dob->orco);
                                                                obi->dupliuv[0]= dob->uv[0];
                                                                obi->dupliuv[1]= dob->uv[1];
                                                        }
@@ -4952,7 +4964,7 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp
 
                                                                set_dupli_tex_mat(re, obi, dob);
                                                                if(dob->type != OB_DUPLIGROUP) {
-                                                                       VECCOPY(obi->dupliorco, dob->orco);
+                                                                       copy_v3_v3(obi->dupliorco, dob->orco);
                                                                        obi->dupliuv[0]= dob->uv[0];
                                                                        obi->dupliuv[1]= dob->uv[1];
                                                                }
@@ -5014,7 +5026,7 @@ void RE_Database_FromScene(Render *re, Main *bmain, Scene *scene, unsigned int l
        /* per second, per object, stats print this */
        re->i.infostr= "Preparing Scene data";
        re->i.cfra= scene->r.cfra;
-       strncpy(re->i.scenename, scene->id.name+2, 20);
+       BLI_strncpy(re->i.scenename, scene->id.name+2, sizeof(re->i.scenename));
        
        /* XXX add test if dbase was filled already? */
        
@@ -5058,7 +5070,7 @@ void RE_Database_FromScene(Render *re, Main *bmain, Scene *scene, unsigned int l
        
        /* still bad... doing all */
        init_render_textures(re);
-       VECCOPY(amb, &re->wrld.ambr);
+       copy_v3_v3(amb, &re->wrld.ambr);
        init_render_materials(re->main, re->r.mode, amb);
        set_node_shader_lamp_loop(shade_material_loop);
 
@@ -5210,7 +5222,7 @@ static void database_fromscene_vectors(Render *re, Scene *scene, unsigned int la
 }
 
 /* choose to use static, to prevent giving too many args to this call */
-static void speedvector_project(Render *re, float *zco, float *co, float *ho)
+static void speedvector_project(Render *re, float zco[2], const float co[3], const float ho[4])
 {
        static float pixelphix=0.0f, pixelphiy=0.0f, zmulx=0.0f, zmuly=0.0f;
        static int pano= 0;
@@ -5245,7 +5257,7 @@ static void speedvector_project(Render *re, float *zco, float *co, float *ho)
        if(pano) {
                float vec[3], ang;
                /* angle between (0,0,-1) and (co) */
-               VECCOPY(vec, co);
+               copy_v3_v3(vec, co);
 
                ang= saacos(-vec[2]/sqrt(vec[0]*vec[0] + vec[2]*vec[2]));
                if(vec[0]<0.0f) ang= -ang;
@@ -5261,7 +5273,7 @@ static void speedvector_project(Render *re, float *zco, float *co, float *ho)
        }
 }
 
-static void calculate_speedvector(float *vectors, int step, float winsq, float winroot, float *co, float *ho, float *speed)
+static void calculate_speedvector(const float vectors[2], int step, float winsq, float winroot, const float co[3], const float ho[4], float speed[4])
 {
        float zco[2], len;
 
@@ -5297,11 +5309,13 @@ static void calculate_speedvector(float *vectors, int step, float winsq, float w
 
 static float *calculate_strandsurface_speedvectors(Render *re, ObjectInstanceRen *obi, StrandSurface *mesh)
 {
-       float winsq= (float)re->winx*(float)re->winy, winroot= sqrt(winsq), (*winspeed)[4];  /* int's can wrap on large images */
-       float ho[4], prevho[4], nextho[4], winmat[4][4], vec[2];
-       int a;
-
        if(mesh->co && mesh->prevco && mesh->nextco) {
+               float winsq= (float)re->winx*(float)re->winy; /* int's can wrap on large images */
+               float winroot= sqrt(winsq);
+               float (*winspeed)[4];
+               float ho[4], prevho[4], nextho[4], winmat[4][4], vec[2];
+               int a;
+
                if(obi->flag & R_TRANSFORMED)
                        mul_m4_m4m4(winmat, obi->mat, re->winmat);
                else
@@ -5461,7 +5475,7 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float *
                for(j=0;j<3;j++) fsvec[j] = velarray[a].vel[j];
                
                /* (bad) HACK insert average velocity if none is there (see previous comment) */
-               if((fsvec[0] == 0.0) && (fsvec[1] == 0.0) && (fsvec[2] == 0.0))
+               if((fsvec[0] == 0.0f) && (fsvec[1] == 0.0f) && (fsvec[2] == 0.0f))
                {
                        fsvec[0] = avgvel[0];
                        fsvec[1] = avgvel[1];
@@ -5758,7 +5772,7 @@ void RE_Database_Baking(Render *re, Main *bmain, Scene *scene, unsigned int lay,
        /* still bad... doing all */
        init_render_textures(re);
        
-       VECCOPY(amb, &re->wrld.ambr);
+       copy_v3_v3(amb, &re->wrld.ambr);
        init_render_materials(re->main, re->r.mode, amb);
        
        set_node_shader_lamp_loop(shade_material_loop);
@@ -5778,6 +5792,14 @@ void RE_Database_Baking(Render *re, Main *bmain, Scene *scene, unsigned int lay,
                if(re->r.mode & R_RAYTRACE)
                        makeraytree(re);
        
+       /* point density texture */
+       if(!re->test_break(re->tbh))
+               make_pointdensities(re);
+
+       /* voxel data texture */
+       if(!re->test_break(re->tbh))
+               make_voxeldata(re);
+
        /* occlusion */
        if((re->wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT|WO_INDIRECT_LIGHT)) && !re->test_break(re->tbh))
                if(re->wrld.ao_gather_method == WO_AOGATHER_APPROX)
@@ -5846,7 +5868,7 @@ void RE_make_sticky(Scene *scene, View3D *v3d)
                                
                                ms= me->msticky;
                                for(a=0; a<me->totvert; a++, ms++, mvert++) {
-                                       VECCOPY(ho, mvert->co);
+                                       copy_v3_v3(ho, mvert->co);
                                        mul_m4_v3(mat, ho);
                                        projectverto(ho, re->winmat, ho);
                                        ms->co[0]= ho[0]/ho[3];