2013-02-12 05:09:35 +00:00
|
|
|
/*
|
2011-11-13 12:17:27 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) Blender Foundation
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup modifiers
|
2013-02-12 05:09:35 +00:00
|
|
|
*/
|
|
|
|
|
2019-02-25 11:39:14 +01:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
|
|
#include "BLI_math.h"
|
|
|
|
#include "BLI_math_inline.h"
|
|
|
|
#include "BLI_task.h"
|
|
|
|
|
2020-06-05 10:41:03 -04:00
|
|
|
#include "BLT_translation.h"
|
|
|
|
|
2011-11-13 12:17:27 +00:00
|
|
|
#include "DNA_customdata_types.h"
|
2020-10-01 09:38:00 -05:00
|
|
|
#include "DNA_defaults.h"
|
2018-07-05 15:30:00 +02:00
|
|
|
#include "DNA_mesh_types.h"
|
2011-11-13 12:17:27 +00:00
|
|
|
#include "DNA_meshdata_types.h"
|
|
|
|
#include "DNA_modifier_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_object_types.h"
|
2011-11-13 12:17:27 +00:00
|
|
|
#include "DNA_scene_types.h"
|
2020-06-05 10:41:03 -04:00
|
|
|
#include "DNA_screen_types.h"
|
2011-11-13 12:17:27 +00:00
|
|
|
|
2020-06-05 10:41:03 -04:00
|
|
|
#include "BKE_context.h"
|
2020-02-10 12:58:59 +01:00
|
|
|
#include "BKE_lib_id.h"
|
2018-07-05 15:30:00 +02:00
|
|
|
#include "BKE_mesh.h"
|
2012-10-30 19:20:17 +00:00
|
|
|
#include "BKE_modifier.h"
|
|
|
|
#include "BKE_ocean.h"
|
2020-06-05 10:41:03 -04:00
|
|
|
#include "BKE_screen.h"
|
|
|
|
|
|
|
|
#include "UI_interface.h"
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
2020-06-23 17:25:44 +02:00
|
|
|
#include "BLO_read_write.h"
|
|
|
|
|
2020-06-05 10:41:03 -04:00
|
|
|
#include "WM_types.h" /* For UI free bake operator. */
|
2012-10-30 19:20:17 +00:00
|
|
|
|
2018-06-22 15:03:42 +02:00
|
|
|
#include "DEG_depsgraph_query.h"
|
|
|
|
|
2017-08-01 09:06:34 +10:00
|
|
|
#include "MOD_modifiertypes.h"
|
2020-06-05 10:41:03 -04:00
|
|
|
#include "MOD_ui_common.h"
|
2017-08-01 09:06:34 +10:00
|
|
|
|
2011-11-13 12:17:27 +00:00
|
|
|
#ifdef WITH_OCEANSIM
|
2020-08-03 10:08:31 -04:00
|
|
|
static void init_cache_data(Object *ob, struct OceanModifierData *omd, const int resolution)
|
2011-11-13 12:17:27 +00:00
|
|
|
{
|
2020-05-08 10:14:02 +02:00
|
|
|
const char *relbase = BKE_modifier_path_relbase_from_global(ob);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-04 15:18:52 +11:00
|
|
|
omd->oceancache = BKE_ocean_init_cache(omd->cachepath,
|
|
|
|
relbase,
|
2011-11-20 14:38:11 +00:00
|
|
|
omd->bakestart,
|
|
|
|
omd->bakeend,
|
|
|
|
omd->wave_scale,
|
|
|
|
omd->chop_amount,
|
|
|
|
omd->foam_coverage,
|
|
|
|
omd->foam_fade,
|
2020-08-03 10:08:31 -04:00
|
|
|
resolution);
|
2011-11-13 12:17:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void simulate_ocean_modifier(struct OceanModifierData *omd)
|
|
|
|
{
|
2015-04-04 15:18:52 +11:00
|
|
|
BKE_ocean_simulate(omd->ocean, omd->time, omd->wave_scale, omd->chop_amount);
|
2011-11-13 12:17:27 +00:00
|
|
|
}
|
2011-11-22 18:03:33 +00:00
|
|
|
#endif /* WITH_OCEANSIM */
|
2011-11-13 12:17:27 +00:00
|
|
|
|
|
|
|
/* Modifier Code */
|
|
|
|
|
|
|
|
static void initData(ModifierData *md)
|
|
|
|
{
|
|
|
|
#ifdef WITH_OCEANSIM
|
2012-05-06 13:38:33 +00:00
|
|
|
OceanModifierData *omd = (OceanModifierData *)md;
|
2011-11-13 16:10:01 +00:00
|
|
|
|
2020-10-01 09:38:00 -05:00
|
|
|
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(omd, modifier));
|
2020-08-03 10:08:31 -04:00
|
|
|
|
2020-10-01 09:38:00 -05:00
|
|
|
MEMCPY_STRUCT_AFTER(omd, DNA_struct_default_get(OceanModifierData), modifier);
|
2011-11-13 15:17:24 +00:00
|
|
|
|
2020-05-08 10:14:02 +02:00
|
|
|
BKE_modifier_path_init(omd->cachepath, sizeof(omd->cachepath), "cache_ocean");
|
2011-11-13 15:17:24 +00:00
|
|
|
|
2015-04-04 15:18:52 +11:00
|
|
|
omd->ocean = BKE_ocean_add();
|
2020-08-03 10:08:31 -04:00
|
|
|
BKE_ocean_init_from_modifier(omd->ocean, omd, omd->viewport_resolution);
|
2011-11-13 12:17:27 +00:00
|
|
|
simulate_ocean_modifier(omd);
|
2013-01-02 16:03:58 +00:00
|
|
|
#else /* WITH_OCEANSIM */
|
2020-10-01 09:38:00 -05:00
|
|
|
UNUSED_VARS(md);
|
2013-01-02 16:03:58 +00:00
|
|
|
#endif /* WITH_OCEANSIM */
|
2011-11-13 12:17:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void freeData(ModifierData *md)
|
|
|
|
{
|
|
|
|
#ifdef WITH_OCEANSIM
|
2012-05-06 13:38:33 +00:00
|
|
|
OceanModifierData *omd = (OceanModifierData *)md;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-04 15:18:52 +11:00
|
|
|
BKE_ocean_free(omd->ocean);
|
2019-05-31 22:51:19 +10:00
|
|
|
if (omd->oceancache) {
|
2015-04-04 15:18:52 +11:00
|
|
|
BKE_ocean_free_cache(omd->oceancache);
|
2019-05-31 22:51:19 +10:00
|
|
|
}
|
2013-01-02 16:03:58 +00:00
|
|
|
#else /* WITH_OCEANSIM */
|
2011-11-13 12:17:27 +00:00
|
|
|
/* unused */
|
|
|
|
(void)md;
|
2013-01-02 16:03:58 +00:00
|
|
|
#endif /* WITH_OCEANSIM */
|
2011-11-13 12:17:27 +00:00
|
|
|
}
|
|
|
|
|
2018-07-04 15:15:08 +02:00
|
|
|
static void copyData(const ModifierData *md, ModifierData *target, const int flag)
|
2011-11-13 12:17:27 +00:00
|
|
|
{
|
|
|
|
#ifdef WITH_OCEANSIM
|
2017-06-19 14:40:08 +02:00
|
|
|
# if 0
|
2019-04-17 08:50:46 +02:00
|
|
|
const OceanModifierData *omd = (const OceanModifierData *)md;
|
2017-06-19 14:40:08 +02:00
|
|
|
# endif
|
2012-05-06 13:38:33 +00:00
|
|
|
OceanModifierData *tomd = (OceanModifierData *)target;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-05-08 10:14:02 +02:00
|
|
|
BKE_modifier_copydata_generic(md, target, flag);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-05 16:23:35 +02:00
|
|
|
/* The oceancache object will be recreated for this copy
|
|
|
|
* automatically when cached=true */
|
2011-11-13 12:17:27 +00:00
|
|
|
tomd->oceancache = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-04 15:18:52 +11:00
|
|
|
tomd->ocean = BKE_ocean_add();
|
2020-08-03 10:08:31 -04:00
|
|
|
BKE_ocean_init_from_modifier(tomd->ocean, tomd, tomd->viewport_resolution);
|
2011-11-13 12:17:27 +00:00
|
|
|
simulate_ocean_modifier(tomd);
|
2013-01-02 16:03:58 +00:00
|
|
|
#else /* WITH_OCEANSIM */
|
2011-11-13 12:17:27 +00:00
|
|
|
/* unused */
|
|
|
|
(void)md;
|
|
|
|
(void)target;
|
2018-07-04 15:15:08 +02:00
|
|
|
(void)flag;
|
2013-01-02 16:03:58 +00:00
|
|
|
#endif /* WITH_OCEANSIM */
|
2011-11-13 12:17:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef WITH_OCEANSIM
|
Refactor CDData masks, to have one mask per mesh elem type.
We already have different storages for cddata of verts, edges etc.,
'simply' do the same for the mask flags we use all around Blender code
to request some data, or limit some operation to some layers, etc.
Reason we need this is that some cddata types (like Normals) are
actually shared between verts/polys/loops, and we don’t want to generate
clnors everytime we request vnors!
As a side note, this also does final fix to T59338, which was the
trigger for this patch (need to request computed loop normals for
another mesh than evaluated one).
Reviewers: brecht, campbellbarton, sergey
Differential Revision: https://developer.blender.org/D4407
2019-03-07 11:13:40 +01:00
|
|
|
static void requiredDataMask(Object *UNUSED(ob),
|
|
|
|
ModifierData *md,
|
|
|
|
CustomData_MeshMasks *r_cddata_masks)
|
2011-11-13 12:17:27 +00:00
|
|
|
{
|
|
|
|
OceanModifierData *omd = (OceanModifierData *)md;
|
|
|
|
|
Refactor CDData masks, to have one mask per mesh elem type.
We already have different storages for cddata of verts, edges etc.,
'simply' do the same for the mask flags we use all around Blender code
to request some data, or limit some operation to some layers, etc.
Reason we need this is that some cddata types (like Normals) are
actually shared between verts/polys/loops, and we don’t want to generate
clnors everytime we request vnors!
As a side note, this also does final fix to T59338, which was the
trigger for this patch (need to request computed loop normals for
another mesh than evaluated one).
Reviewers: brecht, campbellbarton, sergey
Differential Revision: https://developer.blender.org/D4407
2019-03-07 11:13:40 +01:00
|
|
|
if (omd->flag & MOD_OCEAN_GENERATE_FOAM) {
|
|
|
|
r_cddata_masks->fmask |= CD_MASK_MCOL; /* XXX Should be loop cddata I guess? */
|
|
|
|
}
|
2011-11-13 12:17:27 +00:00
|
|
|
}
|
2013-01-02 16:03:58 +00:00
|
|
|
#else /* WITH_OCEANSIM */
|
Refactor CDData masks, to have one mask per mesh elem type.
We already have different storages for cddata of verts, edges etc.,
'simply' do the same for the mask flags we use all around Blender code
to request some data, or limit some operation to some layers, etc.
Reason we need this is that some cddata types (like Normals) are
actually shared between verts/polys/loops, and we don’t want to generate
clnors everytime we request vnors!
As a side note, this also does final fix to T59338, which was the
trigger for this patch (need to request computed loop normals for
another mesh than evaluated one).
Reviewers: brecht, campbellbarton, sergey
Differential Revision: https://developer.blender.org/D4407
2019-03-07 11:13:40 +01:00
|
|
|
static void requiredDataMask(Object *UNUSED(ob),
|
|
|
|
ModifierData *UNUSED(md),
|
|
|
|
CustomData_MeshMasks *UNUSED(r_cddata_masks))
|
2011-11-13 12:17:27 +00:00
|
|
|
{
|
|
|
|
}
|
2013-01-02 16:03:58 +00:00
|
|
|
#endif /* WITH_OCEANSIM */
|
2011-11-13 12:17:27 +00:00
|
|
|
|
2013-06-05 19:22:12 +00:00
|
|
|
static bool dependsOnNormals(ModifierData *md)
|
|
|
|
{
|
|
|
|
OceanModifierData *omd = (OceanModifierData *)md;
|
|
|
|
return (omd->geometry_mode != MOD_OCEAN_GEOM_GENERATE);
|
|
|
|
}
|
|
|
|
|
2011-11-13 12:17:27 +00:00
|
|
|
#ifdef WITH_OCEANSIM
|
2011-11-13 16:10:01 +00:00
|
|
|
|
2015-12-06 18:59:20 +01:00
|
|
|
typedef struct GenerateOceanGeometryData {
|
2011-11-22 18:51:01 +00:00
|
|
|
MVert *mverts;
|
2011-11-22 19:43:09 +00:00
|
|
|
MPoly *mpolys;
|
|
|
|
MLoop *mloops;
|
2015-12-06 18:59:20 +01:00
|
|
|
MLoopUV *mloopuvs;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-12-06 18:59:20 +01:00
|
|
|
int res_x, res_y;
|
|
|
|
int rx, ry;
|
|
|
|
float ox, oy;
|
|
|
|
float sx, sy;
|
|
|
|
float ix, iy;
|
|
|
|
} GenerateOceanGeometryData;
|
2011-11-13 16:10:01 +00:00
|
|
|
|
2018-01-10 12:49:51 +01:00
|
|
|
static void generate_ocean_geometry_vertices(void *__restrict userdata,
|
|
|
|
const int y,
|
2019-07-30 14:56:47 +02:00
|
|
|
const TaskParallelTLS *__restrict UNUSED(tls))
|
2015-12-06 18:59:20 +01:00
|
|
|
{
|
|
|
|
GenerateOceanGeometryData *gogd = userdata;
|
|
|
|
int x;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-12-06 18:59:20 +01:00
|
|
|
for (x = 0; x <= gogd->res_x; x++) {
|
|
|
|
const int i = y * (gogd->res_x + 1) + x;
|
|
|
|
float *co = gogd->mverts[i].co;
|
|
|
|
co[0] = gogd->ox + (x * gogd->sx);
|
|
|
|
co[1] = gogd->oy + (y * gogd->sy);
|
|
|
|
co[2] = 0.0f;
|
|
|
|
}
|
|
|
|
}
|
2011-11-13 16:10:01 +00:00
|
|
|
|
2018-01-10 12:49:51 +01:00
|
|
|
static void generate_ocean_geometry_polygons(void *__restrict userdata,
|
|
|
|
const int y,
|
2019-07-30 14:56:47 +02:00
|
|
|
const TaskParallelTLS *__restrict UNUSED(tls))
|
2015-12-06 18:59:20 +01:00
|
|
|
{
|
|
|
|
GenerateOceanGeometryData *gogd = userdata;
|
|
|
|
int x;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-12-06 18:59:20 +01:00
|
|
|
for (x = 0; x < gogd->res_x; x++) {
|
|
|
|
const int fi = y * gogd->res_x + x;
|
|
|
|
const int vi = y * (gogd->res_x + 1) + x;
|
|
|
|
MPoly *mp = &gogd->mpolys[fi];
|
|
|
|
MLoop *ml = &gogd->mloops[fi * 4];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-12-06 18:59:20 +01:00
|
|
|
ml->v = vi;
|
|
|
|
ml++;
|
|
|
|
ml->v = vi + 1;
|
|
|
|
ml++;
|
|
|
|
ml->v = vi + 1 + gogd->res_x + 1;
|
|
|
|
ml++;
|
|
|
|
ml->v = vi + gogd->res_x + 1;
|
|
|
|
ml++;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-12-06 18:59:20 +01:00
|
|
|
mp->loopstart = fi * 4;
|
|
|
|
mp->totloop = 4;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-12-06 18:59:20 +01:00
|
|
|
mp->flag |= ME_SMOOTH;
|
|
|
|
}
|
|
|
|
}
|
2011-11-13 16:10:01 +00:00
|
|
|
|
2018-01-10 12:49:51 +01:00
|
|
|
static void generate_ocean_geometry_uvs(void *__restrict userdata,
|
|
|
|
const int y,
|
2019-07-30 14:56:47 +02:00
|
|
|
const TaskParallelTLS *__restrict UNUSED(tls))
|
2015-12-06 18:59:20 +01:00
|
|
|
{
|
|
|
|
GenerateOceanGeometryData *gogd = userdata;
|
|
|
|
int x;
|
2011-11-13 16:10:01 +00:00
|
|
|
|
2015-12-06 18:59:20 +01:00
|
|
|
for (x = 0; x < gogd->res_x; x++) {
|
|
|
|
const int i = y * gogd->res_x + x;
|
|
|
|
MLoopUV *luv = &gogd->mloopuvs[i * 4];
|
|
|
|
|
|
|
|
luv->uv[0] = x * gogd->ix;
|
|
|
|
luv->uv[1] = y * gogd->iy;
|
|
|
|
luv++;
|
|
|
|
|
|
|
|
luv->uv[0] = (x + 1) * gogd->ix;
|
|
|
|
luv->uv[1] = y * gogd->iy;
|
|
|
|
luv++;
|
|
|
|
|
|
|
|
luv->uv[0] = (x + 1) * gogd->ix;
|
|
|
|
luv->uv[1] = (y + 1) * gogd->iy;
|
|
|
|
luv++;
|
|
|
|
|
|
|
|
luv->uv[0] = x * gogd->ix;
|
|
|
|
luv->uv[1] = (y + 1) * gogd->iy;
|
|
|
|
luv++;
|
|
|
|
}
|
|
|
|
}
|
2011-11-13 16:10:01 +00:00
|
|
|
|
2020-08-03 10:08:31 -04:00
|
|
|
static Mesh *generate_ocean_geometry(OceanModifierData *omd, Mesh *mesh_orig, const int resolution)
|
2015-12-06 18:59:20 +01:00
|
|
|
{
|
2018-07-05 15:30:00 +02:00
|
|
|
Mesh *result;
|
2011-11-13 16:10:01 +00:00
|
|
|
|
2015-12-06 18:59:20 +01:00
|
|
|
GenerateOceanGeometryData gogd;
|
|
|
|
|
|
|
|
int num_verts;
|
2015-12-06 21:03:57 +01:00
|
|
|
int num_polys;
|
2015-12-06 18:59:20 +01:00
|
|
|
|
2020-08-03 10:08:31 -04:00
|
|
|
const bool use_threading = resolution > 4;
|
2016-01-16 15:59:37 +01:00
|
|
|
|
2020-08-03 10:08:31 -04:00
|
|
|
gogd.rx = resolution * resolution;
|
|
|
|
gogd.ry = resolution * resolution;
|
2015-12-06 18:59:20 +01:00
|
|
|
gogd.res_x = gogd.rx * omd->repeat_x;
|
|
|
|
gogd.res_y = gogd.ry * omd->repeat_y;
|
|
|
|
|
|
|
|
num_verts = (gogd.res_x + 1) * (gogd.res_y + 1);
|
2015-12-06 21:03:57 +01:00
|
|
|
num_polys = gogd.res_x * gogd.res_y;
|
2015-12-06 18:59:20 +01:00
|
|
|
|
|
|
|
gogd.sx = omd->size * omd->spatial_size;
|
|
|
|
gogd.sy = omd->size * omd->spatial_size;
|
|
|
|
gogd.ox = -gogd.sx / 2.0f;
|
|
|
|
gogd.oy = -gogd.sy / 2.0f;
|
|
|
|
|
|
|
|
gogd.sx /= gogd.rx;
|
|
|
|
gogd.sy /= gogd.ry;
|
2011-11-13 16:10:01 +00:00
|
|
|
|
2018-07-05 15:30:00 +02:00
|
|
|
result = BKE_mesh_new_nomain(num_verts, 0, 0, num_polys * 4, num_polys);
|
2019-09-16 10:45:49 +02:00
|
|
|
BKE_mesh_copy_settings(result, mesh_orig);
|
2011-11-13 16:10:01 +00:00
|
|
|
|
2018-07-05 15:30:00 +02:00
|
|
|
gogd.mverts = result->mvert;
|
|
|
|
gogd.mpolys = result->mpoly;
|
|
|
|
gogd.mloops = result->mloop;
|
2011-11-22 19:43:09 +00:00
|
|
|
|
2019-07-30 14:56:47 +02:00
|
|
|
TaskParallelSettings settings;
|
2018-01-08 11:35:48 +01:00
|
|
|
BLI_parallel_range_settings_defaults(&settings);
|
|
|
|
settings.use_threading = use_threading;
|
|
|
|
|
2011-11-13 12:17:27 +00:00
|
|
|
/* create vertices */
|
2018-01-08 11:35:48 +01:00
|
|
|
BLI_task_parallel_range(0, gogd.res_y + 1, &gogd, generate_ocean_geometry_vertices, &settings);
|
2011-11-13 16:10:01 +00:00
|
|
|
|
2011-11-13 12:17:27 +00:00
|
|
|
/* create faces */
|
2018-01-08 11:35:48 +01:00
|
|
|
BLI_task_parallel_range(0, gogd.res_y, &gogd, generate_ocean_geometry_polygons, &settings);
|
2011-11-13 16:10:01 +00:00
|
|
|
|
2018-07-05 15:30:00 +02:00
|
|
|
BKE_mesh_calc_edges(result, false, false);
|
2011-11-13 16:10:01 +00:00
|
|
|
|
2011-11-13 12:17:27 +00:00
|
|
|
/* add uvs */
|
2018-07-05 15:30:00 +02:00
|
|
|
if (CustomData_number_of_layers(&result->ldata, CD_MLOOPUV) < MAX_MTFACE) {
|
|
|
|
gogd.mloopuvs = CustomData_add_layer(
|
|
|
|
&result->ldata, CD_MLOOPUV, CD_CALLOC, NULL, num_polys * 4);
|
2011-11-22 18:51:01 +00:00
|
|
|
|
2015-12-06 18:59:20 +01:00
|
|
|
if (gogd.mloopuvs) { /* unlikely to fail */
|
|
|
|
gogd.ix = 1.0 / gogd.rx;
|
|
|
|
gogd.iy = 1.0 / gogd.ry;
|
2011-11-22 19:43:09 +00:00
|
|
|
|
2018-01-08 11:35:48 +01:00
|
|
|
BLI_task_parallel_range(0, gogd.res_y, &gogd, generate_ocean_geometry_uvs, &settings);
|
2011-11-13 12:17:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-05 15:30:00 +02:00
|
|
|
result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
|
2013-05-30 17:36:43 +00:00
|
|
|
|
2011-11-13 12:17:27 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-07-05 16:23:35 +02:00
|
|
|
static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
|
2011-11-13 12:17:27 +00:00
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
OceanModifierData *omd = (OceanModifierData *)md;
|
2018-07-05 16:23:35 +02:00
|
|
|
int cfra_scene = (int)DEG_get_ctime(ctx->depsgraph);
|
|
|
|
Object *ob = ctx->object;
|
2018-07-10 11:58:01 +02:00
|
|
|
bool allocated_ocean = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-05 15:30:00 +02:00
|
|
|
Mesh *result = NULL;
|
2011-11-13 12:17:27 +00:00
|
|
|
OceanResult ocr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-08-03 10:08:31 -04:00
|
|
|
const int resolution = (ctx->flag & MOD_APPLY_RENDER) ? omd->resolution :
|
|
|
|
omd->viewport_resolution;
|
|
|
|
|
2015-12-06 21:03:57 +01:00
|
|
|
MVert *mverts;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-05 16:23:35 +02:00
|
|
|
int cfra_for_cache;
|
2015-12-06 21:03:57 +01:00
|
|
|
int i, j;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-11-22 18:03:33 +00:00
|
|
|
/* use cached & inverted value for speed
|
|
|
|
* expanded this would read...
|
|
|
|
*
|
|
|
|
* (axis / (omd->size * omd->spatial_size)) + 0.5f) */
|
|
|
|
# define OCEAN_CO(_size_co_inv, _v) ((_v * _size_co_inv) + 0.5f)
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 13:38:33 +00:00
|
|
|
const float size_co_inv = 1.0f / (omd->size * omd->spatial_size);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-07-22 21:02:45 +00:00
|
|
|
/* can happen in when size is small, avoid bad array lookups later and quit now */
|
2016-05-16 00:48:02 +02:00
|
|
|
if (!isfinite(size_co_inv)) {
|
2018-07-05 15:30:00 +02:00
|
|
|
return mesh;
|
2013-07-22 21:02:45 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-11-13 12:17:27 +00:00
|
|
|
/* do ocean simulation */
|
2014-04-01 11:34:00 +11:00
|
|
|
if (omd->cached == true) {
|
2015-12-06 21:03:57 +01:00
|
|
|
if (!omd->oceancache) {
|
2020-08-03 10:08:31 -04:00
|
|
|
init_cache_data(ob, omd, resolution);
|
2015-12-06 21:03:57 +01:00
|
|
|
}
|
2018-07-05 16:23:35 +02:00
|
|
|
BKE_ocean_simulate_cache(omd->oceancache, cfra_scene);
|
2011-11-22 15:10:08 +00:00
|
|
|
}
|
|
|
|
else {
|
2018-07-10 11:58:01 +02:00
|
|
|
/* omd->ocean is NULL on an original object (in contrast to an evaluated one).
|
|
|
|
* We can create a new one, but we have to free it as well once we're done.
|
|
|
|
* This function is only called on an original object when applying the modifier
|
|
|
|
* using the 'Apply Modifier' button, and thus it is not called frequently for
|
|
|
|
* simulation. */
|
2020-08-03 10:08:31 -04:00
|
|
|
allocated_ocean |= BKE_ocean_ensure(omd, resolution);
|
2011-11-13 12:17:27 +00:00
|
|
|
simulate_ocean_modifier(omd);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-06-05 19:22:12 +00:00
|
|
|
if (omd->geometry_mode == MOD_OCEAN_GEOM_GENERATE) {
|
2020-08-03 10:08:31 -04:00
|
|
|
result = generate_ocean_geometry(omd, mesh, resolution);
|
2018-07-05 15:30:00 +02:00
|
|
|
BKE_mesh_ensure_normals(result);
|
2013-06-05 19:22:12 +00:00
|
|
|
}
|
2011-11-13 12:17:27 +00:00
|
|
|
else if (omd->geometry_mode == MOD_OCEAN_GEOM_DISPLACE) {
|
2020-10-07 14:27:33 +02:00
|
|
|
result = (Mesh *)BKE_id_copy_ex(NULL, &mesh->id, NULL, LIB_ID_COPY_LOCALIZE);
|
2011-11-13 12:17:27 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-05 16:23:35 +02:00
|
|
|
cfra_for_cache = cfra_scene;
|
|
|
|
CLAMP(cfra_for_cache, omd->bakestart, omd->bakeend);
|
|
|
|
cfra_for_cache -= omd->bakestart; /* shift to 0 based */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-05 15:30:00 +02:00
|
|
|
mverts = result->mvert;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-11-13 12:17:27 +00:00
|
|
|
/* add vcols before displacement - allows lookup based on position */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-11-13 12:17:27 +00:00
|
|
|
if (omd->flag & MOD_OCEAN_GENERATE_FOAM) {
|
2018-07-05 15:30:00 +02:00
|
|
|
if (CustomData_number_of_layers(&result->ldata, CD_MLOOPCOL) < MAX_MCOL) {
|
|
|
|
const int num_polys = result->totpoly;
|
|
|
|
const int num_loops = result->totloop;
|
|
|
|
MLoop *mloops = result->mloop;
|
2015-12-06 21:03:57 +01:00
|
|
|
MLoopCol *mloopcols = CustomData_add_layer_named(
|
2018-07-05 15:30:00 +02:00
|
|
|
&result->ldata, CD_MLOOPCOL, CD_CALLOC, NULL, num_loops, omd->foamlayername);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-07-02 11:49:15 -04:00
|
|
|
MLoopCol *mloopcols_spray = NULL;
|
|
|
|
if (omd->flag & MOD_OCEAN_GENERATE_SPRAY) {
|
|
|
|
mloopcols_spray = CustomData_add_layer_named(
|
|
|
|
&result->ldata, CD_MLOOPCOL, CD_CALLOC, NULL, num_loops, omd->spraylayername);
|
|
|
|
}
|
|
|
|
|
2011-11-22 19:43:09 +00:00
|
|
|
if (mloopcols) { /* unlikely to fail */
|
2018-07-05 15:30:00 +02:00
|
|
|
MPoly *mpolys = result->mpoly;
|
2011-11-22 19:43:09 +00:00
|
|
|
MPoly *mp;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-12-06 21:03:57 +01:00
|
|
|
for (i = 0, mp = mpolys; i < num_polys; i++, mp++) {
|
|
|
|
MLoop *ml = &mloops[mp->loopstart];
|
|
|
|
MLoopCol *mlcol = &mloopcols[mp->loopstart];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-07-02 11:49:15 -04:00
|
|
|
MLoopCol *mlcolspray = NULL;
|
|
|
|
if (omd->flag & MOD_OCEAN_GENERATE_SPRAY) {
|
|
|
|
mlcolspray = &mloopcols_spray[mp->loopstart];
|
|
|
|
}
|
|
|
|
|
2015-12-06 21:03:57 +01:00
|
|
|
for (j = mp->totloop; j--; ml++, mlcol++) {
|
|
|
|
const float *vco = mverts[ml->v].co;
|
|
|
|
const float u = OCEAN_CO(size_co_inv, vco[0]);
|
|
|
|
const float v = OCEAN_CO(size_co_inv, vco[1]);
|
|
|
|
float foam;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-04-01 11:34:00 +11:00
|
|
|
if (omd->oceancache && omd->cached == true) {
|
2018-07-05 16:23:35 +02:00
|
|
|
BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra_for_cache, u, v);
|
2011-11-22 19:01:52 +00:00
|
|
|
foam = ocr.foam;
|
|
|
|
CLAMP(foam, 0.0f, 1.0f);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
BKE_ocean_eval_uv(omd->ocean, &ocr, u, v);
|
|
|
|
foam = BKE_ocean_jminus_to_foam(ocr.Jminus, omd->foam_coverage);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-11-22 19:43:09 +00:00
|
|
|
mlcol->r = mlcol->g = mlcol->b = (char)(foam * 255);
|
2013-02-12 01:52:55 +00:00
|
|
|
/* This needs to be set (render engine uses) */
|
|
|
|
mlcol->a = 255;
|
2020-07-02 11:49:15 -04:00
|
|
|
|
|
|
|
if (omd->flag & MOD_OCEAN_GENERATE_SPRAY) {
|
|
|
|
if (omd->flag & MOD_OCEAN_INVERT_SPRAY) {
|
|
|
|
mlcolspray->r = ocr.Eminus[0] * 255;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mlcolspray->r = ocr.Eplus[0] * 255;
|
|
|
|
}
|
|
|
|
mlcolspray->g = 0;
|
|
|
|
if (omd->flag & MOD_OCEAN_INVERT_SPRAY) {
|
|
|
|
mlcolspray->b = ocr.Eminus[2] * 255;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mlcolspray->b = ocr.Eplus[2] * 255;
|
|
|
|
}
|
|
|
|
mlcolspray->a = 255;
|
|
|
|
}
|
2011-11-22 19:01:52 +00:00
|
|
|
}
|
2011-11-22 18:03:33 +00:00
|
|
|
}
|
2011-11-13 12:17:27 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
2011-11-13 12:17:27 +00:00
|
|
|
/* displace the geometry */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-05-01 07:40:07 +10:00
|
|
|
/* Note: tried to parallelized that one and previous foam loop,
|
|
|
|
* but gives 20% slower results... odd. */
|
2015-12-06 21:03:57 +01:00
|
|
|
{
|
2018-07-05 15:30:00 +02:00
|
|
|
const int num_verts = result->totvert;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-12-06 21:03:57 +01:00
|
|
|
for (i = 0; i < num_verts; i++) {
|
|
|
|
float *vco = mverts[i].co;
|
|
|
|
const float u = OCEAN_CO(size_co_inv, vco[0]);
|
|
|
|
const float v = OCEAN_CO(size_co_inv, vco[1]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-12-06 21:03:57 +01:00
|
|
|
if (omd->oceancache && omd->cached == true) {
|
2018-07-05 16:23:35 +02:00
|
|
|
BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra_for_cache, u, v);
|
2015-12-06 21:03:57 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
BKE_ocean_eval_uv(omd->ocean, &ocr, u, v);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-12-06 21:03:57 +01:00
|
|
|
vco[2] += ocr.disp[1];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-12-06 21:03:57 +01:00
|
|
|
if (omd->chop_amount > 0.0f) {
|
|
|
|
vco[0] += ocr.disp[0];
|
|
|
|
vco[1] += ocr.disp[2];
|
|
|
|
}
|
2011-11-13 12:17:27 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-10 11:58:01 +02:00
|
|
|
if (allocated_ocean) {
|
|
|
|
BKE_ocean_free(omd->ocean);
|
|
|
|
omd->ocean = NULL;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-07-22 21:02:45 +00:00
|
|
|
# undef OCEAN_CO
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-05 15:30:00 +02:00
|
|
|
return result;
|
2011-11-13 12:17:27 +00:00
|
|
|
}
|
2013-01-02 16:03:58 +00:00
|
|
|
#else /* WITH_OCEANSIM */
|
2018-07-05 16:23:35 +02:00
|
|
|
static Mesh *doOcean(ModifierData *UNUSED(md), const ModifierEvalContext *UNUSED(ctx), Mesh *mesh)
|
2011-11-13 12:17:27 +00:00
|
|
|
{
|
2018-07-05 15:30:00 +02:00
|
|
|
return mesh;
|
2011-11-13 12:17:27 +00:00
|
|
|
}
|
2013-01-02 16:03:58 +00:00
|
|
|
#endif /* WITH_OCEANSIM */
|
2011-11-13 12:17:27 +00:00
|
|
|
|
2020-04-21 13:09:41 +02:00
|
|
|
static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
|
2011-11-13 12:17:27 +00:00
|
|
|
{
|
2018-07-05 15:30:00 +02:00
|
|
|
Mesh *result;
|
2011-11-13 16:10:01 +00:00
|
|
|
|
2018-07-05 16:23:35 +02:00
|
|
|
result = doOcean(md, ctx, mesh);
|
2011-11-13 16:10:01 +00:00
|
|
|
|
2019-04-22 09:15:10 +10:00
|
|
|
if (result != mesh) {
|
2018-07-05 15:30:00 +02:00
|
|
|
result->runtime.cd_dirty_vert |= CD_MASK_NORMAL;
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2011-11-13 16:10:01 +00:00
|
|
|
|
2011-11-13 12:17:27 +00:00
|
|
|
return result;
|
|
|
|
}
|
2020-06-05 10:41:03 -04:00
|
|
|
// #define WITH_OCEANSIM
|
2020-09-02 14:13:26 -05:00
|
|
|
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
2020-06-05 10:41:03 -04:00
|
|
|
{
|
|
|
|
uiLayout *layout = panel->layout;
|
|
|
|
#ifdef WITH_OCEANSIM
|
UI: Small Tweaks to Modifier Layouts for Consistency
These changes are smaller, made based on feedback and a pass on all
the layouts for clarity and consistency. The Multires modifier UI will
be addressed in a separate patch. Here is an overview of the changes:
Renaming Options:
- Build: "Start" -> "Start Frame"
- Curve: "From Radius" -> "Size from Radius"
- Screw: "Calc Order" -> "Calculate Order"
- Displace, Warp, Wave: "Texture Coordinates Object" -> "Object"
Move Mode Toggle to Top & Expand:
- Bevel, Boolean, Normal Edit, Subdivision
Use Columns for Tighter Spacing:
- Displace, Explode, Ocean, Particle Instance, Remesh, Shrinkwrap,
Solidify, Warp, Weighted Normal, Wave
Misc:
- Bevel: Set inactive properties for vertex bevel
- Mesh Sequence Cache: Remove box for cache file
- Skin: Don't align "Mark Loose" and "Clear Loose"
- Array: Expand relative offset subpanel by default
- Array: Move start cap, end cap to a new subpanel
- Bevel: Move width type above width
Differential Revision: https://developer.blender.org/D8115
2020-07-02 10:47:02 -04:00
|
|
|
uiLayout *col, *sub;
|
2020-06-05 10:41:03 -04:00
|
|
|
|
|
|
|
PointerRNA ob_ptr;
|
2020-09-02 14:13:26 -05:00
|
|
|
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
|
|
|
uiLayoutSetPropSep(layout, true);
|
|
|
|
|
UI: Small Tweaks to Modifier Layouts for Consistency
These changes are smaller, made based on feedback and a pass on all
the layouts for clarity and consistency. The Multires modifier UI will
be addressed in a separate patch. Here is an overview of the changes:
Renaming Options:
- Build: "Start" -> "Start Frame"
- Curve: "From Radius" -> "Size from Radius"
- Screw: "Calc Order" -> "Calculate Order"
- Displace, Warp, Wave: "Texture Coordinates Object" -> "Object"
Move Mode Toggle to Top & Expand:
- Bevel, Boolean, Normal Edit, Subdivision
Use Columns for Tighter Spacing:
- Displace, Explode, Ocean, Particle Instance, Remesh, Shrinkwrap,
Solidify, Warp, Weighted Normal, Wave
Misc:
- Bevel: Set inactive properties for vertex bevel
- Mesh Sequence Cache: Remove box for cache file
- Skin: Don't align "Mark Loose" and "Clear Loose"
- Array: Expand relative offset subpanel by default
- Array: Move start cap, end cap to a new subpanel
- Bevel: Move width type above width
Differential Revision: https://developer.blender.org/D8115
2020-07-02 10:47:02 -04:00
|
|
|
col = uiLayoutColumn(layout, false);
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(col, ptr, "geometry_mode", 0, NULL, ICON_NONE);
|
|
|
|
if (RNA_enum_get(ptr, "geometry_mode") == MOD_OCEAN_GEOM_GENERATE) {
|
UI: Small Tweaks to Modifier Layouts for Consistency
These changes are smaller, made based on feedback and a pass on all
the layouts for clarity and consistency. The Multires modifier UI will
be addressed in a separate patch. Here is an overview of the changes:
Renaming Options:
- Build: "Start" -> "Start Frame"
- Curve: "From Radius" -> "Size from Radius"
- Screw: "Calc Order" -> "Calculate Order"
- Displace, Warp, Wave: "Texture Coordinates Object" -> "Object"
Move Mode Toggle to Top & Expand:
- Bevel, Boolean, Normal Edit, Subdivision
Use Columns for Tighter Spacing:
- Displace, Explode, Ocean, Particle Instance, Remesh, Shrinkwrap,
Solidify, Warp, Weighted Normal, Wave
Misc:
- Bevel: Set inactive properties for vertex bevel
- Mesh Sequence Cache: Remove box for cache file
- Skin: Don't align "Mark Loose" and "Clear Loose"
- Array: Expand relative offset subpanel by default
- Array: Move start cap, end cap to a new subpanel
- Bevel: Move width type above width
Differential Revision: https://developer.blender.org/D8115
2020-07-02 10:47:02 -04:00
|
|
|
sub = uiLayoutColumn(col, true);
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(sub, ptr, "repeat_x", 0, IFACE_("Repeat X"), ICON_NONE);
|
|
|
|
uiItemR(sub, ptr, "repeat_y", 0, IFACE_("Y"), ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
}
|
2020-08-03 10:08:31 -04:00
|
|
|
|
|
|
|
sub = uiLayoutColumn(col, true);
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(sub, ptr, "viewport_resolution", 0, IFACE_("Resolution Viewport"), ICON_NONE);
|
|
|
|
uiItemR(sub, ptr, "resolution", 0, IFACE_("Render"), ICON_NONE);
|
UI: Small Tweaks to Modifier Layouts for Consistency
These changes are smaller, made based on feedback and a pass on all
the layouts for clarity and consistency. The Multires modifier UI will
be addressed in a separate patch. Here is an overview of the changes:
Renaming Options:
- Build: "Start" -> "Start Frame"
- Curve: "From Radius" -> "Size from Radius"
- Screw: "Calc Order" -> "Calculate Order"
- Displace, Warp, Wave: "Texture Coordinates Object" -> "Object"
Move Mode Toggle to Top & Expand:
- Bevel, Boolean, Normal Edit, Subdivision
Use Columns for Tighter Spacing:
- Displace, Explode, Ocean, Particle Instance, Remesh, Shrinkwrap,
Solidify, Warp, Weighted Normal, Wave
Misc:
- Bevel: Set inactive properties for vertex bevel
- Mesh Sequence Cache: Remove box for cache file
- Skin: Don't align "Mark Loose" and "Clear Loose"
- Array: Expand relative offset subpanel by default
- Array: Move start cap, end cap to a new subpanel
- Bevel: Move width type above width
Differential Revision: https://developer.blender.org/D8115
2020-07-02 10:47:02 -04:00
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(col, ptr, "time", 0, NULL, ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(col, ptr, "depth", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "size", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "spatial_size", 0, NULL, ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(col, ptr, "random_seed", 0, NULL, ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(col, ptr, "use_normals", 0, NULL, ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
modifier_panel_end(layout, ptr);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
|
|
|
#else /* WITH_OCEANSIM */
|
|
|
|
uiItemL(layout, IFACE_("Built without Ocean modifier"), ICON_NONE);
|
|
|
|
#endif /* WITH_OCEANSIM */
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef WITH_OCEANSIM
|
2020-09-02 14:13:26 -05:00
|
|
|
static void waves_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
2020-06-05 10:41:03 -04:00
|
|
|
{
|
UI: Small Tweaks to Modifier Layouts for Consistency
These changes are smaller, made based on feedback and a pass on all
the layouts for clarity and consistency. The Multires modifier UI will
be addressed in a separate patch. Here is an overview of the changes:
Renaming Options:
- Build: "Start" -> "Start Frame"
- Curve: "From Radius" -> "Size from Radius"
- Screw: "Calc Order" -> "Calculate Order"
- Displace, Warp, Wave: "Texture Coordinates Object" -> "Object"
Move Mode Toggle to Top & Expand:
- Bevel, Boolean, Normal Edit, Subdivision
Use Columns for Tighter Spacing:
- Displace, Explode, Ocean, Particle Instance, Remesh, Shrinkwrap,
Solidify, Warp, Weighted Normal, Wave
Misc:
- Bevel: Set inactive properties for vertex bevel
- Mesh Sequence Cache: Remove box for cache file
- Skin: Don't align "Mark Loose" and "Clear Loose"
- Array: Expand relative offset subpanel by default
- Array: Move start cap, end cap to a new subpanel
- Bevel: Move width type above width
Differential Revision: https://developer.blender.org/D8115
2020-07-02 10:47:02 -04:00
|
|
|
uiLayout *col, *sub;
|
2020-06-05 10:41:03 -04:00
|
|
|
uiLayout *layout = panel->layout;
|
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
|
|
|
uiLayoutSetPropSep(layout, true);
|
|
|
|
|
UI: Small Tweaks to Modifier Layouts for Consistency
These changes are smaller, made based on feedback and a pass on all
the layouts for clarity and consistency. The Multires modifier UI will
be addressed in a separate patch. Here is an overview of the changes:
Renaming Options:
- Build: "Start" -> "Start Frame"
- Curve: "From Radius" -> "Size from Radius"
- Screw: "Calc Order" -> "Calculate Order"
- Displace, Warp, Wave: "Texture Coordinates Object" -> "Object"
Move Mode Toggle to Top & Expand:
- Bevel, Boolean, Normal Edit, Subdivision
Use Columns for Tighter Spacing:
- Displace, Explode, Ocean, Particle Instance, Remesh, Shrinkwrap,
Solidify, Warp, Weighted Normal, Wave
Misc:
- Bevel: Set inactive properties for vertex bevel
- Mesh Sequence Cache: Remove box for cache file
- Skin: Don't align "Mark Loose" and "Clear Loose"
- Array: Expand relative offset subpanel by default
- Array: Move start cap, end cap to a new subpanel
- Bevel: Move width type above width
Differential Revision: https://developer.blender.org/D8115
2020-07-02 10:47:02 -04:00
|
|
|
col = uiLayoutColumn(layout, false);
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(col, ptr, "wave_scale", 0, IFACE_("Scale"), ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "wave_scale_min", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "choppiness", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "wind_velocity", 0, NULL, ICON_NONE);
|
UI: Small Tweaks to Modifier Layouts for Consistency
These changes are smaller, made based on feedback and a pass on all
the layouts for clarity and consistency. The Multires modifier UI will
be addressed in a separate patch. Here is an overview of the changes:
Renaming Options:
- Build: "Start" -> "Start Frame"
- Curve: "From Radius" -> "Size from Radius"
- Screw: "Calc Order" -> "Calculate Order"
- Displace, Warp, Wave: "Texture Coordinates Object" -> "Object"
Move Mode Toggle to Top & Expand:
- Bevel, Boolean, Normal Edit, Subdivision
Use Columns for Tighter Spacing:
- Displace, Explode, Ocean, Particle Instance, Remesh, Shrinkwrap,
Solidify, Warp, Weighted Normal, Wave
Misc:
- Bevel: Set inactive properties for vertex bevel
- Mesh Sequence Cache: Remove box for cache file
- Skin: Don't align "Mark Loose" and "Clear Loose"
- Array: Expand relative offset subpanel by default
- Array: Move start cap, end cap to a new subpanel
- Bevel: Move width type above width
Differential Revision: https://developer.blender.org/D8115
2020-07-02 10:47:02 -04:00
|
|
|
|
|
|
|
uiItemS(layout);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
|
|
|
col = uiLayoutColumn(layout, false);
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(col, ptr, "wave_alignment", UI_ITEM_R_SLIDER, IFACE_("Alignment"), ICON_NONE);
|
UI: Small Tweaks to Modifier Layouts for Consistency
These changes are smaller, made based on feedback and a pass on all
the layouts for clarity and consistency. The Multires modifier UI will
be addressed in a separate patch. Here is an overview of the changes:
Renaming Options:
- Build: "Start" -> "Start Frame"
- Curve: "From Radius" -> "Size from Radius"
- Screw: "Calc Order" -> "Calculate Order"
- Displace, Warp, Wave: "Texture Coordinates Object" -> "Object"
Move Mode Toggle to Top & Expand:
- Bevel, Boolean, Normal Edit, Subdivision
Use Columns for Tighter Spacing:
- Displace, Explode, Ocean, Particle Instance, Remesh, Shrinkwrap,
Solidify, Warp, Weighted Normal, Wave
Misc:
- Bevel: Set inactive properties for vertex bevel
- Mesh Sequence Cache: Remove box for cache file
- Skin: Don't align "Mark Loose" and "Clear Loose"
- Array: Expand relative offset subpanel by default
- Array: Move start cap, end cap to a new subpanel
- Bevel: Move width type above width
Differential Revision: https://developer.blender.org/D8115
2020-07-02 10:47:02 -04:00
|
|
|
sub = uiLayoutColumn(col, false);
|
2020-09-02 14:13:26 -05:00
|
|
|
uiLayoutSetActive(sub, RNA_float_get(ptr, "wave_alignment") > 0.0f);
|
|
|
|
uiItemR(sub, ptr, "wave_direction", 0, IFACE_("Direction"), ICON_NONE);
|
|
|
|
uiItemR(sub, ptr, "damping", 0, NULL, ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
}
|
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
static void foam_panel_draw_header(const bContext *UNUSED(C), Panel *panel)
|
2020-06-05 10:41:03 -04:00
|
|
|
{
|
|
|
|
uiLayout *layout = panel->layout;
|
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(layout, ptr, "use_foam", 0, IFACE_("Foam"), ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
}
|
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
static void foam_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
2020-06-05 10:41:03 -04:00
|
|
|
{
|
|
|
|
uiLayout *col;
|
|
|
|
uiLayout *layout = panel->layout;
|
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
bool use_foam = RNA_boolean_get(ptr, "use_foam");
|
2020-06-05 10:41:03 -04:00
|
|
|
|
|
|
|
uiLayoutSetPropSep(layout, true);
|
|
|
|
|
|
|
|
col = uiLayoutColumn(layout, false);
|
|
|
|
uiLayoutSetActive(col, use_foam);
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(col, ptr, "foam_layer_name", 0, IFACE_("Data Layer"), ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "foam_coverage", 0, IFACE_("Coverage"), ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
}
|
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
static void spray_panel_draw_header(const bContext *UNUSED(C), Panel *panel)
|
2020-07-02 11:49:15 -04:00
|
|
|
{
|
2020-07-02 11:55:37 -04:00
|
|
|
uiLayout *row;
|
2020-07-02 11:49:15 -04:00
|
|
|
uiLayout *layout = panel->layout;
|
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
|
2020-07-02 11:49:15 -04:00
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
bool use_foam = RNA_boolean_get(ptr, "use_foam");
|
2020-07-02 11:55:37 -04:00
|
|
|
|
|
|
|
row = uiLayoutRow(layout, false);
|
|
|
|
uiLayoutSetActive(row, use_foam);
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(row, ptr, "use_spray", 0, IFACE_("Spray"), ICON_NONE);
|
2020-07-02 11:49:15 -04:00
|
|
|
}
|
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
static void spray_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
2020-07-02 11:49:15 -04:00
|
|
|
{
|
|
|
|
uiLayout *col;
|
|
|
|
uiLayout *layout = panel->layout;
|
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
|
2020-07-02 11:49:15 -04:00
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
bool use_foam = RNA_boolean_get(ptr, "use_foam");
|
|
|
|
bool use_spray = RNA_boolean_get(ptr, "use_spray");
|
2020-07-02 11:49:15 -04:00
|
|
|
|
|
|
|
uiLayoutSetPropSep(layout, true);
|
|
|
|
|
|
|
|
col = uiLayoutColumn(layout, false);
|
|
|
|
uiLayoutSetActive(col, use_foam && use_spray);
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(col, ptr, "spray_layer_name", 0, IFACE_("Data Layer"), ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "invert_spray", 0, IFACE_("Invert"), ICON_NONE);
|
2020-07-02 11:49:15 -04:00
|
|
|
}
|
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
static void spectrum_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
2020-06-05 10:41:03 -04:00
|
|
|
{
|
UI: Small Tweaks to Modifier Layouts for Consistency
These changes are smaller, made based on feedback and a pass on all
the layouts for clarity and consistency. The Multires modifier UI will
be addressed in a separate patch. Here is an overview of the changes:
Renaming Options:
- Build: "Start" -> "Start Frame"
- Curve: "From Radius" -> "Size from Radius"
- Screw: "Calc Order" -> "Calculate Order"
- Displace, Warp, Wave: "Texture Coordinates Object" -> "Object"
Move Mode Toggle to Top & Expand:
- Bevel, Boolean, Normal Edit, Subdivision
Use Columns for Tighter Spacing:
- Displace, Explode, Ocean, Particle Instance, Remesh, Shrinkwrap,
Solidify, Warp, Weighted Normal, Wave
Misc:
- Bevel: Set inactive properties for vertex bevel
- Mesh Sequence Cache: Remove box for cache file
- Skin: Don't align "Mark Loose" and "Clear Loose"
- Array: Expand relative offset subpanel by default
- Array: Move start cap, end cap to a new subpanel
- Bevel: Move width type above width
Differential Revision: https://developer.blender.org/D8115
2020-07-02 10:47:02 -04:00
|
|
|
uiLayout *col;
|
2020-06-05 10:41:03 -04:00
|
|
|
uiLayout *layout = panel->layout;
|
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
int spectrum = RNA_enum_get(ptr, "spectrum");
|
2020-06-05 10:41:03 -04:00
|
|
|
|
UI: Small Tweaks to Modifier Layouts for Consistency
These changes are smaller, made based on feedback and a pass on all
the layouts for clarity and consistency. The Multires modifier UI will
be addressed in a separate patch. Here is an overview of the changes:
Renaming Options:
- Build: "Start" -> "Start Frame"
- Curve: "From Radius" -> "Size from Radius"
- Screw: "Calc Order" -> "Calculate Order"
- Displace, Warp, Wave: "Texture Coordinates Object" -> "Object"
Move Mode Toggle to Top & Expand:
- Bevel, Boolean, Normal Edit, Subdivision
Use Columns for Tighter Spacing:
- Displace, Explode, Ocean, Particle Instance, Remesh, Shrinkwrap,
Solidify, Warp, Weighted Normal, Wave
Misc:
- Bevel: Set inactive properties for vertex bevel
- Mesh Sequence Cache: Remove box for cache file
- Skin: Don't align "Mark Loose" and "Clear Loose"
- Array: Expand relative offset subpanel by default
- Array: Move start cap, end cap to a new subpanel
- Bevel: Move width type above width
Differential Revision: https://developer.blender.org/D8115
2020-07-02 10:47:02 -04:00
|
|
|
uiLayoutSetPropSep(layout, true);
|
|
|
|
|
|
|
|
col = uiLayoutColumn(layout, false);
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(col, ptr, "spectrum", 0, NULL, ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
if (ELEM(spectrum, MOD_OCEAN_SPECTRUM_TEXEL_MARSEN_ARSLOE, MOD_OCEAN_SPECTRUM_JONSWAP)) {
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(col, ptr, "sharpen_peak_jonswap", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "fetch_jonswap", 0, NULL, ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
static void bake_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
2020-06-05 10:41:03 -04:00
|
|
|
{
|
|
|
|
uiLayout *col;
|
|
|
|
uiLayout *layout = panel->layout;
|
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
|
|
|
uiLayoutSetPropSep(layout, true);
|
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
bool is_cached = RNA_boolean_get(ptr, "is_cached");
|
|
|
|
bool use_foam = RNA_boolean_get(ptr, "use_foam");
|
2020-06-05 10:41:03 -04:00
|
|
|
|
|
|
|
if (is_cached) {
|
|
|
|
PointerRNA op_ptr;
|
|
|
|
uiItemFullO(layout,
|
|
|
|
"OBJECT_OT_ocean_bake",
|
|
|
|
IFACE_("Delete Bake"),
|
|
|
|
ICON_NONE,
|
|
|
|
NULL,
|
|
|
|
WM_OP_EXEC_DEFAULT,
|
|
|
|
0,
|
|
|
|
&op_ptr);
|
|
|
|
RNA_boolean_set(&op_ptr, "free", true);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
uiItemO(layout, NULL, ICON_NONE, "OBJECT_OT_ocean_bake");
|
|
|
|
}
|
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(layout, ptr, "filepath", 0, NULL, ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
|
|
|
col = uiLayoutColumn(layout, true);
|
|
|
|
uiLayoutSetEnabled(col, !is_cached);
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(col, ptr, "frame_start", 0, IFACE_("Frame Start"), ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "frame_end", 0, IFACE_("End"), ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
|
|
|
col = uiLayoutColumn(layout, false);
|
|
|
|
uiLayoutSetActive(col, use_foam);
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(col, ptr, "bake_foam_fade", 0, NULL, ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
}
|
|
|
|
#endif /* WITH_OCEANSIM */
|
|
|
|
|
|
|
|
static void panelRegister(ARegionType *region_type)
|
|
|
|
{
|
|
|
|
PanelType *panel_type = modifier_panel_register(region_type, eModifierType_Ocean, panel_draw);
|
|
|
|
#ifdef WITH_OCEANSIM
|
|
|
|
modifier_subpanel_register(region_type, "waves", "Waves", NULL, waves_panel_draw, panel_type);
|
2020-07-02 11:49:15 -04:00
|
|
|
PanelType *foam_panel = modifier_subpanel_register(
|
2020-06-05 10:41:03 -04:00
|
|
|
region_type, "foam", "", foam_panel_draw_header, foam_panel_draw, panel_type);
|
2020-07-02 11:49:15 -04:00
|
|
|
modifier_subpanel_register(
|
|
|
|
region_type, "spray", "", spray_panel_draw_header, spray_panel_draw, foam_panel);
|
2020-06-05 10:41:03 -04:00
|
|
|
modifier_subpanel_register(
|
|
|
|
region_type, "spectrum", "Spectrum", NULL, spectrum_panel_draw, panel_type);
|
|
|
|
modifier_subpanel_register(region_type, "bake", "Bake", NULL, bake_panel_draw, panel_type);
|
|
|
|
#else
|
|
|
|
UNUSED_VARS(panel_type);
|
|
|
|
#endif /* WITH_OCEANSIM */
|
|
|
|
}
|
2011-11-13 12:17:27 +00:00
|
|
|
|
2020-06-23 17:25:44 +02:00
|
|
|
static void blendRead(BlendDataReader *UNUSED(reader), ModifierData *md)
|
|
|
|
{
|
|
|
|
OceanModifierData *omd = (OceanModifierData *)md;
|
|
|
|
omd->oceancache = NULL;
|
|
|
|
omd->ocean = NULL;
|
|
|
|
}
|
|
|
|
|
2011-11-13 12:17:27 +00:00
|
|
|
ModifierTypeInfo modifierType_Ocean = {
|
|
|
|
/* name */ "Ocean",
|
|
|
|
/* structName */ "OceanModifierData",
|
|
|
|
/* structSize */ sizeof(OceanModifierData),
|
2020-09-25 12:49:18 +02:00
|
|
|
/* srna */ &RNA_OceanModifier,
|
2011-11-13 12:17:27 +00:00
|
|
|
/* type */ eModifierTypeType_Constructive,
|
2012-05-06 13:38:33 +00:00
|
|
|
/* flags */ eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_SupportsEditmode |
|
|
|
|
eModifierTypeFlag_EnableInEditmode,
|
2020-09-25 12:45:30 +02:00
|
|
|
/* icon */ ICON_MOD_OCEAN,
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-11-13 12:17:27 +00:00
|
|
|
/* copyData */ copyData,
|
2018-04-18 15:45:54 +02:00
|
|
|
/* deformMatrices_DM */ NULL,
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-04-18 15:45:54 +02:00
|
|
|
/* deformMatrices */ NULL,
|
2011-11-14 16:05:44 +00:00
|
|
|
/* deformVertsEM */ NULL,
|
|
|
|
/* deformMatricesEM */ NULL,
|
2020-04-21 13:09:41 +02:00
|
|
|
/* modifyMesh */ modifyMesh,
|
|
|
|
/* modifyHair */ NULL,
|
2020-12-10 14:35:02 +01:00
|
|
|
/* modifyGeometrySet */ NULL,
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-11-13 12:17:27 +00:00
|
|
|
/* initData */ initData,
|
|
|
|
/* requiredDataMask */ requiredDataMask,
|
|
|
|
/* freeData */ freeData,
|
2011-11-14 16:05:44 +00:00
|
|
|
/* isDisabled */ NULL,
|
Depsgraph: New dependency graph integration commit
This commit integrates the work done so far on the new dependency graph system,
where goal was to replace legacy depsgraph with the new one, supporting loads of
neat features like:
- More granular dependency relation nature, which solves issues with fake cycles
in the dependencies.
- Move towards all-animatable, by better integration of drivers into the system.
- Lay down some basis for upcoming copy-on-write, overrides and so on.
The new system is living side-by-side with the previous one and disabled by
default, so nothing will become suddenly broken. The way to enable new depsgraph
is to pass `--new-depsgraph` command line argument.
It's a bit early to consider the system production-ready, there are some TODOs
and issues were discovered during the merge period, they'll be addressed ASAP.
But it's important to merge, because it's the only way to attract artists to
really start testing this system.
There are number of assorted documents related on the design of the new system:
* http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph#Design_Documents
* http://wiki.blender.org/index.php/User:Nazg-gul/DependencyGraph
There are also some user-related information online:
* http://code.blender.org/2015/02/blender-dependency-graph-branch-for-users/
* http://code.blender.org/2015/03/more-dependency-graph-tricks/
Kudos to everyone who was involved into the project:
- Joshua "Aligorith" Leung -- design specification, initial code
- Lukas "lukas_t" Toenne -- integrating code into blender, with further fixes
- Sergey "Sergey" "Sharybin" -- some mocking around, trying to wrap up the
project and so
- Bassam "slikdigit" Kurdali -- stressing the new system, reporting all the
issues and recording/writing documentation.
- Everyone else who i forgot to mention here :)
2015-05-12 15:05:57 +05:00
|
|
|
/* updateDepsgraph */ NULL,
|
2011-11-14 16:05:44 +00:00
|
|
|
/* dependsOnTime */ NULL,
|
2013-06-05 19:22:12 +00:00
|
|
|
/* dependsOnNormals */ dependsOnNormals,
|
2011-11-14 16:05:44 +00:00
|
|
|
/* foreachIDLink */ NULL,
|
2015-10-05 15:57:10 +02:00
|
|
|
/* foreachTexLink */ NULL,
|
2019-03-18 15:56:16 +01:00
|
|
|
/* freeRuntimeData */ NULL,
|
2020-06-05 10:41:03 -04:00
|
|
|
/* panelRegister */ panelRegister,
|
2020-06-15 17:37:07 +02:00
|
|
|
/* blendWrite */ NULL,
|
2020-06-23 17:25:44 +02:00
|
|
|
/* blendRead */ blendRead,
|
2011-11-13 12:17:27 +00:00
|
|
|
};
|