3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "irrlichttypes_bloated.h"
38 COLLISION_AXIS_NONE = -1,
46 CollisionInfo() = default;
48 CollisionType type = COLLISION_NODE;
49 CollisionAxis axis = COLLISION_AXIS_NONE;
50 v3s16 node_p = v3s16(-32768,-32768,-32768); // COLLISION_NODE
56 struct collisionMoveResult
58 collisionMoveResult() = default;
60 bool touching_ground = false;
61 bool collides = false;
62 bool standing_on_object = false;
63 std::vector<CollisionInfo> collisions;
66 // Moves using a single iteration; speed should not exceed pos_max_d/dtime
67 collisionMoveResult collisionMoveSimple(Environment *env,IGameDef *gamedef,
68 f32 pos_max_d, const aabb3f &box_0,
69 f32 stepheight, f32 dtime,
70 v3f *pos_f, v3f *speed_f,
71 v3f accel_f, ActiveObject *self=NULL,
72 bool collideWithObjects=true);
75 // Checks for collision of a moving aabbox with a static aabbox
76 // Returns -1 if no collision, 0 if X collision, 1 if Y collision, 2 if Z collision
77 // dtime receives time until first collision, invalid if -1 is returned
78 CollisionAxis axisAlignedCollision(
79 const aabb3f &staticbox, const aabb3f &movingbox,
80 const v3f &speed, f32 d, f32 *dtime);
83 // Checks if moving the movingbox up by the given distance would hit a ceiling.
84 bool wouldCollideWithCeiling(
85 const std::vector<aabb3f> &staticboxes,
86 const aabb3f &movingbox,
87 f32 y_increase, f32 d);