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:
Diffstat (limited to 'source/blender/blenkernel/intern/ocean.c')
-rw-r--r--source/blender/blenkernel/intern/ocean.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c
index 7f3f916964a..ab0130019b8 100644
--- a/source/blender/blenkernel/intern/ocean.c
+++ b/source/blender/blenkernel/intern/ocean.c
@@ -36,6 +36,7 @@
#include "MEM_guardedalloc.h"
+#include "DNA_modifier_types.h"
#include "DNA_scene_types.h"
#include "BLI_math.h"
@@ -835,6 +836,35 @@ struct Ocean *BKE_ocean_add(void)
return oc;
}
+bool BKE_ocean_ensure(struct OceanModifierData *omd)
+{
+ if (omd->ocean) {
+ return false;
+ }
+
+ omd->ocean = BKE_ocean_add();
+ BKE_ocean_init_from_modifier(omd->ocean, omd);
+ return true;
+}
+
+void BKE_ocean_init_from_modifier(struct Ocean *ocean, struct OceanModifierData const *omd)
+{
+ short do_heightfield, do_chop, do_normals, do_jacobian;
+
+ do_heightfield = true;
+ do_chop = (omd->chop_amount > 0);
+ do_normals = (omd->flag & MOD_OCEAN_GENERATE_NORMALS);
+ do_jacobian = (omd->flag & MOD_OCEAN_GENERATE_FOAM);
+
+ BKE_ocean_free_data(ocean);
+ BKE_ocean_init(ocean, omd->resolution * omd->resolution, omd->resolution * omd->resolution,
+ omd->spatial_size, omd->spatial_size,
+ omd->wind_velocity, omd->smallest_wave, 1.0, omd->wave_direction, omd->damp, omd->wave_alignment,
+ omd->depth, omd->time,
+ do_heightfield, do_chop, do_normals, do_jacobian,
+ omd->seed);
+}
+
void BKE_ocean_init(struct Ocean *o, int M, int N, float Lx, float Lz, float V, float l, float A, float w, float damp,
float alignment, float depth, float time, short do_height_field, short do_chop, short do_normals,
short do_jacobian, int seed)
@@ -1511,4 +1541,16 @@ void BKE_ocean_bake(struct Ocean *UNUSED(o), struct OceanCache *UNUSED(och),
/* unused */
(void)update_cb;
}
+
+void BKE_ocean_init_from_modifier(struct Ocean *UNUSED(ocean), struct OceanModifierData const *UNUSED(omd))
+{
+}
+
#endif /* WITH_OCEANSIM */
+
+void BKE_ocean_free_modifier_cache(struct OceanModifierData *omd)
+{
+ BKE_ocean_free_cache(omd->oceancache);
+ omd->oceancache = NULL;
+ omd->cached = false;
+}