feat: modules moved and engine moved to submodule

This commit is contained in:
Jan van der Weide 2025-04-12 18:40:44 +02:00
parent dfb5e645cd
commit c33d2130cc
5136 changed files with 225275 additions and 64485 deletions

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_LISTENER_3D_GIZMO_PLUGIN_H
#define AUDIO_LISTENER_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -45,5 +44,3 @@ public:
AudioListener3DGizmoPlugin();
};
#endif // AUDIO_LISTENER_3D_GIZMO_PLUGIN_H

View file

@ -158,26 +158,50 @@ void AudioStreamPlayer3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
// or a soft distance cap with the Unit Size property (sound never reaches true zero).
// When Max Distance is 0.0, `r` represents the distance above which the
// sound can't be heard in *most* (but not all) scenarios.
float r;
float radius = player->get_unit_size() * soft_multiplier;
if (player->get_max_distance() > CMP_EPSILON) {
r = MIN(player->get_unit_size() * soft_multiplier, player->get_max_distance());
} else {
r = player->get_unit_size() * soft_multiplier;
radius = MIN(radius, player->get_max_distance());
}
#define PUSH_QUARTER_XY(m_from_x, m_from_y, m_to_x, m_to_y, m_y) \
points_ptrw[index++] = Vector3(m_from_x, -m_from_y - m_y, 0); \
points_ptrw[index++] = Vector3(m_to_x, -m_to_y - m_y, 0); \
points_ptrw[index++] = Vector3(m_from_x, m_from_y + m_y, 0); \
points_ptrw[index++] = Vector3(m_to_x, m_to_y + m_y, 0); \
points_ptrw[index++] = Vector3(-m_from_x, -m_from_y - m_y, 0); \
points_ptrw[index++] = Vector3(-m_to_x, -m_to_y - m_y, 0); \
points_ptrw[index++] = Vector3(-m_from_x, m_from_y + m_y, 0); \
points_ptrw[index++] = Vector3(-m_to_x, m_to_y + m_y, 0);
// Number of points in an octant. So there will be 8 * points_in_octant points in total.
// This corresponds to the smoothness of the circle.
const uint32_t points_in_octant = 15;
const real_t octant_angle = Math::PI / 4;
const real_t inc = (Math::PI / (4 * points_in_octant));
const real_t radius_squared = radius * radius;
real_t r = 0;
Vector<Vector3> points_billboard;
points_billboard.resize(8 * points_in_octant * 2);
Vector3 *points_ptrw = points_billboard.ptrw();
for (int i = 0; i < 120; i++) {
// Create a circle.
const float ra = Math::deg_to_rad((float)(i * 3));
const float rb = Math::deg_to_rad((float)((i + 1) * 3));
const Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * r;
const Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * r;
uint32_t index = 0;
float previous_x = radius;
float previous_y = 0.f;
// Draw a billboarded circle.
points_billboard.push_back(Vector3(a.x, a.y, 0));
points_billboard.push_back(Vector3(b.x, b.y, 0));
for (uint32_t i = 0; i < points_in_octant; i++) {
r += inc;
real_t x = Math::cos((i == points_in_octant - 1) ? octant_angle : r) * radius;
real_t y = Math::sqrt(radius_squared - (x * x));
PUSH_QUARTER_XY(previous_x, previous_y, x, y, 0);
PUSH_QUARTER_XY(previous_y, previous_x, y, x, 0);
previous_x = x;
previous_y = y;
}
#undef PUSH_QUARTER_XY
Color color;
switch (player->get_attenuation_model()) {
// Pick cold colors for all attenuation models (except Disabled),
@ -210,44 +234,76 @@ void AudioStreamPlayer3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
}
if (player->is_emission_angle_enabled()) {
const float pc = player->get_emission_angle();
const float ofs = -Math::cos(Math::deg_to_rad(pc));
const float radius = Math::sin(Math::deg_to_rad(pc));
const float ha = Math::deg_to_rad(player->get_emission_angle());
const float ofs = -Math::cos(ha);
const float radius = Math::sin(ha);
const uint32_t points_in_octant = 7;
const real_t octant_angle = Math::PI / 4;
const real_t inc = (Math::PI / (4 * points_in_octant));
const real_t radius_squared = radius * radius;
real_t r = 0;
Vector<Vector3> points_primary;
points_primary.resize(200);
points_primary.resize(8 * points_in_octant * 2);
Vector3 *points_ptrw = points_primary.ptrw();
real_t step = Math_TAU / 100.0;
for (int i = 0; i < 100; i++) {
const float a = i * step;
const float an = (i + 1) * step;
uint32_t index = 0;
float previous_x = radius;
float previous_y = 0.f;
#define PUSH_QUARTER(m_from_x, m_from_y, m_to_x, m_to_y, m_y) \
points_ptrw[index++] = Vector3(m_from_x, -m_from_y, m_y); \
points_ptrw[index++] = Vector3(m_to_x, -m_to_y, m_y); \
points_ptrw[index++] = Vector3(m_from_x, m_from_y, m_y); \
points_ptrw[index++] = Vector3(m_to_x, m_to_y, m_y); \
points_ptrw[index++] = Vector3(-m_from_x, -m_from_y, m_y); \
points_ptrw[index++] = Vector3(-m_to_x, -m_to_y, m_y); \
points_ptrw[index++] = Vector3(-m_from_x, m_from_y, m_y); \
points_ptrw[index++] = Vector3(-m_to_x, m_to_y, m_y);
const Vector3 from(Math::sin(a) * radius, Math::cos(a) * radius, ofs);
const Vector3 to(Math::sin(an) * radius, Math::cos(an) * radius, ofs);
for (uint32_t i = 0; i < points_in_octant; i++) {
r += inc;
real_t x = Math::cos((i == points_in_octant - 1) ? octant_angle : r) * radius;
real_t y = Math::sqrt(radius_squared - (x * x));
points_primary.write[i * 2 + 0] = from;
points_primary.write[i * 2 + 1] = to;
PUSH_QUARTER(previous_x, previous_y, x, y, ofs);
PUSH_QUARTER(previous_y, previous_x, y, x, ofs);
previous_x = x;
previous_y = y;
}
#undef PUSH_QUARTER
const Ref<Material> material_primary = get_material("stream_player_3d_material_primary", p_gizmo);
p_gizmo->add_lines(points_primary, material_primary);
Vector<Vector3> points_secondary;
points_secondary.resize(16);
for (int i = 0; i < 8; i++) {
const float a = i * (Math_TAU / 8.0);
const Vector3 from(Math::sin(a) * radius, Math::cos(a) * radius, ofs);
points_secondary.write[i * 2 + 0] = from;
points_secondary.write[i * 2 + 1] = Vector3();
}
Vector3 *points_second_ptrw = points_secondary.ptrw();
uint32_t index2 = 0;
// Lines to the circle.
points_second_ptrw[index2++] = Vector3();
points_second_ptrw[index2++] = Vector3(radius, 0, ofs);
points_second_ptrw[index2++] = Vector3();
points_second_ptrw[index2++] = Vector3(-radius, 0, ofs);
points_second_ptrw[index2++] = Vector3();
points_second_ptrw[index2++] = Vector3(0, radius, ofs);
points_second_ptrw[index2++] = Vector3();
points_second_ptrw[index2++] = Vector3(0, -radius, ofs);
real_t octant_value = Math::cos(octant_angle) * radius;
points_second_ptrw[index2++] = Vector3();
points_second_ptrw[index2++] = Vector3(octant_value, octant_value, ofs);
points_second_ptrw[index2++] = Vector3();
points_second_ptrw[index2++] = Vector3(-octant_value, octant_value, ofs);
points_second_ptrw[index2++] = Vector3();
points_second_ptrw[index2++] = Vector3(-octant_value, -octant_value, ofs);
points_second_ptrw[index2++] = Vector3();
points_second_ptrw[index2++] = Vector3(octant_value, -octant_value, ofs);
const Ref<Material> material_secondary = get_material("stream_player_3d_material_secondary", p_gizmo);
p_gizmo->add_lines(points_secondary, material_secondary);
Vector<Vector3> handles;
const float ha = Math::deg_to_rad(player->get_emission_angle());
handles.push_back(Vector3(Math::sin(ha), 0, -Math::cos(ha)));
p_gizmo->add_handles(handles, get_material("handles"));
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef AUDIO_STREAM_PLAYER_3D_GIZMO_PLUGIN_H
#define AUDIO_STREAM_PLAYER_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -49,5 +48,3 @@ public:
AudioStreamPlayer3DGizmoPlugin();
};
#endif // AUDIO_STREAM_PLAYER_3D_GIZMO_PLUGIN_H

View file

@ -180,7 +180,13 @@ void Camera3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
const float hsize = Math::sin(Math::deg_to_rad(fov));
const float depth = -Math::cos(Math::deg_to_rad(fov));
Vector3 side = Vector3(hsize * size_factor.x, 0, depth);
Vector3 side;
if (camera->get_keep_aspect_mode() == Camera3D::KEEP_WIDTH) {
side = Vector3(hsize * size_factor.x, 0, depth * size_factor.x);
} else {
side = Vector3(hsize * size_factor.x, 0, depth * size_factor.y);
}
Vector3 nside = Vector3(-side.x, side.y, side.z);
Vector3 up = Vector3(0, hsize * size_factor.y, 0);
@ -204,7 +210,6 @@ void Camera3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
Vector3 right, up;
Vector3 back(0, 0, -1.0);
Vector3 front(0, 0, 0);
if (aspect == Camera3D::KeepAspect::KEEP_WIDTH) {
right = Vector3(keep_size, 0, 0);
@ -266,8 +271,8 @@ float Camera3DGizmoPlugin::_find_closest_angle_to_half_pi_arc(const Vector3 &p_f
Vector3 min_p;
for (int i = 0; i < arc_test_points; i++) {
float a = i * Math_PI * 0.5 / arc_test_points;
float an = (i + 1) * Math_PI * 0.5 / arc_test_points;
float a = i * Math::PI * 0.5 / arc_test_points;
float an = (i + 1) * Math::PI * 0.5 / arc_test_points;
Vector3 p = Vector3(Math::cos(a), 0, -Math::sin(a)) * p_arc_radius;
Vector3 n = Vector3(Math::cos(an), 0, -Math::sin(an)) * p_arc_radius;
@ -282,6 +287,6 @@ float Camera3DGizmoPlugin::_find_closest_angle_to_half_pi_arc(const Vector3 &p_f
}
//min_p = p_arc_xform.affine_inverse().xform(min_p);
float a = (Math_PI * 0.5) - Vector2(min_p.x, -min_p.z).angle();
float a = (Math::PI * 0.5) - Vector2(min_p.x, -min_p.z).angle();
return Math::rad_to_deg(a);
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef CAMERA_3D_GIZMO_PLUGIN_H
#define CAMERA_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -52,5 +51,3 @@ public:
Camera3DGizmoPlugin();
};
#endif // CAMERA_3D_GIZMO_PLUGIN_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef COLLISION_OBJECT_3D_GIZMO_PLUGIN_H
#define COLLISION_OBJECT_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -44,5 +43,3 @@ public:
CollisionObject3DGizmoPlugin();
};
#endif // COLLISION_OBJECT_3D_GIZMO_PLUGIN_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef COLLISION_POLYGON_3D_GIZMO_PLUGIN_H
#define COLLISION_POLYGON_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -45,5 +44,3 @@ public:
void redraw(EditorNode3DGizmo *p_gizmo) override;
CollisionPolygon3DGizmoPlugin();
};
#endif // COLLISION_POLYGON_3D_GIZMO_PLUGIN_H

View file

@ -58,9 +58,6 @@ CollisionShape3DGizmoPlugin::CollisionShape3DGizmoPlugin() {
create_handle_material("handles");
}
CollisionShape3DGizmoPlugin::~CollisionShape3DGizmoPlugin() {
}
void CollisionShape3DGizmoPlugin::create_collision_material(const String &p_name, float p_alpha) {
Vector<Ref<StandardMaterial3D>> mats;
@ -118,7 +115,7 @@ String CollisionShape3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_g
}
if (Object::cast_to<CapsuleShape3D>(*s)) {
return p_id == 0 ? "Radius" : "Height";
return helper->capsule_get_handle_name(p_id);
}
if (Object::cast_to<CylinderShape3D>(*s)) {
@ -157,7 +154,7 @@ Variant CollisionShape3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p
if (Object::cast_to<CylinderShape3D>(*s)) {
Ref<CylinderShape3D> cs2 = s;
return p_id == 0 ? cs2->get_radius() : cs2->get_height();
return Vector2(cs2->get_radius(), cs2->get_height());
}
if (Object::cast_to<SeparationRayShape3D>(*s)) {
@ -225,26 +222,15 @@ void CollisionShape3DGizmoPlugin::set_handle(const EditorNode3DGizmo *p_gizmo, i
}
if (Object::cast_to<CapsuleShape3D>(*s)) {
Vector3 axis;
axis[p_id == 0 ? 0 : 1] = 1.0;
Ref<CapsuleShape3D> cs2 = s;
Vector3 ra, rb;
Geometry3D::get_closest_points_between_segments(Vector3(), axis * 4096, sg[0], sg[1], ra, rb);
float d = axis.dot(ra);
if (Node3DEditor::get_singleton()->is_snap_enabled()) {
d = Math::snapped(d, Node3DEditor::get_singleton()->get_translate_snap());
}
if (d < 0.001) {
d = 0.001;
}
if (p_id == 0) {
cs2->set_radius(d);
} else if (p_id == 1) {
cs2->set_height(d * 2.0);
}
real_t height = cs2->get_height();
real_t radius = cs2->get_radius();
Vector3 position;
helper->capsule_set_handle(sg, p_id, height, radius, position);
cs2->set_height(height);
cs2->set_radius(radius);
cs->set_global_position(position);
}
if (Object::cast_to<CylinderShape3D>(*s)) {
@ -288,26 +274,7 @@ void CollisionShape3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo
if (Object::cast_to<CapsuleShape3D>(*s)) {
Ref<CapsuleShape3D> ss = s;
Vector2 values = p_restore;
if (p_cancel) {
ss->set_radius(values[0]);
ss->set_height(values[1]);
return;
}
EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton();
if (p_id == 0) {
ur->create_action(TTR("Change Capsule Shape Radius"));
ur->add_do_method(ss.ptr(), "set_radius", ss->get_radius());
} else {
ur->create_action(TTR("Change Capsule Shape Height"));
ur->add_do_method(ss.ptr(), "set_height", ss->get_height());
}
ur->add_undo_method(ss.ptr(), "set_radius", values[0]);
ur->add_undo_method(ss.ptr(), "set_height", values[1]);
ur->commit_action();
helper->cylinder_commit_handle(p_id, TTR("Change Capsule Shape Radius"), TTR("Change Capsule Shape Height"), p_cancel, cs, *ss, *ss);
}
if (Object::cast_to<CylinderShape3D>(*s)) {
@ -357,42 +324,77 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
if (Object::cast_to<SphereShape3D>(*s)) {
Ref<SphereShape3D> sp = s;
float r = sp->get_radius();
float radius = sp->get_radius();
#define PUSH_QUARTER(from_x, from_y, to_x, to_y, y) \
points_ptrw[index++] = Vector3(from_x, y, from_y); \
points_ptrw[index++] = Vector3(to_x, y, to_y); \
points_ptrw[index++] = Vector3(from_x, y, -from_y); \
points_ptrw[index++] = Vector3(to_x, y, -to_y); \
points_ptrw[index++] = Vector3(-from_x, y, from_y); \
points_ptrw[index++] = Vector3(-to_x, y, to_y); \
points_ptrw[index++] = Vector3(-from_x, y, -from_y); \
points_ptrw[index++] = Vector3(-to_x, y, -to_y);
#define PUSH_QUARTER_XY(from_x, from_y, to_x, to_y, y) \
points_ptrw[index++] = Vector3(from_x, -from_y - y, 0); \
points_ptrw[index++] = Vector3(to_x, -to_y - y, 0); \
points_ptrw[index++] = Vector3(from_x, from_y + y, 0); \
points_ptrw[index++] = Vector3(to_x, to_y + y, 0); \
points_ptrw[index++] = Vector3(-from_x, -from_y - y, 0); \
points_ptrw[index++] = Vector3(-to_x, -to_y - y, 0); \
points_ptrw[index++] = Vector3(-from_x, from_y + y, 0); \
points_ptrw[index++] = Vector3(-to_x, to_y + y, 0);
#define PUSH_QUARTER_YZ(from_x, from_y, to_x, to_y, y) \
points_ptrw[index++] = Vector3(0, -from_y - y, from_x); \
points_ptrw[index++] = Vector3(0, -to_y - y, to_x); \
points_ptrw[index++] = Vector3(0, from_y + y, from_x); \
points_ptrw[index++] = Vector3(0, to_y + y, to_x); \
points_ptrw[index++] = Vector3(0, -from_y - y, -from_x); \
points_ptrw[index++] = Vector3(0, -to_y - y, -to_x); \
points_ptrw[index++] = Vector3(0, from_y + y, -from_x); \
points_ptrw[index++] = Vector3(0, to_y + y, -to_x);
// Number of points in an octant. So there will be 8 * points_in_octant * 2 points in total for one circle.
// This Corresponds to the smoothness of the circle.
const uint32_t points_in_octant = 16;
const real_t inc = (Math::PI / (4 * points_in_octant));
const real_t radius_squared = radius * radius;
real_t r = 0;
Vector<Vector3> points;
uint32_t index = 0;
// 3 full circles.
points.resize(3 * 8 * points_in_octant * 2);
Vector3 *points_ptrw = points.ptrw();
for (int i = 0; i <= 360; i++) {
float ra = Math::deg_to_rad((float)i);
float rb = Math::deg_to_rad((float)i + 1);
Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * r;
Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * r;
float previous_x = radius;
float previous_y = 0.f;
points.push_back(Vector3(a.x, 0, a.y));
points.push_back(Vector3(b.x, 0, b.y));
points.push_back(Vector3(0, a.x, a.y));
points.push_back(Vector3(0, b.x, b.y));
points.push_back(Vector3(a.x, a.y, 0));
points.push_back(Vector3(b.x, b.y, 0));
}
Vector<Vector3> collision_segments;
for (int i = 0; i < 64; i++) {
float ra = i * (Math_TAU / 64.0);
float rb = (i + 1) * (Math_TAU / 64.0);
Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * r;
Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * r;
collision_segments.push_back(Vector3(a.x, 0, a.y));
collision_segments.push_back(Vector3(b.x, 0, b.y));
collision_segments.push_back(Vector3(0, a.x, a.y));
collision_segments.push_back(Vector3(0, b.x, b.y));
collision_segments.push_back(Vector3(a.x, a.y, 0));
collision_segments.push_back(Vector3(b.x, b.y, 0));
for (uint32_t i = 0; i < points_in_octant; ++i) {
r += inc;
real_t x = Math::cos(r) * radius;
real_t y = Math::sqrt(radius_squared - (x * x));
PUSH_QUARTER(previous_x, previous_y, x, y, 0);
PUSH_QUARTER(previous_y, previous_x, y, x, 0);
PUSH_QUARTER_XY(previous_x, previous_y, x, y, 0);
PUSH_QUARTER_XY(previous_y, previous_x, y, x, 0);
PUSH_QUARTER_YZ(previous_x, previous_y, x, y, 0);
PUSH_QUARTER_YZ(previous_y, previous_x, y, x, 0)
previous_x = x;
previous_y = y;
}
#undef PUSH_QUARTER
#undef PUSH_QUARTER_XY
#undef PUSH_QUARTER_YZ
p_gizmo->add_lines(points, material, false, collision_color);
p_gizmo->add_collision_segments(collision_segments);
p_gizmo->add_collision_segments(points);
Vector<Vector3> handles;
handles.push_back(Vector3(r, 0, 0));
p_gizmo->add_handles(handles, handles_material);
@ -424,69 +426,98 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
float radius = cs2->get_radius();
float height = cs2->get_height();
// Number of points in an octant. So there will be 8 * points_in_octant points in total.
// This corresponds to the smoothness of the circle.
const uint32_t points_in_octant = 16;
const real_t octant_angle = Math::PI / 4;
const real_t inc = (Math::PI / (4 * points_in_octant));
const real_t radius_squared = radius * radius;
real_t r = 0;
Vector<Vector3> points;
// 4 vertical lines and 4 full circles.
points.resize(4 * 2 + 4 * 8 * points_in_octant * 2);
Vector3 *points_ptrw = points.ptrw();
Vector3 d(0, height * 0.5 - radius, 0);
for (int i = 0; i < 360; i++) {
float ra = Math::deg_to_rad((float)i);
float rb = Math::deg_to_rad((float)i + 1);
Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * radius;
Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * radius;
uint32_t index = 0;
float y_value = height * 0.5 - radius;
points.push_back(Vector3(a.x, 0, a.y) + d);
points.push_back(Vector3(b.x, 0, b.y) + d);
// Vertical Lines.
points_ptrw[index++] = Vector3(0.f, y_value, radius);
points_ptrw[index++] = Vector3(0.f, -y_value, radius);
points_ptrw[index++] = Vector3(0.f, y_value, -radius);
points_ptrw[index++] = Vector3(0.f, -y_value, -radius);
points_ptrw[index++] = Vector3(radius, y_value, 0.f);
points_ptrw[index++] = Vector3(radius, -y_value, 0.f);
points_ptrw[index++] = Vector3(-radius, y_value, 0.f);
points_ptrw[index++] = Vector3(-radius, -y_value, 0.f);
points.push_back(Vector3(a.x, 0, a.y) - d);
points.push_back(Vector3(b.x, 0, b.y) - d);
#define PUSH_QUARTER(from_x, from_y, to_x, to_y, y) \
points_ptrw[index++] = Vector3(from_x, y, from_y); \
points_ptrw[index++] = Vector3(to_x, y, to_y); \
points_ptrw[index++] = Vector3(from_x, y, -from_y); \
points_ptrw[index++] = Vector3(to_x, y, -to_y); \
points_ptrw[index++] = Vector3(-from_x, y, from_y); \
points_ptrw[index++] = Vector3(-to_x, y, to_y); \
points_ptrw[index++] = Vector3(-from_x, y, -from_y); \
points_ptrw[index++] = Vector3(-to_x, y, -to_y);
if (i % 90 == 0) {
points.push_back(Vector3(a.x, 0, a.y) + d);
points.push_back(Vector3(a.x, 0, a.y) - d);
}
#define PUSH_QUARTER_XY(from_x, from_y, to_x, to_y, y) \
points_ptrw[index++] = Vector3(from_x, -from_y - y, 0); \
points_ptrw[index++] = Vector3(to_x, -to_y - y, 0); \
points_ptrw[index++] = Vector3(from_x, from_y + y, 0); \
points_ptrw[index++] = Vector3(to_x, to_y + y, 0); \
points_ptrw[index++] = Vector3(-from_x, -from_y - y, 0); \
points_ptrw[index++] = Vector3(-to_x, -to_y - y, 0); \
points_ptrw[index++] = Vector3(-from_x, from_y + y, 0); \
points_ptrw[index++] = Vector3(-to_x, to_y + y, 0);
Vector3 dud = i < 180 ? d : -d;
#define PUSH_QUARTER_YZ(from_x, from_y, to_x, to_y, y) \
points_ptrw[index++] = Vector3(0, -from_y - y, from_x); \
points_ptrw[index++] = Vector3(0, -to_y - y, to_x); \
points_ptrw[index++] = Vector3(0, from_y + y, from_x); \
points_ptrw[index++] = Vector3(0, to_y + y, to_x); \
points_ptrw[index++] = Vector3(0, -from_y - y, -from_x); \
points_ptrw[index++] = Vector3(0, -to_y - y, -to_x); \
points_ptrw[index++] = Vector3(0, from_y + y, -from_x); \
points_ptrw[index++] = Vector3(0, to_y + y, -to_x);
points.push_back(Vector3(0, a.x, a.y) + dud);
points.push_back(Vector3(0, b.x, b.y) + dud);
points.push_back(Vector3(a.y, a.x, 0) + dud);
points.push_back(Vector3(b.y, b.x, 0) + dud);
float previous_x = radius;
float previous_y = 0.f;
for (uint32_t i = 0; i < points_in_octant; ++i) {
r += inc;
real_t x = Math::cos((i == points_in_octant - 1) ? octant_angle : r) * radius;
real_t y = Math::sqrt(radius_squared - (x * x));
// High circle ring.
PUSH_QUARTER(previous_x, previous_y, x, y, y_value);
PUSH_QUARTER(previous_y, previous_x, y, x, y_value);
// Low circle ring.
PUSH_QUARTER(previous_x, previous_y, x, y, -y_value);
PUSH_QUARTER(previous_y, previous_x, y, x, -y_value);
// Up and Low circle in X-Y plane.
PUSH_QUARTER_XY(previous_x, previous_y, x, y, y_value);
PUSH_QUARTER_XY(previous_y, previous_x, y, x, y_value);
// Up and Low circle in Y-Z plane.
PUSH_QUARTER_YZ(previous_x, previous_y, x, y, y_value);
PUSH_QUARTER_YZ(previous_y, previous_x, y, x, y_value)
previous_x = x;
previous_y = y;
}
#undef PUSH_QUARTER
#undef PUSH_QUARTER_XY
#undef PUSH_QUARTER_YZ
p_gizmo->add_lines(points, material, false, collision_color);
p_gizmo->add_collision_segments(points);
Vector<Vector3> collision_segments;
for (int i = 0; i < 64; i++) {
float ra = i * (Math_TAU / 64.0);
float rb = (i + 1) * (Math_TAU / 64.0);
Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * radius;
Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * radius;
collision_segments.push_back(Vector3(a.x, 0, a.y) + d);
collision_segments.push_back(Vector3(b.x, 0, b.y) + d);
collision_segments.push_back(Vector3(a.x, 0, a.y) - d);
collision_segments.push_back(Vector3(b.x, 0, b.y) - d);
if (i % 16 == 0) {
collision_segments.push_back(Vector3(a.x, 0, a.y) + d);
collision_segments.push_back(Vector3(a.x, 0, a.y) - d);
}
Vector3 dud = i < 32 ? d : -d;
collision_segments.push_back(Vector3(0, a.x, a.y) + dud);
collision_segments.push_back(Vector3(0, b.x, b.y) + dud);
collision_segments.push_back(Vector3(a.y, a.x, 0) + dud);
collision_segments.push_back(Vector3(b.y, b.x, 0) + dud);
}
p_gizmo->add_collision_segments(collision_segments);
Vector<Vector3> handles = {
Vector3(cs2->get_radius(), 0, 0),
Vector3(0, cs2->get_height() * 0.5, 0)
};
Vector<Vector3> handles = helper->capsule_get_handles(cs2->get_height(), cs2->get_radius());
p_gizmo->add_handles(handles, handles_material);
}
@ -495,50 +526,63 @@ void CollisionShape3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
float radius = cs2->get_radius();
float height = cs2->get_height();
#define PUSH_QUARTER(from_x, from_y, to_x, to_y, y) \
points_ptrw[index++] = Vector3(from_x, y, from_y); \
points_ptrw[index++] = Vector3(to_x, y, to_y); \
points_ptrw[index++] = Vector3(from_x, y, -from_y); \
points_ptrw[index++] = Vector3(to_x, y, -to_y); \
points_ptrw[index++] = Vector3(-from_x, y, from_y); \
points_ptrw[index++] = Vector3(-to_x, y, to_y); \
points_ptrw[index++] = Vector3(-from_x, y, -from_y); \
points_ptrw[index++] = Vector3(-to_x, y, -to_y);
// Number of points in an octant. So there will be 8 * points_in_octant * 2 points in total for one circle.
// This corresponds to the smoothness of the circle.
const uint32_t points_in_octant = 16;
const real_t inc = (Math::PI / (4 * points_in_octant));
const real_t radius_squared = radius * radius;
real_t r = 0;
Vector<Vector3> points;
uint32_t index = 0;
// 4 vertical lines and 2 full circles.
points.resize(4 * 2 + 2 * 8 * points_in_octant * 2);
Vector3 *points_ptrw = points.ptrw();
float y_value = height * 0.5;
Vector3 d(0, height * 0.5, 0);
for (int i = 0; i < 360; i++) {
float ra = Math::deg_to_rad((float)i);
float rb = Math::deg_to_rad((float)i + 1);
Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * radius;
Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * radius;
// Vertical lines.
points_ptrw[index++] = Vector3(0.f, y_value, radius);
points_ptrw[index++] = Vector3(0.f, -y_value, radius);
points_ptrw[index++] = Vector3(0.f, y_value, -radius);
points_ptrw[index++] = Vector3(0.f, -y_value, -radius);
points_ptrw[index++] = Vector3(radius, y_value, 0.f);
points_ptrw[index++] = Vector3(radius, -y_value, 0.f);
points_ptrw[index++] = Vector3(-radius, y_value, 0.f);
points_ptrw[index++] = Vector3(-radius, -y_value, 0.f);
points.push_back(Vector3(a.x, 0, a.y) + d);
points.push_back(Vector3(b.x, 0, b.y) + d);
float previous_x = radius;
float previous_y = 0.f;
points.push_back(Vector3(a.x, 0, a.y) - d);
points.push_back(Vector3(b.x, 0, b.y) - d);
for (uint32_t i = 0; i < points_in_octant; ++i) {
r += inc;
real_t x = Math::cos(r) * radius;
real_t y = Math::sqrt(radius_squared - (x * x));
if (i % 90 == 0) {
points.push_back(Vector3(a.x, 0, a.y) + d);
points.push_back(Vector3(a.x, 0, a.y) - d);
}
// High circle ring.
PUSH_QUARTER(previous_x, previous_y, x, y, y_value);
PUSH_QUARTER(previous_y, previous_x, y, x, y_value);
// Low circle ring.
PUSH_QUARTER(previous_x, previous_y, x, y, -y_value);
PUSH_QUARTER(previous_y, previous_x, y, x, -y_value);
previous_x = x;
previous_y = y;
}
#undef PUSH_QUARTER
p_gizmo->add_lines(points, material, false, collision_color);
Vector<Vector3> collision_segments;
for (int i = 0; i < 64; i++) {
float ra = i * (Math_TAU / 64.0);
float rb = (i + 1) * (Math_TAU / 64.0);
Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * radius;
Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * radius;
collision_segments.push_back(Vector3(a.x, 0, a.y) + d);
collision_segments.push_back(Vector3(b.x, 0, b.y) + d);
collision_segments.push_back(Vector3(a.x, 0, a.y) - d);
collision_segments.push_back(Vector3(b.x, 0, b.y) - d);
if (i % 16 == 0) {
collision_segments.push_back(Vector3(a.x, 0, a.y) + d);
collision_segments.push_back(Vector3(a.x, 0, a.y) - d);
}
}
p_gizmo->add_collision_segments(collision_segments);
p_gizmo->add_collision_segments(points);
Vector<Vector3> handles = helper->cylinder_get_handles(cs2->get_height(), cs2->get_radius());
p_gizmo->add_handles(handles, handles_material);

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef COLLISION_SHAPE_3D_GIZMO_PLUGIN_H
#define COLLISION_SHAPE_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -55,7 +54,4 @@ public:
void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false) override;
CollisionShape3DGizmoPlugin();
~CollisionShape3DGizmoPlugin();
};
#endif // COLLISION_SHAPE_3D_GIZMO_PLUGIN_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef CPU_PARTICLES_3D_GIZMO_PLUGIN_H
#define CPU_PARTICLES_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -44,5 +43,3 @@ public:
void redraw(EditorNode3DGizmo *p_gizmo) override;
CPUParticles3DGizmoPlugin();
};
#endif // CPU_PARTICLES_3D_GIZMO_PLUGIN_H

View file

@ -47,9 +47,6 @@ DecalGizmoPlugin::DecalGizmoPlugin() {
create_handle_material("handles");
}
DecalGizmoPlugin::~DecalGizmoPlugin() {
}
bool DecalGizmoPlugin::has_gizmo(Node3D *p_spatial) {
return Object::cast_to<Decal>(p_spatial) != nullptr;
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef DECAL_GIZMO_PLUGIN_H
#define DECAL_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -53,7 +52,4 @@ public:
void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false) override;
DecalGizmoPlugin();
~DecalGizmoPlugin();
};
#endif // DECAL_GIZMO_PLUGIN_H

View file

@ -48,9 +48,6 @@ FogVolumeGizmoPlugin::FogVolumeGizmoPlugin() {
create_handle_material("handles");
}
FogVolumeGizmoPlugin::~FogVolumeGizmoPlugin() {
}
bool FogVolumeGizmoPlugin::has_gizmo(Node3D *p_spatial) {
return (Object::cast_to<FogVolume>(p_spatial) != nullptr);
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef FOG_VOLUME_GIZMO_PLUGIN_H
#define FOG_VOLUME_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -53,7 +52,4 @@ public:
void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false) override;
FogVolumeGizmoPlugin();
~FogVolumeGizmoPlugin();
};
#endif // FOG_VOLUME_GIZMO_PLUGIN_H

View file

@ -33,9 +33,6 @@
#include "editor/editor_settings.h"
#include "scene/3d/visual_instance_3d.h"
GeometryInstance3DGizmoPlugin::GeometryInstance3DGizmoPlugin() {
}
bool GeometryInstance3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
return Object::cast_to<GeometryInstance3D>(p_spatial) != nullptr;
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GEOMETRY_INSTANCE_3D_GIZMO_PLUGIN_H
#define GEOMETRY_INSTANCE_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -42,8 +41,4 @@ public:
virtual int get_priority() const override;
virtual void redraw(EditorNode3DGizmo *p_gizmo) override;
GeometryInstance3DGizmoPlugin();
};
#endif // GEOMETRY_INSTANCE_3D_GIZMO_PLUGIN_H

View file

@ -156,7 +156,10 @@ String Gizmo3DHelper::cylinder_get_handle_name(int p_id) const {
}
}
void Gizmo3DHelper::cylinder_set_handle(const Vector3 p_segment[2], int p_id, real_t &r_height, real_t &r_radius, Vector3 &r_cylinder_position) {
void Gizmo3DHelper::_cylinder_or_capsule_set_handle(const Vector3 p_segment[2], int p_id, real_t &r_height, real_t &r_radius, Vector3 &r_cylinder_position, bool p_is_capsule) {
real_t initial_radius = initial_value.operator Vector2().x;
real_t initial_height = initial_value.operator Vector2().y;
int sign = p_id == 2 ? -1 : 1;
int axis = p_id == 0 ? 0 : 1;
@ -178,9 +181,13 @@ void Gizmo3DHelper::cylinder_set_handle(const Vector3 p_segment[2], int p_id, re
}
r_radius = d;
r_cylinder_position = initial_transform.get_origin();
} else if (p_id == 1 || p_id == 2) {
real_t initial_height = initial_value;
if (p_is_capsule) {
r_height = MAX(initial_height, r_radius * 2.0);
} else {
r_height = initial_height;
}
} else if (p_id == 1 || p_id == 2) {
// Adjust height.
if (Input::get_singleton()->is_key_pressed(Key::ALT)) {
r_height = d * 2.0;
@ -200,6 +207,12 @@ void Gizmo3DHelper::cylinder_set_handle(const Vector3 p_segment[2], int p_id, re
offset[axis] = (r_height - initial_height) * 0.5 * sign;
r_cylinder_position = initial_transform.xform(offset);
}
if (p_is_capsule) {
r_radius = MIN(initial_radius, r_height / 2.0);
} else {
r_radius = initial_radius;
}
}
}
@ -212,25 +225,19 @@ void Gizmo3DHelper::cylinder_commit_handle(int p_id, const String &p_radius_acti
}
if (p_cancel) {
if (p_id == 0) {
p_radius_object->set(p_radius_property, initial_value);
} else {
p_height_object->set(p_height_property, initial_value);
}
p_radius_object->set(p_radius_property, initial_value.operator Vector2().x);
p_height_object->set(p_height_property, initial_value.operator Vector2().y);
p_position_object->set(p_position_property, initial_transform.get_origin());
return;
}
EditorUndoRedoManager *ur = EditorUndoRedoManager::get_singleton();
ur->create_action(p_id == 0 ? p_radius_action_name : p_height_action_name);
if (p_id == 0) {
ur->add_do_property(p_radius_object, p_radius_property, p_radius_object->get(p_radius_property));
ur->add_undo_property(p_radius_object, p_radius_property, initial_value);
} else {
ur->add_do_property(p_height_object, p_height_property, p_height_object->get(p_height_property));
ur->add_do_property(p_position_object, p_position_property, p_position_object->get(p_position_property));
ur->add_undo_property(p_height_object, p_height_property, initial_value);
ur->add_undo_property(p_position_object, p_position_property, initial_transform.get_origin());
}
ur->add_do_property(p_radius_object, p_radius_property, p_radius_object->get(p_radius_property));
ur->add_undo_property(p_radius_object, p_radius_property, initial_value.operator Vector2().x);
ur->add_do_property(p_height_object, p_height_property, p_height_object->get(p_height_property));
ur->add_undo_property(p_height_object, p_height_property, initial_value.operator Vector2().y);
ur->add_do_property(p_position_object, p_position_property, p_position_object->get(p_position_property));
ur->add_undo_property(p_position_object, p_position_property, initial_transform.get_origin());
ur->commit_action();
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GIZMO_3D_HELPER_H
#define GIZMO_3D_HELPER_H
#pragma once
#include "core/object/ref_counted.h"
@ -42,19 +41,44 @@ class Gizmo3DHelper : public RefCounted {
Variant initial_value;
Transform3D initial_transform;
private:
void _cylinder_or_capsule_set_handle(const Vector3 p_segment[2], int p_id, real_t &r_height, real_t &r_radius, Vector3 &r_cylinder_position, bool p_is_capsule);
public:
/**
* Initializes a new action involving a handle.
*
* Depending on the type of gizmo that will be used, different formats for the `p_initial_value` are required:
* Box: The size of the box as `Vector3`
* Cylinder or Capsule: A `Vector2` of the form `Vector2(radius, height)`
*/
void initialize_handle_action(const Variant &p_initial_value, const Transform3D &p_initial_transform);
void get_segment(Camera3D *p_camera, const Point2 &p_point, Vector3 *r_segment);
// Box
Vector<Vector3> box_get_handles(const Vector3 &p_box_size);
String box_get_handle_name(int p_id) const;
void box_set_handle(const Vector3 p_segment[2], int p_id, Vector3 &r_box_size, Vector3 &r_box_position);
void box_commit_handle(const String &p_action_name, bool p_cancel, Object *p_position_object, Object *p_size_object = nullptr, const StringName &p_position_property = "global_position", const StringName &p_size_property = "size");
// Cylinder
Vector<Vector3> cylinder_get_handles(real_t p_height, real_t p_radius);
String cylinder_get_handle_name(int p_id) const;
void cylinder_set_handle(const Vector3 p_segment[2], int p_id, real_t &r_height, real_t &r_radius, Vector3 &r_cylinder_position);
_FORCE_INLINE_ void cylinder_set_handle(const Vector3 p_segment[2], int p_id, real_t &r_height, real_t &r_radius, Vector3 &r_cylinder_position) {
_cylinder_or_capsule_set_handle(p_segment, p_id, r_height, r_radius, r_cylinder_position, false);
}
void cylinder_commit_handle(int p_id, const String &p_radius_action_name, const String &p_height_action_name, bool p_cancel, Object *p_position_object, Object *p_height_object = nullptr, Object *p_radius_object = nullptr, const StringName &p_position_property = "global_position", const StringName &p_height_property = "height", const StringName &p_radius_property = "radius");
};
#endif // GIZMO_3D_HELPER_H
// Capsule
_FORCE_INLINE_ Vector<Vector3> capsule_get_handles(real_t p_height, real_t p_radius) { return cylinder_get_handles(p_height, p_radius); }
_FORCE_INLINE_ String capsule_get_handle_name(int p_id) { return cylinder_get_handle_name(p_id); }
_FORCE_INLINE_ void capsule_set_handle(const Vector3 p_segment[2], int p_id, real_t &r_height, real_t &r_radius, Vector3 &r_capsule_position) {
_cylinder_or_capsule_set_handle(p_segment, p_id, r_height, r_radius, r_capsule_position, true);
}
_FORCE_INLINE_ void capsule_commit_handle(int p_id, const String &p_radius_action_name, const String &p_height_action_name, bool p_cancel, Object *p_position_object, Object *p_height_object = nullptr, Object *p_radius_object = nullptr, const StringName &p_position_property = "global_position", const StringName &p_height_property = "height", const StringName &p_radius_property = "radius") {
cylinder_commit_handle(p_id, p_radius_action_name, p_height_action_name, p_cancel, p_position_object, p_height_object, p_radius_object, p_position_property, p_height_property, p_radius_property);
}
};

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GPU_PARTICLES_3D_GIZMO_PLUGIN_H
#define GPU_PARTICLES_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -45,5 +44,3 @@ public:
GPUParticles3DGizmoPlugin();
};
#endif // GPU_PARTICLES_3D_GIZMO_PLUGIN_H

View file

@ -52,9 +52,6 @@ GPUParticlesCollision3DGizmoPlugin::GPUParticlesCollision3DGizmoPlugin() {
create_handle_material("handles");
}
GPUParticlesCollision3DGizmoPlugin::~GPUParticlesCollision3DGizmoPlugin() {
}
bool GPUParticlesCollision3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
return (Object::cast_to<GPUParticlesCollision3D>(p_spatial) != nullptr) || (Object::cast_to<GPUParticlesAttractor3D>(p_spatial) != nullptr);
}
@ -168,45 +165,81 @@ void GPUParticlesCollision3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
const Ref<Material> handles_material = get_material("handles");
if (Object::cast_to<GPUParticlesCollisionSphere3D>(cs) || Object::cast_to<GPUParticlesAttractorSphere3D>(cs)) {
float r = cs->call("get_radius");
float radius = cs->call("get_radius");
#define PUSH_QUARTER(m_from_x, m_from_y, m_to_x, m_to_y, m_y) \
points_ptrw[index++] = Vector3(m_from_x, m_y, m_from_y); \
points_ptrw[index++] = Vector3(m_to_x, m_y, m_to_y); \
points_ptrw[index++] = Vector3(m_from_x, m_y, -m_from_y); \
points_ptrw[index++] = Vector3(m_to_x, m_y, -m_to_y); \
points_ptrw[index++] = Vector3(-m_from_x, m_y, m_from_y); \
points_ptrw[index++] = Vector3(-m_to_x, m_y, m_to_y); \
points_ptrw[index++] = Vector3(-m_from_x, m_y, -m_from_y); \
points_ptrw[index++] = Vector3(-m_to_x, m_y, -m_to_y);
#define PUSH_QUARTER_XY(m_from_x, m_from_y, m_to_x, m_to_y) \
points_ptrw[index++] = Vector3(m_from_x, -m_from_y, 0); \
points_ptrw[index++] = Vector3(m_to_x, -m_to_y, 0); \
points_ptrw[index++] = Vector3(m_from_x, m_from_y, 0); \
points_ptrw[index++] = Vector3(m_to_x, m_to_y, 0); \
points_ptrw[index++] = Vector3(-m_from_x, -m_from_y, 0); \
points_ptrw[index++] = Vector3(-m_to_x, -m_to_y, 0); \
points_ptrw[index++] = Vector3(-m_from_x, m_from_y, 0); \
points_ptrw[index++] = Vector3(-m_to_x, m_to_y, 0);
#define PUSH_QUARTER_YZ(m_from_x, m_from_y, m_to_x, m_to_y) \
points_ptrw[index++] = Vector3(0, -m_from_y, m_from_x); \
points_ptrw[index++] = Vector3(0, -m_to_y, m_to_x); \
points_ptrw[index++] = Vector3(0, m_from_y, m_from_x); \
points_ptrw[index++] = Vector3(0, m_to_y, m_to_x); \
points_ptrw[index++] = Vector3(0, -m_from_y, -m_from_x); \
points_ptrw[index++] = Vector3(0, -m_to_y, -m_to_x); \
points_ptrw[index++] = Vector3(0, m_from_y, -m_from_x); \
points_ptrw[index++] = Vector3(0, m_to_y, -m_to_x);
// Number of points in an octant. So there will be 8 * points_in_octant points in total.
// This corresponds to the smoothness of the circle.
const uint32_t points_in_octant = 16;
const real_t octant_angle = Math::PI / 4;
const real_t inc = (Math::PI / (4 * points_in_octant));
const real_t radius_squared = radius * radius;
real_t r = 0;
Vector<Vector3> points;
points.resize(3 * 8 * points_in_octant * 2);
Vector3 *points_ptrw = points.ptrw();
for (int i = 0; i <= 360; i++) {
float ra = Math::deg_to_rad((float)i);
float rb = Math::deg_to_rad((float)i + 1);
Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * r;
Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * r;
uint32_t index = 0;
float previous_x = radius;
float previous_y = 0.f;
points.push_back(Vector3(a.x, 0, a.y));
points.push_back(Vector3(b.x, 0, b.y));
points.push_back(Vector3(0, a.x, a.y));
points.push_back(Vector3(0, b.x, b.y));
points.push_back(Vector3(a.x, a.y, 0));
points.push_back(Vector3(b.x, b.y, 0));
}
for (uint32_t i = 0; i < points_in_octant; ++i) {
r += inc;
real_t x = Math::cos((i == points_in_octant - 1) ? octant_angle : r) * radius;
real_t y = Math::sqrt(radius_squared - (x * x));
Vector<Vector3> collision_segments;
PUSH_QUARTER(previous_x, previous_y, x, y, 0);
PUSH_QUARTER(previous_y, previous_x, y, x, 0);
for (int i = 0; i < 64; i++) {
float ra = i * (Math_TAU / 64.0);
float rb = (i + 1) * (Math_TAU / 64.0);
Point2 a = Vector2(Math::sin(ra), Math::cos(ra)) * r;
Point2 b = Vector2(Math::sin(rb), Math::cos(rb)) * r;
PUSH_QUARTER_XY(previous_x, previous_y, x, y);
PUSH_QUARTER_XY(previous_y, previous_x, y, x);
collision_segments.push_back(Vector3(a.x, 0, a.y));
collision_segments.push_back(Vector3(b.x, 0, b.y));
collision_segments.push_back(Vector3(0, a.x, a.y));
collision_segments.push_back(Vector3(0, b.x, b.y));
collision_segments.push_back(Vector3(a.x, a.y, 0));
collision_segments.push_back(Vector3(b.x, b.y, 0));
PUSH_QUARTER_YZ(previous_x, previous_y, x, y);
PUSH_QUARTER_YZ(previous_y, previous_x, y, x);
previous_x = x;
previous_y = y;
}
p_gizmo->add_lines(points, material);
p_gizmo->add_collision_segments(collision_segments);
p_gizmo->add_collision_segments(points);
Vector<Vector3> handles;
handles.push_back(Vector3(r, 0, 0));
p_gizmo->add_handles(handles, handles_material);
#undef PUSH_QUARTER
#undef PUSH_QUARTER_XY
#undef PUSH_QUARTER_YZ
}
if (Object::cast_to<GPUParticlesCollisionBox3D>(cs) || Object::cast_to<GPUParticlesAttractorBox3D>(cs) || Object::cast_to<GPUParticlesAttractorVectorField3D>(cs) || Object::cast_to<GPUParticlesCollisionSDF3D>(cs) || Object::cast_to<GPUParticlesCollisionHeightField3D>(cs)) {

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef GPU_PARTICLES_COLLISION_3D_GIZMO_PLUGIN_H
#define GPU_PARTICLES_COLLISION_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -53,7 +52,4 @@ public:
void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false) override;
GPUParticlesCollision3DGizmoPlugin();
~GPUParticlesCollision3DGizmoPlugin();
};
#endif // GPU_PARTICLES_COLLISION_3D_GIZMO_PLUGIN_H

