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:
authorAndre Susano Pinto <andresusanopinto@gmail.com>2009-09-17 16:56:16 +0400
committerAndre Susano Pinto <andresusanopinto@gmail.com>2009-09-17 16:56:16 +0400
commit5e609c9c52c76c26e890b676184ed6b52c82b393 (patch)
treea2d7623c497177912b4b71aee692f7bd3098b2f8 /source/blender/render
parentc8dfa6071d58ed514877d6444fed0815bf63153c (diff)
* converted raytrace visibility test on meshlaplacian.c to new raytrace API
I need test scenes and test instructions to make sure this is ok, since i have no idea how to test this feature.
Diffstat (limited to 'source/blender/render')
-rw-r--r--source/blender/render/extern/include/RE_raytrace.h22
-rw-r--r--source/blender/render/intern/include/rayobject.h19
-rw-r--r--source/blender/render/intern/source/rayobject.c44
3 files changed, 55 insertions, 30 deletions
diff --git a/source/blender/render/extern/include/RE_raytrace.h b/source/blender/render/extern/include/RE_raytrace.h
index af3ea8e2ac0..fe490461da0 100644
--- a/source/blender/render/extern/include/RE_raytrace.h
+++ b/source/blender/render/extern/include/RE_raytrace.h
@@ -79,6 +79,28 @@ RayObject* RE_rayobject_svbvh_create(int size); /* raytrace/rayobject_svbvh.c *
RayObject* RE_rayobject_bih_create(int size); /* rayobject_bih.c */
+/*
+ * This ray object represents a triangle or a quad face.
+ * All data needed to realize intersection is "localy" available.
+ */
+typedef struct RayFace
+{
+ float v1[4], v2[4], v3[4], v4[3];
+ int quad;
+ void *ob;
+ void *face;
+
+} RayFace;
+
+#define RE_rayface_isQuad(a) ((a)->quad)
+struct VlakRen;
+struct ObjectInstanceRen;
+
+RayObject* RE_rayface_from_vlak(RayFace *face, struct ObjectInstanceRen *obi, struct VlakRen *vlr);
+RayObject* RE_rayface_from_coords(RayFace *rayface, void *ob, void *face, float *co1, float *co2, float *co3, float *co4);
+
+
+
typedef struct LCTSHint LCTSHint;
struct LCTSHint
{
diff --git a/source/blender/render/intern/include/rayobject.h b/source/blender/render/intern/include/rayobject.h
index 19608fba262..dbd68fe8b8b 100644
--- a/source/blender/render/intern/include/rayobject.h
+++ b/source/blender/render/intern/include/rayobject.h
@@ -103,25 +103,6 @@ typedef struct RayVlak
*/
/*
- * This ray object represents a triangle or a quad face.
- * All data needed to realize intersection is "localy" available.
- */
-typedef struct RayFace
-{
- float v1[4], v2[4], v3[4], v4[3];
- int quad;
- void *ob;
- void *face;
-
-} RayFace;
-
-#define RE_rayface_isQuad(a) ((a)->quad)
-/* Loads a VlakRen on a RayFace */
-void RE_rayface_from_vlak(RayFace *face, ObjectInstanceRen *obi, VlakRen *vlr);
-
-
-
-/*
* This rayobject represents a generic object. With it's own callbacks for raytrace operations.
* It's suitable to implement things like LOD.
*/
diff --git a/source/blender/render/intern/source/rayobject.c b/source/blender/render/intern/source/rayobject.c
index 4bd8a12aa01..df457a37123 100644
--- a/source/blender/render/intern/source/rayobject.c
+++ b/source/blender/render/intern/source/rayobject.c
@@ -165,6 +165,17 @@ static int vlr_check_intersect_solid(Isect *is, ObjectInstanceRen* obi, VlakRen
return 0;
}
+static int rayface_check_cullface(RayFace *face, Isect *is)
+{
+ float nor[3];
+
+ /* don't intersect if the ray faces along the face normal */
+ if(face->quad) CalcNormFloat4(face->v1, face->v2, face->v3, face->v4, nor);
+ else CalcNormFloat(face->v1, face->v2, face->v3, nor);
+
+ return (INPR(nor, is->vec) < 0);
+}
+
/* ray - triangle or quad intersection */
/* this function shall only modify Isect if it detects an hit */
static int intersect_rayface(RayFace *face, Isect *is)
@@ -188,6 +199,11 @@ static int intersect_rayface(RayFace *face, Isect *is)
if(vlr_check_intersect_solid(is, (ObjectInstanceRen*)face->ob, (VlakRen*)face->face) == 0)
return 0;
}
+ if(is->skip & RE_SKIP_CULLFACE)
+ {
+ if(rayface_check_cullface(face, is) == 0)
+ return 0;
+ }
RE_RC_COUNT(is->raycounter->faces.test);
@@ -319,26 +335,32 @@ static int intersect_rayface(RayFace *face, Isect *is)
return 0;
}
-void RE_rayface_from_vlak(RayFace *face, ObjectInstanceRen *obi, VlakRen *vlr)
+RayObject* RE_rayface_from_vlak(RayFace *rayface, ObjectInstanceRen *obi, VlakRen *vlr)
+{
+ return RE_rayface_from_coords(rayface, obi, vlr, vlr->v1->co, vlr->v2->co, vlr->v3->co, vlr->v4 ? vlr->v4->co : 0 );
+}
+
+RayObject* RE_rayface_from_coords(RayFace *rayface, void *ob, void *face, float *v1, float *v2, float *v3, float *v4)
{
- VECCOPY(face->v1, vlr->v1->co);
- VECCOPY(face->v2, vlr->v2->co);
- VECCOPY(face->v3, vlr->v3->co);
- if(vlr->v4)
+ rayface->ob = ob;
+ rayface->face = face;
+
+ VECCOPY(rayface->v1, v1);
+ VECCOPY(rayface->v2, v2);
+ VECCOPY(rayface->v3, v3);
+ if(v4)
{
- VECCOPY(face->v4, vlr->v4->co);
- face->quad = 1;
+ VECCOPY(rayface->v4, v4);
+ rayface->quad = 1;
}
else
{
- face->quad = 0;
+ rayface->quad = 0;
}
- face->ob = obi;
- face->face = vlr;
+ return RE_rayobject_unalignRayFace(rayface);
}
-
int RE_rayobject_raycast(RayObject *r, Isect *isec)
{
int i;