From 36531006da83a7b82f008eb0df8227c492f68049 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 2 Feb 2025 13:56:46 +1100 Subject: [PATCH] Cleanup: use const pointer for the gravity vector --- source/blender/blenkernel/BKE_particle.h | 5 ++++- source/blender/blenkernel/intern/particle_system.cc | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index 9184c3228c8..7915c9704ab 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -89,7 +89,10 @@ typedef struct SPHData { ParticleData *pa; float mass; std::optional> eh; - float *gravity; + + /** The gravity as a `float[3]`, may also be null when the simulation doesn't use gravity. */ + const float *gravity; + float hfac; /* Average distance to neighbors (other particles in the support domain), * for calculating the Courant number (adaptive time step). */ diff --git a/source/blender/blenkernel/intern/particle_system.cc b/source/blender/blenkernel/intern/particle_system.cc index dd65ef00ad6..3dfe805070f 100644 --- a/source/blender/blenkernel/intern/particle_system.cc +++ b/source/blender/blenkernel/intern/particle_system.cc @@ -1795,7 +1795,7 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa ParticleSpring *spring = nullptr; SPHRangeData pfr; SPHNeighbor *pfn; - float *gravity = sphdata->gravity; + const float *gravity = sphdata->gravity; const std::optional> &springhash = sphdata->eh; float q, u, rij, dv[3]; @@ -1996,7 +1996,7 @@ static void sphclassical_force_cb(void *sphdata_v, SPHFluidSettings *fluid = psys[0]->part->fluid; SPHRangeData pfr; SPHNeighbor *pfn; - float *gravity = sphdata->gravity; + const float *gravity = sphdata->gravity; float dq, u, rij, dv[3]; float pressure, npressure;