remove some unused stlplus modules
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Fri, 1 Jul 2011 08:01:10 +0000 (02:01 -0600)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Fri, 1 Jul 2011 08:01:10 +0000 (02:01 -0600)
also updated copyright timespan and formatted files for tabstops of 8
characters

203 files changed:
Makefile
README
TODO
build/arch/win32/makedeps.mk
build/arch/win32/rules.mk
build/config.lua
build/dialog.c
configure
data/rules.mk
data/scenes/Classic.lua
doc/yoink_readme.7
options.lua
scripts/man2html.lua
scripts/unix2dos.sh [moved from build/arch/win32/unix2dos.sh with 74% similarity]
src/Animation.cc
src/Animation.hh
src/Character.cc
src/Character.hh
src/GameState.hh
src/Heroine.cc
src/Heroine.hh
src/Hud.cc
src/Hud.hh
src/Main.cc
src/Main.hh
src/Scene.cc
src/Scene.hh
src/TilemapFont.cc
src/TilemapFont.hh
src/Typesetter.cc
src/Typesetter.hh
src/moof/aabb.cc
src/moof/aabb.hh
src/moof/application.cc
src/moof/application.hh
src/moof/backend.cc
src/moof/backend.hh
src/moof/camera.cc
src/moof/camera.hh
src/moof/contact.hh
src/moof/cullable.hh
src/moof/debug.hh
src/moof/dispatcher.cc
src/moof/dispatcher.hh
src/moof/drawable.hh
src/moof/entity.hh
src/moof/event.hh
src/moof/frustum.cc
src/moof/frustum.hh
src/moof/hash.cc
src/moof/hash.hh
src/moof/image.cc
src/moof/image.hh
src/moof/interpolator.hh
src/moof/line.hh
src/moof/log.cc
src/moof/log.hh
src/moof/manager.hh
src/moof/math.hh
src/moof/mesh.cc
src/moof/mesh.hh
src/moof/mesh_bindings.cc
src/moof/modal_dialog.hh
src/moof/network.hh
src/moof/opengl.hh
src/moof/plane.cc
src/moof/plane.hh
src/moof/ray.hh
src/moof/resource.cc
src/moof/resource.hh
src/moof/rigid_body.hh
src/moof/runloop.cc
src/moof/runloop.hh
src/moof/script.hh
src/moof/service.cc
src/moof/service.hh
src/moof/settings.cc
src/moof/settings.hh
src/moof/shape.hh
src/moof/sound.cc
src/moof/sound.hh
src/moof/sound_bindings.cc
src/moof/sphere.hh
src/moof/sprite.cc
src/moof/sprite.hh
src/moof/string.cc
src/moof/string.hh
src/moof/thread.cc
src/moof/thread.hh
src/moof/timer.cc
src/moof/timer.hh
src/moof/video.cc
src/moof/video.hh
src/rules.mk
src/stlplus/rules.mk
src/stlplus/strings/format_types.hpp [deleted file]
src/stlplus/strings/print_address.cpp [deleted file]
src/stlplus/strings/print_address.hpp [deleted file]
src/stlplus/strings/print_basic.hpp [deleted file]
src/stlplus/strings/print_bitset.hpp [deleted file]
src/stlplus/strings/print_bitset.tpp [deleted file]
src/stlplus/strings/print_bool.cpp [deleted file]
src/stlplus/strings/print_bool.hpp [deleted file]
src/stlplus/strings/print_cstring.cpp [deleted file]
src/stlplus/strings/print_cstring.hpp [deleted file]
src/stlplus/strings/print_digraph.hpp [deleted file]
src/stlplus/strings/print_digraph.tpp [deleted file]
src/stlplus/strings/print_float.cpp [deleted file]
src/stlplus/strings/print_float.hpp [deleted file]
src/stlplus/strings/print_foursome.hpp [deleted file]
src/stlplus/strings/print_foursome.tpp [deleted file]
src/stlplus/strings/print_hash.hpp [deleted file]
src/stlplus/strings/print_hash.tpp [deleted file]
src/stlplus/strings/print_inf.cpp [deleted file]
src/stlplus/strings/print_inf.hpp [deleted file]
src/stlplus/strings/print_int.cpp [deleted file]
src/stlplus/strings/print_int.hpp [deleted file]
src/stlplus/strings/print_list.hpp [deleted file]
src/stlplus/strings/print_list.tpp [deleted file]
src/stlplus/strings/print_map.hpp [deleted file]
src/stlplus/strings/print_map.tpp [deleted file]
src/stlplus/strings/print_matrix.hpp [deleted file]
src/stlplus/strings/print_matrix.tpp [deleted file]
src/stlplus/strings/print_ntree.hpp [deleted file]
src/stlplus/strings/print_ntree.tpp [deleted file]
src/stlplus/strings/print_pair.hpp [deleted file]
src/stlplus/strings/print_pair.tpp [deleted file]
src/stlplus/strings/print_pointer.hpp [deleted file]
src/stlplus/strings/print_pointer.tpp [deleted file]
src/stlplus/strings/print_sequence.hpp [deleted file]
src/stlplus/strings/print_sequence.tpp [deleted file]
src/stlplus/strings/print_set.hpp [deleted file]
src/stlplus/strings/print_set.tpp [deleted file]
src/stlplus/strings/print_simple_ptr.hpp [deleted file]
src/stlplus/strings/print_simple_ptr.tpp [deleted file]
src/stlplus/strings/print_smart_ptr.hpp [deleted file]
src/stlplus/strings/print_smart_ptr.tpp [deleted file]
src/stlplus/strings/print_stl.hpp [deleted file]
src/stlplus/strings/print_stlplus.hpp [deleted file]
src/stlplus/strings/print_string.cpp [deleted file]
src/stlplus/strings/print_string.hpp [deleted file]
src/stlplus/strings/print_triple.hpp [deleted file]
src/stlplus/strings/print_triple.tpp [deleted file]
src/stlplus/strings/print_vector.cpp [deleted file]
src/stlplus/strings/print_vector.hpp [deleted file]
src/stlplus/strings/print_vector.tpp [deleted file]
src/stlplus/strings/string_address.cpp [deleted file]
src/stlplus/strings/string_address.hpp [deleted file]
src/stlplus/strings/string_basic.hpp [deleted file]
src/stlplus/strings/string_bitset.hpp [deleted file]
src/stlplus/strings/string_bitset.tpp [deleted file]
src/stlplus/strings/string_bool.cpp [deleted file]
src/stlplus/strings/string_bool.hpp [deleted file]
src/stlplus/strings/string_cstring.cpp [deleted file]
src/stlplus/strings/string_cstring.hpp [deleted file]
src/stlplus/strings/string_digraph.hpp [deleted file]
src/stlplus/strings/string_digraph.tpp [deleted file]
src/stlplus/strings/string_float.cpp [deleted file]
src/stlplus/strings/string_float.hpp [deleted file]
src/stlplus/strings/string_foursome.hpp [deleted file]
src/stlplus/strings/string_foursome.tpp [deleted file]
src/stlplus/strings/string_hash.hpp [deleted file]
src/stlplus/strings/string_hash.tpp [deleted file]
src/stlplus/strings/string_inf.cpp [deleted file]
src/stlplus/strings/string_inf.hpp [deleted file]
src/stlplus/strings/string_int.cpp [deleted file]
src/stlplus/strings/string_int.hpp [deleted file]
src/stlplus/strings/string_list.hpp [deleted file]
src/stlplus/strings/string_list.tpp [deleted file]
src/stlplus/strings/string_map.hpp [deleted file]
src/stlplus/strings/string_map.tpp [deleted file]
src/stlplus/strings/string_matrix.hpp [deleted file]
src/stlplus/strings/string_matrix.tpp [deleted file]
src/stlplus/strings/string_ntree.hpp [deleted file]
src/stlplus/strings/string_ntree.tpp [deleted file]
src/stlplus/strings/string_pair.hpp [deleted file]
src/stlplus/strings/string_pair.tpp [deleted file]
src/stlplus/strings/string_pointer.hpp [deleted file]
src/stlplus/strings/string_pointer.tpp [deleted file]
src/stlplus/strings/string_sequence.hpp [deleted file]
src/stlplus/strings/string_sequence.tpp [deleted file]
src/stlplus/strings/string_set.hpp [deleted file]
src/stlplus/strings/string_set.tpp [deleted file]
src/stlplus/strings/string_simple_ptr.hpp [deleted file]
src/stlplus/strings/string_simple_ptr.tpp [deleted file]
src/stlplus/strings/string_smart_ptr.hpp [deleted file]
src/stlplus/strings/string_smart_ptr.tpp [deleted file]
src/stlplus/strings/string_stl.hpp [deleted file]
src/stlplus/strings/string_stlplus.hpp [deleted file]
src/stlplus/strings/string_string.cpp [deleted file]
src/stlplus/strings/string_string.hpp [deleted file]
src/stlplus/strings/string_triple.hpp [deleted file]
src/stlplus/strings/string_triple.tpp [deleted file]
src/stlplus/strings/string_utilities.cpp [deleted file]
src/stlplus/strings/string_utilities.hpp [deleted file]
src/stlplus/strings/string_vector.cpp [deleted file]
src/stlplus/strings/string_vector.hpp [deleted file]
src/stlplus/strings/string_vector.tpp [deleted file]
src/stlplus/strings/strings.hpp [deleted file]
src/stlplus/strings/strings_fixes.hpp [deleted file]
src/win32.rc
src/yoink.cc
src/yoink.hh

index e104a4ef1710d7c12629c9f3e4ffbb4292e4257d..a0c754b694dbf64e9d42fc277ec02fcacfcbd9a7 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@
 
 # Set V to `1' to echo each build command in full.  The default behavior
 # will keep output minimal.
-V              = 0
+V      = 0
 
 SHELL  = /bin/sh
 
@@ -35,7 +35,7 @@ include config.mk
 
 DATA_TARGETS   :=
 EXEC_TARGETS   :=
-SUBDIRS                        :=
+SUBDIRS                :=
 
 define include_func =
 ifeq (,$$d)
@@ -43,13 +43,13 @@ dir := $1
 else
 dir    := $$d/$1
 endif
-sp                             := $$(sp).x
+sp     := $$(sp).x
 dirstack_$$(sp)        := $$d
 datstack_$$(sp) := $$(data)
 exestack_$$(sp) := $$(exec)
-d                              := $$(dir)
-data :=
-exec :=
+d      := $$(dir)
+data   :=
+exec   :=
 include $$(dir)/rules.mk
 SUBDIRS += $$d $$b
 data   := $$(sort $$(data) $$(appdir_$$b) $$(mandir_$$b) $$(pkgdatadir_$$b) $$(desktop_$$b))
@@ -59,7 +59,7 @@ clean   := $$(clean) $$(deps) $$(exec) $$(data)
 DEPFILE := $$(DEPFILE) $$(deps)
 DATA_TARGETS += $$(data)
 EXEC_TARGETS += $$(exec)
-d              := $$(dirstack_$$(sp))
+d      := $$(dirstack_$$(sp))
 data   := $$(datstack_$$(sp))
 exec   := $$(exestack_$$(sp))
 sp     := $$(basename $$(sp))
@@ -68,7 +68,7 @@ include       = $(foreach i,$1,$(eval $(call include_func,$i)))
 
 targets                = $(EXEC_TARGETS) $(DATA_TARGETS)
 builddir       = build/obj
-b                      = $(builddir)/$(d)
+b              = $(builddir)/$(d)
 this           = $(d)/rules.mk
 
 ifeq (gzip,$(manCompression))
@@ -85,7 +85,7 @@ endif
 #
 
 $(call include,src data doc)
--include build/$(platform)/rules.mk
+-include build/arch/$(platform)/rules.mk
 
 
 #
@@ -98,7 +98,7 @@ PKG_CFLAGS    += -MD -MP -MF $(@:%.o=%.d) -MT $@
 endif
 
 # Include current directory to allow sources to include config.h.
-override CPPFLAGS      += -I.
+override CPPFLAGS      += -I. -DHAVE_CONFIG_H=1
 TGT_CXXFLAGS           = $(TGT_CFLAGS)
 ARFLAGS                = rc
 INSTALL                = install
@@ -106,51 +106,51 @@ INSTALL           = install
 tarname                = $(TARNAME)-$(VERSION)
 
 cmd_compile_c  = $(CC) $(PKG_CFLAGS) $(TGT_CFLAGS) $(CFLAGS) $(CPPFLAGS) \
-                                 $(TARGET_ARCH) -c $(OUTPUT_OPTION) $<
+                 $(TARGET_ARCH) -c $(OUTPUT_OPTION) $<
 cmd_compile_cc = $(CXX) $(PKG_CXXFLAGS) $(TGT_CXXFLAGS) $(CXXFLAGS) $(CPPFLAGS) \
-                                 $(TARGET_ARCH) -c $(OUTPUT_OPTION) $<
-cmd_link_c             = $(CC) $(PKG_CFLAGS) $(TGT_CFLAGS) $(CFLAGS) $(CPPFLAGS) \
-                                 $(PKG_LDFLAGS) $(TGT_LDFLAGS) $(LDFLAGS) \
-                                 $(TARGET_ARCH) $^ $(LOADLIBES) $(PKG_LDLIBS) $(TGT_LDLIBS) $(LDLIBS) -o $@
-cmd_link_cc            = $(CXX) $(PKG_CXXFLAGS) $(TGT_CXXFLAGS) $(CXXFLAGS) $(CPPFLAGS) \
-                                 $(PKG_LDFLAGS) $(TGT_LDFLAGS) $(LDFLAGS) \
-                                 $(TARGET_ARCH) $^ $(LOADLIBES) $(PKG_LDLIBS) $(TGT_LDLIBS) $(LDLIBS) -o $@
-cmd_ar                 = $(AR) $(ARFLAGS) $@ $^; $(RANLIB) $@
+                 $(TARGET_ARCH) -c $(OUTPUT_OPTION) $<
+cmd_link_c     = $(CC) $(PKG_CFLAGS) $(TGT_CFLAGS) $(CFLAGS) $(CPPFLAGS) \
+                 $(PKG_LDFLAGS) $(TGT_LDFLAGS) $(LDFLAGS) \
+                 $(TARGET_ARCH) $^ $(LOADLIBES) $(PKG_LDLIBS) $(TGT_LDLIBS) $(LDLIBS) -o $@
+cmd_link_cc    = $(CXX) $(PKG_CXXFLAGS) $(TGT_CXXFLAGS) $(CXXFLAGS) $(CPPFLAGS) \
+                 $(PKG_LDFLAGS) $(TGT_LDFLAGS) $(LDFLAGS) \
+                 $(TARGET_ARCH) $^ $(LOADLIBES) $(PKG_LDLIBS) $(TGT_LDLIBS) $(LDLIBS) -o $@
+cmd_ar         = $(AR) $(ARFLAGS) $@ $^; $(RANLIB) $@
 cmd_compile_rc = $(WINDRES) $(CPPFLAGS) $(TARGET_ARCH) $(OUTPUT_OPTION) -i $<
-cmd_sed                        = sed -f config.sed <$< >$@
-cmd_gzip               = gzip -c $< >$@
-cmd_bzip2              = bzip2 -c $< >$@
-cmd_xxd                        = id=$(subst .,_,$(notdir $<)); \
-                                 printf "\#include <stddef.h>\nsize_t\tdata_%s_size = %d;\nchar\tdata_%s[] = {\n" \
-                                 $$id $$(wc -c <$<) $$id >$@; \
-                                 xxd -i <$< >>$@; \
-                                 printf ", 0x00\n};\n" >>$@
+cmd_sed                = sed -f config.sed <$< >$@
+cmd_gzip       = gzip -c $< >$@
+cmd_bzip2      = bzip2 -c $< >$@
+cmd_xxd                = id=$(subst .,_,$(notdir $<)); \
+                 printf "\#include <stddef.h>\nsize_t\tdata_%s_size = %d;\nchar\tdata_%s[] = {\n" \
+                 $$id $$(wc -c <$<) $$id >$@; \
+                 xxd -i <$< >>$@; \
+                 printf ", 0x00\n};\n" >>$@
 cmd_configure  = ./configure
 func_install   = mkdir -p $(DESTDIR)$3 && $(INSTALL) -m $1 $2 $(DESTDIR)$3
-func_remove            = rm -f $1
-func_dist              = git archive HEAD --prefix='$(tarname)/' | $1 >"$(tarname).tar.$2" && \
-                                 (md5 "$(tarname).tar.$2" 2>/dev/null || md5sum "$(tarname).tar.$2")
+func_remove    = rm -f $1
+func_dist      = git archive HEAD --prefix='$(tarname)/' | $1 >"$(tarname).tar.$2" && \
+                 (md5 "$(tarname).tar.$2" 2>/dev/null || md5sum "$(tarname).tar.$2")
 
 compile_c      = $(call func_print,CC,$@) $(cmd_compile_c)
 compile_cc     = $(call func_print,CXX,$@) $(cmd_compile_cc)
 compile_rc     = $(call func_print,RC,$@) $(cmd_compile_rc)
 link_c         = $(call func_print,LINK,$@) $(cmd_link_c)
 link_cc                = $(call func_print,LINK,$@) $(cmd_link_cc)
-ar                     = $(call func_print,AR,$@) $(cmd_ar)
-sed                    = $(call func_print,SED,$@) $(cmd_sed)
+ar             = $(call func_print,AR,$@) $(cmd_ar)
+sed            = $(call func_print,SED,$@) $(cmd_sed)
 gzip           = $(call func_print,GZIP,$@) $(cmd_gzip)
 bzip2          = $(call func_print,BZIP2,$@) $(cmd_bzip2)
-xxd                    = $(call func_print,XXD,$@) $(cmd_xxd)
+xxd            = $(call func_print,XXD,$@) $(cmd_xxd)
 configure      = $(call func_print,MAKE,$@) $(cmd_configure)
 dist           = $(call func_print,DIST,$1) $(func_dist)
-install                = $(call func_print,CP,$(DESTDIR)$(3:%/=%)/$(notdir $2)) $(func_install)
+install                = $(call func_print,CP,$(DESTDIR:%/=%)$(3:%/=%)/$(notdir $2)) $(func_install)
 remove         = $(call func_print,RM,$1) $(func_remove)
 
 ifeq (1,$V)
-Q                      =
+Q              =
 func_print     =
 else
-Q                      = @
+Q              = @
 func_print     = printf "\x20\x20$1\t%s\n" $2;
 endif
 
