Cleanup: use BKE_ocean_* prefix

This commit is contained in:
Campbell Barton 2015-04-04 15:18:52 +11:00
parent 7acd69958b
commit 12cede5ca3
4 changed files with 52 additions and 50 deletions

@ -74,13 +74,14 @@ typedef struct OceanCache {
#define OCEAN_CACHING 1 #define OCEAN_CACHING 1
#define OCEAN_CACHED 2 #define OCEAN_CACHED 2
struct Ocean *BKE_add_ocean(void); struct Ocean *BKE_ocean_add(void);
void BKE_free_ocean_data(struct Ocean *oc); void BKE_ocean_free_data(struct Ocean *oc);
void BKE_free_ocean(struct Ocean *oc); void BKE_ocean_free(struct Ocean *oc);
void BKE_init_ocean(struct Ocean *o, int M, int N, float Lx, float Lz, float V, float l, float A, float w, float damp, 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); float alignment, float depth, float time, short do_height_field, short do_chop, short do_normals, short do_jacobian, int seed);
void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount); void BKE_ocean_simulate(struct Ocean *o, float t, float scale, float chop_amount);
/* sampling the ocean surface */ /* sampling the ocean surface */
float BKE_ocean_jminus_to_foam(float jminus, float coverage); float BKE_ocean_jminus_to_foam(float jminus, float coverage);
@ -92,16 +93,17 @@ void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i, int j)
/* ocean cache handling */ /* ocean cache handling */
struct OceanCache *BKE_init_ocean_cache(const char *bakepath, const char *relbase, struct OceanCache *BKE_ocean_init_cache(
const char *bakepath, const char *relbase,
int start, int end, float wave_scale, int start, int end, float wave_scale,
float chop_amount, float foam_coverage, float foam_fade, int resolution); float chop_amount, float foam_coverage, float foam_fade, int resolution);
void BKE_simulate_ocean_cache(struct OceanCache *och, int frame); void BKE_ocean_simulate_cache(struct OceanCache *och, int frame);
void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(void *, float progress, int *cancel), void *update_cb_data); void BKE_ocean_bake(struct Ocean *o, struct OceanCache *och, void (*update_cb)(void *, float progress, int *cancel), void *update_cb_data);
void BKE_ocean_cache_eval_uv(struct OceanCache *och, struct OceanResult *ocr, int f, float u, float v); void BKE_ocean_cache_eval_uv(struct OceanCache *och, struct OceanResult *ocr, int f, float u, float v);
void BKE_ocean_cache_eval_ij(struct OceanCache *och, struct OceanResult *ocr, int f, int i, int j); void BKE_ocean_cache_eval_ij(struct OceanCache *och, struct OceanResult *ocr, int f, int i, int j);
void BKE_free_ocean_cache(struct OceanCache *och); void BKE_ocean_free_cache(struct OceanCache *och);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