View file

@ -179,8 +179,8 @@ void JointGizmosDrawer::draw_circle(Vector3::Axis p_axis, real_t p_radius, const
} else {
if (p_limit_lower > p_limit_upper) {
p_limit_lower = -Math_PI;
p_limit_upper = Math_PI;
p_limit_lower = -Math::PI;
p_limit_upper = Math::PI;
}
const int points = 32;

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef JOINT_3D_GIZMO_PLUGIN_H
#define JOINT_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -95,5 +94,3 @@ public:
static void draw_circle(Vector3::Axis p_axis, real_t p_radius, const Transform3D &p_offset, const Basis &p_base, real_t p_limit_lower, real_t p_limit_upper, Vector<Vector3> &r_points, bool p_inverse = false);
static void draw_cone(const Transform3D &p_offset, const Basis &p_base, real_t p_swing, real_t p_twist, Vector<Vector3> &r_points);
};
#endif // JOINT_3D_GIZMO_PLUGIN_H

View file

@ -32,9 +32,6 @@
#include "scene/3d/label_3d.h"
Label3DGizmoPlugin::Label3DGizmoPlugin() {
}
bool Label3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
return Object::cast_to<Label3D>(p_spatial) != nullptr;
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef LABEL_3D_GIZMO_PLUGIN_H
#define LABEL_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -42,8 +41,4 @@ public:
int get_priority() const override;
bool can_be_hidden() const override;
void redraw(EditorNode3DGizmo *p_gizmo) override;
Label3DGizmoPlugin();
};
#endif // LABEL_3D_GIZMO_PLUGIN_H

