Applied clang-format.

Since PathEditorPlugin was commented out, it didn't get clang-format'ed.
This commit is contained in:
Ferenc Arn 2017-05-24 17:11:20 -05:00
parent fdf301e78b
commit 42de893f9a
3 changed files with 181 additions and 223 deletions

View File

@ -55,8 +55,6 @@ String PathSpatialGizmo::get_handle_name(int p_idx) const {
n += " Out";
return n;
}
Variant PathSpatialGizmo::get_handle_value(int p_idx) const {
@ -84,7 +82,6 @@ Variant PathSpatialGizmo::get_handle_value(int p_idx) const{
original = ofs + c->get_point_pos(idx);
return ofs;
}
void PathSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_point) {
@ -105,8 +102,7 @@ void PathSpatialGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_po
if (p.intersects_ray(ray_from, ray_dir, &inters)) {
if(SpatialEditor::get_singleton()->is_snap_enabled())
{
if (SpatialEditor::get_singleton()->is_snap_enabled()) {
float snap = SpatialEditor::get_singleton()->get_translate_snap();
inters.snap(snap);
}
@ -138,7 +134,6 @@ void PathSpatialGizmo::set_handle(int p_idx,Camera *p_camera, const Point2& p_po
c->set_point_out(idx, local);
}
}
}
void PathSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) {
@ -173,13 +168,9 @@ void PathSpatialGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_c
if (p_cancel) {
return;
}
if (t == 0) {
if (p_cancel) {
@ -192,7 +183,6 @@ void PathSpatialGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_c
ur->add_undo_method(c.ptr(), "set_point_in", idx, p_restore);
ur->commit_action();
} else {
if (p_cancel) {
@ -203,12 +193,9 @@ void PathSpatialGizmo::commit_handle(int p_idx,const Variant& p_restore,bool p_c
ur->add_do_method(c.ptr(), "set_point_out", idx, c->get_point_out(idx));
ur->add_undo_method(c.ptr(), "set_point_out", idx, p_restore);
ur->commit_action();
}
}
void PathSpatialGizmo::redraw() {
clear();
@ -264,21 +251,16 @@ void PathSpatialGizmo::redraw(){
add_handles(handles);
add_handles(sec_handles, false, true);
}
}
PathSpatialGizmo::PathSpatialGizmo(Path *p_path) {
path = p_path;
set_spatial_node(p_path);
}
Ref<SpatialEditorGizmo> PathEditorPlugin::create_spatial_gizmo(Spatial *p_spatial) {
if (p_spatial->cast_to<Path>()) {
return memnew(PathSpatialGizmo(p_spatial->cast_to<Path>()));
@ -301,7 +283,6 @@ bool PathEditorPlugin::forward_spatial_gui_input(Camera* p_camera, const Ref<Inp
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid()) {
Point2 mbpos(mb->get_pos().x, mb->get_pos().y);
@ -321,14 +302,12 @@ bool PathEditorPlugin::forward_spatial_gui_input(Camera* p_camera, const Ref<Inp
if (p_camera->unproject_position(gt.xform(c->get_point_pos(0))).distance_to(mbpos) < click_dist)
return false; //nope, existing
for (int i = 0; i < c->get_point_count() - 1; i++) {
//find the offset and point index of the place to break up
int j = idx;
if (p_camera->unproject_position(gt.xform(c->get_point_pos(i + 1))).distance_to(mbpos) < click_dist)
return false; //nope, existing
while (j < rc && c->get_point_pos(i + 1) != r[j]) {
Vector3 from = r[j];
@ -345,7 +324,6 @@ bool PathEditorPlugin::forward_spatial_gui_input(Camera* p_camera, const Ref<Inp
if (d < 10 && d < closest_d) {
closest_d = d;
closest_seg = i;
Vector3 ray_from = p_camera->project_ray_origin(mbpos);
@ -356,17 +334,14 @@ bool PathEditorPlugin::forward_spatial_gui_input(Camera* p_camera, const Ref<Inp
closest_seg_point = it.xform(rb);
}
}
j++;
}
if (idx == j)
idx++; //force next
else
idx = j; //swap
if (j == rc)
break;
}
@ -442,13 +417,11 @@ bool PathEditorPlugin::forward_spatial_gui_input(Camera* p_camera, const Ref<Inp
}
}
}
}
return false;
}
void PathEditorPlugin::edit(Object *p_object) {
if (p_object) {
@ -499,7 +472,6 @@ void PathEditorPlugin::make_visible(bool p_visible) {
}
}
}
}
void PathEditorPlugin::_mode_changed(int p_idx) {
@ -517,7 +489,6 @@ void PathEditorPlugin::_close_curve() {
if (c->get_point_count() < 2)
return;
c->add_point(c->get_point_pos(0), c->get_point_in(0), c->get_point_out(0));
}
void PathEditorPlugin::_notification(int p_what) {
@ -539,7 +510,6 @@ void PathEditorPlugin::_bind_methods() {
PathEditorPlugin *PathEditorPlugin::singleton = NULL;
PathEditorPlugin::PathEditorPlugin(EditorNode *p_node) {
path = NULL;
@ -593,8 +563,6 @@ PathEditorPlugin::PathEditorPlugin(EditorNode *p_node) {
curve_close->set_tooltip(TTR("Close Curve"));
SpatialEditor::get_singleton()->add_control_to_menu_panel(curve_close);
curve_edit->set_pressed(true);
/*
collision_polygon_editor = memnew( PathEditor(p_node) );
@ -608,12 +576,7 @@ PathEditorPlugin::PathEditorPlugin(EditorNode *p_node) {
collision_polygon_editor->hide();
*/
}
PathEditorPlugin::~PathEditorPlugin()
{
PathEditorPlugin::~PathEditorPlugin() {
}

View File

@ -41,7 +41,6 @@ class PathSpatialGizmo : public EditorSpatialGizmo {
mutable Vector3 original;
public:
virtual String get_handle_name(int p_idx) const;
virtual Variant get_handle_value(int p_idx) const;
virtual void set_handle(int p_idx, Camera *p_camera, const Point2 &p_point);
@ -49,14 +48,12 @@ public:
void redraw();
PathSpatialGizmo(Path *p_path = NULL);
};
class PathEditorPlugin : public EditorPlugin {
GDCLASS(PathEditorPlugin, EditorPlugin);
Separator *sep;
ToolButton *curve_create;
ToolButton *curve_edit;
@ -65,17 +62,16 @@ class PathEditorPlugin : public EditorPlugin {
EditorNode *editor;
Path *path;
void _mode_changed(int p_idx);
void _close_curve();
protected:
void _notification(int p_what);
static void _bind_methods();
public:
Path *get_edited_path() { return path; }
static PathEditorPlugin *singleton;
@ -93,7 +89,6 @@ public:
PathEditorPlugin(EditorNode *p_node);
~PathEditorPlugin();
};
#endif // PATH_EDITOR_PLUGIN_H