示例#1
0
void RE_rayobject_merge_bb(RayObject *r, float *min, float *max)
{
	if (RE_rayobject_isRayFace(r)) {
		RayFace *face = (RayFace*) RE_rayobject_align(r);
		
		DO_MINMAX(face->v1, min, max);
		DO_MINMAX(face->v2, min, max);
		DO_MINMAX(face->v3, min, max);
		if (RE_rayface_isQuad(face)) DO_MINMAX(face->v4, min, max);
	}
	else if (RE_rayobject_isVlakPrimitive(r)) {
		VlakPrimitive *face = (VlakPrimitive*) RE_rayobject_align(r);
		RayFace nface;
		rayface_from_vlak(&nface, face->ob, face->face);

		DO_MINMAX(nface.v1, min, max);
		DO_MINMAX(nface.v2, min, max);
		DO_MINMAX(nface.v3, min, max);
		if (RE_rayface_isQuad(&nface)) DO_MINMAX(nface.v4, min, max);
	}
	else if (RE_rayobject_isRayAPI(r)) {
		r = RE_rayobject_align(r);
		r->api->bb(r, min, max);
	}
	else
		assert(0);
}
示例#2
0
int RE_rayobject_intersect(RayObject *r, Isect *i)
{
    if(RE_rayobject_isRayFace(r))
    {
        return intersect_rayface(r, (RayFace*) RE_rayobject_align(r), i);
    }
    else if(RE_rayobject_isVlakPrimitive(r))
    {
        //TODO optimize (useless copy to RayFace to avoid duplicate code)
        VlakPrimitive *face = (VlakPrimitive*) RE_rayobject_align(r);
        RayFace nface;
        rayface_from_vlak(&nface, face->ob, face->face);

        return intersect_rayface(r, &nface, i);
    }
    else if(RE_rayobject_isRayAPI(r))
    {
        r = RE_rayobject_align(r);
        return r->api->raycast(r, i);
    }
    else {
        assert(0);
        return 0;
    }
}
示例#3
0
void RE_rayobject_set_control(RayObject *r, void *data, RE_rayobjectcontrol_test_break_callback test_break)
{
	if (RE_rayobject_isRayAPI(r)) {
		r = RE_rayobject_align(r);
		r->control.data = data;
		r->control.test_break = test_break;
	}
}
示例#4
0
void RE_rayobject_hint_bb(RayObject *r, RayHint *hint, float *min, float *max)
{
	if (RE_rayobject_isRayFace(r) || RE_rayobject_isVlakPrimitive(r)) {
		return;
	}
	else if (RE_rayobject_isRayAPI(r)) {
		r = RE_rayobject_align(r);
		return r->api->hint_bb(r, hint, min, max);
	}
	else
		assert(0);
}
示例#5
0
float RE_rayobject_cost(RayObject *r)
{
	if (RE_rayobject_isRayFace(r) || RE_rayobject_isVlakPrimitive(r)) {
		return 1.0f;
	}
	else if (RE_rayobject_isRayAPI(r)) {
		r = RE_rayobject_align(r);
		return r->api->cost(r);
	}
	else {
		assert(0);
		return 1.0f;
	}
}