diff options
-rw-r--r-- | platform/windows/os_windows.cpp | 3 | ||||
-rw-r--r-- | scene/resources/curve.cpp | 18 | ||||
-rw-r--r-- | tools/editor/plugins/tile_map_editor_plugin.cpp | 79 | ||||
-rw-r--r-- | tools/editor/plugins/tile_map_editor_plugin.h | 6 |
4 files changed, 51 insertions, 55 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 45d13da828..ce79133664 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -56,6 +56,9 @@ #include "shlobj.h" static const WORD MAX_CONSOLE_LINES = 1500; +extern "C" { + _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; +} //#define STDOUT_FILE diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp index 6c27ffc6d9..7c2fa4d6f4 100644 --- a/scene/resources/curve.cpp +++ b/scene/resources/curve.cpp @@ -541,19 +541,12 @@ void Curve2D::_bake() const { Vector2 pos=points[0].pos; - int point=0; - float ofs=0; List<Vector2> pointlist; for(int i=0;i<points.size()-1;i++) { - float slen=points[i].pos.distance_to(points[i+1].pos); - float divs = slen / bake_interval; - if (divs>1) - divs=1; - - float step = divs*0.1; // 10 substeps ought to be enough? + float step = 0.1; // at least 10 substeps ought to be enough? float p = 0; while(p<1.0) { @@ -1014,19 +1007,12 @@ void Curve3D::_bake() const { Vector3 pos=points[0].pos; - int point=0; - float ofs=0; List<Plane> pointlist; pointlist.push_back(Plane(pos,points[0].tilt)); for(int i=0;i<points.size()-1;i++) { - float slen=points[i].pos.distance_to(points[i+1].pos); - float divs = slen / bake_interval; - if (divs>1) - divs=1; - - float step = divs*0.1; // 10 substeps ought to be enough? + float step = 0.1; // at least 10 substeps ought to be enough? float p = 0; while(p<1.0) { diff --git a/tools/editor/plugins/tile_map_editor_plugin.cpp b/tools/editor/plugins/tile_map_editor_plugin.cpp index a7e6a0d1f9..ce5ea58124 100644 --- a/tools/editor/plugins/tile_map_editor_plugin.cpp +++ b/tools/editor/plugins/tile_map_editor_plugin.cpp @@ -73,6 +73,18 @@ int TileMapEditor::get_selected_tile() const { return item->get_metadata(0); } +void TileMapEditor::set_selected_tile(int p_tile) { + TreeItem *item = palette->get_root()->get_children(); + while (item) { + if ((int)item->get_metadata(0) == p_tile) { + item->select(0); + palette->ensure_cursor_is_visible(); + break; + } + item = item->get_next(); + } +} + void TileMapEditor::_set_cell(const Point2i& p_pos,int p_value,bool p_flip_h, bool p_flip_v,bool p_with_undo) { ERR_FAIL_COND(!node); @@ -224,28 +236,25 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) { canvas_item_editor->update(); return true; + } else if (mb.mod.control) { + tool=TOOL_PICKING; + set_selected_tile(node->get_cell(over_tile.x, over_tile.y)); + canvas_item_editor->update(); + return true; } else { int id = get_selected_tile(); if (id!=TileMap::INVALID_CELL) { tool=TOOL_PAINTING; Point2i local =node->world_to_map((xform_inv.xform(Point2(mb.x,mb.y)))); paint_undo.clear(); - CellOp op; - op.idx = node->get_cell(local.x,local.y); - if (op.idx>=0) { - if (node->is_cell_x_flipped(local.x,local.y)) - op.xf=true; - if (node->is_cell_y_flipped(local.x,local.y)) - op.yf=true; - } - paint_undo[local]=op; + paint_undo[local]=_get_op_from_cell(local); node->set_cell(local.x,local.y,id,mirror_x->is_pressed(),mirror_y->is_pressed()); return true; } } } else { - if (tool==TOOL_PAINTING || tool == TOOL_SELECTING) { + if (tool==TOOL_PAINTING || tool == TOOL_SELECTING || tool == TOOL_PICKING) { if (tool==TOOL_PAINTING) { @@ -279,15 +288,7 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) { tool=TOOL_ERASING; Point2i local =node->world_to_map(xform_inv.xform(Point2(mb.x,mb.y))); paint_undo.clear(); - CellOp op; - op.idx = node->get_cell(local.x,local.y); - if (op.idx>=0) { - if (node->is_cell_x_flipped(local.x,local.y)) - op.xf=true; - if (node->is_cell_y_flipped(local.x,local.y)) - op.yf=true; - } - paint_undo[local]=op; + paint_undo[local]=_get_op_from_cell(local); //node->set_cell(local.x,local.y,id,mirror_x->is_pressed(),mirror_y->is_pressed()); //return true; _set_cell(local,TileMap::INVALID_CELL); @@ -337,15 +338,7 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) { if (!paint_undo.has(over_tile)) { - CellOp op; - op.idx = node->get_cell(over_tile.x,over_tile.y); - if (op.idx>=0) { - if (node->is_cell_x_flipped(over_tile.x,over_tile.y)) - op.xf=true; - if (node->is_cell_y_flipped(over_tile.x,over_tile.y)) - op.yf=true; - } - paint_undo[over_tile]=op; + paint_undo[over_tile]=_get_op_from_cell(over_tile); } node->set_cell(over_tile.x,over_tile.y,id,mirror_x->is_pressed(),mirror_y->is_pressed()); @@ -374,25 +367,22 @@ bool TileMapEditor::forward_input_event(const InputEvent& p_event) { return true; } + if (tool==TOOL_ERASING) { Point2i local =over_tile; if (!paint_undo.has(over_tile)) { - - CellOp op; - op.idx = node->get_cell(over_tile.x,over_tile.y); - if (op.idx>=0) { - if (node->is_cell_x_flipped(over_tile.x,over_tile.y)) - op.xf=true; - if (node->is_cell_y_flipped(over_tile.x,over_tile.y)) - op.yf=true; - } - paint_undo[over_tile]=op; + paint_undo[over_tile]=_get_op_from_cell(over_tile); } //node->set_cell(over_tile.x,over_tile.y,id,mirror_x->is_pressed(),mirror_y->is_pressed()); _set_cell(local,TileMap::INVALID_CELL); return true; } + if (tool==TOOL_PICKING) { + set_selected_tile(node->get_cell(over_tile.x, over_tile.y)); + canvas_item_editor->update(); + return true; + } } break; case InputEvent::KEY: { @@ -710,6 +700,19 @@ void TileMapEditor::_bind_methods() { } +TileMapEditor::CellOp TileMapEditor::_get_op_from_cell(const Point2i& p_pos) +{ + CellOp op; + op.idx = node->get_cell(p_pos.x,p_pos.y); + if (op.idx>=0) { + if (node->is_cell_x_flipped(p_pos.x,p_pos.y)) + op.xf=true; + if (node->is_cell_y_flipped(p_pos.x,p_pos.y)) + op.yf=true; + } + return op; +} + TileMapEditor::TileMapEditor(EditorNode *p_editor) { node=NULL; diff --git a/tools/editor/plugins/tile_map_editor_plugin.h b/tools/editor/plugins/tile_map_editor_plugin.h index ef869591bd..f3c590e228 100644 --- a/tools/editor/plugins/tile_map_editor_plugin.h +++ b/tools/editor/plugins/tile_map_editor_plugin.h @@ -51,7 +51,8 @@ class TileMapEditor : public VBoxContainer { TOOL_PAINTING, TOOL_SELECTING, TOOL_ERASING, - TOOL_DUPLICATING + TOOL_DUPLICATING, + TOOL_PICKING }; Tool tool; @@ -81,11 +82,13 @@ class TileMapEditor : public VBoxContainer { bool xf; bool yf; CellOp() { idx=-1; xf=false; yf=false; } + CellOp(const CellOp& p_other) : idx(p_other.idx), xf(p_other.xf), yf(p_other.yf) {} }; Map<Point2i,CellOp> paint_undo; int get_selected_tile() const; + void set_selected_tile(int p_tile); void _update_palette(); void _canvas_draw(); @@ -102,6 +105,7 @@ protected: void _notification(int p_what); void _node_removed(Node *p_node); static void _bind_methods(); + CellOp _get_op_from_cell(const Point2i& p_pos); public: HBoxContainer *get_canvas_item_editor_hb() const { return canvas_item_editor_hb; } |