View file

@ -179,7 +179,7 @@ void Light3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
for (int i = 0; i < arrow_sides; i++) {
for (int j = 0; j < arrow_points; j++) {
Basis ma(Vector3(0, 0, 1), Math_PI * i / arrow_sides);
Basis ma(Vector3(0, 0, 1), Math::PI * i / arrow_sides);
Vector3 v1 = arrow[j] - Vector3(0, 0, arrow_length);
Vector3 v2 = arrow[(j + 1) % arrow_points] - Vector3(0, 0, arrow_length);
@ -295,8 +295,8 @@ float Light3DGizmoPlugin::_find_closest_angle_to_half_pi_arc(const Vector3 &p_fr
Vector3 min_p;
for (int i = 0; i < arc_test_points; i++) {
float a = i * Math_PI * 0.5 / arc_test_points;
float an = (i + 1) * Math_PI * 0.5 / arc_test_points;
float a = i * Math::PI * 0.5 / arc_test_points;
float an = (i + 1) * Math::PI * 0.5 / arc_test_points;
Vector3 p = Vector3(Math::cos(a), 0, -Math::sin(a)) * p_arc_radius;
Vector3 n = Vector3(Math::cos(an), 0, -Math::sin(an)) * p_arc_radius;
@ -311,6 +311,6 @@ float Light3DGizmoPlugin::_find_closest_angle_to_half_pi_arc(const Vector3 &p_fr
}
//min_p = p_arc_xform.affine_inverse().xform(min_p);
float a = (Math_PI * 0.5) - Vector2(min_p.x, -min_p.z).angle();
float a = (Math::PI * 0.5) - Vector2(min_p.x, -min_p.z).angle();
return Math::rad_to_deg(a);
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef LIGHT_3D_GIZMO_PLUGIN_H
#define LIGHT_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -52,5 +51,3 @@ public:
Light3DGizmoPlugin();
};
#endif // LIGHT_3D_GIZMO_PLUGIN_H

View file

@ -88,7 +88,7 @@ void LightmapGIGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
HashSet<Vector2i> lines_found;
Vector<Vector3> points = data->get_capture_points();
if (points.size() == 0) {
if (points.is_empty()) {
return;
}
Vector<Color> sh = data->get_capture_sh();
@ -123,8 +123,8 @@ void LightmapGIGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
int stack_count = 8;
int sector_count = 16;
float sector_step = (Math_PI * 2.0) / sector_count;
float stack_step = Math_PI / stack_count;
float sector_step = (Math::PI * 2.0) / sector_count;
float stack_step = Math::PI / stack_count;
Vector<Vector3> vertices;
Vector<Color> colors;
@ -141,7 +141,7 @@ void LightmapGIGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
}
for (int i = 0; i <= stack_count; ++i) {
float stack_angle = Math_PI / 2 - i * stack_step; // starting from pi/2 to -pi/2
float stack_angle = Math::PI / 2 - i * stack_step; // starting from pi/2 to -pi/2
float xy = radius * Math::cos(stack_angle); // r * cos(u)
float z = radius * Math::sin(stack_angle); // r * sin(u)

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef LIGHTMAP_GI_GIZMO_PLUGIN_H
#define LIGHTMAP_GI_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -44,5 +43,3 @@ public:
LightmapGIGizmoPlugin();
};
#endif // LIGHTMAP_GI_GIZMO_PLUGIN_H

View file

@ -66,14 +66,14 @@ void LightmapProbeGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
int stack_count = 8;
int sector_count = 16;
float sector_step = (Math_PI * 2.0) / sector_count;
float stack_step = Math_PI / stack_count;
float sector_step = (Math::PI * 2.0) / sector_count;
float stack_step = Math::PI / stack_count;
Vector<Vector3> vertices;
float radius = 0.2;
for (int i = 0; i <= stack_count; ++i) {
float stack_angle = Math_PI / 2 - i * stack_step; // starting from pi/2 to -pi/2
float stack_angle = Math::PI / 2 - i * stack_step; // starting from pi/2 to -pi/2
float xy = radius * Math::cos(stack_angle); // r * cos(u)
float z = radius * Math::sin(stack_angle); // r * sin(u)

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef LIGHTMAP_PROBE_GIZMO_PLUGIN_H
#define LIGHTMAP_PROBE_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -44,5 +43,3 @@ public:
LightmapProbeGizmoPlugin();
};
#endif // LIGHTMAP_PROBE_GIZMO_PLUGIN_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef MARKER_3D_GIZMO_PLUGIN_H
#define MARKER_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -46,5 +45,3 @@ public:
Marker3DGizmoPlugin();
};
#endif // MARKER_3D_GIZMO_PLUGIN_H

View file

@ -32,12 +32,9 @@
#include "editor/plugins/node_3d_editor_plugin.h"
#include "scene/3d/mesh_instance_3d.h"
#include "scene/3d/soft_body_3d.h"
#include "scene/3d/physics/soft_body_3d.h"
#include "scene/resources/3d/primitive_meshes.h"
MeshInstance3DGizmoPlugin::MeshInstance3DGizmoPlugin() {
}
bool MeshInstance3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
return Object::cast_to<MeshInstance3D>(p_spatial) != nullptr && Object::cast_to<SoftBody3D>(p_spatial) == nullptr;
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef MESH_INSTANCE_3D_GIZMO_PLUGIN_H
#define MESH_INSTANCE_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -42,8 +41,4 @@ public:
int get_priority() const override;
bool can_be_hidden() const override;
void redraw(EditorNode3DGizmo *p_gizmo) override;
MeshInstance3DGizmoPlugin();
};
#endif // MESH_INSTANCE_3D_GIZMO_PLUGIN_H

View file

@ -32,7 +32,7 @@
#include "editor/editor_undo_redo_manager.h"
#include "editor/plugins/node_3d_editor_plugin.h"
#include "scene/3d/navigation_link_3d.h"
#include "scene/3d/navigation/navigation_link_3d.h"
#include "servers/navigation_server_3d.h"
NavigationLink3DGizmoPlugin::NavigationLink3DGizmoPlugin() {
@ -70,10 +70,10 @@ void NavigationLink3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
p_gizmo->clear();
// Number of points in an octant. So there ill be 8 * points_in_octant points in total.
// Number of points in an octant. So there will be 8 * points_in_octant points in total.
// Correspond to the smoothness of the circle.
const uint32_t points_in_octant = 4;
real_t inc = (Math_PI / (4 * points_in_octant));
const uint32_t points_in_octant = 8;
real_t inc = (Math::PI / (4 * points_in_octant));
Vector<Vector3> lines;
// points_in_octant * 8 * 2 per circle * 2 circles. 2 for the start-end. 4 for the arrow, and another 4 if bidirectionnal.

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef NAVIGATION_LINK_3D_GIZMO_PLUGIN_H
#define NAVIGATION_LINK_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -49,5 +48,3 @@ public:
NavigationLink3DGizmoPlugin();
};
#endif // NAVIGATION_LINK_3D_GIZMO_PLUGIN_H

View file

@ -30,7 +30,8 @@
#include "navigation_region_3d_gizmo_plugin.h"
#include "scene/3d/navigation_region_3d.h"
#include "core/math/random_pcg.h"
#include "scene/3d/navigation/navigation_region_3d.h"
#include "servers/navigation_server_3d.h"
NavigationRegion3DGizmoPlugin::NavigationRegion3DGizmoPlugin() {

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef NAVIGATION_REGION_3D_GIZMO_PLUGIN_H
#define NAVIGATION_REGION_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -57,5 +56,3 @@ public:
NavigationRegion3DGizmoPlugin();
};
#endif // NAVIGATION_REGION_3D_GIZMO_PLUGIN_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef OCCLUDER_INSTANCE_3D_GIZMO_PLUGIN_H
#define OCCLUDER_INSTANCE_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -49,5 +48,3 @@ public:
OccluderInstance3DGizmoPlugin();
};
#endif // OCCLUDER_INSTANCE_3D_GIZMO_PLUGIN_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef PARTICLES_3D_EMISSION_SHAPE_GIZMO_PLUGIN_H
#define PARTICLES_3D_EMISSION_SHAPE_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/gizmos/gizmo_3d_helper.h"
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -53,5 +52,3 @@ public:
Particles3DEmissionShapeGizmoPlugin();
};
#endif // PARTICLES_3D_EMISSION_SHAPE_GIZMO_PLUGIN_H

