single_threaded_resizeable_old.c
// return fullbright colour of sphere intersection
return fullbright colour of sphere intersection
return fullbright colour of sphere intersection
Uint32 fullbright_trace(const vec rayorig, const vec raydir)
{
    float tnear = FLOAT_MAX;
    sphere* sphr = NULL;
    for(uint i = 0; i < MAX_SPHERES; i++)
    {
        float t0 = FLOAT_MAX, t1 = FLOAT_MAX;
        if(intersect(rayorig, raydir, &t0, &t1, &sphere_array[i]))
        {
            if(t0 < 0){t0 = t1;}
            if(t0 < tnear)
            {
                tnear = t0;
                sphr = &sphere_array[i];
            }
        }
    }
    if(sphr == NULL)
        return 0xFF00FF00;
    return SDL_MapRGB(bb->format, (Uint8)(sphr->r*255.f), (Uint8)(sphr->g*255.f), (Uint8)(sphr->b*255.f));
}
Uint32 fullbright_trace ( const vec rayorig , const vec raydir ) { float tnear = FLOAT_MAX ; sphere * sphr = NULL ; for ( uint i = 0 ; i < MAX_SPHERES ; i ++ ) { float t0 = FLOAT_MAX , t1 = FLOAT_MAX ; if ( intersect ( rayorig , raydir , & t0 , & t1 , & sphere_array [ i ] ) ) { if ( t0 < 0 ) { t0 = t1 ; } if ( t0 < tnear ) { tnear = t0 ; sphr = & sphere_array [ i ] ; } } } if ( sphr == NULL ) return 0xFF00FF00 ; return SDL_MapRGB ( bb -> format , ( Uint8 ) ( sphr -> r * 255.f ) , ( Uint8 ) ( sphr -> g * 255.f ) , ( Uint8 ) ( sphr -> b * 255.f ) ) ; }
return fullbright colour of sphere intersection
return fullbright colour of sphere intersection
// find intersection with a sphere // if there's no intersection return black // return surface colour //printf("a0: %.2f %.2f %.2f\n", sphr->r*255.f, sphr->g*255.f, sphr->b*255.f);