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 | ||||
-rw-r--r-- | tools/export/blender25/godot_export_manager.py | 65 |
5 files changed, 101 insertions, 70 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; } diff --git a/tools/export/blender25/godot_export_manager.py b/tools/export/blender25/godot_export_manager.py index a5df60e47d..31db2c9e94 100644 --- a/tools/export/blender25/godot_export_manager.py +++ b/tools/export/blender25/godot_export_manager.py @@ -101,6 +101,7 @@ class godot_export_manager(bpy.types.Panel): row = layout.row()
col = row.column()
+ col.prop(group,"use_include_particle_duplicates")
col.prop(group,"use_mesh_modifiers")
col.prop(group,"use_tangent_arrays")
col.prop(group,"use_triangles")
@@ -134,6 +135,8 @@ class add_objects_to_group(bpy.types.Operator): bl_label = "Add Objects to Group"
bl_description = "Adds the selected Objects to the active group below."
+ undo = BoolProperty(default=True)
+
def execute(self,context):
scene = context.scene
@@ -150,7 +153,8 @@ class add_objects_to_group(bpy.types.Operator): self.report({'INFO'}, objects_str + " added to group." )
- bpy.ops.ed.undo_push(message="Objects added to group")
+ if self.undo:
+ bpy.ops.ed.undo_push(message="Objects added to group")
else:
self.report({'WARNING'}, "Create a group first." )
return{'FINISHED'}
@@ -228,11 +232,11 @@ class export_all_groups(bpy.types.Operator): def execute(self,context):
scene = context.scene
- for i in range(len(scene.godot_export_groups)):
- if scene.godot_export_groups[i].active:
- bpy.ops.scene.godot_export_group(idx=i)
+
+ for i in range(0,len(scene.godot_export_groups)):
+ bpy.ops.scene.godot_export_group(idx=i,export_all=True)
+
self.report({'INFO'}, "All Groups exported." )
- bpy.ops.ed.undo_push(message="Export all Groups")
return{'FINISHED'}
@@ -242,6 +246,8 @@ class export_group(bpy.types.Operator): bl_description = "Exports the active group to destination folder as Collada file."
idx = IntProperty(default=0)
+ export_all = BoolProperty(default=False)
+
def copy_object_recursive(self,ob,parent,single_user = True):
new_ob = bpy.data.objects[ob.name].copy()
@@ -280,9 +286,20 @@ class export_group(bpy.types.Operator): self.delete_object(group)
def execute(self,context):
+
scene = context.scene
group = context.scene.godot_export_groups
+ if not group[self.idx].active and self.export_all:
+ return{'FINISHED'}
+
+ for i,object in enumerate(group[self.idx].nodes):
+ if object.name in bpy.data.objects:
+ pass
+ else:
+ group[self.idx].nodes.remove(i)
+ bpy.ops.ed.undo_push(message="Clear not existent Group Nodes.")
+
path = group[self.idx].export_path
if (path.find("//")==0 or path.find("\\\\")==0):
#if relative, convert to absolute
@@ -307,25 +324,42 @@ class export_group(bpy.types.Operator): object.select = False
context.scene.objects.active = None
- for i,object in enumerate(group[self.idx].nodes):
-
- if object.name in bpy.data.objects:
- if bpy.data.objects[object.name].type == "EMPTY":
- self.convert_group_to_node(bpy.data.objects[object.name])
- else:
+ ### make particle duplicates, parent and select them
+ nodes_to_be_added = []
+ if group[self.idx].use_include_particle_duplicates:
+ for i,object in enumerate(group[self.idx].nodes):
+ if bpy.data.objects[object.name].type != "EMPTY":
+ context.scene.objects.active = bpy.data.objects[object.name]
bpy.data.objects[object.name].select = True
+ bpy.ops.object.duplicates_make_real()
+ for object in context.selected_objects:
+ nodes_to_be_added.append(object)
+ bpy.ops.object.parent_set(type="OBJECT", keep_transform=False)
- else: # if object is not in the scene anymore it will be removed from the group
- group[self.idx].nodes.remove(i)
+ for object in context.selected_objects:
+ object.select = False
+ bpy.data.objects[object.name].select = False
+ context.scene.objects.active = None
+ for object in nodes_to_be_added:
+ object.select = True
+
+ ### select all other nodes from the group
+ for i,object in enumerate(group[self.idx].nodes):
+ if bpy.data.objects[object.name].type == "EMPTY":
+ self.convert_group_to_node(bpy.data.objects[object.name])
+ else:
+ bpy.data.objects[object.name].select = True
+
bpy.ops.object.transform_apply(location=group[self.idx].apply_loc, rotation=group[self.idx].apply_rot, scale=group[self.idx].apply_scale)
bpy.ops.export_scene.dae(check_existing=True, filepath=path, filter_glob="*.dae", object_types=group[self.idx].object_types, use_export_selected=group[self.idx].use_export_selected, use_mesh_modifiers=group[self.idx].use_mesh_modifiers, use_tangent_arrays=group[self.idx].use_tangent_arrays, use_triangles=group[self.idx].use_triangles, use_copy_images=group[self.idx].use_copy_images, use_active_layers=group[self.idx].use_active_layers, use_exclude_ctrl_bones=group[self.idx].use_exclude_ctrl_bones, use_anim=group[self.idx].use_anim, use_anim_action_all=group[self.idx].use_anim_action_all, use_anim_skip_noexp=group[self.idx].use_anim_skip_noexp, use_anim_optimize=group[self.idx].use_anim_optimize, anim_optimize_precision=group[self.idx].anim_optimize_precision, use_metadata=group[self.idx].use_metadata)
-
self.report({'INFO'}, '"'+group[self.idx].name+'"' + " Group exported." )
msg = "Export Group "+group[self.idx].name
+
bpy.ops.ed.undo_push(message="")
bpy.ops.ed.undo()
bpy.ops.ed.undo_push(message=msg)
+
else:
self.report({'INFO'}, "Define Export Name and Export Path." )
return{'FINISHED'}
@@ -397,6 +431,7 @@ class godot_export_groups(bpy.types.PropertyGroup): anim_optimize_precision = FloatProperty(name="Precision",description=("Tolerence for comparing double keyframes (higher for greater accuracy)"),min=1, max=16,soft_min=1, soft_max=16,default=6.0)
use_metadata = BoolProperty(name="Use Metadata",default=True,options={'HIDDEN'})
+ use_include_particle_duplicates = BoolProperty(name="Include Particle Duplicates",default=True)
def register():
bpy.utils.register_class(godot_export_manager)
@@ -426,7 +461,7 @@ def unregister(): bpy.utils.unregister_class(export_group)
bpy.utils.unregister_class(add_objects_to_group)
bpy.utils.unregister_class(del_objects_from_group)
- bpy.utils.unlregister_class(select_group_objects)
+ bpy.utils.unregister_class(select_group_objects)
bpy.utils.unregister_class(UI_List_Godot)
@persistent
|