From 853bf13d9e1aef6fe544990b1f89a39ceb3820d2 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 14 Nov 2011 15:46:39 +0900 Subject: [PATCH] Move the winding code into libQFmodels. --- config.d/build_control.m4 | 2 +- include/QF/Makefile.am | 2 +- {tools/qfbsp/include => include/QF}/winding.h | 11 ++++++----- libs/models/Makefile.am | 2 +- libs/models/test/testclip.c | 18 +++++++++--------- {tools/qfbsp/source => libs/models}/winding.c | 11 ++++++----- tools/qfbsp/include/Makefile.am | 2 +- tools/qfbsp/include/bsp5.h | 2 +- tools/qfbsp/source/Makefile.am | 3 +-- tools/qfbsp/source/brush.c | 1 - tools/qfbsp/source/csg4.c | 1 - tools/qfbsp/source/merge.c | 1 - tools/qfbsp/source/outside.c | 1 - tools/qfbsp/source/portals.c | 1 - tools/qfbsp/source/readbsp.c | 1 - tools/qfbsp/source/region.c | 1 - tools/qfbsp/source/solidbsp.c | 1 - tools/qfbsp/source/surfaces.c | 1 - tools/qfbsp/source/tjunc.c | 1 - 19 files changed, 27 insertions(+), 36 deletions(-) rename {tools/qfbsp/include => include/QF}/winding.h (96%) rename {tools/qfbsp/source => libs/models}/winding.c (97%) diff --git a/config.d/build_control.m4 b/config.d/build_control.m4 index 8f4953a95..8105ba438 100644 --- a/config.d/build_control.m4 +++ b/config.d/build_control.m4 @@ -527,7 +527,7 @@ QF_DEPS(BSP2IMG, ) QF_DEPS(QFBSP, [-I$(top_srcdir)/tools/qfbsp/include], - [$(top_builddir)/libs/util/libQFutil.la], + [$(top_builddir)/libs/util/libQFutil.la $(top_builddir)/libs/models/libQFmodels.la], [$(WIN32_LIBS)], ) QF_DEPS(QFCC, diff --git a/include/QF/Makefile.am b/include/QF/Makefile.am index 8998e8a4d..451faf023 100644 --- a/include/QF/Makefile.am +++ b/include/QF/Makefile.am @@ -9,7 +9,7 @@ nobase_pkginclude_HEADERS = \ qargs.h qdefs.h qendian.h qfplist.h qtypes.h quakefs.h quakeio.h render.h \ riff.h ruamoko.h screen.h script.h sizebuf.h skin.h sound.h spritegn.h \ sys.h teamplay.h tga.h uint32.h va.h ver_check.h vid.h view.h wad.h \ - wadfile.h zone.h \ + wadfile.h winding.h zone.h \ \ GL/ati.h GL/defines.h GL/extensions.h GL/funcs.h GL/qf_explosions.h \ GL/qf_funcs_list.h GL/qf_lightmap.h GL/qf_noisetextures.h \ diff --git a/tools/qfbsp/include/winding.h b/include/QF/winding.h similarity index 96% rename from tools/qfbsp/include/winding.h rename to include/QF/winding.h index 3bae9415e..f1a779003 100644 --- a/tools/qfbsp/include/winding.h +++ b/include/QF/winding.h @@ -20,18 +20,19 @@ $Id$ */ -#ifndef qfbsp_winding_h -#define qfbsp_winding_h +#ifndef __QF_winding_h +#define __QF_winding_h #include "QF/mathlib.h" -/** \defgroup qfbsp_winding Winding Manipulation - \ingroup qfbsp +/** \defgroup winding Winding Manipulation */ //@{ struct plane_s; +#define ON_EPSILON 0.05 + typedef struct winding_s { int numpoints; ///< The number of points in the winding vec3_t points[3]; ///< variable sized, never less than 3 @@ -130,4 +131,4 @@ void DivideWinding (winding_t *in, struct plane_s *split, //@} -#endif//qfbsp_winding_h +#endif//__QF_winding_h diff --git a/libs/models/Makefile.am b/libs/models/Makefile.am index e11fb0b2b..134b59909 100644 --- a/libs/models/Makefile.am +++ b/libs/models/Makefile.am @@ -7,7 +7,7 @@ INCLUDES= -I$(top_srcdir)/include lib_LTLIBRARIES= libQFmodels.la @VID_MODEL_TARGETS@ EXTRA_LTLIBRARIES= libQFmodels_gl.la libQFmodels_sw.la -models_sources = clip_hull.c model.c trace.c +models_sources = clip_hull.c model.c trace.c winding.c libQFmodels_la_LDFLAGS= -version-info $(QUAKE_LIBRARY_VERSION_INFO) -no-undefined libQFmodels_la_LIBADD= brush/libbrush.la $(top_builddir)/libs/util/libQFutil.la diff --git a/libs/models/test/testclip.c b/libs/models/test/testclip.c index 338c7eae7..97e5e282a 100644 --- a/libs/models/test/testclip.c +++ b/libs/models/test/testclip.c @@ -26,7 +26,7 @@ mclipnode_t clipnodes_simple_wedge[] = { { 1, {CONTENTS_EMPTY, CONTENTS_SOLID}}, }; -mplane_t planes_simple_wedge[] = { +plane_t planes_simple_wedge[] = { {{1, 0, 0}, 0, 0, 0}, // 0 {{0.8, 0, 0.6}, 0, 4, 0}, // 1 }; @@ -51,7 +51,7 @@ mclipnode_t clipnodes_tpp1[] = { { 2, {CONTENTS_SOLID, CONTENTS_EMPTY}}, }; -mplane_t planes_tpp1[] = { +plane_t planes_tpp1[] = { {{1, 0, 0}, -32, 0, 0}, {{1, 0, 0}, 32, 0, 0}, {{1, 0, 0}, 48, 0, 0}, @@ -77,7 +77,7 @@ mclipnode_t clipnodes_tpp2[] = { { 2, {CONTENTS_SOLID, CONTENTS_EMPTY}}, }; -mplane_t planes_tpp2[] = { +plane_t planes_tpp2[] = { {{1, 0, 0}, 32, 0, 0}, {{1, 0, 0}, -32, 0, 0}, {{1, 0, 0}, 48, 0, 0}, @@ -103,7 +103,7 @@ mclipnode_t clipnodes_tppw[] = { { 2, {CONTENTS_SOLID, CONTENTS_WATER}}, }; -mplane_t planes_tppw[] = { +plane_t planes_tppw[] = { {{1, 0, 0}, 32, 0, 0}, {{1, 0, 0}, -32, 0, 0}, {{1, 0, 0}, 48, 0, 0}, @@ -130,7 +130,7 @@ mclipnode_t clipnodes_step1[] = { { 2, {CONTENTS_SOLID, CONTENTS_EMPTY}}, }; -mplane_t planes_step1[] = { +plane_t planes_step1[] = { {{0, 0, 1}, 0, 2, 0}, {{0, 0, 1}, 32, 2, 0}, {{1, 0, 0}, 0, 0, 0}, @@ -157,7 +157,7 @@ mclipnode_t clipnodes_step2[] = { { 2, {CONTENTS_EMPTY, CONTENTS_SOLID}}, }; -mplane_t planes_step2[] = { +plane_t planes_step2[] = { {{1, 0, 0}, 0, 0, 0}, {{0, 0, 1}, 32, 2, 0}, {{0, 0, 1}, 0, 2, 0}, @@ -184,7 +184,7 @@ mclipnode_t clipnodes_step3[] = { { 2, {CONTENTS_EMPTY, CONTENTS_SOLID}}, }; -mplane_t planes_step3[] = { +plane_t planes_step3[] = { {{1, 0, 0}, 0, 0, 0}, {{0, 0, 1}, 0, 2, 0}, {{0, 0, 1}, 32, 2, 0}, @@ -215,7 +215,7 @@ mclipnode_t clipnodes_covered_step[] = { { 4, {CONTENTS_SOLID, CONTENTS_EMPTY}}, }; -mplane_t planes_covered_step[] = { +plane_t planes_covered_step[] = { {{0, 0, 1}, 0, 2, 0}, {{0, 0, 1}, 32, 2, 0}, {{1, 0, 0}, 0, 0, 0}, @@ -243,7 +243,7 @@ mclipnode_t clipnodes_ramp[] = { { 2, {CONTENTS_EMPTY, CONTENTS_SOLID}}, }; -mplane_t planes_ramp[] = { +plane_t planes_ramp[] = { {{ 1, 0, 0}, 0, 0, 0}, {{ 0, 0, 1}, 0, 2, 0}, {{-0.6, 0, 0.8}, 0, 4, 0}, diff --git a/tools/qfbsp/source/winding.c b/libs/models/winding.c similarity index 97% rename from tools/qfbsp/source/winding.c rename to libs/models/winding.c index 90849b168..c5b06cb3a 100644 --- a/tools/qfbsp/source/winding.c +++ b/libs/models/winding.c @@ -37,8 +37,9 @@ static __attribute__ ((used)) const char rcsid[] = #include "QF/sys.h" -#include "bsp5.h" -#include "winding.h" +#include "QF/winding.h" + +#define BOGUS (8e6) /** \addtogroup qfbsp_winding */ @@ -56,7 +57,7 @@ BaseWindingForPlane (const plane_t *p) // find the major axis - max = -BOGUS_RANGE; + max = -BOGUS; x = -1; for (i = 0; i < 3; i++) { v = fabs (p->normal[i]); @@ -87,8 +88,8 @@ BaseWindingForPlane (const plane_t *p) CrossProduct (vup, p->normal, vright); - VectorScale (vup, BOGUS_RANGE, vup); - VectorScale (vright, BOGUS_RANGE, vright); + VectorScale (vup, BOGUS, vup); + VectorScale (vright, BOGUS, vright); // project a really big axis aligned box onto the plane w = NewWinding (4); diff --git a/tools/qfbsp/include/Makefile.am b/tools/qfbsp/include/Makefile.am index 527651177..d4ab30d4e 100644 --- a/tools/qfbsp/include/Makefile.am +++ b/tools/qfbsp/include/Makefile.am @@ -2,4 +2,4 @@ AUTOMAKE_OPTIONS= foreign EXTRA_DIST= brush.h bsp5.h csg4.h draw.h map.h merge.h options.h outside.h \ portals.h readbsp.h region.h solidbsp.h surfaces.h tjunc.h \ - winding.h writebsp.h + writebsp.h diff --git a/tools/qfbsp/include/bsp5.h b/tools/qfbsp/include/bsp5.h index 5230ed550..30a924d7d 100644 --- a/tools/qfbsp/include/bsp5.h +++ b/tools/qfbsp/include/bsp5.h @@ -28,6 +28,7 @@ #include "QF/mathlib.h" #include "QF/bspfile.h" +#include "QF/winding.h" /** \defgroup qfbsp_general General functions \ingroup qfbsp @@ -36,7 +37,6 @@ #define MAX_THREADS 4 -#define ON_EPSILON 0.05 #define BOGUS_RANGE 18000 // the exact bounding box of the brushes is expanded some for the headnode diff --git a/tools/qfbsp/source/Makefile.am b/tools/qfbsp/source/Makefile.am index 2bd7b6fee..9e4172541 100644 --- a/tools/qfbsp/source/Makefile.am +++ b/tools/qfbsp/source/Makefile.am @@ -17,8 +17,7 @@ EXTRA_PROGRAMS= qfbsp qfbsp_SOURCES= \ brush.c csg4.c map.c merge.c nodraw.c options.c outside.c portals.c \ - qfbsp.c readbsp.c region.c solidbsp.c surfaces.c tjunc.c winding.c \ - writebsp.c + qfbsp.c readbsp.c region.c solidbsp.c surfaces.c tjunc.c writebsp.c qfbsp_LDADD= $(QFBSP_LIBS) qfbsp_DEPENDENCIES= $(QFBSP_DEPS) diff --git a/tools/qfbsp/source/brush.c b/tools/qfbsp/source/brush.c index f3dbfd89a..f27c253b8 100644 --- a/tools/qfbsp/source/brush.c +++ b/tools/qfbsp/source/brush.c @@ -37,7 +37,6 @@ #include "draw.h" #include "options.h" #include "surfaces.h" -#include "winding.h" /** \addtogroup qfbsp_brush */ diff --git a/tools/qfbsp/source/csg4.c b/tools/qfbsp/source/csg4.c index 0de15cd58..bbb63fd0c 100644 --- a/tools/qfbsp/source/csg4.c +++ b/tools/qfbsp/source/csg4.c @@ -37,7 +37,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "merge.h" #include "solidbsp.h" #include "surfaces.h" -#include "winding.h" /** \addtogroup qfbsp_csg4 */ diff --git a/tools/qfbsp/source/merge.c b/tools/qfbsp/source/merge.c index 91a21e8f5..c3c6c04e1 100644 --- a/tools/qfbsp/source/merge.c +++ b/tools/qfbsp/source/merge.c @@ -32,7 +32,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "draw.h" #include "merge.h" #include "surfaces.h" -#include "winding.h" /** \addtogroup qfbsp_merge */ diff --git a/tools/qfbsp/source/outside.c b/tools/qfbsp/source/outside.c index 08ea2e8d8..3de085e7b 100644 --- a/tools/qfbsp/source/outside.c +++ b/tools/qfbsp/source/outside.c @@ -31,7 +31,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "options.h" #include "portals.h" #include "outside.h" -#include "winding.h" /** \addtogroup qfbsp_outside */ diff --git a/tools/qfbsp/source/portals.c b/tools/qfbsp/source/portals.c index e6f068044..b4c54a971 100644 --- a/tools/qfbsp/source/portals.c +++ b/tools/qfbsp/source/portals.c @@ -36,7 +36,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "draw.h" #include "options.h" #include "portals.h" -#include "winding.h" /** \addtogroup qfbsp_portals */ diff --git a/tools/qfbsp/source/readbsp.c b/tools/qfbsp/source/readbsp.c index 7beea980a..9578af25c 100644 --- a/tools/qfbsp/source/readbsp.c +++ b/tools/qfbsp/source/readbsp.c @@ -56,7 +56,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "options.h" #include "portals.h" #include "readbsp.h" -#include "winding.h" /** \addtogroup qfbsp_readbsp */ diff --git a/tools/qfbsp/source/region.c b/tools/qfbsp/source/region.c index 243b0cfd8..52487aeb2 100644 --- a/tools/qfbsp/source/region.c +++ b/tools/qfbsp/source/region.c @@ -35,7 +35,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "bsp5.h" #include "region.h" #include "surfaces.h" -#include "winding.h" /** \addtogroup qfbsp_region */ diff --git a/tools/qfbsp/source/solidbsp.c b/tools/qfbsp/source/solidbsp.c index d0ff65c96..365f9d0e8 100644 --- a/tools/qfbsp/source/solidbsp.c +++ b/tools/qfbsp/source/solidbsp.c @@ -37,7 +37,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "draw.h" #include "solidbsp.h" #include "surfaces.h" -#include "winding.h" /** \addtogroup qfbsp_solidbsp */ diff --git a/tools/qfbsp/source/surfaces.c b/tools/qfbsp/source/surfaces.c index 95970ae3e..0879ff416 100644 --- a/tools/qfbsp/source/surfaces.c +++ b/tools/qfbsp/source/surfaces.c @@ -36,7 +36,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "options.h" #include "region.h" #include "surfaces.h" -#include "winding.h" /** \addtogroup qfbsp_surface */ diff --git a/tools/qfbsp/source/tjunc.c b/tools/qfbsp/source/tjunc.c index 0a831d609..9f33159df 100644 --- a/tools/qfbsp/source/tjunc.c +++ b/tools/qfbsp/source/tjunc.c @@ -35,7 +35,6 @@ static __attribute__ ((used)) const char rcsid[] = #include "brush.h" #include "bsp5.h" #include "options.h" -#include "winding.h" #include "tjunc.h" /** \addtogroup qfbsp_tjunc