1 /*
2  * Copyright 2011-2012 Arx Libertatis Team (see the AUTHORS file)
3  *
4  * This file is part of Arx Libertatis.
5  *
6  * Arx Libertatis is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Arx Libertatis is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Arx Libertatis.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 /* Based on:
20 ===========================================================================
21 ARX FATALIS GPL Source Code
22 Copyright (C) 1999-2010 Arkane Studios SA, a ZeniMax Media company.
23 
24 This file is part of the Arx Fatalis GPL Source Code ('Arx Fatalis Source Code').
25 
26 Arx Fatalis Source Code is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
27 License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
28 
29 Arx Fatalis Source Code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
30 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
31 
32 You should have received a copy of the GNU General Public License along with Arx Fatalis Source Code.  If not, see
33 <http://www.gnu.org/licenses/>.
34 
35 In addition, the Arx Fatalis Source Code is also subject to certain additional terms. You should have received a copy of these
36 additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Arx
37 Fatalis Source Code. If not, please request a copy in writing from Arkane Studios at the address below.
38 
39 If you have questions concerning this license or the applicable additional terms, you may contact in writing Arkane Studios, c/o
40 ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
41 ===========================================================================
42 */
43 // Code: Cyril Meynier
44 //
45 // Copyright (c) 1999-2000 ARKANE Studios SA. All rights reserved
46 
47 #ifndef ARX_PHYSICS_COLLISIONS_H
48 #define ARX_PHYSICS_COLLISIONS_H
49 
50 #include <stddef.h>
51 
52 #include "game/Entity.h"
53 #include "graphics/data/Mesh.h"
54 #include "platform/Flags.h"
55 #include "math/MathFwd.h"
56 
57 // ARX_COLLISIONS flags (cylinder move)
58 enum CollisionFlag {
59 	CFLAG_LEVITATE          = (1<<0),
60 	CFLAG_NO_INTERCOL       = (1<<1),
61 	CFLAG_SPECIAL           = (1<<2),
62 	CFLAG_EASY_SLIDING      = (1<<3),
63 	CFLAG_CLIMBING          = (1<<4),
64 	CFLAG_JUST_TEST         = (1<<5),
65 	CFLAG_NPC               = (1<<6),
66 	CFLAG_PLAYER            = (1<<7),
67 	CFLAG_RETURN_HEIGHT     = (1<<8),
68 	CFLAG_EXTRA_PRECISION   = (1<<9),
69 	CFLAG_CHECK_VALID_POS   = (1<<10),
70 	CFLAG_ANCHOR_GENERATION = (1<<11),
71 	CFLAG_COLLIDE_NOCOL     = (1<<12),
72 	CFLAG_NO_NPC_COLLIDE    = (1<<13),
73 	CFLAG_NO_HEIGHT_MOD     = (1<<14)
74 };
75 DECLARE_FLAGS(CollisionFlag, CollisionFlags)
76 DECLARE_FLAGS_OPERATORS(CollisionFlags)
77 
78 const size_t MAX_IN_SPHERE = 20;
79 
80 extern size_t MAX_IN_SPHERE_Pos;
81 extern short EVERYTHING_IN_SPHERE[MAX_IN_SPHERE + 1];
82 extern size_t EXCEPTIONS_LIST_Pos;
83 extern short EXCEPTIONS_LIST[MAX_IN_SPHERE + 1];
84 extern bool DIRECT_PATH;
85 
86 bool ARX_COLLISION_Move_Cylinder(IO_PHYSICS * ip, Entity * io, float MOVE_CYLINDER_STEP, CollisionFlags flags = 0);
87 float CheckAnythingInCylinder(EERIE_CYLINDER * cyl, Entity * ioo, long flags = 0);
88 
89 enum CheckAnythingInSphereFlag {
90 	 CAS_NO_NPC_COL        = (1<<0),
91 	 CAS_NO_SAME_GROUP     = (1<<1),
92 	 CAS_NO_BACKGROUND_COL = (1<<2),
93 	 CAS_NO_ITEM_COL       = (1<<3),
94 	 CAS_NO_FIX_COL        = (1<<4),
95 	 CAS_NO_DEAD_COL       = (1<<5)
96 };
97 DECLARE_FLAGS(CheckAnythingInSphereFlag, CASFlags)
98 DECLARE_FLAGS_OPERATORS(CASFlags)
99 
100 //except source...
101 bool CheckAnythingInSphere(EERIE_SPHERE * sphere, long source, CASFlags flags = 0, long * num = NULL);
102 
103 //except source...
104 bool CheckEverythingInSphere(EERIE_SPHERE * sphere, long source, long targ = -1);
105 
106 //except source...
107 EERIEPOLY * CheckBackgroundInSphere(EERIE_SPHERE * sphere);
108 
109 bool IsCollidingIO(Entity * io, Entity * ioo);
110 
111 /*!
112  * @param ignoreNoCollisionFlag true if the IO_NO_COLLISIONS on the interactive object should be ignored
113  */
114 bool CheckIOInSphere(EERIE_SPHERE * sphere, long target, bool ignoreNoCollisionFlag = false);
115 
116 bool AttemptValidCylinderPos(EERIE_CYLINDER * cyl, Entity * io, CollisionFlags flags);
117 bool IO_Visible(Vec3f * orgn, Vec3f * dest, EERIEPOLY * epp, Vec3f * hit);
118 
119 void ANCHOR_BLOCK_By_IO(Entity * io, long status);
120 void ANCHOR_BLOCK_Clear();
121 float CylinderPlatformCollide(EERIE_CYLINDER * cyl, Entity * io);
122 bool IsAnyNPCInPlatform(Entity * pfrm);
123 void PushIO_ON_Top(Entity * ioo, float ydec);
124 
125 #endif // ARX_PHYSICS_COLLISIONS_H
126