Removed cmath dependency.

This commit is contained in:
2017-01-02 00:23:04 -04:00
parent 806040018e
commit e9986a923f
7 changed files with 13678 additions and 5418 deletions

View File

@@ -3,7 +3,7 @@ HEADERS = ray.hpp figure.hpp sphere.hpp plane.hpp disk.hpp material.hpp light.hp
OBJECTS = main.o sphere.o plane.o disk.o directional_light.o tracer.o
CXX = g++
CXXFLAGS = -ansi -pedantic -Wall -g -DGLM_FORCE_RADIANS -fopenmp
LDLIBS = -lm
LDLIBS =
.PHONY: all
all: $(TARGET)

View File

@@ -1,5 +1,3 @@
#include <cmath>
#include <glm/glm.hpp>
#include <glm/gtc/constants.hpp>
@@ -8,12 +6,14 @@
using glm::pi;
using glm::reflect;
using glm::dot;
using glm::pow;
using glm::max;
vec3 DirectionalLight::shade(vec3 normal, Ray & r, Material & m) const {
float n_dot_l, r_dot_l;
vec3 color, ref;
n_dot_l = max(dot(normal, m_position), 0.0);
n_dot_l = max(dot(normal, m_position), 0.0f);
color += (m.m_diffuse / pi<float>()) * m_diffuse * n_dot_l;
ref = reflect(m_position, normal);

View File

@@ -16,10 +16,6 @@ public:
vec3 m_specular;
vec3 m_ambient;
float max(float a, float b) const {
return a >= b ? a : b;
}
virtual ~Light() { }
virtual vec3 shade(vec3 normal, Ray & r, Material & m) const = 0;

19073
output.ppm

File diff suppressed because one or more lines are too long

View File

@@ -1,16 +1,14 @@
#include <cmath>
#include "plane.hpp"
#define TOL 1e-6
using std::fabs;
using glm::abs;
using glm::dot;
bool Plane::intersect(Ray & r, float & t) const {
float d = dot(r.m_direction, m_normal);
if (fabs(d) > TOL) {
if (abs(d) > TOL) {
t = dot(m_normal, (m_point - r.m_origin)) / d;
return t >= 0.0f;
}

View File

@@ -1,8 +1,7 @@
#include <cmath>
#include "sphere.hpp"
using glm::normalize;
using glm::sqrt;
bool Sphere::intersect(Ray & r, float & t) const {
float t1, t2;

View File

@@ -17,7 +17,7 @@ using glm::reflect;
using glm::refract;
using glm::clamp;
using glm::tan;
using glm::cos;
using glm::sqrt;
static const vec3 BCKG_COLOR = vec3(0.16f, 0.66f, 0.72f);