View file

@ -32,8 +32,8 @@
#include "editor/editor_settings.h"
#include "editor/plugins/gizmos/joint_3d_gizmo_plugin.h"
#include "scene/3d/physical_bone_simulator_3d.h"
#include "scene/3d/physics/physical_bone_3d.h"
#include "scene/3d/physics/physical_bone_simulator_3d.h"
PhysicalBone3DGizmoPlugin::PhysicalBone3DGizmoPlugin() {
create_material("joint_material", EDITOR_GET("editors/3d_gizmos/gizmo_colors/joint"));

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef PHYSICS_BONE_3D_GIZMO_PLUGIN_H
#define PHYSICS_BONE_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -44,5 +43,3 @@ public:
PhysicalBone3DGizmoPlugin();
};
#endif // PHYSICS_BONE_3D_GIZMO_PLUGIN_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef RAY_CAST_3D_GIZMO_PLUGIN_H
#define RAY_CAST_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -44,5 +43,3 @@ public:
RayCast3DGizmoPlugin();
};
#endif // RAY_CAST_3D_GIZMO_PLUGIN_H

View file

@ -51,9 +51,6 @@ ReflectionProbeGizmoPlugin::ReflectionProbeGizmoPlugin() {
create_handle_material("handles");
}
ReflectionProbeGizmoPlugin::~ReflectionProbeGizmoPlugin() {
}
bool ReflectionProbeGizmoPlugin::has_gizmo(Node3D *p_spatial) {
return Object::cast_to<ReflectionProbe>(p_spatial) != nullptr;
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef REFLECTION_PROBE_GIZMO_PLUGIN_H
#define REFLECTION_PROBE_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -53,7 +52,4 @@ public:
void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false) override;
ReflectionProbeGizmoPlugin();
~ReflectionProbeGizmoPlugin();
};
#endif // REFLECTION_PROBE_GIZMO_PLUGIN_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SHAPE_CAST_3D_GIZMO_PLUGIN_H
#define SHAPE_CAST_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -44,5 +43,3 @@ public:
ShapeCast3DGizmoPlugin();
};
#endif // SHAPE_CAST_3D_GIZMO_PLUGIN_H

