Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use real_t in editor plugins #49783

Merged
merged 1 commit into from
Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 62 additions & 62 deletions editor/plugins/canvas_item_editor_plugin.cpp

Large diffs are not rendered by default.

64 changes: 21 additions & 43 deletions editor/plugins/canvas_item_editor_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ class CanvasItemEditorSelectedItem : public Object {

public:
Transform2D prev_xform;
float prev_rot = 0;
real_t prev_rot = 0;
Rect2 prev_rect;
Vector2 prev_pivot;
float prev_anchors[4] = { 0.0f };
real_t prev_anchors[4] = { (real_t)0.0 };

Transform2D pre_drag_xform;
Rect2 pre_drag_rect;
Expand Down Expand Up @@ -250,7 +250,7 @@ class CanvasItemEditor : public VBoxContainer {
bool show_edit_locks;
bool show_transformation_gizmos;

float zoom;
real_t zoom;
Point2 view_offset;
Point2 previous_update_view_offset;

Expand All @@ -262,9 +262,9 @@ class CanvasItemEditor : public VBoxContainer {
int primary_grid_steps;
int grid_step_multiplier;

float snap_rotation_step;
float snap_rotation_offset;
float snap_scale_step;
real_t snap_rotation_step;
real_t snap_rotation_offset;
real_t snap_scale_step;
bool smart_snap_active;
bool grid_snap_active;

Expand Down Expand Up @@ -292,7 +292,7 @@ class CanvasItemEditor : public VBoxContainer {

struct _SelectResult {
CanvasItem *item = nullptr;
float z_index = 0;
real_t z_index = 0;
bool has_z = true;
_FORCE_INLINE_ bool operator<(const _SelectResult &p_rr) const {
return has_z && p_rr.has_z ? p_rr.z_index < z_index : p_rr.has_z;
Expand All @@ -309,7 +309,7 @@ class CanvasItemEditor : public VBoxContainer {

struct BoneList {
Transform2D xform;
float length = 0.f;
real_t length = 0;
uint64_t last_pass = 0;
};

Expand All @@ -332,7 +332,7 @@ class CanvasItemEditor : public VBoxContainer {
struct PoseClipboard {
Vector2 pos;
Vector2 scale;
float rot = 0;
real_t rot = 0;
ObjectID id;
};
List<PoseClipboard> pose_clipboard;
Expand Down Expand Up @@ -432,7 +432,7 @@ class CanvasItemEditor : public VBoxContainer {

void _popup_callback(int p_op);
bool updating_scroll;
void _update_scroll(float);
void _update_scroll(real_t);
void _update_scrollbars();
void _append_canvas_item(CanvasItem *p_item);
void _snap_changed();
Expand All @@ -459,7 +459,7 @@ class CanvasItemEditor : public VBoxContainer {

void _draw_text_at_position(Point2 p_position, String p_string, Side p_side);
void _draw_margin_at_position(int p_value, Point2 p_position, Side p_side);
void _draw_percentage_at_position(float p_value, Point2 p_position, Side p_side);
void _draw_percentage_at_position(real_t p_value, Point2 p_position, Side p_side);
void _draw_straight_line(Point2 p_from, Point2 p_to, Color p_color);

void _draw_smart_snapping();
Expand Down Expand Up @@ -501,16 +501,16 @@ class CanvasItemEditor : public VBoxContainer {
SnapTarget snap_target[2];
Transform2D snap_transform;
void _snap_if_closer_float(
float p_value,
float &r_current_snap, SnapTarget &r_current_snap_target,
float p_target_value, SnapTarget p_snap_target,
float p_radius = 10.0);
const real_t p_value,
real_t &r_current_snap, SnapTarget &r_current_snap_target,
const real_t p_target_value, const SnapTarget p_snap_target,
const real_t p_radius = 10.0);
void _snap_if_closer_point(
Point2 p_value,
Point2 &r_current_snap, SnapTarget (&r_current_snap_target)[2],
Point2 p_target_value, SnapTarget p_snap_target,
real_t rotation = 0.0,
float p_radius = 10.0);
Point2 p_target_value, const SnapTarget p_snap_target,
const real_t rotation = 0.0,
const real_t p_radius = 10.0);
void _snap_other_nodes(
const Point2 p_value,
const Transform2D p_transform_to_snap,
Expand All @@ -527,8 +527,8 @@ class CanvasItemEditor : public VBoxContainer {

VBoxContainer *controls_vb;
EditorZoomWidget *zoom_widget;
void _update_zoom(float p_zoom);
void _zoom_on_position(float p_zoom, Point2 p_position = Point2());
void _update_zoom(real_t p_zoom);
void _zoom_on_position(real_t p_zoom, Point2 p_position = Point2());
void _button_toggle_smart_snap(bool p_status);
void _button_toggle_grid_snap(bool p_status);
void _button_override_camera(bool p_pressed);
Expand Down Expand Up @@ -557,28 +557,6 @@ class CanvasItemEditor : public VBoxContainer {

HBoxContainer *get_panel_hb() { return hb; }

struct compare_items_x {
bool operator()(const CanvasItem *a, const CanvasItem *b) const {
return a->get_global_transform().elements[2].x < b->get_global_transform().elements[2].x;
}
};

struct compare_items_y {
bool operator()(const CanvasItem *a, const CanvasItem *b) const {
return a->get_global_transform().elements[2].y < b->get_global_transform().elements[2].y;
}
};

struct proj_vector2_x {
float get(const Vector2 &v) { return v.x; }
void set(Vector2 &v, float f) { v.x = f; }
};

struct proj_vector2_y {
float get(const Vector2 &v) { return v.y; }
void set(Vector2 &v, float f) { v.y = f; }
};

template <class P, class C>
void space_selected_items();

Expand All @@ -599,7 +577,7 @@ class CanvasItemEditor : public VBoxContainer {
};

Point2 snap_point(Point2 p_target, unsigned int p_modes = SNAP_DEFAULT, unsigned int p_forced_modes = 0, const CanvasItem *p_self_canvas_item = nullptr, List<CanvasItem *> p_other_nodes_exceptions = List<CanvasItem *>());
float snap_angle(float p_target, float p_start = 0) const;
real_t snap_angle(real_t p_target, real_t p_start = 0) const;

Transform2D get_canvas_transform() const { return transform; }

Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/editor_preview_plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2
xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math_PI * 0.125);
xform.basis = Basis().rotated(Vector3(1, 0, 0), Math_PI * 0.125) * xform.basis;
AABB rot_aabb = xform.xform(aabb);
float m = MAX(rot_aabb.size.x, rot_aabb.size.y) * 0.5;
real_t m = MAX(rot_aabb.size.x, rot_aabb.size.y) * 0.5;
if (m == 0) {
return Ref<Texture2D>();
}
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/node_3d_editor_gizmos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ void EditorNode3DGizmo::add_vertices(const Vector<Vector3> &p_vertices, const Re
instances.push_back(ins);
}

void EditorNode3DGizmo::add_unscaled_billboard(const Ref<Material> &p_material, float p_scale, const Color &p_modulate) {
void EditorNode3DGizmo::add_unscaled_billboard(const Ref<Material> &p_material, real_t p_scale, const Color &p_modulate) {
ERR_FAIL_COND(!spatial_node);
Instance ins;

Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/node_3d_editor_gizmos.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class EditorNode3DGizmo : public Node3DGizmo {
void add_mesh(const Ref<ArrayMesh> &p_mesh, const Ref<Material> &p_material = Ref<Material>(), const Transform3D &p_xform = Transform3D(), const Ref<SkinReference> &p_skin_reference = Ref<SkinReference>());
void add_collision_segments(const Vector<Vector3> &p_lines);
void add_collision_triangles(const Ref<TriangleMesh> &p_tmesh);
void add_unscaled_billboard(const Ref<Material> &p_material, float p_scale = 1, const Color &p_modulate = Color(1, 1, 1));
void add_unscaled_billboard(const Ref<Material> &p_material, real_t p_scale = 1, const Color &p_modulate = Color(1, 1, 1));
void add_handles(const Vector<Vector3> &p_handles, const Ref<Material> &p_material, const Vector<int> &p_ids = Vector<int>(), bool p_billboard = false, bool p_secondary = false);
void add_solid_box(Ref<Material> &p_material, Vector3 p_size, Vector3 p_position = Vector3(), const Transform3D &p_xform = Transform3D());

Expand Down
Loading