summaryrefslogtreecommitdiffstats
path: root/libdimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-01-06 16:17:44 -0500
committerTavian Barnes <tavianator@gmail.com>2010-01-06 16:17:44 -0500
commitd0533395834e8e0dc2cec65f1f25364690956851 (patch)
treed671c2d74117d674da9fd970e355d2da9fec3976 /libdimension
parent4e2a6e40a77068492e3b63b84a18d0cc7f003fb7 (diff)
downloaddimension-d0533395834e8e0dc2cec65f1f25364690956851.tar.xz
Make quality settings into flags.
Diffstat (limited to 'libdimension')
-rw-r--r--libdimension/dimension/scene.h16
-rw-r--r--libdimension/raytrace.c12
2 files changed, 14 insertions, 14 deletions
diff --git a/libdimension/dimension/scene.h b/libdimension/dimension/scene.h
index 81efb13..671bc12 100644
--- a/libdimension/dimension/scene.h
+++ b/libdimension/dimension/scene.h
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
+ * Copyright (C) 2010 Tavian Barnes <tavianator@gmail.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -26,13 +26,13 @@
#define DIMENSION_SCENE_H
typedef enum {
- DMNSN_RENDER_NONE,
- DMNSN_RENDER_OBJECTS,
- DMNSN_RENDER_PIGMENT,
- DMNSN_RENDER_LIGHTS,
- DMNSN_RENDER_FINISH,
- DMNSN_RENDER_TRANSLUCENCY,
- DMNSN_RENDER_FULL
+ DMNSN_RENDER_NONE = 0,
+ DMNSN_RENDER_OBJECTS = 1 << 0,
+ DMNSN_RENDER_PIGMENT = 1 << 1,
+ DMNSN_RENDER_LIGHTS = 1 << 2,
+ DMNSN_RENDER_FINISH = 1 << 3,
+ DMNSN_RENDER_TRANSLUCENCY = 1 << 4,
+ DMNSN_RENDER_FULL = ~DMNSN_RENDER_NONE
} dmnsn_quality;
typedef struct {
diff --git a/libdimension/raytrace.c b/libdimension/raytrace.c
index 594149c..38f1564 100644
--- a/libdimension/raytrace.c
+++ b/libdimension/raytrace.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009 Tavian Barnes <tavianator@gmail.com> *
+ * Copyright (C) 2010 Tavian Barnes <tavianator@gmail.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -240,7 +240,7 @@ dmnsn_raytrace_scene_impl(dmnsn_progress *progress, dmnsn_scene *scene,
/* Set the pixel to the background color */
color = scene->background;
- if (scene->quality >= DMNSN_RENDER_OBJECTS) {
+ if (scene->quality & DMNSN_RENDER_OBJECTS) {
/* Get the ray corresponding to the (x,y)'th pixel */
ray = (*scene->camera->ray_fn)(scene->camera,
((double)x)/(scene->canvas->x - 1),
@@ -375,7 +375,7 @@ dmnsn_raytrace_lighting(dmnsn_intersection *intersection, dmnsn_scene *scene,
if (dmnsn_raytrace_light_ray(intersection, scene, kD_splay_tree, light,
&light_color))
{
- if (scene->quality >= DMNSN_RENDER_FINISH
+ if (scene->quality & DMNSN_RENDER_FINISH
&& finish && finish->finish_fn)
{
dmnsn_vector ray = dmnsn_vector_normalize(
@@ -410,7 +410,7 @@ dmnsn_raytrace_shoot(dmnsn_line ray, dmnsn_scene *scene,
if (intersection) {
/* Get the pigment of the object */
dmnsn_color pigment = dmnsn_black;
- if (scene->quality >= DMNSN_RENDER_PIGMENT) {
+ if (scene->quality & DMNSN_RENDER_PIGMENT) {
pigment = dmnsn_raytrace_pigment(intersection, scene);
}
color = pigment;
@@ -419,7 +419,7 @@ dmnsn_raytrace_shoot(dmnsn_line ray, dmnsn_scene *scene,
/* Account for finishes and shadows */
dmnsn_color illum = pigment;
- if (scene->quality >= DMNSN_RENDER_LIGHTS) {
+ if (scene->quality & DMNSN_RENDER_LIGHTS) {
illum = dmnsn_raytrace_lighting(intersection,
scene,
kD_splay_tree,
@@ -431,7 +431,7 @@ dmnsn_raytrace_shoot(dmnsn_line ray, dmnsn_scene *scene,
/* Account for translucency */
dmnsn_color trans = illum;
- if (scene->quality >= DMNSN_RENDER_TRANSLUCENCY
+ if (scene->quality & DMNSN_RENDER_TRANSLUCENCY
&& (pigment.filter || pigment.trans))
{
trans = dmnsn_color_mul(1.0 - pigment.filter - pigment.trans, illum);