View file

@ -30,7 +30,7 @@
#include "soft_body_3d_gizmo_plugin.h"
#include "scene/3d/soft_body_3d.h"
#include "scene/3d/physics/soft_body_3d.h"
SoftBody3DGizmoPlugin::SoftBody3DGizmoPlugin() {
Color gizmo_color = SceneTree::get_singleton()->get_debug_collisions_color();

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SOFT_BODY_3D_GIZMO_PLUGIN_H
#define SOFT_BODY_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -50,5 +49,3 @@ public:
SoftBody3DGizmoPlugin();
};
#endif // SOFT_BODY_3D_GIZMO_PLUGIN_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SPRING_ARM_3D_GIZMO_PLUGIN_H
#define SPRING_ARM_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -44,5 +43,3 @@ public:
SpringArm3DGizmoPlugin();
};
#endif // SPRING_ARM_3D_GIZMO_PLUGIN_H

View file

@ -171,7 +171,7 @@ void SpringBoneSimulator3DGizmoPlugin::draw_sphere(Ref<SurfaceTool> &p_surface_t
static const Vector3 VECTOR3_UP = Vector3(0, 1, 0);
static const Vector3 VECTOR3_FORWARD = Vector3(0, 0, 1);
static const int STEP = 16;
static const float SPPI = Math_TAU / (float)STEP;
static const float SPPI = Math::TAU / (float)STEP;
for (int i = 1; i <= STEP; i++) {
p_surface_tool->set_color(p_color);
@ -302,7 +302,7 @@ void SpringBoneCollision3DGizmoPlugin::draw_sphere(Ref<SurfaceTool> &p_surface_t
static const Vector3 VECTOR3_UP = Vector3(0, 1, 0);
static const Vector3 VECTOR3_FORWARD = Vector3(0, 0, 1);
static const int STEP = 16;
static const float SPPI = Math_TAU / (float)STEP;
static const float SPPI = Math::TAU / (float)STEP;
for (int i = 1; i <= STEP; i++) {
p_surface_tool->set_color(p_color);
@ -330,8 +330,8 @@ void SpringBoneCollision3DGizmoPlugin::draw_capsule(Ref<SurfaceTool> &p_surface_
static const Vector3 VECTOR3_FORWARD = Vector3(0, 0, 1);
static const int STEP = 16;
static const int HALF_STEP = 8;
static const float SPPI = Math_TAU / (float)STEP;
static const float HALF_PI = Math_PI * 0.5;
static const float SPPI = Math::TAU / (float)STEP;
static const float HALF_PI = Math::PI * 0.5;
Vector3 top = VECTOR3_UP * (p_height * 0.5 - p_radius);
Vector3 bottom = -top;
@ -376,7 +376,7 @@ void SpringBoneCollision3DGizmoPlugin::draw_capsule(Ref<SurfaceTool> &p_surface_
void SpringBoneCollision3DGizmoPlugin::draw_plane(Ref<SurfaceTool> &p_surface_tool, const Color &p_color) {
static const Vector3 VECTOR3_UP = Vector3(0, 1, 0);
static const float HALF_PI = Math_PI * 0.5;
static const float HALF_PI = Math::PI * 0.5;
static const float ARROW_LENGTH = 0.3;
static const float ARROW_HALF_WIDTH = 0.05;
static const float ARROW_TOP_HALF_WIDTH = 0.1;

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SPRING_BONE_3D_GIZMO_PLUGIN_H
#define SPRING_BONE_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/editor_plugin.h"
#include "editor/plugins/node_3d_editor_plugin.h"
@ -85,5 +84,3 @@ public:
SpringBoneCollision3DGizmoPlugin();
~SpringBoneCollision3DGizmoPlugin();
};
#endif // SPRING_BONE_3D_GIZMO_PLUGIN_H

View file

@ -32,9 +32,6 @@
#include "scene/3d/sprite_3d.h"
SpriteBase3DGizmoPlugin::SpriteBase3DGizmoPlugin() {
}
bool SpriteBase3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
return Object::cast_to<SpriteBase3D>(p_spatial) != nullptr;
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef SPRITE_BASE_3D_GIZMO_PLUGIN_H
#define SPRITE_BASE_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -42,8 +41,4 @@ public:
int get_priority() const override;
bool can_be_hidden() const override;
void redraw(EditorNode3DGizmo *p_gizmo) override;
SpriteBase3DGizmoPlugin();
};
#endif // SPRITE_BASE_3D_GIZMO_PLUGIN_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef VEHICLE_BODY_3D_GIZMO_PLUGIN_H
#define VEHICLE_BODY_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -44,5 +43,3 @@ public:
VehicleWheel3DGizmoPlugin();
};
#endif // VEHICLE_BODY_3D_GIZMO_PLUGIN_H

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef VISIBLE_ON_SCREEN_NOTIFIER_3D_GIZMO_PLUGIN_H
#define VISIBLE_ON_SCREEN_NOTIFIER_3D_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -49,5 +48,3 @@ public:
VisibleOnScreenNotifier3DGizmoPlugin();
};
#endif // VISIBLE_ON_SCREEN_NOTIFIER_3D_GIZMO_PLUGIN_H

View file

@ -51,9 +51,6 @@ VoxelGIGizmoPlugin::VoxelGIGizmoPlugin() {
create_handle_material("handles");
}
VoxelGIGizmoPlugin::~VoxelGIGizmoPlugin() {
}
bool VoxelGIGizmoPlugin::has_gizmo(Node3D *p_spatial) {
return Object::cast_to<VoxelGI>(p_spatial) != nullptr;
}

View file

@ -28,8 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifndef VOXEL_GI_GIZMO_PLUGIN_H
#define VOXEL_GI_GIZMO_PLUGIN_H
#pragma once
#include "editor/plugins/node_3d_editor_gizmos.h"
@ -53,7 +52,4 @@ public:
void commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel = false) override;
VoxelGIGizmoPlugin();
~VoxelGIGizmoPlugin();
};
#endif // VOXEL_GI_GIZMO_PLUGIN_H