I’m fighting with the ‘create diff’ tool. I have a local diff that I created, isolated to the change pinning the spectra to the surface (allowing for the resolution to be changed without the surface fundamentally changing). The ‘create diff’ tool whines that :
Unhandled Exception ("AphrontQueryException")
#1048: Column 'filename' cannot be null
for reasons that I don’t understand. Diff is
diff --git "a/e:\\ocean.c" "b/blender\\source\\blender\\blenkernel\\intern\\ocean.c"
index 9faa61f..5c96258 100644
--- "a/e:\\ocean.c"
+++ "b/blender\\source\\blender\\blenkernel\\intern\\ocean.c"
@@ -812,6 +812,38 @@ void BKE_ocean_simulate(struct Ocean *o, float t, float scale, float chop_amount
BLI_task_pool_free(pool);
}
+unsigned int generateUID(float xCoord, float zCoord)
+{
+ // a very simple hash function. should probably do a better one at some point
+ register float angle;
+ register float length;
+ register float coordSq;
+ register float id_out;
+ unsigned int returnVal = 1;
+
+ if (zCoord != 0.0f && xCoord != 0.0f) {
+ coordSq = zCoord * zCoord + xCoord * xCoord;
+ length = sqrt(coordSq);
+ angle = xCoord / length;
+ angle = acos(angle);
+ angle *= 57.295779513082320876798154814105f; // RadsToDegs(angle);
+
+ if (angle > 180.0f)
+ angle = 360.0f - angle;
+
+ id_out = coordSq + (length * angle) + 0.5f;
+
+ if (angle == 0.0f)
+ returnVal = (unsigned int)coordSq;
+ else if (zCoord <= 0.0f)
+ returnVal = (unsigned int)floor(id_out);
+ else
+ returnVal = INT_MAX - (unsigned int)floor(id_out);
+ }
+ return returnVal;
+}
+
+
static void set_height_normalize_factor(struct Ocean *oc)
{
float res = 1.0;
@@ -986,10 +1018,13 @@ void BKE_ocean_init(struct Ocean *o,
}
/*srand(seed);*/
- rng = BLI_rng_new(seed);
-
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 + generateUID(o->_kx[i], o->_kz[j]);
+
+ rng = BLI_rng_new(new_seed);
float r1 = gaussRand(rng);
float r2 = gaussRand(rng);