Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
collision.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5#pragma once
6
8#include <vector>
9
10class Map;
11class IGameDef;
12class Environment;
13class ActiveObject;
14
20
28
30{
31 CollisionInfo() = default;
32
35 v3s16 node_p = v3s16(-32768,-32768,-32768); // COLLISION_NODE
36 ActiveObject *object = nullptr; // COLLISION_OBJECT
40};
41
43{
45
46 bool collides = false;
47 bool touching_ground = false;
48 bool standing_on_object = false;
49 std::vector<CollisionInfo> collisions;
50};
51
55
58 const aabb3f &box_0,
59 f32 stepheight, f32 dtime,
60 v3f *pos_f, v3f *speed_f,
61 v3f accel_f, ActiveObject *self=NULL,
62 bool collide_with_objects=true);
63
70 const aabb3f &box_0, const v3f &pos_f, ActiveObject *self = nullptr,
71 bool collide_with_objects = true);
72
73// Helper function:
74// Checks for collision of a moving aabbox with a static aabbox
75// Returns -1 if no collision, 0 if X collision, 1 if Y collision, 2 if Z collision
76// dtime receives time until first collision, invalid if -1 is returned
78 const aabb3f &staticbox, const aabb3f &movingbox,
79 v3f speed, f32 *dtime);
80
81// Helper function:
82// Checks if moving the movingbox up by the given distance would hit a ceiling.
84 const std::vector<aabb3f> &staticboxes,
85 const aabb3f &movingbox,
86 f32 y_increase, f32 d);
Definition activeobject.h:141
Definition environment.h:34
Definition gamedef.h:36
Definition map.h:101
CollisionAxis
Definition collision.h:22
@ COLLISION_AXIS_X
Definition collision.h:24
@ COLLISION_AXIS_Y
Definition collision.h:25
@ COLLISION_AXIS_Z
Definition collision.h:26
@ COLLISION_AXIS_NONE
Definition collision.h:23
bool g_collision_problems_encountered
Status if any problems were ever encountered during collision detection.
Definition collision.cpp:24
bool collision_check_intersection(Environment *env, IGameDef *gamedef, const aabb3f &box_0, const v3f &pos_f, ActiveObject *self=nullptr, bool collide_with_objects=true)
A simpler version of "collisionMoveSimple" that only checks whether a collision occurs at the given p...
Definition collision.cpp:587
collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef, const aabb3f &box_0, f32 stepheight, f32 dtime, v3f *pos_f, v3f *speed_f, v3f accel_f, ActiveObject *self=NULL, bool collide_with_objects=true)
Definition collision.cpp:325
bool wouldCollideWithCeiling(const std::vector< aabb3f > &staticboxes, const aabb3f &movingbox, f32 y_increase, f32 d)
CollisionAxis axisAlignedCollision(const aabb3f &staticbox, const aabb3f &movingbox, v3f speed, f32 *dtime)
Definition collision.cpp:81
CollisionType
Definition collision.h:16
@ COLLISION_OBJECT
Definition collision.h:18
@ COLLISION_NODE
Definition collision.h:17
core::aabbox3d< f32 > aabb3f
Definition irr_aabb3d.h:11
core::vector3d< s16 > v3s16
Definition irr_v3d.h:13
core::vector3df v3f
Definition irr_v3d.h:11
Definition collision.h:30
CollisionInfo()=default
CollisionAxis axis
Definition collision.h:34
CollisionType type
Definition collision.h:33
v3f old_speed
Definition collision.h:38
v3s16 node_p
Definition collision.h:35
v3f new_pos
Definition collision.h:37
v3f new_speed
Definition collision.h:39
Definition collision.h:43
std::vector< CollisionInfo > collisions
Definition collision.h:49
bool collides
Definition collision.h:46
collisionMoveResult()=default
bool touching_ground
Definition collision.h:47
bool standing_on_object
Definition collision.h:48