diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-07-15 01:23:10 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2017-07-15 08:32:34 -0300 |
commit | 2e73be99d8d86d9dad7bcb99518a4d3cbb5c373c (patch) | |
tree | d863db50852afe5d4b0bc15b8452054498004cb1 /editor | |
parent | e64b82ebfcc3475c7a7d2a9196bfe20d6c9e3614 (diff) |
Lots of work on Audio & Physics engine:
-Added new 3D stream player node
-Added ability for Area to capture sound from streams
-Added small features in physics to be able to properly guess distance to areas for sound
-Fixed 3D CollisionObject so shapes are added the same as in 2D, directly from children
-Fixed KinematicBody API to make it the same as 2D.
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_node.cpp | 7 | ||||
-rw-r--r-- | editor/import/resource_importer_scene.cpp | 9 | ||||
-rw-r--r-- | editor/plugins/collision_polygon_editor_plugin.cpp | 638 | ||||
-rw-r--r-- | editor/plugins/collision_polygon_editor_plugin.h | 18 | ||||
-rw-r--r-- | editor/plugins/mesh_instance_editor_plugin.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/spatial_editor_plugin.cpp | 17 | ||||
-rw-r--r-- | editor/plugins/spatial_editor_plugin.h | 1 | ||||
-rw-r--r-- | editor/scene_tree_editor.cpp | 2 | ||||
-rw-r--r-- | editor/spatial_editor_gizmos.cpp | 127 | ||||
-rw-r--r-- | editor/spatial_editor_gizmos.h | 19 |
10 files changed, 464 insertions, 376 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 348dd32a66..1183bece7f 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -6343,21 +6343,17 @@ EditorNode::EditorNode() { add_editor_plugin( memnew( ShaderEditorPlugin(this,false) ) );*/ add_editor_plugin(memnew(CameraEditorPlugin(this))); - // add_editor_plugin( memnew( SampleEditorPlugin(this) ) ); - // add_editor_plugin( memnew( SampleLibraryEditorPlugin(this) ) ); add_editor_plugin(memnew(ThemeEditorPlugin(this))); add_editor_plugin(memnew(MultiMeshEditorPlugin(this))); add_editor_plugin(memnew(MeshInstanceEditorPlugin(this))); add_editor_plugin(memnew(AnimationTreeEditorPlugin(this))); - //add_editor_plugin( memnew( SamplePlayerEditorPlugin(this) ) ); - this is kind of useless at this point //add_editor_plugin( memnew( MeshLibraryEditorPlugin(this) ) ); - //add_editor_plugin( memnew( StreamEditorPlugin(this) ) ); add_editor_plugin(memnew(StyleBoxEditorPlugin(this))); add_editor_plugin(memnew(ParticlesEditorPlugin(this))); add_editor_plugin(memnew(ResourcePreloaderEditorPlugin(this))); add_editor_plugin(memnew(ItemListEditorPlugin(this))); //add_editor_plugin( memnew( RichTextEditorPlugin(this) ) ); - //add_editor_plugin( memnew( CollisionPolygonEditorPlugin(this) ) ); + add_editor_plugin(memnew(CollisionPolygonEditorPlugin(this))); add_editor_plugin(memnew(CollisionPolygon2DEditorPlugin(this))); add_editor_plugin(memnew(TileSetEditorPlugin(this))); add_editor_plugin(memnew(TileMapEditorPlugin(this))); @@ -6367,7 +6363,6 @@ EditorNode::EditorNode() { add_editor_plugin(memnew(GIProbeEditorPlugin(this))); add_editor_plugin(memnew(Path2DEditorPlugin(this))); add_editor_plugin(memnew(PathEditorPlugin(this))); - //add_editor_plugin( memnew( BakedLightEditorPlugin(this) ) ); add_editor_plugin(memnew(Line2DEditorPlugin(this))); add_editor_plugin(memnew(Polygon2DEditorPlugin(this))); add_editor_plugin(memnew(LightOccluder2DEditorPlugin(this))); diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 2ccbd36e18..dbf7a1bea5 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -33,7 +33,7 @@ #include "io/resource_saver.h" #include "scene/resources/packed_scene.h" -#include "scene/3d/body_shape.h" +#include "scene/3d/collision_shape.h" #include "scene/3d/mesh_instance.h" #include "scene/3d/navigation.h" #include "scene/3d/physics_body.h" @@ -369,10 +369,8 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array p_node = col; StaticBody *sb = col->cast_to<StaticBody>(); - CollisionShape *colshape = memnew(CollisionShape); - colshape->set_shape(sb->get_shape(0)); + CollisionShape *colshape = sb->get_child(0)->cast_to<CollisionShape>(); colshape->set_name("shape"); - sb->add_child(colshape); colshape->set_owner(p_node->get_owner()); } else if (p_node->has_meta("empty_draw_type")) { String empty_draw_type = String(p_node->get_meta("empty_draw_type")); @@ -463,8 +461,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array p_node->add_child(col); StaticBody *sb = col->cast_to<StaticBody>(); - CollisionShape *colshape = memnew(CollisionShape); - colshape->set_shape(sb->get_shape(0)); + CollisionShape *colshape = sb->get_child(0)->cast_to<CollisionShape>(); colshape->set_name("shape"); col->add_child(colshape); colshape->set_owner(p_node->get_owner()); diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp index 270ba5a5a4..5b364ed2c1 100644 --- a/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_editor_plugin.cpp @@ -35,339 +35,304 @@ #include "scene/3d/camera.h" #include "spatial_editor_plugin.h" -#if 0 - void CollisionPolygonEditor::_notification(int p_what) { - switch(p_what) { + switch (p_what) { case NOTIFICATION_READY: { - button_create->set_icon( get_icon("Edit","EditorIcons")); - button_edit->set_icon( get_icon("MovePoint","EditorIcons")); + button_create->set_icon(get_icon("Edit", "EditorIcons")); + button_edit->set_icon(get_icon("MovePoint", "EditorIcons")); button_edit->set_pressed(true); - get_tree()->connect("node_removed",this,"_node_removed"); - + get_tree()->connect("node_removed", this, "_node_removed"); } break; case NOTIFICATION_PROCESS: { if (node->get_depth() != prev_depth) { _polygon_draw(); - prev_depth=node->get_depth(); + prev_depth = node->get_depth(); } } break; } - } void CollisionPolygonEditor::_node_removed(Node *p_node) { - if(p_node==node) { - node=NULL; - if (imgeom->get_parent()==p_node) + if (p_node == node) { + node = NULL; + if (imgeom->get_parent() == p_node) p_node->remove_child(imgeom); hide(); set_process(false); } - } - void CollisionPolygonEditor::_menu_option(int p_option) { - switch(p_option) { + switch (p_option) { case MODE_CREATE: { - mode=MODE_CREATE; + mode = MODE_CREATE; button_create->set_pressed(true); button_edit->set_pressed(false); } break; case MODE_EDIT: { - mode=MODE_EDIT; + mode = MODE_EDIT; button_create->set_pressed(false); button_edit->set_pressed(true); } break; - } } void CollisionPolygonEditor::_wip_close() { undo_redo->create_action(TTR("Create Poly3D")); - undo_redo->add_undo_method(node,"set_polygon",node->get_polygon()); - undo_redo->add_do_method(node,"set_polygon",wip); - undo_redo->add_do_method(this,"_polygon_draw"); - undo_redo->add_undo_method(this,"_polygon_draw"); + undo_redo->add_undo_method(node, "set_polygon", node->get_polygon()); + undo_redo->add_do_method(node, "set_polygon", wip); + undo_redo->add_do_method(this, "_polygon_draw"); + undo_redo->add_undo_method(this, "_polygon_draw"); wip.clear(); - wip_active=false; - mode=MODE_EDIT; + wip_active = false; + mode = MODE_EDIT; button_edit->set_pressed(true); button_create->set_pressed(false); - edited_point=-1; + edited_point = -1; undo_redo->commit_action(); - } -bool CollisionPolygonEditor::forward_spatial_gui_input(Camera* p_camera,const InputEvent& p_event) { +bool CollisionPolygonEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { if (!node) return false; Transform gt = node->get_global_transform(); Transform gi = gt.affine_inverse(); - float depth = node->get_depth()*0.5; + float depth = node->get_depth() * 0.5; Vector3 n = gt.basis.get_axis(2).normalized(); - Plane p(gt.origin+n*depth,n); - - - switch(p_event.type) { + Plane p(gt.origin + n * depth, n); - case InputEvent::MOUSE_BUTTON: { + Ref<InputEventMouseButton> mb = p_event; - const InputEventMouseButton &mb=p_event.mouse_button; + if (mb.is_valid()) { + Vector2 gpoint = mb->get_position(); + Vector3 ray_from = p_camera->project_ray_origin(gpoint); + Vector3 ray_dir = p_camera->project_ray_normal(gpoint); + Vector3 spoint; - Vector2 gpoint=Point2(mb->get_pos().x,mb->get_pos().y); - Vector3 ray_from = p_camera->project_ray_origin(gpoint); - Vector3 ray_dir = p_camera->project_ray_normal(gpoint); - - Vector3 spoint; - - if (!p.intersects_ray(ray_from,ray_dir,&spoint)) - break; + if (!p.intersects_ray(ray_from, ray_dir, &spoint)) + return false; - spoint = gi.xform(spoint); + spoint = gi.xform(spoint); - Vector2 cpoint(spoint.x,spoint.y); + Vector2 cpoint(spoint.x, spoint.y); - cpoint=CanvasItemEditor::get_singleton()->snap_point(cpoint); + cpoint = CanvasItemEditor::get_singleton()->snap_point(cpoint); - Vector<Vector2> poly = node->get_polygon(); + Vector<Vector2> poly = node->get_polygon(); - //first check if a point is to be added (segment split) - real_t grab_threshold=EDITOR_DEF("editors/poly_editor/point_grab_radius",8); + //first check if a point is to be added (segment split) + real_t grab_treshold = EDITOR_DEF("editors/poly_editor/point_grab_radius", 8); - switch(mode) { + switch (mode) { + case MODE_CREATE: { - case MODE_CREATE: { + if (mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) { - if (mb->get_button_index()==BUTTON_LEFT && mb->is_pressed()) { + if (!wip_active) { + wip.clear(); + wip.push_back(cpoint); + wip_active = true; + edited_point_pos = cpoint; + _polygon_draw(); + edited_point = 1; + return true; + } else { - if (!wip_active) { + if (wip.size() > 1 && p_camera->unproject_position(gt.xform(Vector3(wip[0].x, wip[0].y, depth))).distance_to(gpoint) < grab_treshold) { + //wip closed + _wip_close(); - wip.clear(); - wip.push_back( cpoint ); - wip_active=true; - edited_point_pos=cpoint; - _polygon_draw(); - edited_point=1; return true; } else { - - if (wip.size()>1 && p_camera->unproject_position(gt.xform(Vector3(wip[0].x,wip[0].y,depth))).distance_to(gpoint)<grab_threshold) { - //wip closed - _wip_close(); - - return true; - } else { - - wip.push_back( cpoint ); - edited_point=wip.size(); - _polygon_draw(); - return true; - - //add wip point - } + wip.push_back(cpoint); + edited_point = wip.size(); + _polygon_draw(); + return true; } - } else if (mb->get_button_index()==BUTTON_RIGHT && mb->is_pressed() && wip_active) { - _wip_close(); } + } else if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed() && wip_active) { + _wip_close(); + } + } break; + case MODE_EDIT: { - } break; + if (mb->get_button_index() == BUTTON_LEFT) { + if (mb->is_pressed()) { - case MODE_EDIT: { + if (mb->get_control()) { - if (mb->get_button_index()==BUTTON_LEFT) { - if (mb->is_pressed()) { + if (poly.size() < 3) { - if (mb->get_control()) { - - - if (poly.size() < 3) { - - undo_redo->create_action(TTR("Edit Poly")); - undo_redo->add_undo_method(node,"set_polygon",poly); - poly.push_back(cpoint); - undo_redo->add_do_method(node,"set_polygon",poly); - undo_redo->add_do_method(this,"_polygon_draw"); - undo_redo->add_undo_method(this,"_polygon_draw"); - undo_redo->commit_action(); - return true; - } - - //search edges - int closest_idx=-1; - Vector2 closest_pos; - real_t closest_dist=1e10; - for(int i=0;i<poly.size();i++) { - - Vector2 points[2] ={ - p_camera->unproject_position(gt.xform(Vector3(poly[i].x,poly[i].y,depth))), - p_camera->unproject_position(gt.xform(Vector3(poly[(i+1)%poly.size()].x,poly[(i+1)%poly.size()].y,depth))) - }; - - Vector2 cp = Geometry::get_closest_point_to_segment_2d(gpoint,points); - if (cp.distance_squared_to(points[0])<CMP_EPSILON2 || cp.distance_squared_to(points[1])<CMP_EPSILON2) - continue; //not valid to reuse point - - real_t d = cp.distance_to(gpoint); - if (d<closest_dist && d<grab_threshold) { - closest_dist=d; - closest_pos=cp; - closest_idx=i; - } - - - } - - if (closest_idx>=0) { - - pre_move_edit=poly; - poly.insert(closest_idx+1,cpoint); - edited_point=closest_idx+1; - edited_point_pos=cpoint; - node->set_polygon(poly); - _polygon_draw(); - return true; - } - } else { - - //look for points to move - - int closest_idx=-1; - Vector2 closest_pos; - real_t closest_dist=1e10; - for(int i=0;i<poly.size();i++) { - - Vector2 cp = p_camera->unproject_position(gt.xform(Vector3(poly[i].x,poly[i].y,depth))); - - real_t d = cp.distance_to(gpoint); - if (d<closest_dist && d<grab_threshold) { - closest_dist=d; - closest_pos=cp; - closest_idx=i; - } + undo_redo->create_action(TTR("Edit Poly")); + undo_redo->add_undo_method(node, "set_polygon", poly); + poly.push_back(cpoint); + undo_redo->add_do_method(node, "set_polygon", poly); + undo_redo->add_do_method(this, "_polygon_draw"); + undo_redo->add_undo_method(this, "_polygon_draw"); + undo_redo->commit_action(); + return true; + } + //search edges + int closest_idx = -1; + Vector2 closest_pos; + real_t closest_dist = 1e10; + for (int i = 0; i < poly.size(); i++) { + + Vector2 points[2] = { + p_camera->unproject_position(gt.xform(Vector3(poly[i].x, poly[i].y, depth))), + p_camera->unproject_position(gt.xform(Vector3(poly[(i + 1) % poly.size()].x, poly[(i + 1) % poly.size()].y, depth))) + }; + + Vector2 cp = Geometry::get_closest_point_to_segment_2d(gpoint, points); + if (cp.distance_squared_to(points[0]) < CMP_EPSILON2 || cp.distance_squared_to(points[1]) < CMP_EPSILON2) + continue; //not valid to reuse point + + real_t d = cp.distance_to(gpoint); + if (d < closest_dist && d < grab_treshold) { + closest_dist = d; + closest_pos = cp; + closest_idx = i; } + } - if (closest_idx>=0) { + if (closest_idx >= 0) { - pre_move_edit=poly; - edited_point=closest_idx; - edited_point_pos=poly[closest_idx]; - _polygon_draw(); - return true; - } + pre_move_edit = poly; + poly.insert(closest_idx + 1, cpoint); + edited_point = closest_idx + 1; + edited_point_pos = cpoint; + node->set_polygon(poly); + _polygon_draw(); + return true; } } else { - if (edited_point!=-1) { + //look for points to move - //apply + int closest_idx = -1; + Vector2 closest_pos; + real_t closest_dist = 1e10; + for (int i = 0; i < poly.size(); i++) { - ERR_FAIL_INDEX_V(edited_point,poly.size(),false); - poly[edited_point]=edited_point_pos; - undo_redo->create_action(TTR("Edit Poly")); - undo_redo->add_do_method(node,"set_polygon",poly); - undo_redo->add_undo_method(node,"set_polygon",pre_move_edit); - undo_redo->add_do_method(this,"_polygon_draw"); - undo_redo->add_undo_method(this,"_polygon_draw"); - undo_redo->commit_action(); + Vector2 cp = p_camera->unproject_position(gt.xform(Vector3(poly[i].x, poly[i].y, depth))); - edited_point=-1; - return true; + real_t d = cp.distance_to(gpoint); + if (d < closest_dist && d < grab_treshold) { + closest_dist = d; + closest_pos = cp; + closest_idx = i; + } } - } - } if (mb->get_button_index()==BUTTON_RIGHT && mb->is_pressed() && edited_point==-1) { - + if (closest_idx >= 0) { - int closest_idx=-1; - Vector2 closest_pos; - real_t closest_dist=1e10; - for(int i=0;i<poly.size();i++) { - - Vector2 cp = p_camera->unproject_position(gt.xform(Vector3(poly[i].x,poly[i].y,depth))); - - real_t d = cp.distance_to(gpoint); - if (d<closest_dist && d<grab_threshold) { - closest_dist=d; - closest_pos=cp; - closest_idx=i; + pre_move_edit = poly; + edited_point = closest_idx; + edited_point_pos = poly[closest_idx]; + _polygon_draw(); + return true; } - } + } else { - if (closest_idx>=0) { + if (edited_point != -1) { + //apply - undo_redo->create_action(TTR("Edit Poly (Remove Point)")); - undo_redo->add_undo_method(node,"set_polygon",poly); - poly.remove(closest_idx); - undo_redo->add_do_method(node,"set_polygon",poly); - undo_redo->add_do_method(this,"_polygon_draw"); - undo_redo->add_undo_method(this,"_polygon_draw"); + ERR_FAIL_INDEX_V(edited_point, poly.size(), false); + poly[edited_point] = edited_point_pos; + undo_redo->create_action(TTR("Edit Poly")); + undo_redo->add_do_method(node, "set_polygon", poly); + undo_redo->add_undo_method(node, "set_polygon", pre_move_edit); + undo_redo->add_do_method(this, "_polygon_draw"); + undo_redo->add_undo_method(this, "_polygon_draw"); undo_redo->commit_action(); + + edited_point = -1; return true; } - } + } + if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed() && edited_point == -1) { + int closest_idx = -1; + Vector2 closest_pos; + real_t closest_dist = 1e10; + for (int i = 0; i < poly.size(); i++) { + Vector2 cp = p_camera->unproject_position(gt.xform(Vector3(poly[i].x, poly[i].y, depth))); - } break; - } - + real_t d = cp.distance_to(gpoint); + if (d < closest_dist && d < grab_treshold) { + closest_dist = d; + closest_pos = cp; + closest_idx = i; + } + } + if (closest_idx >= 0) { - } break; - case InputEvent::MOUSE_MOTION: { + undo_redo->create_action(TTR("Edit Poly (Remove Point)")); + undo_redo->add_undo_method(node, "set_polygon", poly); + poly.remove(closest_idx); + undo_redo->add_do_method(node, "set_polygon", poly); + undo_redo->add_do_method(this, "_polygon_draw"); + undo_redo->add_undo_method(this, "_polygon_draw"); + undo_redo->commit_action(); + return true; + } + } - const InputEventMouseMotion &mm=p_event.mouse_motion; + } break; + } + } - if (edited_point!=-1 && (wip_active || mm->get_button_mask()&BUTTON_MASK_LEFT)) { + Ref<InputEventMouseMotion> mm = p_event; - Vector2 gpoint = Point2(mm.x,mm.y); + if (mm.is_valid()) { - Vector3 ray_from = p_camera->project_ray_origin(gpoint); - Vector3 ray_dir = p_camera->project_ray_normal(gpoint); + if (edited_point != -1 && (wip_active || mm->get_button_mask() & BUTTON_MASK_LEFT)) { - Vector3 spoint; + Vector2 gpoint = mm->get_position(); - if (!p.intersects_ray(ray_from,ray_dir,&spoint)) - break; + Vector3 ray_from = p_camera->project_ray_origin(gpoint); + Vector3 ray_dir = p_camera->project_ray_normal(gpoint); - spoint = gi.xform(spoint); + Vector3 spoint; - Vector2 cpoint(spoint.x,spoint.y); + if (!p.intersects_ray(ray_from, ray_dir, &spoint)) + return false; - cpoint=CanvasItemEditor::get_singleton()->snap_point(cpoint); - edited_point_pos = cpoint; + spoint = gi.xform(spoint); - _polygon_draw(); + Vector2 cpoint(spoint.x, spoint.y); - } + cpoint = CanvasItemEditor::get_singleton()->snap_point(cpoint); + edited_point_pos = cpoint; - } break; + _polygon_draw(); + } } return false; @@ -380,41 +345,38 @@ void CollisionPolygonEditor::_polygon_draw() { Vector<Vector2> poly; if (wip_active) - poly=wip; + poly = wip; else - poly=node->get_polygon(); - + poly = node->get_polygon(); - float depth = node->get_depth()*0.5; + float depth = node->get_depth() * 0.5; imgeom->clear(); imgeom->set_material_override(line_material); - imgeom->begin(Mesh::PRIMITIVE_LINES,Ref<Texture>()); - + imgeom->begin(Mesh::PRIMITIVE_LINES, Ref<Texture>()); Rect2 rect; - for(int i=0;i<poly.size();i++) { - + for (int i = 0; i < poly.size(); i++) { - Vector2 p,p2; - p = i==edited_point ? edited_point_pos : poly[i]; - if ((wip_active && i==poly.size()-1) || (((i+1)%poly.size())==edited_point)) - p2=edited_point_pos; + Vector2 p, p2; + p = i == edited_point ? edited_point_pos : poly[i]; + if ((wip_active && i == poly.size() - 1) || (((i + 1) % poly.size()) == edited_point)) + p2 = edited_point_pos; else - p2 = poly[(i+1)%poly.size()]; + p2 = poly[(i + 1) % poly.size()]; - if (i==0) - rect.pos=p; + if (i == 0) + rect.position = p; else rect.expand_to(p); - Vector3 point = Vector3(p.x,p.y,depth); - Vector3 next_point = Vector3(p2.x,p2.y,depth); + Vector3 point = Vector3(p.x, p.y, depth); + Vector3 next_point = Vector3(p2.x, p2.y, depth); - imgeom->set_color(Color(1,0.3,0.1,0.8)); + imgeom->set_color(Color(1, 0.3, 0.1, 0.8)); imgeom->add_vertex(point); - imgeom->set_color(Color(1,0.3,0.1,0.8)); + imgeom->set_color(Color(1, 0.3, 0.1, 0.8)); imgeom->add_vertex(next_point); //Color col=Color(1,0.3,0.1,0.8); @@ -422,60 +384,59 @@ void CollisionPolygonEditor::_polygon_draw() { //vpc->draw_texture(handle,point-handle->get_size()*0.5); } - rect=rect.grow(1); - - AABB r; - r.pos.x=rect.pos.x; - r.pos.y=rect.pos.y; - r.pos.z=depth; - r.size.x=rect.size.x; - r.size.y=rect.size.y; - r.size.z=0; - - imgeom->set_color(Color(0.8,0.8,0.8,0.2)); - imgeom->add_vertex(r.pos); - imgeom->set_color(Color(0.8,0.8,0.8,0.2)); - imgeom->add_vertex(r.pos+Vector3(0.3,0,0)); - imgeom->set_color(Color(0.8,0.8,0.8,0.2)); - imgeom->add_vertex(r.pos); - imgeom->set_color(Color(0.8,0.8,0.8,0.2)); - imgeom->add_vertex(r.pos+Vector3(0.0,0.3,0)); - - imgeom->set_color(Color(0.8,0.8,0.8,0.2)); - imgeom->add_vertex(r.pos+Vector3(r.size.x,0,0)); - imgeom->set_color(Color(0.8,0.8,0.8,0.2)); - imgeom->add_vertex(r.pos+Vector3(r.size.x,0,0)-Vector3(0.3,0,0)); - imgeom->set_color(Color(0.8,0.8,0.8,0.2)); - imgeom->add_vertex(r.pos+Vector3(r.size.x,0,0)); - imgeom->set_color(Color(0.8,0.8,0.8,0.2)); - imgeom->add_vertex(r.pos+Vector3(r.size.x,0,0)+Vector3(0,0.3,0)); - - imgeom->set_color(Color(0.8,0.8,0.8,0.2)); - imgeom->add_vertex(r.pos+Vector3(0,r.size.y,0)); - imgeom->set_color(Color(0.8,0.8,0.8,0.2)); - imgeom->add_vertex(r.pos+Vector3(0,r.size.y,0)-Vector3(0,0.3,0)); - imgeom->set_color(Color(0.8,0.8,0.8,0.2)); - imgeom->add_vertex(r.pos+Vector3(0,r.size.y,0)); - imgeom->set_color(Color(0.8,0.8,0.8,0.2)); - imgeom->add_vertex(r.pos+Vector3(0,r.size.y,0)+Vector3(0.3,0,0)); - - imgeom->set_color(Color(0.8,0.8,0.8,0.2)); - imgeom->add_vertex(r.pos+r.size); - imgeom->set_color(Color(0.8,0.8,0.8,0.2)); - imgeom->add_vertex(r.pos+r.size-Vector3(0.3,0,0)); - imgeom->set_color(Color(0.8,0.8,0.8,0.2)); - imgeom->add_vertex(r.pos+r.size); - imgeom->set_color(Color(0.8,0.8,0.8,0.2)); - imgeom->add_vertex(r.pos+r.size-Vector3(0.0,0.3,0)); + rect = rect.grow(1); + + Rect3 r; + r.position.x = rect.position.x; + r.position.y = rect.position.y; + r.position.z = depth; + r.size.x = rect.size.x; + r.size.y = rect.size.y; + r.size.z = 0; + + imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2)); + imgeom->add_vertex(r.position); + imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2)); + imgeom->add_vertex(r.position + Vector3(0.3, 0, 0)); + imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2)); + imgeom->add_vertex(r.position); + imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2)); + imgeom->add_vertex(r.position + Vector3(0.0, 0.3, 0)); + + imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2)); + imgeom->add_vertex(r.position + Vector3(r.size.x, 0, 0)); + imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2)); + imgeom->add_vertex(r.position + Vector3(r.size.x, 0, 0) - Vector3(0.3, 0, 0)); + imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2)); + imgeom->add_vertex(r.position + Vector3(r.size.x, 0, 0)); + imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2)); + imgeom->add_vertex(r.position + Vector3(r.size.x, 0, 0) + Vector3(0, 0.3, 0)); + + imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2)); + imgeom->add_vertex(r.position + Vector3(0, r.size.y, 0)); + imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2)); + imgeom->add_vertex(r.position + Vector3(0, r.size.y, 0) - Vector3(0, 0.3, 0)); + imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2)); + imgeom->add_vertex(r.position + Vector3(0, r.size.y, 0)); + imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2)); + imgeom->add_vertex(r.position + Vector3(0, r.size.y, 0) + Vector3(0.3, 0, 0)); + + imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2)); + imgeom->add_vertex(r.position + r.size); + imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2)); + imgeom->add_vertex(r.position + r.size - Vector3(0.3, 0, 0)); + imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2)); + imgeom->add_vertex(r.position + r.size); + imgeom->set_color(Color(0.8, 0.8, 0.8, 0.2)); + imgeom->add_vertex(r.position + r.size - Vector3(0.0, 0.3, 0)); imgeom->end(); - - while(m->get_surface_count()) { + while (m->get_surface_count()) { m->surface_remove(0); } - if (poly.size()==0) + if (poly.size() == 0) return; Array a; @@ -484,78 +445,69 @@ void CollisionPolygonEditor::_polygon_draw() { { va.resize(poly.size()); - PoolVector<Vector3>::Write w=va.write(); - for(int i=0;i<poly.size();i++) { - + PoolVector<Vector3>::Write w = va.write(); + for (int i = 0; i < poly.size(); i++) { - Vector2 p,p2; - p = i==edited_point ? edited_point_pos : poly[i]; + Vector2 p, p2; + p = i == edited_point ? edited_point_pos : poly[i]; - Vector3 point = Vector3(p.x,p.y,depth); - w[i]=point; + Vector3 point = Vector3(p.x, p.y, depth); + w[i] = point; } } - a[Mesh::ARRAY_VERTEX]=va; - m->add_surface(Mesh::PRIMITIVE_POINTS,a); - m->surface_set_material(0,handle_material); - + a[Mesh::ARRAY_VERTEX] = va; + m->add_surface_from_arrays(Mesh::PRIMITIVE_POINTS, a); + m->surface_set_material(0, handle_material); } - - void CollisionPolygonEditor::edit(Node *p_collision_polygon) { - - if (p_collision_polygon) { - node=p_collision_polygon->cast_to<CollisionPolygon>(); + node = p_collision_polygon->cast_to<CollisionPolygon>(); wip.clear(); - wip_active=false; - edited_point=-1; + wip_active = false; + edited_point = -1; p_collision_polygon->add_child(imgeom); _polygon_draw(); set_process(true); - prev_depth=-1; + prev_depth = -1; } else { - node=NULL; + node = NULL; if (imgeom->get_parent()) imgeom->get_parent()->remove_child(imgeom); set_process(false); } - } void CollisionPolygonEditor::_bind_methods() { - ClassDB::bind_method(D_METHOD("_menu_option"),&CollisionPolygonEditor::_menu_option); - ClassDB::bind_method(D_METHOD("_polygon_draw"),&CollisionPolygonEditor::_polygon_draw); - ClassDB::bind_method(D_METHOD("_node_removed"),&CollisionPolygonEditor::_node_removed); - + ClassDB::bind_method(D_METHOD("_menu_option"), &CollisionPolygonEditor::_menu_option); + ClassDB::bind_method(D_METHOD("_polygon_draw"), &CollisionPolygonEditor::_polygon_draw); + ClassDB::bind_method(D_METHOD("_node_removed"), &CollisionPolygonEditor::_node_removed); } CollisionPolygonEditor::CollisionPolygonEditor(EditorNode *p_editor) { - - node=NULL; - editor=p_editor; + node = NULL; + editor = p_editor; undo_redo = editor->get_undo_redo(); - add_child( memnew( VSeparator )); - button_create = memnew( ToolButton ); + add_child(memnew(VSeparator)); + button_create = memnew(ToolButton); add_child(button_create); - button_create->connect("pressed",this,"_menu_option",varray(MODE_CREATE)); + button_create->connect("pressed", this, "_menu_option", varray(MODE_CREATE)); button_create->set_toggle_mode(true); - button_edit = memnew( ToolButton ); + button_edit = memnew(ToolButton); add_child(button_edit); - button_edit->connect("pressed",this,"_menu_option",varray(MODE_EDIT)); + button_edit->connect("pressed", this, "_menu_option", varray(MODE_EDIT)); button_edit->set_toggle_mode(true); - //add_constant_override("separation",0); +//add_constant_override("separation",0); #if 0 options = memnew( MenuButton ); @@ -567,46 +519,40 @@ CollisionPolygonEditor::CollisionPolygonEditor(EditorNode *p_editor) { #endif mode = MODE_EDIT; - wip_active=false; - imgeom = memnew( ImmediateGeometry ); - imgeom->set_transform(Transform(Matrix3(),Vector3(0,0,0.00001))); - + wip_active = false; + imgeom = memnew(ImmediateGeometry); + imgeom->set_transform(Transform(Basis(), Vector3(0, 0, 0.00001))); - line_material = Ref<SpatialMaterial>( memnew( SpatialMaterial )); - line_material->set_flag(Material::FLAG_UNSHADED, true); + line_material = Ref<SpatialMaterial>(memnew(SpatialMaterial)); + line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); line_material->set_line_width(3.0); - line_material->set_fixed_flag(SpatialMaterial::FLAG_USE_ALPHA, true); - line_material->set_fixed_flag(SpatialMaterial::FLAG_USE_COLOR_ARRAY, true); - line_material->set_parameter(SpatialMaterial::PARAM_DIFFUSE,Color(1,1,1)); - - - - - handle_material = Ref<SpatialMaterial>( memnew( SpatialMaterial )); - handle_material->set_flag(Material::FLAG_UNSHADED, true); - handle_material->set_fixed_flag(SpatialMaterial::FLAG_USE_POINT_SIZE, true); - handle_material->set_parameter(SpatialMaterial::PARAM_DIFFUSE,Color(1,1,1)); - handle_material->set_fixed_flag(SpatialMaterial::FLAG_USE_ALPHA, true); - handle_material->set_fixed_flag(SpatialMaterial::FLAG_USE_COLOR_ARRAY, false); - Ref<Texture> handle=editor->get_gui_base()->get_icon("Editor3DHandle","EditorIcons"); + line_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + line_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + line_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); + line_material->set_albedo(Color(1, 1, 1)); + + handle_material = Ref<SpatialMaterial>(memnew(SpatialMaterial)); + handle_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + handle_material->set_flag(SpatialMaterial::FLAG_USE_POINT_SIZE, true); + handle_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + handle_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + handle_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); + Ref<Texture> handle = editor->get_gui_base()->get_icon("Editor3DHandle", "EditorIcons"); handle_material->set_point_size(handle->get_width()); - handle_material->set_texture(SpatialMaterial::PARAM_DIFFUSE,handle); + handle_material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, handle); - pointsm = memnew( MeshInstance ); + pointsm = memnew(MeshInstance); imgeom->add_child(pointsm); - m = Ref<Mesh>( memnew( Mesh ) ); + m.instance(); pointsm->set_mesh(m); - pointsm->set_transform(Transform(Matrix3(),Vector3(0,0,0.00001))); - - + pointsm->set_transform(Transform(Basis(), Vector3(0, 0, 0.00001))); } CollisionPolygonEditor::~CollisionPolygonEditor() { - memdelete( imgeom ); + memdelete(imgeom); } - void CollisionPolygonEditorPlugin::edit(Object *p_object) { collision_polygon_editor->edit(p_object->cast_to<Node>()); @@ -614,7 +560,7 @@ void CollisionPolygonEditorPlugin::edit(Object *p_object) { bool CollisionPolygonEditorPlugin::handles(Object *p_object) const { - return p_object->is_type("CollisionPolygon"); + return p_object->is_class("CollisionPolygon"); } void CollisionPolygonEditorPlugin::make_visible(bool p_visible) { @@ -626,24 +572,16 @@ void CollisionPolygonEditorPlugin::make_visible(bool p_visible) { collision_polygon_editor->hide(); collision_polygon_editor->edit(NULL); } - } CollisionPolygonEditorPlugin::CollisionPolygonEditorPlugin(EditorNode *p_node) { - editor=p_node; - collision_polygon_editor = memnew( CollisionPolygonEditor(p_node) ); + editor = p_node; + collision_polygon_editor = memnew(CollisionPolygonEditor(p_node)); SpatialEditor::get_singleton()->add_control_to_menu_panel(collision_polygon_editor); collision_polygon_editor->hide(); - - - } - -CollisionPolygonEditorPlugin::~CollisionPolygonEditorPlugin() -{ +CollisionPolygonEditorPlugin::~CollisionPolygonEditorPlugin() { } - -#endif diff --git a/editor/plugins/collision_polygon_editor_plugin.h b/editor/plugins/collision_polygon_editor_plugin.h index 995f2224bf..3a8428fc62 100644 --- a/editor/plugins/collision_polygon_editor_plugin.h +++ b/editor/plugins/collision_polygon_editor_plugin.h @@ -42,12 +42,11 @@ @author Juan Linietsky <reduzio@gmail.com> */ -#if 0 class CanvasItemEditor; class CollisionPolygonEditor : public HBoxContainer { - GDCLASS(CollisionPolygonEditor, HBoxContainer ); + GDCLASS(CollisionPolygonEditor, HBoxContainer); UndoRedo *undo_redo; enum Mode { @@ -62,7 +61,6 @@ class CollisionPolygonEditor : public HBoxContainer { ToolButton *button_create; ToolButton *button_edit; - Ref<SpatialMaterial> line_material; Ref<SpatialMaterial> handle_material; @@ -71,7 +69,7 @@ class CollisionPolygonEditor : public HBoxContainer { CollisionPolygon *node; ImmediateGeometry *imgeom; MeshInstance *pointsm; - Ref<Mesh> m; + Ref<ArrayMesh> m; MenuButton *options; @@ -91,9 +89,9 @@ protected: void _notification(int p_what); void _node_removed(Node *p_node); static void _bind_methods(); -public: - virtual bool forward_spatial_gui_input(Camera* p_camera,const InputEvent& p_event); +public: + virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event); void edit(Node *p_collision_polygon); CollisionPolygonEditor(EditorNode *p_editor); ~CollisionPolygonEditor(); @@ -101,14 +99,13 @@ public: class CollisionPolygonEditorPlugin : public EditorPlugin { - GDCLASS( CollisionPolygonEditorPlugin, EditorPlugin ); + GDCLASS(CollisionPolygonEditorPlugin, EditorPlugin); CollisionPolygonEditor *collision_polygon_editor; EditorNode *editor; public: - - virtual bool forward_spatial_gui_input(Camera* p_camera,const InputEvent& p_event) { return collision_polygon_editor->forward_spatial_gui_input(p_camera,p_event); } + virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { return collision_polygon_editor->forward_spatial_gui_input(p_camera, p_event); } virtual String get_name() const { return "CollisionPolygon"; } bool has_main_screen() const { return false; } @@ -118,7 +115,6 @@ public: CollisionPolygonEditorPlugin(EditorNode *p_node); ~CollisionPolygonEditorPlugin(); - }; -#endif + #endif // COLLISION_POLYGON_EDITOR_PLUGIN_H diff --git a/editor/plugins/mesh_instance_editor_plugin.cpp b/editor/plugins/mesh_instance_editor_plugin.cpp index ab09d0dd96..49498d0fa0 100644 --- a/editor/plugins/mesh_instance_editor_plugin.cpp +++ b/editor/plugins/mesh_instance_editor_plugin.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "mesh_instance_editor_plugin.h" -#include "scene/3d/body_shape.h" +#include "scene/3d/collision_shape.h" #include "scene/3d/navigation_mesh.h" #include "scene/3d/physics_body.h" #include "scene/gui/box_container.h" diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 995d13f6a8..d7f4781e89 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -2025,6 +2025,15 @@ void SpatialEditorViewport::_menu_option(int p_option) { view_menu->get_popup()->set_item_checked(idx, current); } break; + case VIEW_AUDIO_DOPPLER: { + + int idx = view_menu->get_popup()->get_item_index(VIEW_AUDIO_DOPPLER); + bool current = view_menu->get_popup()->is_item_checked(idx); + current = !current; + camera->set_doppler_tracking(current ? Camera::DOPPLER_TRACKING_IDLE_STEP : Camera::DOPPLER_TRACKING_DISABLED); + view_menu->get_popup()->set_item_checked(idx, current); + + } break; case VIEW_GIZMOS: { int idx = view_menu->get_popup()->get_item_index(VIEW_GIZMOS); @@ -2237,6 +2246,13 @@ void SpatialEditorViewport::set_state(const Dictionary &p_state) { viewport->set_as_audio_listener(listener); view_menu->get_popup()->set_item_checked(idx, listener); } + if (p_state.has("doppler")) { + bool doppler = p_state["doppler"]; + + int idx = view_menu->get_popup()->get_item_index(VIEW_AUDIO_DOPPLER); + camera->set_doppler_tracking(doppler ? Camera::DOPPLER_TRACKING_IDLE_STEP : Camera::DOPPLER_TRACKING_DISABLED); + view_menu->get_popup()->set_item_checked(idx, doppler); + } if (p_state.has("previewing")) { Node *pv = EditorNode::get_singleton()->get_edited_scene()->get_node(p_state["previewing"]); @@ -2395,6 +2411,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_ENVIRONMENT), true); view_menu->get_popup()->add_separator(); view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_audio_listener", TTR("Audio Listener")), VIEW_AUDIO_LISTENER); + view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_audio_doppler", TTR("Doppler Enable")), VIEW_AUDIO_DOPPLER); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_GIZMOS), true); view_menu->get_popup()->add_separator(); diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index 6b05a8b370..9b626054c0 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -83,6 +83,7 @@ class SpatialEditorViewport : public Control { VIEW_ENVIRONMENT, VIEW_ORTHOGONAL, VIEW_AUDIO_LISTENER, + VIEW_AUDIO_DOPPLER, VIEW_GIZMOS, VIEW_INFORMATION, VIEW_DISPLAY_NORMAL, diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index d12d8b5528..94c94e126d 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -161,7 +161,7 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { item->set_selectable(0, true); if (can_rename) { -#ifdef ENABLE_DEPRECATED +#ifndef DISABLE_DEPRECATED if (p_node->has_meta("_editor_collapsed")) { //remove previous way of storing folding, which did not get along with scene inheritance and instancing if ((bool)p_node->get_meta("_editor_collapsed")) diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index 62fa93ac23..faf9dee5d0 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -867,6 +867,127 @@ LightSpatialGizmo::LightSpatialGizmo(Light *p_light) { ////// +//// player gizmo + +String AudioStreamPlayer3DSpatialGizmo::get_handle_name(int p_idx) const { + + return "Emission Radius"; +} + +Variant AudioStreamPlayer3DSpatialGizmo::get_handle_value(int p_idx) const { + + return player->get_emission_angle(); +} + +void AudioStreamPlayer3DSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_point) { + + Transform gt = player->get_global_transform(); + gt.orthonormalize(); + Transform gi = gt.affine_inverse(); + + Vector3 ray_from = p_camera->project_ray_origin(p_point); + Vector3 ray_dir = p_camera->project_ray_normal(p_point); + Vector3 ray_to = ray_from + ray_dir * 4096; + + ray_from = gi.xform(ray_from); + ray_to = gi.xform(ray_to); + + float closest_dist = 1e20; + float closest_angle = 1e20; + + for (int i = 0; i < 180; i++) { + + float a = i * Math_PI / 180.0; + float an = (i + 1) * Math_PI / 180.0; + + Vector3 from(Math::sin(a), 0, -Math::cos(a)); + Vector3 to(Math::sin(an), 0, -Math::cos(an)); + + Vector3 r1, r2; + Geometry::get_closest_points_between_segments(from, to, ray_from, ray_to, r1, r2); + float d = r1.distance_to(r2); + if (d < closest_dist) { + closest_dist = d; + closest_angle = i; + } + } + + if (closest_angle < 91) { + player->set_emission_angle(closest_angle); + } +} + +void AudioStreamPlayer3DSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) { + + if (p_cancel) { + + player->set_emission_angle(p_restore); + + } else { + + UndoRedo *ur = SpatialEditor::get_singleton()->get_undo_redo(); + ur->create_action(TTR("Change AudioStreamPlayer3D Emission Angle")); + ur->add_do_method(player, "set_emission_angle", player->get_emission_angle()); + ur->add_undo_method(player, "set_emission_angle", p_restore); + ur->commit_action(); + } +} + +void AudioStreamPlayer3DSpatialGizmo::redraw() { + + clear(); + + if (player->is_emission_angle_enabled()) { + float pc = player->get_emission_angle(); + + Vector<Vector3> points; + points.resize(208); + + float ofs = -Math::cos(Math::deg2rad(pc)); + float radius = Math::sin(Math::deg2rad(pc)); + + for (int i = 0; i < 100; i++) { + + float a = i * 2.0 * Math_PI / 100.0; + float an = (i + 1) * 2.0 * Math_PI / 100.0; + + Vector3 from(Math::sin(a) * radius, Math::cos(a) * radius, ofs); + Vector3 to(Math::sin(an) * radius, Math::cos(an) * radius, ofs); + + points[i * 2 + 0] = from; + points[i * 2 + 1] = to; + } + + for (int i = 0; i < 4; i++) { + + float a = i * 2.0 * Math_PI / 4.0; + + Vector3 from(Math::sin(a) * radius, Math::cos(a) * radius, ofs); + + points[200 + i * 2 + 0] = from; + points[200 + i * 2 + 1] = Vector3(); + } + + add_lines(points, SpatialEditorGizmos::singleton->car_wheel_material); + add_collision_segments(points); + + Vector<Vector3> handles; + float ha = Math::deg2rad(player->get_emission_angle()); + handles.push_back(Vector3(Math::sin(ha), 0, -Math::cos(ha))); + add_handles(handles); + } + + add_unscaled_billboard(SpatialEditorGizmos::singleton->sample_player_icon, 0.05); +} + +AudioStreamPlayer3DSpatialGizmo::AudioStreamPlayer3DSpatialGizmo(AudioStreamPlayer3D *p_player) { + + player = p_player; + set_spatial_node(p_player); +} + +////// + String CameraSpatialGizmo::get_handle_name(int p_idx) const { if (camera->get_projection() == Camera::PROJECTION_PERSPECTIVE) { @@ -3101,6 +3222,12 @@ Ref<SpatialEditorGizmo> SpatialEditorGizmos::get_gizmo(Spatial *p_spatial) { return misg; } + if (p_spatial->cast_to<AudioStreamPlayer3D>()) { + + Ref<AudioStreamPlayer3DSpatialGizmo> misg = memnew(AudioStreamPlayer3DSpatialGizmo(p_spatial->cast_to<AudioStreamPlayer3D>())); + return misg; + } + return Ref<SpatialEditorGizmo>(); } diff --git a/editor/spatial_editor_gizmos.h b/editor/spatial_editor_gizmos.h index a8ace87530..469a2d594a 100644 --- a/editor/spatial_editor_gizmos.h +++ b/editor/spatial_editor_gizmos.h @@ -31,9 +31,10 @@ #define SPATIAL_EDITOR_GIZMOS_H #include "editor/plugins/spatial_editor_plugin.h" -#include "scene/3d/body_shape.h" +#include "scene/3d/audio_stream_player_3d.h" #include "scene/3d/camera.h" #include "scene/3d/collision_polygon.h" +#include "scene/3d/collision_shape.h" #include "scene/3d/gi_probe.h" #include "scene/3d/light.h" #include "scene/3d/listener.h" @@ -137,6 +138,22 @@ public: LightSpatialGizmo(Light *p_light = NULL); }; +class AudioStreamPlayer3DSpatialGizmo : public EditorSpatialGizmo { + + GDCLASS(AudioStreamPlayer3DSpatialGizmo, EditorSpatialGizmo); + + AudioStreamPlayer3D *player; + +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); + virtual void commit_handle(int p_idx, const Variant &p_restore, bool p_cancel = false); + + void redraw(); + AudioStreamPlayer3DSpatialGizmo(AudioStreamPlayer3D *p_player = NULL); +}; + class CameraSpatialGizmo : public EditorSpatialGizmo { GDCLASS(CameraSpatialGizmo, EditorSpatialGizmo); |