@ -494,7 +494,7 @@ void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i, int j)
BLI_rw_mutex_unlock(&oc->oceanmutex); BLI_rw_mutex_unlock(&oc->oceanmutex);
} }
void BKE_simulate_ocean(struct Ocean *o, float t, float scale, float chop_amount) void BKE_ocean_simulate(struct Ocean *o, float t, float scale, float chop_amount)
{ {
int i, j; int i, j;
@ -732,7 +732,7 @@ static void set_height_normalize_factor(struct Ocean *oc)
oc->normalize_factor = 1.0; oc->normalize_factor = 1.0;
BKE_simulate_ocean(oc, 0.0, 1.0, 0); BKE_ocean_simulate(oc, 0.0, 1.0, 0);
BLI_rw_mutex_lock(&oc->oceanmutex, THREAD_LOCK_READ); BLI_rw_mutex_lock(&oc->oceanmutex, THREAD_LOCK_READ);
@ -754,7 +754,7 @@ static void set_height_normalize_factor(struct Ocean *oc)
oc->normalize_factor = res; oc->normalize_factor = res;
} }
struct Ocean *BKE_add_ocean(void) struct Ocean *BKE_ocean_add(void)
{ {
Ocean *oc = MEM_callocN(sizeof(Ocean), "ocean sim data"); Ocean *oc = MEM_callocN(sizeof(Ocean), "ocean sim data");
@ -763,7 +763,7 @@ struct Ocean *BKE_add_ocean(void)
return oc; return oc;
} }
void BKE_init_ocean(struct Ocean *o, int M, int N, float Lx, float Lz, float V, float l, float A, float w, float damp, 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, float alignment, float depth, float time, short do_height_field, short do_chop, short do_normals,
short do_jacobian, int seed) short do_jacobian, int seed)
{ {
@ -900,7 +900,7 @@ void BKE_init_ocean(struct Ocean *o, int M, int N, float Lx, float Lz, float V,
BLI_rng_free(rng); BLI_rng_free(rng);
} }
void BKE_free_ocean_data(struct Ocean *oc) void BKE_ocean_free_data(struct Ocean *oc)
{ {
if (!oc) return; if (!oc) return;
@ -962,11 +962,11 @@ void BKE_free_ocean_data(struct Ocean *oc)
BLI_rw_mutex_unlock(&oc->oceanmutex); BLI_rw_mutex_unlock(&oc->oceanmutex);
} }
void BKE_free_ocean(struct Ocean *oc) void BKE_ocean_free(struct Ocean *oc)
{ {
if (!oc) return; if (!oc) return;
BKE_free_ocean_data(oc); BKE_ocean_free_data(oc);
BLI_rw_mutex_end(&oc->oceanmutex); BLI_rw_mutex_end(&oc->oceanmutex);
MEM_freeN(oc); MEM_freeN(oc);
@ -1021,7 +1021,7 @@ MINLINE void value_to_rgba_unit_alpha(float r_rgba[4], const float value)
r_rgba[3] = 1.0f; r_rgba[3] = 1.0f;
} }
void BKE_free_ocean_cache(struct OceanCache *och) void BKE_ocean_free_cache(struct OceanCache *och)
{ {
int i, f = 0; int i, f = 0;
@ -1111,7 +1111,7 @@ void BKE_ocean_cache_eval_ij(struct OceanCache *och, struct OceanResult *ocr, in
} }
} }
struct OceanCache *BKE_init_ocean_cache(const char *bakepath, const char *relbase, int start, int end, float wave_scale, struct OceanCache *BKE_ocean_init_cache(const char *bakepath, const char *relbase, int start, int end, float wave_scale,
float chop_amount, float foam_coverage, float foam_fade, int resolution) float chop_amount, float foam_coverage, float foam_fade, int resolution)
{ {
OceanCache *och = MEM_callocN(sizeof(OceanCache), "ocean cache data"); OceanCache *och = MEM_callocN(sizeof(OceanCache), "ocean cache data");
@ -1138,7 +1138,7 @@ struct OceanCache *BKE_init_ocean_cache(const char *bakepath, const char *relbas
return och; return och;
} }
void BKE_simulate_ocean_cache(struct OceanCache *och, int frame) void BKE_ocean_simulate_cache(struct OceanCache *och, int frame)
{ {
char string[FILE_MAX]; char string[FILE_MAX];
int f = frame; int f = frame;
@ -1182,7 +1182,7 @@ void BKE_simulate_ocean_cache(struct OceanCache *och, int frame)
} }
void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(void *, float progress, int *cancel), void BKE_ocean_bake(struct Ocean *o, struct OceanCache *och, void (*update_cb)(void *, float progress, int *cancel),
void *update_cb_data) void *update_cb_data)
{ {
/* note: some of these values remain uninitialized unless certain options /* note: some of these values remain uninitialized unless certain options
@ -1221,7 +1221,7 @@ void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(v
ibuf_disp = IMB_allocImBuf(res_x, res_y, 32, IB_rectfloat); ibuf_disp = IMB_allocImBuf(res_x, res_y, 32, IB_rectfloat);
ibuf_normal = IMB_allocImBuf(res_x, res_y, 32, IB_rectfloat); ibuf_normal = IMB_allocImBuf(res_x, res_y, 32, IB_rectfloat);
BKE_simulate_ocean(o, och->time[i], och->wave_scale, och->chop_amount); BKE_ocean_simulate(o, och->time[i], och->wave_scale, och->chop_amount);
/* add new foam */ /* add new foam */
for (y = 0; y < res_y; y++) { for (y = 0; y < res_y; y++) {
@ -1371,29 +1371,29 @@ void BKE_ocean_eval_ij(struct Ocean *UNUSED(oc), struct OceanResult *UNUSED(ocr)
{ {
} }
void BKE_simulate_ocean(struct Ocean *UNUSED(o), float UNUSED(t), float UNUSED(scale), float UNUSED(chop_amount)) void BKE_ocean_simulate(struct Ocean *UNUSED(o), float UNUSED(t), float UNUSED(scale), float UNUSED(chop_amount))
{ {
} }
struct Ocean *BKE_add_ocean(void) struct Ocean *BKE_ocean_add(void)
{ {
Ocean *oc = MEM_callocN(sizeof(Ocean), "ocean sim data"); Ocean *oc = MEM_callocN(sizeof(Ocean), "ocean sim data");
return oc; return oc;
} }
void BKE_init_ocean(struct Ocean *UNUSED(o), int UNUSED(M), int UNUSED(N), float UNUSED(Lx), float UNUSED(Lz), void BKE_ocean_init(struct Ocean *UNUSED(o), int UNUSED(M), int UNUSED(N), float UNUSED(Lx), float UNUSED(Lz),
float UNUSED(V), float UNUSED(l), float UNUSED(A), float UNUSED(w), float UNUSED(damp), float UNUSED(V), float UNUSED(l), float UNUSED(A), float UNUSED(w), float UNUSED(damp),
float UNUSED(alignment), float UNUSED(depth), float UNUSED(time), short UNUSED(do_height_field), float UNUSED(alignment), float UNUSED(depth), float UNUSED(time), short UNUSED(do_height_field),
short UNUSED(do_chop), short UNUSED(do_normals), short UNUSED(do_jacobian), int UNUSED(seed)) short UNUSED(do_chop), short UNUSED(do_normals), short UNUSED(do_jacobian), int UNUSED(seed))
{ {
} }
void BKE_free_ocean_data(struct Ocean *UNUSED(oc)) void BKE_ocean_free_data(struct Ocean *UNUSED(oc))
{ {
} }
void BKE_free_ocean(struct Ocean *oc) void BKE_ocean_free(struct Ocean *oc)
{ {
if (!oc) return; if (!oc) return;
MEM_freeN(oc); MEM_freeN(oc);
@ -1403,7 +1403,7 @@ void BKE_free_ocean(struct Ocean *oc)
/* ********* Baking/Caching ********* */ /* ********* Baking/Caching ********* */
void BKE_free_ocean_cache(struct OceanCache *och) void BKE_ocean_free_cache(struct OceanCache *och)
{ {
if (!och) return; if (!och) return;
@ -1420,7 +1420,7 @@ void BKE_ocean_cache_eval_ij(struct OceanCache *UNUSED(och), struct OceanResult
{ {
} }
OceanCache *BKE_init_ocean_cache(const char *UNUSED(bakepath), const char *UNUSED(relbase), int UNUSED(start), OceanCache *BKE_ocean_init_cache(const char *UNUSED(bakepath), const char *UNUSED(relbase), int UNUSED(start),
int UNUSED(end), float UNUSED(wave_scale), float UNUSED(chop_amount), int UNUSED(end), float UNUSED(wave_scale), float UNUSED(chop_amount),
float UNUSED(foam_coverage), float UNUSED(foam_fade), int UNUSED(resolution)) float UNUSED(foam_coverage), float UNUSED(foam_fade), int UNUSED(resolution))
{ {
@ -1429,11 +1429,11 @@ OceanCache *BKE_init_ocean_cache(const char *UNUSED(bakepath), const char *UNUSE
return och; return och;
} }
void BKE_simulate_ocean_cache(struct OceanCache *UNUSED(och), int UNUSED(frame)) void BKE_ocean_simulate_cache(struct OceanCache *UNUSED(och), int UNUSED(frame))
{ {
} }
void BKE_bake_ocean(struct Ocean *UNUSED(o), struct OceanCache *UNUSED(och), void BKE_ocean_bake(struct Ocean *UNUSED(o), struct OceanCache *UNUSED(och),
void (*update_cb)(void *, float progress, int *cancel), void *UNUSED(update_cb_data)) void (*update_cb)(void *, float progress, int *cancel), void *UNUSED(update_cb_data))
{ {
/* unused */ /* unused */

@ -2045,7 +2045,7 @@ static void init_ocean_modifier_bake(struct Ocean *oc, struct OceanModifierData
do_normals = (omd->flag & MOD_OCEAN_GENERATE_NORMALS); do_normals = (omd->flag & MOD_OCEAN_GENERATE_NORMALS);
do_jacobian = (omd->flag & MOD_OCEAN_GENERATE_FOAM); do_jacobian = (omd->flag & MOD_OCEAN_GENERATE_FOAM);
BKE_init_ocean(oc, omd->resolution * omd->resolution, omd->resolution * omd->resolution, omd->spatial_size, omd->spatial_size, 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->wind_velocity, omd->smallest_wave, 1.0, omd->wave_direction, omd->damp, omd->wave_alignment,
omd->depth, omd->time, omd->depth, omd->time,
do_heightfield, do_chop, do_normals, do_jacobian, do_heightfield, do_chop, do_normals, do_jacobian,
@ -2103,7 +2103,7 @@ static void oceanbake_startjob(void *customdata, short *stop, short *do_update,
G.is_break = false; /* XXX shared with render - replace with job 'stop' switch */ G.is_break = false; /* XXX shared with render - replace with job 'stop' switch */
BKE_bake_ocean(oj->ocean, oj->och, oceanbake_update, (void *)oj); BKE_ocean_bake(oj->ocean, oj->och, oceanbake_update, (void *)oj);
*do_update = true; *do_update = true;
*stop = 0; *stop = 0;
@ -2114,7 +2114,7 @@ static void oceanbake_endjob(void *customdata)
OceanBakeJob *oj = customdata; OceanBakeJob *oj = customdata;
if (oj->ocean) { if (oj->ocean) {
BKE_free_ocean(oj->ocean); BKE_ocean_free(oj->ocean);
oj->ocean = NULL; oj->ocean = NULL;
} }
@ -2145,7 +2145,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
} }
och = BKE_init_ocean_cache(omd->cachepath, modifier_path_relbase(ob), och = BKE_ocean_init_cache(omd->cachepath, modifier_path_relbase(ob),
omd->bakestart, omd->bakeend, omd->wave_scale, omd->bakestart, omd->bakeend, omd->wave_scale,
omd->chop_amount, omd->foam_coverage, omd->foam_fade, omd->resolution); omd->chop_amount, omd->foam_coverage, omd->foam_fade, omd->resolution);
@ -2179,11 +2179,11 @@ static int ocean_bake_exec(bContext *C, wmOperator *op)
} }
/* make a copy of ocean to use for baking - threadsafety */ /* make a copy of ocean to use for baking - threadsafety */
ocean = BKE_add_ocean(); ocean = BKE_ocean_add();
init_ocean_modifier_bake(ocean, omd); init_ocean_modifier_bake(ocean, omd);
#if 0 #if 0
BKE_bake_ocean(ocean, och); BKE_ocean_bake(ocean, och);
omd->oceancache = och; omd->oceancache = och;
omd->cached = true; omd->cached = true;

@ -48,14 +48,14 @@ static void init_cache_data(Object *ob, struct OceanModifierData *omd)
{ {
const char *relbase = modifier_path_relbase(ob); const char *relbase = modifier_path_relbase(ob);
omd->oceancache = BKE_init_ocean_cache(omd->cachepath, relbase, omd->oceancache = BKE_ocean_init_cache(omd->cachepath, relbase,
omd->bakestart, omd->bakeend, omd->wave_scale, omd->bakestart, omd->bakeend, omd->wave_scale,
omd->chop_amount, omd->foam_coverage, omd->foam_fade, omd->resolution); omd->chop_amount, omd->foam_coverage, omd->foam_fade, omd->resolution);
} }
static void clear_cache_data(struct OceanModifierData *omd) static void clear_cache_data(struct OceanModifierData *omd)
{ {
BKE_free_ocean_cache(omd->oceancache); BKE_ocean_free_cache(omd->oceancache);
omd->oceancache = NULL; omd->oceancache = NULL;
omd->cached = false; omd->cached = false;
} }
@ -72,8 +72,8 @@ static void init_ocean_modifier(struct OceanModifierData *omd)
do_normals = (omd->flag & MOD_OCEAN_GENERATE_NORMALS); do_normals = (omd->flag & MOD_OCEAN_GENERATE_NORMALS);
do_jacobian = (omd->flag & MOD_OCEAN_GENERATE_FOAM); do_jacobian = (omd->flag & MOD_OCEAN_GENERATE_FOAM);
BKE_free_ocean_data(omd->ocean); BKE_ocean_free_data(omd->ocean);
BKE_init_ocean(omd->ocean, omd->resolution * omd->resolution, omd->resolution * omd->resolution, BKE_ocean_init(omd->ocean, omd->resolution * omd->resolution, omd->resolution * omd->resolution,
omd->spatial_size, omd->spatial_size, omd->spatial_size, omd->spatial_size,
omd->wind_velocity, omd->smallest_wave, 1.0, omd->wave_direction, omd->damp, omd->wave_alignment, omd->wind_velocity, omd->smallest_wave, 1.0, omd->wave_direction, omd->damp, omd->wave_alignment,
omd->depth, omd->time, omd->depth, omd->time,
@ -85,7 +85,7 @@ static void simulate_ocean_modifier(struct OceanModifierData *omd)
{ {
if (!omd || !omd->ocean) return; if (!omd || !omd->ocean) return;
BKE_simulate_ocean(omd->ocean, omd->time, omd->wave_scale, omd->chop_amount); BKE_ocean_simulate(omd->ocean, omd->time, omd->wave_scale, omd->chop_amount);
} }
#endif /* WITH_OCEANSIM */ #endif /* WITH_OCEANSIM */
@ -133,7 +133,7 @@ static void initData(ModifierData *md)
omd->foam_fade = 0.98; omd->foam_fade = 0.98;
omd->foamlayername[0] = '\0'; /* layer name empty by default */ omd->foamlayername[0] = '\0'; /* layer name empty by default */
omd->ocean = BKE_add_ocean(); omd->ocean = BKE_ocean_add();
init_ocean_modifier(omd); init_ocean_modifier(omd);
simulate_ocean_modifier(omd); simulate_ocean_modifier(omd);
#else /* WITH_OCEANSIM */ #else /* WITH_OCEANSIM */
@ -147,9 +147,9 @@ static void freeData(ModifierData *md)
#ifdef WITH_OCEANSIM #ifdef WITH_OCEANSIM
OceanModifierData *omd = (OceanModifierData *) md; OceanModifierData *omd = (OceanModifierData *) md;
BKE_free_ocean(omd->ocean); BKE_ocean_free(omd->ocean);
if (omd->oceancache) if (omd->oceancache)
BKE_free_ocean_cache(omd->oceancache); BKE_ocean_free_cache(omd->oceancache);
#else /* WITH_OCEANSIM */ #else /* WITH_OCEANSIM */
/* unused */ /* unused */
(void)md; (void)md;
@ -195,7 +195,7 @@ static void copyData(ModifierData *md, ModifierData *target)
tomd->bakeend = omd->bakeend; tomd->bakeend = omd->bakeend;
tomd->oceancache = NULL; tomd->oceancache = NULL;
tomd->ocean = BKE_add_ocean(); tomd->ocean = BKE_ocean_add();
init_ocean_modifier(tomd); init_ocean_modifier(tomd);
simulate_ocean_modifier(tomd); simulate_ocean_modifier(tomd);
#else /* WITH_OCEANSIM */ #else /* WITH_OCEANSIM */
@ -426,7 +426,7 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob,
/* update modifier */ /* update modifier */
if (omd->refresh & MOD_OCEAN_REFRESH_ADD) if (omd->refresh & MOD_OCEAN_REFRESH_ADD)
omd->ocean = BKE_add_ocean(); omd->ocean = BKE_ocean_add();
if (omd->refresh & MOD_OCEAN_REFRESH_RESET) if (omd->refresh & MOD_OCEAN_REFRESH_RESET)
init_ocean_modifier(omd); init_ocean_modifier(omd);
if (omd->refresh & MOD_OCEAN_REFRESH_CLEAR_CACHE) if (omd->refresh & MOD_OCEAN_REFRESH_CLEAR_CACHE)
@ -437,7 +437,7 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob,
/* do ocean simulation */ /* do ocean simulation */
if (omd->cached == true) { if (omd->cached == true) {
if (!omd->oceancache) init_cache_data(ob, omd); if (!omd->oceancache) init_cache_data(ob, omd);
BKE_simulate_ocean_cache(omd->oceancache, md->scene->r.cfra); BKE_ocean_simulate_cache(omd->oceancache, md->scene->r.cfra);
} }
else { else {
simulate_ocean_modifier(omd); simulate_ocean_modifier(omd);