svn merge ^/trunk/blender -r40720:40872
[blender.git] / source / blender / render / intern / source / convertblender.c
index c347de6fb4b3f89cfecdf6272e85176fbc7252c2..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;
@@ -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= cosf((float)M_PI*(0.5f+(float)degr)/180.0f );
+       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;
@@ -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;
@@ -1349,7 +1349,7 @@ static void particle_billboard(Render *re, ObjectRen *obr, Material *ma, Particl
        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;
+       float uvx = 0.0f, uvy = 0.0f, uvdx = 1.0f, uvdy = 1.0f, time = 0.0f;
 
        vlr= RE_findOrAddVlak(obr, obr->totvlak++);
        vlr->v1= RE_findOrAddVert(obr, obr->totvert++);
@@ -1376,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;
@@ -1470,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);
@@ -1481,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);
 
@@ -1497,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);
 
@@ -1717,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) {
@@ -1728,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;
 
@@ -1892,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);
@@ -1902,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) {
@@ -1945,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;       
@@ -1955,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++;
@@ -1982,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);
                                }
                        }
 
@@ -2147,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) {
@@ -2161,7 +2161,7 @@ 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];
@@ -2238,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);
@@ -2269,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);
@@ -2280,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?) */
@@ -2461,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 */
@@ -2540,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++;
                }       
@@ -2548,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++;
                        }       
@@ -2557,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);
                        }
@@ -2573,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);
                        }
@@ -2602,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;
@@ -2670,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);
@@ -2688,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;
@@ -2701,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) {
@@ -2718,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;
@@ -2913,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);
 
@@ -2979,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;
 
@@ -3340,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);
@@ -3782,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, 
@@ -4001,7 +4002,7 @@ void init_render_world(Render *re)
                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);
                
@@ -4051,25 +4052,25 @@ 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.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.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.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.9f) {
                                        thresh+= dot; tot++;
@@ -4340,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);
                }
        }
 }
@@ -4358,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)
@@ -4851,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);
@@ -4932,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];
                                                        }
@@ -4958,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];
                                                                }
@@ -5020,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? */
        
@@ -5064,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);
 
@@ -5216,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;
@@ -5251,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;
@@ -5267,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;
 
@@ -5303,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
@@ -5764,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);
@@ -5860,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];