[Bf-blender-cvs] [089374869b9] temp-npr-gpencil-modifiers: Gpencil: Code style fixes for two modifiers.
YimingWu
noreply at git.blender.org
Thu Oct 10 10:58:27 CEST 2019
Commit: 089374869b949dfe7c2acd441299844df909c843
Author: YimingWu
Date: Thu Oct 10 16:52:49 2019 +0800
Branches: temp-npr-gpencil-modifiers
https://developer.blender.org/rB089374869b949dfe7c2acd441299844df909c843
Gpencil: Code style fixes for two modifiers.
===================================================================
M source/blender/blenkernel/intern/gpencil.c
M source/blender/blenlib/BLI_map.h
M source/blender/gpencil_modifiers/intern/MOD_gpencillength.c
M source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c
M source/blender/makesdna/DNA_gpencil_modifier_types.h
===================================================================
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index c596b8a1fb8..cfee019b21c 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -1772,18 +1772,18 @@ bool BKE_gpencil_stretch_stroke(bGPDstroke *gps, const float dist)
second_last = &pt[gps->totpoints - 2];
next_pt = &pt[1];
- float len1 = 0;
- float len2 = 0;
+ float len1 = 0.0f;
+ float len2 = 0.0f;
i = 1;
- while (len1 < 0.001 && gps->totpoints > i) {
+ while (len1 < 0.001f && gps->totpoints > i) {
next_pt = &pt[i];
len1 = len_v3v3(&next_pt->x, &pt->x);
i++;
}
i = 2;
- while (len2 < 0.001 && gps->totpoints >= i) {
+ while (len2 < 0.001f && gps->totpoints >= i) {
second_last = &pt[gps->totpoints - i];
len2 = len_v3v3(&last_pt->x, &second_last->x);
i++;
@@ -1814,7 +1814,7 @@ bool BKE_gpencil_trim_stroke_points(bGPDstroke *gps, const int index_from, const
bGPDspoint *pt = gps->points, *new_pt;
MDeformVert *dv, *new_dv;
- int new_count = index_to - index_from + 1;
+ const int new_count = index_to - index_from + 1;
if (new_count >= gps->totpoints) {
return false;
@@ -1872,8 +1872,8 @@ bool BKE_gpencil_split_stroke(bGPDframe *gpf,
return false;
}
- int new_count = gps->totpoints - before_index;
- int old_count = before_index;
+ const int new_count = gps->totpoints - before_index;
+ const int old_count = before_index;
/* Handle remaining segments first. */
@@ -1903,8 +1903,8 @@ bool BKE_gpencil_split_stroke(bGPDframe *gpf,
(*remaining_gps) = new_gps;
- /* Trim the original stroke into a shorter one. */
- /* Keep the end point. */
+ /* Trim the original stroke into a shorter one.
+ * Keep the end point. */
BKE_gpencil_trim_stroke_points(gps, 0, old_count);
@@ -1929,10 +1929,12 @@ bool BKE_gpencil_shrink_stroke(bGPDstroke *gps, const float dist)
second_last = &pt[gps->totpoints - 2];
next_pt = &pt[1];
- float len1 = 0, this_len1 = 0, cut_len1 = 0;
- float len2 = 0, this_len2 = 0, cut_len2 = 0;
+ float len1, this_len1, cut_len1;
+ float len2, this_len2, cut_len2;
int index_start, index_end;
+ len1 = len2 = this_len1 = this_len2 = cut_len1 = cut_len2 = 0.0f;
+
i = 1;
while (len1 < dist && gps->totpoints > i - 1) {
next_pt = &pt[i];
@@ -2507,12 +2509,12 @@ void BKE_gpencil_stroke_2d_flat_ref(const bGPDspoint *ref_points,
float BKE_gpencil_stroke_length(const bGPDstroke *gps, bool use_3d)
{
if (!gps->points || gps->totpoints < 2) {
- return 0;
+ return 0.0f;
}
float *last_pt = &gps->points[0].x;
int i;
bGPDspoint *pt;
- float total_length = 0;
+ float total_length = 0.0f;
for (i = 1; i < gps->totpoints; i++) {
pt = &gps->points[i];
if (use_3d) {
diff --git a/source/blender/blenlib/BLI_map.h b/source/blender/blenlib/BLI_map.h
index 1edf7653c71..3e934480b94 100644
--- a/source/blender/blenlib/BLI_map.h
+++ b/source/blender/blenlib/BLI_map.h
@@ -624,16 +624,15 @@ template<typename KeyT, typename ValueT, typename Allocator = GuardedAllocator>
template<typename ForwardKeyT, typename ForwardValueT>
bool add_override__impl(ForwardKeyT &&key, ForwardValueT &&value)
{
- return this->add_or_modify(
- std::forward<ForwardKeyT>(key),
- [&](ValueT *dst) {
- new (dst) ValueT(std::forward<ForwardValueT>(value));
- return true;
- },
- [&](ValueT *old_value) {
- *old_value = std::forward<ForwardValueT>(value);
- return false;
- });
+ return this->add_or_modify(std::forward<ForwardKeyT>(key),
+ [&](ValueT *dst) {
+ new (dst) ValueT(std::forward<ForwardValueT>(value));
+ return true;
+ },
+ [&](ValueT *old_value) {
+ *old_value = std::forward<ForwardValueT>(value);
+ return false;
+ });
}
template<typename ForwardKeyT, typename ForwardValueT>
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillength.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillength.c
index 81d736f43d2..eccf48873e7 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillength.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillength.c
@@ -90,7 +90,7 @@ static void applyLength(bGPDstroke *gps, float length, float percentage)
if (len < FLT_EPSILON) {
return;
}
- float length2 = len * percentage / 2; /* Srinking from two tips. */
+ float length2 = len * percentage / 2.0f; /* Srinking from two tips. */
stretchOrShrinkStroke(gps, length2);
}
@@ -177,5 +177,4 @@ GpencilModifierTypeInfo modifierType_Gpencil_Length = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
- /* getDuplicationFactor */ NULL,
};
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c
index c564e7177b3..6dd25a2bf56 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c
@@ -69,7 +69,7 @@
static void initData(GpencilModifierData *md)
{
MultiplyGpencilModifierData *mmd = (MultiplyGpencilModifierData *)md;
- mmd->distance = 0.5;
+ mmd->distance = 0.5f;
mmd->split_angle = 1.0f;
}
@@ -346,5 +346,4 @@ GpencilModifierTypeInfo modifierType_Gpencil_Multiply = {
/* foreachObjectLink */ NULL,
/* foreachIDLink */ NULL,
/* foreachTexLink */ NULL,
- /* getDuplicationFactor */ NULL,
};
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_types.h b/source/blender/makesdna/DNA_gpencil_modifier_types.h
index c240e335f74..e1e89521186 100644
--- a/source/blender/makesdna/DNA_gpencil_modifier_types.h
+++ b/source/blender/makesdna/DNA_gpencil_modifier_types.h
@@ -680,13 +680,15 @@ typedef struct MultiplyGpencilModifierData {
int duplications;
float distance;
- float offset; /* -1:inner 0:middle 1:outer */
+ /* -1:inner 0:middle 1:outer */
+ float offset;
float fading_center;
float fading_thickness;
float fading_opacity;
- float split_angle; /* in rad not deg */
+ /* in rad not deg */
+ float split_angle;
/* char _pad[4]; */
} MultiplyGpencilModifierData;
More information about the Bf-blender-cvs
mailing list