Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/customdata.cc
| Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
| #include "bmesh.h" | #include "bmesh.h" | ||||
| #include "CLG_log.h" | #include "CLG_log.h" | ||||
| /* only for customdata_data_transfer_interp_normal_normals */ | /* only for customdata_data_transfer_interp_normal_normals */ | ||||
| #include "data_transfer_intern.h" | #include "data_transfer_intern.h" | ||||
| using blender::IndexRange; | |||||
| /* number of layers to add when growing a CustomData object */ | /* number of layers to add when growing a CustomData object */ | ||||
| #define CUSTOMDATA_GROW 5 | #define CUSTOMDATA_GROW 5 | ||||
| /* ensure typemap size is ok */ | /* ensure typemap size is ok */ | ||||
| BLI_STATIC_ASSERT(ARRAY_SIZE(((CustomData *)nullptr)->typemap) == CD_NUMTYPES, "size mismatch"); | BLI_STATIC_ASSERT(ARRAY_SIZE(((CustomData *)nullptr)->typemap) == CD_NUMTYPES, "size mismatch"); | ||||
| static CLG_LogRef LOG = {"bke.customdata"}; | static CLG_LogRef LOG = {"bke.customdata"}; | ||||
| ▲ Show 20 Lines • Show All 447 Lines • ▼ Show 20 Lines | |||||
| /** \name Callbacks for (#MIntProperty, #CD_PROP_INT32) | /** \name Callbacks for (#MIntProperty, #CD_PROP_INT32) | ||||
| * \{ */ | * \{ */ | ||||
| static void layerCopy_propInt(const void *source, void *dest, int count) | static void layerCopy_propInt(const void *source, void *dest, int count) | ||||
| { | { | ||||
| memcpy(dest, source, sizeof(MIntProperty) * count); | memcpy(dest, source, sizeof(MIntProperty) * count); | ||||
| } | } | ||||
| static void layerInterp_propInt(const void **sources, | |||||
| const float *weights, | |||||
| const float *UNUSED(sub_weights), | |||||
| int count, | |||||
| void *dest) | |||||
| { | |||||
| float result = 0.0f; | |||||
| for (const int i : IndexRange(count)) { | |||||
HooglyBoogly: What about adding a `using blender::IndexRange` at the top of the file here?
I've wanted to use… | |||||
| const float weight = weights[i]; | |||||
| const float src = *static_cast<const int *>(sources[i]); | |||||
| result += src * weight; | |||||
| } | |||||
| const int rounded_result = static_cast<int>(round(result)); | |||||
| *static_cast<int *>(dest) = rounded_result; | |||||
| } | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Callbacks for (#MStringProperty, #CD_PROP_STRING) | /** \name Callbacks for (#MStringProperty, #CD_PROP_STRING) | ||||
| * \{ */ | * \{ */ | ||||
| static void layerCopy_propString(const void *source, void *dest, int count) | static void layerCopy_propString(const void *source, void *dest, int count) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 1,146 Lines • ▼ Show 20 Lines | static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { | ||||
| layerValidate_propFloat}, | layerValidate_propFloat}, | ||||
| /* 11: CD_PROP_INT32 */ | /* 11: CD_PROP_INT32 */ | ||||
| {sizeof(MIntProperty), | {sizeof(MIntProperty), | ||||
| "MIntProperty", | "MIntProperty", | ||||
| 1, | 1, | ||||
| N_("Int"), | N_("Int"), | ||||
| layerCopy_propInt, | layerCopy_propInt, | ||||
| nullptr, | nullptr, | ||||
| nullptr, | layerInterp_propInt, | ||||
| nullptr}, | nullptr}, | ||||
| /* 12: CD_PROP_STRING */ | /* 12: CD_PROP_STRING */ | ||||
| {sizeof(MStringProperty), | {sizeof(MStringProperty), | ||||
| "MStringProperty", | "MStringProperty", | ||||
| 1, | 1, | ||||
| N_("String"), | N_("String"), | ||||
| layerCopy_propString, | layerCopy_propString, | ||||
| nullptr, | nullptr, | ||||
| ▲ Show 20 Lines • Show All 3,749 Lines • Show Last 20 Lines | |||||
What about adding a using blender::IndexRange at the top of the file here?
I've wanted to use IndexRange elsewhere in this file in various patches ;)