Fix ocean modifier giving different result on Arm than x86

And re-enable the test on macOS Arm.

Ref T78710
This commit is contained in:
Brecht Van Lommel 2021-05-18 14:02:41 +02:00
parent 53376ec7fc
commit b158477551
Notes: blender-bot 2023-02-14 07:53:51 +01:00
Referenced by issue #78710, macOS: Support arm64
2 changed files with 14 additions and 13 deletions

View File

@ -911,8 +911,12 @@ void BKE_ocean_init(struct Ocean *o,
for (i = 0; i < o->_M; i++) {
for (j = 0; j < o->_N; j++) {
/* This ensures we get a value tied to the surface location, avoiding dramatic surface
* change with changing resolution. */
int new_seed = seed + BLI_hash_int_2d(o->_kx[i] * 360.0f, o->_kz[j] * 360.0f);
* change with changing resolution.
* Explicitly cast to signed int first to ensure consistent behavior on all processors,
* since behavior of float to unsigned int cast is undefined in C. */
const int hash_x = o->_kx[i] * 360.0f;
const int hash_z = o->_kz[j] * 360.0f;
int new_seed = seed + BLI_hash_int_2d(hash_x, hash_z);
BLI_rng_seed(rng, new_seed);
float r1 = gaussRand(rng);

View File

@ -240,17 +240,14 @@ add_blender_test(
--run-all-tests
)
# disabled on macOS arm64 until updated & working
if(NOT (APPLE AND ("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "arm64")))
if(WITH_MOD_OCEANSIM)
add_blender_test(
physics_ocean
${TEST_SRC_DIR}/physics/ocean_test.blend
--python ${TEST_PYTHON_DIR}/physics_ocean.py
--
--run-all-tests
)
endif()
if(WITH_MOD_OCEANSIM)
add_blender_test(
physics_ocean
${TEST_SRC_DIR}/physics/ocean_test.blend
--python ${TEST_PYTHON_DIR}/physics_ocean.py
--
--run-all-tests
)
endif()