@@ -214,7 +214,8 @@ install-data: $(DATA_TARGETS)
        $(Q)$(foreach d,$(SUBDIRS),$(foreach f,$(pkgdatadir_$d),\
                $(call install,644,$f,$(dir $(f:$d%=$(pkgdatadir)%)));))
        $(Q)$(foreach d,$(SUBDIRS),$(foreach f,$(mandir_$d),\
-               $(call install,644,$f,$(dir $(f:$d%=$(mandir)/man$(shell echo "$f" | sed 's/[^.]*\.\([^.]*\).*/\1/')%)));))
+               $(call install,644,$f,\
+               $(dir $(f:$d%=$(mandir)/man$(shell echo "$f" | sed 's/[^.]*\.\([^.]*\).*/\1/')%)));))
 
 install-exec: $(EXEC_TARGETS)
        $(Q)$(foreach d,$(SUBDIRS),$(foreach f,$(bindir_$d),\
@@ -246,7 +247,7 @@ dist: dist-$(archiveFormat)
 # Prevent make from removing any build targets.
 #
 
-.SECONDARY:    $(clean)
+.SECONDARY: $(clean)
 
 .PHONY: all clean distclean install install-data install-exec
 .PHONY: install-desktop-entry
diff --git a/README b/README
index 0cab8cce8b8e178eba795c62eb7ac3f2b2e4ba76..b993ffdeb6e306d5483c2c86c59bf49e7ab2d8a8 100644 (file)
--- a/README
+++ b/README
@@ -80,7 +80,7 @@ DESCRIPTION
      o   Stick to the coding style of the source code files you edit.  Follow
          the general style of method and variable naming, as well as white
          space formatting.  In particular, use literal tabs with an assumed
-         tabstop of 4 characters.  Also, try to limit line lengths to 75
+         tabstop of 8 characters.  Also, try to limit line lengths to 78
          characters.
 
      o   For legal reasons, don't include other peoples' code with your patch.
diff --git a/TODO b/TODO
index dc4b35674ec46c8360153bbb4467995abb880fc7..4ecad27865a51e4af8c02f6993cac253195438e9 100644 (file)
--- a/TODO
+++ b/TODO
@@ -2,8 +2,8 @@
 The roadmap and ticket tracker are available on the website:
 There are lists of goals and tasks on the website:
 
-Roadmap:        http://www.dogcows.com/yoink/roadmap
-Ticket Tracker: http://www.dogcows.com/yoink/report/1
+Roadmap:       http://www.dogcows.com/yoink/roadmap
+Ticket Tracker:        http://www.dogcows.com/yoink/report/1
 
 
 Other than that, the itself code is documented with stuff that needs doing:
index fbdbecdefbc25c86631b2ff6ccaa941e7e825b6b..03766157694a16450710ea2c1c7c738ca7080c51 100644 (file)
 #   make -f deps.mk -j2 host=i486-mingw32 prefix=/usr/i486-mingw32
 #   sudo make install
 #
-# A lot of temporary files and directories are downloaded or extracted to
-# the current directory, so you may want to make from a clean directory.
+# A lot of temporary files and directories are downloaded or extracted to the
+# current directory, so you may want to make from a clean directory.
 #
 
-
 host   = i686-mingw32
 prefix = /usr/i686-mingw32/usr
 
@@ -50,9 +49,9 @@ endif
 
 
 ###########################################################################
-BOOST                  = boost_1_46_1
-BOOST_CKSUM            = 7375679575f4c8db605d426fc721d506
-BOOST_EXT              = .tar.bz2
+BOOST          = boost_1_46_1
+BOOST_CKSUM    = 7375679575f4c8db605d426fc721d506
+BOOST_EXT      = .tar.bz2
 BOOST_VERSION  = 1.46.1
 
 $(BOOST)$(BOOST_EXT):
@@ -69,7 +68,7 @@ install-$(BOOST): $(BOOST)$(BOOST_EXT)
 
 
 ###########################################################################
-SDL                    = SDL-1.2.14
+SDL            = SDL-1.2.14
 SDL_CKSUM      = e52086d1b508fa0b76c52ee30b55bec4
 SDL_EXT                = .tar.gz
 
@@ -89,9 +88,9 @@ install-$(SDL): $(SDL)
 
 
 ###########################################################################
-LIBOGG                 = libogg-1.2.2
+LIBOGG         = libogg-1.2.2
 LIBOGG_CKSUM   = 5a9fcabc9a1b7c6f1cd75ddc78f36c56
-LIBOGG_EXT             = .tar.gz
+LIBOGG_EXT     = .tar.gz
 
 $(LIBOGG)$(LIBOGG_EXT):
        $(call getdist,$@,http://downloads.xiph.org/releases/ogg/$@)
@@ -109,7 +108,7 @@ install-$(LIBOGG): $(LIBOGG)
 
 
 ###########################################################################
-LIBVORBIS              = libvorbis-1.3.2
+LIBVORBIS      = libvorbis-1.3.2
 LIBVORBIS_CKSUM        = c870b9bd5858a0ecb5275c14486d9554
 LIBVORBIS_EXT  = .tar.gz
 
@@ -129,9 +128,9 @@ install-$(LIBVORBIS): $(LIBVORBIS) install-$(LIBOGG)
 
 
 ###########################################################################
-OPENAL                 = openal-soft-1.13-bin
+OPENAL         = openal-soft-1.13-bin
 OPENAL_CKSUM   = b545d3ebb8138cc581cd67f988638f43
-OPENAL_EXT             = .zip
+OPENAL_EXT     = .zip
 OPENAL_VERSION = 1.13
 
 define OPENAL_PCFILE
@@ -167,9 +166,9 @@ install-$(OPENAL): $(OPENAL)$(OPENAL_EXT)
 
 
 ###########################################################################
-ZLIB                   = zlib-1.2.5
-ZLIB_CKSUM             = c735eab2d659a96e5a594c9e8541ad63
-ZLIB_EXT               = .tar.gz
+ZLIB           = zlib-1.2.5
+ZLIB_CKSUM     = c735eab2d659a96e5a594c9e8541ad63
+ZLIB_EXT       = .tar.gz
 ZLIB_VERSION   = 1.2.5
 
 define ZLIB_PCFILE
@@ -208,9 +207,9 @@ install-$(ZLIB): $(ZLIB)
 
 
 ###########################################################################
-LIBPNG                 = libpng-1.5.2
+LIBPNG         = libpng-1.5.2
 LIBPNG_CKSUM   = 31d448eb93a1646359a23f1b23434ab3
-LIBPNG_EXT             = .tar.gz
+LIBPNG_EXT     = .tar.gz
 
 define LIBPNG_PATCH
 diff -ur libpng-1.5.2.orig/configure.pc libpng-1.5.2/configure.pc
@@ -248,7 +247,7 @@ install-$(LIBPNG): $(LIBPNG) install-$(ZLIB)
 
 
 ###########################################################################
-LUA                    = lua-5.1.4
+LUA            = lua-5.1.4
 LUA_CKSUM      = d0870f2de55d59c1c8419f36e8fac150
 LUA_EXT                = .tar.gz
 
index 0f5eae5e40ed961cb49f35f4dc641b7b0f5195be..3e3c49d0f9db9f9ec692d934d0351896fdcad990 100644 (file)
@@ -1,17 +1,13 @@
+
 #
-# Yoink
-# Run this script to create a win32 package.
-#
-# You should typically only run this through the "portable" and "installer"
-# makes targets in the package root directory.  The build system will take
-# care to pass the correct arguments.
+# Rules to create win32 packages.
 #
 
 docs           = AUTHORS COPYING README TODO
 libraries      = libogg-0 libpng15 libvorbis-0 libvorbisfile-3 lua51 OpenAL32 SDL zlib1
 
-MAN2HTML       = lua doc/man2html.lua
-UNIX2DOS       = arch/win32/unix2dos.sh
+MAN2HTML       = $${LUA:-lua} scripts/man2html.lua
+UNIX2DOS       = scripts/unix2dos.sh
 MAKENSIS       = makensis
 
 stagedir       = $(builddir)/$(tarname)
index fa522cf9247a31b0b530e5923d78fe63737d178b..6a72455103bbc068824fb24ee5530e08365ef658 100644 (file)
@@ -71,8 +71,8 @@ end
 
 local arguments                = parseArguments(unpack(arg))
 local interactive      = arguments["--interactive"]
-local rules                    = arguments["--rules"]      or "options.lua"
-local configfile       = arguments["--configfile"] or "config.mk"
+local rules            = arguments["--rules"]          or "options.lua"
+local configfile       = arguments["--configfile"]     or "config.mk"
 local printendmsg      = arguments["--print-instructions"]
 local exportHeader     = arguments["--export-header"]
 local exportTerms      = arguments["--export-terms"]
@@ -92,7 +92,9 @@ local function beginProcess(title, caption)
        return function(progress, caption)
                if progress ~= nil
                then
-                       if 0.0 <= progress and progress <= 1.0 then progress = progress * 100 end
+                       if 0.0 <= progress and progress <= 1.0 then
+                               progress = progress * 100
+                       end
                        return updater(progress, caption)
                end
                print()
@@ -103,16 +105,12 @@ end
 local function loadDialog(name, configfile)
        local dialog
        local result, err = pcall(function() dialog = require "dialog" end)
-       if not result
-       then
-               printWarning(err)
-               return nil
-       end
+       if not result then printWarning(err) return nil end
        dialog.title = string.format("%s - %s Configuration", configfile, name)
-       printInfo = dialog.msgbox
-       printWarning = dialog.msgbox
-       printError = dialog.msgbox
-       beginProcess = dialog.gauge
+       printInfo       = dialog.msgbox
+       printWarning    = dialog.msgbox
+       printError      = dialog.msgbox
+       beginProcess    = dialog.gauge
        return dialog
 end
 
@@ -185,20 +183,20 @@ local Option = util.class()
 ---------------------------------------------------------------------------
 
 function Option:__init(rule, lookup, objects)
-       self.name               = rule.name
+       self.name       = rule.name
        self.caption    = rule.caption
-       self.help               = rule.help
-       self.value              = rule.value
-       self.symbol             = rule.symbol
+       self.help       = rule.help
+       self.value      = rule.value
+       self.symbol     = rule.symbol
        self.cmdline    = rule.cmdline
-       self.config             = rule.config
-       self.export             = rule.export
+       self.config     = rule.config
+       self.export     = rule.export
        self.visible    = rule.visible
-       self.check              = rule.check
-       self.temp               = rule.temp
-       self.before             = rule.before   
-       self.after              = rule.after    
-       self.lookup             = lookup or {}
+       self.check      = rule.check
+       self.temp       = rule.temp
+       self.before     = rule.before   
+       self.after      = rule.after    
+       self.lookup     = lookup or {}
        self.objects    = objects or {}
 
        if type(self.check) == "function"   then setfenv(self.check, self.lookup) end
@@ -327,7 +325,6 @@ function Option:writeSymbol(fd)
        if self.symbol ~= nil and not self.temp
        then
                fd:write(util.align(self.symbol, "= " .. tostring(self.lookup[self.symbol]), 16) .. "\n")
-               --fd:write(string.format("%s\t= %s\n", self.symbol, tostring(self.lookup[self.symbol])))
        end
 end
 
@@ -339,7 +336,7 @@ end
 function Option:writeSedLine(fd)
        if self.export
        then
-               local value     = self:toExpandedString():gsub("/", "\\/")
+               local value = self:toExpandedString():gsub("/", "\\/")
                local function writeLine(key)
                        key = tostring(key):gsub("/", "\\/")
                        fd:write(string.format("s/@%s@/%s/g\n", key, value))
@@ -398,11 +395,11 @@ function Option:printHelpLine()
 end
 
 function Option:getHelpText()
-       local value             = self:toString()
-       local help              = self.help or "No help available.\n"
-       local name              = self.name or "Unnamed"
+       local value     = self:toString()
+       local help      = self.help or "No help available.\n"
+       local name      = self.name or "Unnamed"
        local symbol    = self:getSymbol() or "None"
-       local arg               = self:getArg() or "None"
+       local arg       = self:getArg() or "None"
 
        local problem   = self:getProblem()
        if problem then problem = "\nProblem(s):\n" .. problem
@@ -591,7 +588,7 @@ end
 function BooleanOption:writeCppLine(fd)
        if self.config
        then
-               local value     = self.lookup[self.symbol]
+               local value = self.lookup[self.symbol]
                local function writeLine(key)
                        -- Reverse the value if key starts with a bang.
                        local value = value
@@ -813,8 +810,7 @@ function GroupOption:showMenu(dialog)
                                dialog.msgbox(value.name, value:getHelpText(), {["--no-collapse"] = true})
                                selected = value:getMenuItem()
                        else
-                               dialog.msgbox("No Help",
-                                                         "Sorry, no help is available for this option.")
+                               dialog.msgbox("No Help", "Sorry, no help is available for this option.")
                        end
                else
                        running = false
@@ -964,8 +960,7 @@ if interactive then loadDialog(name, configfile) end
 options:convertDependenciesToDependants()
 checkSymbols(options:getObjects())
 
-if dialog
-then
+if dialog then
        local action = options:runMenu()
        if action == "exit" or action == "error"
        then
@@ -975,8 +970,7 @@ then
                options:saveToFile(configfile)
                print("configuration saved to " .. configfile)
        end
-elseif options:isValid()
-then
+elseif options:isValid() then
        options:saveToFile(configfile)
 else
        printError("Uh oh!", [[
index ee8a2a8a669c61157eb4ccdced3ca442ca807858..e4c76d723ede46818557fbb4d7568548d6db9fdb 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2011, Charles McGarvey  [*******************************
+/*]  Copyright (c) 2011, Charles McGarvey  [**********************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #define LUA_DIALOG_NAME                "dialog"
 #define LUA_DIALOG_VERSION     "1.0"
@@ -41,13 +39,12 @@ static void printarray(const char* argv[])
 /**
  * Fork and execute a command with arguments and optionally get a file
  * descriptor connected to one of the child's own file descriptors.  The
- * process id of the child is returned, or -1 on error.  If fd is not NULL,
- * a pipe will be created and connected to *fd.  If *fd is 0, then *fd will
- * be set to a write file descriptor connected to the child's standard
- * input.  If *fd is not 0, then *fd will be set to a read file descriptor
- * set connected to the specified file descriptor of the child.  In either
- * case, the caller has the responsibility to close fd when it is no longer
- * needed.
+ * process id of the child is returned, or -1 on error.  If fd is not NULL, a
+ * pipe will be created and connected to *fd.  If *fd is 0, then *fd will be
+ * set to a write file descriptor connected to the child's standard input.  If
+ * *fd is not 0, then *fd will be set to a read file descriptor set connected
+ * to the specified file descriptor of the child.  In either case, the caller
+ * has the responsibility to close fd when it is no longer needed.
  */
 static pid_t myexec(const char* command, char* const argv[], int* fd) 
 {
@@ -55,31 +52,24 @@ static pid_t myexec(const char* command, char* const argv[], int* fd)
        int p[2];
        pid_t child;
 
-       if (fd)
-       {
+       if (fd) {
                if (pipe(p) != 0) return -1;
                parentFd = (*fd == 0);
        }
-       if (!(child = fork()))
-       {
-               if (fd)
-               {
+       if (!(child = fork())) {
+               if (fd) {
                        close(p[parentFd]);
                        if (dup2(p[!parentFd], *fd) == -1) _exit(127);
                }
                execv(command, argv);
                _exit(127);
        }
-       if (child == -1)
-       {
+       if (child == -1) {
                if (parentFd != -1)
-               {
                        close(p[0]); close(p[1]);
-               }
                return -1;
        }
-       if (parentFd != -1)
-       {
+       if (parentFd != -1) {
                close(p[!parentFd]);
                *fd = p[parentFd];
        }
@@ -99,8 +89,8 @@ static int mywait(pid_t pid)
 
 
 /**
- * Read from a file descriptor until EOF and push contents to the top of
- * the Lua stack.  Closes the file descriptor afterward.
+ * Read from a file descriptor until EOF and push contents to the top of the
+ * Lua stack.  Closes the file descriptor afterward.
  */
 static void pushstream(lua_State* L, int fd)
 {
@@ -109,8 +99,7 @@ static void pushstream(lua_State* L, int fd)
 
        char buffer[BUFSIZ];
        ssize_t bytes;
-       while ((bytes = read(fd, buffer, sizeof(buffer))))
-       {
+       while ((bytes = read(fd, buffer, sizeof(buffer)))) {
                if (bytes == -1) break;
                luaL_addlstring(&B, buffer, bytes);
        }
@@ -125,8 +114,7 @@ static void pushstream(lua_State* L, int fd)
 static void writelstring(int fd, const char* str, size_t len)
 {
        ssize_t bytes;
-       while ((bytes = write(fd, str, len)))
-       {
+       while ((bytes = write(fd, str, len))) {
                if (bytes == -1) break;
                str += bytes;
                len -= bytes;
@@ -168,8 +156,7 @@ static void addstrings(const char* argv[], ...)
        int i; for (i = 0; argv[i]; ++i);
        va_start(ap, argv);
        const char* arg = va_arg(ap, const char*);
-       while (arg)
-       {
+       while (arg) {
                argv[i++] = arg;
                arg = va_arg(ap, const char*);
        }
@@ -197,8 +184,7 @@ static void addcommand(lua_State* L, const char* argv[])
        lua_getfield(L, -1, "command");
        lua_getfield(L, -2, "title");
        addstrings(argv, lua_tostring(L, -2), NULL);
-       if (lua_isstring(L, -1))
-       {
+       if (lua_isstring(L, -1)) {
                addstrings(argv, "--backtitle", lua_tostring(L, -1), NULL);
        }
        lua_pop(L, 3);
@@ -261,8 +247,7 @@ static int addextra(lua_State* L, const char* argv[], int n)
 {
        if (!lua_istable(L, n)) return 0;
        lua_pushnil(L);
-       while (lua_next(L, n))
-       {
+       while (lua_next(L, n)) {
                addstrings(argv, lua_tostring(L, -2), NULL);
                if (lua_isstring(L, -1)) addstrings(argv, lua_tostring(L, -1), NULL);
                lua_pop(L, 1);
@@ -296,29 +281,24 @@ static void addmenuitems(lua_State* L, const char* argv[])
        if (searchstrings(argv, "--item-help") != -1) fields = 3;
 
        if (!lua_istable(L, 3)) luaL_argerror(L, 3, "menu items");
-       int i; for (i = 1;; ++i)
-       {
+       int i; for (i = 1;; ++i) {
                lua_pushinteger(L, i);
                lua_gettable(L, 3);
-               if (lua_isnil(L, -1))
-               {
+               if (lua_isnil(L, -1)) {
                        lua_pop(L, 1);
                        break;
                }
-               else if (lua_istable(L, -1))
-               {
+               else if (lua_istable(L, -1)) {
                        int subtable = lua_gettop(L);
                        lua_pushnil(L);
-                       int j; for (j = 0; j < fields; ++j)
-                       {
+                       int j; for (j = 0; j < fields; ++j) {
                                if (!lua_next(L, subtable)) luaL_argerror(L, 3, "not enough fields");
                                addstrings(argv, lua_tostring(L, -1), NULL);
                                lua_pop(L, 1);
                        }
                        lua_pop(L, 1);
                }
-               else
-               {
+               else {
                        if (fields == 2) addstrings(argv, "", "", NULL);
                        else addstrings(argv, "", "", "", NULL);
                }
@@ -356,8 +336,7 @@ static void closegauge(lua_State* L)
 {
        lua_getfield(L, LUA_REGISTRYINDEX, "dialog_gauge_pid");
        lua_getfield(L, LUA_REGISTRYINDEX, "dialog_gauge_fd");
-       if (!lua_isnumber(L, -2) || !lua_isnumber(L, -1))
-       {
+       if (!lua_isnumber(L, -2) || !lua_isnumber(L, -1)) {
                lua_pop(L, 2);
                return;
        }
@@ -385,8 +364,7 @@ static void closegauge(lua_State* L)
  */
 static int updategauge(lua_State* L)
 {
-       if (!lua_isnumber(L, 1))
-       {
+       if (!lua_isnumber(L, 1)) {
                closegauge(L);
                return 0;
        }
@@ -399,15 +377,13 @@ static int updategauge(lua_State* L)
        if (0.0 <= percent && percent <= 1.0) percent *= 100.0;
        lua_pushinteger(L, (lua_Integer)percent);
        lua_replace(L, 1);
-       if (lua_isstring(L, 2))
-       {
+       if (lua_isstring(L, 2)) {
                writestring(fd, "XXX");
                tostream(L, 1, fd);
                tostream(L, 2, fd);
                writestring(fd, "XXX");
        }
-       else
-       {
+       else {
                tostream(L, 1, fd);
        }
        return 0;
@@ -530,32 +506,28 @@ static int dialog_yesno(lua_State* L)
 LUALIB_API int luaopen_dialog(lua_State* L)
 {
        const struct luaL_Reg dialog_funcs[] = {
-               {"gauge",               dialog_gauge},
+               {"gauge",       dialog_gauge},
                {"inputbox",    dialog_inputbox},
-               {"menu",                dialog_menu},
-               {"msgbox",              dialog_msgbox},
-               {"yesno",               dialog_yesno},
+               {"menu",        dialog_menu},
+               {"msgbox",      dialog_msgbox},
+               {"yesno",       dialog_yesno},
                {NULL, NULL}
        };
        luaL_register(L, LUA_DIALOG_NAME, dialog_funcs);
 
        const char* names[] = {getenv("DIALOG"), "dialog", "cdialog"};
-       int i; for (i = 0; i < 3; ++i)
-       {
-               if (names[i])
-               {
+       int i; for (i = 0; i < 3; ++i) {
+               if (names[i]) {
                        char* path = strdup(getenv("PATH"));
                        char* token; char** paths = &path;
-                       while ((token = strsep(paths, ":")))
-                       {
+                       while ((token = strsep(paths, ":"))) {
                                luaL_Buffer B;
                                luaL_buffinit(L, &B);
                                luaL_addstring(&B, token);
                                luaL_addstring(&B, "/");
                                luaL_addstring(&B, names[i]);
                                luaL_pushresult(&B);
-                               if (access(lua_tostring(L, -1), X_OK) == 0)
-                               {
+                               if (access(lua_tostring(L, -1), X_OK) == 0) {
                                        lua_setfield(L, -2, "command");
                                        goto break2;
                                }
@@ -564,7 +536,7 @@ LUALIB_API int luaopen_dialog(lua_State* L)
                        free(path);
                }
        }
-    luaL_error(L, "cannot find dialog executable in the path; set DIALOG");
+       luaL_error(L, "cannot find dialog executable in the path; set DIALOG");
 
 break2:
 
index 09df45fdf580bdfd3bfddbca3e903027fe9e7db3..27d212487401f0aeb374cb02400a3aed703da550 100755 (executable)
--- a/configure
+++ b/configure
@@ -11,7 +11,7 @@ die () {
 
 [ -f build/config.lua ] || die 1 <<"END"
 You must first `cd' to the project directory root where the Makefile is.
-There is no support for out-of-tree builds.
+There is no support for out-of-source-tree builds.
 END
 
 LUA=${LUA:-lua}
@@ -30,5 +30,3 @@ END
 export PATH="./build:$PATH"
 exec "$LUA" build/config.lua "$@" -L./build
 
-# vi:ts=4
-
index 1968532d47411594a74f912ef6e4a6d52a573cb1..64f76590d423f21b25c067daeb66177bf8153e2d 100644 (file)
@@ -4,10 +4,10 @@
 #
 
 pkgdatadir_$d := $(shell find $d -name "*.ac"  \
-                                 -o -name "*.lua" \
-                              -o -name "*.gz"  \
-                              -o -name "*.ogg" \
-                              -o -name "*.png") $d/yoinkrc
+                             -o -name "*.lua" \
+                             -o -name "*.gz"  \
+                             -o -name "*.ogg" \
+                             -o -name "*.png") $d/yoinkrc
 # Install resource files to pkgdatadir.
 
 desktop_$b := $b/yoink.desktop         # Install desktop entry file.
index b1364b02a64cadca5823868697c2dac5cc111605..c60f68b5987c1180e1c67ca5aad9c7eb8d893822 100644 (file)
@@ -68,12 +68,13 @@ Event = {}
 
 do
        local mysound = yoink.sound("Explosion")
-       --local mysound = yoink.sound()
-       --mysound:sample("Explosion")
+       mysound = yoink.sound()
+       mysound:sample("Pop")
        local count = 0
        function Event.Think()
                if count % 300 == 0 then
-                       --mysound:play()
+                       mysound:play()
+                       LogDebug("Hello world!")
                end
                count = count + 1
        end
index e61ddf6429e8f0ed8ea78627a042380e40ea5f07..c35ae2da6828ae02b4758f508092d128c221a975 100644 (file)
@@ -108,7 +108,7 @@ that, please observe the following:
 .It
 Stick to the coding style of the source code files you edit.  Follow the
 general style of method and variable naming, as well as white space
-formatting.  In particular, use literal tabs with an assumed tabstop of 4
+formatting.  In particular, use literal tabs with an assumed tabstop of 8
 characters.  Also, try to limit line lengths to 75 characters.
 .It
 For legal reasons, don't include other peoples' code with your patch.  You
index 30d1c756f73ddc67cc4770d548eeac4c4965e9d9..4839144d99f97a9ca19c30b40c6ecf39645a4bd5 100644 (file)
@@ -102,15 +102,15 @@ return string.format("%s %s", project, version),
                        check   = function(value)
                                if value == ""
                                then
-                                       CC              = "gcc"
-                                       CXX             = "g++"
-                                       AR              = "ar"
+                                       CC      = "gcc"
+                                       CXX     = "g++"
+                                       AR      = "ar"
                                        RANLIB  = "ranlib"
                                        WINDRES = "windres"
                                else
-                                       CC              = value .. "-gcc"
-                                       CXX             = value .. "-g++"
-                                       AR              = value .. "-ar"
+                                       CC      = value .. "-gcc"
+                                       CXX     = value .. "-g++"
+                                       AR      = value .. "-ar"
                                        RANLIB  = value .. "-ranlib"
                                        WINDRES = value .. "-windres"
                                end
@@ -314,11 +314,11 @@ If in doubt, say No.
                        check   = function(value)
                                if value
                                then
-                                       PKG_CFLAGS = PKG_CFLAGS:setFlag("-pg")
-                                       PKG_LDFLAGS = PKG_LDFLAGS:setFlag("-pg")
+                                       PKG_CFLAGS      = PKG_CFLAGS:setFlag("-pg")
+                                       PKG_LDFLAGS     = PKG_LDFLAGS:setFlag("-pg")
                                else
-                                       PKG_CFLAGS = PKG_CFLAGS:unsetFlag("-pg")
-                                       PKG_LDFLAGS = PKG_LDFLAGS:unsetFlag("-pg")
+                                       PKG_CFLAGS      = PKG_CFLAGS:unsetFlag("-pg")
+                                       PKG_LDFLAGS     = PKG_LDFLAGS:unsetFlag("-pg")
                                end
                                return value
                        end
@@ -351,10 +351,8 @@ without these extra codepaths.
 If in doubt, say No.
 ]],
                        check   = function(value)
-                               if value
-                               then
+                               if value then
                                        CFLAGS = CFLAGS:setFlag("-Wall", "-g")
-                                       CFLAGS = CFLAGS:replaceFlag("%-O%d?", "-O0")
                                end
                                return value
                        end
@@ -592,6 +590,3 @@ If in doubt, say None.
        }
 }
 
-
--- vi:ft=lua
-
index e33a12622d2a1663536012e195d19a6a43ee2c47..c7663c5f976d7fe25f07d3ad85c3447e0784b304 100755 (executable)
@@ -18,13 +18,13 @@ end
 -----
 
 function die(...) print("die:", ...); os.exit(1) end
-function isReadable(file) return os.execute("test -r "..file) == 0 end
+function readable(file) return os.execute("test -r "..file) == 0 end
 
 arg.hideEmail = false
 arg.output = "yoink.html"
 
 arg.input = "yoink.6"
-if not isReadable(arg.input) then arg.input = "build/doc/yoink.6" end
+if not readable(arg.input) then arg.input = "build/doc/yoink.6" end
 
 do
        local t = {
@@ -42,7 +42,11 @@ do
                                        showhelp(); os.exit(1)
                                end
                                skip = t[v](args, i)
-                               if tonumber(skip) then skip = skip + 1 else skip = 1 end
+                               if tonumber(skip) then
+                                       skip = skip + 1
+                               else
+                                       skip = 1
+                               end
                        end
                        skip = skip - 1
                end
@@ -51,10 +55,10 @@ end
 parseArgs(arg)
 
 filters = {
-       function(t)                                             -- 1. Edit page title
+       function(t)                     -- 1. Edit page title
                return t:gsub("(<title>).*(</title>)", "%1Yoink Manual%2")
        end,
-       function(t)                                             -- 2. Insert footer before </body>
+       function(t)                     -- 2. Insert footer before </body>
                return t:gsub("</body>", [[
 <p style="font-size: 9px; text-align: center;">
        This manual page was generated on ]]..os.date("%d %b %Y")..[[.
similarity index 74%
rename from build/arch/win32/unix2dos.sh
rename to scripts/unix2dos.sh
index c3ee7a8d336f5ef54c3a721c3fdb26198f8bf6a1..41e4085cdb70e67caab2e0334170890fe0463c68 100755 (executable)
@@ -5,11 +5,11 @@
 # An implementation of unix2dos using sed.
 #
 
-if [ -f "$1" ];
+if [ -f "$1" ]
 then
        TMPFILE="$1.$$"
        sed 's/\r*$/\r/' "$1" >$TMPFILE
-       if [ ! "$2" ];
+       if [ ! "$2" ]
        then
                mv -f "$TMPFILE" "$1"
        else
@@ -18,7 +18,7 @@ then
        rm -f "$TMPFILE"
 else
        echo "`basename $0` infile [outfile]"
-       echo "  convert a file from unix to dos file format"
+       echo "  convert a text file from unix to dos line-endings"
        exit 1
 fi 
 
index a9710ce66b525e0536789394ca014b5323a89b2f..5ab26d216704ec1ea5c15dcd84977e9a1286d4a9 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #include <map>
 #include <stdexcept>
 
 
 /**
- * The collection of nested animation classes.  The animation
- * implementation consists of an impl class which is allocated and
- * initialized with the interface object.  This class contains the specific
- * fields which are required to run a single instance of an animation.  The
- * sequence data is loaded in a different class which can be shared amongst
- * multiple animation implementation instances.
+ * The collection of nested animation classes.  The animation implementation
+ * consists of an impl class which is allocated and initialized with the
+ * interface object.  This class contains the specific fields which are
+ * required to run a single instance of an animation.  The sequence data is
+ * loaded in a different class which can be shared amongst multiple animation
+ * implementation instances.
  */
-
 class Animation::impl
 {
 public:
 
        /**
         * Contains "global" animation data for the various animations which
-        * get loaded.  This is a mippleton, so it will be shared amongst any
+        * get loaded.  This is a manager, so it will be shared amongst any
         * animation which wants to use these loaded sequences.
         */
-
        class Data : public moof::manager<Data>
        {
        public:
 
                /**
-                * A frame of an animation sequence.  A frame is merely an index
-                * which presumably represents a "slide" or tile which should be
-                * displayed, and the duration that is how long the slide will be
-                * shown.
+                * A frame of an animation sequence.  A frame is merely an
+                * index which presumably represents a "slide" or tile which
+                * should be displayed, and the duration that is how long the
+                * slide will be shown.
                 */
-
                class Frame
                {
                public:
 
-                       unsigned        mIndex;                                 ///< Frame index.
-                       moof::scalar    mDuration;                              ///< Frame duration.
+                       unsigned        mIndex;         ///< Frame index.
+                       moof::scalar    mDuration;      ///< Frame duration.
 
                        /**
-                        * Construction is initialization.  The frame data is loaded
-                        * from a frame map which is probably loaded within an
-                        * animation file.
+                        * Construction is initialization.  The frame data is
+                        * loaded from a frame map which is probably loaded
+                        * within an animation file.
                         */
-               
                        Frame(const moof::script::slot& table) :
                                mIndex(0),
                                mDuration(1.0)
@@ -73,28 +67,26 @@ public:
                        }
                };
 
-
                /**
-                * A sequence is just a few attributes and a list of frames in the
-                * order that they should be played.
+                * A sequence is just a few attributes and a list of frames in
+                * the order that they should be played.
                 */
-
                class Sequence
                {
                public:
 
                        std::vector<Frame>      mFrames;        ///< List of frames.
-                       moof::scalar                    mDelay;         ///< Scale frame durations.
-                       bool                            mLoop;          ///< Does the sequence repeat?
-                       std::string                     mNext;          ///< Next sequence name.
+                       moof::scalar            mDelay;         ///< Scale frame durations.
+                       bool                    mLoop;          ///< Does the sequence repeat?
+                       std::string             mNext;          ///< Next sequence name.
 
                        /**
-                        * Construction is initialization.  The constructor loads
-                        * sequence data from the sequence map, presumably loaded from
-                        * an animation file.  The rest of the loading takes place in
-                        * the frame's constructor which loads each individual frame.
+                        * Construction is initialization.  The constructor
+                        * loads sequence data from the sequence map,
+                        * presumably loaded from an animation file.  The rest
+                        * of the loading takes place in the frame's
+                        * constructor which loads each individual frame.
                         */
-
                        Sequence(const moof::script::slot& table) :
                                mDelay(0.0),
                                mLoop(true)
@@ -106,35 +98,27 @@ public:
                                // TODO - sequence class/type not yet implemented
 
                                moof::script::slot frameTable = table.push_field("frames");
-                               if (frameTable.is_table())
-                               {
+                               if (frameTable.is_table()) {
                                        int max = frameTable.length();
-                                       for (int index = 1; index <= max; ++index)
-                                       {
+                                       for (int index = 1; index <= max; ++index) {
                                                moof::script::slot top = frameTable.push_field(index);
 
                                                if (top.is_table())
-                                               {
                                                        mFrames.push_back(Frame(top));
-                                               }
                                                else
-                                               {
                                                        moof::log_warning << "invalid frame at index "
                                                                                   << index << std::endl;
-                                               }
                                        }
                                }
                                frameTable.remove();
                        }
                };
 
-
                /**
                 * Starts loading a file with animation data.  Such a file is
                 * formatted as a map of named sequences.   The sequence
                 * constructor loads each individual sequence.
                 */
-
                void init(const std::string& name)
                {
                        moof::script script;
@@ -144,8 +128,7 @@ public:
                        moof::log::import(script);
                        importAnimationBindings(script);
 
-                       if (script.do_file(path) != moof::script::success)
-                       {
+                       if (script.do_file(path) != moof::script::success) {
                                std::string str;
                                script[-1].get(str);
                                moof::log_warning(str);
@@ -165,12 +148,10 @@ public:
                        return 0;
                }
 
-
                void importAnimationBindings(moof::script& script)
                {
                        script.import_function("DefineSequence",
-                                                                 boost::bind(&Data::defineSequence,
-                                                                                         this, _1));
+                                       boost::bind(&Data::defineSequence, this, _1));
 
                        script.globals().set_field("ATTACK",    1);
                        script.globals().set_field("CHARGE",    2);
@@ -181,15 +162,12 @@ public:
                        script.globals().set_field("STAND",     7);
                }
 
-
                std::map<std::string,Sequence> mSequences;      ///< List of sequences.
        };
 
-
        /**
         * Construction is intialization.
         */
-
        impl(const std::string& name) :
                mData(Data::instance(name)),
                mCurrentSequence(0),
@@ -198,59 +176,50 @@ public:
                mTimeAccum(0),
                mFrameDuration(0) {}
 
-
        /**
         * Sets up the animation classes to "play" a named sequence.  If
         * another sequence was active, it will be replaced.  Future updates
         * will progress the new sequence.
         */
-
        void startSequence(const std::string& name)
        {
                std::map<std::string,Data::Sequence>::iterator it;
 
                it = mData->mSequences.find(name);
-               if (it != mData->mSequences.end())
-               {
+               if (it != mData->mSequences.end()) {
                        mCurrentSequence = &(*it).second;
                        mFrameCounter = 0;
                        mFrameIndex = mCurrentSequence->mFrames[0].mIndex;
                        mTimeAccum = 0.0;
                        mFrameDuration = mCurrentSequence->mDelay *
-                                                        mCurrentSequence->mFrames[0].mDuration;
+                               mCurrentSequence->mFrames[0].mDuration;
                }
        }
 
        /**
         * Updates or progresses the animation sequence.  If the time interval
-        * surpasses the duration of the current frame, a new frame becomes the
-        * current frame.  If the last frame of a sequence expires, the active
-        * sequence will switch automatically to the designated "next"
+        * surpasses the duration of the current frame, a new frame becomes
+        * the current frame.  If the last frame of a sequence expires, the
+        * active sequence will switch automatically to the designated "next"
         * sequence, or if none is specified but the sequence is set to loop,
         * the first frame of the sequence will become the current frame, and
         * the animation essentially starts over again.
         */
-
        void update(moof::scalar t, moof::scalar dt)
        {
                if (!mCurrentSequence) return;
 
                mTimeAccum += dt;
 
-               if (mTimeAccum >= mFrameDuration)
-               {
-                       if (++mFrameCounter >= mCurrentSequence->mFrames.size())
-                       {
-                               if (!mCurrentSequence->mNext.empty())
-                               {
+               if (mTimeAccum >= mFrameDuration) {
+                       if (++mFrameCounter >= mCurrentSequence->mFrames.size()) {
+                               if (!mCurrentSequence->mNext.empty()) {
                                        startSequence(mCurrentSequence->mNext);
                                }
-                               else if (mCurrentSequence->mLoop)
-                               {
+                               else if (mCurrentSequence->mLoop) {
                                        mFrameCounter = 0;
                                }
-                               else
-                               {
+                               else {
                                        mFrameCounter--;
                                        mCurrentSequence = 0;
                                }
@@ -263,21 +232,19 @@ public:
                }
        }
 
-       boost::shared_ptr<Data> mData;                          ///< Internal data.
+       boost::shared_ptr<Data> mData;                  ///< Internal data.
 
-       Data::Sequence*                 mCurrentSequence;       ///< Active sequence.
-       unsigned                                mFrameCounter;          ///< Current frame.
-       unsigned                                mFrameIndex;            ///< Index of current frame.
-       moof::scalar                            mTimeAccum;                     ///< Time accumulation.
-       moof::scalar                            mFrameDuration;         ///< Scaled frame duration.
+       Data::Sequence*         mCurrentSequence;       ///< Active sequence.
+       unsigned                mFrameCounter;          ///< Current frame.
+       unsigned                mFrameIndex;            ///< Index of current frame.
+       moof::scalar            mTimeAccum;             ///< Time accumulation.
+       moof::scalar            mFrameDuration;         ///< Scaled frame duration.
 };
 
-
 Animation::Animation(const std::string& name) :
        // pass through
        impl_(new Animation::impl(name)) {}
 
-
 void Animation::startSequence(const std::string& name)
 {
        // pass through
@@ -290,12 +257,10 @@ void Animation::update(moof::scalar t, moof::scalar dt)
        impl_->update(t, dt);
 }
 
-
 /**
  * Gets the index for the current frame.  This is presumably called by some
  * drawing code which will draw the correct current frame.
  */
-
 unsigned Animation::getFrame() const
 {
        return impl_->mFrameIndex;
index 97e916d8b5f3a77ae502cd50c878b79733020355..c8cdca8ed752c4b3addfdc4ee0ccd61906cabc19 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _ANIMATION_HH_
 #define _ANIMATION_HH_
@@ -34,7 +32,6 @@ typedef boost::shared_ptr<Animation> AnimationP;
  * is determined.  This class is generic enough that a frame can mean just
  * about anything to whatever drawing context is used to render the frame.
  */
-
 class Animation
 {
 public:
@@ -46,13 +43,11 @@ public:
                return AnimationP(new Animation(name));
        }
 
-
        void startSequence(const std::string& name);
 
        void update(moof::scalar t, moof::scalar dt);
        unsigned getFrame() const;
 
-
 private:
 
        class impl;
index 3cae68009e4b998bf8b4b823538204bf6c803a66..c6a47f9c9ed1f5e605e42b23d6d7fcbfc8702286 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #include <iostream>
 
@@ -42,6 +40,7 @@ private:
        moof::vector2 location;
 };
 
+
 class ResistanceForce
 {
 public:
@@ -85,7 +84,6 @@ Character::Character(const std::string& name) :
        prev_state_ = state_;
 }
 
-
 void Character::update(moof::scalar t, moof::scalar dt)
 {
        moof::rigid_body2::update(t, dt); // update physics
@@ -103,7 +101,6 @@ void Character::update(moof::scalar t, moof::scalar dt)
        tilemap.tile(frame);
 }
 
-
 void Character::draw(moof::scalar alpha) const
 {
        moof::state2 state = moof::rigid_body2::state(alpha);
@@ -121,7 +118,6 @@ void Character::draw(moof::scalar alpha) const
        tilemap.draw(coords);
 }
 
-
 /*int Character::getOctant(const moof::Aabb<3>& aabb) const
 {
        int octantNum = -1;
@@ -232,7 +228,6 @@ void Character::draw(moof::scalar alpha) const
 }
 */
 
-
 void Character::addImpulse(moof::vector2 impulse)
 {
        state_.momentum += impulse;
index bdbdb29414f0a6ce436e440691bab99ae53f203a..bb2d5e6dd69f9efeb920408401df4daa1ccab14a 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _CHARACTER_HH_
 #define _CHARACTER_HH_
 class Character;
 typedef boost::shared_ptr<Character> CharacterP;
 
-
 /**
  * Parent class of animate objects with "personalities."  This basically
  * includes the heroine herself and the bad guys.
  */
-
 class Character : public moof::rigid_body2
 {
 public:
@@ -52,7 +48,7 @@ public:
        //virtual int getOctant(const moof::Aabb<3>& aabb) const;
 
        moof::sprite    tilemap;
-       Animation               animation;
+       Animation       animation;
 };
 
 
index 66b7a7d938e1d9cbe5109a124404b4578b5e834d..ecf9e05e08b60af28a0dfc07847d52bb42756ad6 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _GAMESTATE_HH_
 #define _GAMESTATE_HH_
 
 struct GameState
 {
-       moof::script                            script;
+       moof::script                    script;
        std::vector<std::string>        sceneList;
 
-       HeroineP                                        heroine;
-       SceneP                                          scene;
+       HeroineP                        heroine;
+       SceneP                          scene;
 
-       moof::lerp_scalar                       interp;
+       moof::lerp_scalar               interp;
 
-       moof::camera                            camera;
+       moof::camera                    camera;
 };
 
 
index a20691855b7fb44a42fcc0eb9962780170fba576..4ca4ce8702006cd46bd55c79ec5465d71f947fda 100644 (file)
@@ -1,88 +1,87 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #include <moof/log.hh>
 #include <moof/sound.hh>
 
 #include "Heroine.hh"
        
+
 Heroine::Heroine() :
        Character("Heroine") {}
 
-
 void Heroine::update(moof::scalar t, moof::scalar dt)
 {
        Character::update(t, dt);
 
-       moof::vector3 at(0.0, 0.0, 0.0);
-       const moof::vector3 up(0.0, 1.0, 0.0);
+       moof::vector3           at(0.0, 0.0, 0.0);
+       const moof::vector3     up(0.0, 1.0, 0.0);
 
        if (state_.velocity[0] < 0.0) at[0] = -1.0;
-       else                          at[0] = 1.0;
+       else at[0] = 1.0;
 
        moof::sound::listener_position(moof::promote(state_.position));
        moof::sound::listener_velocity(moof::promote(state_.velocity));
        moof::sound::listener_orientation(at, up);
 }
 
-
 bool Heroine::handle_event(const moof::event& event)
 {
        moof::scalar force = 40.0;
        
        switch (event.type)
        {
-               case SDL_KEYDOWN:
-                       if (event.key.keysym.sym == SDLK_a)
-                       {
-                               state_.force += moof::vector2(-force, 0.0);
-                               return true;
-                       }
-                       else if (event.key.keysym.sym == SDLK_d)
-                       {
-                               state_.force += moof::vector2(force, 0.0);
-                               return true;
-                       }
-                       else if (event.key.keysym.sym == SDLK_s)
-                       {
-                               state_.force += moof::vector2(0.0, -force);
-                               return true;
-                       }
-                       else if (event.key.keysym.sym == SDLK_w)
-                       {
-                               state_.force += moof::vector2(0.0, force);
-                               return true;
-                       }
+       case SDL_KEYDOWN:
+               if (event.key.keysym.sym == SDLK_a)
+               {
+                       state_.force += moof::vector2(-force, 0.0);
+                       return true;
+               }
+               else if (event.key.keysym.sym == SDLK_d)
+               {
+                       state_.force += moof::vector2(force, 0.0);
+                       return true;
+               }
+               else if (event.key.keysym.sym == SDLK_s)
+               {
+                       state_.force += moof::vector2(0.0, -force);
+                       return true;
+               }
+               else if (event.key.keysym.sym == SDLK_w)
+               {
+                       state_.force += moof::vector2(0.0, force);
+                       return true;
+               }
+               break;
 
-               case SDL_KEYUP:
-                       if (event.key.keysym.sym == SDLK_a)
-                       {
-                               state_.force += moof::vector2(force, 0.0);
-                               return true;
-                       }
-                       else if (event.key.keysym.sym == SDLK_d)
-                       {
-                               state_.force += moof::vector2(-force, 0.0);
-                               return true;
-                       }
-                       else if (event.key.keysym.sym == SDLK_s)
-                       {
-                               state_.force += moof::vector2(0.0, force);
-                               return true;
-                       }
-                       else if (event.key.keysym.sym == SDLK_w)
-                       {
-                               state_.force += moof::vector2(0.0, -force);
-                               return true;
-                       }
+       case SDL_KEYUP:
+               if (event.key.keysym.sym == SDLK_a)
+               {
+                       state_.force += moof::vector2(force, 0.0);
+                       return true;
+               }
+               else if (event.key.keysym.sym == SDLK_d)
+               {
+                       state_.force += moof::vector2(-force, 0.0);
+                       return true;
+               }
+               else if (event.key.keysym.sym == SDLK_s)
+               {
+                       state_.force += moof::vector2(0.0, force);
+                       return true;
+               }
+               else if (event.key.keysym.sym == SDLK_w)
+               {
+                       state_.force += moof::vector2(0.0, -force);
+                       return true;
+               }
+               break;
        }
        return false;
 }
index 6eb5a547eca85d8a803961ed23d4954abe23aedc..4cbf8b1a4d9e1e449feedd541bf60dd52fe91e9c 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _HEROINE_HH_
 #define _HEROINE_HH_
 class Heroine;
 typedef boost::shared_ptr<Heroine> HeroineP;
 
-
 /**
  * The protagonist.
  */
-
 class Heroine : public Character
 {
 public:
index cc25dd582171a80551192c1148f65bba4a378a12..dde53ee37b5f486c807dfda50680841387163c21 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #include <moof/aabb.hh>
 #include <moof/log.hh>
@@ -62,11 +60,8 @@ void ProgressBar::setProgress(moof::scalar progress)
 
 void ProgressBar::draw(moof::scalar alpha) const
 {
-       if (moof::is_equal(mProgress, 0.0))
-       {
-               // don't draw anything if the progress is 0%
-               return;
-       }
+       if (moof::is_equal(mProgress, 0.0)) return;
+       // don't draw anything if the progress is 0%
 
        glColor4f(1.0f, 1.0f, 1.0f, 0.85f);
        mTilemap.bind();
@@ -113,13 +108,12 @@ Hud::Hud(GameState& state) :
        resize(video->width(), video->height());
 }
 
-
 void Hud::resize(int width, int height)
 {
        moof::matrix_orthographic_RH(mProjection, SCALAR(0.0), 
-                                                                moof::scalar(width), SCALAR(0.0),
-                                                                moof::scalar(height),
-                                                                SCALAR(1.0), SCALAR(-1.0), moof::z_clip_neg_one);
+                       moof::scalar(width), SCALAR(0.0),
+                       moof::scalar(height), SCALAR(1.0),
+                       SCALAR(-1.0), moof::z_clip_neg_one);
 
        // position the two progress bars at the top-left of the screen
        mBar1.resize(moof::rectangle(20, height - 51, 0.7 * width, height - 3));
@@ -129,7 +123,6 @@ void Hud::resize(int width, int height)
        setBar2Progress(0.0);
 }
 
-
 void Hud::update(moof::scalar t, moof::scalar dt)
 {
        state_.interp.update(t, dt);
@@ -167,20 +160,20 @@ bool Hud::handle_event(const moof::event& event)
 {
        switch (event.type)
        {
-               case SDL_KEYUP:
-                       if (event.key.keysym.sym == SDLK_h)
-                       {
-                               // don't want the hud anymore
-                               //parent().remove_child(this);
-
-                               moof::log_warning("okay bye bye hud");
-                               return true;
-                       }
-                       break;
-
-               case SDL_VIDEORESIZE:
-                       resize(event.resize.w, event.resize.h);
-                       break;
+       case SDL_KEYUP:
+               if (event.key.keysym.sym == SDLK_h)
+               {
+                       // don't want the hud anymore
+                       //parent().remove_child(this);
+
+                       moof::log_warning("okay bye bye hud");
+                       return true;
+               }
+               break;
+
+       case SDL_VIDEORESIZE:
+               resize(event.resize.w, event.resize.h);
+               break;
        }
 
        return false;
index 30c01363435a73becfe351528b1d07f0514fa0bb..05882ed0121f439250925846594991335bb13cad 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _HUD_HH_
 #define _HUD_HH_
@@ -25,6 +23,7 @@
 #include "GameState.hh"
 
 
+// forward declarations
 class rectangle;
 
 // TODO this stuff is still just hacked up
index a674bbcb0dd9675a560cd2e6564f8c17da1aa7b4..8b011638735b48061d32fdafcdbf8096095bbfaa 100644 (file)
@@ -1,26 +1,26 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
+#if HAVE_CONFIG_H
 #include "config.h"
+#endif
 
-#include <cstdlib>             // atexit
+#include <cstdlib>     // atexit
 #include <exception>
 #include <functional>
 #include <iostream>
 #include <string>
 
-#if PLATFORM_WIN32
-inline int isatty(int dummy) { return 0; }
-#else
+#if PLATFORM_POSIX
 #include <termios.h>
+#else
+inline int isatty(int dummy) { return 0; }
 #endif
 
 #include <stlplus/portability/file_system.hpp>
@@ -53,7 +53,6 @@ Main::Main(moof::settings& settings) :
 #endif
 }
 
-
 void Main::update(moof::scalar t, moof::scalar dt)
 {
        yoink.update(t, dt);
@@ -78,35 +77,31 @@ void Main::handle_event(const moof::event& event)
 
        switch (event.type)
        {
-               case SDL_KEYUP:
-
-                       if (event.key.keysym.sym == SDLK_f)
-                       {
-                               moof::video::current()->toggle_fullscreen();
-                       }
-                       else if (event.key.keysym.sym == SDLK_l)
-                       {
-                               moof::video::current()->toggle_cursor_captured();
-                               moof::video::current()->toggle_cursor_visible();
-                       }
-                       else if (event.key.keysym.sym == SDLK_ESCAPE)
-                       {
-                               stop();
-                       }
-                       break;
-
-               case SDL_VIDEORESIZE:
-
-                       glViewport(0, 0, event.resize.w, event.resize.h);
-                       break;
-
-               case SDL_QUIT:
-
+       case SDL_KEYUP:
+               if (event.key.keysym.sym == SDLK_f)
+               {
+                       moof::video::current()->toggle_fullscreen();
+               }
+               else if (event.key.keysym.sym == SDLK_l)
+               {
+                       moof::video::current()->toggle_cursor_captured();
+                       moof::video::current()->toggle_cursor_visible();
+               }
+               else if (event.key.keysym.sym == SDLK_ESCAPE)
+               {
                        stop();
+               }
+               break;
+
+       case SDL_VIDEORESIZE:
+               glViewport(0, 0, event.resize.w, event.resize.h);
+               break;
+
+       case SDL_QUIT:
+               stop();
        }
 }
 
-
 std::string Main::search_paths()
 {
        // Add search paths; they should be searched in this order:
@@ -152,7 +147,6 @@ std::string Main::config_paths()
        return path;
 }
 
-
 void Main::setup_opengl()
 {
        glEnable(GL_TEXTURE_2D);
@@ -187,27 +181,26 @@ void Main::setup_opengl()
        glLightfv(GL_LIGHT0, GL_SPECULAR, spec);
 }
 
-
 void Main::print_usage()
 {
        std::cout << "Usage: "
-                         << PACKAGE" [-h|--help] [-i|--info] [OPTION=VALUE]..."
-                         << std::endl
-                         << "The alien-smashing action game." << std::endl
-                         << std::endl
-                         << "Options:" << std::endl
-                         << "  -h, --help" << std::endl
-                         << "      show this help and exit" << std::endl
-                         << "  -i, --info" << std::endl
-                         << "      show version and build information" << std::endl
-                         << "  detail=1|2|3" << std::endl
-                         << "      the level of detail of game scenes" << std::endl
-                         << "  fullscreen=true|false" << std::endl
-                         << "      if true, uses the entire display" << std::endl
-                         << "  framerate=num" << std::endl
-                         << "      number of frames to draw per second" << std::endl
-                         << std::endl
-                         << "See documentation for more options." << std::endl;
+                 << PACKAGE" [-h|--help] [-i|--info] [OPTION=VALUE]..."
+                 << std::endl
+                 << "The alien-smashing action game." << std::endl
+                 << std::endl
+                 << "Options:" << std::endl
+                 << "  -h, --help" << std::endl
+                 << "      show this help and exit" << std::endl
+                 << "  -i, --info" << std::endl
+                 << "      show version and build information" << std::endl
+                 << "  detail=1|2|3" << std::endl
+                 << "      the level of detail of game scenes" << std::endl
+                 << "  fullscreen=true|false" << std::endl
+                 << "      if true, uses the entire display" << std::endl
+                 << "  framerate=num" << std::endl
+                 << "      number of frames to draw per second" << std::endl
+                 << std::endl
+                 << "See documentation for more options." << std::endl;
 }
 
 void Main::print_info(int argc, char* argv[])
@@ -220,27 +213,14 @@ void Main::print_info(int argc, char* argv[])
 #endif
 }
 
-void Main::print_option(const std::string& option, bool enabled)
-{
-       if (isatty(1) == 1)
-       {
-               if (enabled) std::cout << "\033[1;94m";
-               else std::cout << "\033[1m";
-       }
-       if (!enabled) std::cout << "-";
-       std::cout << option;
-       if (isatty(1) == 1) std::cout << "\033[0m";
-       std::cout << " ";
-}
-
 
 void hello()
 {
        if (isatty(1) == 1) std::cout << "\033[94m";
        std::cout << std::endl << PACKAGE_STRING << std::endl
-                         << "Compiled " << __TIME__ " " __DATE__ << std::endl
-                         << "Send patches and bug reports to <"
-                         PACKAGE_BUGREPORT << ">." << std::endl << moof::log::endl;
+                 << "Compiled " << __TIME__" "__DATE__ << std::endl
+                 << "Send patches and bug reports to <"PACKAGE_BUGREPORT">."
+                 << std::endl << moof::log::endl;
 }
 
 void goodbye()
@@ -297,18 +277,16 @@ int main(int argc, char* argv[])
        catch (const std::exception& e)
        {
                moof::modal_dialog dialog(moof::modal_dialog::error,
-                                                                 PACKAGE_STRING, "unhandled exception",
-                                                                 e.what());
+                               PACKAGE_STRING, "unhandled exception",
+                               e.what());
                dialog.run();
        }
        catch (const char* e)
        {
                moof::modal_dialog dialog(moof::modal_dialog::error,
-                                                                 PACKAGE_STRING, "unhandled exception",
-                                                                 e);
+                               PACKAGE_STRING, "unhandled exception", e);
                dialog.run();
        }
-
        return 1;
 }
 
index 088bd3c1b67e393303165f1a774e6370e84d57be..65ad901ccf700a8bb1d1a59cfae0609e27e50f71 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MAIN_HH_
 #define _MAIN_HH_
@@ -34,7 +32,7 @@ class Main : public moof::application
 {
 public:
 
-       Main(moof::settings& settings);
+       explicit Main(moof::settings& settings);
 
        void update(moof::scalar t, moof::scalar dt);
        void draw(moof::scalar alpha) const;
@@ -53,8 +51,6 @@ private:
         */
        static void setup_opengl();
 
-       static void print_option(const std::string& option, bool enabled);
-
        moof::dispatcher::handle        video_reloaded_;
        moof::timer                                     hotload_timer_;
 
index af54c28768cfa92af735ccb9858d211f0a0789b2..dc6ab75cac02f218bebd54d1b173382c64086389 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #include <map>
 
@@ -36,12 +34,12 @@ struct Scene::impl : public moof::manager<impl>
                        NONE    = 0,
                        LEFT    = 1,
                        RIGHT   = 2,
-                       TOP             = 3
+                       TOP     = 3
                };
 
                Quad(const moof::vector3* vertices[4],
-                        const moof::image_handle& texture,
-                        int tileIndex) :
+                               const moof::image_handle& texture,
+                               int tileIndex) :
                        mTilemap(texture, tileIndex),
                        mBlending(false),
                        mFog(false),
@@ -112,9 +110,9 @@ struct Scene::impl : public moof::manager<impl>
                
                moof::sprite    mTilemap;
 
-               bool                    mBlending;
-               bool                    mFog;
-               Surface                 mSurface;
+               bool            mBlending;
+               bool            mFog;
+               Surface         mSurface;
        };
 
 
@@ -123,9 +121,9 @@ struct Scene::impl : public moof::manager<impl>
        moof::image_handle      mTexture;
 
        std::list< boost::shared_ptr<impl::Quad> >      mObjects;
-       std::list<moof::line2>                                          mLines;
+       std::list<moof::line2>                          mLines;
 
-       moof::aabb<3>                           mBounds;
+       moof::aabb<3>                                   mBounds;
 
 
        enum AXIS
@@ -264,14 +262,13 @@ struct Scene::impl : public moof::manager<impl>
 
        int rotate(moof::script& script)
        {
-               size_t                  index = 0;
+               size_t          index = 0;
                moof::scalar    value;
 
                script[1].require_number().get(index);
                script[2].require_number().get(value);
 
-               moof::matrix_rotate_about_world_axis(mTransform, index,
-                                                                                        moof::rad(value));
+               moof::matrix_rotate_about_world_axis(mTransform, index, moof::rad(value));
 
                return 0;
        }
@@ -350,7 +347,7 @@ struct Scene::impl : public moof::manager<impl>
                        }
                }
 
-               Quad::Surface   surface = Quad::NONE;
+               Quad::Surface surface = Quad::NONE;
                table.get(surface, "surface");
 
                if (surface != Quad::NONE)
@@ -365,7 +362,6 @@ struct Scene::impl : public moof::manager<impl>
 
                        mLines.push_back(moof::line<2>(bl, tr));
                }
-
                return 0;
        }
 
@@ -374,8 +370,8 @@ struct Scene::impl : public moof::manager<impl>
                moof::script::slot param = script[1];
                moof::script::slot top = script[-1];
 
-               int             index = 0;
-               int             width = 1;
+               int     index = 0;
+               int     width = 1;
                bool    blending = false;
                bool    fog = false;
 
@@ -479,7 +475,7 @@ void Scene::draw_if_visible(moof::scalar alpha,
 
 
 bool Scene::castRay(const moof::ray<2>& ray,
-                                       std::list<moof::ray<2>::contact>& hits) const
+               std::list<moof::ray<2>::contact>& hits) const
 {
        std::list< moof::line<2> >& lines = impl_->mLines;
        std::list< moof::line<2> >::const_iterator it;
@@ -558,4 +554,3 @@ bool Scene::checkForCollision(Character& character)
        return false;
 }
 
-
index 8c60cc50bb0f533b9e3fa1c83b24b0fbc153b30b..7f36f9b897f7536446a04d522e31751582c708ad 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _SCENE_HH_
 #define _SCENE_HH_
 #include <moof/script.hh>
 
 
-class Character;
-
-
+// forward declarations
 namespace moof {
 class settings;
 }
+class Character;
 
 class Scene;
 typedef boost::shared_ptr<Scene> SceneP;
index b060ccf26e038c2c5c7c28834c0fde3f2c64644e..f0facbb81b25edc5bbed4d0ab1e87e6a62614dba 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #include <iostream>
 
index 3a7d378bccedde576340338fcbebcbca271054d5..b3759a93aee111e12e5d45215daf3d684a2bbe7c 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _TILEMAPFONT_HH_
 #define _TILEMAPFONT_HH_
index 1b21f76ea404ff99091b1a790e36502f5251161e..e6689e52d9817ba5c0534a008a475fea812c90c0 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #include <algorithm>
 #include <cstdarg>
index 19e6dbfa7aedec91962eb9808b5346a6611148cf..ac2e3f1198028dc743cf5e4b8ac66cb316c37873 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _TYPESETTER_HH_
 #define _TYPESETTER_HH_
index cbad71bf624704d345c84127a87e1cc062558273..f403f7aa28f34c88629405eb9b077e6817945376 100644 (file)
@@ -1,21 +1,17 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #include "aabb.hh"
 #include "script.hh"
 
-
 namespace moof {
 
-
 void import_aabb_class(script& script)
 {
 }
index b2fc4b0d23835ce44d1d7a6bb48afbe06bc6f3db..3228b5a225a412927a0601b68c5a77bc608a5383 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_AABB_HH_
 #define _MOOF_AABB_HH_
@@ -31,9 +29,9 @@
 namespace moof {
 
 
+// forward declarations
 class script;
 
-
 template <int D = 3>
 struct aabb : public cullable, public drawable, public shape<D>
 {
@@ -42,7 +40,6 @@ struct aabb : public cullable, public drawable, public shape<D>
        vector min;
        vector max;
 
-
        aabb() {}
 
        aabb(const vector& a, const vector& b)
@@ -66,7 +63,6 @@ struct aabb : public cullable, public drawable, public shape<D>
                init(a, b);
        }
 
-
        void init(const vector2& a, const vector2& b)
        {
                if (a[0] < b[0])
@@ -125,13 +121,11 @@ struct aabb : public cullable, public drawable, public shape<D>
                }
        }
 
-
        vector center() const
        {
                return (min + max) / 2.0;
        }
 
-
        plane xy_plane() const
        {
                plane plane;
@@ -156,7 +150,6 @@ struct aabb : public cullable, public drawable, public shape<D>
                return plane;
        }
 
-
        void get_corners(vector2 corners[4]) const
        {
                corners[0][0] = min[0]; corners[0][1] = min[1];
@@ -193,12 +186,10 @@ struct aabb : public cullable, public drawable, public shape<D>
                corners[7][2] = min[2];
        }
 
-
        void enclose_vertices(const vector vertices[], unsigned count)
        {
                min.zero();
                max.zero();
-
                for (unsigned i = 1; i < count; ++i)
                {
                        min.minimize(vertices[i]);
@@ -206,7 +197,6 @@ struct aabb : public cullable, public drawable, public shape<D>
                }
        }
 
-
        void draw(scalar alpha = 0.0) const
        {
                glRect(min[0], min[1], max[0], max[1]);
@@ -224,21 +214,25 @@ void import_aabb_class(script& script);
 template <>
 inline void aabb<3>::draw(scalar alpha) const
 {
-       scalar vertices[] = {min[0], min[1], min[2],
-                                                min[0], max[1], min[2],
-                                                max[0], max[1], min[2],
-                                                max[0], min[1], min[2],
-                                                min[0], max[1], max[2],
-                                                min[0], min[1], max[2],
-                                                max[0], min[1], max[2],
-                                                max[0], max[1], max[2]};
-
-       GLubyte indices[] = {0, 1, 2, 3,
-                                                1, 2, 7, 4,
-                                                3, 0, 5, 6,
-                                                2, 3, 6, 7,
-                                                5, 0, 1, 4,
-                                                4, 5, 6, 7};
+       scalar vertices[] = {
+               min[0], min[1], min[2],
+               min[0], max[1], min[2],
+               max[0], max[1], min[2],
+               max[0], min[1], min[2],
+               min[0], max[1], max[2],
+               min[0], min[1], max[2],
+               max[0], min[1], max[2],
+               max[0], max[1], max[2]
+       };
+
+       GLubyte indices[] = {
+               0, 1, 2, 3,
+               1, 2, 7, 4,
+               3, 0, 5, 6,
+               2, 3, 6, 7,
+               5, 0, 1, 4,
+               4, 5, 6, 7
+       };
 
        glEnableClientState(GL_VERTEX_ARRAY);
        glDisableClientState(GL_TEXTURE_COORD_ARRAY);
@@ -247,8 +241,7 @@ inline void aabb<3>::draw(scalar alpha) const
        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
        image::reset_binding();
 
-       glDrawElements(GL_QUADS, sizeof(indices), GL_UNSIGNED_BYTE,
-                                  indices);
+       glDrawElements(GL_QUADS, sizeof(indices), GL_UNSIGNED_BYTE, indices);
 
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
        //glDisableClientState(GL_VERTEX_ARRAY);
@@ -262,7 +255,6 @@ inline bool aabb<3>::is_visible(const frustum& frustum) const
        return frustum.contains(*this);
 }
 
-
 typedef aabb<2>                aabb2;
 typedef aabb2          rectangle;
 typedef aabb<3>                aabb3;
index 0da5bae4b449a989b878c427a541bd065d0ee00f..e0b73b78d9ac053e7a5f8805a2431acc4c730235 100644 (file)
@@ -1,15 +1,13 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
-#include <cstdlib>                                     // exit, srand
+#include <cstdlib>                     // exit, srand
 #include <boost/noncopyable.hpp>
 
 #include <SDL/SDL.h>
@@ -42,20 +40,19 @@ application::application(settings& settings) :
        settings.get("framerate", framerate);
        framerate = SCALAR(1.0) / framerate;
 
-       //timer::default_source().scale(SCALAR(0.76));
-
        //update_timer_.init(boost::bind(&application::dispatch_update,
-                                                                  //this, _1, _2),
-                                          //timestep_, timer::repeat);
+               //this, _1, _2), timestep_, timer::repeat);
        //add_timer(update_timer_);
        
        game_time_.reset(timestep_);
+       //game_time_.scale(SCALAR(0.5));
 
        draw_timer_.init(boost::bind(&application::dispatch_draw,
-                                                                this, _1, _2), framerate, timer::repeat);
+                               this, _1, _2), framerate, timer::repeat);
        add_timer(draw_timer_);
-}
 
+       //timer::default_source().scale(SCALAR(0.2));
+}
 
 void application::dispatch_update(timer& timer, scalar t)
 {
@@ -65,27 +62,23 @@ void application::dispatch_update(timer& timer, scalar t)
        {
                switch (event.type)
                {
-                       case SDL_KEYDOWN:
-
-                               if (event.key.keysym.sym == SDLK_ESCAPE &&
-                                               (SDL_GetModState() & KMOD_CTRL) )
-                               {
-                                       // emergency escape
-                                       log_warning("escape forced");
-                                       exit(1);
-                               }
-                               break;
-
-                       case SDL_VIDEORESIZE:
-
-                               video::current()->resize(event.resize.w, event.resize.h);
-                               break;
+               case SDL_KEYDOWN:
+                       if (event.key.keysym.sym == SDLK_ESCAPE &&
+                                       (SDL_GetModState() & KMOD_CTRL))
+                       {
+                               log_warning("escape forced");
+                               exit(1);
+                       }
+                       break;
+
+               case SDL_VIDEORESIZE:
+                       video::current()->resize(event.resize.w,
+                                       event.resize.h);
+                       break;
                }
-
                handle_event(event);
        }
 
-
        const int MAX_CONSECUTIVE_UPDATES = 15;
 
        log_debug("updating", timer.expiration(), "/", t);
@@ -96,9 +89,8 @@ void application::dispatch_update(timer& timer, scalar t)
        int i = 0;
        while (timestep_ <= accum_ && i < MAX_CONSECUTIVE_UPDATES)
        {
-               log_debug("UPDATING");
-               update(game_time_.ticks(), timestep_);
-               game_time_.step();
+               scalar dt = game_time_.step();
+               update(game_time_.ticks(), dt);
                accum_ -= timestep_;
        }
 
@@ -116,7 +108,7 @@ void application::dispatch_draw(timer& timer, scalar t)
 
        scalar alpha = accum_ * inverse_timestep_;
        
-       alpha = cml::clamp(alpha, SCALAR(-1.0), SCALAR(2.0));
+       //alpha = cml::clamp(alpha, SCALAR(-1.0), SCALAR(2.0));
        if (alpha < SCALAR(0.0)) log_warning("alpha:", alpha);
        else if (alpha > SCALAR(1.0)) log_warning("alpha:", alpha);
        else log_debug("alpha:", alpha);
@@ -125,9 +117,11 @@ void application::dispatch_draw(timer& timer, scalar t)
 
        scalar begin = timer::ticks();
        video::current()->swap(t);
-
        scalar duration = timer::ticks() - begin;
-       log_debug("flip duration:", duration);
+       log_debug("flip duration:", duration, begin, timer::ticks());
+
+       log_info("draw difference:", t - last_draw_);
+       last_draw_ = t;
 }
 
 
index 84490580704b27d393f6fa6117a2c6fe90f12ae3..5c808670bde984ce524873d45b8e6d7fe0ddeece 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_APPLICATION_HH_
 #define _MOOF_APPLICATION_HH_
 namespace moof {
 
 
+// forward declarations
 class settings;
 
 class application : public runloop
 {
 public:
 
-       application(settings& settings);
+       explicit application(settings& settings);
        virtual ~application() {}
 
        virtual void update(scalar t, scalar dt) = 0;
        virtual void draw(scalar alpha) const = 0;
        virtual void handle_event(const event& event) = 0;
 
-
 private:
 
        void dispatch_update(timer& timer, scalar t);
        void dispatch_draw(timer& timer, scalar t);
 
-       scalar  last_update_;
-       scalar  accum_;
+       scalar          last_update_;
+       scalar          last_draw_;
+       scalar          accum_;
        game_time       game_time_;
 
-       timer   update_timer_;
-       timer   draw_timer_;
+       timer           update_timer_;
+       timer           draw_timer_;
 
-       scalar  timestep_;
-       scalar  inverse_timestep_;
+       scalar          timestep_;
+       scalar          inverse_timestep_;
 };
 
 
index 2dd199d216c846d11b0517f87c4e9a9fcc762d46..fa3ad3102ab546a9cc630f49ff3d4a8a2fcb046b 100644 (file)
@@ -1,13 +1,15 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
 
 #include <stdexcept>
 
 namespace moof {
 
 
-struct impl
-{
-       static bool             is_initialized;
-       static int              retain_count;
-};
-
-bool   impl::is_initialized = false;
-int            impl::retain_count = 0;
-
+static int retain_count = 0;
 
 backend::backend()
 {
-       if (impl::retain_count++ == 0)
+       if (retain_count++ == 0)
        {
-#if defined(_WIN32)
+#if PLATFORM_WIN32
                if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0)
 #else
                if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTTHREAD) != 0)
@@ -47,45 +41,40 @@ backend::backend()
                {
                        char name[128];
                        SDL_VideoDriverName(name, sizeof(name));
-                       log_info << "initialized SDL; using video driver `"
-                                        << name << "'" << std::endl;
+                       log_info << "initialized SDL; using video driver `" <<
+                               name << "'" << std::endl;
                }
-
                if (FE_Init() != 0)
                {
                        throw std::runtime_error(FE_GetError());
                }
        }
-
-       impl::is_initialized = true;
 }
 
 backend::backend(const backend& backend)
 {
-       ++impl::retain_count;
+       ++retain_count;
 }
 
-backend& backend::operator=(const backend& backend)
+backend& backend::operator = (const backend& backend)
 {
-       ++impl::retain_count;
+       ++retain_count;
        return *this;
 }
 
 backend::~backend()
 {
-       if (--impl::retain_count == 0)
+       if (--retain_count == 0)
        {
                log_info("shutting down SDL...");
                FE_Quit();
                SDL_Quit();
-
-               impl::is_initialized = false;
        }
 }
 
 bool backend::is_initialized()
 {
-       return impl::is_initialized;
+       return 0 < retain_count;
 }
 
 
index b40a72a67a4d2f7ca0a1ed61817a6638ecccb106..b25e53ae7fbf14c382a93c3b1c6646724a7b26f8 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_BACKEND_HH_
 #define _MOOF_BACKEND_HH_
@@ -23,18 +21,17 @@ namespace moof {
 
 /**
  * Some classes and subsystems require certain backend libraries to be
- * initialized.  This is the mechanism to accomplish that.  Classes which
- * rely on any backend libraries just need to instantiate this class as a
- * member.  Backend cleanup will occur automagically when there are no more
- * instances.
+ * initialized.  This is the mechanism to accomplish that.  Classes which rely
+ * on any backend libraries just need to instantiate this class as a member.
+ * Backend cleanup will occur automagically when there are no more instances.
  */
 class backend
 {
 public:
 
        /**
-        * Construct a backend reference, initializing the backend if it hasn't
-        * already been initialized.
+        * Construct a backend reference, initializing the backend if it
+        * hasn't already been initialized.
         */
        backend();
 
@@ -44,11 +41,10 @@ public:
         */
        static bool is_initialized();
 
-
-       // The rest of this stuff is to implement the reference counting.
+       /* The rest of this stuff is to implement the reference counting. */
 
        backend(const backend& backend);
-       backend& operator=(const backend& backend);
+       backend& operator = (const backend& backend);
        ~backend();
 };
 
index 093b7d197d93658834b2c954aed5b38ec3f8b00b..95488dbc69bbab43afa1dcfeab0dc5a170f47e06 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #include "camera.hh"
 #include "opengl.hh"
@@ -30,23 +28,21 @@ void camera::look_at(const vector3& point)
 {
        // FIXME: this doesn't work as expected
        quaternion_rotation_aim_at(state_.orientation, state_.position, point,
-                                                          vector3(0.0, 1.0, 0.0));
+                       vector3(0.0, 1.0, 0.0));
 }
 
-
 void camera::projection(const matrix4& projection)
 {
        projection_ = projection;
 }
 
-void camera::projection(scalar fovy, scalar aspect, scalar abutting,
-                                                  scalar distant)
+void camera::projection(scalar fovy,
+               scalar aspect, scalar abutting, scalar distant)
 {
        matrix_perspective_yfov_RH(projection_, fovy, aspect, abutting,
-                                                                       distant, z_clip_neg_one);
+                       distant, z_clip_neg_one);
 }
 
-
 void camera::upload_to_gl(scalar alpha) const
 {
        calculate(alpha);
@@ -72,7 +68,6 @@ void camera::calculate(scalar alpha) const
        frustum_.init(modelview_, projection_);
 }
 
-
 void camera::update(scalar t, scalar dt)
 {
        rigid_body3::update(t, dt);
@@ -83,66 +78,58 @@ void camera::draw(scalar alpha) const
        sphere_.draw(alpha);
 }
 
-
 void camera::handle_event(const event& event)
 {
        const scalar ds = 50.0;
 
        switch (event.type)
        {
-               case SDL_KEYDOWN:
-                       if (event.key.keysym.sym == SDLK_RIGHT)
-                       {
-                               state_.position[0] -= ds;
-                       }
-                       else if (event.key.keysym.sym == SDLK_LEFT)
-                       {
-                               state_.position[0] += ds;
-                       }
-                       else if (event.key.keysym.sym == SDLK_UP)
-                       {
-                               state_.position[1] -= ds;
-                       }
-                       else if (event.key.keysym.sym == SDLK_DOWN)
-                       {
-                               state_.position[1] += ds;
-                       }
-                       else if (event.key.keysym.sym == SDLK_PAGEUP)
-                       {
-                               state_.position[2] += ds;
-                       }
-                       else if (event.key.keysym.sym == SDLK_PAGEDOWN)
-                       {
-                               state_.position[2] -= ds;
-                       }
+       case SDL_KEYDOWN:
+               switch (event.key.keysym.sym)
+               {
+               case SDLK_RIGHT:
+                       state_.position[0] -= ds; break;
+               case SDLK_LEFT:
+                       state_.position[0] += ds; break;
+               case SDLK_UP:
+                       state_.position[1] -= ds; break;
+               case SDLK_DOWN:
+                       state_.position[1] += ds; break;
+               case SDLK_PAGEUP:
+                       state_.position[2] += ds; break;
+               case SDLK_PAGEDOWN:
+                       state_.position[2] -= ds; break;
+               default:
                        break;
+               }
+               break;
 
-               case SDL_MOUSEMOTION:
-                       {
-                               scalar xrel = rad(scalar(event.motion.xrel) / 6.0);
-                               scalar yrel = rad(scalar(event.motion.yrel) / 6.0);
+       case SDL_MOUSEMOTION:
+       {
+               scalar xrel = rad(scalar(event.motion.xrel) / 6.0);
+               scalar yrel = rad(scalar(event.motion.yrel) / 6.0);
 
-                               quaternion rotation = state_.orientation;
+               quaternion rotation = state_.orientation;
 
-                               quaternion_rotate_about_world_x(rotation, yrel);
-                               //mRotation.normalize();
-                               quaternion_rotate_about_world_y(rotation, xrel);
+               quaternion_rotate_about_world_x(rotation, yrel);
+               //mRotation.normalize();
+               quaternion_rotate_about_world_y(rotation, xrel);
 
-                               rotation.normalize();
-                               state_.orientation = rotation;
-                       }
-                       break;
+               rotation.normalize();
+               state_.orientation = rotation;
+               break;
+       }
 
-               case SDL_MOUSEBUTTONDOWN:
-                       if (event.button.button == SDL_BUTTON_WHEELUP)
-                       {
-                               state_.position[2] -= ds;
-                       }
-                       else if (event.button.button == SDL_BUTTON_WHEELDOWN)
-                       {
-                               state_.position[2] -= ds;
-                       }
+       case SDL_MOUSEBUTTONDOWN:
+               switch (event.button.button)
+               {
+               case SDL_BUTTON_WHEELUP:
+                       state_.position[2] -= ds;
+                       break;
+               case SDL_BUTTON_WHEELDOWN:
+                       state_.position[2] += ds;
                        break;
+               }
        }
 }
 
index b3aac0e080cd06a00e1c8a9b87d10f8c71b9e667..43e547163d9a0ff8206a3a91475b75d85050e0a4 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_CAMERA_HH_
 #define _MOOF_CAMERA_HH_
@@ -61,21 +59,18 @@ public:
                return frustum_;
        }
 
-
        void upload_to_gl(scalar alpha = 0) const;
 
        void update(scalar t, scalar dt);
        void draw(scalar alpha = 0) const;
        void handle_event(const event& event);
 
-
 private:
 
        void calculate(scalar alpha) const;
 
-       mutable matrix4                 modelview_;
-       matrix4                                 projection_;
-
+       mutable matrix4         modelview_;
+       matrix4                 projection_;
        mutable class frustum   frustum_;
 };
 
index a14718a64117b5bfcf264dc96de92122993c6ef3..1d1998e19e69b273ad88acaaed6ce649089e06c1 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_CONTACT_HH_
 #define _MOOF_CONTACT_HH_
@@ -28,9 +26,9 @@ struct contact
 {
        typedef moof::vector< scalar, fixed<D> > vector;
 
-       vector  point;                  // point of contact
-       scalar  distance;               // distance of penetration
-       vector  normal;                 // normal of surface at point of contact
+       vector  point;          // point of contact
+       scalar  distance;       // distance of penetration
+       vector  normal;         // normal of surface at point of contact
 
        bool operator < (const contact& rhs)
        {
index 4e4391e3187d64c05017e1bf1a3868add0276d41..3f0169a391670dc427bf149296a3d2d704f68a2b 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_CULLABLE_HH_
 #define _MOOF_CULLABLE_HH_
 namespace moof {
 
 
+// forward declarations
 class frustum;
 
 /**
  * Interface for anything that can be culled.
  */
-
 class cullable
 {
 public:
+
        virtual ~cullable() {}
 
        virtual bool is_visible(const frustum& frustum) const
index 837340f242eb7bef7999e7dd7ab1913d3a0cf3c3..baa0304ae535db72e3baf4ce6272614c4357e724 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_DEBUG_HH_
 #define _MOOF_DEBUG_HH_
index 96babe48194eb1d91243ccad2fa412cf10207e72..c0aeae5c3ec6c3bafca835d3cd7f02c7a4abbf8e 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #include <map>
 
@@ -25,29 +23,25 @@ public:
                dispatcher_(dispatcher),
                id_(0) {}
 
-       dispatcher::handle getNewHandle()
+       dispatcher::handle new_handle()
        {
-               ++id_;
-               dispatcher::handle handle(dispatcher_->impl_, id_);
+               dispatcher::handle handle(dispatcher_->impl_, --id_);
                return handle;
        }
 
        typedef std::pair<unsigned,dispatcher::function>        callback;
-       typedef std::multimap<std::string,callback>                     callback_lookup;
-       typedef callback_lookup::iterator                                       callback_it;
-
-       typedef std::multimap<unsigned,std::string>                     handle_lookup;
-       typedef handle_lookup::iterator                                         handle_it;
+       typedef std::multimap<std::string,callback>             callback_lookup;
+       typedef callback_lookup::iterator                       callback_it;
 
+       typedef std::multimap<unsigned,std::string>             handle_lookup;
+       typedef handle_lookup::iterator                         handle_it;
 
        handle add_target(const std::string& event,
-                                         const function& callback,
-                                         handle handle)
+                       const function& callback, handle handle)
        {
-               callbacks_.insert(std::make_pair(event, std::make_pair(handle.id(),
-                                                                                                                          callback)));
+               callbacks_.insert(std::make_pair(event,
+                                       std::make_pair(handle.id(), callback)));
                handles_.insert(std::make_pair(handle.id(), event));
-
                return handle;
        }
 
@@ -55,7 +49,8 @@ public:
        {
                std::pair<handle_it,handle_it> matching(handles_.equal_range(id));
 
-               for (handle_it it = matching.first; it != matching.second; ++it)
+               for (handle_it it = matching.first;
+                               it != matching.second; ++it)
                {
                        callback_it first = callbacks_.find((*it).second);
                        callback_it last = callbacks_.end();
@@ -85,16 +80,13 @@ public:
                }
        }
 
-
-       dispatcher*             dispatcher_;
-
-       unsigned                id_;
+       dispatcher*     dispatcher_;
+       unsigned        id_;
 
        callback_lookup callbacks_;
        handle_lookup   handles_;
 };
 
-
 void dispatcher::handle::clear()
 {
        boost::shared_ptr<impl> dispatcher;
@@ -109,36 +101,31 @@ void dispatcher::handle::clear()
 dispatcher::dispatcher() :
        impl_(new dispatcher::impl(this)) {}
 
-
-dispatcher::handle dispatcher::add_target(const std::string& event,
-                                                                                 const function& callback)
+dispatcher::handle
+dispatcher::add_target(const std::string& event, const function& callback)
 {
-       return add_target(event, callback, impl_->getNewHandle());
+       return add_target(event, callback, impl_->new_handle());
 }
 
 dispatcher::handle dispatcher::add_target(const std::string& event,
-                                                                                 const function& callback,
-                                                                                 handle handle)
+               const function& callback, handle handle)
 {
        // pass through
        return impl_->add_target(event, callback, handle);
 }
 
-
 void dispatcher::remove_target(unsigned id)
 {
        // pass through
        return impl_->remove_target(id);
 }
 
-
 void dispatcher::dispatch(const std::string& event)
 {
        // pass through
        impl_->dispatch(event);
 }
 
-
 dispatcher& dispatcher::global()
 {
        static dispatcher dispatcher;
index a4207c42170bffd68ee1a48713e857b9430c911b..f2613e8fdeb2d11aba27b51c7758ef3e6fbdd989 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_DISPATCH_HH_
 #define _MOOF_DISPATCH_HH_
@@ -31,7 +29,6 @@ namespace moof {
 /**
  * Dispatcher of messages to interested parties.
  */
-
 class dispatcher
 {
        class impl;
@@ -39,7 +36,6 @@ class dispatcher
 
        void remove_target(unsigned id);
 
-
 public:
 
        class handle
@@ -84,17 +80,16 @@ public:
        private:
 
                boost::weak_ptr<impl>   dispatcher_;
-               mutable unsigned                id_;
+               mutable unsigned        id_;
        };
 
        typedef boost::function<void(void)> function;
 
-
        dispatcher();
 
        handle add_target(const std::string& event, const function& callback);
        handle add_target(const std::string& event, const function& callback,
-                                          handle handle);
+                       handle handle);
 
        void dispatch(const std::string& event);
 
index 3882995fe900aceb46ed455433a44ebe81d5d8cf..2f5c6cd09b4ac20261c93722caa39e9cffb6e0d6 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_DRAWABLE_HH_
 #define _MOOF_DRAWABLE_HH_
@@ -29,8 +27,8 @@ namespace moof {
 class drawable
 {
 public:
-       virtual ~drawable() {}
 
+       virtual ~drawable() {}
        virtual void draw(scalar alpha) const = 0;
 };
 
index f95a94cc1fba513549ac4e56fd6ec0e8fa17dbb0..92b4dc5dd7b074b747020d3a7fc807c7da49ebc5 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_ENTITY_HH_
 #define _MOOF_ENTITY_HH_
 namespace moof {
 
 
+// forward declarations
 class frustum;
 
-
-class entity;
-
-/**
- * Entity pointer.
- */
-typedef boost::shared_ptr<entity> entity_ptr;
-
-
 /**
  * Interface for game objects that can be drawn to the screen and have a
  * specified volume (take up space).
@@ -57,7 +47,8 @@ public:
         * timestep.
         * \param frustum The camera frustum for determining visibility.
         */
-       virtual void draw_if_visible(scalar alpha, const frustum& frustum) const
+       virtual void
+       draw_if_visible(scalar alpha, const frustum& frustum) const
        {
                if (is_visible(frustum)) draw(alpha);
        }
@@ -74,7 +65,6 @@ public:
                return sphere_.is_visible(frustum) && aabb_.is_visible(frustum);
        }
 
-
        /**
         * Get the axis-aligned bounding box surrounding the entity.
         * \return The AABB.
@@ -92,13 +82,14 @@ public:
                return sphere_;
        }
 
-
 protected:
 
-       moof::aabb3             aabb_;
+       moof::aabb3     aabb_;
        moof::sphere3   sphere_;
 };
 
+typedef boost::shared_ptr<entity> entity_ptr;
+
 
 } // namespace moof
 
index c717db49ea09b6acb3e7f0122afa688c091cccd6..8635e5f8d77c021c3312e05b7c7ae648e7c5b4ac 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_EVENT_HH_
 #define _MOOF_EVENT_HH_
index aaeceb094fb4ecacc2e2c2fbf1d49835eb345c74..c525c1a42cec0181d66d17982b43db21ec0d5ecf 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #include "aabb.hh"
 #include "frustum.hh"
@@ -20,72 +18,55 @@ namespace moof {
 void frustum::init(const matrix4& modelview, const matrix4& projection)
 {
        scalar planes[6][4];
-
        extract_frustum_planes(modelview, projection, planes, z_clip_neg_one);
 
-       planes_[0] = plane(planes[0][0], planes[0][1],
-                                          planes[0][2], planes[0][3]);
-       planes_[1] = plane(planes[1][0], planes[1][1],
-                                          planes[1][2], planes[1][3]);
-       planes_[2] = plane(planes[2][0], planes[2][1],
-                                          planes[2][2], planes[2][3]);
-       planes_[3] = plane(planes[3][0], planes[3][1],
-                                          planes[3][2], planes[3][3]);
-       planes_[4] = plane(planes[4][0], planes[4][1],
-                                          planes[4][2], planes[4][3]);
-       planes_[5] = plane(planes[5][0], planes[5][1],
-                                          planes[5][2], planes[5][3]);
+       planes_[0] = plane(planes[0][0], planes[0][1], planes[0][2], planes[0][3]);
+       planes_[1] = plane(planes[1][0], planes[1][1], planes[1][2], planes[1][3]);
+       planes_[2] = plane(planes[2][0], planes[2][1], planes[2][2], planes[2][3]);
+       planes_[3] = plane(planes[3][0], planes[3][1], planes[3][2], planes[3][3]);
+       planes_[4] = plane(planes[4][0], planes[4][1], planes[4][2], planes[4][3]);
+       planes_[5] = plane(planes[5][0], planes[5][1], planes[5][2], planes[5][3]);
 }
 
 void frustum::init(const matrix4& modelview, scalar fovy, scalar aspect,
-                                  scalar abutting, scalar distant)
+               scalar abutting, scalar distant)
 {
        matrix4 projection;
-
-       matrix_perspective_yfov_RH(projection, fovy, aspect, abutting,
-                                                                       distant, z_clip_neg_one);
-
+       matrix_perspective_yfov_RH(projection,
+                       fovy, aspect, abutting, distant, z_clip_neg_one);
        init(modelview, projection);
 }
 
 frustum::collision frustum::contains(const aabb<3>& aabb) const
 {
-       vector3 corners[8];
-       int nTotalInside = 0;
-
+       int     total = 0;
+       vector3 corners[8];
        aabb.get_corners(corners);
 
        for (int i = 0; i < 6; ++i)
        {
-               int nInside = 8;
-
+               int num = 8;
                for (int j = 0; j < 8; ++j)
                {
                        if (planes_[i].intersects(corners[j]) == plane::negative)
-                       {
-                               --nInside;
-                       }
+                               --num;
                }
-
-               if (nInside == 0)      return outside;
-               else if (nInside == 8) ++nTotalInside;
+               if (num == 0) return outside;
+               else if (num == 8) ++total;
        }
 
-       if (nTotalInside == 6) return inside;
-       else                   return intersecting;
+       if (total == 6) return inside;
+       return intersecting;
 }
 
-
-frustum::collision frustum::contains(const sphere<3>& sphere) const
+frustum::collision frustum::contains(const sphere3& sphere) const
 {
        for (int i = 0; i < 6; ++i)
        {
                plane::halfspace halfspace = planes_[i].intersects(sphere);
-               
-               if (halfspace == plane::negative)       return outside;
+               if (halfspace == plane::negative) return outside;
                else if (halfspace == plane::intersecting) return intersecting;
        }
-
        return inside;
 }
 
index 1e44701402577b26c2edc29c3c1dc948a717d471..c603a97884c056e1fc408bf7bbace8305728d8f4 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_FRUSTUM_HH_
 #define _MOOF_FRUSTUM_HH_
 #include <moof/math.hh>
 #include <moof/plane.hh>
 
-
 namespace moof {
 
-
 template <int D> class aabb;
 template <int D> class sphere;
 
-
 /**
- * A six-sided volume for representing the space visible by a position
- * looking outward.
+ * A six-sided volume for representing the space visible by a position looking
+ * outward.
  */
 class frustum
 {
@@ -38,8 +33,8 @@ public:
 
        enum collision
        {
-               outside                 = 0,
-               inside                  = 1,
+               outside         = 0,
+               inside          = 1,
                intersecting    = 2
        };
 
@@ -56,18 +51,16 @@ public:
 
        void init(const matrix4& modelview, const matrix4& projection);
        void init(const matrix4& modelview, scalar fovy, scalar aspect,
-                         scalar abutting, scalar distant);
+                       scalar abutting, scalar distant);
 
        collision contains(const aabb<3>& aabb) const;
        collision contains(const sphere<3>& sphere) const;
 
-
 private:
 
        plane planes_[6]; // left, right, bottom, top, near, far
 };
 
-
 } // namespace moof
 
 #endif // _MOOF_FRUSTUM_HH_
index dbbc9befae9b337a352ab65591b84bd81ba69d13..ae09b1cf1df5f1b24e9507f7cde4b3c7b7aa66ac 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #include "hash.hh"
 
@@ -31,8 +29,8 @@ namespace moof {
 // 2. It will not produce the same results on little-endian and big-endian
 //    machines.
 
-unsigned hash_function::operator()(const void* key, int len,
-                                                                  unsigned int seed) const
+unsigned
+hash_function::operator()(const void* key, int len, unsigned int seed) const
 {
        // 'm' and 'r' are mixing constants generated offline.
        // They're not really 'magic', they just happen to work well.
index ea63db152ad53f05bc7b3643b45437a5b13a2efc..8b14ac5596bc65957c3491f76dc49db2eaced093 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_HASH_HH_
 #define _MOOF_HASH_HH_
@@ -27,12 +25,10 @@ namespace moof {
 
 using stlplus::hash;
 
-
 struct hash_function
 {
        // generic hash function
-       unsigned operator () (const void* key, int len,
-                                                 unsigned seed = -1) const;
+       unsigned operator () (const void* key, int len, unsigned seed = -1) const;
 
        unsigned operator () (const std::string& val) const
        {
index b9076f0c9ec1a46d3808851136155971574c6d4a..09f797ca8f3fc3d9235fb7ccf4f1ad21f5f84eae 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #include <cstring>             // strncmp
 #include <fstream>
@@ -60,19 +58,20 @@ image::image(const std::string& path) :
        wrap_s_(GL_CLAMP),
        wrap_t_(GL_CLAMP)
 {
-       std::ifstream file(path.c_str());
-       if (!file.good()) throw std::runtime_error("no valid image found at " + path);
+       std::ifstream file(path.c_str(), std::ifstream::binary);
+       if (!file.good())
+               throw std::runtime_error("no valid image found at " + path);
 
        png_byte        signature[8];
        size_t          bytesRead;
 
-       int bpp;
+       int             bpp;
 
        png_byte        colors;
        png_bytepp      rows = 0;
 
        png_textp       texts = 0;
-       int                     nutext_s;
+       int             nutext_s;
 
        bytesRead = file.read((char*)signature, sizeof(signature)).gcount();
        if (bytesRead < sizeof(signature) ||
@@ -80,10 +79,11 @@ image::image(const std::string& path) :
 
        struct png
        {
-               png_structp context;
+               png_structp     context;
                png_infop       info;
                png() :
-                       context(png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0)),
+                       context(png_create_read_struct(PNG_LIBPNG_VER_STRING,
+                                               0, 0, 0)),
                        info(png_create_info_struct(context))
                {
                        if (!context || !info) throw 0;
@@ -91,7 +91,7 @@ image::image(const std::string& path) :
                ~png()
                {
                        png_destroy_read_struct(context ? &context : 0,
-                                                                       info    ? &info    : 0, 0);
+                                       info ? &info : 0, 0);
                }
        } png;
 
@@ -105,17 +105,17 @@ image::image(const std::string& path) :
        colors = png_get_color_type(png.context, png.info);
        switch (colors)
        {
-               case PNG_COLOR_TYPE_PALETTE:
-                       png_set_palette_to_rgb(png.context);
-                       break;
+       case PNG_COLOR_TYPE_PALETTE:
+               png_set_palette_to_rgb(png.context);
+               break;
 
-               case PNG_COLOR_TYPE_GRAY:
-                       if (bpp < 8) png_set_expand(png.context);
-                       break;
+       case PNG_COLOR_TYPE_GRAY:
+               if (bpp < 8) png_set_expand(png.context);
+               break;
 
-               case PNG_COLOR_TYPE_GRAY_ALPHA:
-                       png_set_gray_to_rgb(png.context);
-                       break;
+       case PNG_COLOR_TYPE_GRAY_ALPHA:
+               png_set_gray_to_rgb(png.context);
+               break;
        }
 
        if (bpp == 16) png_set_strip_16(png.context);
@@ -127,14 +127,14 @@ image::image(const std::string& path) :
        depth_ = bpp * channels_;
 
        // read comments
-       bool    isTexture = false;
+       bool texture = false;
        png_get_text(png.context, png.info, &texts, &nutext_s);
        for (int i = 0; i < nutext_s; ++i)
        {
                if (strncmp(texts[i].key, "X-Yoink-Texture", 11) == 0)
                {
                        set_texture_info(texts[i].text);
-                       isTexture = true;
+                       texture = true;
                        break;
                }
        }
@@ -146,12 +146,13 @@ image::image(const std::string& path) :
        pixels_ = new char[width_ * pitch_];
 
        rows = new png_bytep[height_];
-       if (isTexture)
+       if (texture)
        {
                log_debug("texture detected; loading flipped");
                for (int i = 0; i < height_; ++i)
                {
-                       rows[height_-1-i] = (png_bytep)(pixels_ + i * channels_ * width_);
+                       rows[height_-1-i] = (png_bytep)(pixels_ +
+                                       i * channels_ * width_);
                }
        }
        else
@@ -159,7 +160,8 @@ image::image(const std::string& path) :
                log_debug("no texture attributes found");
                for (int i = 0; i < height_; ++i)
                {
-                       rows[i] = (png_bytep)(pixels_ + i * channels_ * width_);
+                       rows[i] = (png_bytep)(pixels_ +
+                                       i * channels_ * width_);
                }
        }
 
@@ -202,11 +204,9 @@ void image::set_as_icon() const
        );
 
        SDL_WM_SetIcon(context, 0);
-
        SDL_FreeSurface(context);
 }
 
-
 bool image::tile_coordinates(int index, scalar coords[8]) const
 {
        // make sure the index represents a real tile
@@ -227,7 +227,6 @@ bool image::tile_coordinates(int index, scalar coords[8]) const
        return true;
 }
 
-
 void image::bind() const
 {
        ASSERT(video::current() && "should have a video context set");
@@ -251,25 +250,20 @@ void image::reset_binding()
        global_object_ = 0;
 }
 
-
 /*
  * Upload the image to GL so that it will be accessible by a much more
  * manageable handle and hopefully reside in video memory.
  */
 void image::upload_to_gl() const
 {
-       if (object_)
-       {
-               // already loaded
-               return;
-       }
+       if (object_) return;    // already loaded
 
        glGenTextures(1, (GLuint*)&object_);
        glBindTexture(GL_TEXTURE_2D, (GLuint)object_);
 
        GLuint mode;
        if (channels_ == 3) mode = GL_RGB;
-       else                mode = GL_RGBA;
+       else mode = GL_RGBA;
        
        glTexImage2D
        //gluBuild2DMipmaps
@@ -299,11 +293,7 @@ void image::unload_from_gl() const
 {
        if (object_)
        {
-               if (object_ == global_object_)
-               {
-                       global_object_ = 0;
-               }
-
+               if (object_ == global_object_) global_object_ = 0;
                glDeleteTextures(1, (GLuint*)&object_);
                object_ = 0;
        }
@@ -327,7 +317,6 @@ void image::set_properties() const
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_t_);
 }
 
-
 void image::set_texture_info(const std::string& info)
 {
        script script;
index 6aa251bad0a658a3ca48fd24ba61c87f124d9e9e..62f8699abb029503b1e87b2db97c56d96bc1d356 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_IMAGE_HH_
 #define _MOOF_IMAGE_HH_
@@ -33,9 +31,7 @@ public:
 
        static const int no_tile = -1;
 
-
        explicit image(const std::string& path);
-
        ~image();
 
        int width() const
@@ -63,7 +59,6 @@ public:
                return channels_;
        }
 
-
        std::string comment() const
        {
                return comment_;
@@ -74,10 +69,8 @@ public:
                return pixels_;
        }
 
-
        void set_as_icon() const;
 
-
        /**
         * Calculate texture coordinates for a tile at a certain index.  Tiles
         * are indexed start with zero as the top-left tile and moving across,
@@ -93,11 +86,9 @@ public:
         */
        bool tile_coordinates(int index, scalar coords[8]) const;
 
-
        void bind() const;
        static void reset_binding();
 
-
 private:
 
        void upload_to_gl() const;
@@ -106,26 +97,25 @@ private:
        void set_properties() const;
        void set_texture_info(const std::string& info);
 
-
-       char*                           pixels_;
+       char*                   pixels_;
 
        mutable unsigned        object_;
        static unsigned         global_object_;
 
-       int                                     width_;
-       int                                     height_;
-       int                                     depth_;
-       int                                     pitch_;
-       int                                     channels_;
+       int                     width_;
+       int                     height_;
+       int                     depth_;
+       int                     pitch_;
+       int                     channels_;
 
-       std::string                     comment_;
+       std::string             comment_;
 
-       unsigned                        min_filter_;
-       unsigned                        mag_filter_;
-       int                                     tile_s_;
-       int                                     tile_t_;
-       unsigned                        wrap_s_;
-       unsigned                        wrap_t_;
+       unsigned                min_filter_;
+       unsigned                mag_filter_;
+       int                     tile_s_;
+       int                     tile_t_;
+       unsigned                wrap_s_;
+       unsigned                wrap_t_;
 
        //mutable dispatcher::handle    new_context_;
 };
index 0a7aa012b480747e69c7e3577c1c6f3c8546f9f8..83dd0c9bdf095d1f289f8d8ec15896c294afd0b5 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_INTERPOLATOR_HH_
 #define _MOOF_INTERPOLATOR_HH_
@@ -40,10 +38,9 @@ public:
        {
                stop            = 0,    /// Interpolator will stop when done.
                repeat          = 1,    /// Interpolator will go back to the beginning.
-               oscillate       = 2             /// Interpolator will reverse direction.
+               oscillate       = 2     /// Interpolator will reverse direction.
        };
 
-
        /**
         * Construct an uninitialized interpolator.
         */
@@ -57,7 +54,8 @@ public:
         * \param t The duration of the interpolation.
         * \param mode The interpolation mode.
         */
-       interpolator(const T& a, const T& b, scalar t = 1.0, mode mode = stop) :
+       interpolator(const T& a, const T& b,
+                       scalar t = 1.0, mode mode = stop) :
                state_(a),
                prior_(a),
                a_(a),
@@ -86,7 +84,6 @@ public:
                is_done_ = false;
        }
 
-
        /**
         * Update the interpolation state with a timeslice.
         * \param t The total time in seconds.
@@ -104,42 +101,40 @@ public:
                        {
                                switch (mode_)
                                {
-                                       case stop:
-                                               alpha_ = SCALAR(1.0);
-                                               is_done_ = true;
-                                               break;
-                                       case repeat:
-                                               alpha_ -= SCALAR(1.0);
-                                               break;
-                                       case oscillate:
-                                               alpha_ = SCALAR(2.0) - alpha_;
-                                               scale_ = -scale_;
-                                               break;
+                               case stop:
+                                       alpha_ = SCALAR(1.0);
+                                       is_done_ = true;
+                                       break;
+                               case repeat:
+                                       alpha_ -= SCALAR(1.0);
+                                       break;
+                               case oscillate:
+                                       alpha_ = SCALAR(2.0) - alpha_;
+                                       scale_ = -scale_;
+                                       break;
                                }
                        }
                        else if (alpha_ < 0.0)
                        {
                                switch (mode_)
                                {
-                                       case stop:
-                                               alpha_ = SCALAR(0.0);
-                                               is_done_ = true;
-                                               break;
-                                       case repeat:
-                                               alpha_ += SCALAR(1.0);
-                                               break;
-                                       case oscillate:
-                                               alpha_ = -alpha_;
-                                               scale_ = -scale_;
-                                               break;
+                               case stop:
+                                       alpha_ = SCALAR(0.0);
+                                       is_done_ = true;
+                                       break;
+                               case repeat:
+                                       alpha_ += SCALAR(1.0);
+                                       break;
+                               case oscillate:
+                                       alpha_ = -alpha_;
+                                       scale_ = -scale_;
+                                       break;
                                }
                        }
-
                        state_ = function_(a_, b_, alpha_);
                }
        }
 
-
        /**
         * Get the interpolated value.
         * \return The interpolated value.
@@ -169,7 +164,6 @@ public:
                return is_done_;
        }
 
-
 private:
 
        T       state_;
@@ -195,7 +189,6 @@ struct linear_interpolation_function
        }
 };
 
-
 typedef interpolator<linear_interpolation_function> lerp_scalar;
 
 
index 0ba6bb368c6d56b628ed8ec9a38862fb91e0abac..8f5794d52850643b1531587f3e4f0a537f249a9e 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_LINE_HH_
 #define _MOOF_LINE_HH_
@@ -36,18 +34,15 @@ struct line : public drawable, public shape<D>
 {
        typedef moof::vector< scalar, fixed<D> > vector;
 
-
        vector  a;
        vector  b;
 
-
        line() {}
 
        line(const vector& point1, const vector& point2) :
                a(point1),
                b(point2) {}
 
-
        vector direction() const
        {
                return b - a;
@@ -58,31 +53,31 @@ struct line : public drawable, public shape<D>
                return direction().length();
        }
 
-
        bool intersect(const line& other, contact<D>& hit) const
        {
                scalar d = (other.b[1] - other.a[1]) * (b[0] - a[0]) -
-                                  (other.b[0] - other.a[0]) * (b[1] - a[1]);
+                       (other.b[0] - other.a[0]) * (b[1] - a[1]);
 
-               if (d == SCALAR(0.0)) return false;                     // lines are parallel
+               if (d == SCALAR(0.0)) return false;     // lines are parallel
                // ignoring the (somewhat remote) possibility of coincidence
 
-               scalar m = ((other.b[0] - other.a[0]) * (a[1] - other.a[1]) -
-                                       (other.b[1] - other.a[1]) * (a[0] - other.a[0])) / d;
+               scalar m = ((other.b[0] - other.a[0]) *
+                               (a[1] - other.a[1]) -
+                               (other.b[1] - other.a[1]) *
+                               (a[0] - other.a[0])) / d;
 
                scalar n = ((b[0] - a[0]) * (b[1] - other.a[1]) -
-                                       (b[1] - a[1]) * (b[0] - other.a[0])) / d;
+                               (b[1] - a[1]) * (b[0] - other.a[0])) / d;
 
                if (m < SCALAR(0.0) || m > SCALAR(1.0) ||       // not intersecting
-                       n < SCALAR(0.0) || n > SCALAR(1.0)) return false;
+                       n < SCALAR(0.0) || n > SCALAR(1.0))
+                       return false;
 
                vector2 tangent = b - a;
                vector2 normal = perp(tangent).normalize();
 
                if (dot(normal, other.a - other.b) < SCALAR(0.0))
-               {
                        normal = -normal;
-               }
 
                hit.point = a + m * tangent;
                hit.normal = normal;
@@ -104,7 +99,6 @@ struct line : public drawable, public shape<D>
                if (projection < SCALAR(0.0) || projection > surfaceLength)
                {
                        // try endpoints
-                       
                        if (other.intersect(a, hit))
                        {
                                hit.normal = -hit.normal;
@@ -117,7 +111,6 @@ struct line : public drawable, public shape<D>
                                hit.point = b;
                                return true;
                        }
-                       
                        return false;
                }
 
@@ -126,7 +119,7 @@ struct line : public drawable, public shape<D>
 
                scalar distance = normal.length();
 
-               if (distance > other.radius) false;             // not intersecting
+               if (distance > other.radius) false;     // not intersecting
 
                normal.normalize();
 
@@ -137,8 +130,8 @@ struct line : public drawable, public shape<D>
                return true;
        }
 
-
-       bool intersect_ray(const ray<2>& ray, moof::ray<2>::contact& hit) const
+       bool
+       intersect_ray(const ray<2>& ray, moof::ray<2>::contact& hit) const
        {
                vector2 v1 = a - ray.point;
                scalar  a1 = signed_angle_2D(v1, b - ray.point);
@@ -170,7 +163,6 @@ struct line : public drawable, public shape<D>
                hit.normal = perp(a - b);
                return true;
 
-
                /*
                // solve: Cx + r*Dx = Ax + s(Bx - Ax)
                //        Cy + r*Dy = Ay + s(By - Ay)
@@ -222,7 +214,6 @@ struct line : public drawable, public shape<D>
                */
        }
 
-
        void draw(scalar alpha = 0.0) const
        {
                image::reset_binding();
@@ -233,7 +224,6 @@ struct line : public drawable, public shape<D>
        }
 };
 
-
 typedef line<2>                line2;
 typedef line<3>                line3;
 
@@ -248,7 +238,7 @@ struct polygon : public drawable, public shape<D>
        polygon() {}
 
        bool intersect_ray(const ray<D>& ray,
-                                          typename moof::ray<D>::contact& hit)
+                       typename moof::ray<D>::contact& hit)
        {
                return false;
        }
@@ -257,22 +247,17 @@ struct polygon : public drawable, public shape<D>
        {
                image::reset_binding();
                glBegin(GL_POLYGON);
-               for (int i = 0; i < D; ++i)
-               {
-                       glVertex(points[0]);
-               }
+                       for (int i = 0; i < D; ++i) glVertex(points[0]);
                glEnd();
        }
 };
 
-
 typedef polygon<2,3>   triangle2;
 typedef polygon<3,3>   triangle3;
 
 
 template <int D>
-bool intersect(const line<D>& line, const sphere<D>& sphere,
-                          contact<D>& hit)
+bool intersect(const line<D>& line, const sphere<D>& sphere, contact<D>& hit)
 {
        return false;
 }
index d0acf2e103334e98c99a562b8688b2f644c0a9aa..514649653a4d4fbd1491e597d7527cd2f01eb7b4 100644 (file)
@@ -1,23 +1,24 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
+
+#if HAVE_INCLUDE_H
+#include "config.h"
+#endif
 
 #include <fstream>
 
-#if !defined(__WIN32)
+#if PLATFORM_POSIX
 #include <termios.h>
 #else
 inline int isatty(int dummy) { return 0; }
 #endif
 
-
 #include "log.hh"
 #include "script.hh"
 
@@ -38,27 +39,29 @@ enum log::level log::level()
        return global_level_;
 }
 
-
 log::log(enum level level) :
        level_(level)
 {
        if (isatty(1) == 0)
                switch (level)
                {
-                       case log::error:        prefix_ = "  error: ";  break;
-                       case log::warning:      prefix_ = "warning: ";  break;
-                       case log::info:         prefix_ = "   info: ";  break;
-                       case log::debug:        prefix_ = "  debug: ";  break;
-                       case log::none:         break;
+               case log::error:        prefix_ = "  error: ";  break;
+               case log::warning:      prefix_ = "warning: ";  break;
+               case log::info:         prefix_ = "   info: ";  break;
+               case log::debug:        prefix_ = "  debug: ";  break;
+               case log::none:         break;
                }
        else
                switch (level)
                {
-                       case log::error:        prefix_ = "\033[30;101m  error: ";      break;
-                       case log::warning:      prefix_ = "\033[30;103mwarning: ";      break;
-                       case log::info:         prefix_ = "   info: ";                          break;
-                       case log::debug:        prefix_ = "\033[2m  debug: ";           break;
-                       case log::none:         break;
+               case log::error:        prefix_ = "\033[30;101m  error: ";
+                                       break;
+               case log::warning:      prefix_ = "\033[30;103mwarning: ";
+                                       break;
+               case log::info:         prefix_ = "   info: ";
+                                       break;
+               case log::debug:        prefix_ = "\033[2m  debug: ";
+               case log::none:         break;
                }
 }
 
@@ -66,22 +69,20 @@ std::ostream& operator << (class log& log, log::endl_ endl)
 {
        if (log::global_level_ < log.level_) return null_log;
        if (isatty(1) == 0) return moof::log << std::endl;
-       else return moof::log << "\033[0m" << std::endl;
+       return moof::log << "\033[0m" << std::endl;
 }
 
 std::ostream& operator << (std::ostream& stream, log::endl_ endl)
 {
        if (isatty(1) == 0) return stream << std::endl;
-       else return stream << "\033[0m" << std::endl;
+       return stream << "\033[0m" << std::endl;
 }
 
-
 std::ostream& log(std::cout);
 
 static std::ofstream null_log_;
 std::ostream& null_log(null_log_);
 
-
 // These objects are intentionally not deconstructed so that logging will
 // still be available after this module has been cleaned up.
 class log& log_error(*new class log(log::error));
@@ -89,7 +90,6 @@ class log& log_warning(*new class log(log::warning));
 class log& log_info(*new class log(log::info));
 class log& log_debug(*new class log(log::debug));
 
-
 static int log_script(script& script, enum log::level level)
 {
        static class log* logs[] = {
@@ -102,8 +102,7 @@ static int log_script(script& script, enum log::level level)
 
        script::slot param = script[1];
 
-       while (!param.is_none())
-       {
+       while (!param.is_none()) {
                (*logs[level])(param);
                ++param.index;
        }
@@ -114,15 +113,15 @@ static int log_script(script& script, enum log::level level)
 void log::import(script& script)
 {
        script.import_function("LogError",
-                                                 boost::bind(log_script, _1, log::error));
+                       boost::bind(log_script, _1, log::error));
        script.import_function("LogWarning",
-                                                 boost::bind(log_script, _1, log::warning));
+                       boost::bind(log_script, _1, log::warning));
        script.import_function("LogInfo",
-                                                 boost::bind(log_script, _1, log::info));
+                       boost::bind(log_script, _1, log::info));
        script.import_function("print",
-                                                 boost::bind(log_script, _1, log::info));
+                       boost::bind(log_script, _1, log::info));
        script.import_function("LogDebug",
-                                                 boost::bind(log_script, _1, log::debug));
+                       boost::bind(log_script, _1, log::debug));
 }
 
 
index cad63e939a572a7c058aa6ad2e5c51fe12c19441..addf37c135f9066025c019aa7818ef16b93851d4 100644 (file)
@@ -1,22 +1,20 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_LOG_HH_
 #define _MOOF_LOG_HH_
 
 /**
  * \file log.hh
- * Functions related to logging the process.
- * The logging functions are log_error(), log_warning(), and log_info(),
- * listed from most critical to least critical.
+ * Functions related to logging the process.  The logging functions are
+ * log_error(), log_warning(), and log_info(), listed from most critical to
+ * least critical.
  */
 
 #include <cstdlib>             // exit
@@ -27,9 +25,9 @@
 namespace moof {
 
 
+// forward declarations
 class script;
 
-
 /**
  * A class for handling a log priority.  There are two ways to log
  * messages: by treating a log object as a function whose parameters are
@@ -46,14 +44,13 @@ public:
         */
        enum level
        {
-               none            = 0,            ///< Disable all logging.
-               error           = 1,            ///< Log only errors.
-               warning         = 2,            ///< Log warnings and errors.
-               info            = 3,            ///< Log everything.
-               debug           = 4,            ///< Log absolutely everything.
+               none            = 0,    ///< Disable all logging.
+               error           = 1,    ///< Log only errors.
+               warning         = 2,    ///< Log warnings and errors.
+               info            = 3,    ///< Log everything.
+               debug           = 4,    ///< Log absolutely everything.
        };
 
-
        /**
         * Set the lowest-priority log message that will be outputted to the
         * log.  Any logging with a lower priority will be ignored.
@@ -68,14 +65,12 @@ public:
         */
        static enum level level();
 
-
        /**
         * Import log functions to a script.
         * \param The script.
         */
        static void import(script& script);
 
-
        /**
         * Construct a log with a certain priority and prefix string.
         * \param level The log level.
@@ -83,7 +78,6 @@ public:
         */
        log(enum level level);
 
-
        /**
         * Output this to end a line.  This is equivalent to std::endl except
         * this will also reset terminal format attributes.
@@ -92,7 +86,6 @@ public:
        {
        } endl;
 
-
        template <class A>
        void operator () (const A& a)
        {
@@ -119,19 +112,15 @@ public:
 
        template <class A, class B, class C, class D, class E>
        void operator () (const A& a,
-                                         const B& b,
-                                         const C& c,
-                                         const D& d,
-                                         const E& e)
+                       const B& b,
+                       const C& c,
+                       const D& d,
+                       const E& e)
        {
-               *this << a << " "
-                         << b << " "
-                         << c << " "
-                         << d << " "
-                         << e << endl;
+               *this << a << " " << b << " " << c << " " << d << " " << e <<
+                       endl;
        }
 
-
 private:
 
        template <class T> friend std::ostream& operator << (log&, const T&);
@@ -139,11 +128,10 @@ private:
 
        static enum level       global_level_;
 
-       enum level                      level_;
-       std::string                     prefix_;
+       enum level              level_;
+       std::string             prefix_;
 };
 
-
 extern std::ostream&   log;
 extern std::ostream&   null_log;
 
index 98b102dddfafbcfa598fb7937071308812d61c15..a3963e8a1341f8929f6407722bee32938063791b 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_MANAGER_HH_
 #define _MOOF_MANAGER_HH_
@@ -47,7 +45,6 @@ public:
                return boost::shared_ptr<T>(retain(name), &release);
        }
 
-
 private:
 
        typedef stlplus::hash<std::string,T*,hash_function> ptr_lookup;
@@ -68,7 +65,8 @@ private:
                        {
                                new_object->name_ = name;
                                new_object->init(name);
-                               ptr_lookup_.insert(std::make_pair(name, new_object));
+                               ptr_lookup_.insert(std::make_pair(name,
+                                                       new_object));
                        }
                        return new_object; 
                }
@@ -85,8 +83,8 @@ private:
 
 
        static ptr_lookup       ptr_lookup_;
-       std::string                     name_;
-       unsigned                        retain_count_;
+       std::string             name_;
+       unsigned                retain_count_;
 };
 
 template <class T>
index 14e8c78626acdb41bfedac1b8609e19d9588818b..e7cd3f03951f873c04ec37dcb3e02a91993f78e6 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_MATH_HH_
 #define _MOOF_MATH_HH_
  * General math-related types and functions.
  */
 
+#if HAVE_CONFIG_H
 #include "config.h"
+#endif
 
 #include <cmath>
 
 #include <cml/cml.h>
 #include <SDL/SDL_opengl.h>
 
-
 #if ENABLE_DOUBLE_PRECISION
 typedef GLdouble       GLscalar;
 #define GL_SCALAR      GL_DOUBLE
@@ -41,7 +40,6 @@ namespace moof {
 
 using namespace cml;
 
-
 typedef GLscalar scalar;
 
 typedef vector< scalar, fixed<2> > vector2;
@@ -52,11 +50,10 @@ typedef matrix< scalar, fixed<2,2>, col_basis, col_major > matrix2;
 typedef matrix< scalar, fixed<3,3>, col_basis, col_major > matrix3;
 typedef matrix< scalar, fixed<4,4>, col_basis, col_major > matrix4;
 
-typedef quaternion< scalar, fixed<>, vector_first, positive_cross >    quaternion;
+typedef quaternion< scalar, fixed<>, vector_first, positive_cross > quaternion;
 
 typedef constants<scalar> constants;
 
-
 inline vector3 demote(const vector4& vec)
 {
        return vector3(vec[0], vec[1], vec[2]);
@@ -90,10 +87,10 @@ inline bool is_equal(scalar a, scalar b, scalar epsilon = EPSILON)
 }
 
 
-// Here are some generic implementations of a few simple integrators.  To
-// use, you need one type representing the state and another containing the
-// derivatives of the primary state variables.  The state class must
-// implement these methods:
+// Here are some generic implementations of a few simple integrators.  To use,
+// you need one type representing the state and another containing the
+// derivatives of the primary state variables.  The state class must implement
+// these methods:
 //
 // void calculate_derivative(Derivative_Type& derivative, scalar absoluteTime);
 // void step(const Derivative_Type& derivative, scalar deltaTime);
@@ -118,12 +115,10 @@ inline D evaluate(S state,  scalar t, scalar dt, const D& derivative)
        return evaluate<S,D>(state, t + dt);
 }
 
-
 template <class S, class D>
 inline void euler(S& state, scalar t, scalar dt)
 {
        D a = evaluate<S,D>(state, t);
-
        state.step(a, dt);
 }
 
@@ -132,7 +127,6 @@ inline void rk2(S& state, scalar t, scalar dt)
 {
        D a = evaluate<S,D>(state, t);
        D b = evaluate<S,D>(state, t, dt * SCALAR(0.5), a);
-
        state.step(b, dt);
 }
 
@@ -143,7 +137,6 @@ inline void rk4(S& state, scalar t, scalar dt)
        D b = evaluate<S,D>(state, t, dt * SCALAR(0.5), a);
        D c = evaluate<S,D>(state, t, dt * SCALAR(0.5), b);
        D d = evaluate<S,D>(state, t, dt, c);
-
        state.step((a + (b + c) * SCALAR(2.0) + d) * SCALAR(1.0/6.0), dt);
 }
 
index e380adfd19d6eb2ea9e9bc2bc9799eb0c2bf8362..32550f7fcfb3361aff55ea7e2748c0c2c62531df 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #include <cstring>
 #include <fstream>
@@ -18,8 +16,6 @@
 #include <boost/algorithm/string/trim.hpp>
 #include <zlib.h>
 
-#include <stlplus/strings/string_utilities.hpp>
-
 #include "debug.hh"
 #include "log.hh"
 #include "mesh.hh"
@@ -27,9 +23,8 @@
 
 // TODO: this file needs to be cleaned up
 
-
-#define AC3D_FORMAT_VERSION            (0x0b)
-#define ZLIB_BUF_SIZE                  (262114)
+#define AC3D_FORMAT_VERSION    0x0b
+#define ZLIB_BUF_SIZE          262114
 
 
 namespace moof {
@@ -37,22 +32,17 @@ namespace moof {
 
 MOOF_REGISTER_RESOURCE(mesh, ac, models);
 
-
 static std::string read_string(std::istream& stream)
 {
        std::string     str;
        char            atom;
 
-       do      // skip to the next non-space character
-       {
-               stream.get(atom);
-       }
+       do stream.get(atom);
        while (stream && std::isspace(atom));
 
        if (atom == '"')
        {
-               do
-               {
+               do {
                        stream.get(atom);
                        if (atom == '"') break;
                        str += atom;
@@ -61,8 +51,7 @@ static std::string read_string(std::istream& stream)
        }
        else
        {
-               do
-               {
+               do {
                        stream.get(atom);
                        if (std::isspace(atom)) break;
                        str += atom;
@@ -73,7 +62,7 @@ static std::string read_string(std::istream& stream)
        return str;
 }
 
-inline int read_hex(std::istream& stream)
+static int read_hex(std::istream& stream)
 {
        int hex;
        std::ios::fmtflags flags = stream.flags();
@@ -83,21 +72,21 @@ inline int read_hex(std::istream& stream)
        return hex;
 }
 
-inline vector2 read_pair(std::istream& stream)
+static vector2 read_pair(std::istream& stream)
 {
        vector2 triplet;
        stream >> triplet[0] >> triplet[1];
        return triplet;
 }
 
-inline vector3 read_triplet(std::istream& stream)
+static vector3 read_triplet(std::istream& stream)
 {
        vector3 triplet;
        stream >> triplet[0] >> triplet[1] >> triplet[2];
        return triplet;
 }
 
-inline vector4 read_color(std::istream& stream)
+static vector4 read_color(std::istream& stream)
 {
        vector4 color;
        stream >> color[0] >> color[1] >> color[2];
@@ -105,12 +94,10 @@ inline vector4 read_color(std::istream& stream)
        return color;
 }
 
-
 void mesh::import(std::istream& stream)
 {
-       std::string             atom;
-
-       object_ptr              obj;
+       std::string     atom;
+       object_ptr      obj;
        std::stack<int> kids;
 
        // read and verify the AC3D header
@@ -379,12 +366,10 @@ void mesh::import(std::istream& stream)
        //face.triangles.push_back(vert);
 //}
 
-
-
 mesh::mesh(const std::string& path)
 {
        std::ifstream file(path.c_str(), std::ifstream::in |
-                                                                        std::ifstream::binary);
+                       std::ifstream::binary);
        if (!file) throw std::runtime_error("cannot find mesh file");
 
        // if we can read the header, the file isn't compressed
@@ -394,7 +379,6 @@ mesh::mesh(const std::string& path)
        {
                log_info("text mesh detected");
                file.seekg(std::ios::beg);
-
                import(file);
        }
        else
@@ -415,31 +399,30 @@ mesh::mesh(const std::string& path)
                zstream.next_in = Z_NULL;
                
                int result = inflateInit2(&zstream, 32+MAX_WBITS);
-               if (result != Z_OK) throw std::runtime_error("zlib init error");
+               if (result != Z_OK)
+                       throw std::runtime_error("zlib init error");
 
-               do
-               {
+               do {
                        file.read(in, sizeof(in));
                        zstream.next_in = (Bytef*)in;
                        zstream.avail_in = file.gcount();
 
                        if (zstream.avail_in == 0) break;
 
-                       do
-                       {
+                       do {
                                zstream.next_out = (Bytef*)out;
                                zstream.avail_out = sizeof(out);
 
                                result = inflate(&zstream, Z_NO_FLUSH);
                                switch (result)
                                {
-                                       case Z_NEED_DICT:
-                                       case Z_DATA_ERROR:
-                                       case Z_MEM_ERROR:
-                                               inflateEnd(&zstream);
-                                               throw std::runtime_error("zlib inflate error");
-                                       case Z_STREAM_ERROR:
-                                               throw std::runtime_error("zlib stream error");
+                               case Z_NEED_DICT:
+                               case Z_DATA_ERROR:
+                               case Z_MEM_ERROR:
+                                       inflateEnd(&zstream);
+                                       throw std::runtime_error("zlib inflate error");
+                               case Z_STREAM_ERROR:
+                                       throw std::runtime_error("zlib stream error");
                                }
 
                                int inflated = sizeof(out) - zstream.avail_out;
@@ -450,12 +433,10 @@ mesh::mesh(const std::string& path)
                while(result != Z_STREAM_END);
 
                inflateEnd(&zstream);
-
                import(stream);
        }
 }
 
-
 void mesh::draw(scalar alpha) const
 {
        glEnableClientState(GL_VERTEX_ARRAY);
@@ -469,7 +450,6 @@ void mesh::draw(scalar alpha) const
        // TODO: disable vertex array?
 }
 
-
 void mesh::set_material(int index) const
 {
        set_material(materials_[index]);
@@ -485,7 +465,6 @@ void mesh::set_material(const material& material) const
        glMaterial(GL_FRONT, GL_SHININESS, material.shininess);
 }
 
-
 void mesh::object::draw(scalar alpha, bool recurse) const
 {
        glVertexPointer(verts);
@@ -516,13 +495,10 @@ void mesh::object::draw(scalar alpha, bool recurse) const
        {
                std::vector<object_ptr>::const_iterator jt;
                for (jt = kids.begin(); jt != kids.end(); ++jt)
-               {
                        (*jt)->draw(alpha);
-               }
        }
 }
 
-
 //class mesh_resource_loader
 //{
 //public:
index 0fbc3cc5b303a526f6aa99f0b19ec075fadeb6e8..26accec43e1410b295797c6dbda017f7ac9b9faf 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_MESH_HH_
 #define _MOOF_MESH_HH_
@@ -34,9 +32,9 @@
 namespace moof {
 
 
+// forward declarations
 class script;
 
-
 class mesh : public boost::noncopyable, public entity
 {
 public:
@@ -45,23 +43,19 @@ public:
 
        void draw(scalar alpha = SCALAR(0.0)) const;
 
-
        struct material
        {
                material(const std::string& id) :
                        name(id) {}
 
-
+               scalar          shininess;
                std::string     name;
-
-               vector4         diffuse;
                vector4         ambient;
+               vector4         diffuse;
                vector4         emissive;
                vector4         specular;
-               scalar          shininess;
        };
 
-
        void set_material(int index) const;
        void set_material(const material& material) const;
 
@@ -71,7 +65,6 @@ public:
                std::vector<vector2>    triangles_uv;
        };
 
-
        class object;
        typedef boost::shared_ptr<object> object_ptr;
        typedef boost::weak_ptr<object>   object_weakptr;
@@ -87,33 +80,31 @@ public:
                        return object_ptr(new object(m));
                }
 
-               void draw(scalar alpha = SCALAR(0.0), bool recurse = true) const;
-
+               void
+               draw(scalar alpha = SCALAR(0.0), bool recurse = true) const;
 
-               const moof::mesh&                       mesh;
+               const moof::mesh&       mesh;
 
-               std::string                                     name;
-               std::string                                     data;
-               std::string                                     url;
+               std::string             name;
+               std::string             data;
+               std::string             url;
 
-               image_handle                            texture;
-               vector2                                         texrep;
+               image_handle            texture;
+               vector2                 texrep;
 
-               std::vector<vector3>            verts;
-               std::vector<material_group>     faces;
+               std::vector<vector3>                    verts;
+               std::vector<material_group>             faces;
 
-               std::vector<object_ptr>         kids;
-               std::map<std::string,object_ptr>                kids_byname;
-               object_weakptr                                  parent;
+               std::vector<object_ptr>                 kids;
+               std::map<std::string,object_ptr>        kids_byname;
+               object_weakptr                          parent;
        };
 
-
        object_ptr operator [] (unsigned index) const
        {
                return objects_[index];
        }
 
-
        /**
         * Import script bindings for the mesh class.
         * \param The script.
@@ -121,7 +112,6 @@ public:
         */
        static void import(script& script, const std::string& nspace = "");
 
-
 private:
 
        void import(std::istream& stream);
index 02138add2249c6c3ecae12a085ea9bf96b97f5e4..8c9f9e0c07aff424d717944ea3499b73edb19e1d 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #include "log.hh"
 #include "mesh.hh"
@@ -37,8 +35,10 @@ static int mesh_draw(script& script)
        script[1].require_object<mesh_handle>("mesh").get(mesh);
 
        scalar alpha;
-       if (script[2].get(alpha)) (*mesh)->draw(alpha);
-       else                      (*mesh)->draw();
+       if (script[2].get(alpha))
+               (*mesh)->draw(alpha);
+       else
+               (*mesh)->draw();
 
        return 0;
 }
@@ -70,17 +70,19 @@ static int object_draw(script& script)
        mesh::object_ptr* object;
        script[1].require_object<mesh::object_ptr>("mesh object").get(object);
 
-       scalar alpha;
-       bool recurse;
-       if (script[2].get(alpha))
-       {
-               if (script[3].get(recurse)) (*object)->draw(alpha, recurse);
-               else (*object)->draw(alpha);
+       scalar  alpha;
+       bool    recurse;
+       if (script[2].get(alpha)) {
+               if (script[3].get(recurse))
+                       (*object)->draw(alpha, recurse);
+               else
+                       (*object)->draw(alpha);
        }
-       else
-       {
-               if (script[2].get(recurse)) (*object)->draw(SCALAR(0.0), recurse);
-               else (*object)->draw();
+       else {
+               if (script[2].get(recurse))
+                       (*object)->draw(SCALAR(0.0), recurse);
+               else
+                       (*object)->draw();
        }
 
        return 0;
@@ -91,21 +93,18 @@ static int object_index(script& script)
        mesh::object_ptr* object;
        script[1].require_object<mesh::object_ptr>("mesh object").get(object);
 
-       if (script[2].is_number())
-       {
+       if (script[2].is_number()) {
                unsigned index;
                script[2].get(index);
                --index;
                script.push((*object)->kids[index]);
        }
-       else if (script[2].is_string())
-       {
+       else if (script[2].is_string()) {
                std::string name;
                script[2].get(name);
                script.push((*object)->kids_byname[name]);
        }
-       else
-       {
+       else {
                script[2].raise_type_error("index or name");
        }
        return 1;
index 4498692c9a3a79bade1539f6f778bd71fde20fc8..4afeb39b1d998a78d066470b66916c25cd364b3e 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_MODAL_DIALOG_HH_
 #define _MOOF_MODAL_DIALOG_HH_
@@ -18,7 +16,9 @@
  * supported, but only one can be used as determined at build time.
  */
 
+#if HAVE_CONFIG_H
 #include "config.h"
+#endif
 
 #include <string>
 
@@ -42,7 +42,6 @@ namespace moof {
 /**
  * Small wrapper over various user interface modal dialog windows.
  */
-
 struct modal_dialog
 {
        enum type
@@ -52,12 +51,10 @@ struct modal_dialog
                error           = 3
        };
 
-
-       std::string title;
+       std::string     title;
        type            type;
-       std::string text1;
-       std::string text2;
-
+       std::string     text1;
+       std::string     text2;
 
        /**
         * Construct a dialog box.
@@ -67,84 +64,80 @@ struct modal_dialog
         * \param text2 The second line.
         */
        modal_dialog(enum type type = information,
-                                const std::string& title = "",
-                                const std::string& text1 = "",
-                                const std::string& text2 = "") :
+                       const std::string& title = "",
+                       const std::string& text1 = "",
+                       const std::string& text2 = "") :
                title(title),
                type(type),
                text1(text1),
                text2(text2) {}
 
-
        void run() const
        {
                switch (type)
                {
-                       case warning:
-                               log_warning(text1);
-                               log_warning(text2);
-                               break;
-                       case error:
-                               log_error(text1);
-                               log_error(text2);
-                               break;
-                       default:
-                               log_info(text1);
-                               log_info(text2);
-                               break;
+               case warning:
+                       log_warning(text1);
+                       log_warning(text2);
+                       break;
+               case error:
+                       log_error(text1);
+                       log_error(text2);
+                       break;
+               default:
+                       log_info(text1);
+                       log_info(text2);
+                       break;
                }
 
 #if PLATFORM_WIN32
-
                int icon_type;
                switch (type)
                {
-                       case warning:
-                               icon_type = MB_ICONWARNING;
-                               break;
-                       case error:
-                               icon_type = MB_ICONERROR;
-                               break;
-                       default:
-                               icon_type = MB_ICONINFORMATION;
-                               break;
+               case warning:
+                       icon_type = MB_ICONWARNING;
+                       break;
+               case error:
+                       icon_type = MB_ICONERROR;
+                       break;
+               default:
+                       icon_type = MB_ICONINFORMATION;
+                       break;
                }
 
                MessageBox(0, (text1 + "\n" + text2).c_str(), title.c_str(),
                                   MB_OK | icon_type);
-
 #elif WITH_GUI_GTK
-
-               int             argc = 0;
+               int     argc = 0;
                char**  argv;
                gtk_init(&argc, &argv);
 
                GtkMessageType icon_type;
                switch (type)
                {
-                       case warning:
-                               icon_type = GTK_MESSAGE_WARNING;
-                               break;
-                       case error:
-                               icon_type = GTK_MESSAGE_ERROR;
-                               break;
-                       default:
-                               icon_type = GTK_MESSAGE_INFO;
-                               break;
+               case warning:
+                       icon_type = GTK_MESSAGE_WARNING;
+                       break;
+               case error:
+                       icon_type = GTK_MESSAGE_ERROR;
+                       break;
+               default:
+                       icon_type = GTK_MESSAGE_INFO;
+                       break;
                }
 
                GtkWidget* dialog = gtk_message_dialog_new(NULL,
                                GTK_DIALOG_DESTROY_WITH_PARENT, icon_type,
                                GTK_BUTTONS_CLOSE, "%s", text1.c_str());
                gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
-                                                                                                "%s", text2.c_str());
+                                       "%s", text2.c_str());
                gtk_window_set_title(GTK_WINDOW(dialog), title.c_str());
 
-               std::string icon_path = resource::find_file(PACKAGE".png");
+               std::string icon_path = resource::find_file(PACKAGE_TARNAME".png");
                if (!icon_path.empty())
                {
                        GdkPixbuf* iconPixbuf = gdk_pixbuf_new_from_file(icon_path.c_str(),
-                                                                                                                        NULL);
+                                       NULL);
                        gtk_window_set_icon(GTK_WINDOW(dialog), iconPixbuf);
                }
 
@@ -152,25 +145,23 @@ struct modal_dialog
                gtk_widget_destroy(dialog);
                // FIXME - this doesn't seem to actually remove the window from the
                // screen when it closes
-
 #elif WITH_GUI_QT4
-
-               int             argc = 0;
+               int     argc = 0;
                char**  argv;
                QApplication qt_app(argc, argv);
 
                QMessageBox::Icon icon_type;
                switch (type)
                {
-                       case warning:
-                               icon_type = QMessageBox::Warning;
-                               break;
-                       case error:
-                               icon_type = QMessageBox::Critical;
-                               break;
-                       default:
-                               icon_type = QMessageBox::Information;
-                               break;
+               case warning:
+                       icon_type = QMessageBox::Warning;
+                       break;
+               case error:
+                       icon_type = QMessageBox::Critical;
+                       break;
+               default:
+                       icon_type = QMessageBox::Information;
+                       break;
                }
 
                QMessageBox dialog;
@@ -180,7 +171,7 @@ struct modal_dialog
                dialog.setInformativeText(text2.c_str());
                dialog.setStandardButtons(QMessageBox::Close);
 
-               std::string icon_path = resource::find_file(PACKAGE".png");
+               std::string icon_path = resource::find_file(PACKAGE_TARNAME".png");
                if (!icon_path.empty())
                {
                        QIcon icon(icon_path.c_str());
@@ -188,7 +179,6 @@ struct modal_dialog
                }
 
                dialog.exec();
-
 #endif
        }
 };
index 38502d3393e0cac32c52d3e3c7c12036738874fb..998473b7f88535fb70d4324172c1f54f86e6c5e2 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_NETWORK_HH_
 #define _MOOF_NETWORK_HH_
index 3367bc8616ddcf569dfa78261bec5f90b9432462..6eeb5532f60427a07ada8bc167852c77c378be95 100644 (file)
@@ -1,24 +1,24 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_OPENGL_HH_
 #define _MOOF_OPENGL_HH_
 
 /**
  * \file opengl.hh
- * Defines macros for OpenGL functions that operate on scalars, vectors,
- * and matrices.
+ * Defines macros for OpenGL functions that operate on scalars, vectors, and
+ * matrices.
  */
 
+#if HAVE_CONFIG_H
 #include "config.h"
+#endif
 
 #include <vector>
 
 #define ARGS_V4                const moof::vector4& v
 #define PASS_V4                v[0], v[1], v[2], v[3]
 
-
 #if ENABLE_DOUBLE_PRECISION
 
-#define OPENGL_GENERIC_FUNC(R, N, L)                                                                   \
+#define OPENGL_GENERIC_FUNC(R, N, L)                                   \
        inline R gl##N(ARGS_##L) { gl##N##d(PASS_##L); }//
 
-#define OPENGL_ORDINAL_FUNC(R, N, K)                                                                   \
-       inline R gl##N(ARGS_##S##K) { gl##N##K##d(PASS_##S##K); }                       \
+#define OPENGL_ORDINAL_FUNC(R, N, K)                                   \
+       inline R gl##N(ARGS_##S##K) { gl##N##K##d(PASS_##S##K); }       \
        inline R gl##N(ARGS_##P##K) { gl##N##K##d##v(PASS_##P##K); }//
 
 #else
 
-#define OPENGL_GENERIC_FUNC(R, N, L)                                                                   \
+#define OPENGL_GENERIC_FUNC(R, N, L)                                   \
        inline R gl##N(ARGS_##L) { gl##N##f(PASS_##L); }//
 
-#define OPENGL_ORDINAL_FUNC(R, N, K)                                                                   \
-       inline R gl##N(ARGS_##S##K) { gl##N##K##f(PASS_##S##K); }                       \
+#define OPENGL_ORDINAL_FUNC(R, N, K)                                   \
+       inline R gl##N(ARGS_##S##K) { gl##N##K##f(PASS_##S##K); }       \
        inline R gl##N(ARGS_##P##K) { gl##N##K##f##v(PASS_##P##K); }//
 
 #endif
 
+OPENGL_GENERIC_FUNC(void, LoadMatrix, P);
+OPENGL_GENERIC_FUNC(void, LoadMatrix, M);
+OPENGL_GENERIC_FUNC(void, MultMatrix, P);
+OPENGL_GENERIC_FUNC(void, MultMatrix, M);
+OPENGL_GENERIC_FUNC(void, Scale,       S3);
+OPENGL_GENERIC_FUNC(void, Scale,       V3);
+OPENGL_GENERIC_FUNC(void, Rotate,      S4);
+OPENGL_GENERIC_FUNC(void, Rotate,      V4);
+OPENGL_GENERIC_FUNC(void, Translate,   S3);
+OPENGL_GENERIC_FUNC(void, Translate,   V3);
 
-OPENGL_GENERIC_FUNC(void,      LoadMatrix,     P);
-OPENGL_GENERIC_FUNC(void,      LoadMatrix,     M);
-OPENGL_GENERIC_FUNC(void,      MultMatrix, P);
-OPENGL_GENERIC_FUNC(void,      MultMatrix, M);
-
-OPENGL_GENERIC_FUNC(void,      Scale,          S3);
-OPENGL_GENERIC_FUNC(void,      Scale,          V3);
-OPENGL_GENERIC_FUNC(void,      Rotate,         S4);
-OPENGL_GENERIC_FUNC(void,      Rotate,         V4);
-OPENGL_GENERIC_FUNC(void,      Translate,      S3);
-OPENGL_GENERIC_FUNC(void,      Translate,      V3);
-
-OPENGL_ORDINAL_FUNC(void,      Color,          3);
-OPENGL_ORDINAL_FUNC(void,      Color,          4);
+OPENGL_ORDINAL_FUNC(void, Color, 3);
+OPENGL_ORDINAL_FUNC(void, Color, 4);
 
-OPENGL_ORDINAL_FUNC(void,      Vertex,         2);
-OPENGL_ORDINAL_FUNC(void,      Vertex,         3);
-OPENGL_ORDINAL_FUNC(void,      Vertex,         4);
+OPENGL_ORDINAL_FUNC(void, Vertex, 2);
+OPENGL_ORDINAL_FUNC(void, Vertex, 3);
+OPENGL_ORDINAL_FUNC(void, Vertex, 4);
 
-OPENGL_ORDINAL_FUNC(void,      TexCoord,       2);
-OPENGL_ORDINAL_FUNC(void,      TexCoord,       3);
-OPENGL_ORDINAL_FUNC(void,      TexCoord,       4);
-
-OPENGL_GENERIC_FUNC(void,      Rect,           S4);
-OPENGL_GENERIC_FUNC(void,      Rect,           V4);
+OPENGL_ORDINAL_FUNC(void, TexCoord, 2);
+OPENGL_ORDINAL_FUNC(void, TexCoord, 3);
+OPENGL_ORDINAL_FUNC(void, TexCoord, 4);
 
+OPENGL_GENERIC_FUNC(void, Rect, S4);
+OPENGL_GENERIC_FUNC(void, Rect, V4);
 
 inline void glMaterial(GLenum face, GLenum pname, moof::scalar s)
 {
@@ -136,12 +133,14 @@ inline void glDrawElements(GLenum type, const std::vector<GLuint>& v)
        glDrawElements(type, v.size(), GL_UNSIGNED_INT, &v[0]);
 }
 
-
+inline void glGetScalar(GLenum a, GLscalar* b)
+{
 #if ENABLE_DOUBLE_PRECISION
-inline void glGetScalar(GLenum a, GLscalar* b) { glGetDoublev(a, b); }
+       glGetDoublev(a, b);
 #else
-inline void glGetScalar(GLenum a, GLscalar* b) { glGetFloatv(a, b); }
+       glGetFloatv(a, b);
 #endif
+}
 
 
 #endif // _MOOF_OPENGL_HH_
index 4a175b0932cc0ded5f8039bcf3491cc6d215b3c3..dc9ce2d62a4116e8735327ea9fd9130cc4ef10da 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #include "aabb.hh"
 #include "plane.hh"
 namespace moof {
 
 
-plane::halfspace plane::intersects(const aabb<3>& aabb) const
+plane::halfspace plane::intersects(const aabb3& aabb) const
 {
-       vector3 corners[8];
        int nPositive = 8;
-
+       vector3 corners[8];
        aabb.get_corners(corners);
 
        for (int i = 0; i < 8; ++i)
        {
-               if (intersects(corners[i]) == negative)
-               {
-                       --nPositive;
-               }
+               if (intersects(corners[i]) == negative) --nPositive;
        }
 
-       if (nPositive == 0)      return negative;
+       if (nPositive == 0) return negative;
        else if (nPositive == 8) return positive;
-       else                     return intersecting;
+       return intersecting;
 }
 
-plane::halfspace plane::intersects(const sphere<3>& sphere) const
+plane::halfspace plane::intersects(const sphere3& sphere) const
 {
        scalar distance = distance_to_point(sphere.point);
 
-       if (distance < -sphere.radius)     return negative;
+       if (distance < -sphere.radius) return negative;
        else if (distance < sphere.radius) return intersecting;
-       else                               return positive;
+       return positive;
 }
 
 
index 5605831a3ca73ba5bbe37cc3b290b0ca3c0c66f9..83b5517385380a18f59c5cc167640d96b76e8e88 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_PLANE_HH_
 #define _MOOF_PLANE_HH_
 namespace moof {
 
 
+// forward declarations
 template <int D> class aabb;
 template <int D> class sphere;
 
-
 /**
- * A plane in 3-space defined by the equation Ax + By + Cz = D, where [A,
- * B, C] is normal to the plane.
+ * A plane in 3-space defined by the equation Ax + By + Cz = D, where [A, B,
+ * C] is normal to the plane.
  */
 struct plane : public shape<3>
 {
@@ -39,9 +37,9 @@ struct plane : public shape<3>
 
        enum halfspace
        {
-               negative                = -1,
+               negative        = -1,
                intersecting    =  0,
-               positive                =  1
+               positive        =  1
        };
 
        plane() {}
@@ -52,7 +50,6 @@ struct plane : public shape<3>
                normal(a, b, c),
                d(scalar) {}
 
-
        bool intersect_ray(const ray3& ray, ray3::contact& hit)
        {
                // solve: [(ray.point + t*ray.direction) dot normal] + d = 0
@@ -79,11 +76,10 @@ struct plane : public shape<3>
                if (hit.distance < SCALAR(0.0)) return false;
 
                if (numer >= 0.0) hit.normal = normal;
-               else              hit.normal = -normal;
+               else hit.normal = -normal;
                return true;
        }
 
-
        /* Causes the normal of the plane to become normalized.  The scalar may
         * also be changed to keep the equation true.  Word to the wise: don't
         * normalize a plane if the normal is the zero vector.
@@ -91,7 +87,6 @@ struct plane : public shape<3>
        void normalize()
        {
                scalar mag = normal.length();
-
                normal /= mag;
                d /= mag;
        }
@@ -109,8 +104,8 @@ struct plane : public shape<3>
                scalar distance = distance_to_point(point);
 
                if (is_equal(distance, 0.0)) return intersecting;
-               else if (distance < 0.0)     return negative;
-               else                         return positive;
+               else if (distance < 0.0) return negative;
+               return positive;
        }
 
        halfspace intersects(const aabb<3>& aabb) const;
index b1f7bdde88e54d937b124ee06433900df56c2de4..b992903b8bb2d892bf853af68d409d1e136363fa 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_RAY_HH_
 #define _MOOF_RAY_HH_
@@ -73,9 +71,8 @@ struct ray : public drawable
        }
 };
 
-
-typedef ray<2> ray2;
-typedef ray<3> ray3;
+typedef ray<2> ray2;
+typedef ray<3> ray3;
 
 
 } // namespace moof
index 95b4c698501a05686a02d1789a3f428298939cb1..7a60d0e304e6e4c444dbeb5d920c3a5215c4e478 100644 (file)
@@ -1,15 +1,15 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
+#if HAVE_CONFIG_H
 #include "config.h"
+#endif
 
 #include <queue>
 
 #include "hash.hh"
 #include "resource.hh"
 
-
 #ifndef BUF_SIZE
-#define BUF_SIZE 4096
+#define BUF_SIZE 8192
 #endif
 
 
 namespace moof {
-       
+
 
 /*] Filesystem searching
  *************************************************************************/
@@ -44,7 +43,6 @@ void resource::set_search_paths(const std::string& paths)
        boost::split(search_paths_, paths, boost::is_any_of(":"));
 }
 
-
 std::string resource::find_file(const std::string& name)
 {
        std::string ext = stlplus::extension_part(name);
@@ -76,8 +74,8 @@ std::string resource::find_file(const std::string& name)
        return std::string();
 }
 
-std::string resource::find_file(const std::string& name,
-                                                               const std::string& ext)
+std::string
+resource::find_file(const std::string& name, const std::string& ext)
 {
        std::string actual_ext = stlplus::extension_part(name);
        if (actual_ext != ext)
@@ -105,9 +103,7 @@ static struct rsrc_list
        {
                hash<std::string,resource_weakptr,hash_function>::iterator it;
                for (it = table.begin(); it != table.end(); ++it)
-               {
                        log_warning("leaked resource:", (*it).first);
-               }
        }
 #endif
 } rsrc_list;
@@ -131,7 +127,7 @@ static struct watch_list
        int add(resource_ptr rsrc)
        {
                int wd = inotify_add_watch(fd, rsrc->path().c_str(),
-                                                                  IN_DELETE_SELF | IN_MODIFY);
+                               IN_DELETE_SELF | IN_MODIFY);
                table[wd] = rsrc;
                return wd;
        }
@@ -142,22 +138,19 @@ static struct watch_list
 } watch_list;
 #endif
 
-
 resource_ptr resource::load(const std::string& name)
 {
        std::string ext = stlplus::extension_part(name);
        return load_with_path(find_file(name, ext), ext);
 }
 
-resource_ptr resource::load(const std::string& name,
-                                                       const std::string& ext)
+resource_ptr resource::load(const std::string& name, const std::string& ext)
 {
        return load_with_path(find_file(name, ext), ext);
 }
 
-
-resource_ptr resource::load_with_path(const std::string& path,
-                                                                         const std::string& ext)
+resource_ptr
+resource::load_with_path(const std::string& path, const std::string& ext)
 {
        if (path.empty()) return resource_ptr();
 
@@ -189,7 +182,6 @@ resource_ptr resource::load_with_path(const std::string& path,
        return resource_ptr();
 }
 
-
 /*] Hotloading
  *************************************************************************/
 
@@ -237,7 +229,6 @@ int resource::reload_as_needed()
                }
        }
 #endif
-
        return count;
 }
 
@@ -260,32 +251,30 @@ resource::~resource()
 #endif
 }
 
-
 /*] Resource registration
  *************************************************************************/
 
 bool resource::call_registry(const std::string& ext,
-                                                        loader_ptr& loader,
-                                                        registry_action action)
+               loader_ptr& loader, registry_action action)
 {
        static std::map<std::string,loader_ptr> table;
 
        switch (action)
        {
-               case set:
-               {
-                       if (loader) table[ext] = loader;
-                       else        table.erase(ext);
-                       break;
-               }
+       case lookup:
+       {
+               std::map<std::string,loader_ptr>::iterator it;
+               it = table.find(ext);
+               if (it != table.end()) loader = (*it).second;
+               break;
+       }
 
-               case lookup:
-               {
-                       std::map<std::string,loader_ptr>::iterator it;
-                       it = table.find(ext);
-                       if (it != table.end()) loader = (*it).second;
-                       break;
-               }
+       case set:
+               if (loader)
+                       table[ext] = loader;
+               else
+                       table.erase(ext);
+               break;
        }
 
        return loader;
index 094791c30f383b34538f6713227a190f69452ba3..41dfd61ac11d5ab3bbd94262fcf58c543183181f 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #ifndef _MOOF_RESOURCE_HH_
 #define _MOOF_RESOURCE_HH_
@@ -34,7 +32,6 @@ namespace moof {
 class resource;
 typedef boost::shared_ptr<resource> resource_ptr;
 
-
 /**
  * Generic resource class capable of containing any type of resource,
  * providing a type-safe interface.
@@ -49,7 +46,6 @@ public:
         */
        static void set_search_paths(const std::string& paths);
 
-
        /**
         * Get the path to a resource of a given name.  This uses the search
         * path(s) and resources prefixes to locate resource files.
@@ -67,8 +63,8 @@ public:
         * extension is not already a part of name.
         * \return The full path of the resource.
         */
-       static std::string find_file(const std::string& name,
-                                                                const std::string& ext);
+       static std::string
+       find_file(const std::string& name, const std::string& ext);
 
        /**
         * Register a type with the extension of files which this type can
@@ -78,7 +74,7 @@ public:
         */
        template <class T>
        static void register_type(const std::string& extension,
-                                                         const std::string& prefix = "")
+                       const std::string& prefix = "")
        {
                loader_ptr loader(new specific_loader<T>(prefix));
                call_registry(extension, loader, set);
@@ -96,7 +92,6 @@ public:
                call_registry(extension, loader, set);
        }
 
-
        /**
         * Find and load a resource by name or path.
         * \param name The name or partial path of the resource.  This should
@@ -112,9 +107,8 @@ public:
         * \param 
         * \return The resource.
         */
-       static resource_ptr load(const std::string& name,
-                                                        const std::string& ext);
-
+       static resource_ptr
+       load(const std::string& name, const std::string& ext);
 
        /**
         * Reload the resource data.  This will cause the resource file to be
@@ -138,7 +132,6 @@ public:
         */
        static int reload_as_needed();
 
-
        /**
         * Get whether or not the type of the underlying resource data matches
         * an expected type.
@@ -162,13 +155,11 @@ public:
                return 0;
        }
 
-
        /**
         * Deconstruct a resource container.
         */
        virtual ~resource();
 
-
 private:
 
        template <class T>
@@ -178,9 +169,8 @@ private:
                unloader_(new specific_unloader<T>(ptr)),
                wd_(-1) {}
 
-       static resource_ptr load_with_path(const std::string& path,
-                                                                          const std::string& extension);
-
+       static resource_ptr
+       load_with_path(const std::string& path, const std::string& extension);
 
        class loader
        {
@@ -201,7 +191,6 @@ private:
                        return prefix_;
                }
 
-
        private:
 
                std::string prefix_;
@@ -223,7 +212,6 @@ private:
                }
        };
 
-
        class unloader
        {
        public:
@@ -246,13 +234,11 @@ private:
                        delete object_;
                }
 
-
        private:
 
                T* object_;
        };
 
-
        enum registry_action
        {
                lookup,
@@ -260,16 +246,14 @@ private:
        };
 
        static bool call_registry(const std::string& extension,
-                                                         loader_ptr& loader,
-                                                         registry_action action);
+                       loader_ptr& loader, registry_action action);
 
-
-       void*                   resource_;
+       void*           resource_;
        std::type_info* typeinfo_;
        unloader_ptr    unloader_;
-       int