[Bf-blender-cvs] [d580c90] master: CustomData: const correctness for interp()
Campbell Barton
noreply at git.blender.org
Mon Feb 23 04:00:48 CET 2015
Commit: d580c90469b4ba182bd8aa8e7a4e289884e426fe
Author: Campbell Barton
Date: Mon Feb 23 13:51:55 2015 +1100
Branches: master
https://developer.blender.org/rBd580c90469b4ba182bd8aa8e7a4e289884e426fe
CustomData: const correctness for interp()
===================================================================
M source/blender/blenkernel/BKE_customdata.h
M source/blender/blenkernel/intern/customdata.c
M source/blender/blenkernel/intern/data_transfer.c
M source/blender/blenkernel/intern/data_transfer_intern.h
M source/blender/blenkernel/intern/deform.c
M source/blender/bmesh/intern/bmesh_interp.c
M source/blender/bmesh/intern/bmesh_interp.h
M source/blender/bmesh/intern/bmesh_mods.c
M source/blender/bmesh/operators/bmo_fill_grid.c
M source/blender/bmesh/operators/bmo_inset.c
M source/blender/bmesh/tools/bmesh_decimate_collapse.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index f3f1e0a..5087842 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -79,7 +79,7 @@ extern const CustomDataMask CD_MASK_EVERYTHING;
void customData_mask_layers__print(CustomDataMask mask);
-typedef void (*cd_interp)(void **sources, const float *weights, const float *sub_weights, int count, void *dest);
+typedef void (*cd_interp)(const void **sources, const float *weights, const float *sub_weights, int count, void *dest);
typedef void (*cd_copy)(const void *source, void *dest, int count);
/**
@@ -226,14 +226,17 @@ void CustomData_free_elem(struct CustomData *data, int index, int count);
* count gives the number of source elements to interpolate from
* dest_index gives the dest element to write the interpolated value to
*/
-void CustomData_interp(const struct CustomData *source, struct CustomData *dest,
- int *src_indices, float *weights, float *sub_weights,
- int count, int dest_index);
-void CustomData_bmesh_interp_n(struct CustomData *data, void **src_blocks, const float *weights,
- const float *sub_weights, int count, void *dest_block, int n);
-void CustomData_bmesh_interp(struct CustomData *data, void **src_blocks,
- const float *weights, const float *sub_weights, int count,
- void *dest_block);
+void CustomData_interp(
+ const struct CustomData *source, struct CustomData *dest,
+ int *src_indices, float *weights, float *sub_weights,
+ int count, int dest_index);
+void CustomData_bmesh_interp_n(
+ struct CustomData *data, const void **src_blocks, const float *weights,
+ const float *sub_weights, int count, void *dest_block_ofs, int n);
+void CustomData_bmesh_interp(
+ struct CustomData *data, const void **src_blocks,
+ const float *weights, const float *sub_weights, int count,
+ void *dest_block);
/* swaps the data in the element corners, to new corners with indices as
@@ -377,7 +380,7 @@ struct CustomDataTransferLayerMap;
typedef void (*cd_datatransfer_interp)(
const struct CustomDataTransferLayerMap *laymap, void *dest,
- void **sources, const float *weights, const int count, const float mix_factor);
+ const void **sources, const float *weights, const int count, const float mix_factor);
/**
* Fake CD_LAYERS (those are actually 'real' data stored directly into elements' structs, or otherwise not (directly)
@@ -432,7 +435,7 @@ typedef struct CustomDataTransferLayerMap {
float mix_factor;
const float *mix_weights; /* If non-NULL, array of weights, one for each dest item, replaces mix_factor. */
- void *data_src; /* Data source array (can be regular CD data, vertices/edges/etc., keyblocks...). */
+ const void *data_src; /* Data source array (can be regular CD data, vertices/edges/etc., keyblocks...). */
void *data_dst; /* Data dest array (same type as dat_src). */
int data_src_n; /* Index to affect in data_src (used e.g. for vgroups). */
int data_dst_n; /* Index to affect in data_dst (used e.g. for vgroups). */
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 0436ec0..94dc84e 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -159,7 +159,7 @@ static void layerCopy_mdeformvert(const void *source, void *dest,
memcpy(dest, source, count * size);
for (i = 0; i < count; ++i) {
- MDeformVert *dvert = (MDeformVert *)((char *)dest + i * size);
+ MDeformVert *dvert = POINTER_OFFSET(dest, i * size);
if (dvert->totweight) {
MDeformWeight *dw = MEM_mallocN(dvert->totweight * sizeof(*dw),
@@ -178,7 +178,7 @@ static void layerFree_mdeformvert(void *data, int count, int size)
int i;
for (i = 0; i < count; ++i) {
- MDeformVert *dvert = (MDeformVert *)((char *)data + i * size);
+ MDeformVert *dvert = POINTER_OFFSET(data, i * size);
if (dvert->dw) {
MEM_freeN(dvert->dw);
@@ -195,7 +195,7 @@ static void layerCopy_bmesh_elem_py_ptr(const void *UNUSED(source), void *dest,
int i, size = sizeof(void *);
for (i = 0; i < count; ++i) {
- void **ptr = (void **)((char *)dest + i * size);
+ void **ptr = POINTER_OFFSET(dest, i * size);
*ptr = NULL;
}
}
@@ -212,15 +212,16 @@ static void layerFree_bmesh_elem_py_ptr(void *data, int count, int size)
int i;
for (i = 0; i < count; ++i) {
- void **ptr = (void *)((char *)data + i * size);
+ void **ptr = POINTER_OFFSET(data, i * size);
if (*ptr) {
bpy_bm_generic_invalidate(*ptr);
}
}
}
-static void layerInterp_mdeformvert(void **sources, const float *weights,
- const float *UNUSED(sub_weights), int count, void *dest)
+static void layerInterp_mdeformvert(
+ const void **sources, const float *weights,
+ const float *UNUSED(sub_weights), int count, void *dest)
{
/* a single linked list of MDeformWeight's
* use this to avoid double allocs (which LinkNode would do) */
@@ -239,7 +240,7 @@ static void layerInterp_mdeformvert(void **sources, const float *weights,
/* build a list of unique def_nrs for dest */
totweight = 0;
for (i = 0; i < count; ++i) {
- MDeformVert *source = sources[i];
+ const MDeformVert *source = sources[i];
float interp_weight = weights ? weights[i] : 1.0f;
for (j = 0; j < source->totweight; ++j) {
@@ -300,13 +301,14 @@ static void layerInterp_mdeformvert(void **sources, const float *weights,
}
}
-static void layerInterp_normal(void **sources, const float *weights,
- const float *UNUSED(sub_weights), int count, void *dest)
+static void layerInterp_normal(
+ const void **sources, const float *weights,
+ const float *UNUSED(sub_weights), int count, void *dest)
{
float no[3] = {0.0f};
while (count--) {
- madd_v3_v3fl(no, (float *)sources[count], weights[count]);
+ madd_v3_v3fl(no, (const float *)sources[count], weights[count]);
}
copy_v3_v3((float *)dest, no);
@@ -353,8 +355,9 @@ static void layerCopy_tface(const void *source, void *dest, int count)
dest_tf[i] = source_tf[i];
}
-static void layerInterp_tface(void **sources, const float *weights,
- const float *sub_weights, int count, void *dest)
+static void layerInterp_tface(
+ const void **sources, const float *weights,
+ const float *sub_weights, int count, void *dest)
{
MTFace *tf = dest;
int i, j, k;
@@ -366,7 +369,7 @@ static void layerInterp_tface(void **sources, const float *weights,
sub_weight = sub_weights;
for (i = 0; i < count; ++i) {
float weight = weights ? weights[i] : 1;
- MTFace *src = sources[i];
+ const MTFace *src = sources[i];
for (j = 0; j < 4; ++j) {
if (sub_weights) {
@@ -460,8 +463,9 @@ static void layerCopy_origspace_face(const void *source, void *dest, int count)
dest_tf[i] = source_tf[i];
}
-static void layerInterp_origspace_face(void **sources, const float *weights,
- const float *sub_weights, int count, void *dest)
+static void layerInterp_origspace_face(
+ const void **sources, const float *weights,
+ const float *sub_weights, int count, void *dest)
{
OrigSpaceFace *osf = dest;
int i, j, k;
@@ -473,7 +477,7 @@ static void layerInterp_origspace_face(void **sources, const float *weights,
sub_weight = sub_weights;
for (i = 0; i < count; ++i) {
float weight = weights ? weights[i] : 1;
- OrigSpaceFace *src = sources[i];
+ const OrigSpaceFace *src = sources[i];
for (j = 0; j < 4; ++j) {
if (sub_weights) {
@@ -790,8 +794,9 @@ static void layerDefault_mloopcol(void *data, int count)
}
-static void layerInterp_mloopcol(void **sources, const float *weights,
- const float *sub_weights, int count, void *dest)
+static void layerInterp_mloopcol(
+ const void **sources, const float *weights,
+ const float *sub_weights, int count, void *dest)
{
MLoopCol *mc = dest;
int i;
@@ -807,7 +812,7 @@ static void layerInterp_mloopcol(void **sources, const float *weights,
sub_weight = sub_weights;
for (i = 0; i < count; ++i) {
float weight = weights ? weights[i] : 1;
- MLoopCol *src = sources[i];
+ const MLoopCol *src = sources[i];
if (sub_weights) {
col.r += src->r * (*sub_weight) * weight;
col.g += src->g * (*sub_weight) * weight;
@@ -894,8 +899,9 @@ static void layerAdd_mloopuv(void *data1, const void *data2)
add_v2_v2(l1->uv, l2->uv);
}
-static void layerInterp_mloopuv(void **sources, const float *weights,
- const float *sub_weights, int count, void *dest)
+static void layerInterp_mloopuv(
+ const void **sources, const float *weights,
+ const float *sub_weights, int count, void *dest)
{
float uv[2];
int i;
@@ -906,7 +912,7 @@ static void layerInterp_mloopuv(void **sources, const float *weights,
const float *sub_weight = sub_weights;
for (i = 0; i < count; i++) {
float weight = weights ? weights[i] : 1.0f;
- MLoopUV *src = sources[i];
+ const MLoopUV *src = sources[i];
madd_v2_v2fl(uv, src->uv, (*sub_weight) * weight);
sub_weight++;
}
@@ -914,7 +920,7 @@ static void layerInterp_mloopuv(void **sources, const float *weights,
else {
for (i = 0; i < count; i++) {
float weight = weights ? weights[i] : 1;
- MLoopUV *src = sources[i];
+ const MLoopUV *src = sources[i];
madd_v2_v2fl(uv, src->uv, weight);
}
}
@@ -970,8 +976,9 @@ static void layerAdd_mloop_origspace(void *data1, const void *data2)
add_v2_v2(l1->uv, l2->uv);
}
-static void layerInterp_mloop_origspace(void **sources, const float *weights,
- const float *sub_weights, int count, void *dest)
+static void layerInterp_mloop_origspace(
+ const void **sources, const float *weights,
+ const float *sub_weights, int count, void *dest)
{
float uv[2];
int i;
@@ -982,7 +989,7 @@ stat
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list