Cleanup: Rename callback flags from library_query to `IDWALK_CB_...`
[blender-staging.git] / source / blender / modifiers / intern / MOD_uvproject.c
index a10386a6f41fd87d4264b7e22f44f720e1fd8c41..78dc1ea8bcb2968b821c2ceee96ade28f7f62cb5 100644 (file)
 
 
 #include "BKE_camera.h"
+#include "BKE_library_query.h"
 #include "BKE_mesh.h"
 #include "BKE_DerivedMesh.h"
 
 #include "MOD_modifiertypes.h"
 
 #include "MEM_guardedalloc.h"
+
 #include "depsgraph_private.h"
+#include "DEG_depsgraph_build.h"
 
 static void initData(ModifierData *md)
 {
@@ -89,7 +92,7 @@ static void foreachObjectLink(ModifierData *md, Object *ob,
        int i;
 
        for (i = 0; i < MOD_UVPROJECT_MAXPROJECTORS; ++i)
-               walk(userData, ob, &umd->projectors[i]);
+               walk(userData, ob, &umd->projectors[i], IDWALK_CB_NOP);
 }
 
 static void foreachIDLink(ModifierData *md, Object *ob,
@@ -97,10 +100,9 @@ static void foreachIDLink(ModifierData *md, Object *ob,
 {
        UVProjectModifierData *umd = (UVProjectModifierData *) md;
 
-       walk(userData, ob, (ID **)&umd->image);
+       walk(userData, ob, (ID **)&umd->image, IDWALK_CB_USER);
 
-       foreachObjectLink(md, ob, (ObjectWalkFunc)walk,
-                         userData);
+       foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData);
 }
 
 static void updateDepgraph(ModifierData *md, DagForest *forest,
@@ -122,6 +124,21 @@ static void updateDepgraph(ModifierData *md, DagForest *forest,
        }
 }
 
+static void updateDepsgraph(ModifierData *md,
+                            struct Main *UNUSED(bmain),
+                            struct Scene *UNUSED(scene),
+                            Object *UNUSED(ob),
+                            struct DepsNodeHandle *node)
+{
+       UVProjectModifierData *umd = (UVProjectModifierData *)md;
+       int i;
+       for (i = 0; i < umd->num_projectors; ++i) {
+               if (umd->projectors[i] != NULL) {
+                       DEG_add_object_relation(node, umd->projectors[i], DEG_OB_COMP_TRANSFORM, "UV Project Modifier");
+               }
+       }
+}
+
 typedef struct Projector {
        Object *ob;             /* object this projector is derived from */
        float projmat[4][4];    /* projection matrix */
@@ -139,7 +156,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd,
        Image *image = umd->image;
        MPoly *mpoly, *mp;
        MLoop *mloop;
-       int override_image = ((umd->flags & MOD_UVPROJECT_OVERRIDEIMAGE) != 0);
+       const bool override_image = (umd->flags & MOD_UVPROJECT_OVERRIDEIMAGE) != 0;
        Projector projectors[MOD_UVPROJECT_MAXPROJECTORS];
        int num_projectors = 0;
        char uvname[MAX_CUSTOMDATA_LAYER_NAME];
@@ -369,6 +386,7 @@ ModifierTypeInfo modifierType_UVProject = {
        /* freeData */          NULL,
        /* isDisabled */        NULL,
        /* updateDepgraph */    updateDepgraph,
+       /* updateDepsgraph */   updateDepsgraph,
        /* dependsOnTime */     NULL,
        /* dependsOnNormals */  NULL,
        /* foreachObjectLink */ foreachObjectLink,