code cleanup: move file string defines into BLI_path_utils.h, BKE_utildefines is...
[blender.git] / source / blender / blenkernel / intern / anim.c
index 16ff1646f436c291f79f36aa02e5841216dfd2a6..b4a3d905edb6732047a28990e81b87888400d41d 100644 (file)
@@ -63,7 +63,6 @@
 #include "BKE_object.h"
 #include "BKE_particle.h"
 #include "BKE_scene.h"
-#include "BKE_utildefines.h"
 #include "BKE_tessmesh.h"
 #include "BKE_depsgraph.h"
 #include "BKE_anim.h"
@@ -282,7 +281,7 @@ void animviz_get_object_motionpaths(Object *ob, ListBase *targets)
 
 /* ........ */
 
-/* Note on evaluation optimisations:
+/* Note on evaluation optimizations:
  * Optimisations currently used here play tricks with the depsgraph in order to try and 
  * evaluate as few objects as strictly necessary to get nicer performance under standard
  * production conditions. For those people who really need the accurate version, 
@@ -323,7 +322,7 @@ static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets)
 /* update scene for current frame */
 static void motionpaths_calc_update_scene(Scene *scene)
 {
-#if 1 // 'production' optimisations always on
+#if 1 // 'production' optimizations always on
        Base *base, *last = NULL;
        
        /* only stuff that moves or needs display still */
@@ -431,7 +430,7 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets)
        if (efra <= sfra) return;
        
        /* optimize the depsgraph for faster updates */
-       /* TODO: whether this is used should depend on some setting for the level of optimisations used */
+       /* TODO: whether this is used should depend on some setting for the level of optimizations used */
        motionpaths_calc_optimise_depsgraph(scene, targets);
        
        /* calculate path over requested range */
@@ -755,8 +754,8 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int par_inde
 
                        /* check the group instance and object layers match, also that the object visible flags are ok. */
                        if ((dob->origlay & group->layer) == 0 ||
-                           (G.rendering == 0 && dob->ob->restrictflag & OB_RESTRICT_VIEW) ||
-                           (G.rendering && dob->ob->restrictflag & OB_RESTRICT_RENDER))
+                           ((G.is_rendering == FALSE) && dob->ob->restrictflag & OB_RESTRICT_VIEW) ||
+                           ((G.is_rendering == TRUE)  && dob->ob->restrictflag & OB_RESTRICT_RENDER))
                        {
                                dob->no_draw = TRUE;
                        }
@@ -934,7 +933,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl
        else
                dm = mesh_get_derived_deform(scene, par, CD_MASK_BAREMESH);
        
-       if (G.rendering) {
+       if (G.is_rendering) {
                vdd.orco = (float(*)[3])BKE_mesh_orco_verts_get(par);
                BKE_mesh_orco_verts_transform(me, vdd.orco, me->totvert, 0);
        }
@@ -1066,7 +1065,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
        mloop = dm->getLoopArray(dm);
        mvert = dm->getVertArray(dm);
 
-       if (G.rendering) {
+       if (G.is_rendering) {
 
                orco = (float(*)[3])BKE_mesh_orco_verts_get(par);
                BKE_mesh_orco_verts_transform(me, orco, me->totvert, 0);
@@ -1177,7 +1176,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa
                                                mul_m4_m4m3(obmat, tmat, mat);
                                                
                                                dob = new_dupli_object(lb, ob, obmat, par->lay, a, par_index, OB_DUPLIFACES, animated);
-                                               if (G.rendering) {
+                                               if (G.is_rendering) {
                                                        w = 1.0f / (float)mp->totloop;
 
                                                        if (orco) {
@@ -1251,7 +1250,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
        if (!psys_check_enabled(par, psys))
                return;
 
-       if (G.rendering == 0)
+       if (G.is_rendering == FALSE)
                no_draw_flag |= PARS_NO_DISP;
        
        ctime = BKE_scene_frame_get(scene); /* NOTE: in old animsys, used parent object's timeoffset... */
@@ -1279,9 +1278,9 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
                        if (part->dup_group == NULL || part->dup_group->gobject.first == NULL)
                                return;
 
-                       for (go = part->dup_group->gobject.first; go; go = go->next)
-                               if (go->ob == par)
-                                       return;
+                       if (BLI_findptr(&part->dup_group->gobject, par, offsetof(GroupObject, ob))) {
+                               return;
+                       }
                }
 
                /* if we have a hair particle system, use the path cache */
@@ -1445,7 +1444,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
 
                                        dob = new_dupli_object(lb, go->ob, mat, par->lay, counter, index, OB_DUPLIPARTS, animated);
                                        copy_m4_m4(dob->omat, obcopylist[b].obmat);
-                                       if (G.rendering)
+                                       if (G.is_rendering)
                                                psys_get_dupli_texture(psys, part, sim.psmd, pa, cpa, dob->uv, dob->orco);
                                }
                        }
@@ -1458,12 +1457,30 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
 
                                /* particle rotation uses x-axis as the aligned axis, so pre-rotate the object accordingly */
                                if ((part->draw & PART_DRAW_ROTATE_OB) == 0) {
-                                       float xvec[3], q[4];
+                                       float xvec[3], q[4], size_mat[4][4], original_size[3];
+
+                                       mat4_to_size(original_size, obmat);
+                                       size_to_mat4(size_mat, original_size);
+
                                        xvec[0] = -1.f;
                                        xvec[1] = xvec[2] = 0;
                                        vec_to_quat(q, xvec, ob->trackflag, ob->upflag);
                                        quat_to_mat4(obmat, q);
                                        obmat[3][3] = 1.0f;
+                                       
+                                       /* add scaling if requested */
+                                       if ((part->draw & PART_DRAW_NO_SCALE_OB) == 0)
+                                               mult_m4_m4m4(obmat, obmat, size_mat);
+                               }
+                               else if (part->draw & PART_DRAW_NO_SCALE_OB) {
+                                       /* remove scaling */
+                                       float size_mat[4][4], original_size[3];
+
+                                       mat4_to_size(original_size, obmat);
+                                       size_to_mat4(size_mat, original_size);
+                                       invert_m4(size_mat);
+
+                                       mult_m4_m4m4(obmat, obmat, size_mat);
                                }
                                
                                /* Normal particles and cached hair live in global space so we need to
@@ -1487,7 +1504,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
 
                                dob = new_dupli_object(lb, ob, mat, ob->lay, counter, index, GS(id->name) == ID_GR ? OB_DUPLIGROUP : OB_DUPLIPARTS, animated);
                                copy_m4_m4(dob->omat, oldobmat);
-                               if (G.rendering)
+                               if (G.is_rendering)
                                        psys_get_dupli_texture(psys, part, sim.psmd, pa, cpa, dob->uv, dob->orco);
                        }
 
@@ -1543,7 +1560,7 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int par_inde
 {
        Object *ob, *obar[256] = {NULL};
        Curve *cu;
-       struct chartrans *ct, *chartransdata;
+       struct CharTrans *ct, *chartransdata;
        float vec[3], obmat[4][4], pmat[4][4], fsize, xof, yof;
        int slen, a;
        
@@ -1593,7 +1610,7 @@ static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBas
                return;
        
        /* Should the dupli's be generated for this object? - Respect restrict flags */
-       if (G.rendering) {
+       if (G.is_rendering) {
                if (ob->restrictflag & OB_RESTRICT_RENDER) {
                        return;
                }