2011-05-01 15:16:59 +00:00
|
|
|
/*
|
2011-10-23 17:52:20 +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.
|
|
|
|
*/
|
2011-05-01 15:16:59 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup modifiers
|
2011-09-22 12:00:24 +00:00
|
|
|
*/
|
|
|
|
|
2011-05-01 15:16:59 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2018-05-08 18:41:43 +02:00
|
|
|
#include "DNA_mesh_types.h"
|
2012-04-30 08:24:44 +00:00
|
|
|
#include "DNA_meshdata_types.h"
|
2018-05-08 18:41:43 +02:00
|
|
|
#include "DNA_object_types.h"
|
2012-04-30 08:24:44 +00:00
|
|
|
|
2011-05-01 15:16:59 +00:00
|
|
|
#include "BLI_math.h"
|
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
2018-05-08 18:41:43 +02:00
|
|
|
#include "BKE_editmesh.h"
|
|
|
|
#include "BKE_library.h"
|
2015-10-08 14:21:11 +02:00
|
|
|
#include "BKE_library_query.h"
|
2018-05-08 18:41:43 +02:00
|
|
|
#include "BKE_mesh.h"
|
2011-05-01 15:16:59 +00:00
|
|
|
#include "BKE_modifier.h"
|
|
|
|
#include "BKE_deform.h"
|
|
|
|
#include "BKE_texture.h"
|
|
|
|
#include "BKE_colortools.h"
|
|
|
|
|
2018-05-23 15:52:35 +02:00
|
|
|
#include "DEG_depsgraph.h"
|
2018-06-22 15:03:42 +02:00
|
|
|
#include "DEG_depsgraph_query.h"
|
2018-05-23 15:52:35 +02:00
|
|
|
|
2011-05-01 15:16:59 +00:00
|
|
|
#include "RE_shader_ext.h"
|
|
|
|
|
|
|
|
#include "MOD_util.h"
|
|
|
|
|
|
|
|
|
|
|
|
static void initData(ModifierData *md)
|
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
WarpModifierData *wmd = (WarpModifierData *) md;
|
2011-05-01 15:16:59 +00:00
|
|
|
|
|
|
|
wmd->curfalloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
|
|
|
|
wmd->texture = NULL;
|
|
|
|
wmd->strength = 1.0f;
|
|
|
|
wmd->falloff_radius = 1.0f;
|
|
|
|
wmd->falloff_type = eWarp_Falloff_Smooth;
|
|
|
|
wmd->flag = 0;
|
|
|
|
}
|
|
|
|
|
2018-07-04 12:45:30 +02:00
|
|
|
static void copyData(const ModifierData *md, ModifierData *target, const int flag)
|
2011-05-01 15:16:59 +00:00
|
|
|
{
|
2018-05-08 15:04:10 +02:00
|
|
|
const WarpModifierData *wmd = (const WarpModifierData *) md;
|
2012-05-06 13:38:33 +00:00
|
|
|
WarpModifierData *twmd = (WarpModifierData *) target;
|
2011-05-01 15:16:59 +00:00
|
|
|
|
2018-07-04 12:45:30 +02:00
|
|
|
modifier_copyData_generic(md, target, flag);
|
2011-05-01 15:16:59 +00:00
|
|
|
|
|
|
|
twmd->curfalloff = curvemapping_copy(wmd->curfalloff);
|
|
|
|
}
|
|
|
|
|
|
|
|
static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
|
|
|
|
{
|
|
|
|
WarpModifierData *wmd = (WarpModifierData *)md;
|
|
|
|
CustomDataMask dataMask = 0;
|
|
|
|
|
|
|
|
/* ask for vertexgroups if we need them */
|
2012-03-24 06:24:53 +00:00
|
|
|
if (wmd->defgrp_name[0]) dataMask |= (CD_MASK_MDEFORMVERT);
|
2011-07-11 09:15:20 +00:00
|
|
|
dataMask |= (CD_MASK_MDEFORMVERT);
|
2011-05-01 15:16:59 +00:00
|
|
|
|
|
|
|
/* ask for UV coordinates if we need them */
|
2012-03-24 06:24:53 +00:00
|
|
|
if (wmd->texmapping == MOD_DISP_MAP_UV) dataMask |= (1 << CD_MTFACE);
|
2011-05-01 15:16:59 +00:00
|
|
|
|
|
|
|
return dataMask;
|
|
|
|
}
|
|
|
|
|
2013-06-02 03:59:19 +00:00
|
|
|
static bool dependsOnTime(ModifierData *md)
|
2011-05-01 15:16:59 +00:00
|
|
|
{
|
|
|
|
WarpModifierData *wmd = (WarpModifierData *)md;
|
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (wmd->texture) {
|
2011-05-01 15:16:59 +00:00
|
|
|
return BKE_texture_dependsOnTime(wmd->texture);
|
|
|
|
}
|
|
|
|
else {
|
2013-06-02 03:59:19 +00:00
|
|
|
return false;
|
2011-05-01 15:16:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void freeData(ModifierData *md)
|
|
|
|
{
|
|
|
|
WarpModifierData *wmd = (WarpModifierData *) md;
|
|
|
|
curvemapping_free(wmd->curfalloff);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-10 12:14:08 +02:00
|
|
|
static bool isDisabled(const struct Scene *UNUSED(scene), ModifierData *md, bool UNUSED(userRenderParams))
|
2011-05-01 15:16:59 +00:00
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
WarpModifierData *wmd = (WarpModifierData *) md;
|
2011-05-01 15:16:59 +00:00
|
|
|
|
|
|
|
return !(wmd->object_from && wmd->object_to);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void foreachObjectLink(ModifierData *md, Object *ob, ObjectWalkFunc walk, void *userData)
|
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
WarpModifierData *wmd = (WarpModifierData *) md;
|
2011-05-01 15:16:59 +00:00
|
|
|
|
2017-01-31 09:47:59 +01:00
|
|
|
walk(userData, ob, &wmd->object_from, IDWALK_CB_NOP);
|
|
|
|
walk(userData, ob, &wmd->object_to, IDWALK_CB_NOP);
|
|
|
|
walk(userData, ob, &wmd->map_object, IDWALK_CB_NOP);
|
2011-05-01 15:16:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData)
|
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
WarpModifierData *wmd = (WarpModifierData *) md;
|
2011-05-01 15:16:59 +00:00
|
|
|
|
2017-01-31 09:47:59 +01:00
|
|
|
walk(userData, ob, (ID **)&wmd->texture, IDWALK_CB_USER);
|
2011-05-01 15:16:59 +00:00
|
|
|
|
2015-10-05 15:57:10 +02:00
|
|
|
foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData);
|
2011-05-01 15:16:59 +00:00
|
|
|
}
|
|
|
|
|
2011-08-12 18:11:22 +00:00
|
|
|
static void foreachTexLink(ModifierData *md, Object *ob, TexWalkFunc walk, void *userData)
|
|
|
|
{
|
|
|
|
walk(userData, ob, md, "texture");
|
|
|
|
}
|
|
|
|
|
2018-02-22 12:54:06 +01:00
|
|
|
static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
|
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
|
|
|
{
|
|
|
|
WarpModifierData *wmd = (WarpModifierData *) md;
|
|
|
|
if (wmd->object_from != NULL && wmd->object_to != NULL) {
|
2019-02-12 12:01:17 +01:00
|
|
|
DEG_add_modifier_to_transform_relation(ctx->node, "Warplace Modifier");
|
2018-02-22 12:54:06 +01:00
|
|
|
DEG_add_object_relation(ctx->node, wmd->object_from, DEG_OB_COMP_TRANSFORM, "Warp Modifier from");
|
|
|
|
DEG_add_object_relation(ctx->node, wmd->object_to, DEG_OB_COMP_TRANSFORM, "Warp Modifier to");
|
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
|
|
|
}
|
|
|
|
if ((wmd->texmapping == MOD_DISP_MAP_OBJECT) && wmd->map_object != NULL) {
|
2018-02-22 12:54:06 +01:00
|
|
|
DEG_add_object_relation(ctx->node, wmd->map_object, DEG_OB_COMP_TRANSFORM, "Warp Modifier map");
|
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
|
|
|
}
|
2018-12-05 17:35:13 +01:00
|
|
|
if (wmd->texture != NULL) {
|
|
|
|
DEG_add_generic_id_relation(ctx->node, &wmd->texture->id, "Warp Modifier");
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2018-05-12 08:04:56 +02:00
|
|
|
static void warpModifier_do(
|
2018-05-23 15:52:35 +02:00
|
|
|
WarpModifierData *wmd, const ModifierEvalContext *ctx,
|
2018-05-12 08:21:07 +02:00
|
|
|
Mesh *mesh, float (*vertexCos)[3], int numVerts)
|
2011-05-01 15:16:59 +00:00
|
|
|
{
|
2018-05-23 15:52:35 +02:00
|
|
|
Object *ob = ctx->object;
|
2011-05-01 15:16:59 +00:00
|
|
|
float obinv[4][4];
|
|
|
|
float mat_from[4][4];
|
|
|
|
float mat_from_inv[4][4];
|
|
|
|
float mat_to[4][4];
|
|
|
|
float mat_unit[4][4];
|
|
|
|
float mat_final[4][4];
|
|
|
|
|
|
|
|
float tmat[4][4];
|
|
|
|
|
2015-02-03 04:35:02 +11:00
|
|
|
const float falloff_radius_sq = SQUARE(wmd->falloff_radius);
|
2011-05-01 15:16:59 +00:00
|
|
|
float strength = wmd->strength;
|
|
|
|
float fac = 1.0f, weight;
|
|
|
|
int i;
|
2011-07-11 09:15:20 +00:00
|
|
|
int defgrp_index;
|
2012-05-06 13:38:33 +00:00
|
|
|
MDeformVert *dvert, *dv = NULL;
|
2011-05-01 15:16:59 +00:00
|
|
|
|
2012-05-06 13:38:33 +00:00
|
|
|
float (*tex_co)[3] = NULL;
|
2011-05-01 15:16:59 +00:00
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (!(wmd->object_from && wmd->object_to))
|
2011-05-01 15:16:59 +00:00
|
|
|
return;
|
|
|
|
|
2018-06-29 19:02:19 +02:00
|
|
|
MOD_get_vgroup(ob, mesh, wmd->defgrp_name, &dvert, &defgrp_index);
|
2015-02-03 04:38:59 +11:00
|
|
|
if (dvert == NULL) {
|
|
|
|
defgrp_index = -1;
|
|
|
|
}
|
2011-07-11 09:15:20 +00:00
|
|
|
|
2012-05-03 21:35:04 +00:00
|
|
|
if (wmd->curfalloff == NULL) /* should never happen, but bad lib linking could cause it */
|
2011-05-01 15:16:59 +00:00
|
|
|
wmd->curfalloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
|
|
|
|
|
2012-08-21 14:43:51 +00:00
|
|
|
if (wmd->curfalloff) {
|
|
|
|
curvemapping_initialize(wmd->curfalloff);
|
|
|
|
}
|
|
|
|
|
2011-05-01 15:16:59 +00:00
|
|
|
invert_m4_m4(obinv, ob->obmat);
|
|
|
|
|
2018-12-07 15:45:53 +01:00
|
|
|
mul_m4_m4m4(mat_from, obinv, DEG_get_evaluated_object(ctx->depsgraph, wmd->object_from)->obmat);
|
|
|
|
mul_m4_m4m4(mat_to, obinv, DEG_get_evaluated_object(ctx->depsgraph, wmd->object_to)->obmat);
|
2011-05-01 15:16:59 +00:00
|
|
|
|
|
|
|
invert_m4_m4(tmat, mat_from); // swap?
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(mat_final, tmat, mat_to);
|
2011-05-01 15:16:59 +00:00
|
|
|
|
|
|
|
invert_m4_m4(mat_from_inv, mat_from);
|
|
|
|
|
|
|
|
unit_m4(mat_unit);
|
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (strength < 0.0f) {
|
2011-05-01 16:07:18 +00:00
|
|
|
float loc[3];
|
2011-05-01 15:16:59 +00:00
|
|
|
strength = -strength;
|
2011-05-01 16:07:18 +00:00
|
|
|
|
|
|
|
/* inverted location is not useful, just use the negative */
|
|
|
|
copy_v3_v3(loc, mat_final[3]);
|
2011-05-01 15:16:59 +00:00
|
|
|
invert_m4(mat_final);
|
2011-05-01 16:07:18 +00:00
|
|
|
negate_v3_v3(mat_final[3], loc);
|
|
|
|
|
2011-05-01 15:16:59 +00:00
|
|
|
}
|
2012-05-06 13:38:33 +00:00
|
|
|
weight = strength;
|
2011-05-01 15:16:59 +00:00
|
|
|
|
2018-12-07 15:45:53 +01:00
|
|
|
Tex *tex_target = (Tex *)DEG_get_evaluated_id(ctx->depsgraph, &wmd->texture->id);
|
|
|
|
if (mesh != NULL && tex_target != NULL) {
|
2018-01-14 22:14:20 +01:00
|
|
|
tex_co = MEM_malloc_arrayN(numVerts, sizeof(*tex_co), "warpModifier_do tex_co");
|
2018-12-07 15:45:53 +01:00
|
|
|
MOD_get_texture_coords((MappingInfoModifierData *)wmd, ctx, ob, mesh, vertexCos, tex_co);
|
2012-04-10 14:11:45 +00:00
|
|
|
|
2018-12-07 15:45:53 +01:00
|
|
|
MOD_init_texture((MappingInfoModifierData *)wmd, ctx);
|
2011-05-01 15:16:59 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
for (i = 0; i < numVerts; i++) {
|
2011-05-01 15:16:59 +00:00
|
|
|
float *co = vertexCos[i];
|
|
|
|
|
2012-05-03 21:35:04 +00:00
|
|
|
if (wmd->falloff_type == eWarp_Falloff_None ||
|
2015-02-03 04:35:02 +11:00
|
|
|
((fac = len_squared_v3v3(co, mat_from[3])) < falloff_radius_sq &&
|
|
|
|
(fac = (wmd->falloff_radius - sqrtf(fac)) / wmd->falloff_radius)))
|
2012-05-03 21:35:04 +00:00
|
|
|
{
|
2011-05-01 15:16:59 +00:00
|
|
|
/* skip if no vert group found */
|
2015-02-03 04:38:59 +11:00
|
|
|
if (defgrp_index != -1) {
|
2011-07-11 09:15:20 +00:00
|
|
|
dv = &dvert[i];
|
2015-02-03 04:38:59 +11:00
|
|
|
weight = defvert_find_weight(dv, defgrp_index) * strength;
|
|
|
|
if (weight <= 0.0f) {
|
|
|
|
continue;
|
2011-05-01 15:16:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* closely match PROP_SMOOTH and similar */
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (wmd->falloff_type) {
|
2012-05-06 13:38:33 +00:00
|
|
|
case eWarp_Falloff_None:
|
|
|
|
fac = 1.0f;
|
|
|
|
break;
|
|
|
|
case eWarp_Falloff_Curve:
|
|
|
|
fac = curvemapping_evaluateF(wmd->curfalloff, 0, fac);
|
|
|
|
break;
|
|
|
|
case eWarp_Falloff_Sharp:
|
|
|
|
fac = fac * fac;
|
|
|
|
break;
|
|
|
|
case eWarp_Falloff_Smooth:
|
|
|
|
fac = 3.0f * fac * fac - 2.0f * fac * fac * fac;
|
|
|
|
break;
|
|
|
|
case eWarp_Falloff_Root:
|
2014-03-28 14:53:37 +11:00
|
|
|
fac = sqrtf(fac);
|
2012-05-06 13:38:33 +00:00
|
|
|
break;
|
|
|
|
case eWarp_Falloff_Linear:
|
|
|
|
/* pass */
|
|
|
|
break;
|
|
|
|
case eWarp_Falloff_Const:
|
|
|
|
fac = 1.0f;
|
|
|
|
break;
|
|
|
|
case eWarp_Falloff_Sphere:
|
2014-03-28 14:53:37 +11:00
|
|
|
fac = sqrtf(2 * fac - fac * fac);
|
2012-05-06 13:38:33 +00:00
|
|
|
break;
|
2015-02-04 05:35:09 +11:00
|
|
|
case eWarp_Falloff_InvSquare:
|
|
|
|
fac = fac * (2.0f - fac);
|
|
|
|
break;
|
2011-05-01 15:16:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fac *= weight;
|
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (tex_co) {
|
2018-06-22 15:03:42 +02:00
|
|
|
struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
|
2011-05-01 15:16:59 +00:00
|
|
|
TexResult texres;
|
|
|
|
texres.nor = NULL;
|
2018-12-07 15:45:53 +01:00
|
|
|
BKE_texture_get_value(scene, tex_target, tex_co[i], &texres, false);
|
2011-05-01 15:16:59 +00:00
|
|
|
fac *= texres.tin;
|
|
|
|
}
|
|
|
|
|
2015-02-03 04:26:31 +11:00
|
|
|
if (fac != 0.0f) {
|
|
|
|
/* into the 'from' objects space */
|
|
|
|
mul_m4_v3(mat_from_inv, co);
|
2011-05-01 15:16:59 +00:00
|
|
|
|
2015-02-03 04:26:31 +11:00
|
|
|
if (fac == 1.0f) {
|
|
|
|
mul_m4_v3(mat_final, co);
|
2011-05-01 15:16:59 +00:00
|
|
|
}
|
|
|
|
else {
|
2015-02-03 04:26:31 +11:00
|
|
|
if (wmd->flag & MOD_WARP_VOLUME_PRESERVE) {
|
|
|
|
/* interpolate the matrix for nicer locations */
|
|
|
|
blend_m4_m4m4(tmat, mat_unit, mat_final, fac);
|
|
|
|
mul_m4_v3(tmat, co);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
float tvec[3];
|
|
|
|
mul_v3_m4v3(tvec, mat_final, co);
|
|
|
|
interp_v3_v3v3(co, co, tvec, fac);
|
|
|
|
}
|
2011-05-01 15:16:59 +00:00
|
|
|
}
|
|
|
|
|
2015-02-03 04:26:31 +11:00
|
|
|
/* out of the 'from' objects space */
|
|
|
|
mul_m4_v3(mat_from, co);
|
|
|
|
}
|
2011-05-01 15:16:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-08 18:41:43 +02:00
|
|
|
if (tex_co) {
|
2011-05-01 15:16:59 +00:00
|
|
|
MEM_freeN(tex_co);
|
2018-05-08 18:41:43 +02:00
|
|
|
}
|
2011-05-01 15:16:59 +00:00
|
|
|
}
|
|
|
|
|
2018-05-12 08:04:56 +02:00
|
|
|
static void deformVerts(
|
2018-05-12 08:21:07 +02:00
|
|
|
ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh,
|
|
|
|
float (*vertexCos)[3], int numVerts)
|
2011-05-01 15:16:59 +00:00
|
|
|
{
|
2018-11-27 15:11:13 +01:00
|
|
|
WarpModifierData *wmd = (WarpModifierData *)md;
|
|
|
|
Mesh *mesh_src = NULL;
|
2011-05-01 15:16:59 +00:00
|
|
|
|
2018-11-27 20:10:41 +01:00
|
|
|
if (wmd->defgrp_name[0] != '\0' || wmd->texture != NULL) {
|
|
|
|
/* mesh_src is only needed for vgroups and textures. */
|
2018-11-27 17:21:16 +01:00
|
|
|
mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false);
|
2011-05-01 15:16:59 +00:00
|
|
|
}
|
|
|
|
|
2018-11-27 15:11:13 +01:00
|
|
|
warpModifier_do(wmd, ctx, mesh_src, vertexCos, numVerts);
|
2011-05-01 15:16:59 +00:00
|
|
|
|
2018-11-27 15:11:13 +01:00
|
|
|
if (!ELEM(mesh_src, NULL, mesh)) {
|
|
|
|
BKE_id_free(NULL, mesh_src);
|
|
|
|
}
|
2011-05-01 15:16:59 +00:00
|
|
|
}
|
|
|
|
|
2018-05-12 08:04:56 +02:00
|
|
|
static void deformVertsEM(
|
2018-05-12 08:21:07 +02:00
|
|
|
ModifierData *md, const ModifierEvalContext *ctx, struct BMEditMesh *em,
|
|
|
|
Mesh *mesh, float (*vertexCos)[3], int numVerts)
|
2011-05-01 15:16:59 +00:00
|
|
|
{
|
2018-11-27 15:11:13 +01:00
|
|
|
WarpModifierData *wmd = (WarpModifierData *)md;
|
2018-11-27 20:10:41 +01:00
|
|
|
Mesh *mesh_src = NULL;
|
2011-05-01 15:16:59 +00:00
|
|
|
|
2018-11-27 20:10:41 +01:00
|
|
|
if (wmd->defgrp_name[0] != '\0' || wmd->texture != NULL) {
|
|
|
|
/* mesh_src is only needed for vgroups and textures. */
|
|
|
|
mesh_src = MOD_deform_mesh_eval_get(ctx->object, em, mesh, NULL, numVerts, false, false);
|
2011-05-01 15:16:59 +00:00
|
|
|
}
|
|
|
|
|
2018-11-27 15:11:13 +01:00
|
|
|
warpModifier_do(wmd, ctx, mesh_src, vertexCos, numVerts);
|
2011-05-01 15:16:59 +00:00
|
|
|
|
2018-11-27 15:11:13 +01:00
|
|
|
if (!ELEM(mesh_src, NULL, mesh)) {
|
2018-05-08 18:41:43 +02:00
|
|
|
BKE_id_free(NULL, mesh_src);
|
2011-05-01 15:16:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ModifierTypeInfo modifierType_Warp = {
|
2012-10-24 05:45:54 +00:00
|
|
|
/* name */ "Warp",
|
|
|
|
/* structName */ "WarpModifierData",
|
|
|
|
/* structSize */ sizeof(WarpModifierData),
|
|
|
|
/* type */ eModifierTypeType_OnlyDeform,
|
|
|
|
/* flags */ eModifierTypeFlag_AcceptsCVs |
|
2016-05-18 22:21:46 +10:00
|
|
|
eModifierTypeFlag_AcceptsLattice |
|
2012-10-24 05:45:54 +00:00
|
|
|
eModifierTypeFlag_SupportsEditmode,
|
|
|
|
/* copyData */ copyData,
|
2018-04-18 15:45:54 +02:00
|
|
|
|
2018-05-08 18:41:43 +02:00
|
|
|
/* deformVerts_DM */ NULL,
|
2018-04-18 15:45:54 +02:00
|
|
|
/* deformMatrices_DM */ NULL,
|
2018-05-08 18:41:43 +02:00
|
|
|
/* deformVertsEM_DM */ NULL,
|
2018-04-18 15:45:54 +02:00
|
|
|
/* deformMatricesEM_DM*/NULL,
|
|
|
|
/* applyModifier_DM */ NULL,
|
|
|
|
|
2018-05-08 18:41:43 +02:00
|
|
|
/* deformVerts */ deformVerts,
|
2012-10-24 05:45:54 +00:00
|
|
|
/* deformMatrices */ NULL,
|
2018-05-08 18:41:43 +02:00
|
|
|
/* deformVertsEM */ deformVertsEM,
|
2012-10-24 05:45:54 +00:00
|
|
|
/* deformMatricesEM */ NULL,
|
2013-08-07 03:36:05 +00:00
|
|
|
/* applyModifier */ NULL,
|
2018-04-18 15:45:54 +02:00
|
|
|
|
2012-10-24 05:45:54 +00:00
|
|
|
/* initData */ initData,
|
|
|
|
/* requiredDataMask */ requiredDataMask,
|
|
|
|
/* freeData */ freeData,
|
|
|
|
/* isDisabled */ isDisabled,
|
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 */ updateDepsgraph,
|
2012-10-24 05:45:54 +00:00
|
|
|
/* dependsOnTime */ dependsOnTime,
|
|
|
|
/* dependsOnNormals */ NULL,
|
2011-05-01 15:16:59 +00:00
|
|
|
/* foreachObjectLink */ foreachObjectLink,
|
2012-10-24 05:45:54 +00:00
|
|
|
/* foreachIDLink */ foreachIDLink,
|
|
|
|
/* foreachTexLink */ foreachTexLink,
|
2011-05-01 15:16:59 +00:00
|
|
|
};
|