mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-17 10:20:55 +00:00
91e65b6c80
I got rather tired of there being multiple definitions of mostly compatible plane types (and I need a common type anyway). dplane_t still exists for now because I want to be careful when messing with the actual bsp format.
74 lines
1.8 KiB
C
74 lines
1.8 KiB
C
/*
|
|
clip_hull.c
|
|
|
|
dynamic bsp clipping hull management
|
|
|
|
Copyright (C) 2001 Bill Currie <bill@taniwha.org>
|
|
|
|
Author: Bill Currie <bill@taniwha.org>
|
|
Date: 2001/7/28
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License
|
|
as published by the Free Software Foundation; either version 2
|
|
of the License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to:
|
|
|
|
Free Software Foundation, Inc.
|
|
59 Temple Place - Suite 330
|
|
Boston, MA 02111-1307, USA
|
|
|
|
*/
|
|
#ifdef HAVE_CONFIG_H
|
|
# include "config.h"
|
|
#endif
|
|
|
|
static __attribute__ ((used)) const char rcsid[] =
|
|
"$Id$";
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "QF/clip_hull.h"
|
|
#include "QF/model.h"
|
|
|
|
|
|
VISIBLE clip_hull_t *
|
|
MOD_Alloc_Hull (int nodes, int planes)
|
|
{
|
|
clip_hull_t *ch;
|
|
int size, i;
|
|
|
|
size = sizeof (hull_t);
|
|
size += sizeof (mclipnode_t) * nodes + sizeof (plane_t) * planes;
|
|
size *= MAX_MAP_HULLS;
|
|
size += sizeof (clip_hull_t);
|
|
|
|
ch = calloc (size, 1);
|
|
if (!ch)
|
|
return 0;
|
|
ch->hulls[0] = (hull_t *) &ch[1];
|
|
for (i = 1; i < MAX_MAP_HULLS; i++)
|
|
ch->hulls[i] = &ch->hulls[i - 1][1];
|
|
ch->hulls[0]->clipnodes = (mclipnode_t *) &ch->hulls[i - 1][1];
|
|
ch->hulls[0]->planes = (plane_t *) &ch->hulls[0]->clipnodes[nodes];
|
|
for (i = 1; i < MAX_MAP_HULLS; i++) {
|
|
ch->hulls[i]->clipnodes =
|
|
(mclipnode_t *) &ch->hulls[i - 1]->planes[planes];
|
|
ch->hulls[i]->planes = (plane_t *) &ch->hulls[i]->clipnodes[nodes];
|
|
}
|
|
return ch;
|
|
}
|
|
|
|
VISIBLE void
|
|
MOD_Free_Hull (clip_hull_t *ch)
|
|
{
|
|
free (ch);
|
|
}
|