[Bf-blender-cvs] [d9e71d5] master: Fix uninitialized vars in DistanceKey node

2015-08-31 Thread Campbell Barton
Commit: d9e71d5e16ae3ff8e96dbaa72d9ee03b03b3c8e4
Author: Campbell Barton
Date:   Mon Aug 31 16:12:14 2015 +1000
Branches: master
https://developer.blender.org/rBd9e71d5e16ae3ff8e96dbaa72d9ee03b03b3c8e4

Fix uninitialized vars in DistanceKey node

===

M   source/blender/compositor/nodes/COM_DistanceMatteNode.cpp

===

diff --git a/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp 
b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
index 5f3feda..4f3ab60 100644
--- a/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
@@ -66,6 +66,8 @@ void DistanceMatteNode::convertToOperations(NodeConverter 
, const Comp

ConvertRGBToYCCOperation *operationYCCImage = new 
ConvertRGBToYCCOperation();
ConvertRGBToYCCOperation *operationYCCMatte = new 
ConvertRGBToYCCOperation();
+   operationYCCImage->setMode(0);  /* BLI_YCC_ITU_BT601 */
+   operationYCCMatte->setMode(0);  /* BLI_YCC_ITU_BT601 */
converter.addOperation(operationYCCImage);
converter.addOperation(operationYCCMatte);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [d267739] master: Fix incorrect cast

2015-08-31 Thread Campbell Barton
Commit: d267739be7f6f95b9c0af99571e818c9adde6cd2
Author: Campbell Barton
Date:   Mon Aug 31 13:47:32 2015 +1000
Branches: master
https://developer.blender.org/rBd267739be7f6f95b9c0af99571e818c9adde6cd2

Fix incorrect cast

===

M   source/blender/compositor/nodes/COM_ChannelMatteNode.cpp

===

diff --git a/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp 
b/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
index cf0f471..aa93016 100644
--- a/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp
@@ -55,7 +55,7 @@ void ChannelMatteNode::convertToOperations(NodeConverter 
, const Compo
convert = new ConvertRGBToYCCOperation();
((ConvertRGBToYCCOperation *)convert)->setMode(0); /* 
BLI_YCC_ITU_BT601 */
inv_convert = new ConvertYCCToRGBOperation();
-   ((ConvertRGBToYCCOperation *)inv_convert)->setMode(0); 
/* BLI_YCC_ITU_BT601 */
+   ((ConvertYCCToRGBOperation *)inv_convert)->setMode(0); 
/* BLI_YCC_ITU_BT601 */
break;
default:
break;

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [489a5d3] master: Fix T45959: DistanceKey output incorrect

2015-08-31 Thread Campbell Barton
Commit: 489a5d34b7bf84141696e99274a4cbd7425a9b7b
Author: Campbell Barton
Date:   Mon Aug 31 16:20:21 2015 +1000
Branches: master
https://developer.blender.org/rB489a5d34b7bf84141696e99274a4cbd7425a9b7b

Fix T45959: DistanceKey output incorrect

===

M   source/blender/compositor/nodes/COM_DistanceMatteNode.cpp

===

diff --git a/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp 
b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
index 4f3ab60..c617ecb 100644
--- a/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
+++ b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp
@@ -81,10 +81,20 @@ void DistanceMatteNode::convertToOperations(NodeConverter 
, const Comp
operation = matte;
}

+   converter.mapOutputSocket(outputSocketMatte, 
operation->getOutputSocket(0));
converter.addLink(operation->getOutputSocket(), 
operationAlpha->getInputSocket(1));

-   converter.mapOutputSocket(outputSocketMatte, 
operation->getOutputSocket());
-   converter.mapOutputSocket(outputSocketImage, 
operationAlpha->getOutputSocket());
+   if (storage->channel != 1) {
+   ConvertYCCToRGBOperation *inv_convert = new 
ConvertYCCToRGBOperation();
+   inv_convert->setMode(0); /* BLI_YCC_ITU_BT601 */
+
+   converter.addOperation(inv_convert);
+   converter.addLink(operationAlpha->getOutputSocket(0), 
inv_convert->getInputSocket(0));
+   converter.mapOutputSocket(outputSocketImage, 
inv_convert->getOutputSocket());
+   }
+   else {
+   converter.mapOutputSocket(outputSocketImage, 
operationAlpha->getOutputSocket());
+   }

converter.addPreview(operationAlpha->getOutputSocket());
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [929db33] master: Write thumbnail directly

2015-08-31 Thread Campbell Barton
Commit: 929db33828fa86927da2996fa606ecfe522dd677
Author: Campbell Barton
Date:   Tue Sep 1 01:52:27 2015 +1000
Branches: master
https://developer.blender.org/rB929db33828fa86927da2996fa606ecfe522dd677

Write thumbnail directly

BlendThumbnail matches the on-disk format, so just write directly.

===

M   source/blender/blenloader/intern/writefile.c

===

diff --git a/source/blender/blenloader/intern/writefile.c 
b/source/blender/blenloader/intern/writefile.c
index 94f3237..6f7157e 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -3691,14 +3691,7 @@ static void write_global(WriteData *wd, int fileflags, 
Main *mainvar)
 static void write_thumb(WriteData *wd, const BlendThumbnail *thumb)
 {
if (thumb) {
-   size_t sz = BLEN_THUMB_MEMSIZE_FILE(thumb->width, 
thumb->height);
-   int *img = alloca(sz);
-
-   BLI_assert((sz - (sizeof(*img) * 2)) == 
(BLEN_THUMB_MEMSIZE(thumb->width, thumb->height) - sizeof(thumb)));
-   img[0] = thumb->width;
-   img[1] = thumb->height;
-   memcpy([2], thumb->rect, sz - (sizeof(*img) * 2));
-   writedata(wd, TEST, sz, img);
+   writedata(wd, TEST, BLEN_THUMB_MEMSIZE_FILE(thumb->width, 
thumb->height), thumb);
}
 }

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [26bad9e] master: Cleanup: Fix some typos in volume code comments.

2015-08-31 Thread Thomas Dinges
Commit: 26bad9e8f040f5fd4fc4f1f438e3e418069ce30f
Author: Thomas Dinges
Date:   Mon Aug 31 18:08:55 2015 +0200
Branches: master
https://developer.blender.org/rB26bad9e8f040f5fd4fc4f1f438e3e418069ce30f

Cleanup: Fix some typos in volume code comments.

===

M   intern/cycles/kernel/kernel_volume.h

===

diff --git a/intern/cycles/kernel/kernel_volume.h 
b/intern/cycles/kernel/kernel_volume.h
index 27c0b44..0a74a9d 100644
--- a/intern/cycles/kernel/kernel_volume.h
+++ b/intern/cycles/kernel/kernel_volume.h
@@ -374,7 +374,7 @@ ccl_device VolumeIntegrateResult 
kernel_volume_integrate_homogeneous(KernelGloba
/* distance sampling */
sample_t = kernel_volume_distance_sample(ray->t, 
sigma_t, channel, xi, , );
 
-   /* modifiy pdf for hit/miss decision */
+   /* modify pdf for hit/miss decision */
if(probalistic_scatter)
pdf *= make_float3(1.0f, 1.0f, 1.0f) - 
volume_color_transmittance(sigma_t, t);
 
@@ -422,7 +422,7 @@ ccl_device VolumeIntegrateResult 
kernel_volume_integrate_homogeneous(KernelGloba
 
 /* heterogeneous volume distance sampling: integrate stepping through the
  * volume until we reach the end, get absorbed entirely, or run out of
- * iterations. this does probalistically scatter or get transmitted through
+ * iterations. this does probabilistically scatter or get transmitted through
  * for path tracing where we don't want to branch. */
 ccl_device VolumeIntegrateResult 
kernel_volume_integrate_heterogeneous_distance(KernelGlobals *kg,
PathState *state, Ray *ray, ShaderData *sd, PathRadiance *L, float3 
*throughput, RNG *rng)
@@ -610,7 +610,7 @@ typedef struct VolumeSegment {
 /* record volume steps to the end of the volume.
  *
  * it would be nice if we could only record up to the point that we need to 
scatter,
- * but the entire segment is needed to do always scattering, rather than 
probalistically
+ * but the entire segment is needed to do always scattering, rather than 
probabilistically
  * hitting or missing the volume. if we don't know the transmittance at the 
end of the
  * volume we can't generate stratified distance samples up to that 
transmittance */
 ccl_device void kernel_volume_decoupled_record(KernelGlobals *kg, PathState 
*state,
@@ -766,7 +766,7 @@ ccl_device VolumeIntegrateResult 
kernel_volume_decoupled_scatter(
sd->randb_closure = rphase*3.0f - channel;
float xi = rscatter;
 
-   /* probalistic scattering decision based on transmittance */
+   /* probabilistic scattering decision based on transmittance */
if(probalistic_scatter) {
float sample_transmittance = 
kernel_volume_channel_get(segment->accum_transmittance, channel);
 
@@ -846,7 +846,7 @@ ccl_device VolumeIntegrateResult 
kernel_volume_decoupled_scatter(
float3 distance_pdf;
sample_t = prev_t + kernel_volume_distance_sample(step_t, 
step->sigma_t, channel, xi, , _pdf);
 
-   /* modifiy pdf for hit/miss decision */
+   /* modify pdf for hit/miss decision */
if(probalistic_scatter)
distance_pdf *= make_float3(1.0f, 1.0f, 1.0f) - 
segment->accum_transmittance;
 
@@ -942,7 +942,7 @@ ccl_device VolumeIntegrateResult 
kernel_volume_decoupled_scatter(
 /* decide if we need to use decoupled or not */
 ccl_device bool kernel_volume_use_decoupled(KernelGlobals *kg, bool 
heterogeneous, bool direct, int sampling_method)
 {
-   /* decoupled ray marching for heterogenous volumes not supported on the 
GPU,
+   /* decoupled ray marching for heterogeneous volumes not supported on 
the GPU,
 * which also means equiangular and multiple importance sampling is not
 * support for that case */
 #ifdef __KERNEL_GPU__

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [879c5d4] master: Cycles: Make the max value for World MIS Map Resolution a power of two.

2015-08-31 Thread Thomas Dinges
Commit: 879c5d4568ee6651d73ae3b31541f5ed17b9f0a1
Author: Thomas Dinges
Date:   Mon Aug 31 18:17:16 2015 +0200
Branches: master
https://developer.blender.org/rB879c5d4568ee6651d73ae3b31541f5ed17b9f0a1

Cycles: Make the max value for World MIS Map Resolution a power of two.

Old value likely was a copy / paste error.

===

M   intern/cycles/blender/addon/properties.py

===

diff --git a/intern/cycles/blender/addon/properties.py 
b/intern/cycles/blender/addon/properties.py
index 3417435..23d0d85 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -743,7 +743,7 @@ class CyclesWorldSettings(bpy.types.PropertyGroup):
 name="Map Resolution",
 description="Importance map size is resolution x resolution; "
 "higher values potentially produce less noise, at 
the cost of memory and speed",
-min=4, max=8096,
+min=4, max=8192,
 default=256,
 )
 cls.samples = IntProperty(

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [705776d] master: Fix T45954: Inset w/ interpolated vertex color

2015-08-31 Thread Campbell Barton
Commit: 705776db1fbaa5a7563d7efae89f0c984afdea6d
Author: Campbell Barton
Date:   Tue Sep 1 02:48:28 2015 +1000
Branches: master
https://developer.blender.org/rB705776db1fbaa5a7563d7efae89f0c984afdea6d

Fix T45954: Inset w/ interpolated vertex color

Accumulating ubyte color was overflowing.

Thanks to @mont29 for suggested fix.

===

M   source/blender/bmesh/operators/bmo_inset.c

===

diff --git a/source/blender/bmesh/operators/bmo_inset.c 
b/source/blender/bmesh/operators/bmo_inset.c
index 6664bf6..f55a62e 100644
--- a/source/blender/bmesh/operators/bmo_inset.c
+++ b/source/blender/bmesh/operators/bmo_inset.c
@@ -208,18 +208,11 @@ static void bm_loop_customdata_merge(
 */
const void *data_src;
 
-   CustomData_data_add(
+   CustomData_data_mix_value(
type,
BM_ELEM_CD_GET_VOID_P(l_a_inner_inset, offset),
-   BM_ELEM_CD_GET_VOID_P(l_b_inner_inset, offset));
-   CustomData_data_multiply(
-   type,
-   BM_ELEM_CD_GET_VOID_P(l_a_inner_inset, offset),
-   0.5f);
-   CustomData_data_copy_value(
-   type,
-   BM_ELEM_CD_GET_VOID_P(l_a_inner_inset, offset),
-   BM_ELEM_CD_GET_VOID_P(l_b_inner_inset, offset));
+   BM_ELEM_CD_GET_VOID_P(l_b_inner_inset, offset),
+   CDT_MIX_MIX, 0.5f);
 
/* use this as a reference (could be 'l_b_inner_inset' 
too) */
data_src = BM_ELEM_CD_GET_VOID_P(l_a_inner_inset, 
offset);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [0018483] master: error in last commit

2015-08-31 Thread Campbell Barton
Commit: 0018483dfaf96af569fad40bed6f47389ef3358f
Author: Campbell Barton
Date:   Tue Sep 1 03:02:14 2015 +1000
Branches: master
https://developer.blender.org/rB0018483dfaf96af569fad40bed6f47389ef3358f

error in last commit

===

M   source/blender/bmesh/operators/bmo_inset.c

===

diff --git a/source/blender/bmesh/operators/bmo_inset.c 
b/source/blender/bmesh/operators/bmo_inset.c
index f55a62e..118a19d 100644
--- a/source/blender/bmesh/operators/bmo_inset.c
+++ b/source/blender/bmesh/operators/bmo_inset.c
@@ -213,6 +213,10 @@ static void bm_loop_customdata_merge(
BM_ELEM_CD_GET_VOID_P(l_a_inner_inset, offset),
BM_ELEM_CD_GET_VOID_P(l_b_inner_inset, offset),
CDT_MIX_MIX, 0.5f);
+   CustomData_data_copy_value(
+   type,
+   BM_ELEM_CD_GET_VOID_P(l_a_inner_inset, offset),
+   BM_ELEM_CD_GET_VOID_P(l_b_inner_inset, offset));
 
/* use this as a reference (could be 'l_b_inner_inset' 
too) */
data_src = BM_ELEM_CD_GET_VOID_P(l_a_inner_inset, 
offset);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [333feea] master: Fix T45258, impossible to select brush when removing it from 2d painting.

2015-08-31 Thread Antony Riakiotakis
Commit: 333feea6e9450379f5314f327cf1ac1aef6d8a07
Author: Antony Riakiotakis
Date:   Mon Aug 31 21:37:38 2015 +0300
Branches: master
https://developer.blender.org/rB333feea6e9450379f5314f327cf1ac1aef6d8a07

Fix T45258, impossible to select brush when removing it from 2d
painting.

Also system added a brush every time it found no paint brush in the
system which is not what we would want.

Solution:
* Brush panel stays visible always, regardless of whether there is a
brush or not.
* We search for first available brush when we find no brush in paint
struct instead of always generating a new one.
* Generating and searching for a brush take a mode argument now. Needed
some refactoring to users of BKE_paint_init as well.
* Did some style cleanups for paint mode enums.

Patch is big but it's mostly argument refactoring.

===

M   release/scripts/startup/bl_ui/space_image.py
M   source/blender/blenkernel/BKE_brush.h
M   source/blender/blenkernel/BKE_paint.h
M   source/blender/blenkernel/intern/brush.c
M   source/blender/blenkernel/intern/paint.c
M   source/blender/blenloader/intern/versioning_defaults.c
M   source/blender/editors/include/ED_image.h
M   source/blender/editors/object/object_edit.c
M   source/blender/editors/sculpt_paint/paint_cursor.c
M   source/blender/editors/sculpt_paint/paint_curve.c
M   source/blender/editors/sculpt_paint/paint_image.c
M   source/blender/editors/sculpt_paint/paint_ops.c
M   source/blender/editors/sculpt_paint/paint_stroke.c
M   source/blender/editors/sculpt_paint/paint_vertex.c
M   source/blender/editors/sculpt_paint/sculpt.c
M   source/blender/editors/sculpt_paint/sculpt_uv.c
M   source/blender/editors/util/ed_util.c
M   source/blender/makesrna/intern/rna_brush.c
M   source/blender/makesrna/intern/rna_main_api.c
M   source/blender/makesrna/intern/rna_scene.c
M   source/blender/makesrna/intern/rna_space.c

===

diff --git a/release/scripts/startup/bl_ui/space_image.py 
b/release/scripts/startup/bl_ui/space_image.py
index 80796cd..53209a6 100644
--- a/release/scripts/startup/bl_ui/space_image.py
+++ b/release/scripts/startup/bl_ui/space_image.py
@@ -705,7 +705,7 @@ class IMAGE_PT_tools_transform_uvs(Panel, UVToolsPanel):
 col.operator("transform.shear")
 
 
-class IMAGE_PT_paint(Panel, BrushButtonsPanel):
+class IMAGE_PT_paint(Panel, ImagePaintPanel):
 bl_label = "Paint"
 bl_category = "Tools"
 
@@ -721,6 +721,11 @@ class IMAGE_PT_paint(Panel, BrushButtonsPanel):
 if brush:
 brush_texpaint_common(self, context, layout, brush, settings)
 
+@classmethod
+def poll(cls, context):
+sima = context.space_data
+toolsettings = context.tool_settings.image_paint
+return sima.show_paint
 
 class IMAGE_PT_tools_brush_overlay(BrushButtonsPanel, Panel):
 bl_label = "Overlay"
diff --git a/source/blender/blenkernel/BKE_brush.h 
b/source/blender/blenkernel/BKE_brush.h
index 042fba7..aff3fb0 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -40,7 +40,8 @@ void BKE_brush_system_init(void);
 void BKE_brush_system_exit(void);
 
 /* datablock functions */
-struct Brush *BKE_brush_add(struct Main *bmain, const char *name);
+struct Brush *BKE_brush_add(struct Main *bmain, const char *name, short 
ob_mode);
+struct Brush *BKE_brush_first_search(struct Main *bmain, short ob_mode);
 struct Brush *BKE_brush_copy(struct Brush *brush);
 void BKE_brush_make_local(struct Brush *brush);
 void BKE_brush_free(struct Brush *brush);
diff --git a/source/blender/blenkernel/BKE_paint.h 
b/source/blender/blenkernel/BKE_paint.h
index c9192fd..bf1cfb2 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -66,13 +66,13 @@ extern const char PAINT_CURSOR_WEIGHT_PAINT[3];
 extern const char PAINT_CURSOR_TEXTURE_PAINT[3];
 
 typedef enum PaintMode {
-   PAINT_SCULPT = 0,
-   PAINT_VERTEX = 1,
-   PAINT_WEIGHT = 2,
-   PAINT_TEXTURE_PROJECTIVE = 3,
-   PAINT_TEXTURE_2D = 4,
-   PAINT_SCULPT_UV = 5,
-   PAINT_INVALID = 6
+   ePaintSculpt = 0,
+   ePaintVertex = 1,
+   ePaintWeight = 2,
+   ePaintTextureProjective = 3,
+   ePaintTexture2D = 4,
+   ePaintSculptUV = 5,
+   ePaintInvalid = 6
 } PaintMode;
 
 /* overlay invalidation */
@@ -108,12 +108,14 @@ void BKE_palette_clear(struct Palette 
*palette);
 struct PaintCurve *BKE_paint_curve_add(struct Main *bmain, const char *name);
 void BKE_paint_curve_free(struct PaintCurve *pc);
 
-void BKE_paint_init(struct UnifiedPaintSettings *ups, struct Paint *p, const 
char col[3]);
+void BKE_paint_init(struct Scene *sce, PaintMode mode, const char col[3]);
 void BKE_paint_free(struct Paint *p);
 void BKE_paint_copy(struct Paint *src, struct Paint 

[Bf-blender-cvs] [b3f4bf8] master: Trade-marked BPlayer Fix (c)

2015-08-31 Thread Bastien Montagne
Commit: b3f4bf87b4f01eb9f5006942d213e2411054c8aa
Author: Bastien Montagne
Date:   Mon Aug 31 22:03:51 2015 +0200
Branches: master
https://developer.blender.org/rBb3f4bf87b4f01eb9f5006942d213e2411054c8aa

Trade-marked BPlayer Fix (c)

===

M   source/blenderplayer/bad_level_call_stubs/stubs.c

===

diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c 
b/source/blenderplayer/bad_level_call_stubs/stubs.c
index 5e5e29a..657a1c5 100644
--- a/source/blenderplayer/bad_level_call_stubs/stubs.c
+++ b/source/blenderplayer/bad_level_call_stubs/stubs.c
@@ -353,9 +353,9 @@ struct ListBase *get_constraint_lb(struct Object *ob, 
struct bConstraint *con, s
 bool ED_space_image_show_uvedit(struct SpaceImage *sima, struct Object 
*obedit) RET_ZERO
 bool ED_space_image_show_render(struct SpaceImage *sima) RET_ZERO
 bool ED_space_image_show_paint(struct SpaceImage *sima) RET_ZERO
-void ED_space_image_paint_update(struct wmWindowManager *wm, struct 
ToolSettings *settings) RET_NONE
+void ED_space_image_paint_update(struct wmWindowManager *wm, struct Scene 
*scene) RET_NONE
 void ED_space_image_set(struct SpaceImage *sima, struct Scene *scene, struct 
Object *obedit, struct Image *ima) RET_NONE
-void ED_space_image_uv_sculpt_update(struct wmWindowManager *wm, struct 
ToolSettings *settings) RET_NONE
+void ED_space_image_uv_sculpt_update(struct wmWindowManager *wm, struct Scene 
*scene) RET_NONE
 void ED_space_image_scopes_update(const struct bContext *C, struct SpaceImage 
*sima, struct ImBuf *ibuf, bool use_view_settings) RET_NONE
 
 void ED_uvedit_get_aspect(struct Scene *scene, struct Object *ob, struct BMesh 
*em, float *aspx, float *aspy) RET_NONE

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [54fd4ec] GPencil_Editing_Stage3: Compile fix for changes from master

2015-08-31 Thread Joshua Leung
Commit: 54fd4ec960672a08356c194d21c01a650d91cf2b
Author: Joshua Leung
Date:   Tue Sep 1 12:16:00 2015 +1200
Branches: GPencil_Editing_Stage3
https://developer.blender.org/rB54fd4ec960672a08356c194d21c01a650d91cf2b

Compile fix for changes from master

===

M   source/blender/editors/gpencil/gpencil_brush.c

===

diff --git a/source/blender/editors/gpencil/gpencil_brush.c 
b/source/blender/editors/gpencil/gpencil_brush.c
index 3c2371e2..4502c95 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -44,7 +44,7 @@
 #include "BLI_rand.h"
 #include "BLI_utildefines.h"
 
-#include "BLF_translation.h"
+#include "BLT_translation.h"
 
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [922d723] master: Cleanup: pep8

2015-08-31 Thread Campbell Barton
Commit: 922d72355dc23698b87e3f16b062e9889d8ba942
Author: Campbell Barton
Date:   Tue Sep 1 03:51:50 2015 +1000
Branches: master
https://developer.blender.org/rB922d72355dc23698b87e3f16b062e9889d8ba942

Cleanup: pep8

===

M   intern/cycles/blender/addon/engine.py
M   release/scripts/modules/bl_previews_utils/bl_previews_render.py
M   release/scripts/modules/nodeitems_utils.py
M   release/scripts/modules/progress_report.py
M   release/scripts/startup/bl_operators/file.py
M   release/scripts/startup/bl_ui/properties_freestyle.py
M   release/scripts/startup/bl_ui/space_filebrowser.py
M   release/scripts/startup/bl_ui/space_image.py
M   release/scripts/startup/bl_ui/space_time.py
M   release/scripts/startup/bl_ui/space_view3d.py
M   release/scripts/startup/bl_ui/space_view3d_toolbar.py

===

diff --git a/intern/cycles/blender/addon/engine.py 
b/intern/cycles/blender/addon/engine.py
index c936b90..2bfac3c 100644
--- a/intern/cycles/blender/addon/engine.py
+++ b/intern/cycles/blender/addon/engine.py
@@ -49,6 +49,7 @@ def _workaround_buggy_drivers():
 print("Cycles: OpenGL driver known to be buggy, disabling OpenCL 
platform.")
 _cycles.opencl_disable()
 
+
 def init():
 import bpy
 import _cycles
diff --git a/release/scripts/modules/bl_previews_utils/bl_previews_render.py 
b/release/scripts/modules/bl_previews_utils/bl_previews_render.py
index d53fc3e..27922c6 100644
--- a/release/scripts/modules/bl_previews_utils/bl_previews_render.py
+++ b/release/scripts/modules/bl_previews_utils/bl_previews_render.py
@@ -41,7 +41,7 @@ def rna_backup_gen(data, include_props=None, 
exclude_props=None, root=()):
 # only writable properties...
 for p in data.bl_rna.properties:
 pid = p.identifier
-if pid in {'rna_type',}:
+if pid in {'rna_type', }:
 continue
 path = root + (pid,)
 if include_props is not None and path not in include_props:
diff --git a/release/scripts/modules/nodeitems_utils.py 
b/release/scripts/modules/nodeitems_utils.py
index 1cc9afc..be6f031 100644
--- a/release/scripts/modules/nodeitems_utils.py
+++ b/release/scripts/modules/nodeitems_utils.py
@@ -85,6 +85,7 @@ class NodeItemCustom:
 
 _node_categories = {}
 
+
 def register_node_categories(identifier, cat_list):
 if identifier in _node_categories:
 raise KeyError("Node categories list '%s' already registered" % 
identifier)
@@ -167,6 +168,7 @@ def unregister_node_categories(identifier=None):
 unregister_node_cat_types(cat_types)
 _node_categories.clear()
 
+
 def draw_node_categories_menu(self, context):
 for cats in _node_categories.values():
 cats[1](self, context)
diff --git a/release/scripts/modules/progress_report.py 
b/release/scripts/modules/progress_report.py
index 0d1f4f2..578eb96 100644
--- a/release/scripts/modules/progress_report.py
+++ b/release/scripts/modules/progress_report.py
@@ -20,6 +20,7 @@
 
 import time
 
+
 class ProgressReport:
 """
 A basic 'progress report' using either simple prints in console, or 
WindowManager's 'progress' API.
diff --git a/release/scripts/startup/bl_operators/file.py 
b/release/scripts/startup/bl_operators/file.py
index a6a6982..efcc7d5 100644
--- a/release/scripts/startup/bl_operators/file.py
+++ b/release/scripts/startup/bl_operators/file.py
@@ -28,6 +28,7 @@ from bpy.props import (
 
 # ## Datablock previews... ##
 
+
 class WM_OT_previews_batch_generate(Operator):
 """Generate selected .blend file's previews"""
 bl_idname = "wm.previews_batch_generate"
diff --git a/release/scripts/startup/bl_ui/properties_freestyle.py 
b/release/scripts/startup/bl_ui/properties_freestyle.py
index f58a698..e062044 100644
--- a/release/scripts/startup/bl_ui/properties_freestyle.py
+++ b/release/scripts/startup/bl_ui/properties_freestyle.py
@@ -381,7 +381,6 @@ class 
RENDERLAYER_PT_freestyle_linestyle(RenderLayerFreestyleEditorButtonsPanel,
 message = "Enable Face Smoothness to use this modifier"
 self.draw_modifier_box_error(col.box(), modifier, message)
 
-
 def draw_alpha_modifier(self, context, modifier):
 layout = self.layout
 
@@ -496,7 +495,6 @@ class 
RENDERLAYER_PT_freestyle_linestyle(RenderLayerFreestyleEditorButtonsPanel,
 row.prop(modifier, "angle_min")
 row.prop(modifier, "angle_max")
 
-
 elif modifier.type == 'CURVATURE_3D':
 self.draw_modifier_curve_common(box, modifier, False, False)
 row = box.row(align=True)
@@ -510,7 +508,6 @@ class 
RENDERLAYER_PT_freestyle_linestyle(RenderLayerFreestyleEditorButtonsPanel,
 message = "Enable Face Smoothness to use this modifier"
 self.draw_modifier_box_error(col.box(), 

[Bf-blender-cvs] [c86a519] master: Use qsort_r for BMesh Py API

2015-08-31 Thread Campbell Barton
Commit: c86a519898a04207dfe141414dda33953a98a7f5
Author: Campbell Barton
Date:   Tue Sep 1 13:56:08 2015 +1000
Branches: master
https://developer.blender.org/rBc86a519898a04207dfe141414dda33953a98a7f5

Use qsort_r for BMesh Py API

===

M   source/blender/python/bmesh/bmesh_py_types.c

===

diff --git a/source/blender/python/bmesh/bmesh_py_types.c 
b/source/blender/python/bmesh/bmesh_py_types.c
index 728332d..c4d11fb 100644
--- a/source/blender/python/bmesh/bmesh_py_types.c
+++ b/source/blender/python/bmesh/bmesh_py_types.c
@@ -27,9 +27,8 @@
  *  \ingroup pybmesh
  */
 
-#include 
-
 #include "BLI_math.h"
+#include "BLI_sort.h"
 
 #include "DNA_mesh_types.h"
 #include "DNA_object_types.h"
@@ -41,6 +40,8 @@
 
 #include "bmesh.h"
 
+#include 
+
 #include "../mathutils/mathutils.h"
 
 #include "../generic/py_capi_utils.h"
@@ -2455,10 +2456,10 @@ PyDoc_STRVAR(bpy_bmelemseq_sort_doc,
  * Note: the functions below assumes the keys array has been allocated and it
  * has enough elements to complete the task.
  */
-static double *keys = NULL;
 
-static int bpy_bmelemseq_sort_cmp_by_keys_ascending(const void *index1_v, 
const void *index2_v)
+static int bpy_bmelemseq_sort_cmp_by_keys_ascending(const void *index1_v, 
const void *index2_v, void *keys_v)
 {
+   const double *keys = keys_v;
const int *index1 = (int *)index1_v;
const int *index2 = (int *)index2_v;
 
@@ -2467,9 +2468,9 @@ static int bpy_bmelemseq_sort_cmp_by_keys_ascending(const 
void *index1_v, const
elsereturn 0;
 }
 
-static int bpy_bmelemseq_sort_cmp_by_keys_descending(const void *index1_v, 
const void *index2_v)
+static int bpy_bmelemseq_sort_cmp_by_keys_descending(const void *index1_v, 
const void *index2_v, void *keys_v)
 {
-   return -bpy_bmelemseq_sort_cmp_by_keys_ascending(index1_v, index2_v);
+   return -bpy_bmelemseq_sort_cmp_by_keys_ascending(index1_v, index2_v, 
keys_v);
 }
 
 static PyObject *bpy_bmelemseq_sort(BPy_BMElemSeq *self, PyObject *args, 
PyObject *kw)
@@ -2484,9 +2485,10 @@ static PyObject *bpy_bmelemseq_sort(BPy_BMElemSeq *self, 
PyObject *args, PyObjec
BMIter iter;
BMElem *ele;
 
+   double *keys;
int *elem_idx;
unsigned int *elem_map_idx;
-   int (*elem_idx_compare_by_keys)(const void *, const void *);
+   int (*elem_idx_compare_by_keys)(const void *, const void *, void *);
 
unsigned int *vert_idx = NULL;
unsigned int *edge_idx = NULL;
@@ -2577,7 +2579,7 @@ static PyObject *bpy_bmelemseq_sort(BPy_BMElemSeq *self, 
PyObject *args, PyObjec
else
elem_idx_compare_by_keys = 
bpy_bmelemseq_sort_cmp_by_keys_ascending;
 
-   qsort(elem_idx, n_elem, sizeof(*elem_idx), elem_idx_compare_by_keys);
+   BLI_qsort_r(elem_idx, n_elem, sizeof(*elem_idx), 
elem_idx_compare_by_keys, keys);
 
elem_map_idx = PyMem_MALLOC(sizeof(*elem_map_idx) * n_elem);
if (elem_map_idx == NULL) {

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [96fa58e] master: Math Lib: Add closest_to_plane helper functions

2015-08-31 Thread Campbell Barton
Commit: 96fa58e22cde8329bfc5639f9a68c85be9473b1d
Author: Campbell Barton
Date:   Mon Aug 31 20:05:49 2015 +1000
Branches: master
https://developer.blender.org/rB96fa58e22cde8329bfc5639f9a68c85be9473b1d

Math Lib: Add closest_to_plane helper functions

- closest_to_plane3 (for float3 planes)
- closest_to_plane*_normalized_v3 (for unit length planes)

Use when the plane is known to be unit length

===

M   source/blender/blenlib/BLI_math_geom.h
M   source/blender/blenlib/intern/math_geom.c
M   source/blender/bmesh/operators/bmo_planar_faces.c
M   source/blender/bmesh/tools/bmesh_bevel.c
M   source/blender/editors/object/object_vgroup.c

===

diff --git a/source/blender/blenlib/BLI_math_geom.h 
b/source/blender/blenlib/BLI_math_geom.h
index 1a25f9f..c4bb3cc 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -119,7 +119,10 @@ float dist_signed_squared_to_corner_v3v3v3(
 float closest_to_line_v3(float r[3], const float p[3], const float l1[3], 
const float l2[3]);
 float closest_to_line_v2(float r[2], const float p[2], const float l1[2], 
const float l2[2]);
 void closest_to_line_segment_v3(float r_close[3], const float p[3], const 
float l1[3], const float l2[3]);
+void closest_to_plane_normalized_v3(float r_close[3], const float plane[4], 
const float pt[3]);
 void closest_to_plane_v3(float r_close[3], const float plane[4], const float 
pt[3]);
+void closest_to_plane3_normalized_v3(float r_close[3], const float plane[3], 
const float pt[3]);
+void closest_to_plane3_v3(float r_close[3], const float plane[3], const float 
pt[3]);
 
 /* Set 'r' to the point in triangle (t1, t2, t3) closest to point 'p' */
 void closest_on_tri_to_point_v3(float r[3], const float p[3], const float 
t1[3], const float t2[3], const float t3[3]);
diff --git a/source/blender/blenlib/intern/math_geom.c 
b/source/blender/blenlib/intern/math_geom.c
index 379c852..f7c2ad7 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -380,6 +380,27 @@ void closest_to_plane_v3(float r_close[3], const float 
plane[4], const float pt[
madd_v3_v3v3fl(r_close, pt, plane, -side / len_sq);
 }
 
+void closest_to_plane_normalized_v3(float r_close[3], const float plane[4], 
const float pt[3])
+{
+   const float side = plane_point_side_v3(plane, pt);
+   BLI_ASSERT_UNIT_V3(plane);
+   madd_v3_v3v3fl(r_close, pt, plane, -side);
+}
+
+void closest_to_plane3_v3(float r_close[3], const float plane[3], const float 
pt[3])
+{
+   const float len_sq = len_squared_v3(plane);
+   const float side = dot_v3v3(plane, pt);
+   madd_v3_v3v3fl(r_close, pt, plane, -side / len_sq);
+}
+
+void closest_to_plane3_normalized_v3(float r_close[3], const float plane[3], 
const float pt[3])
+{
+   const float side = dot_v3v3(plane, pt);
+   BLI_ASSERT_UNIT_V3(plane);
+   madd_v3_v3v3fl(r_close, pt, plane, -side);
+}
+
 float dist_signed_squared_to_plane_v3(const float pt[3], const float plane[4])
 {
const float len_sq = len_squared_v3(plane);
diff --git a/source/blender/bmesh/operators/bmo_planar_faces.c 
b/source/blender/bmesh/operators/bmo_planar_faces.c
index 4e3ac58..8849e49 100644
--- a/source/blender/bmesh/operators/bmo_planar_faces.c
+++ b/source/blender/bmesh/operators/bmo_planar_faces.c
@@ -117,7 +117,7 @@ void bmo_planar_faces_exec(BMesh *bm, BMOperator *op)
}
va = *va_p;
 
-   closest_to_plane_v3(co, plane, l_iter->v->co);
+   closest_to_plane_normalized_v3(co, plane, 
l_iter->v->co);
va->co_tot += 1;
 
interp_v3_v3v3(va->co, va->co, co, 1.0f / 
(float)va->co_tot);
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c 
b/source/blender/bmesh/tools/bmesh_bevel.c
index e20d4e6..c7f77a7 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -823,7 +823,7 @@ static void offset_meet(EdgeHalf *e1, EdgeHalf *e2, BMVert 
*v, BMFace *f, bool e
if (!ff)
continue;
plane_from_point_normal_v3(plane, 
v->co, ff->no);
-   closest_to_plane_v3(dropco, plane, 
meetco);
+   closest_to_plane_normalized_v3(dropco, 
plane, meetco);
if (point_between_edges(dropco, v, ff, 
e, e->next)) {
copy_v3_v3(meetco, dropco);
break;
diff --git a/source/blender/editors/object/object_vgroup.c 
b/source/blender/editors/object/object_vgroup.c
index 

[Bf-blender-cvs] [e503e37] master: Revert fix for T45849, alternate fix coming up

2015-08-31 Thread Campbell Barton
Commit: e503e37333bd5d9d409530448d767bcd709f4a5a
Author: Campbell Barton
Date:   Mon Aug 31 22:12:19 2015 +1000
Branches: master
https://developer.blender.org/rBe503e37333bd5d9d409530448d767bcd709f4a5a

Revert fix for T45849, alternate fix coming up

epsilon check here didn't account for scale, causing T45919

===

M   source/blender/blenlib/intern/math_geom.c

===

diff --git a/source/blender/blenlib/intern/math_geom.c 
b/source/blender/blenlib/intern/math_geom.c
index f7c2ad7..27b3f56 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -1955,7 +1955,7 @@ int isect_line_line_epsilon_v3(
div = dot_v3v3(ab, ab);
 
/* test zero length line */
-   if (UNLIKELY(div <= epsilon)) {
+   if (UNLIKELY(div == 0.0f)) {
return 0;
}
/* test if the two lines are coplanar */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [06b14aa] master: error in comments

2015-08-31 Thread Campbell Barton
Commit: 06b14aa5f9c961d7bdcf6f959bbb5e517633dc4e
Author: Campbell Barton
Date:   Mon Aug 31 22:24:34 2015 +1000
Branches: master
https://developer.blender.org/rB06b14aa5f9c961d7bdcf6f959bbb5e517633dc4e

error in comments

===

M   source/blender/blenlib/intern/math_geom.c

===

diff --git a/source/blender/blenlib/intern/math_geom.c 
b/source/blender/blenlib/intern/math_geom.c
index e12bebe..328bf55 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -1607,7 +1607,8 @@ bool isect_tri_tri_epsilon_v3(
/**
 * Implementation note: its simpler to project the triangles 
onto the intersection plane
 * before intersecting their edges with the ray, defined by 
'isect_plane_plane_v3'.
-* This way we can use 'line_point_factor_v3_ex' to see if an 
edge crosses 'co_proj'.
+* This way we can use 'line_point_factor_v3_ex' to see if an 
edge crosses 'co_proj',
+* then use the factor to calculate the world-space point.
 */
struct {
float min, max;
@@ -1621,7 +1622,7 @@ bool isect_tri_tri_epsilon_v3(
 
closest_to_plane3_normalized_v3(co_proj, plane_no, plane_co);
 
-   /* For both triangles, find the overlap with the line defined 
by the ray [co_proj, isect_no].
+   /* For both triangles, find the overlap with the line defined 
by the ray [co_proj, plane_no].
 * When the ranges overlap we know the triangles do too. */
for (t = 0; t < 2; t++) {
int j, j_prev;
@@ -1634,9 +1635,9 @@ bool isect_tri_tri_epsilon_v3(
for (j = 0, j_prev = 2; j < 3; j_prev = j++) {
const float edge_fac = 
line_point_factor_v3_ex(co_proj, tri_proj[j_prev], tri_proj[j], epsilon, -1.0f);
/* ignore collinear lines, they are either an 
edge shared between 2 tri's
-* (which runs along [co_proj, isect_no], but 
can be safely ignored).
+* (which runs along [co_proj, plane_no], but 
can be safely ignored).
 *
-* or an collinear edge placed away from the 
ray - which we don't intersect with & can ignore. */
+* or a collinear edge placed away from the ray 
- which we don't intersect with & can ignore. */
if (UNLIKELY(edge_fac == -1.0f)) {
/* pass */
}

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [a603a34] master: Revert fix for T45849 (part 2, tsk!)

2015-08-31 Thread Campbell Barton
Commit: a603a3470c1ad18f5ceed3315aaec6cdc5c8e107
Author: Campbell Barton
Date:   Mon Aug 31 22:45:04 2015 +1000
Branches: master
https://developer.blender.org/rBa603a3470c1ad18f5ceed3315aaec6cdc5c8e107

Revert fix for T45849 (part 2, tsk!)

===

M   source/blender/blenlib/intern/math_geom.c

===

diff --git a/source/blender/blenlib/intern/math_geom.c 
b/source/blender/blenlib/intern/math_geom.c
index 328bf55..65625db 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -1976,6 +1976,7 @@ int isect_line_line_epsilon_v3(
d = dot_v3v3(c, ab);
div = dot_v3v3(ab, ab);
 
+   /* important not to use an epsilon here, see: T45919 */
/* test zero length line */
if (UNLIKELY(div == 0.0f)) {
return 0;
@@ -2048,8 +2049,9 @@ bool isect_line_line_strict_v3(const float v1[3], const 
float v2[3],
d = dot_v3v3(c, ab);
div = dot_v3v3(ab, ab);
 
+   /* important not to use an epsilon here, see: T45919 */
/* test zero length line */
-   if (UNLIKELY(div <= epsilon)) {
+   if (UNLIKELY(div == 0.0f)) {
return false;
}
/* test if the two lines are coplanar */

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [5f64b77] master: Fix T45955: Python's pdb can't show script source

2015-08-31 Thread Campbell Barton
Commit: 5f64b77ca5235465b52183d2ea519606253a354e
Author: Campbell Barton
Date:   Mon Aug 31 23:41:13 2015 +1000
Branches: master
https://developer.blender.org/rB5f64b77ca5235465b52183d2ea519606253a354e

Fix T45955: Python's pdb can't show script source

===

M   source/blender/python/intern/bpy_interface.c

===

diff --git a/source/blender/python/intern/bpy_interface.c 
b/source/blender/python/intern/bpy_interface.c
index 274b335..61477d0 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -491,7 +491,9 @@ static int python_script_exec(bContext *C, const char *fn, 
struct Text *text,
 * incompatible'.
 * So now we load the script file data to a buffer */
{
-   const char *pystring = "with open(__file__, 
'r') as f: exec(f.read())";
+   const char *pystring =
+   "ns = globals().copy()\n"
+   "with open(__file__, 'rb') as f: 
exec(compile(f.read(), __file__, 'exec'), ns)";
 
fclose(fp);

___
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs


[Bf-blender-cvs] [6a53e65] master: Alternate fix for T45849: tri-tri intersect error

2015-08-31 Thread Campbell Barton
Commit: 6a53e658d31220de0399d1460747307ce4b5d81f
Author: Campbell Barton
Date:   Mon Aug 31 22:15:27 2015 +1000
Branches: master
https://developer.blender.org/rB6a53e658d31220de0399d1460747307ce4b5d81f

Alternate fix for T45849: tri-tri intersect error

Project both triangles onto the same plane to simplify calculations.

===

M   source/blender/blenlib/BLI_math_geom.h
M   source/blender/blenlib/intern/math_geom.c

===

diff --git a/source/blender/blenlib/BLI_math_geom.h 
b/source/blender/blenlib/BLI_math_geom.h
index c4bb3cc..0f389fb 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -127,9 +127,17 @@ void closest_to_plane3_v3(float r_close[3], const float 
plane[3], const float pt
 /* Set 'r' to the point in triangle (t1, t2, t3) closest to point 'p' */
 void closest_on_tri_to_point_v3(float r[3], const float p[3], const float 
t1[3], const float t2[3], const float t3[3]);
 
-
-float line_point_factor_v3(const float p[3], const float l1[3], const float 
l2[3]);
-float line_point_factor_v2(const float p[2], const float l1[2], const float 
l2[2]);
+float line_point_factor_v3_ex(
+const float p[3], const float l1[3], const float l2[3],
+const float epsilon, const float fallback);
+float line_point_factor_v3(
+const float p[3], const float l1[3], const float l2[3]);
+
+float line_point_factor_v2_ex(
+const float p[2], const float l1[2], const float l2[2],
+const float epsilon, const float fallback);
+float line_point_factor_v2(
+const float p[2], const float l1[2], const float l2[2]);
 
 float line_plane_factor_v3(const float plane_co[3], const float plane_no[3],
const float l1[3], const float l2[3]);
diff --git a/source/blender/blenlib/intern/math_geom.c 
b/source/blender/blenlib/intern/math_geom.c
index 27b3f56..e12bebe 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -1596,45 +1596,66 @@ bool isect_tri_tri_epsilon_v3(
 {
const float *tri_pair[2][3] = {{t_a0, t_a1, t_a2}, {t_b0, t_b1, t_b2}};
float no_a[3], no_b[3];
-   float isect_co[3], isect_no[3];
+   float plane_co[3], plane_no[3];
 
BLI_assert((r_i1 != NULL) == (r_i2 != NULL));
 
-   normal_tri_v3(no_a, UNPACK3(tri_pair[0]));
-   normal_tri_v3(no_b, UNPACK3(tri_pair[1]));
+   cross_tri_v3(no_a, UNPACK3(tri_pair[0]));
+   cross_tri_v3(no_b, UNPACK3(tri_pair[1]));
 
-   if (isect_plane_plane_v3(isect_co, isect_no, t_a0, no_a, t_b0, no_b)) {
-   float isect_co_other[3];
+   if (isect_plane_plane_v3(plane_co, plane_no, t_a0, no_a, t_b0, no_b)) {
+   /**
+* Implementation note: its simpler to project the triangles 
onto the intersection plane
+* before intersecting their edges with the ray, defined by 
'isect_plane_plane_v3'.
+* This way we can use 'line_point_factor_v3_ex' to see if an 
edge crosses 'co_proj'.
+*/
struct {
float min, max;
} range[2] = {{FLT_MAX, -FLT_MAX}, {FLT_MAX, -FLT_MAX}};
int t;
+   float co_proj[3];
+
+   /* only for numeric stability
+* (and so we can call 'closest_to_plane3_normalized_v3' below) 
*/
+   normalize_v3(plane_no);
 
-   add_v3_v3v3(isect_co_other, isect_co, isect_no);
+   closest_to_plane3_normalized_v3(co_proj, plane_no, plane_co);
 
-   /* For both triangles, find the overlap with the line defined 
by (isect_co, isect_co_other).
+   /* For both triangles, find the overlap with the line defined 
by the ray [co_proj, isect_no].
 * When the ranges overlap we know the triangles do too. */
for (t = 0; t < 2; t++) {
int j, j_prev;
+   float tri_proj[3][3];
+
+   closest_to_plane3_normalized_v3(tri_proj[0], plane_no, 
tri_pair[t][0]);
+   closest_to_plane3_normalized_v3(tri_proj[1], plane_no, 
tri_pair[t][1]);
+   closest_to_plane3_normalized_v3(tri_proj[2], plane_no, 
tri_pair[t][2]);
 
for (j = 0, j_prev = 2; j < 3; j_prev = j++) {
-   /* intersection point on the line intersecting 
both planes */
-   float ix_span[3];
-   /* intersection point on the triangles edge */
-   float ix_tri[3];
-
-   if (isect_line_line_epsilon_v3(
-   isect_co, isect_co_other,
-   tri_pair[t][j], tri_pair[t][j_prev],
-