1 //---------------------------------------------------------------------------- 2 // EDGE Blockmap utility functions 3 //---------------------------------------------------------------------------- 4 // 5 // Copyright (c) 1999-2009 The EDGE Team. 6 // 7 // This program is free software; you can redistribute it and/or 8 // modify it under the terms of the GNU General Public License 9 // as published by the Free Software Foundation; either version 2 10 // of the License, or (at your option) any later version. 11 // 12 // This program is distributed in the hope that it will be useful, 13 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 // GNU General Public License for more details. 16 // 17 //---------------------------------------------------------------------------- 18 // 19 // Based on the DOOM source code, released by Id Software under the 20 // following copyright: 21 // 22 // Copyright (C) 1993-1996 by id Software, Inc. 23 // 24 //---------------------------------------------------------------------------- 25 26 #ifndef __P_BLOCKMAP_H__ 27 #define __P_BLOCKMAP_H__ 28 29 // #include "epi/arrays.h" 30 31 // mapblocks are used to check movement 32 // against lines and things 33 #define BLOCKMAP_UNIT 128 34 #define LIGHTMAP_UNIT 512 35 36 #define BMAP_END ((unsigned short) 0xFFFF) 37 38 extern int bmap_width; // in mapblocks 39 extern int bmap_height; 40 41 extern float bmap_orgx; // origin of block map 42 extern float bmap_orgy; 43 44 #define BLOCKMAP_GET_X(x) ((int) ((x) - bmap_orgx) / BLOCKMAP_UNIT) 45 #define BLOCKMAP_GET_Y(y) ((int) ((y) - bmap_orgy) / BLOCKMAP_UNIT) 46 47 #define LIGHTMAP_GET_X(x) ((int) ((x) - bmap_orgx) / LIGHTMAP_UNIT) 48 #define LIGHTMAP_GET_Y(y) ((int) ((y) - bmap_orgy) / LIGHTMAP_UNIT) 49 50 51 #define PT_ADDLINES 1 52 #define PT_ADDTHINGS 2 53 54 typedef struct intercept_s 55 { 56 float frac; // along trace line 57 58 // one of these will be NULL 59 mobj_t *thing; 60 line_t *line; 61 } 62 intercept_t; 63 64 extern divline_t trace; 65 66 67 /* FUNCTIONS */ 68 69 void P_CreateThingBlockMap(void); 70 void P_DestroyBlockMap(void); 71 72 void P_SetThingPosition(mobj_t * mo); 73 void P_UnsetThingPosition(mobj_t * mo); 74 void P_UnsetThingFinally(mobj_t * mo); 75 void P_ChangeThingPosition(mobj_t * mo, float x, float y, float z); 76 void P_FreeSectorTouchNodes(sector_t *sec); 77 78 void P_GenerateBlockMap(int min_x, int min_y, int max_x, int max_y); 79 80 bool P_BlockLinesIterator(float x1, float y1, float x2, float y2, 81 bool (* func)(line_t *, void *), 82 void *data = NULL); 83 84 bool P_BlockThingsIterator(float x1, float y1, float x2, float y2, 85 bool (* func)(mobj_t *, void *), 86 void *data = NULL); 87 88 void P_DynamicLightIterator(float x1, float y1, float z1, 89 float x2, float y2, float z2, 90 void (* func)(mobj_t *, void *), 91 void *data = NULL); 92 93 void P_SectorGlowIterator(sector_t *sec, 94 float x1, float y1, float z1, 95 float x2, float y2, float z2, 96 void (* func)(mobj_t *, void *), 97 void *data = NULL); 98 99 float P_InterceptVector(divline_t * v2, divline_t * v1); 100 101 bool P_PathTraverse(float x1, float y1, float x2, float y2, int flags, 102 bool (* func)(intercept_t *, void *), 103 void *data = NULL); 104 105 106 #endif // __P_BLOCKMAP_H__ 107 108 //--- editor settings --- 109 // vi:ts=4:sw=4:noexpandtab 110