Ocean Modifier: removed duplicated code
Some code was copied with 'keep in sync with xxx' comments added to it.
This commit is contained in:
parent
de55ae56ae
commit
0c8452ad99
|
@ -74,6 +74,7 @@ typedef struct OceanCache {
|
|||
struct Ocean *BKE_ocean_add(void);
|
||||
void BKE_ocean_free_data(struct Ocean *oc);
|
||||
void BKE_ocean_free(struct Ocean *oc);
|
||||
void BKE_ocean_init_from_modifier(struct Ocean *ocean, struct OceanModifierData const *omd);
|
||||
|
||||
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,
|
||||
|
|
|
@ -836,6 +836,24 @@ struct Ocean *BKE_ocean_add(void)
|
|||
return oc;
|
||||
}
|
||||
|
||||
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)
|
||||
|
|
|
@ -2062,25 +2062,6 @@ static bool ocean_bake_poll(bContext *C)
|
|||
return edit_modifier_poll_generic(C, &RNA_OceanModifier, 0);
|
||||
}
|
||||
|
||||
/* copied from init_ocean_modifier, MOD_ocean.c */
|
||||
static void init_ocean_modifier_bake(struct Ocean *oc, struct OceanModifierData *omd)
|
||||
{
|
||||
int do_heightfield, do_chop, do_normals, do_jacobian;
|
||||
|
||||
if (!omd || !oc) return;
|
||||
|
||||
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_init(oc, 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);
|
||||
}
|
||||
|
||||
typedef struct OceanBakeJob {
|
||||
/* from wmJob */
|
||||
struct Object *owner;
|
||||
|
@ -2213,7 +2194,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
|
|||
|
||||
/* make a copy of ocean to use for baking - threadsafety */
|
||||
ocean = BKE_ocean_add();
|
||||
init_ocean_modifier_bake(ocean, omd);
|
||||
BKE_ocean_init_from_modifier(ocean, omd);
|
||||
|
||||
#if 0
|
||||
BKE_ocean_bake(ocean, och);
|
||||
|
|
|
@ -61,27 +61,6 @@ static void init_cache_data(Object *ob, struct OceanModifierData *omd)
|
|||
omd->chop_amount, omd->foam_coverage, omd->foam_fade, omd->resolution);
|
||||
}
|
||||
|
||||
/* keep in sync with init_ocean_modifier_bake(), object_modifier.c */
|
||||
static void init_ocean_modifier(struct OceanModifierData *omd)
|
||||
{
|
||||
int do_heightfield, do_chop, do_normals, do_jacobian;
|
||||
|
||||
if (!omd || !omd->ocean) return;
|
||||
|
||||
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(omd->ocean);
|
||||
BKE_ocean_init(omd->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);
|
||||
}
|
||||
|
||||
static void simulate_ocean_modifier(struct OceanModifierData *omd)
|
||||
{
|
||||
BKE_ocean_simulate(omd->ocean, omd->time, omd->wave_scale, omd->chop_amount);
|
||||
|
@ -131,7 +110,7 @@ static void initData(ModifierData *md)
|
|||
omd->foamlayername[0] = '\0'; /* layer name empty by default */
|
||||
|
||||
omd->ocean = BKE_ocean_add();
|
||||
init_ocean_modifier(omd);
|
||||
BKE_ocean_init_from_modifier(omd->ocean, omd);
|
||||
simulate_ocean_modifier(omd);
|
||||
#else /* WITH_OCEANSIM */
|
||||
/* unused */
|
||||
|
@ -168,7 +147,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
|
|||
tomd->oceancache = NULL;
|
||||
|
||||
tomd->ocean = BKE_ocean_add();
|
||||
init_ocean_modifier(tomd);
|
||||
BKE_ocean_init_from_modifier(tomd->ocean, tomd);
|
||||
simulate_ocean_modifier(tomd);
|
||||
#else /* WITH_OCEANSIM */
|
||||
/* unused */
|
||||
|
|
Loading…
Reference in New Issue