Luanti 5.10.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 int plane = -1;
41};
42
44{
46
47 bool touching_ground = false;
48 bool collides = false;
49 bool standing_on_object = false;
50 std::vector<CollisionInfo> collisions;
51};
52
56 f32 pos_max_d, const aabb3f &box_0,
57 f32 stepheight, f32 dtime,
58 v3f *pos_f, v3f *speed_f,
59 v3f accel_f, ActiveObject *self=NULL,
60 bool collide_with_objects=true);
61
68 const aabb3f &box_0, const v3f &pos_f, ActiveObject *self = nullptr,
69 bool collide_with_objects = true);
70
71// Helper function:
72// Checks for collision of a moving aabbox with a static aabbox
73// Returns -1 if no collision, 0 if X collision, 1 if Y collision, 2 if Z collision
74// dtime receives time until first collision, invalid if -1 is returned
76 const aabb3f &staticbox, const aabb3f &movingbox,
77 v3f speed, f32 *dtime);
78
79// Helper function:
80// Checks if moving the movingbox up by the given distance would hit a ceiling.
82 const std::vector<aabb3f> &staticboxes,
83 const aabb3f &movingbox,
84 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 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:603
bool wouldCollideWithCeiling(const std::vector< aabb3f > &staticboxes, const aabb3f &movingbox, f32 y_increase, f32 d)
collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef, f32 pos_max_d, 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)
Moves using a single iteration; speed should not exceed pos_max_d/dtime.
Definition collision.cpp:331
CollisionType
Definition collision.h:16
@ COLLISION_OBJECT
Definition collision.h:18
@ COLLISION_NODE
Definition collision.h:17
CollisionAxis axisAlignedCollision(const aabb3f &staticbox, const aabb3f &movingbox, v3f speed, f32 *dtime)
Definition collision.cpp:87
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
int plane
Definition collision.h:40
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:44
std::vector< CollisionInfo > collisions
Definition collision.h:50
bool collides
Definition collision.h:48
collisionMoveResult()=default
bool touching_ground
Definition collision.h:47
bool standing_on_object
Definition collision.h:49