Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGermano Cavalcante <germano.costa@ig.com.br>2021-11-25 16:17:31 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2021-11-25 16:18:57 +0300
commitbc4c20d414e90c8e25e12cfee860e86adb06e961 (patch)
treeadd30daf5016f85991ab8999e0c393c4eb463d83 /source/blender/editors
parent447378753d320ea04d7c1ce00723fc02f35966f0 (diff)
Fix T93360: 'Iteractive Light Track' do not work over empty background
Bug introduced in {rBaa0ac0035a0d}. The invalid depth fallback was changed to `FLT_MAX` in order to match the annotation and gpencil operations. This broke the `Interactive Light Track` operator which invalidates the operation if the depth value is `1.0f`. The chosen solution was to change the value tested in the annotation and gpencil operations.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/gpencil/annotate_paint.c13
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_intern.h2
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c11
-rw-r--r--source/blender/editors/gpencil/gpencil_primitive.c10
-rw-r--r--source/blender/editors/gpencil/gpencil_utils.c4
-rw-r--r--source/blender/editors/space_view3d/view3d_utils.c11
7 files changed, 33 insertions, 20 deletions
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c
index bf53241a947..47af2cff0ce 100644
--- a/source/blender/editors/gpencil/annotate_paint.c
+++ b/source/blender/editors/gpencil/annotate_paint.c
@@ -78,6 +78,8 @@
/* ******************************************* */
/* 'Globals' and Defines */
+#define DEPTH_INVALID 1.0f
+
/* values for tGPsdata->status */
typedef enum eGPencil_PaintStatus {
GP_STATUS_IDLING = 0, /* stroke isn't in progress yet */
@@ -324,6 +326,9 @@ static void annotation_stroke_convertcoords(tGPsdata *p,
float *depth)
{
bGPdata *gpd = p->gpd;
+ if (depth && (*depth == DEPTH_INVALID)) {
+ depth = NULL;
+ }
/* in 3d-space - pt->x/y/z are 3 side-by-side floats */
if (gpd->runtime.sbuffer_sflag & GP_STROKE_3DSPACE) {
@@ -1003,14 +1008,14 @@ static void annotation_stroke_newfrombuffer(tGPsdata *p)
int last_valid = 0;
for (i = 0; i < gpd->runtime.sbuffer_used; i++) {
- if (depth_arr[i] != FLT_MAX) {
+ if (depth_arr[i] != DEPTH_INVALID) {
break;
}
}
first_valid = i;
for (i = gpd->runtime.sbuffer_used - 1; i >= 0; i--) {
- if (depth_arr[i] != FLT_MAX) {
+ if (depth_arr[i] != DEPTH_INVALID) {
break;
}
}
@@ -1018,14 +1023,14 @@ static void annotation_stroke_newfrombuffer(tGPsdata *p)
/* invalidate non-endpoints, so only blend between first and last */
for (i = first_valid + 1; i < last_valid; i++) {
- depth_arr[i] = FLT_MAX;
+ depth_arr[i] = DEPTH_INVALID;
}
interp_depth = true;
}
if (interp_depth) {
- interp_sparse_array(depth_arr, gpd->runtime.sbuffer_used, FLT_MAX);
+ interp_sparse_array(depth_arr, gpd->runtime.sbuffer_used, DEPTH_INVALID);
}
}
}
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 9860c75f290..90cf64b58d8 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -1415,7 +1415,7 @@ static void gpencil_get_depth_array(tGPDfill *tgpf)
}
else {
if (interp_depth) {
- interp_sparse_array(tgpf->depth_arr, totpoints, FLT_MAX);
+ interp_sparse_array(tgpf->depth_arr, totpoints, DEPTH_INVALID);
}
}
}
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index 3f3fd4fff39..cfc1257204b 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -27,6 +27,8 @@
#include "ED_numinput.h"
+#define DEPTH_INVALID 1.0f
+
/* internal exports only */
struct Material;
struct bGPDspoint;
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index f0118988559..018334a851e 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -429,6 +429,9 @@ static void gpencil_stroke_convertcoords(tGPsdata *p,
float *depth)
{
bGPdata *gpd = p->gpd;
+ if (depth && (*depth == DEPTH_INVALID)) {
+ depth = NULL;
+ }
/* in 3d-space - pt->x/y/z are 3 side-by-side floats */
if (gpd->runtime.sbuffer_sflag & GP_STROKE_3DSPACE) {
@@ -1126,7 +1129,7 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p)
/* find first valid contact point */
for (i = 0; i < gpd->runtime.sbuffer_used; i++) {
- if (depth_arr[i] != FLT_MAX) {
+ if (depth_arr[i] != DEPTH_INVALID) {
break;
}
}
@@ -1138,7 +1141,7 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p)
}
else {
for (i = gpd->runtime.sbuffer_used - 1; i >= 0; i--) {
- if (depth_arr[i] != FLT_MAX) {
+ if (depth_arr[i] != DEPTH_INVALID) {
break;
}
}
@@ -1148,14 +1151,14 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p)
* first and last contact in an imaginary line between them */
for (i = 0; i < gpd->runtime.sbuffer_used; i++) {
if (!ELEM(i, first_valid, last_valid)) {
- depth_arr[i] = FLT_MAX;
+ depth_arr[i] = DEPTH_INVALID;
}
}
interp_depth = true;
}
if (interp_depth) {
- interp_sparse_array(depth_arr, gpd->runtime.sbuffer_used, FLT_MAX);
+ interp_sparse_array(depth_arr, gpd->runtime.sbuffer_used, DEPTH_INVALID);
}
}
}
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index 7382aca9a87..8157e9d8fe7 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -841,7 +841,7 @@ static void gpencil_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
/* find first valid contact point */
int i;
for (i = 0; i < gps->totpoints; i++) {
- if (depth_arr[i] != FLT_MAX) {
+ if (depth_arr[i] != DEPTH_INVALID) {
break;
}
}
@@ -853,7 +853,7 @@ static void gpencil_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
}
else {
for (i = gps->totpoints - 1; i >= 0; i--) {
- if (depth_arr[i] != FLT_MAX) {
+ if (depth_arr[i] != DEPTH_INVALID) {
break;
}
}
@@ -864,14 +864,14 @@ static void gpencil_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
* first and last contact in an imaginary line between them */
for (i = 0; i < gps->totpoints; i++) {
if (!ELEM(i, first_valid, last_valid)) {
- depth_arr[i] = FLT_MAX;
+ depth_arr[i] = DEPTH_INVALID;
}
}
interp_depth = true;
}
if (interp_depth) {
- interp_sparse_array(depth_arr, gps->totpoints, FLT_MAX);
+ interp_sparse_array(depth_arr, gps->totpoints, DEPTH_INVALID);
}
}
}
@@ -1041,7 +1041,7 @@ static void gpencil_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi)
gpd->runtime.sbuffer, &gpd->runtime.sbuffer_size, &gpd->runtime.sbuffer_used, false);
/* add small offset to keep stroke over the surface */
- if ((depth_arr) && (gpd->zdepth_offset > 0.0f)) {
+ if ((depth_arr) && (gpd->zdepth_offset > 0.0f) && (depth_arr[i] != DEPTH_INVALID)) {
depth_arr[i] *= (1.0f - (gpd->zdepth_offset / 1000.0f));
}
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 86df452f49a..99cf2b52df7 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -991,6 +991,10 @@ void gpencil_stroke_convertcoords_tpoint(Scene *scene,
{
ToolSettings *ts = scene->toolsettings;
+ if (depth && (*depth == DEPTH_INVALID)) {
+ depth = NULL;
+ }
+
int mval_i[2];
round_v2i_v2fl(mval_i, &point2D->x);
diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c
index d6a1cd930fc..f01955a6468 100644
--- a/source/blender/editors/space_view3d/view3d_utils.c
+++ b/source/blender/editors/space_view3d/view3d_utils.c
@@ -1127,7 +1127,7 @@ bool ED_view3d_depth_read_cached_seg(
data.vd = vd;
data.margin = margin;
- data.depth = FLT_MAX;
+ data.depth = 1.0f;
copy_v2_v2_int(p1, mval_sta);
copy_v2_v2_int(p2, mval_end);
@@ -1136,7 +1136,7 @@ bool ED_view3d_depth_read_cached_seg(
*depth = data.depth;
- return (*depth != FLT_MAX);
+ return (*depth != 1.0f);
}
/** \} */
@@ -1647,6 +1647,9 @@ bool ED_view3d_depth_read_cached(const ViewDepths *vd,
int margin,
float *r_depth)
{
+ BLI_assert(1.0 <= vd->depth_range[1]);
+ *r_depth = 1.0f;
+
if (!vd || !vd->depths) {
return false;
}
@@ -1676,15 +1679,11 @@ bool ED_view3d_depth_read_cached(const ViewDepths *vd,
depth = vd->depths[y * vd->w + x];
}
- BLI_assert(1.0 <= vd->depth_range[1]);
if (depth != 1.0f) {
*r_depth = depth;
return true;
}
- /* Grease-pencil and annotations also need the returned depth value to be high
- * so the caller can detect it's invalid. */
- *r_depth = FLT_MAX;
return false;
}