diff options
Diffstat (limited to 'modules/gridmap')
| -rw-r--r-- | modules/gridmap/SCsub | 6 | ||||
| -rw-r--r-- | modules/gridmap/config.py | 8 | ||||
| -rw-r--r-- | modules/gridmap/grid_map.cpp | 149 | ||||
| -rw-r--r-- | modules/gridmap/grid_map.h | 8 | ||||
| -rw-r--r-- | modules/gridmap/grid_map_editor_plugin.cpp | 140 | ||||
| -rw-r--r-- | modules/gridmap/grid_map_editor_plugin.h | 7 | ||||
| -rw-r--r-- | modules/gridmap/register_types.cpp | 4 | ||||
| -rw-r--r-- | modules/gridmap/register_types.h | 2 |
8 files changed, 164 insertions, 160 deletions
diff --git a/modules/gridmap/SCsub b/modules/gridmap/SCsub index 211a043468..0882406761 100644 --- a/modules/gridmap/SCsub +++ b/modules/gridmap/SCsub @@ -1,3 +1,7 @@ +#!/usr/bin/env python + Import('env') -env.add_source_files(env.modules_sources,"*.cpp") +env.add_source_files(env.modules_sources, "*.cpp") + +Export('env') diff --git a/modules/gridmap/config.py b/modules/gridmap/config.py index ea7e83378a..1ab13c4aeb 100644 --- a/modules/gridmap/config.py +++ b/modules/gridmap/config.py @@ -1,11 +1,9 @@ def can_build(platform): - return True + # FIXME: Disabled temporary for gles3 implementation + return False def configure(env): - pass - - - + pass diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index 503e723de2..271db4babc 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -61,9 +61,9 @@ bool GridMap::_set(const StringName& p_name, const Variant& p_value) { } else if (name=="theme/bake") { set_bake(p_value); /* } else if (name=="cells") { - DVector<int> cells = p_value; + PoolVector<int> cells = p_value; int amount=cells.size(); - DVector<int>::Read r = cells.read(); + PoolVector<int>::Read r = cells.read(); ERR_FAIL_COND_V(amount&1,false); // not even cell_map.clear();; for(int i=0;i<amount/3;i++) { @@ -86,9 +86,9 @@ bool GridMap::_set(const StringName& p_name, const Variant& p_value) { baked=d["baked"]; if (d.has("cells")) { - DVector<int> cells = d["cells"]; + PoolVector<int> cells = d["cells"]; int amount=cells.size(); - DVector<int>::Read r = cells.read(); + PoolVector<int>::Read r = cells.read(); ERR_FAIL_COND_V(amount%3,false); // not even cell_map.clear();; for(int i=0;i<amount/3;i++) { @@ -183,10 +183,10 @@ bool GridMap::_get(const StringName& p_name,Variant &r_ret) const { Dictionary d; - DVector<int> cells; + PoolVector<int> cells; cells.resize(cell_map.size()*3); { - DVector<int>::Write w = cells.write(); + PoolVector<int>::Write w = cells.write(); int i=0; for (Map<IndexKey,Cell>::Element *E=cell_map.front();E;E=E->next(),i++) { @@ -252,7 +252,7 @@ void GridMap::_get_property_list( List<PropertyInfo> *p_list) const { for(const Map<int,Area*>::Element *E=area_map.front();E;E=E->next()) { String base="areas/"+itos(E->key())+"/"; - p_list->push_back( PropertyInfo( Variant::_AABB, base+"bounds", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_STORAGE) ); + p_list->push_back( PropertyInfo( Variant::RECT3, base+"bounds", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_STORAGE) ); p_list->push_back( PropertyInfo( Variant::STRING, base+"name", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_STORAGE) ); p_list->push_back( PropertyInfo( Variant::REAL, base+"disable_distance", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_STORAGE) ); p_list->push_back( PropertyInfo( Variant::COLOR, base+"disable_color", PROPERTY_HINT_NONE,"",PROPERTY_USAGE_STORAGE) ); @@ -665,7 +665,7 @@ void GridMap::_octant_update(const OctantKey &p_key) { VS::get_singleton()->mesh_clear(g.collision_debug); } - DVector<Vector3> col_debug; + PoolVector<Vector3> col_debug; /* * foreach item in this octant, @@ -678,8 +678,8 @@ void GridMap::_octant_update(const OctantKey &p_key) { ii.multimesh->set_instance_count(ii.cells.size()); - AABB aabb; - AABB mesh_aabb = ii.mesh.is_null()?AABB():ii.mesh->get_aabb(); + Rect3 aabb; + Rect3 mesh_aabb = ii.mesh.is_null()?Rect3():ii.mesh->get_aabb(); Vector3 ofs(cell_size*0.5*int(center_x),cell_size*0.5*int(center_y),cell_size*0.5*int(center_z)); @@ -731,7 +731,7 @@ void GridMap::_octant_update(const OctantKey &p_key) { ii.shape->add_vertices_to_array(col_debug,xform); } - // print_line("PHIS x: "+xform); + //print_line("PHIS x: "+xform); } // add the item's navmesh at given xform to GridMap's Navigation ancestor @@ -796,7 +796,7 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) { for(Map<int,Octant::ItemInstances>::Element *E=g.items.front();E;E=E->next()) { VS::get_singleton()->instance_set_scenario(E->get().multimesh_instance,RID()); - // VS::get_singleton()->instance_set_transform(E->get().multimesh_instance,get_global_transform()); + //VS::get_singleton()->instance_set_transform(E->get().multimesh_instance,get_global_transform()); VS::get_singleton()->instance_set_room(E->get().multimesh_instance,RID()); } @@ -863,15 +863,15 @@ void GridMap::_octant_bake(const OctantKey &p_key, const Ref<TriangleMesh>& p_tm if (ii.mesh->surface_get_primitive_type(i)!=Mesh::PRIMITIVE_TRIANGLES) continue; Array a = ii.mesh->surface_get_arrays(i); - DVector<Vector3> av=a[VS::ARRAY_VERTEX]; + PoolVector<Vector3> av=a[VS::ARRAY_VERTEX]; int avs = av.size(); - DVector<Vector3>::Read vr = av.read(); + PoolVector<Vector3>::Read vr = av.read(); - DVector<int> ai=a[VS::ARRAY_INDEX]; + PoolVector<int> ai=a[VS::ARRAY_INDEX]; int ais=ai.size(); if (ais) { - DVector<int>::Read ir=ai.read(); + PoolVector<int>::Read ir=ai.read(); for(int j=0;j<ais;j++) { p_prebake->push_back(xform.xform(vr[ir[j]])); @@ -912,7 +912,6 @@ void GridMap::_octant_bake(const OctantKey &p_key, const Ref<TriangleMesh>& p_tm int lc = p_lights.size(); const BakeLight* bl = p_lights.ptr(); float ofs = cell_size*0.02; - float att = 0.2; for(;V;V=V->next()) { @@ -921,7 +920,7 @@ void GridMap::_octant_bake(const OctantKey &p_key, const Ref<TriangleMesh>& p_tm Vector3 vertex = v.vertex + octant_ofs; //print_line("V GET: "+vertex); - Vector3 normal = tm->get_area_normal( AABB( Vector3(-ofs,-ofs,-ofs)+vertex,Vector3(ofs,ofs,ofs)*2.0)); + Vector3 normal = tm->get_area_normal( Rect3( Vector3(-ofs,-ofs,-ofs)+vertex,Vector3(ofs,ofs,ofs)*2.0)); if (normal==Vector3()) { print_line("couldn't find for vertex: "+vertex); } @@ -961,9 +960,9 @@ void GridMap::_octant_bake(const OctantKey &p_key, const Ref<TriangleMesh>& p_tm st->add_to_format(VS::ARRAY_FORMAT_COLOR); if (m.is_valid()) { - Ref<FixedMaterial> fm = m; + Ref<FixedSpatialMaterial> fm = m; if (fm.is_valid()) - fm->set_fixed_flag(FixedMaterial::FLAG_USE_COLOR_ARRAY,true); + fm->set_fixed_flag(FixedSpatialMaterial::FLAG_USE_COLOR_ARRAY,true); } } } @@ -1002,8 +1001,8 @@ void GridMap::_notification(int p_what) { _update_area_instances(); for(Map<OctantKey,Octant*>::Element *E=octant_map.front();E;E=E->next()) { -// IndexKey ik; -// ik.key = E->key().indexkey; + //IndexKey ik; + //ik.key = E->key().indexkey; _octant_enter_world(E->key()); _octant_update(E->key()); } @@ -1186,60 +1185,60 @@ void GridMap::_update_dirty_map_callback() { void GridMap::_bind_methods() { - ObjectTypeDB::bind_method(_MD("set_theme","theme:MeshLibrary"),&GridMap::set_theme); - ObjectTypeDB::bind_method(_MD("get_theme:MeshLibrary"),&GridMap::get_theme); + ClassDB::bind_method(_MD("set_theme","theme:MeshLibrary"),&GridMap::set_theme); + ClassDB::bind_method(_MD("get_theme:MeshLibrary"),&GridMap::get_theme); - ObjectTypeDB::bind_method(_MD("set_bake","enable"),&GridMap::set_bake); - ObjectTypeDB::bind_method(_MD("is_baking_enabled"),&GridMap::is_baking_enabled); + ClassDB::bind_method(_MD("set_bake","enable"),&GridMap::set_bake); + ClassDB::bind_method(_MD("is_baking_enabled"),&GridMap::is_baking_enabled); - ObjectTypeDB::bind_method(_MD("set_cell_size","size"),&GridMap::set_cell_size); - ObjectTypeDB::bind_method(_MD("get_cell_size"),&GridMap::get_cell_size); + ClassDB::bind_method(_MD("set_cell_size","size"),&GridMap::set_cell_size); + ClassDB::bind_method(_MD("get_cell_size"),&GridMap::get_cell_size); - ObjectTypeDB::bind_method(_MD("set_octant_size","size"),&GridMap::set_octant_size); - ObjectTypeDB::bind_method(_MD("get_octant_size"),&GridMap::get_octant_size); + ClassDB::bind_method(_MD("set_octant_size","size"),&GridMap::set_octant_size); + ClassDB::bind_method(_MD("get_octant_size"),&GridMap::get_octant_size); - ObjectTypeDB::bind_method(_MD("set_cell_item","x","y","z","item","orientation"),&GridMap::set_cell_item,DEFVAL(0)); - ObjectTypeDB::bind_method(_MD("get_cell_item","x","y","z"),&GridMap::get_cell_item); - ObjectTypeDB::bind_method(_MD("get_cell_item_orientation","x","y","z"),&GridMap::get_cell_item_orientation); + ClassDB::bind_method(_MD("set_cell_item","x","y","z","item","orientation"),&GridMap::set_cell_item,DEFVAL(0)); + ClassDB::bind_method(_MD("get_cell_item","x","y","z"),&GridMap::get_cell_item); + ClassDB::bind_method(_MD("get_cell_item_orientation","x","y","z"),&GridMap::get_cell_item_orientation); -// ObjectTypeDB::bind_method(_MD("_recreate_octants"),&GridMap::_recreate_octants); - ObjectTypeDB::bind_method(_MD("_update_dirty_map_callback"),&GridMap::_update_dirty_map_callback); - ObjectTypeDB::bind_method(_MD("resource_changed","resource"),&GridMap::resource_changed); + //ClassDB::bind_method(_MD("_recreate_octants"),&GridMap::_recreate_octants); + ClassDB::bind_method(_MD("_update_dirty_map_callback"),&GridMap::_update_dirty_map_callback); + ClassDB::bind_method(_MD("resource_changed","resource"),&GridMap::resource_changed); - ObjectTypeDB::bind_method(_MD("set_center_x","enable"),&GridMap::set_center_x); - ObjectTypeDB::bind_method(_MD("get_center_x"),&GridMap::get_center_x); - ObjectTypeDB::bind_method(_MD("set_center_y","enable"),&GridMap::set_center_y); - ObjectTypeDB::bind_method(_MD("get_center_y"),&GridMap::get_center_y); - ObjectTypeDB::bind_method(_MD("set_center_z","enable"),&GridMap::set_center_z); - ObjectTypeDB::bind_method(_MD("get_center_z"),&GridMap::get_center_z); + ClassDB::bind_method(_MD("set_center_x","enable"),&GridMap::set_center_x); + ClassDB::bind_method(_MD("get_center_x"),&GridMap::get_center_x); + ClassDB::bind_method(_MD("set_center_y","enable"),&GridMap::set_center_y); + ClassDB::bind_method(_MD("get_center_y"),&GridMap::get_center_y); + ClassDB::bind_method(_MD("set_center_z","enable"),&GridMap::set_center_z); + ClassDB::bind_method(_MD("get_center_z"),&GridMap::get_center_z); - ObjectTypeDB::bind_method(_MD("set_clip","enabled","clipabove","floor","axis"),&GridMap::set_clip,DEFVAL(true),DEFVAL(0),DEFVAL(Vector3::AXIS_X)); + ClassDB::bind_method(_MD("set_clip","enabled","clipabove","floor","axis"),&GridMap::set_clip,DEFVAL(true),DEFVAL(0),DEFVAL(Vector3::AXIS_X)); - ObjectTypeDB::bind_method(_MD("create_area","id","area"),&GridMap::create_area); - ObjectTypeDB::bind_method(_MD("area_get_bounds","area","bounds"),&GridMap::area_get_bounds); - ObjectTypeDB::bind_method(_MD("area_set_exterior_portal","area","enable"),&GridMap::area_set_exterior_portal); - ObjectTypeDB::bind_method(_MD("area_set_name","area","name"),&GridMap::area_set_name); - ObjectTypeDB::bind_method(_MD("area_get_name","area"),&GridMap::area_get_name); - ObjectTypeDB::bind_method(_MD("area_is_exterior_portal","area"),&GridMap::area_is_exterior_portal); - ObjectTypeDB::bind_method(_MD("area_set_portal_disable_distance","area","distance"),&GridMap::area_set_portal_disable_distance); - ObjectTypeDB::bind_method(_MD("area_get_portal_disable_distance","area"),&GridMap::area_get_portal_disable_distance); - ObjectTypeDB::bind_method(_MD("area_set_portal_disable_color","area","color"),&GridMap::area_set_portal_disable_color); - ObjectTypeDB::bind_method(_MD("area_get_portal_disable_color","area"),&GridMap::area_get_portal_disable_color); - ObjectTypeDB::bind_method(_MD("erase_area","area"),&GridMap::erase_area); - ObjectTypeDB::bind_method(_MD("get_unused_area_id","area"),&GridMap::get_unused_area_id); - ObjectTypeDB::bind_method(_MD("bake_geometry"),&GridMap::bake_geometry); + ClassDB::bind_method(_MD("create_area","id","area"),&GridMap::create_area); + ClassDB::bind_method(_MD("area_get_bounds","area","bounds"),&GridMap::area_get_bounds); + ClassDB::bind_method(_MD("area_set_exterior_portal","area","enable"),&GridMap::area_set_exterior_portal); + ClassDB::bind_method(_MD("area_set_name","area","name"),&GridMap::area_set_name); + ClassDB::bind_method(_MD("area_get_name","area"),&GridMap::area_get_name); + ClassDB::bind_method(_MD("area_is_exterior_portal","area"),&GridMap::area_is_exterior_portal); + ClassDB::bind_method(_MD("area_set_portal_disable_distance","area","distance"),&GridMap::area_set_portal_disable_distance); + ClassDB::bind_method(_MD("area_get_portal_disable_distance","area"),&GridMap::area_get_portal_disable_distance); + ClassDB::bind_method(_MD("area_set_portal_disable_color","area","color"),&GridMap::area_set_portal_disable_color); + ClassDB::bind_method(_MD("area_get_portal_disable_color","area"),&GridMap::area_get_portal_disable_color); + ClassDB::bind_method(_MD("erase_area","area"),&GridMap::erase_area); + ClassDB::bind_method(_MD("get_unused_area_id","area"),&GridMap::get_unused_area_id); + ClassDB::bind_method(_MD("bake_geometry"),&GridMap::bake_geometry); - ObjectTypeDB::bind_method(_MD("_baked_light_changed"),&GridMap::_baked_light_changed); - ObjectTypeDB::bind_method(_MD("set_use_baked_light","use"),&GridMap::set_use_baked_light); - ObjectTypeDB::bind_method(_MD("is_using_baked_light","use"),&GridMap::is_using_baked_light); + ClassDB::bind_method(_MD("_baked_light_changed"),&GridMap::_baked_light_changed); + ClassDB::bind_method(_MD("set_use_baked_light","use"),&GridMap::set_use_baked_light); + ClassDB::bind_method(_MD("is_using_baked_light","use"),&GridMap::is_using_baked_light); - ObjectTypeDB::bind_method(_MD("_get_baked_light_meshes"),&GridMap::_get_baked_light_meshes); + ClassDB::bind_method(_MD("_get_baked_light_meshes"),&GridMap::_get_baked_light_meshes); - ObjectTypeDB::set_method_flags("GridMap","bake_geometry",METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR); + ClassDB::set_method_flags("GridMap","bake_geometry",METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR); - ObjectTypeDB::bind_method(_MD("clear"),&GridMap::clear); + ClassDB::bind_method(_MD("clear"),&GridMap::clear); BIND_CONSTANT( INVALID_CELL_ITEM ); @@ -1436,7 +1435,7 @@ void GridMap::_update_area_instances() { } -Error GridMap::create_area(int p_id,const AABB& p_bounds) { +Error GridMap::create_area(int p_id,const Rect3& p_bounds) { ERR_FAIL_COND_V(area_map.has(p_id),ERR_ALREADY_EXISTS); ERR_EXPLAIN("ID 0 is taken as global area, start from 1"); @@ -1485,12 +1484,12 @@ Error GridMap::create_area(int p_id,const AABB& p_bounds) { return OK; } -AABB GridMap::area_get_bounds(int p_area) const { +Rect3 GridMap::area_get_bounds(int p_area) const { - ERR_FAIL_COND_V(!area_map.has(p_area),AABB()); + ERR_FAIL_COND_V(!area_map.has(p_area),Rect3()); const Area *a = area_map[p_area]; - AABB aabb; + Rect3 aabb; aabb.pos=Vector3(a->from.x,a->from.y,a->from.z); aabb.size=Vector3(a->to.x,a->to.y,a->to.z)-aabb.pos; @@ -1668,7 +1667,7 @@ void GridMap::bake_geometry() { } - DVector<Vector3> vv; + PoolVector<Vector3> vv; vv.fill_with(vertices); //print_line("TOTAL VERTICES: "+itos(vv.size())); tmesh = Ref<TriangleMesh>( memnew( TriangleMesh )); @@ -1707,10 +1706,12 @@ void GridMap::bake_geometry() { void GridMap::_baked_light_changed() { -// if (!baked_light_instance) -// VS::get_singleton()->instance_geometry_set_baked_light(get_instance(),RID()); -// else -// VS::get_singleton()->instance_geometry_set_baked_light(get_instance(),baked_light_instance->get_baked_light_instance()); + /* + if (!baked_light_instance) + VS::get_singleton()->instance_geometry_set_baked_light(get_instance(),RID()); + else + VS::get_singleton()->instance_geometry_set_baked_light(get_instance(),baked_light_instance->get_baked_light_instance()); + */ for(Map<OctantKey,Octant*>::Element *E=octant_map.front();E;E=E->next()) { for(Map<int,Octant::ItemInstances>::Element *F=E->get()->items.front();F;F=F->next()) { @@ -1809,6 +1810,7 @@ bool GridMap::is_using_baked_light() const{ } + GridMap::GridMap() { cell_size=2; @@ -1830,7 +1832,8 @@ GridMap::GridMap() { baked_light_instance=NULL; use_baked_light=false; - + navigation = NULL; + set_notify_transform(true); } diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h index 0116ea094f..04d140cdc6 100644 --- a/modules/gridmap/grid_map.h +++ b/modules/gridmap/grid_map.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -44,7 +44,7 @@ class BakedLightInstance; class GridMap : public Spatial { - OBJ_TYPE( GridMap, Spatial ); + GDCLASS( GridMap, Spatial ); enum { MAP_DIRTY_TRANSFORMS=1, @@ -268,8 +268,8 @@ public: void set_clip(bool p_enabled, bool p_clip_above=true, int p_floor=0, Vector3::Axis p_axis=Vector3::AXIS_X); - Error create_area(int p_id,const AABB& p_area); - AABB area_get_bounds(int p_area) const; + Error create_area(int p_id,const Rect3& p_area); + Rect3 area_get_bounds(int p_area) const; void area_set_exterior_portal(int p_area,bool p_enable); void area_set_name(int p_area,const String& p_name); String area_get_name(int p_area) const; diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 87afe3d5a4..109f6338db 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -99,70 +99,70 @@ void GridMapEditor::_menu_option(int p_option) { } break; case MENU_OPTION_CURSOR_ROTATE_Y: { - Matrix3 r; + Basis r; if (input_action==INPUT_DUPLICATE) { r.set_orthogonal_index(selection.duplicate_rot); - r.rotate(Vector3(0,1,0),Math_PI/2.0); + r.rotate(Vector3(0,1,0),-Math_PI/2.0); selection.duplicate_rot=r.get_orthogonal_index(); _update_duplicate_indicator(); break; } r.set_orthogonal_index(cursor_rot); - r.rotate(Vector3(0,1,0),Math_PI/2.0); + r.rotate(Vector3(0,1,0),-Math_PI/2.0); cursor_rot=r.get_orthogonal_index(); _update_cursor_transform(); } break; case MENU_OPTION_CURSOR_ROTATE_X: { - Matrix3 r; + Basis r; if (input_action==INPUT_DUPLICATE) { r.set_orthogonal_index(selection.duplicate_rot); - r.rotate(Vector3(1,0,0),Math_PI/2.0); + r.rotate(Vector3(1,0,0),-Math_PI/2.0); selection.duplicate_rot=r.get_orthogonal_index(); _update_duplicate_indicator(); break; } r.set_orthogonal_index(cursor_rot); - r.rotate(Vector3(1,0,0),Math_PI/2.0); + r.rotate(Vector3(1,0,0),-Math_PI/2.0); cursor_rot=r.get_orthogonal_index(); _update_cursor_transform(); } break; case MENU_OPTION_CURSOR_ROTATE_Z: { - Matrix3 r; + Basis r; if (input_action==INPUT_DUPLICATE) { r.set_orthogonal_index(selection.duplicate_rot); - r.rotate(Vector3(0,0,1),Math_PI/2.0); + r.rotate(Vector3(0,0,1),-Math_PI/2.0); selection.duplicate_rot=r.get_orthogonal_index(); _update_duplicate_indicator(); break; } r.set_orthogonal_index(cursor_rot); - r.rotate(Vector3(0,0,1),Math_PI/2.0); + r.rotate(Vector3(0,0,1),-Math_PI/2.0); cursor_rot=r.get_orthogonal_index(); _update_cursor_transform(); } break; case MENU_OPTION_CURSOR_BACK_ROTATE_Y: { - Matrix3 r; + Basis r; r.set_orthogonal_index(cursor_rot); - r.rotate(Vector3(0,1,0),-Math_PI/2.0); + r.rotate(Vector3(0,1,0),Math_PI/2.0); cursor_rot=r.get_orthogonal_index(); _update_cursor_transform(); } break; case MENU_OPTION_CURSOR_BACK_ROTATE_X: { - Matrix3 r; + Basis r; r.set_orthogonal_index(cursor_rot); - r.rotate(Vector3(1,0,0),-Math_PI/2.0); + r.rotate(Vector3(1,0,0),Math_PI/2.0); cursor_rot=r.get_orthogonal_index(); _update_cursor_transform(); } break; case MENU_OPTION_CURSOR_BACK_ROTATE_Z: { - Matrix3 r; + Basis r; r.set_orthogonal_index(cursor_rot); - r.rotate(Vector3(0,0,1),-Math_PI/2.0); + r.rotate(Vector3(0,0,1),Math_PI/2.0); cursor_rot=r.get_orthogonal_index(); _update_cursor_transform(); } break; @@ -191,7 +191,7 @@ void GridMapEditor::_menu_option(int p_option) { if (!selection.active) break; int area = node->get_unused_area_id(); - Error err = node->create_area(area,AABB(selection.begin,selection.end-selection.begin+Vector3(1,1,1))); + Error err = node->create_area(area,Rect3(selection.begin,selection.end-selection.begin+Vector3(1,1,1))); if (err!=OK) { @@ -212,6 +212,18 @@ void GridMapEditor::_menu_option(int p_option) { _update_areas_display(); update_areas(); } break; + case MENU_OPTION_SELECTION_DUPLICATE: + if (!(selection.active && input_action==INPUT_NONE)) + return; + if (last_mouseover==Vector3(-1,-1,-1)) //nono mouseovering anythin + break; + + input_action=INPUT_DUPLICATE; + selection.click=last_mouseover; + selection.current=last_mouseover; + selection.duplicate_rot=0; + _update_duplicate_indicator(); + break; case MENU_OPTION_SELECTION_CLEAR: { if (!selection.active) return; @@ -306,7 +318,7 @@ bool GridMapEditor::do_input_action(Camera* p_camera,const Point2& p_point,bool p.d=edit_floor[edit_axis]*node->get_cell_size(); Vector3 inters; - if (!p.intersects_segment(from, from + normal * settings_pick_distance->get_val(), &inters)) + if (!p.intersects_segment(from, from + normal * settings_pick_distance->get_value(), &inters)) return false; @@ -346,7 +358,7 @@ bool GridMapEditor::do_input_action(Camera* p_camera,const Point2& p_point,bool } last_mouseover=Vector3(cell[0],cell[1],cell[2]); - VS::get_singleton()->instance_set_transform(grid_instance[edit_axis],Transform(Matrix3(),grid_ofs)); + VS::get_singleton()->instance_set_transform(grid_instance[edit_axis],Transform(Basis(),grid_ofs)); if (cursor_instance.is_valid()) { @@ -377,7 +389,9 @@ bool GridMapEditor::do_input_action(Camera* p_camera,const Point2& p_point,bool int item=node->get_cell_item(cell[0],cell[1],cell[2]); if (item>=0) { selected_pallete=item; + theme_pallete->set_current(item); update_pallete(); + _update_cursor_instance(); } return true; } if (input_action==INPUT_PAINT) { @@ -445,7 +459,7 @@ void GridMapEditor::_update_duplicate_indicator() { Transform xf; xf.scale(Vector3(1,1,1)*(Vector3(1,1,1)+(selection.end-selection.begin))*node->get_cell_size()); xf.origin=(selection.begin+(selection.current-selection.click))*node->get_cell_size(); - Matrix3 rot; + Basis rot; rot.set_orthogonal_index(selection.duplicate_rot); xf.basis = rot * xf.basis; @@ -467,7 +481,7 @@ void GridMapEditor::_duplicate_paste() { List< __Item > items; - Matrix3 rot; + Basis rot; rot.set_orthogonal_index(selection.duplicate_rot); for(int i=selection.begin.x;i<=selection.end.x;i++) { @@ -484,7 +498,7 @@ void GridMapEditor::_duplicate_paste() { Vector3 rel=Vector3(i,j,k)-selection.begin; rel = rot.xform(rel); - Matrix3 orm; + Basis orm; orm.set_orthogonal_index(orientation); orm = rot * orm; @@ -530,39 +544,16 @@ bool GridMapEditor::forward_spatial_input_event(Camera* p_camera,const InputEven if (edit_mode->get_selected()==0) { // regular click switch (p_event.type) { - case InputEvent::KEY: { - - if (p_event.key.pressed && p_event.key.scancode==KEY_D && p_event.key.mod.shift && selection.active && input_action==INPUT_NONE) { - - if (last_mouseover==Vector3(-1,-1,-1)) //nono mouseovering anythin - return false; - - input_action=INPUT_DUPLICATE; - selection.click=last_mouseover; - selection.current=last_mouseover; - selection.duplicate_rot=0; - _update_duplicate_indicator(); - - - } - - if (p_event.key.pressed && p_event.key.scancode==KEY_DELETE && selection.active) { - - _delete_selection(); - return true; - } - - } break; case InputEvent::MOUSE_BUTTON: { if (p_event.mouse_button.button_index==BUTTON_WHEEL_UP && (p_event.mouse_button.mod.command || p_event.mouse_button.mod.shift)) { if (p_event.mouse_button.pressed) - floor->set_val( floor->get_val() +1); + floor->set_value( floor->get_value() +1); return true; //eaten } else if (p_event.mouse_button.button_index==BUTTON_WHEEL_DOWN && (p_event.mouse_button.mod.command || p_event.mouse_button.mod.shift)) { if (p_event.mouse_button.pressed) - floor->set_val( floor->get_val() -1); + floor->set_value( floor->get_value() -1); return true; } @@ -673,7 +664,7 @@ bool GridMapEditor::forward_spatial_input_event(Camera* p_camera,const InputEven for(List<int>::Element *E=areas.front();E;E=E->next()) { int area = E->get(); - AABB aabb = node->area_get_bounds(area); + Rect3 aabb = node->area_get_bounds(area); aabb.pos*=node->get_cell_size(); aabb.size*=node->get_cell_size(); @@ -740,8 +731,8 @@ void GridMapEditor::update_pallete() { theme_pallete->set_icon_mode(ItemList::ICON_MODE_LEFT); } - float min_size = EDITOR_DEF("grid_map/preview_size",64); - theme_pallete->set_min_icon_size(Size2(min_size, min_size)); + float min_size = EDITOR_DEF("editors/grid_map/preview_size",64); + theme_pallete->set_fixed_icon_size(Size2(min_size, min_size)); theme_pallete->set_fixed_column_width(min_size*3/2); theme_pallete->set_max_text_lines(2); @@ -851,6 +842,11 @@ void GridMapEditor::edit(GridMap *p_gridmap) { VS *vs = VS::get_singleton(); last_mouseover=Vector3(-1,-1,-1); + input_action=INPUT_NONE; + selection.active=false; + _update_selection_transform(); + _update_duplicate_indicator(); + spatial_editor = editor->get_editor_plugin_screen()->cast_to<SpatialEditorPlugin>(); if (!node) { @@ -976,7 +972,7 @@ void GridMapEditor::update_grid() { grid_ofs[edit_axis]=edit_floor[edit_axis]*node->get_cell_size(); edit_grid_xform.origin=grid_ofs; - edit_grid_xform.basis=Matrix3(); + edit_grid_xform.basis=Basis(); for(int i=0;i<3;i++) { @@ -985,7 +981,7 @@ void GridMapEditor::update_grid() { } updating=true; - floor->set_val(edit_floor[edit_axis]); + floor->set_value(edit_floor[edit_axis]); updating=false; } @@ -1130,7 +1126,7 @@ void GridMapEditor::_update_areas_display() { RID mesh = VisualServer::get_singleton()->mesh_create(); - DVector<Plane> planes; + PoolVector<Plane> planes; for(int i=0;i<3;i++) { Vector3 axis; @@ -1146,7 +1142,7 @@ void GridMapEditor::_update_areas_display() { ad.mesh=mesh; ad.instance = VisualServer::get_singleton()->instance_create2(mesh,node->get_world()->get_scenario()); Transform xform; - AABB aabb = node->area_get_bounds(area); + Rect3 aabb = node->area_get_bounds(area); xform.origin=aabb.pos * node->get_cell_size(); xform.basis.scale(aabb.size * node->get_cell_size()); VisualServer::get_singleton()->instance_set_transform(ad.instance,global_xf * xform); @@ -1185,15 +1181,15 @@ void GridMapEditor::_floor_changed(float p_value) { void GridMapEditor::_bind_methods() { - ObjectTypeDB::bind_method("_menu_option",&GridMapEditor::_menu_option); - ObjectTypeDB::bind_method("_configure",&GridMapEditor::_configure); - ObjectTypeDB::bind_method("_item_selected_cbk",&GridMapEditor::_item_selected_cbk); - ObjectTypeDB::bind_method("_edit_mode_changed",&GridMapEditor::_edit_mode_changed); - ObjectTypeDB::bind_method("_area_renamed",&GridMapEditor::_area_renamed); - ObjectTypeDB::bind_method("_area_selected",&GridMapEditor::_area_selected); - ObjectTypeDB::bind_method("_floor_changed",&GridMapEditor::_floor_changed); + ClassDB::bind_method("_menu_option",&GridMapEditor::_menu_option); + ClassDB::bind_method("_configure",&GridMapEditor::_configure); + ClassDB::bind_method("_item_selected_cbk",&GridMapEditor::_item_selected_cbk); + ClassDB::bind_method("_edit_mode_changed",&GridMapEditor::_edit_mode_changed); + ClassDB::bind_method("_area_renamed",&GridMapEditor::_area_renamed); + ClassDB::bind_method("_area_selected",&GridMapEditor::_area_selected); + ClassDB::bind_method("_floor_changed",&GridMapEditor::_floor_changed); - ObjectTypeDB::bind_method(_MD("_set_display_mode","mode"), &GridMapEditor::_set_display_mode); + ClassDB::bind_method(_MD("_set_display_mode","mode"), &GridMapEditor::_set_display_mode); } @@ -1205,7 +1201,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { editor=p_editor; undo_redo=p_editor->get_undo_redo(); - int mw = EDITOR_DEF("grid_map/palette_min_width",230); + int mw = EDITOR_DEF("editors/grid_map/palette_min_width",230); Control *ec = memnew( Control); ec->set_custom_minimum_size(Size2(mw,0)); add_child(ec); @@ -1247,7 +1243,8 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { options->get_popup()->add_item("Create Exterior Connector",MENU_OPTION_SELECTION_MAKE_EXTERIOR_CONNECTOR); options->get_popup()->add_item("Erase Area",MENU_OPTION_REMOVE_AREA); options->get_popup()->add_separator(); - options->get_popup()->add_item("Selection -> Clear",MENU_OPTION_SELECTION_CLEAR); + options->get_popup()->add_item("Selection -> Duplicate",MENU_OPTION_SELECTION_DUPLICATE,KEY_MASK_SHIFT+KEY_INSERT); + options->get_popup()->add_item("Selection -> Clear",MENU_OPTION_SELECTION_CLEAR,KEY_MASK_SHIFT+KEY_DELETE); //options->get_popup()->add_separator(); //options->get_popup()->add_item("Configure",MENU_OPTION_CONFIGURE); @@ -1260,17 +1257,16 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { settings_vbc = memnew(VBoxContainer); settings_vbc->set_custom_minimum_size(Size2(200, 0)); settings_dialog->add_child(settings_vbc); - settings_dialog->set_child_rect(settings_vbc); settings_pick_distance = memnew(SpinBox); settings_pick_distance->set_max(10000.0f); settings_pick_distance->set_min(500.0f); settings_pick_distance->set_step(1.0f); - settings_pick_distance->set_val(EDITOR_DEF("gridmap_editor/pick_distance", 5000.0)); + settings_pick_distance->set_value(EDITOR_DEF("editors/grid_map/pick_distance", 5000.0)); settings_vbc->add_margin_child("Pick Distance:", settings_pick_distance); clip_mode=CLIP_DISABLED; - options->get_popup()->connect("item_pressed", this,"_menu_option"); + options->get_popup()->connect("id_pressed", this,"_menu_option"); HBoxContainer *hb = memnew( HBoxContainer ); add_child(hb); @@ -1299,6 +1295,8 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { hb->add_child(mode_list); mode_list->connect("pressed", this, "_set_display_mode", varray(DISPLAY_LIST)); + EDITOR_DEF("editors/grid_map/preview_size",64) + display_mode = DISPLAY_THUMBNAIL; selected_area=-1; @@ -1344,8 +1342,8 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { //selection mesh create - DVector<Vector3> lines; - DVector<Vector3> triangles; + PoolVector<Vector3> lines; + PoolVector<Vector3> triangles; for (int i=0;i<6;i++) { @@ -1379,7 +1377,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { for(int i=0;i<12;i++) { - AABB base(Vector3(0,0,0),Vector3(1,1,1)); + Rect3 base(Vector3(0,0,0),Vector3(1,1,1)); Vector3 a,b; base.get_edge(i,a,b); lines.push_back(a); @@ -1483,7 +1481,7 @@ void GridMapEditorPlugin::edit(Object *p_object) { bool GridMapEditorPlugin::handles(Object *p_object) const { - return p_object->is_type("GridMap"); + return p_object->is_class("GridMap"); } void GridMapEditorPlugin::make_visible(bool p_visible) { diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h index fc43866ef3..2c0ff99dc6 100644 --- a/modules/gridmap/grid_map_editor_plugin.h +++ b/modules/gridmap/grid_map_editor_plugin.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -40,7 +40,7 @@ class SpatialEditorPlugin; class GridMapEditor : public VBoxContainer { - OBJ_TYPE(GridMapEditor, VBoxContainer ); + GDCLASS(GridMapEditor, VBoxContainer ); enum { @@ -167,6 +167,7 @@ class GridMapEditor : public VBoxContainer { MENU_OPTION_DUPLICATE_SELECTS, MENU_OPTION_SELECTION_MAKE_AREA, MENU_OPTION_SELECTION_MAKE_EXTERIOR_CONNECTOR, + MENU_OPTION_SELECTION_DUPLICATE, MENU_OPTION_SELECTION_CLEAR, MENU_OPTION_REMOVE_AREA, MENU_OPTION_GRIDMAP_SETTINGS @@ -237,7 +238,7 @@ public: class GridMapEditorPlugin : public EditorPlugin { - OBJ_TYPE( GridMapEditorPlugin, EditorPlugin ); + GDCLASS( GridMapEditorPlugin, EditorPlugin ); GridMapEditor *gridmap_editor; EditorNode *editor; diff --git a/modules/gridmap/register_types.cpp b/modules/gridmap/register_types.cpp index 9dcc04b22a..b4a0d3b0b7 100644 --- a/modules/gridmap/register_types.cpp +++ b/modules/gridmap/register_types.cpp @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -36,7 +36,7 @@ void register_gridmap_types() { #ifndef _3D_DISABLED - ObjectTypeDB::register_type<GridMap>(); + ClassDB::register_class<GridMap>(); #ifdef TOOLS_ENABLED EditorPlugins::add_by_type<GridMapEditorPlugin>(); #endif diff --git a/modules/gridmap/register_types.h b/modules/gridmap/register_types.h index 7b5c10f9e5..cc7c13961a 100644 --- a/modules/gridmap/register_types.h +++ b/modules/gridmap/register_types.h @@ -5,7 +5,7 @@ /* GODOT ENGINE */ /* http://www.godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ |