36 #include "RNA_prototypes.h"
84 simulate_ocean_modifier(omd);
122 simulate_ocean_modifier(tomd);
159 typedef struct GenerateOceanGeometryData {
170 } GenerateOceanGeometryData;
172 static void generate_ocean_geometry_vertices(
void *__restrict userdata,
176 GenerateOceanGeometryData *gogd = userdata;
179 for (
x = 0;
x <= gogd->res_x;
x++) {
180 const int i =
y * (gogd->res_x + 1) +
x;
181 float *co = gogd->mverts[i].co;
182 co[0] = gogd->ox + (
x * gogd->sx);
183 co[1] = gogd->oy + (
y * gogd->sy);
188 static void generate_ocean_geometry_polygons(
void *__restrict userdata,
192 GenerateOceanGeometryData *gogd = userdata;
195 for (
x = 0;
x < gogd->res_x;
x++) {
196 const int fi =
y * gogd->res_x +
x;
197 const int vi =
y * (gogd->res_x + 1) +
x;
198 MPoly *mp = &gogd->mpolys[fi];
199 MLoop *ml = &gogd->mloops[fi * 4];
205 ml->
v = vi + 1 + gogd->res_x + 1;
207 ml->
v = vi + gogd->res_x + 1;
210 mp->loopstart = fi * 4;
217 static void generate_ocean_geometry_uvs(
void *__restrict userdata,
221 GenerateOceanGeometryData *gogd = userdata;
224 for (
x = 0;
x < gogd->res_x;
x++) {
225 const int i =
y * gogd->res_x +
x;
226 MLoopUV *luv = &gogd->mloopuvs[i * 4];
228 luv->
uv[0] =
x * gogd->ix;
229 luv->
uv[1] =
y * gogd->iy;
232 luv->
uv[0] = (
x + 1) * gogd->ix;
233 luv->
uv[1] =
y * gogd->iy;
236 luv->
uv[0] = (
x + 1) * gogd->ix;
237 luv->
uv[1] = (
y + 1) * gogd->iy;
240 luv->
uv[0] =
x * gogd->ix;
241 luv->
uv[1] = (
y + 1) * gogd->iy;
250 GenerateOceanGeometryData gogd;
255 const bool use_threading = resolution > 4;
257 gogd.rx = resolution * resolution;
258 gogd.ry = resolution * resolution;
259 gogd.res_x = gogd.rx * omd->
repeat_x;
260 gogd.res_y = gogd.ry * omd->
repeat_y;
262 verts_num = (gogd.res_x + 1) * (gogd.res_y + 1);
263 polys_num = gogd.res_x * gogd.res_y;
267 gogd.ox = -gogd.sx / 2.0f;
268 gogd.oy = -gogd.sy / 2.0f;
276 gogd.mverts =
result->mvert;
277 gogd.mpolys =
result->mpoly;
278 gogd.mloops =
result->mloop;
298 gogd.ix = 1.0 / gogd.rx;
299 gogd.iy = 1.0 / gogd.ry;
317 bool allocated_ocean =
false;
334 #
define OCEAN_CO(_size_co_inv, _v) ((_v * _size_co_inv) + 0.5f)
344 if (omd->
cached ==
true) {
346 init_cache_data(ob, omd, resolution);
357 simulate_ocean_modifier(omd);
361 result = generate_ocean_geometry(omd,
mesh, resolution);
367 cfra_for_cache = cfra_scene;
376 const int polys_num =
result->totpoly;
377 const int loops_num =
result->totloop;
392 for (i = 0, mp = mpolys; i < polys_num; i++, mp++) {
398 mlcolspray = &mloopcols_spray[mp->
loopstart];
401 for (j = mp->
totloop; j--; ml++, mlcol++) {
402 const float *vco = mverts[ml->
v].co;
403 const float u = OCEAN_CO(size_co_inv, vco[0]);
404 const float v = OCEAN_CO(size_co_inv, vco[1]);
410 CLAMP(foam, 0.0f, 1.0f);
417 mlcol->
r = mlcol->
g = mlcol->
b = (char)(foam * 255);
423 mlcolspray->
r = ocr.
Eminus[0] * 255;
426 mlcolspray->
r = ocr.
Eplus[0] * 255;
430 mlcolspray->
b = ocr.
Eminus[2] * 255;
433 mlcolspray->
b = ocr.
Eplus[2] * 255;
447 const int verts_num =
result->totvert;
449 for (i = 0; i < verts_num; i++) {
450 float *vco = mverts[i].co;
451 const float u = OCEAN_CO(size_co_inv, vco[0]);
452 const float v = OCEAN_CO(size_co_inv, vco[1]);
461 vco[2] += ocr.
disp[1];
464 vco[0] += ocr.
disp[0];
465 vco[1] += ocr.
disp[2];
472 if (allocated_ocean) {
513 uiItemR(sub,
ptr,
"viewport_resolution", 0,
IFACE_(
"Resolution Viewport"), ICON_NONE);
529 uiItemL(layout,
TIP_(
"Built without Ocean modifier"), ICON_NONE);
651 "OBJECT_OT_ocean_bake",
661 uiItemO(layout,
NULL, ICON_NONE,
"OBJECT_OT_ocean_bake");
683 region_type,
"foam",
"", foam_panel_draw_header, foam_panel_draw, panel_type);
685 region_type,
"spray",
"", spray_panel_draw_header, spray_panel_draw, foam_panel);
687 region_type,
"spectrum",
"Spectrum",
NULL, spectrum_panel_draw, panel_type);
int CustomData_number_of_layers(const struct CustomData *data, int type)
void * CustomData_add_layer_named(struct CustomData *data, int type, eCDAllocType alloctype, void *layer, int totelem, const char *name)
void * CustomData_add_layer(struct CustomData *data, int type, eCDAllocType alloctype, void *layer, int totelem)
struct ID * BKE_id_copy_ex(struct Main *bmain, const struct ID *id, struct ID **r_newid, int flag)
void BKE_mesh_copy_parameters_for_eval(struct Mesh *me_dst, const struct Mesh *me_src)
struct Mesh * BKE_mesh_new_nomain(int verts_len, int edges_len, int tessface_len, int loops_len, int polys_len)
void BKE_mesh_tag_coords_changed(struct Mesh *mesh)
void BKE_mesh_calc_edges(struct Mesh *mesh, bool keep_existing_edges, bool select_new_edges)
void BKE_modifier_path_init(char *path, int path_maxlen, const char *name)
@ eModifierTypeFlag_EnableInEditmode
@ eModifierTypeFlag_SupportsEditmode
@ eModifierTypeFlag_AcceptsMesh
void BKE_modifier_copydata_generic(const struct ModifierData *md, struct ModifierData *md_dst, int flag)
const char * BKE_modifier_path_relbase_from_global(struct Object *ob)
@ eModifierTypeType_Constructive
void BKE_modifier_set_error(const struct Object *ob, struct ModifierData *md, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_ocean_cache_eval_uv(struct OceanCache *och, struct OceanResult *ocr, int f, float u, float v)
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)
void BKE_ocean_simulate(struct Ocean *o, float t, float scale, float chop_amount)
float BKE_ocean_jminus_to_foam(float jminus, float coverage)
bool BKE_ocean_ensure(struct OceanModifierData *omd, int resolution)
void BKE_ocean_free_cache(struct OceanCache *och)
void BKE_ocean_simulate_cache(struct OceanCache *och, int frame)
struct Ocean * BKE_ocean_add(void)
void BKE_ocean_eval_uv(struct Ocean *oc, struct OceanResult *ocr, float u, float v)
bool BKE_ocean_init_from_modifier(struct Ocean *ocean, struct OceanModifierData const *omd, int resolution)
void BKE_ocean_free(struct Ocean *oc)
bool BKE_ocean_is_valid(const struct Ocean *o)
void BLI_task_parallel_range(int start, int stop, void *userdata, TaskParallelRangeFunc func, const TaskParallelSettings *settings)
BLI_INLINE void BLI_parallel_range_settings_defaults(TaskParallelSettings *settings)
#define MEMCMP_STRUCT_AFTER_IS_ZERO(struct_var, member)
#define MEMCPY_STRUCT_AFTER(struct_dst, struct_src, member)
float DEG_get_ctime(const Depsgraph *graph)
#define DNA_struct_default_get(struct_name)
@ MOD_OCEAN_GEOM_GENERATE
@ MOD_OCEAN_GEOM_DISPLACE
@ MOD_OCEAN_SPECTRUM_TEXEL_MARSEN_ARSLOE
@ MOD_OCEAN_SPECTRUM_JONSWAP
@ MOD_OCEAN_GENERATE_FOAM
@ MOD_OCEAN_GENERATE_SPRAY
struct OceanModifierData OceanModifierData
Object is a sort of wrapper for general info.
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
static void bake_panel_draw(const bContext *UNUSED(C), Panel *panel)
static void blendRead(BlendDataReader *UNUSED(reader), ModifierData *md)
static void copyData(const ModifierData *md, ModifierData *target, const int flag)
static Mesh * modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
static void requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md), CustomData_MeshMasks *UNUSED(r_cddata_masks))
static bool dependsOnNormals(ModifierData *md)
ModifierTypeInfo modifierType_Ocean
static Mesh * doOcean(ModifierData *UNUSED(md), const ModifierEvalContext *UNUSED(ctx), Mesh *mesh)
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
static void initData(ModifierData *md)
static void panelRegister(ARegionType *region_type)
static void freeData(ModifierData *md)
PointerRNA * modifier_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr)
void modifier_panel_end(uiLayout *layout, PointerRNA *ptr)
PanelType * modifier_panel_register(ARegionType *region_type, ModifierType type, PanelDrawFn draw)
PanelType * modifier_subpanel_register(ARegionType *region_type, const char *name, const char *label, PanelDrawFn draw_header, PanelDrawFn draw, PanelType *parent)
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position CLAMP
void uiLayoutSetActive(uiLayout *layout, bool active)
void uiLayoutSetEnabled(uiLayout *layout, bool enabled)
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
void uiItemL(uiLayout *layout, const char *name, int icon)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
void uiItemS(uiLayout *layout)
uiLayout * uiLayoutRow(uiLayout *layout, bool align)
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname)
void uiItemFullO(uiLayout *layout, const char *opname, const char *name, int icon, struct IDProperty *properties, wmOperatorCallContext context, int flag, struct PointerRNA *r_opptr)
ATTR_WARN_UNUSED_RESULT const BMVert * v
SyclQueue void void size_t num_bytes void
define("MAT_AOV_SUPPORT") .image_array_out(6
ccl_gpu_kernel_postfix ccl_global float int int sy
ccl_gpu_kernel_postfix ccl_global float int sx
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
float RNA_float_get(PointerRNA *ptr, const char *name)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
int RNA_enum_get(PointerRNA *ptr, const char *name)
struct Depsgraph * depsgraph
struct OceanCache * oceancache