Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-08-08 06:29:21 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-08-08 06:38:00 +0300
commit171e77c3c25a1224fc5f7db40ec6f8879f8dbbb0 (patch)
treeea51f4fa508a39807e6f6d333b2d53af8a2b9fc1 /source/blender/blenkernel/intern/pointcache.c
parent4bf3ca20165959f98c7c830a138ba2901d3dd851 (diff)
Cleanup: use array syntax for sizeof with fixed values
Also order sizeof(..) first to promote other values to size_t.
Diffstat (limited to 'source/blender/blenkernel/intern/pointcache.c')
-rw-r--r--source/blender/blenkernel/intern/pointcache.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index ae18f3289e4..64e642462af 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -126,19 +126,19 @@ static CLG_LogRef LOG = {"bke.pointcache"};
static int ptcache_data_size[] = {
sizeof(unsigned int), // BPHYS_DATA_INDEX
- 3 * sizeof(float), // BPHYS_DATA_LOCATION
- 3 * sizeof(float), // BPHYS_DATA_VELOCITY
- 4 * sizeof(float), // BPHYS_DATA_ROTATION
- 3 * sizeof(float), // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST
+ sizeof(float[3]), // BPHYS_DATA_LOCATION
+ sizeof(float[3]), // BPHYS_DATA_VELOCITY
+ sizeof(float[4]), // BPHYS_DATA_ROTATION
+ sizeof(float[3]), // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST
sizeof(float), // BPHYS_DATA_SIZE
- 3 * sizeof(float), // BPHYS_DATA_TIMES
+ sizeof(float[3]), // BPHYS_DATA_TIMES
sizeof(BoidData), // case BPHYS_DATA_BOIDS
};
static int ptcache_extra_datasize[] = {
0,
sizeof(ParticleSpring),
- sizeof(float) * 3,
+ sizeof(float[3]),
};
/* forward declarations */
@@ -212,8 +212,8 @@ static void ptcache_softbody_read(
BodyPoint *bp = soft->bpoint + index;
if (old_data) {
- memcpy(bp->pos, data, 3 * sizeof(float));
- memcpy(bp->vec, data + 3, 3 * sizeof(float));
+ memcpy(bp->pos, data, sizeof(float[3]));
+ memcpy(bp->vec, data + 3, sizeof(float[3]));
}
else {
PTCACHE_DATA_TO(data, BPHYS_DATA_LOCATION, 0, bp->pos);
@@ -241,8 +241,8 @@ static void ptcache_softbody_interpolate(int index,
copy_v3_v3(keys[1].vel, bp->vec);
if (old_data) {
- memcpy(keys[2].co, old_data, 3 * sizeof(float));
- memcpy(keys[2].vel, old_data + 3, 3 * sizeof(float));
+ memcpy(keys[2].co, old_data, sizeof(float[3]));
+ memcpy(keys[2].vel, old_data + 3, sizeof(float[3]));
}
else {
BKE_ptcache_make_particle_key(keys + 2, 0, data, cfra2);
@@ -545,9 +545,9 @@ static void ptcache_cloth_read(
ClothVertex *vert = cloth->verts + index;
if (old_data) {
- memcpy(vert->x, data, 3 * sizeof(float));
- memcpy(vert->xconst, data + 3, 3 * sizeof(float));
- memcpy(vert->v, data + 6, 3 * sizeof(float));
+ memcpy(vert->x, data, sizeof(float[3]));
+ memcpy(vert->xconst, data + 3, sizeof(float[3]));
+ memcpy(vert->v, data + 6, sizeof(float[3]));
}
else {
PTCACHE_DATA_TO(data, BPHYS_DATA_LOCATION, 0, vert->x);
@@ -577,8 +577,8 @@ static void ptcache_cloth_interpolate(int index,
copy_v3_v3(keys[1].vel, vert->v);
if (old_data) {
- memcpy(keys[2].co, old_data, 3 * sizeof(float));
- memcpy(keys[2].vel, old_data + 6, 3 * sizeof(float));
+ memcpy(keys[2].co, old_data, sizeof(float[3]));
+ memcpy(keys[2].vel, old_data + 6, sizeof(float[3]));
}
else {
BKE_ptcache_make_particle_key(keys + 2, 0, data, cfra2);
@@ -1421,7 +1421,7 @@ static int ptcache_dynamicpaint_write(PTCacheFile *pf, void *dp_v)
int cache_compress = 1;
/* version header */
- ptcache_file_write(pf, DPAINT_CACHE_VERSION, 1, sizeof(char) * 4);
+ ptcache_file_write(pf, DPAINT_CACHE_VERSION, 1, sizeof(char[4]));
if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ && surface->data) {
int total_points = surface->data->total_points;
@@ -1459,7 +1459,7 @@ static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v)
char version[4];
/* version header */
- ptcache_file_read(pf, version, 1, sizeof(char) * 4);
+ ptcache_file_read(pf, version, 1, sizeof(char[4]));
if (!STREQLEN(version, DPAINT_CACHE_VERSION, 4)) {
CLOG_ERROR(&LOG, "Dynamic Paint: Invalid cache version: '%c%c%c%c'!", UNPACK4(version));
return 0;
@@ -1538,8 +1538,8 @@ static void ptcache_rigidbody_read(
if (rbo->type == RBO_TYPE_ACTIVE) {
if (old_data) {
- memcpy(rbo->pos, data, 3 * sizeof(float));
- memcpy(rbo->orn, data + 3, 4 * sizeof(float));
+ memcpy(rbo->pos, data, sizeof(float[3]));
+ memcpy(rbo->orn, data + 3, sizeof(float[4]));
}
else {
PTCACHE_DATA_TO(data, BPHYS_DATA_LOCATION, 0, rbo->pos);
@@ -1577,8 +1577,8 @@ static void ptcache_rigidbody_interpolate(int index,
copy_qt_qt(keys[1].rot, rbo->orn);
if (old_data) {
- memcpy(keys[2].co, data, 3 * sizeof(float));
- memcpy(keys[2].rot, data + 3, 4 * sizeof(float));
+ memcpy(keys[2].co, data, sizeof(float[3]));
+ memcpy(keys[2].rot, data + 3, sizeof(float[4]));
}
else {
BKE_ptcache_make_particle_key(&keys[2], 0, data, cfra2);
@@ -2276,7 +2276,7 @@ static int ptcache_file_compressed_read(PTCacheFile *pf, unsigned char *result,
size_t out_len = len;
#endif
unsigned char *in;
- unsigned char *props = MEM_callocN(16 * sizeof(char), "tmp");
+ unsigned char *props = MEM_callocN(sizeof(char[16]), "tmp");
ptcache_file_read(pf, &compressed, 1, sizeof(unsigned char));
if (compressed) {
@@ -2322,7 +2322,7 @@ static int ptcache_file_compressed_write(
int r = 0;
unsigned char compressed = 0;
size_t out_len = 0;
- unsigned char *props = MEM_callocN(16 * sizeof(char), "tmp");
+ unsigned char *props = MEM_callocN(sizeof(char[16]), "tmp");
size_t sizeOfIt = 5;
(void)mode; /* unused when building w/o compression */
@@ -2623,13 +2623,13 @@ static void ptcache_mem_clear(PTCacheMem *pm)
static int ptcache_old_elemsize(PTCacheID *pid)
{
if (pid->type == PTCACHE_TYPE_SOFTBODY) {
- return 6 * sizeof(float);
+ return sizeof(float[6]);
}
if (pid->type == PTCACHE_TYPE_PARTICLES) {
return sizeof(ParticleKey);
}
if (pid->type == PTCACHE_TYPE_CLOTH) {
- return 9 * sizeof(float);
+ return sizeof(float[9]);
}
return 0;