Debian Codegraph @

scene/3d/physics/ray_cast_3d.h

raw symbols SCIP
1 /**************************************************************************/
2 /* ray_cast_3d.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #include "scene/3d/node_3d.h"
34
35 class CollisionObject3D;
36
37 class RayCast3D : public Node3D {
38 GDCLASS(RayCast3D, Node3D);
39
40 bool enabled = true;
41 bool collided = false;
42 ObjectID against;
43 RID against_rid;
44 int against_shape = 0;
45 Vector3 collision_point;
46 Vector3 collision_normal;
47 int collision_face_index = -1;
48
49 Vector3 target_position = Vector3(0, -1, 0);
50 HashSet<RID> exclude;
51
52 uint32_t collision_mask = 1;
53 bool exclude_parent_body = true;
54
55 Ref<Material> debug_material;
56 Color debug_shape_custom_color = Color(0.0, 0.0, 0.0);
57 int debug_shape_thickness = 2;
58 Vector<Vector3> debug_shape_vertices;
59 Vector<Vector3> debug_line_vertices;
60
61 void _create_debug_shape();
62 void _update_debug_shape();
63 void _update_debug_shape_material(bool p_check_collision = false);
64 void _update_debug_shape_vertices();
65 void _clear_debug_shape();
66
67 bool collide_with_areas = false;
68 bool collide_with_bodies = true;
69
70 bool hit_from_inside = false;
71 bool hit_back_faces = true;
72
73 RID debug_instance;
74 Ref<ArrayMesh> debug_mesh;
75
76 protected:
77 void _notification(int p_what);
78 void _update_raycast_state();
79 static void _bind_methods();
80
81 public:
82 void set_collide_with_areas(bool p_enabled);
83 bool is_collide_with_areas_enabled() const;
84
85 void set_collide_with_bodies(bool p_enabled);
86 bool is_collide_with_bodies_enabled() const;
87
88 void set_hit_from_inside(bool p_enabled);
89 bool is_hit_from_inside_enabled() const;
90
91 void set_hit_back_faces(bool p_enabled);
92 bool is_hit_back_faces_enabled() const;
93
94 void set_enabled(bool p_enabled);
95 bool is_enabled() const;
96
97 void set_target_position(const Vector3 &p_point);
98 Vector3 get_target_position() const;
99
100 void set_collision_mask(uint32_t p_mask);
101 uint32_t get_collision_mask() const;
102
103 void set_collision_mask_value(int p_layer_number, bool p_value);
104 bool get_collision_mask_value(int p_layer_number) const;
105
106 void set_exclude_parent_body(bool p_exclude_parent_body);
107 bool get_exclude_parent_body() const;
108
109 const Color &get_debug_shape_custom_color() const;
110 void set_debug_shape_custom_color(const Color &p_color);
111
112 const Vector<Vector3> &get_debug_shape_vertices() const;
113 const Vector<Vector3> &get_debug_line_vertices() const;
114
115 Ref<StandardMaterial3D> get_debug_material();
116
117 int get_debug_shape_thickness() const;
118 void set_debug_shape_thickness(const int p_debug_thickness);
119
120 void force_raycast_update();
121 bool is_colliding() const;
122 Object *get_collider() const;
123 RID get_collider_rid() const;
124 int get_collider_shape() const;
125 Vector3 get_collision_point() const;
126 Vector3 get_collision_normal() const;
127 int get_collision_face_index() const;
128
129 void add_exception_rid(const RID &p_rid);
130 void add_exception(RequiredParam<const CollisionObject3D> rp_node);
131 void remove_exception_rid(const RID &p_rid);
132 void remove_exception(RequiredParam<const CollisionObject3D> rp_node);
133 void clear_exceptions();
134
135 RayCast3D();
136 };