Fix wrong grease pencil shader FX usage of object location.

It should use the evaluated object location, and not add any unnecessary
dependency on geometry data.
This commit is contained in:
Brecht Van Lommel 2019-01-02 18:18:11 +01:00
parent f694d37929
commit f8ce4ebf07
4 changed files with 4 additions and 7 deletions

View File

@ -310,7 +310,7 @@ static void DRW_gpencil_fx_light(
DRW_shgroup_uniform_vec2(fx_shgrp, "Viewport", DRW_viewport_size_get(), 1);
/* location of the light using obj location as origin */
copy_v3_v3(fxd->loc, &fxd->object->loc[0]);
copy_v3_v3(fxd->loc, fxd->object->obmat[3]);
/* Calc distance to strokes plane
* The w component of location is used to transfer the distance to drawing plane
@ -323,7 +323,7 @@ static void DRW_gpencil_fx_light(
}
mul_mat3_m4_v3(cache->obmat, r_normal); /* only rotation component */
plane_from_point_normal_v3(r_plane, r_point, r_normal);
float dt = dist_to_plane_v3(fxd->object->loc, r_plane);
float dt = dist_to_plane_v3(fxd->object->obmat[3], r_plane);
fxd->loc[3] = dt; /* use last element to save it */
DRW_shgroup_uniform_vec4(fx_shgrp, "loc", &fxd->loc[0], 1);
@ -469,7 +469,7 @@ static void DRW_gpencil_fx_shadow(
DRW_shgroup_uniform_vec4(fx_shgrp, "shadow_color", &fxd->shadow_rgba[0], 1);
if ((fxd->object) && (fxd->flag & FX_SHADOW_USE_OBJECT)) {
DRW_shgroup_uniform_vec3(fx_shgrp, "loc", &fxd->object->loc[0], 1);
DRW_shgroup_uniform_vec3(fx_shgrp, "loc", fxd->object->obmat[3], 1);
}
else {
DRW_shgroup_uniform_vec3(fx_shgrp, "loc", &cache->loc[0], 1);
@ -609,7 +609,7 @@ static void DRW_gpencil_fx_swirl(
DRW_shgroup_uniform_vec2(fx_shgrp, "Viewport", DRW_viewport_size_get(), 1);
DRW_shgroup_uniform_vec3(fx_shgrp, "loc", &fxd->object->loc[0], 1);
DRW_shgroup_uniform_vec3(fx_shgrp, "loc", fxd->object->obmat[3], 1);
DRW_shgroup_uniform_int(fx_shgrp, "radius", &fxd->radius, 1);
DRW_shgroup_uniform_float(fx_shgrp, "angle", &fxd->angle, 1);

View File

@ -63,7 +63,6 @@ static void updateDepsgraph(ShaderFxData *md, const ModifierUpdateDepsgraphConte
{
LightShaderFxData *fxd = (LightShaderFxData *)md;
if (fxd->object != NULL) {
DEG_add_object_relation(ctx->node, fxd->object, DEG_OB_COMP_GEOMETRY, "Light ShaderFx");
DEG_add_object_relation(ctx->node, fxd->object, DEG_OB_COMP_TRANSFORM, "Light ShaderFx");
}
DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Light ShaderFx");

View File

@ -74,7 +74,6 @@ static void updateDepsgraph(ShaderFxData *fx, const ModifierUpdateDepsgraphConte
{
ShadowShaderFxData *fxd = (ShadowShaderFxData *)fx;
if (fxd->object != NULL) {
DEG_add_object_relation(ctx->node, fxd->object, DEG_OB_COMP_GEOMETRY, "Shadow ShaderFx");
DEG_add_object_relation(ctx->node, fxd->object, DEG_OB_COMP_TRANSFORM, "Shadow ShaderFx");
}
DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Shadow ShaderFx");

View File

@ -62,7 +62,6 @@ static void updateDepsgraph(ShaderFxData *fx, const ModifierUpdateDepsgraphConte
{
SwirlShaderFxData *fxd = (SwirlShaderFxData *)fx;
if (fxd->object != NULL) {
DEG_add_object_relation(ctx->node, fxd->object, DEG_OB_COMP_GEOMETRY, "Swirl ShaderFx");
DEG_add_object_relation(ctx->node, fxd->object, DEG_OB_COMP_TRANSFORM, "Swirl ShaderFx");
}
DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Swirl ShaderFx");