Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
- This file was moved from source/blender/modifiers/intern/MOD_gpencilbuild.c.
| Show All 30 Lines | |||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| #include "DNA_meshdata_types.h" | #include "DNA_meshdata_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_gpencil_types.h" | #include "DNA_gpencil_types.h" | ||||
| #include "DNA_gpencil_modifier_types.h" | |||||
| #include "BLI_blenlib.h" | #include "BLI_blenlib.h" | ||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_gpencil.h" | #include "BKE_gpencil.h" | ||||
| #include "BKE_gpencil_modifier.h" | |||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| #include "MOD_modifiertypes.h" | |||||
| #include "MOD_gpencil_util.h" | #include "MOD_gpencil_util.h" | ||||
| #include "MOD_gpencil_modifiertypes.h" | |||||
| static void initData(ModifierData *md) | static void initData(GpencilModifierData *md) | ||||
| { | { | ||||
| BuildGpencilModifierData *gpmd = (BuildGpencilModifierData *)md; | BuildGpencilModifierData *gpmd = (BuildGpencilModifierData *)md; | ||||
| /* We deliberately set this range to the half the default | /* We deliberately set this range to the half the default | ||||
| * frame-range to have an immediate effect ot suggest use-cases | * frame-range to have an immediate effect ot suggest use-cases | ||||
| */ | */ | ||||
| gpmd->start_frame = 1; | gpmd->start_frame = 1; | ||||
| gpmd->end_frame = 125; | gpmd->end_frame = 125; | ||||
| /* Init default length of each build effect - Nothing special */ | /* Init default length of each build effect - Nothing special */ | ||||
| gpmd->start_delay = 0.0f; | gpmd->start_delay = 0.0f; | ||||
| gpmd->length = 100.0f; | gpmd->length = 100.0f; | ||||
| } | } | ||||
| static void copyData(const ModifierData *md, ModifierData *target) | static void copyData(const GpencilModifierData *md, GpencilModifierData *target) | ||||
| { | { | ||||
| modifier_copyData_generic(md, target); | BKE_gpencil_modifier_copyData_generic(md, target); | ||||
| } | } | ||||
| static bool dependsOnTime(ModifierData *UNUSED(md)) | static bool dependsOnTime(GpencilModifierData *UNUSED(md)) | ||||
| { | { | ||||
| return true; | return true; | ||||
| } | } | ||||
| /* ******************************************** */ | /* ******************************************** */ | ||||
| /* Build Modifier - Stroke generation logic | /* Build Modifier - Stroke generation logic | ||||
| * | * | ||||
| * There are two modes for how the strokes are sequenced (at a macro-level): | * There are two modes for how the strokes are sequenced (at a macro-level): | ||||
| ▲ Show 20 Lines • Show All 314 Lines • ▼ Show 20 Lines | for (gps = gpf->strokes.first; gps; gps = gps_next) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* --------------------------------------------- */ | /* --------------------------------------------- */ | ||||
| /* Entry-point for Build Modifier */ | /* Entry-point for Build Modifier */ | ||||
| static void gp_generateStrokes( | static void gp_generateStrokes( | ||||
| ModifierData *md, Depsgraph *depsgraph, | GpencilModifierData *md, Depsgraph *depsgraph, | ||||
| Object *UNUSED(ob), bGPDlayer *gpl, bGPDframe *gpf) | Object *UNUSED(ob), bGPDlayer *gpl, bGPDframe *gpf) | ||||
| { | { | ||||
| BuildGpencilModifierData *mmd = (BuildGpencilModifierData *)md; | BuildGpencilModifierData *mmd = (BuildGpencilModifierData *)md; | ||||
| const bool reverse = (mmd->transition != GP_BUILD_TRANSITION_GROW); | const bool reverse = (mmd->transition != GP_BUILD_TRANSITION_GROW); | ||||
| const float ctime = DEG_get_ctime(depsgraph); | const float ctime = DEG_get_ctime(depsgraph); | ||||
| //printf("GP Build Modifier - %f\n", ctime); | //printf("GP Build Modifier - %f\n", ctime); | ||||
| ▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | |||||
| /* FIXME: Baking the Build Modifier is currently unsupported. | /* FIXME: Baking the Build Modifier is currently unsupported. | ||||
| * Adding support for this is more complicated than for other | * Adding support for this is more complicated than for other | ||||
| * modifiers, as to implement this, we'd have to add more frames, | * modifiers, as to implement this, we'd have to add more frames, | ||||
| * which would in turn break how the modifier functions. | * which would in turn break how the modifier functions. | ||||
| */ | */ | ||||
| #if 0 | #if 0 | ||||
| static void gp_bakeModifier( | static void gp_bakeModifier( | ||||
| Main *bmain, const Depsgraph *UNUSED(depsgraph), | Main *bmain, const Depsgraph *UNUSED(depsgraph), | ||||
| ModifierData *md, Object *ob) | GpencilModifierData *md, Object *ob) | ||||
| { | { | ||||
| bGPdata *gpd = ob->data; | bGPdata *gpd = ob->data; | ||||
| for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { | for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { | ||||
| for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) { | for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| #endif | #endif | ||||
| /* ******************************************** */ | /* ******************************************** */ | ||||
| ModifierTypeInfo modifierType_Gpencil_Build = { | GpencilModifierTypeInfo modifierType_Gpencil_Build = { | ||||
| /* name */ "Build", | /* name */ "Build", | ||||
| /* structName */ "BuildGpencilModifierData", | /* structName */ "BuildGpencilModifierData", | ||||
| /* structSize */ sizeof(BuildGpencilModifierData), | /* structSize */ sizeof(BuildGpencilModifierData), | ||||
| /* type */ eModifierTypeType_Gpencil, | /* type */ eGpencilModifierTypeType_Gpencil, | ||||
| /* flags */ eModifierTypeFlag_GpencilMod, | /* flags */ eGpencilModifierTypeFlag_GpencilMod, | ||||
| /* copyData */ copyData, | /* copyData */ copyData, | ||||
| /* deformVerts_DM */ NULL, | |||||
| /* deformMatrices_DM */ NULL, | |||||
| /* deformVertsEM_DM */ NULL, | |||||
| /* deformMatricesEM_DM*/NULL, | |||||
| /* applyModifier_DM */ NULL, | |||||
| /* applyModifierEM_DM */NULL, | |||||
| /* deformVerts */ NULL, | |||||
| /* deformMatrices */ NULL, | |||||
| /* deformVertsEM */ NULL, | |||||
| /* deformMatricesEM */ NULL, | |||||
| /* applyModifier */ NULL, | |||||
| /* applyModifierEM */ NULL, | |||||
| /* gp_deformStroke */ NULL, | /* gp_deformStroke */ NULL, | ||||
| /* gp_generateStrokes */ gp_generateStrokes, | /* gp_generateStrokes */ gp_generateStrokes, | ||||
| /* gp_bakeModifier */ NULL, | /* gp_bakeModifier */ NULL, | ||||
| /* initData */ initData, | /* initData */ initData, | ||||
| /* requiredDataMask */ NULL, | |||||
| /* freeData */ NULL, | /* freeData */ NULL, | ||||
| /* isDisabled */ NULL, | /* isDisabled */ NULL, | ||||
| /* updateDepsgraph */ NULL, | /* updateDepsgraph */ NULL, | ||||
| /* dependsOnTime */ dependsOnTime, | /* dependsOnTime */ dependsOnTime, | ||||
| /* dependsOnNormals */ NULL, | /* dependsOnNormals */ NULL, | ||||
| /* foreachObjectLink */ NULL, | /* foreachObjectLink */ NULL, | ||||
| /* foreachIDLink */ NULL, | /* foreachIDLink */ NULL, | ||||
| /* foreachTexLink */ NULL, | /* foreachTexLink */ NULL, | ||||
| }; | }; | ||||