[Bf-blender-cvs] [3e5910d2731] greasepencil-edit-curve: Merge branch 'master' into greasepencil-edit-curve
Antonio Vazquez
noreply at git.blender.org
Tue Jul 14 10:43:51 CEST 2020
Commit: 3e5910d27312875e1e390a8fc40188bc90efe532
Author: Antonio Vazquez
Date: Tue Jul 14 10:43:13 2020 +0200
Branches: greasepencil-edit-curve
https://developer.blender.org/rB3e5910d27312875e1e390a8fc40188bc90efe532
Merge branch 'master' into greasepencil-edit-curve
Conflicts:
source/blender/editors/gpencil/gpencil_utils.c
source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
===================================================================
===================================================================
diff --cc source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
index 4987ce5fa60,56d94611b5d..8e0e314f454
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
@@@ -17,9 -17,9 +17,9 @@@
* This is a new part of Blender
*/
--/** \file
-- * \ingroup modifiers
-- */
++ /** \file
++ * \ingroup modifiers
++ */
#include <stdio.h>
@@@ -57,29 -57,29 +57,29 @@@
#include "MOD_gpencil_ui_common.h"
#include "MOD_gpencil_util.h"
--static void initData(GpencilModifierData *md)
++static void initData(GpencilModifierData* md)
{
-- BuildGpencilModifierData *gpmd = (BuildGpencilModifierData *)md;
++ BuildGpencilModifierData* gpmd = (BuildGpencilModifierData*)md;
-- /* We deliberately set this range to the half the default
-- * frame-range to have an immediate effect to suggest use-cases
-- */
-- gpmd->start_frame = 1;
-- gpmd->end_frame = 125;
++ /* We deliberately set this range to the half the default
++ * frame-range to have an immediate effect to suggest use-cases
++ */
++ gpmd->start_frame = 1;
++ gpmd->end_frame = 125;
-- /* Init default length of each build effect - Nothing special */
-- gpmd->start_delay = 0.0f;
-- gpmd->length = 100.0f;
++ /* Init default length of each build effect - Nothing special */
++ gpmd->start_delay = 0.0f;
++ gpmd->length = 100.0f;
}
--static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
++static void copyData(const GpencilModifierData* md, GpencilModifierData* target)
{
-- BKE_gpencil_modifier_copydata_generic(md, target);
++ BKE_gpencil_modifier_copydata_generic(md, target);
}
--static bool dependsOnTime(GpencilModifierData *UNUSED(md))
++static bool dependsOnTime(GpencilModifierData* UNUSED(md))
{
-- return true;
++ return true;
}
/* ******************************************** */
@@@ -98,566 -98,552 +98,560 @@@
* - All strokes present are fully visible (i.e. we don't have to ignore any)
*/
--/* Remove a particular stroke */
--static void clear_stroke(bGPDframe *gpf, bGPDstroke *gps)
++ /* Remove a particular stroke */
++static void clear_stroke(bGPDframe* gpf, bGPDstroke* gps)
{
-- BLI_remlink(&gpf->strokes, gps);
-- BKE_gpencil_free_stroke(gps);
++ BLI_remlink(&gpf->strokes, gps);
++ BKE_gpencil_free_stroke(gps);
}
/* Clear all strokes in frame */
--static void gpf_clear_all_strokes(bGPDframe *gpf)
++static void gpf_clear_all_strokes(bGPDframe* gpf)
{
-- bGPDstroke *gps, *gps_next;
-- for (gps = gpf->strokes.first; gps; gps = gps_next) {
-- gps_next = gps->next;
-- clear_stroke(gpf, gps);
-- }
-- BLI_listbase_clear(&gpf->strokes);
++ bGPDstroke* gps, * gps_next;
++ for (gps = gpf->strokes.first; gps; gps = gps_next) {
++ gps_next = gps->next;
++ clear_stroke(gpf, gps);
++ }
++ BLI_listbase_clear(&gpf->strokes);
}
/* Reduce the number of points in the stroke
*
* Note: This won't be called if all points are present/removed
- * TODO: Allow blending of growing/shrinking tip (e.g. for more gradual transitions)
*/
- static void reduce_stroke_points(bGPdata *gpd,
- bGPDstroke *gps,
-static void reduce_stroke_points(bGPDstroke *gps,
-- const int num_points,
-- const eBuildGpencil_Transition transition)
++static void reduce_stroke_points(bGPdata* gpd,
++ bGPDstroke* gps,
++ const int num_points,
++ const eBuildGpencil_Transition transition)
{
-- bGPDspoint *new_points = MEM_callocN(sizeof(bGPDspoint) * num_points, __func__);
-- MDeformVert *new_dvert = NULL;
-- if ((gps->dvert != NULL) && (num_points > 0)) {
-- new_dvert = MEM_callocN(sizeof(MDeformVert) * num_points, __func__);
-- }
--
-- /* Which end should points be removed from */
- // TODO: free stroke weights
-- switch (transition) {
-- case GP_BUILD_TRANSITION_GROW: /* Show in forward order =
-- * Remove ungrown-points from end of stroke. */
-- case GP_BUILD_TRANSITION_SHRINK: /* Hide in reverse order =
-- * Remove dead-points from end of stroke. */
-- {
-- /* copy over point data */
-- memcpy(new_points, gps->points, sizeof(bGPDspoint) * num_points);
-- if ((gps->dvert != NULL) && (num_points > 0)) {
-- memcpy(new_dvert, gps->dvert, sizeof(MDeformVert) * num_points);
--
-- /* free unused point weights */
-- for (int i = num_points; i < gps->totpoints; i++) {
-- MDeformVert *dvert = &gps->dvert[i];
-- BKE_gpencil_free_point_weights(dvert);
-- }
-- }
-- break;
-- }
--
-- /* Hide in forward order = Remove points from start of stroke */
-- case GP_BUILD_TRANSITION_FADE: {
-- /* num_points is the number of points left after reducing.
-- * We need to know how many to remove
-- */
-- const int offset = gps->totpoints - num_points;
--
-- /* copy over point data */
-- memcpy(new_points, gps->points + offset, sizeof(bGPDspoint) * num_points);
-- if ((gps->dvert != NULL) && (num_points > 0)) {
-- memcpy(new_dvert, gps->dvert + offset, sizeof(MDeformVert) * num_points);
--
-- /* free unused weights */
-- for (int i = 0; i < offset; i++) {
-- MDeformVert *dvert = &gps->dvert[i];
-- BKE_gpencil_free_point_weights(dvert);
-- }
-- }
-- break;
-- }
--
-- default:
-- printf("ERROR: Unknown transition %d in %s()\n", (int)transition, __func__);
-- break;
-- }
--
-- /* replace stroke geometry */
-- MEM_SAFE_FREE(gps->points);
-- MEM_SAFE_FREE(gps->dvert);
-- gps->points = new_points;
-- gps->dvert = new_dvert;
-- gps->totpoints = num_points;
--
-- /* Calc geometry data. */
- BKE_gpencil_stroke_geometry_update(gpd, gps);
- BKE_gpencil_stroke_geometry_update(gps);
++ bGPDspoint* new_points = MEM_callocN(sizeof(bGPDspoint) * num_points, __func__);
++ MDeformVert* new_dvert = NULL;
++ if ((gps->dvert != NULL) && (num_points > 0)) {
++ new_dvert = MEM_callocN(sizeof(MDeformVert) * num_points, __func__);
++ }
++
++ /* Which end should points be removed from */
++ switch (transition) {
++ case GP_BUILD_TRANSITION_GROW: /* Show in forward order =
++ * Remove ungrown-points from end of stroke. */
++ case GP_BUILD_TRANSITION_SHRINK: /* Hide in reverse order =
++ * Remove dead-points from end of stroke. */
++ {
++ /* copy over point data */
++ memcpy(new_points, gps->points, sizeof(bGPDspoint) * num_points);
++ if ((gps->dvert != NULL) && (num_points > 0)) {
++ memcpy(new_dvert, gps->dvert, sizeof(MDeformVert) * num_points);
++
++ /* free unused point weights */
++ for (int i = num_points; i < gps->totpoints; i++) {
++ MDeformVert* dvert = &gps->dvert[i];
++ BKE_gpencil_free_point_weights(dvert);
++ }
++ }
++ break;
++ }
++
++ /* Hide in forward order = Remove points from start of stroke */
++ case GP_BUILD_TRANSITION_FADE:
++ {
++ /* num_points is the number of points left after reducing.
++ * We need to know how many to remove
++ */
++ const int offset = gps->totpoints - num_points;
++
++ /* copy over point data */
++ memcpy(new_points, gps->points + offset, sizeof(bGPDspoint) * num_points);
++ if ((gps->dvert != NULL) && (num_points > 0)) {
++ memcpy(new_dvert, gps->dvert + offset, sizeof(MDeformVert) * num_points);
++
++ /* free unused weights */
++ for (int i = 0; i < offset; i++) {
++ MDeformVert* dvert = &gps->dvert[i];
++ BKE_gpencil_free_point_weights(dvert);
++ }
++ }
++ break;
++ }
++
++ default:
++ printf("ERROR: Unknown transition %d in %s()\n", (int)transition, __func__);
++ break;
++ }
++
++ /* replace stroke geometry */
++ MEM_SAFE_FREE(gps->points);
++ MEM_SAFE_FREE(gps->dvert);
++ gps->points = new_points;
++ gps->dvert = new_dvert;
++ gps->totpoints = num_points;
++
++ /* Calc geometry data. */
++ BKE_gpencil_stroke_geometry_update(gpd, gps);
}
/* --------------------------------------------- */
/* Stroke Data Table Entry - This represents one stroke being generated */
--typedef struct tStrokeBuildDetails {
-- bGPDstroke *gps;
++typedef struct tStrokeBuildDetails
++{
++ bGPDstroke* gps;
-- /* Indices - first/last indices for the stroke's points (overall) */
-- size_t start_idx, end_idx;
++ /* Indices - first/last indices for the stroke's points (overall) */
++ size_t start_idx, end_idx;
-- /* Number of points - Cache for more convenient access */
-- int totpoints;
++ /* Number of points - Cache for more convenient access */
++ int totpoints;
} tStrokeBuildDetails;
/* Sequential - Show strokes one after the other */
- static void build_sequential(BuildGpencilModifierData *mmd,
- bGPdata *gpd,
- bGPDframe *gpf,
- float fac)
-static void build_sequential(BuildGpencilModifierData *mmd, bGPDframe *gpf, float fac)
++static void build_sequential(BuildGpencilModifierData* mmd,
++ bGPdata* gpd,
++ bGPDframe* gpf,
++ float fac)
{
-- const size_t tot_strokes = BLI_listbase_count(&gpf->strokes);
-- bGPDstroke *gps;
-- size_t i;
--
-- /* 1) Compute proportion of time each stroke should occupy */
-- /* NOTE: This assumes that the total number of points won't overflow! */
-- tStrokeBuildDetails *table = MEM_callocN(sizeof(tStrokeBuildDetails) * tot_strokes, __func__);
-- size_t totpoints = 0;
--
-- /* 1.1) First pass - Tally up points */
-- for (gps = gpf->strokes.first, i = 0; gps; gps = gps->next, i++) {
-- tStrokeBuildDetails *cell = &table[i];
--
-- cell->gps = gps;
-- cell->totpoints = gps->totpoints;
--
-- totpoints += cell->totpoints;
-- }
--
-- /* 1.2) Second pass - Compute the overall indices for points */
-- for (i = 0; i < tot_strokes; i++) {
-- tStrokeBuildDetails *cell = &table[i];
--
-- if (i == 0) {
-- cell->start_idx = 0;
-- }
-- else {
-- cell->start_idx = (cell - 1)->end_idx;
-- }
-- cell->end_idx = cell->start_idx + cell->totpoints - 1;
-- }
--
-- /* 2) Determine the global indices for points that should be visible */
-- size_t
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list