# HG changeset patch # User John Tsiombikas # Date 1393364868 -7200 # Node ID 0ac499409edd8fa9c388c93434b10c0c5cc680f0 # Parent 92bfb0206969c40456dc90abd88f51943ef2a0ba added misisng header file in goat3dgfx.h added contains() function in geom diff -r 92bfb0206969 -r 0ac499409edd Makefile.in --- a/Makefile.in Sat Dec 28 06:48:23 2013 +0200 +++ b/Makefile.in Tue Feb 25 23:47:48 2014 +0200 @@ -9,6 +9,8 @@ name = goat3dgfx lib_a = lib$(name).a +pcfile = $(name).pc + so_major = 0 so_minor = 1 @@ -26,7 +28,7 @@ inc = -Isrc -Isrc/vr warn = -Wall -libs_ldflags = -limago -lanim -lpsys -lvmath +libs_ldflags = -limago -lanim -lpsys -lvmath -lresman CFLAGS = -pedantic $(warn) $(dbg) $(pic) $(opt) $(inc) $(cfg_cflags) $(libs_cflags) CXXFLAGS = $(CFLAGS) @@ -69,6 +71,8 @@ ln -s $(lib_so) $(soname) && \ ln -s $(soname) $(devlink) || \ true + mkdir -p $(DESTDIR)$(PREFIX)/share/pkgconfig + cp $(pcfile) $(DESTDIR)$(PREFIX)/share/pkgconfig/$(pcfile) .PHONY: uninstall uninstall: @@ -80,3 +84,4 @@ rm -f $(DESTDIR)$(PREFIX)/lib/$(soname) && \ rm -f $(DESTDIR)$(PREFIX)/lib/$(devlink) || \ true + rm -f $(DESTDIR)$(PREFIX)/share/pkgconfig/$(pcfile) diff -r 92bfb0206969 -r 0ac499409edd configure --- a/configure Sat Dec 28 06:48:23 2013 +0200 +++ b/configure Tue Feb 25 23:47:48 2014 +0200 @@ -5,7 +5,7 @@ dbg=true vr=true -for arg; do +for arg in $#; do case "$arg" in --prefix=*) value=`echo $arg | sed 's/--prefix=//'` @@ -204,6 +204,25 @@ cat Makefile.in >>Makefile } +gen_pkgconfig() +{ + pcfile=goat3dgfx.pc + echo "generating: $pcfile ..." + begin_emit $pcfile + + emit "prefix=$prefix" + emit "ver=0.1" + + if [ `uname -s` = Darwin ]; then + emit 'libgl=-framework OpenGL -framework GLUT -lGLEW' + else + emit 'libgl=-lGL -lGLU -lglut -lGLEW' + fi + emit 'libovr=' + + cat ${pcfile}.in >>$pcfile +} + check_opengl check_glut check_glew @@ -211,3 +230,4 @@ gen_makefile gen_config +gen_pkgconfig diff -r 92bfb0206969 -r 0ac499409edd goat3dgfx.pc.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/goat3dgfx.pc.in Tue Feb 25 23:47:48 2014 +0200 @@ -0,0 +1,8 @@ +libdir=${prefix}/lib +incdir=${prefix}/include/goat3dgfx + +Name: goat3dgfx +Description: Mutant Stargoat 3D graphics engine +Version: ${ver} +Cflags: -I${incdir} +Libs: -L${libdir} ${libgl} ${libovr} -lgoat3dgfx -lvmath -limago -lpsys -lvmath -lresman -lm diff -r 92bfb0206969 -r 0ac499409edd src/geom.cc --- a/src/geom.cc Sat Dec 28 06:48:23 2013 +0200 +++ b/src/geom.cc Tue Feb 25 23:47:48 2014 +0200 @@ -49,6 +49,12 @@ error_log("Sphere::intersection undefined\n"); } +bool Sphere::contains(const Vector3 &pt) const +{ + float dist_sq = (pt - center).length_sq(); + return dist_sq <= radius * radius; +} + bool Sphere::intersect(const Ray &ray, HitPoint *hit) const { float a = dot_product(ray.dir, ray.dir); @@ -136,6 +142,13 @@ } } +bool AABox::contains(const Vector3 &pt) const +{ + return pt.x >= min.x && pt.x <= max.x && + pt.y >= min.y && pt.y <= max.y && + pt.z >= min.z && pt.z <= max.z; +} + bool AABox::intersect(const Ray &ray, HitPoint *hit) const { Vector3 param[2] = {min, max}; @@ -235,6 +248,11 @@ error_log("Plane::set_intersection undefined\n"); } +bool Plane::contains(const Vector3 &pt) const +{ + return false; // TODO: maybe define containment as half-space containment? +} + bool Plane::intersect(const Ray &ray, HitPoint *hit) const { float ndotdir = dot_product(normal, ray.dir); diff -r 92bfb0206969 -r 0ac499409edd src/geom.h --- a/src/geom.h Sat Dec 28 06:48:23 2013 +0200 +++ b/src/geom.h Tue Feb 25 23:47:48 2014 +0200 @@ -21,6 +21,7 @@ virtual void set_union(const GeomObject *obj1, const GeomObject *obj2) = 0; virtual void set_intersection(const GeomObject *obj1, const GeomObject *obj2) = 0; + virtual bool contains(const Vector3 &pt) const = 0; virtual bool intersect(const Ray &ray, HitPoint *hit = 0) const = 0; }; @@ -35,6 +36,7 @@ void set_union(const GeomObject *obj1, const GeomObject *obj2); void set_intersection(const GeomObject *obj1, const GeomObject *obj2); + bool contains(const Vector3 &pt) const; bool intersect(const Ray &ray, HitPoint *hit = 0) const; }; @@ -48,6 +50,7 @@ void set_union(const GeomObject *obj1, const GeomObject *obj2); void set_intersection(const GeomObject *obj1, const GeomObject *obj2); + bool contains(const Vector3 &pt) const; bool intersect(const Ray &ray, HitPoint *hit = 0) const; }; @@ -63,6 +66,7 @@ void set_union(const GeomObject *obj1, const GeomObject *obj2); void set_intersection(const GeomObject *obj1, const GeomObject *obj2); + bool contains(const Vector3 &pt) const; bool intersect(const Ray &ray, HitPoint *hit = 0) const; }; diff -r 92bfb0206969 -r 0ac499409edd src/goat3dgfx.h --- a/src/goat3dgfx.h Sat Dec 28 06:48:23 2013 +0200 +++ b/src/goat3dgfx.h Tue Feb 25 23:47:48 2014 +0200 @@ -2,6 +2,7 @@ #define GOAT3DGFX_H_ #include +#include #include #include #include