Fixed #19571
authorAndre Susano Pinto <andresusanopinto@gmail.com>
Thu, 8 Oct 2009 11:24:06 +0000 (11:24 +0000)
committerAndre Susano Pinto <andresusanopinto@gmail.com>
Thu, 8 Oct 2009 11:24:06 +0000 (11:24 +0000)
(was crashing when building a raytree from a scene withouth any geometry)

source/blender/render/extern/include/RE_raytrace.h
source/blender/render/intern/raytrace/rayobject.cpp
source/blender/render/intern/source/rayshade.c

index 22d55bb1a91e4793014bd1c3251095e09bd1180b..7d430d5550aa3b5a1d2908460d51815ae369f1bc 100644 (file)
@@ -83,6 +83,7 @@ void RE_rayobject_hint_bb(RayObject *r, RayHint *hint, float *min, float *max);
 /* RayObject constructors */
 RayObject* RE_rayobject_octree_create(int ocres, int size);
 RayObject* RE_rayobject_instance_create(RayObject *target, float transform[][4], void *ob, void *target_ob);
+RayObject* RE_rayobject_empty_create();
 
 RayObject* RE_rayobject_blibvh_create(int size);       /* BLI_kdopbvh.c   */
 RayObject* RE_rayobject_vbvh_create(int size);         /* raytrace/rayobject_vbvh.c */
index 95387cf1ee442e8fab3022bcad5cfba78094b0d2..621fd3f794e8cc5e9f5322de874341f43ee57dcd 100644 (file)
@@ -535,3 +535,43 @@ int RE_rayobjectcontrol_test_break(RayObjectControl *control)
 
        return 0;
 }
+
+
+/*
+ * Empty raytree
+ */
+static int RE_rayobject_empty_intersect(RayObject *o, Isect *is)
+{
+       return 0;
+}
+
+static void RE_rayobject_empty_free(RayObject *o)
+{
+}
+
+static void RE_rayobject_empty_bb(RayObject *o, float *min, float *max)
+{
+       return;
+}
+
+static float RE_rayobject_empty_cost(RayObject *o)
+{
+       return 0.0;
+}
+
+static RayObjectAPI empty_api =
+{
+       RE_rayobject_empty_intersect,
+       NULL, //static void RE_rayobject_instance_add(RayObject *o, RayObject *ob);
+       NULL, //static void RE_rayobject_instance_done(RayObject *o);
+       RE_rayobject_empty_free,
+       RE_rayobject_empty_bb,
+       RE_rayobject_empty_cost
+};
+
+static RayObject empty_raytree = { &empty_api, {0, 0} };
+
+RayObject *RE_rayobject_empty_create()
+{
+       return RE_rayobject_unalignRayAPI( &empty_raytree );
+}
index 881a549ad9602bb2d934bee07b211e5e697602ab..4ad4d6370f8a471aec45193f8721f088755be15f 100644 (file)
@@ -335,6 +335,12 @@ static void makeraytree_single(Render *re)
                }
        }
        
+       if(faces + special == 0)
+       {
+               re->raytree = RE_rayobject_empty_create();
+               return;
+       }
+       
        //Create raytree
        raytree = re->raytree = RE_rayobject_create( re, re->r.raytrace_structure, faces+special );