Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/scene/2d/physics/joints/joint_2d.h
9912 views
1
/**************************************************************************/
2
/* joint_2d.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/2d/node_2d.h"
34
35
class PhysicsBody2D;
36
37
class Joint2D : public Node2D {
38
GDCLASS(Joint2D, Node2D);
39
40
RID joint;
41
RID ba, bb;
42
43
NodePath a;
44
NodePath b;
45
real_t bias = 0.0;
46
47
bool exclude_from_collision = true;
48
bool configured = false;
49
String warning;
50
51
protected:
52
void _disconnect_signals();
53
void _body_exit_tree();
54
void _update_joint(bool p_only_free = false);
55
56
void _notification(int p_what);
57
virtual void _configure_joint(RID p_joint, PhysicsBody2D *body_a, PhysicsBody2D *body_b) = 0;
58
59
static void _bind_methods();
60
61
_FORCE_INLINE_ bool is_configured() const { return configured; }
62
63
public:
64
virtual PackedStringArray get_configuration_warnings() const override;
65
66
void set_node_a(const NodePath &p_node_a);
67
NodePath get_node_a() const;
68
69
void set_node_b(const NodePath &p_node_b);
70
NodePath get_node_b() const;
71
72
void set_bias(real_t p_bias);
73
real_t get_bias() const;
74
75
void set_exclude_nodes_from_collision(bool p_enable);
76
bool get_exclude_nodes_from_collision() const;
77
78
RID get_rid() const { return joint; }
79
Joint2D();
80
~Joint2D();
81
};
82
83