From a31a85ac9cdfb28b0b56a2e445a0f61048730eef Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 24 Aug 2013 15:02:12 +0000 Subject: Fix #36541: blender internal raytrace render hangs with high ray depth. The code here is not efficient for such cases, a ray depth can give up to 2^depth rays due to the ray splitting in two at each depth. A proper solution requires a better algorithm, for now I've ensured that you can at least cancel such renders. The overhead from the extra test_break is negligible. --- source/blender/render/intern/source/rayshade.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source/blender') diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index 7ae64d499fa..838f73b5e83 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -734,6 +734,15 @@ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, con ShadeInput shi = {NULL}; Isect isec; float dist_mir = origshi->mat->dist_mir; + + /* with high depth the number of rays can explode due to the path splitting + * in two each time, giving 2^depth rays. we need to be able to cancel such + * a render to avoid hanging, a better solution would be random picking + * between directions and russian roulette termination */ + if(R.test_break(R.tbh)) { + zero_v4(col); + return; + } copy_v3_v3(isec.start, start); copy_v3_v3(isec.dir, dir); -- cgit v1.2.3