Merge pull request #37340 from reduz/rename-3d-nodes

Make 2D and 3D node names more explicit
This commit is contained in:
Juan Linietsky 2020-03-27 13:47:15 -03:00 committed by GitHub
commit 307b1b3a58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
292 changed files with 6393 additions and 6545 deletions

View File

@ -3554,7 +3554,7 @@ void AnimationTrackEditor::_insert_delay() {
insert_queue = false;
}
void AnimationTrackEditor::insert_transform_key(Spatial *p_node, const String &p_sub, const Transform &p_xform) {
void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_sub, const Transform &p_xform) {
if (!keying)
return;
@ -4446,8 +4446,8 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) {
ERR_FAIL_COND(!node);
NodePath path_to = root->get_path_to(node);
if (adding_track_type == Animation::TYPE_TRANSFORM && !node->is_class("Spatial")) {
EditorNode::get_singleton()->show_warning(TTR("Transform tracks only apply to Spatial-based nodes."));
if (adding_track_type == Animation::TYPE_TRANSFORM && !node->is_class("Node3D")) {
EditorNode::get_singleton()->show_warning(TTR("Transform tracks only apply to 3D-based nodes."));
return;
}
@ -4638,10 +4638,10 @@ void AnimationTrackEditor::_insert_key_from_track(float p_ofs, int p_track) {
EditorNode::get_singleton()->show_warning(TTR("Track path is invalid, so can't add a key."));
return;
}
Spatial *base = Object::cast_to<Spatial>(root->get_node(animation->track_get_path(p_track)));
Node3D *base = Object::cast_to<Node3D>(root->get_node(animation->track_get_path(p_track)));
if (!base) {
EditorNode::get_singleton()->show_warning(TTR("Track is not of type Spatial, can't insert key"));
EditorNode::get_singleton()->show_warning(TTR("Track is not of type Node3D, can't insert key"));
return;
}

View File

@ -513,7 +513,7 @@ public:
void set_anim_pos(float p_pos);
void insert_node_value_key(Node *p_node, const String &p_property, const Variant &p_value, bool p_only_if_exists = false);
void insert_value_key(const String &p_property, const Variant &p_value, bool p_advance);
void insert_transform_key(Spatial *p_node, const String &p_sub, const Transform &p_xform);
void insert_transform_key(Node3D *p_node, const String &p_sub, const Transform &p_xform);
void show_select_node_warning(bool p_show);

View File

@ -33,8 +33,8 @@
#include "editor/audio_stream_preview.h"
#include "editor_resource_preview.h"
#include "editor_scale.h"
#include "scene/2d/animated_sprite.h"
#include "scene/2d/sprite.h"
#include "scene/2d/animated_sprite_2d.h"
#include "scene/2d/sprite_2d.h"
#include "scene/3d/sprite_3d.h"
#include "scene/animation/animation_player.h"
#include "servers/audio/audio_stream.h"
@ -357,7 +357,7 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se
Size2 size;
if (Object::cast_to<Sprite>(object) || Object::cast_to<Sprite3D>(object)) {
if (Object::cast_to<Sprite2D>(object) || Object::cast_to<Sprite3D>(object)) {
Ref<Texture2D> texture = object->call("get_texture");
if (!texture.is_valid()) {
@ -379,7 +379,7 @@ Rect2 AnimationTrackEditSpriteFrame::get_key_rect(int p_index, float p_pixels_se
if (vframes > 1) {
size.y /= vframes;
}
} else if (Object::cast_to<AnimatedSprite>(object) || Object::cast_to<AnimatedSprite3D>(object)) {
} else if (Object::cast_to<AnimatedSprite2D>(object) || Object::cast_to<AnimatedSprite3D>(object)) {
Ref<SpriteFrames> sf = object->call("get_sprite_frames");
if (sf.is_null()) {
@ -436,7 +436,7 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
Ref<Texture2D> texture;
Rect2 region;
if (Object::cast_to<Sprite>(object) || Object::cast_to<Sprite3D>(object)) {
if (Object::cast_to<Sprite2D>(object) || Object::cast_to<Sprite3D>(object)) {
texture = object->call("get_texture");
if (!texture.is_valid()) {
@ -473,7 +473,7 @@ void AnimationTrackEditSpriteFrame::draw_key(int p_index, float p_pixels_sec, in
region.position.x += region.size.x * coords.x;
region.position.y += region.size.y * coords.y;
} else if (Object::cast_to<AnimatedSprite>(object) || Object::cast_to<AnimatedSprite3D>(object)) {
} else if (Object::cast_to<AnimatedSprite2D>(object) || Object::cast_to<AnimatedSprite3D>(object)) {
Ref<SpriteFrames> sf = object->call("get_sprite_frames");
if (sf.is_null()) {
@ -1300,14 +1300,14 @@ AnimationTrackEdit *AnimationTrackEditDefaultPlugin::create_value_track_edit(Obj
return audio;
}
if (p_property == "frame" && (p_object->is_class("Sprite") || p_object->is_class("Sprite3D") || p_object->is_class("AnimatedSprite") || p_object->is_class("AnimatedSprite3D"))) {
if (p_property == "frame" && (p_object->is_class("Sprite2D") || p_object->is_class("Sprite3D") || p_object->is_class("AnimatedSprite2D") || p_object->is_class("AnimatedSprite3D"))) {
AnimationTrackEditSpriteFrame *sprite = memnew(AnimationTrackEditSpriteFrame);
sprite->set_node(p_object);
return sprite;
}
if (p_property == "frame_coords" && (p_object->is_class("Sprite") || p_object->is_class("Sprite3D"))) {
if (p_property == "frame_coords" && (p_object->is_class("Sprite2D") || p_object->is_class("Sprite3D"))) {
AnimationTrackEditSpriteFrame *sprite = memnew(AnimationTrackEditSpriteFrame);
sprite->set_as_coords();

View File

@ -42,10 +42,10 @@
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/plugins/canvas_item_editor_plugin.h"
#include "editor/plugins/spatial_editor_plugin.h"
#include "editor/plugins/node_3d_editor_plugin.h"
#include "editor/property_editor.h"
#include "main/performance.h"
#include "scene/3d/camera.h"
#include "scene/3d/camera_3d.h"
#include "scene/debugger/scene_debugger.h"
#include "scene/gui/dialogs.h"
#include "scene/gui/label.h"
@ -791,12 +791,12 @@ void ScriptEditorDebugger::_notification(int p_what) {
} else if (camera_override >= CameraOverride::OVERRIDE_3D_1) {
int viewport_idx = camera_override - CameraOverride::OVERRIDE_3D_1;
SpatialEditorViewport *viewport = SpatialEditor::get_singleton()->get_editor_viewport(viewport_idx);
Camera *const cam = viewport->get_camera();
Node3DEditorViewport *viewport = Node3DEditor::get_singleton()->get_editor_viewport(viewport_idx);
Camera3D *const cam = viewport->get_camera();
Array msg;
msg.push_back(cam->get_camera_transform());
if (cam->get_projection() == Camera::PROJECTION_ORTHOGONAL) {
if (cam->get_projection() == Camera3D::PROJECTION_ORTHOGONAL) {
msg.push_back(false);
msg.push_back(cam->get_size());
} else {

View File

@ -646,7 +646,7 @@ void EditorProperty::_gui_input(const Ref<InputEvent> &p_event) {
emit_signal("property_keyed", property, use_keying_next());
if (use_keying_next()) {
if (property == "frame_coords" && (object->is_class("Sprite") || object->is_class("Sprite3D"))) {
if (property == "frame_coords" && (object->is_class("Sprite2D") || object->is_class("Sprite3D"))) {
Vector2 new_coords = object->get(property);
new_coords.x++;
if (new_coords.x >= object->get("hframes").operator int64_t()) {

View File

@ -114,32 +114,33 @@
#include "editor/plugins/asset_library_editor_plugin.h"
#include "editor/plugins/audio_stream_editor_plugin.h"
#include "editor/plugins/baked_lightmap_editor_plugin.h"
#include "editor/plugins/camera_editor_plugin.h"
#include "editor/plugins/camera_3d_editor_plugin.h"
#include "editor/plugins/canvas_item_editor_plugin.h"
#include "editor/plugins/collision_polygon_2d_editor_plugin.h"
#include "editor/plugins/collision_polygon_editor_plugin.h"
#include "editor/plugins/collision_polygon_3d_editor_plugin.h"
#include "editor/plugins/collision_shape_2d_editor_plugin.h"
#include "editor/plugins/cpu_particles_2d_editor_plugin.h"
#include "editor/plugins/cpu_particles_editor_plugin.h"
#include "editor/plugins/cpu_particles_3d_editor_plugin.h"
#include "editor/plugins/curve_editor_plugin.h"
#include "editor/plugins/debugger_editor_plugin.h"
#include "editor/plugins/editor_preview_plugins.h"
#include "editor/plugins/gi_probe_editor_plugin.h"
#include "editor/plugins/gpu_particles_2d_editor_plugin.h"
#include "editor/plugins/gpu_particles_3d_editor_plugin.h"
#include "editor/plugins/gradient_editor_plugin.h"
#include "editor/plugins/item_list_editor_plugin.h"
#include "editor/plugins/light_occluder_2d_editor_plugin.h"
#include "editor/plugins/line_2d_editor_plugin.h"
#include "editor/plugins/material_editor_plugin.h"
#include "editor/plugins/mesh_editor_plugin.h"
#include "editor/plugins/mesh_instance_editor_plugin.h"
#include "editor/plugins/mesh_instance_3d_editor_plugin.h"
#include "editor/plugins/mesh_library_editor_plugin.h"
#include "editor/plugins/multimesh_editor_plugin.h"
#include "editor/plugins/navigation_polygon_editor_plugin.h"
#include "editor/plugins/particles_2d_editor_plugin.h"
#include "editor/plugins/particles_editor_plugin.h"
#include "editor/plugins/node_3d_editor_plugin.h"
#include "editor/plugins/path_2d_editor_plugin.h"
#include "editor/plugins/path_editor_plugin.h"
#include "editor/plugins/physical_bone_plugin.h"
#include "editor/plugins/path_3d_editor_plugin.h"
#include "editor/plugins/physical_bone_3d_editor_plugin.h"
#include "editor/plugins/polygon_2d_editor_plugin.h"
#include "editor/plugins/resource_preloader_editor_plugin.h"
#include "editor/plugins/root_motion_editor_plugin.h"
@ -147,10 +148,9 @@
#include "editor/plugins/script_text_editor.h"
#include "editor/plugins/shader_editor_plugin.h"
#include "editor/plugins/skeleton_2d_editor_plugin.h"
#include "editor/plugins/skeleton_editor_plugin.h"
#include "editor/plugins/skeleton_ik_editor_plugin.h"
#include "editor/plugins/spatial_editor_plugin.h"
#include "editor/plugins/sprite_editor_plugin.h"
#include "editor/plugins/skeleton_3d_editor_plugin.h"
#include "editor/plugins/skeleton_ik_3d_editor_plugin.h"
#include "editor/plugins/sprite_2d_editor_plugin.h"
#include "editor/plugins/sprite_frames_editor_plugin.h"
#include "editor/plugins/style_box_editor_plugin.h"
#include "editor/plugins/text_editor.h"
@ -1107,7 +1107,7 @@ void EditorNode::_find_node_types(Node *p_node, int &count_2d, int &count_3d) {
if (p_node->is_class("CanvasItem"))
count_2d++;
else if (p_node->is_class("Spatial"))
else if (p_node->is_class("Node3D"))
count_3d++;
for (int i = 0; i < p_node->get_child_count(); i++)
@ -1139,7 +1139,7 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) {
if (is2d) {
img = scene_root->get_texture()->get_data();
} else {
img = SpatialEditor::get_singleton()->get_editor_viewport(0)->get_viewport_node()->get_texture()->get_data();
img = Node3DEditor::get_singleton()->get_editor_viewport(0)->get_viewport_node()->get_texture()->get_data();
}
if (img.is_valid()) {
@ -3595,8 +3595,8 @@ void EditorNode::register_editor_types() {
ClassDB::register_class<EditorSelection>();
ClassDB::register_class<EditorFileDialog>();
ClassDB::register_virtual_class<EditorSettings>();
ClassDB::register_class<EditorSpatialGizmo>();
ClassDB::register_class<EditorSpatialGizmoPlugin>();
ClassDB::register_class<EditorNode3DGizmo>();
ClassDB::register_class<EditorNode3DGizmoPlugin>();
ClassDB::register_virtual_class<EditorResourcePreview>();
ClassDB::register_class<EditorResourcePreviewGenerator>();
ClassDB::register_virtual_class<EditorFileSystem>();
@ -6571,7 +6571,7 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(DebuggerEditorPlugin(this, debug_menu)));
add_editor_plugin(memnew(AnimationPlayerEditorPlugin(this)));
add_editor_plugin(memnew(CanvasItemEditorPlugin(this)));
add_editor_plugin(memnew(SpatialEditorPlugin(this)));
add_editor_plugin(memnew(Node3DEditorPlugin(this)));
add_editor_plugin(memnew(ScriptEditorPlugin(this)));
EditorAudioBuses *audio_bus_editor = EditorAudioBuses::register_editor();
@ -6597,18 +6597,19 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(ShaderEditorPlugin(this)));
add_editor_plugin(memnew(VisualShaderEditorPlugin(this)));
add_editor_plugin(memnew(CameraEditorPlugin(this)));
add_editor_plugin(memnew(Camera3DEditorPlugin(this)));
add_editor_plugin(memnew(ThemeEditorPlugin(this)));
add_editor_plugin(memnew(MultiMeshEditorPlugin(this)));
add_editor_plugin(memnew(MeshInstanceEditorPlugin(this)));
add_editor_plugin(memnew(MeshInstance3DEditorPlugin(this)));
add_editor_plugin(memnew(AnimationTreeEditorPlugin(this)));
add_editor_plugin(memnew(MeshLibraryEditorPlugin(this)));
add_editor_plugin(memnew(StyleBoxEditorPlugin(this)));
add_editor_plugin(memnew(SpriteEditorPlugin(this)));
add_editor_plugin(memnew(Sprite2DEditorPlugin(this)));
add_editor_plugin(memnew(Skeleton2DEditorPlugin(this)));
add_editor_plugin(memnew(ParticlesEditorPlugin(this)));
add_editor_plugin(memnew(GPUParticles2DEditorPlugin(this)));
add_editor_plugin(memnew(GPUParticles3DEditorPlugin(this)));
add_editor_plugin(memnew(CPUParticles2DEditorPlugin(this)));
add_editor_plugin(memnew(CPUParticlesEditorPlugin(this)));
add_editor_plugin(memnew(CPUParticles3DEditorPlugin(this)));
add_editor_plugin(memnew(ResourcePreloaderEditorPlugin(this)));
add_editor_plugin(memnew(ItemListEditorPlugin(this)));
add_editor_plugin(memnew(Polygon3DEditorPlugin(this)));
@ -6617,11 +6618,10 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(TileMapEditorPlugin(this)));
add_editor_plugin(memnew(SpriteFramesEditorPlugin(this)));
add_editor_plugin(memnew(TextureRegionEditorPlugin(this)));
add_editor_plugin(memnew(Particles2DEditorPlugin(this)));
add_editor_plugin(memnew(GIProbeEditorPlugin(this)));
// add_editor_plugin(memnew(BakedLightmapEditorPlugin(this)));
//add_editor_plugin(memnew(BakedLightmapEditorPlugin(this)));
add_editor_plugin(memnew(Path2DEditorPlugin(this)));
add_editor_plugin(memnew(PathEditorPlugin(this)));
add_editor_plugin(memnew(Path3DEditorPlugin(this)));
add_editor_plugin(memnew(Line2DEditorPlugin(this)));
add_editor_plugin(memnew(Polygon2DEditorPlugin(this)));
add_editor_plugin(memnew(LightOccluder2DEditorPlugin(this)));
@ -6632,9 +6632,9 @@ EditorNode::EditorNode() {
add_editor_plugin(memnew(TextureEditorPlugin(this)));
add_editor_plugin(memnew(AudioStreamEditorPlugin(this)));
add_editor_plugin(memnew(AudioBusesEditorPlugin(audio_bus_editor)));
add_editor_plugin(memnew(SkeletonEditorPlugin(this)));
add_editor_plugin(memnew(SkeletonIKEditorPlugin(this)));
add_editor_plugin(memnew(PhysicalBonePlugin(this)));
add_editor_plugin(memnew(Skeleton3DEditorPlugin(this)));
add_editor_plugin(memnew(SkeletonIK3DEditorPlugin(this)));
add_editor_plugin(memnew(PhysicalBone3DEditorPlugin(this)));
add_editor_plugin(memnew(MeshEditorPlugin(this)));
add_editor_plugin(memnew(MaterialEditorPlugin(this)));
@ -6851,7 +6851,7 @@ bool EditorPluginList::forward_gui_input(const Ref<InputEvent> &p_event) {
return discard;
}
bool EditorPluginList::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled) {
bool EditorPluginList::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled) {
bool discard = false;
for (int i = 0; i < plugins_list.size(); i++) {

View File

@ -894,7 +894,7 @@ public:
bool forward_gui_input(const Ref<InputEvent> &p_event);
void forward_canvas_draw_over_viewport(Control *p_overlay);
void forward_canvas_force_draw_over_viewport(Control *p_overlay);
bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled);
bool forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event, bool serve_when_force_input_enabled);
void forward_spatial_draw_over_viewport(Control *p_overlay);
void forward_spatial_force_draw_over_viewport(Control *p_overlay);
void add_plugin(EditorPlugin *p_plugin);

View File

@ -38,8 +38,8 @@
#include "editor_resource_preview.h"
#include "main/main.h"
#include "plugins/canvas_item_editor_plugin.h"
#include "plugins/spatial_editor_plugin.h"
#include "scene/3d/camera.h"
#include "plugins/node_3d_editor_plugin.h"
#include "scene/3d/camera_3d.h"
#include "scene/gui/popup_menu.h"
#include "servers/visual_server.h"
@ -371,24 +371,24 @@ void EditorPlugin::add_control_to_container(CustomControlContainer p_location, C
case CONTAINER_SPATIAL_EDITOR_MENU: {
SpatialEditor::get_singleton()->add_control_to_menu_panel(p_control);
Node3DEditor::get_singleton()->add_control_to_menu_panel(p_control);
} break;
case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT: {
SpatialEditor::get_singleton()->get_palette_split()->add_child(p_control);
SpatialEditor::get_singleton()->get_palette_split()->move_child(p_control, 0);
Node3DEditor::get_singleton()->get_palette_split()->add_child(p_control);
Node3DEditor::get_singleton()->get_palette_split()->move_child(p_control, 0);
} break;
case CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT: {
SpatialEditor::get_singleton()->get_palette_split()->add_child(p_control);
SpatialEditor::get_singleton()->get_palette_split()->move_child(p_control, 1);
Node3DEditor::get_singleton()->get_palette_split()->add_child(p_control);
Node3DEditor::get_singleton()->get_palette_split()->move_child(p_control, 1);
} break;
case CONTAINER_SPATIAL_EDITOR_BOTTOM: {
SpatialEditor::get_singleton()->get_shader_split()->add_child(p_control);
Node3DEditor::get_singleton()->get_shader_split()->add_child(p_control);
} break;
case CONTAINER_CANVAS_EDITOR_MENU: {
@ -445,18 +445,18 @@ void EditorPlugin::remove_control_from_container(CustomControlContainer p_locati
case CONTAINER_SPATIAL_EDITOR_MENU: {
SpatialEditor::get_singleton()->remove_control_from_menu_panel(p_control);
Node3DEditor::get_singleton()->remove_control_from_menu_panel(p_control);
} break;
case CONTAINER_SPATIAL_EDITOR_SIDE_LEFT:
case CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT: {
SpatialEditor::get_singleton()->get_palette_split()->remove_child(p_control);
Node3DEditor::get_singleton()->get_palette_split()->remove_child(p_control);
} break;
case CONTAINER_SPATIAL_EDITOR_BOTTOM: {
SpatialEditor::get_singleton()->get_shader_split()->remove_child(p_control);
Node3DEditor::get_singleton()->get_shader_split()->remove_child(p_control);
} break;
case CONTAINER_CANVAS_EDITOR_MENU: {
@ -562,10 +562,10 @@ void EditorPlugin::forward_canvas_force_draw_over_viewport(Control *p_overlay) {
// Updates the overlays of the 2D viewport or, if in 3D mode, of every 3D viewport.
int EditorPlugin::update_overlays() const {
if (SpatialEditor::get_singleton()->is_visible()) {
if (Node3DEditor::get_singleton()->is_visible()) {
int count = 0;
for (uint32_t i = 0; i < SpatialEditor::VIEWPORTS_COUNT; i++) {
SpatialEditorViewport *vp = SpatialEditor::get_singleton()->get_editor_viewport(i);
for (uint32_t i = 0; i < Node3DEditor::VIEWPORTS_COUNT; i++) {
Node3DEditorViewport *vp = Node3DEditor::get_singleton()->get_editor_viewport(i);
if (vp->is_visible()) {
vp->update_surface();
count++;
@ -579,7 +579,7 @@ int EditorPlugin::update_overlays() const {
}
}
bool EditorPlugin::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) {
bool EditorPlugin::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
if (get_script_instance() && get_script_instance()->has_method("forward_spatial_gui_input")) {
return get_script_instance()->call("forward_spatial_gui_input", p_camera, p_event);
@ -724,12 +724,12 @@ void EditorPlugin::remove_export_plugin(const Ref<EditorExportPlugin> &p_exporte
EditorExport::get_singleton()->remove_export_plugin(p_exporter);
}
void EditorPlugin::add_spatial_gizmo_plugin(const Ref<EditorSpatialGizmoPlugin> &p_gizmo_plugin) {
SpatialEditor::get_singleton()->add_gizmo_plugin(p_gizmo_plugin);
void EditorPlugin::add_spatial_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin) {
Node3DEditor::get_singleton()->add_gizmo_plugin(p_gizmo_plugin);
}
void EditorPlugin::remove_spatial_gizmo_plugin(const Ref<EditorSpatialGizmoPlugin> &p_gizmo_plugin) {
SpatialEditor::get_singleton()->remove_gizmo_plugin(p_gizmo_plugin);
void EditorPlugin::remove_spatial_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin) {
Node3DEditor::get_singleton()->remove_gizmo_plugin(p_gizmo_plugin);
}
void EditorPlugin::add_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin) {
@ -865,7 +865,7 @@ void EditorPlugin::_bind_methods() {
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_canvas_gui_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_canvas_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_canvas_force_draw_over_viewport", PropertyInfo(Variant::OBJECT, "overlay", PROPERTY_HINT_RESOURCE_TYPE, "Control")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_spatial_gui_input", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_spatial_gui_input", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera3D"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_plugin_name"));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(PropertyInfo(Variant::OBJECT, "icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "get_plugin_icon"));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "has_main_screen"));

View File

@ -42,14 +42,14 @@
#include "scene/resources/texture.h"
class EditorNode;
class Spatial;
class Camera;
class Node3D;
class Camera3D;
class EditorSelection;
class EditorExport;
class EditorSettings;
class EditorImportPlugin;
class EditorExportPlugin;
class EditorSpatialGizmoPlugin;
class EditorNode3DGizmoPlugin;
class EditorResourcePreview;
class EditorFileSystem;
class EditorToolAddons;
@ -185,7 +185,7 @@ public:
virtual void forward_canvas_draw_over_viewport(Control *p_overlay);
virtual void forward_canvas_force_draw_over_viewport(Control *p_overlay);
virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event);
virtual bool forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event);
virtual void forward_spatial_draw_over_viewport(Control *p_overlay);
virtual void forward_spatial_force_draw_over_viewport(Control *p_overlay);
@ -227,8 +227,8 @@ public:
void add_export_plugin(const Ref<EditorExportPlugin> &p_exporter);
void remove_export_plugin(const Ref<EditorExportPlugin> &p_exporter);
void add_spatial_gizmo_plugin(const Ref<EditorSpatialGizmoPlugin> &p_gizmo_plugin);
void remove_spatial_gizmo_plugin(const Ref<EditorSpatialGizmoPlugin> &p_gizmo_plugin);
void add_spatial_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin);
void remove_spatial_gizmo_plugin(const Ref<EditorNode3DGizmoPlugin> &p_gizmo_plugin);
void add_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin);
void remove_inspector_plugin(const Ref<EditorInspectorPlugin> &p_plugin);

View File

Before

Width:  |  Height:  |  Size: 708 B

After

Width:  |  Height:  |  Size: 708 B

View File

Before

Width:  |  Height:  |  Size: 226 B

After

Width:  |  Height:  |  Size: 226 B

View File

Before

Width:  |  Height:  |  Size: 613 B

After

Width:  |  Height:  |  Size: 613 B

View File

Before

Width:  |  Height:  |  Size: 327 B

After

Width:  |  Height:  |  Size: 327 B

View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

Before

Width:  |  Height:  |  Size: 347 B

After

Width:  |  Height:  |  Size: 347 B

View File

Before

Width:  |  Height:  |  Size: 344 B

After

Width:  |  Height:  |  Size: 344 B

View File

Before

Width:  |  Height:  |  Size: 558 B

After

Width:  |  Height:  |  Size: 558 B

View File

Before

Width:  |  Height:  |  Size: 255 B

After

Width:  |  Height:  |  Size: 255 B

View File

Before

Width:  |  Height:  |  Size: 260 B

After

Width:  |  Height:  |  Size: 260 B

View File

Before

Width:  |  Height:  |  Size: 604 B

After

Width:  |  Height:  |  Size: 604 B

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 352 B

After

Width:  |  Height:  |  Size: 352 B

View File

Before

Width:  |  Height:  |  Size: 340 B

After

Width:  |  Height:  |  Size: 340 B

View File

Before

Width:  |  Height:  |  Size: 497 B

After

Width:  |  Height:  |  Size: 497 B

View File

Before

Width:  |  Height:  |  Size: 447 B

After

Width:  |  Height:  |  Size: 447 B

View File

Before

Width:  |  Height:  |  Size: 469 B

After

Width:  |  Height:  |  Size: 469 B

View File

Before

Width:  |  Height:  |  Size: 587 B

After

Width:  |  Height:  |  Size: 587 B

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 516 B

After

Width:  |  Height:  |  Size: 516 B

View File

Before

Width:  |  Height:  |  Size: 487 B

After

Width:  |  Height:  |  Size: 487 B

View File

Before

Width:  |  Height:  |  Size: 456 B

After

Width:  |  Height:  |  Size: 456 B

View File

Before

Width:  |  Height:  |  Size: 802 B

After

Width:  |  Height:  |  Size: 802 B

View File

Before

Width:  |  Height:  |  Size: 700 B

After

Width:  |  Height:  |  Size: 700 B

View File

Before

Width:  |  Height:  |  Size: 527 B

After

Width:  |  Height:  |  Size: 527 B

View File

Before

Width:  |  Height:  |  Size: 651 B

After

Width:  |  Height:  |  Size: 651 B

View File

Before

Width:  |  Height:  |  Size: 214 B

After

Width:  |  Height:  |  Size: 214 B

View File

Before

Width:  |  Height:  |  Size: 676 B

After

Width:  |  Height:  |  Size: 676 B

View File

Before

Width:  |  Height:  |  Size: 669 B

After

Width:  |  Height:  |  Size: 669 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 264 B

After

Width:  |  Height:  |  Size: 264 B

View File

Before

Width:  |  Height:  |  Size: 305 B

After

Width:  |  Height:  |  Size: 305 B

View File

Before

Width:  |  Height:  |  Size: 595 B

After

Width:  |  Height:  |  Size: 595 B

View File

Before

Width:  |  Height:  |  Size: 538 B

After

Width:  |  Height:  |  Size: 538 B

View File

Before

Width:  |  Height:  |  Size: 917 B

After

Width:  |  Height:  |  Size: 917 B

View File

Before

Width:  |  Height:  |  Size: 399 B

After

Width:  |  Height:  |  Size: 399 B

View File

Before

Width:  |  Height:  |  Size: 587 B

After

Width:  |  Height:  |  Size: 587 B

View File

Before

Width:  |  Height:  |  Size: 162 B

After

Width:  |  Height:  |  Size: 162 B

View File

Before

Width:  |  Height:  |  Size: 255 B

After

Width:  |  Height:  |  Size: 255 B

View File

Before

Width:  |  Height:  |  Size: 690 B

After

Width:  |  Height:  |  Size: 690 B

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

Before

Width:  |  Height:  |  Size: 545 B

After

Width:  |  Height:  |  Size: 545 B

View File

Before

Width:  |  Height:  |  Size: 523 B

After

Width:  |  Height:  |  Size: 523 B

View File

Before

Width:  |  Height:  |  Size: 229 B

After

Width:  |  Height:  |  Size: 229 B

View File

Before

Width:  |  Height:  |  Size: 223 B

After

Width:  |  Height:  |  Size: 223 B

View File

@ -1 +0,0 @@
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m7.9629 1.002a1.0001 1.0001 0 0 0 -.41016.10352l-3.7891 1.8945h8.4727l-3.7891-1.8945a1.0001 1.0001 0 0 0 -.48438-.10352z" fill="#ff7070"/><path d="m3.7637 3-2.2109 1.1055a1.0001 1.0001 0 0 0 -.55273.89453h3.2363l3.7637-1.8809 3.7637 1.8809h3.2363a1.0001 1.0001 0 0 0 -.55273-.89453l-2.2109-1.1055h-8.4727z" fill="#ffeb70"/><path d="m1 5v2h2v-.38086l.76172.38086h8.4766l.76172-.38086v.38086h2v-2h-3.2363l-3.7637 1.8828-3.7637-1.8828h-3.2363z" fill="#9dff70"/><path d="m1 7v2h2v-2zm2.7617 0 3.2383 1.6191v.38086h2v-.38086l3.2383-1.6191zm9.2383 0v2h2v-2z" fill="#70ffb9"/><path d="m1 9v2h3.2344l-1.2344-.61719v-1.3828h-2zm6 0v2h2v-2zm6 0v1.3828l-1.2344.61719h3.2344v-2h-2z" fill="#70deff"/><path d="m3.7637 13 3.7891 1.8945a1.0001 1.0001 0 0 0 .48438.10547 1.0001 1.0001 0 0 0 .41016-.10547l3.7891-1.8945h-8.4727z" fill="#ff70ac"/><path d="m1 11a1.0001 1.0001 0 0 0 .55273.89453l2.2109 1.1055h8.4727l2.2109-1.1055a1.0001 1.0001 0 0 0 .55273-.89453h-3.2344l-2.7656 1.3828v-1.3828h-2v1.3828l-2.7656-1.3828h-3.2344z" fill="#9f70ff"/></svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 177 B

After

Width:  |  Height:  |  Size: 177 B

View File

Before

Width:  |  Height:  |  Size: 387 B

After

Width:  |  Height:  |  Size: 387 B

View File

Before

Width:  |  Height:  |  Size: 222 B

After

Width:  |  Height:  |  Size: 222 B

View File

Before

Width:  |  Height:  |  Size: 644 B

After

Width:  |  Height:  |  Size: 644 B

View File

Before

Width:  |  Height:  |  Size: 408 B

After

Width:  |  Height:  |  Size: 408 B

View File

Before

Width:  |  Height:  |  Size: 511 B

After

Width:  |  Height:  |  Size: 511 B

View File

Before

Width:  |  Height:  |  Size: 581 B

After

Width:  |  Height:  |  Size: 581 B

View File

Before

Width:  |  Height:  |  Size: 577 B

After

Width:  |  Height:  |  Size: 577 B

View File

Before

Width:  |  Height:  |  Size: 532 B

After

Width:  |  Height:  |  Size: 532 B

View File

Before

Width:  |  Height:  |  Size: 244 B

After

Width:  |  Height:  |  Size: 244 B

View File

@ -1 +0,0 @@
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m1 1044.4 7 3 7-3-7-3z" fill="#a2d2ff" fill-rule="evenodd" transform="translate(0 -1036.4)"/></svg>

Before

Width:  |  Height:  |  Size: 191 B

View File

Before

Width:  |  Height:  |  Size: 191 B

After

Width:  |  Height:  |  Size: 191 B

View File

@ -33,12 +33,12 @@
#include "core/os/os.h"
#include "editor/editor_node.h"
#include "editor/import/collada.h"
#include "scene/3d/camera.h"
#include "scene/3d/light.h"
#include "scene/3d/mesh_instance.h"
#include "scene/3d/path.h"
#include "scene/3d/skeleton.h"
#include "scene/3d/spatial.h"
#include "scene/3d/camera_3d.h"
#include "scene/3d/light_3d.h"
#include "scene/3d/mesh_instance_3d.h"
#include "scene/3d/node_3d.h"
#include "scene/3d/path_3d.h"
#include "scene/3d/skeleton_3d.h"
#include "scene/animation/animation_player.h"
#include "scene/resources/animation.h"
#include "scene/resources/packed_scene.h"
@ -47,13 +47,13 @@
struct ColladaImport {
Collada collada;
Spatial *scene;
Node3D *scene;
Vector<Ref<Animation>> animations;
struct NodeMap {
//String path;
Spatial *node;
Node3D *node;
int bone;
List<int> anim_tracks;
@ -76,17 +76,17 @@ struct ColladaImport {
Map<String, Ref<ArrayMesh>> mesh_cache;
Map<String, Ref<Curve3D>> curve_cache;
Map<String, Ref<Material>> material_cache;
Map<Collada::Node *, Skeleton *> skeleton_map;
Map<Collada::Node *, Skeleton3D *> skeleton_map;
Map<Skeleton *, Map<String, int>> skeleton_bone_map;
Map<Skeleton3D *, Map<String, int>> skeleton_bone_map;
Set<String> valid_animated_nodes;
Vector<int> valid_animated_properties;
Map<String, bool> bones_with_animation;
Error _populate_skeleton(Skeleton *p_skeleton, Collada::Node *p_node, int &r_bone, int p_parent);
Error _populate_skeleton(Skeleton3D *p_skeleton, Collada::Node *p_node, int &r_bone, int p_parent);
Error _create_scene_skeletons(Collada::Node *p_node);
Error _create_scene(Collada::Node *p_node, Spatial *p_parent);
Error _create_scene(Collada::Node *p_node, Node3D *p_parent);
Error _create_resources(Collada::Node *p_node, bool p_use_compression);
Error _create_material(const String &p_target);
Error _create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_mesh, const Map<String, Collada::NodeGeometry::Material> &p_material_map, const Collada::MeshData &meshdata, const Transform &p_local_xform, const Vector<int> &bone_remap, const Collada::SkinControllerData *p_skin_controller, const Collada::MorphControllerData *p_morph_data, Vector<Ref<ArrayMesh>> p_morph_meshes = Vector<Ref<ArrayMesh>>(), bool p_use_compression = false, bool p_use_mesh_material = false);
@ -110,7 +110,7 @@ struct ColladaImport {
}
};
Error ColladaImport::_populate_skeleton(Skeleton *p_skeleton, Collada::Node *p_node, int &r_bone, int p_parent) {
Error ColladaImport::_populate_skeleton(Skeleton3D *p_skeleton, Collada::Node *p_node, int &r_bone, int p_parent) {
if (p_node->type != Collada::Node::TYPE_JOINT)
return OK;
@ -174,7 +174,7 @@ Error ColladaImport::_create_scene_skeletons(Collada::Node *p_node) {
if (p_node->type == Collada::Node::TYPE_SKELETON) {
Skeleton *sk = memnew(Skeleton);
Skeleton3D *sk = memnew(Skeleton3D);
int bone = 0;
for (int i = 0; i < p_node->children.size(); i++) {
@ -193,15 +193,15 @@ Error ColladaImport::_create_scene_skeletons(Collada::Node *p_node) {
return OK;
}
Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
Error ColladaImport::_create_scene(Collada::Node *p_node, Node3D *p_parent) {
Spatial *node = NULL;
Node3D *node = NULL;
switch (p_node->type) {
case Collada::Node::TYPE_NODE: {
node = memnew(Spatial);
node = memnew(Node3D);
} break;
case Collada::Node::TYPE_JOINT: {
@ -223,7 +223,7 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
if (!bool(GLOBAL_DEF("collada/use_ambient", false)))
return OK;
//well, it's an ambient light..
Light *l = memnew(DirectionalLight);
Light3D *l = memnew(DirectionalLight3D);
//l->set_color(Light::COLOR_AMBIENT,ld.color);
//l->set_color(Light::COLOR_DIFFUSE,Color(0,0,0));
//l->set_color(Light::COLOR_SPECULAR,Color(0,0,0));
@ -232,7 +232,7 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
} else if (ld.mode == Collada::LightData::MODE_DIRECTIONAL) {
//well, it's an ambient light..
Light *l = memnew(DirectionalLight);
Light3D *l = memnew(DirectionalLight3D);
/*
if (found_ambient) //use it here
l->set_color(Light::COLOR_AMBIENT,ambient);
@ -243,12 +243,12 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
node = l;
} else {
Light *l;
Light3D *l;
if (ld.mode == Collada::LightData::MODE_OMNI)
l = memnew(OmniLight);
l = memnew(OmniLight3D);
else {
l = memnew(SpotLight);
l = memnew(SpotLight3D);
//l->set_parameter(Light::PARAM_SPOT_ANGLE,ld.spot_angle);
//l->set_parameter(Light::PARAM_SPOT_ATTENUATION,ld.spot_exp);
}
@ -262,13 +262,13 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
} else {
node = memnew(Spatial);
node = memnew(Node3D);
}
} break;
case Collada::Node::TYPE_CAMERA: {
Collada::NodeCamera *cam = static_cast<Collada::NodeCamera *>(p_node);
Camera *camera = memnew(Camera);
Camera3D *camera = memnew(Camera3D);
if (collada.state.camera_data_map.has(cam->camera)) {
@ -280,12 +280,12 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
if (cd.orthogonal.y_mag) {
camera->set_keep_aspect_mode(Camera::KEEP_HEIGHT);
camera->set_keep_aspect_mode(Camera3D::KEEP_HEIGHT);
camera->set_orthogonal(cd.orthogonal.y_mag * 2.0, cd.z_near, cd.z_far);
} else if (!cd.orthogonal.y_mag && cd.orthogonal.x_mag) {
camera->set_keep_aspect_mode(Camera::KEEP_WIDTH);
camera->set_keep_aspect_mode(Camera3D::KEEP_WIDTH);
camera->set_orthogonal(cd.orthogonal.x_mag * 2.0, cd.z_near, cd.z_far);
}
@ -314,17 +314,17 @@ Error ColladaImport::_create_scene(Collada::Node *p_node, Spatial *p_parent) {
if (collada.state.curve_data_map.has(ng->source)) {
node = memnew(Path);
node = memnew(Path3D);
} else {
//mesh since nothing else
node = memnew(MeshInstance);
node = memnew(MeshInstance3D);
//Object::cast_to<MeshInstance>(node)->set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT, true);
}
} break;
case Collada::Node::TYPE_SKELETON: {
ERR_FAIL_COND_V(!skeleton_map.has(p_node), ERR_CANT_CREATE);
Skeleton *sk = skeleton_map[p_node];
Skeleton3D *sk = skeleton_map[p_node];
node = sk;
} break;
}
@ -1010,12 +1010,12 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
if (p_node->type == Collada::Node::TYPE_GEOMETRY && node_map.has(p_node->id)) {
Spatial *node = node_map[p_node->id].node;
Node3D *node = node_map[p_node->id].node;
Collada::NodeGeometry *ng = static_cast<Collada::NodeGeometry *>(p_node);
if (Object::cast_to<Path>(node)) {
if (Object::cast_to<Path3D>(node)) {
Path *path = Object::cast_to<Path>(node);
Path3D *path = Object::cast_to<Path3D>(node);
if (curve_cache.has(ng->source)) {
@ -1083,11 +1083,11 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
}
}
if (Object::cast_to<MeshInstance>(node)) {
if (Object::cast_to<MeshInstance3D>(node)) {
Collada::NodeGeometry *ng2 = static_cast<Collada::NodeGeometry *>(p_node);
MeshInstance *mi = Object::cast_to<MeshInstance>(node);
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(node);
ERR_FAIL_COND_V(!mi, ERR_BUG);
@ -1114,7 +1114,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
String skname = skeletons[0];
ERR_FAIL_COND_V(!node_map.has(skname), ERR_INVALID_DATA);
NodeMap nmsk = node_map[skname];
Skeleton *sk = Object::cast_to<Skeleton>(nmsk.node);
Skeleton3D *sk = Object::cast_to<Skeleton3D>(nmsk.node);
ERR_FAIL_COND_V(!sk, ERR_INVALID_DATA);
ERR_FAIL_COND_V(!skeleton_bone_map.has(sk), ERR_INVALID_DATA);
Map<String, int> &bone_remap_map = skeleton_bone_map[sk];
@ -1265,7 +1265,7 @@ Error ColladaImport::load(const String &p_path, int p_flags, bool p_force_make_t
ERR_FAIL_COND_V(!collada.state.visual_scene_map.has(collada.state.root_visual_scene), ERR_INVALID_DATA);
Collada::VisualScene &vs = collada.state.visual_scene_map[collada.state.root_visual_scene];
scene = memnew(Spatial); // root
scene = memnew(Node3D); // root
//determine what's going on with the lights
for (int i = 0; i < vs.root_nodes.size(); i++) {
@ -1530,7 +1530,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
String path = scene->get_path_to(nm.node);
if (nm.bone >= 0) {
Skeleton *sk = static_cast<Skeleton *>(nm.node);
Skeleton3D *sk = static_cast<Skeleton3D *>(nm.node);
String name = sk->get_bone_name(nm.bone);
path = path + ":" + name;
}
@ -1621,7 +1621,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
if (nm.bone >= 0) {
//make bone transform relative to rest (in case of skeleton)
Skeleton *sk = Object::cast_to<Skeleton>(nm.node);
Skeleton3D *sk = Object::cast_to<Skeleton3D>(nm.node);
if (sk) {
xform = sk->get_bone_rest(nm.bone).affine_inverse() * xform;
@ -1662,7 +1662,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
NodeMap &nm = node_map[E->key()];
String path = scene->get_path_to(nm.node);
ERR_CONTINUE(nm.bone < 0);
Skeleton *sk = static_cast<Skeleton *>(nm.node);
Skeleton3D *sk = static_cast<Skeleton3D *>(nm.node);
String name = sk->get_bone_name(nm.bone);
path = path + ":" + name;

View File

@ -37,9 +37,9 @@
#include "core/os/file_access.h"
#include "core/os/os.h"
#include "modules/regex/regex.h"
#include "scene/3d/bone_attachment.h"
#include "scene/3d/camera.h"
#include "scene/3d/mesh_instance.h"
#include "scene/3d/bone_attachment_3d.h"
#include "scene/3d/camera_3d.h"
#include "scene/3d/mesh_instance_3d.h"
#include "scene/animation/animation_player.h"
#include "scene/resources/surface_tool.h"
@ -2108,7 +2108,7 @@ Error EditorSceneImporterGLTF::_create_skeletons(GLTFState &state) {
GLTFSkeleton &gltf_skeleton = state.skeletons.write[skel_i];
Skeleton *skeleton = memnew(Skeleton);
Skeleton3D *skeleton = memnew(Skeleton3D);
gltf_skeleton.godot_skeleton = skeleton;
// Make a unique name, no gltf node represents this skeleton
@ -2485,12 +2485,12 @@ void EditorSceneImporterGLTF::_assign_scene_names(GLTFState &state) {
}
}
BoneAttachment *EditorSceneImporterGLTF::_generate_bone_attachment(GLTFState &state, Skeleton *skeleton, const GLTFNodeIndex node_index) {
BoneAttachment3D *EditorSceneImporterGLTF::_generate_bone_attachment(GLTFState &state, Skeleton3D *skeleton, const GLTFNodeIndex node_index) {
const GLTFNode *gltf_node = state.nodes[node_index];
const GLTFNode *bone_node = state.nodes[gltf_node->parent];
BoneAttachment *bone_attachment = memnew(BoneAttachment);
BoneAttachment3D *bone_attachment = memnew(BoneAttachment3D);
print_verbose("glTF: Creating bone attachment for: " + gltf_node->name);
ERR_FAIL_COND_V(!bone_node->joint, nullptr);
@ -2500,12 +2500,12 @@ BoneAttachment *EditorSceneImporterGLTF::_generate_bone_attachment(GLTFState &st
return bone_attachment;
}
MeshInstance *EditorSceneImporterGLTF::_generate_mesh_instance(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) {
MeshInstance3D *EditorSceneImporterGLTF::_generate_mesh_instance(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) {
const GLTFNode *gltf_node = state.nodes[node_index];
ERR_FAIL_INDEX_V(gltf_node->mesh, state.meshes.size(), nullptr);
MeshInstance *mi = memnew(MeshInstance);
MeshInstance3D *mi = memnew(MeshInstance3D);
print_verbose("glTF: Creating mesh for: " + gltf_node->name);
GLTFMesh &mesh = state.meshes.write[gltf_node->mesh];
@ -2522,12 +2522,12 @@ MeshInstance *EditorSceneImporterGLTF::_generate_mesh_instance(GLTFState &state,
return mi;
}
Camera *EditorSceneImporterGLTF::_generate_camera(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) {
Camera3D *EditorSceneImporterGLTF::_generate_camera(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) {
const GLTFNode *gltf_node = state.nodes[node_index];
ERR_FAIL_INDEX_V(gltf_node->camera, state.cameras.size(), nullptr);
Camera *camera = memnew(Camera);
Camera3D *camera = memnew(Camera3D);
print_verbose("glTF: Creating camera for: " + gltf_node->name);
const GLTFCamera &c = state.cameras[gltf_node->camera];
@ -2540,26 +2540,26 @@ Camera *EditorSceneImporterGLTF::_generate_camera(GLTFState &state, Node *scene_
return camera;
}
Spatial *EditorSceneImporterGLTF::_generate_spatial(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) {
Node3D *EditorSceneImporterGLTF::_generate_spatial(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) {
const GLTFNode *gltf_node = state.nodes[node_index];
Spatial *spatial = memnew(Spatial);
Node3D *spatial = memnew(Node3D);
print_verbose("glTF: Creating spatial for: " + gltf_node->name);
return spatial;
}
void EditorSceneImporterGLTF::_generate_scene_node(GLTFState &state, Node *scene_parent, Spatial *scene_root, const GLTFNodeIndex node_index) {
void EditorSceneImporterGLTF::_generate_scene_node(GLTFState &state, Node *scene_parent, Node3D *scene_root, const GLTFNodeIndex node_index) {
const GLTFNode *gltf_node = state.nodes[node_index];
Spatial *current_node = nullptr;
Node3D *current_node = nullptr;
// Is our parent a skeleton
Skeleton *active_skeleton = Object::cast_to<Skeleton>(scene_parent);
Skeleton3D *active_skeleton = Object::cast_to<Skeleton3D>(scene_parent);
if (gltf_node->skeleton >= 0) {
Skeleton *skeleton = state.skeletons[gltf_node->skeleton].godot_skeleton;
Skeleton3D *skeleton = state.skeletons[gltf_node->skeleton].godot_skeleton;
if (active_skeleton != skeleton) {
ERR_FAIL_COND_MSG(active_skeleton != nullptr, "glTF: Generating scene detected direct parented Skeletons");
@ -2577,7 +2577,7 @@ void EditorSceneImporterGLTF::_generate_scene_node(GLTFState &state, Node *scene
// If we have an active skeleton, and the node is node skinned, we need to create a bone attachment
if (current_node == nullptr && active_skeleton != nullptr && gltf_node->skin < 0) {
BoneAttachment *bone_attachment = _generate_bone_attachment(state, active_skeleton, node_index);
BoneAttachment3D *bone_attachment = _generate_bone_attachment(state, active_skeleton, node_index);
scene_parent->add_child(bone_attachment);
bone_attachment->set_owner(scene_root);
@ -2776,7 +2776,7 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye
const GLTFNode *node = state.nodes[E->key()];
if (node->skeleton >= 0) {
const Skeleton *sk = Object::cast_to<Skeleton>(state.scene_nodes.find(node_index)->get());
const Skeleton3D *sk = Object::cast_to<Skeleton3D>(state.scene_nodes.find(node_index)->get());
ERR_FAIL_COND(sk == nullptr);
const String path = ap->get_parent()->get_path_to(sk);
@ -2853,7 +2853,7 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye
xform.basis.set_quat_scale(rot, scale);
xform.origin = pos;
const Skeleton *skeleton = state.skeletons[node->skeleton].godot_skeleton;
const Skeleton3D *skeleton = state.skeletons[node->skeleton].godot_skeleton;
const int bone_idx = skeleton->find_bone(node->name);
xform = skeleton->get_bone_rest(bone_idx).affine_inverse() * xform;
@ -2922,7 +2922,7 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye
ap->add_animation(name, animation);
}
void EditorSceneImporterGLTF::_process_mesh_instances(GLTFState &state, Spatial *scene_root) {
void EditorSceneImporterGLTF::_process_mesh_instances(GLTFState &state, Node3D *scene_root) {
for (GLTFNodeIndex node_i = 0; node_i < state.nodes.size(); ++node_i) {
const GLTFNode *node = state.nodes[node_i];
@ -2930,12 +2930,12 @@ void EditorSceneImporterGLTF::_process_mesh_instances(GLTFState &state, Spatial
const GLTFSkinIndex skin_i = node->skin;
Map<GLTFNodeIndex, Node *>::Element *mi_element = state.scene_nodes.find(node_i);
MeshInstance *mi = Object::cast_to<MeshInstance>(mi_element->get());
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(mi_element->get());
ERR_FAIL_COND(mi == nullptr);
const GLTFSkeletonIndex skel_i = state.skins[node->skin].skeleton;
const GLTFSkeleton &gltf_skeleton = state.skeletons[skel_i];
Skeleton *skeleton = gltf_skeleton.godot_skeleton;
Skeleton3D *skeleton = gltf_skeleton.godot_skeleton;
ERR_FAIL_COND(skeleton == nullptr);
mi->get_parent()->remove_child(mi);
@ -2949,9 +2949,9 @@ void EditorSceneImporterGLTF::_process_mesh_instances(GLTFState &state, Spatial
}
}
Spatial *EditorSceneImporterGLTF::_generate_scene(GLTFState &state, const int p_bake_fps) {
Node3D *EditorSceneImporterGLTF::_generate_scene(GLTFState &state, const int p_bake_fps) {
Spatial *root = memnew(Spatial);
Node3D *root = memnew(Node3D);
// scene_name is already unique
root->set_name(state.scene_name);
@ -3084,7 +3084,7 @@ Node *EditorSceneImporterGLTF::import_scene(const String &p_path, uint32_t p_fla
_assign_scene_names(state);
/* STEP 17 MAKE SCENE! */
Spatial *scene = _generate_scene(state, p_bake_fps);
Node3D *scene = _generate_scene(state, p_bake_fps);
return scene;
}

View File

@ -32,12 +32,12 @@
#define EDITOR_SCENE_IMPORTER_GLTF_H
#include "editor/import/resource_importer_scene.h"
#include "scene/3d/skeleton.h"
#include "scene/3d/spatial.h"
#include "scene/3d/node_3d.h"
#include "scene/3d/skeleton_3d.h"
class AnimationPlayer;
class BoneAttachment;
class MeshInstance;
class BoneAttachment3D;
class MeshInstance3D;
class EditorSceneImporterGLTF : public EditorSceneImporter {
@ -192,7 +192,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
Vector<GLTFNodeIndex> roots;
// The created Skeleton for the scene
Skeleton *godot_skeleton;
Skeleton3D *godot_skeleton;
// Set of unique bone names for the skeleton
Set<String> unique_names;
@ -395,15 +395,15 @@ class EditorSceneImporterGLTF : public EditorSceneImporter {
Error _parse_animations(GLTFState &state);
BoneAttachment *_generate_bone_attachment(GLTFState &state, Skeleton *skeleton, const GLTFNodeIndex node_index);
MeshInstance *_generate_mesh_instance(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index);
Camera *_generate_camera(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index);
Spatial *_generate_spatial(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index);
BoneAttachment3D *_generate_bone_attachment(GLTFState &state, Skeleton3D *skeleton, const GLTFNodeIndex node_index);
MeshInstance3D *_generate_mesh_instance(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index);
Camera3D *_generate_camera(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index);
Node3D *_generate_spatial(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index);
void _generate_scene_node(GLTFState &state, Node *scene_parent, Spatial *scene_root, const GLTFNodeIndex node_index);
Spatial *_generate_scene(GLTFState &state, const int p_bake_fps);
void _generate_scene_node(GLTFState &state, Node *scene_parent, Node3D *scene_root, const GLTFNodeIndex node_index);
Node3D *_generate_scene(GLTFState &state, const int p_bake_fps);
void _process_mesh_instances(GLTFState &state, Spatial *scene_root);
void _process_mesh_instances(GLTFState &state, Node3D *scene_root);
void _assign_scene_names(GLTFState &state);

View File

@ -32,8 +32,8 @@
#include "core/io/resource_saver.h"
#include "core/os/file_access.h"
#include "scene/3d/mesh_instance.h"
#include "scene/3d/spatial.h"
#include "scene/3d/mesh_instance_3d.h"
#include "scene/3d/node_3d.h"
#include "scene/resources/mesh.h"
#include "scene/resources/surface_tool.h"
@ -431,11 +431,11 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in
return NULL;
}
Spatial *scene = memnew(Spatial);
Node3D *scene = memnew(Node3D);
for (List<Ref<Mesh>>::Element *E = meshes.front(); E; E = E->next()) {
MeshInstance *mi = memnew(MeshInstance);
MeshInstance3D *mi = memnew(MeshInstance3D);
mi->set_mesh(E->get());
mi->set_name(E->get()->get_name());
scene->add_child(mi);

View File

@ -32,19 +32,19 @@
#include "core/io/resource_saver.h"
#include "editor/editor_node.h"
#include "scene/3d/collision_shape.h"
#include "scene/3d/mesh_instance.h"
#include "scene/3d/navigation.h"
#include "scene/3d/physics_body.h"
#include "scene/3d/vehicle_body.h"
#include "scene/3d/collision_shape_3d.h"
#include "scene/3d/mesh_instance_3d.h"
#include "scene/3d/navigation_3d.h"
#include "scene/3d/physics_body_3d.h"
#include "scene/3d/vehicle_body_3d.h"
#include "scene/animation/animation_player.h"
#include "scene/resources/animation.h"
#include "scene/resources/box_shape.h"
#include "scene/resources/box_shape_3d.h"
#include "scene/resources/packed_scene.h"
#include "scene/resources/ray_shape.h"
#include "scene/resources/ray_shape_3d.h"
#include "scene/resources/resource_format_text.h"
#include "scene/resources/sphere_shape.h"
#include "scene/resources/world_margin_shape.h"
#include "scene/resources/sphere_shape_3d.h"
#include "scene/resources/world_margin_shape_3d.h"
uint32_t EditorSceneImporter::get_import_flags() const {
@ -276,15 +276,15 @@ static String _fixstr(const String &p_what, const String &p_str) {
return what;
}
static void _gen_shape_list(const Ref<Mesh> &mesh, List<Ref<Shape>> &r_shape_list, bool p_convex) {
static void _gen_shape_list(const Ref<Mesh> &mesh, List<Ref<Shape3D>> &r_shape_list, bool p_convex) {
if (!p_convex) {
Ref<Shape> shape = mesh->create_trimesh_shape();
Ref<Shape3D> shape = mesh->create_trimesh_shape();
r_shape_list.push_back(shape);
} else {
Vector<Ref<Shape>> cd = mesh->convex_decompose();
Vector<Ref<Shape3D>> cd = mesh->convex_decompose();
if (cd.size()) {
for (int i = 0; i < cd.size(); i++) {
r_shape_list.push_back(cd[i]);
@ -293,7 +293,7 @@ static void _gen_shape_list(const Ref<Mesh> &mesh, List<Ref<Shape>> &r_shape_lis
}
}
Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>, List<Ref<Shape>>> &collision_map, LightBakeMode p_light_bake_mode) {
Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>, List<Ref<Shape3D>>> &collision_map, LightBakeMode p_light_bake_mode) {
// children first
for (int i = 0; i < p_node->get_child_count(); i++) {
@ -314,9 +314,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
return NULL;
}
if (Object::cast_to<MeshInstance>(p_node)) {
if (Object::cast_to<MeshInstance3D>(p_node)) {
MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node);
Ref<ArrayMesh> m = mi->get_mesh();
@ -344,7 +344,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
if (p_light_bake_mode != LIGHT_BAKE_DISABLED) {
mi->set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT, true);
mi->set_flag(GeometryInstance3D::FLAG_USE_BAKED_LIGHT, true);
}
}
@ -377,12 +377,12 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
if (isroot)
return p_node;
MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node);
if (mi) {
Ref<Mesh> mesh = mi->get_mesh();
if (mesh.is_valid()) {
List<Ref<Shape>> shapes;
List<Ref<Shape3D>> shapes;
String fixed_name;
if (collision_map.has(mesh)) {
shapes = collision_map[mesh];
@ -404,7 +404,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
if (shapes.size()) {
StaticBody *col = memnew(StaticBody);
StaticBody3D *col = memnew(StaticBody3D);
col->set_transform(mi->get_transform());
col->set_name(fixed_name);
p_node->replace_by(col);
@ -412,9 +412,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
p_node = col;
int idx = 0;
for (List<Ref<Shape>>::Element *E = shapes.front(); E; E = E->next()) {
for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) {
CollisionShape *cshape = memnew(CollisionShape);
CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(E->get());
col->add_child(cshape);
@ -427,55 +427,55 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
} else if (p_node->has_meta("empty_draw_type")) {
String empty_draw_type = String(p_node->get_meta("empty_draw_type"));
StaticBody *sb = memnew(StaticBody);
StaticBody3D *sb = memnew(StaticBody3D);
sb->set_name(_fixstr(name, "colonly"));
Object::cast_to<Spatial>(sb)->set_transform(Object::cast_to<Spatial>(p_node)->get_transform());
Object::cast_to<Node3D>(sb)->set_transform(Object::cast_to<Node3D>(p_node)->get_transform());
p_node->replace_by(sb);
memdelete(p_node);
p_node = NULL;
CollisionShape *colshape = memnew(CollisionShape);
CollisionShape3D *colshape = memnew(CollisionShape3D);
if (empty_draw_type == "CUBE") {
BoxShape *boxShape = memnew(BoxShape);
BoxShape3D *boxShape = memnew(BoxShape3D);
boxShape->set_extents(Vector3(1, 1, 1));
colshape->set_shape(boxShape);
colshape->set_name("BoxShape");
colshape->set_name("BoxShape3D");
} else if (empty_draw_type == "SINGLE_ARROW") {
RayShape *rayShape = memnew(RayShape);
RayShape3D *rayShape = memnew(RayShape3D);
rayShape->set_length(1);
colshape->set_shape(rayShape);
colshape->set_name("RayShape");
Object::cast_to<Spatial>(sb)->rotate_x(Math_PI / 2);
colshape->set_name("RayShape3D");
Object::cast_to<Node3D>(sb)->rotate_x(Math_PI / 2);
} else if (empty_draw_type == "IMAGE") {
WorldMarginShape *world_margin_shape = memnew(WorldMarginShape);
WorldMarginShape3D *world_margin_shape = memnew(WorldMarginShape3D);
colshape->set_shape(world_margin_shape);
colshape->set_name("WorldMarginShape");
} else {
SphereShape *sphereShape = memnew(SphereShape);
SphereShape3D *sphereShape = memnew(SphereShape3D);
sphereShape->set_radius(1);
colshape->set_shape(sphereShape);
colshape->set_name("SphereShape");
colshape->set_name("SphereShape3D");
}
sb->add_child(colshape);
colshape->set_owner(sb->get_owner());
}
} else if (_teststr(name, "rigid") && Object::cast_to<MeshInstance>(p_node)) {
} else if (_teststr(name, "rigid") && Object::cast_to<MeshInstance3D>(p_node)) {
if (isroot)
return p_node;
MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node);
Ref<Mesh> mesh = mi->get_mesh();
if (mesh.is_valid()) {
List<Ref<Shape>> shapes;
List<Ref<Shape3D>> shapes;
if (collision_map.has(mesh)) {
shapes = collision_map[mesh];
} else {
_gen_shape_list(mesh, shapes, true);
}
RigidBody *rigid_body = memnew(RigidBody);
RigidBody3D *rigid_body = memnew(RigidBody3D);
rigid_body->set_name(_fixstr(name, "rigid"));
p_node->replace_by(rigid_body);
rigid_body->set_transform(mi->get_transform());
@ -486,9 +486,9 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
mi->set_owner(rigid_body->get_owner());
int idx = 0;
for (List<Ref<Shape>>::Element *E = shapes.front(); E; E = E->next()) {
for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) {
CollisionShape *cshape = memnew(CollisionShape);
CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(E->get());
rigid_body->add_child(cshape);
@ -498,14 +498,14 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
}
}
} else if ((_teststr(name, "col") || (_teststr(name, "convcol"))) && Object::cast_to<MeshInstance>(p_node)) {
} else if ((_teststr(name, "col") || (_teststr(name, "convcol"))) && Object::cast_to<MeshInstance3D>(p_node)) {
MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node);
Ref<Mesh> mesh = mi->get_mesh();
if (mesh.is_valid()) {
List<Ref<Shape>> shapes;
List<Ref<Shape3D>> shapes;
String fixed_name;
if (collision_map.has(mesh)) {
shapes = collision_map[mesh];
@ -530,15 +530,15 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
}
if (shapes.size()) {
StaticBody *col = memnew(StaticBody);
StaticBody3D *col = memnew(StaticBody3D);
col->set_name("static_collision");
mi->add_child(col);
col->set_owner(mi->get_owner());
int idx = 0;
for (List<Ref<Shape>>::Element *E = shapes.front(); E; E = E->next()) {
for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) {
CollisionShape *cshape = memnew(CollisionShape);
CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(E->get());
col->add_child(cshape);
@ -550,22 +550,22 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
}
}
} else if (_teststr(name, "navmesh") && Object::cast_to<MeshInstance>(p_node)) {
} else if (_teststr(name, "navmesh") && Object::cast_to<MeshInstance3D>(p_node)) {
if (isroot)
return p_node;
MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node);
Ref<ArrayMesh> mesh = mi->get_mesh();
ERR_FAIL_COND_V(mesh.is_null(), NULL);
NavigationRegion *nmi = memnew(NavigationRegion);
NavigationRegion3D *nmi = memnew(NavigationRegion3D);
nmi->set_name(_fixstr(name, "navmesh"));
Ref<NavigationMesh> nmesh = memnew(NavigationMesh);
nmesh->create_from_mesh(mesh);
nmi->set_navigation_mesh(nmesh);
Object::cast_to<Spatial>(nmi)->set_transform(mi->get_transform());
Object::cast_to<Node3D>(nmi)->set_transform(mi->get_transform());
p_node->replace_by(nmi);
memdelete(p_node);
p_node = nmi;
@ -575,8 +575,8 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
return p_node;
Node *owner = p_node->get_owner();
Spatial *s = Object::cast_to<Spatial>(p_node);
VehicleBody *bv = memnew(VehicleBody);
Node3D *s = Object::cast_to<Node3D>(p_node);
VehicleBody3D *bv = memnew(VehicleBody3D);
String n = _fixstr(p_node->get_name(), "vehicle");
bv->set_name(n);
p_node->replace_by(bv);
@ -595,8 +595,8 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
return p_node;
Node *owner = p_node->get_owner();
Spatial *s = Object::cast_to<Spatial>(p_node);
VehicleWheel *bv = memnew(VehicleWheel);
Node3D *s = Object::cast_to<Node3D>(p_node);
VehicleWheel3D *bv = memnew(VehicleWheel3D);
String n = _fixstr(p_node->get_name(), "wheel");
bv->set_name(n);
p_node->replace_by(bv);
@ -609,16 +609,16 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
p_node = bv;
} else if (Object::cast_to<MeshInstance>(p_node)) {
} else if (Object::cast_to<MeshInstance3D>(p_node)) {
//last attempt, maybe collision inside the mesh data
MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node);
Ref<ArrayMesh> mesh = mi->get_mesh();
if (!mesh.is_null()) {
List<Ref<Shape>> shapes;
List<Ref<Shape3D>> shapes;
if (collision_map.has(mesh)) {
shapes = collision_map[mesh];
} else if (_teststr(mesh->get_name(), "col")) {
@ -632,15 +632,15 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>
}
if (shapes.size()) {
StaticBody *col = memnew(StaticBody);
StaticBody3D *col = memnew(StaticBody3D);
col->set_name("static_collision");
p_node->add_child(col);
col->set_owner(p_node->get_owner());
int idx = 0;
for (List<Ref<Shape>>::Element *E = shapes.front(); E; E = E->next()) {
for (List<Ref<Shape3D>>::Element *E = shapes.front(); E; E = E->next()) {
CollisionShape *cshape = memnew(CollisionShape);
CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(E->get());
col->add_child(cshape);
@ -934,14 +934,14 @@ void ResourceImporterScene::_find_meshes(Node *p_node, Map<Ref<ArrayMesh>, Trans
List<PropertyInfo> pi;
p_node->get_property_list(&pi);
MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(p_node);
if (mi) {
Ref<ArrayMesh> mesh = mi->get_mesh();
if (mesh.is_valid() && !meshes.has(mesh)) {
Spatial *s = mi;
Node3D *s = mi;
Transform transform;
while (s) {
transform = transform * s->get_transform();
@ -1141,7 +1141,7 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String
void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, int p_preset) const {
r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/root_type", PROPERTY_HINT_TYPE_STRING, "Node"), "Spatial"));
r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/root_type", PROPERTY_HINT_TYPE_STRING, "Node"), "Node3D"));
r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "nodes/root_name"), "Scene Root"));
List<String> script_extentions;
@ -1333,7 +1333,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
root_type = ScriptServer::get_global_class_base(root_type);
}
if (root_type != "Spatial") {
if (root_type != "Node3D") {
Node *base_node = Object::cast_to<Node>(ClassDB::instance(root_type));
if (base_node) {
@ -1348,9 +1348,9 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
scene->set_script(Variant(root_script));
}
if (Object::cast_to<Spatial>(scene)) {
if (Object::cast_to<Node3D>(scene)) {
float root_scale = p_options["nodes/root_scale"];
Object::cast_to<Spatial>(scene)->scale(Vector3(root_scale, root_scale, root_scale));
Object::cast_to<Node3D>(scene)->scale(Vector3(root_scale, root_scale, root_scale));
}
if (p_options["nodes/root_name"] != "Scene Root")
@ -1368,7 +1368,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
float anim_optimizer_maxang = p_options["animation/optimizer/max_angle"];
int light_bake_mode = p_options["meshes/light_baking"];
Map<Ref<Mesh>, List<Ref<Shape>>> collision_map;
Map<Ref<Mesh>, List<Ref<Shape3D>>> collision_map;
scene = _fix_node(scene, scene, collision_map, LightBakeMode(light_bake_mode));

View File

@ -34,7 +34,7 @@
#include "core/io/resource_importer.h"
#include "scene/resources/animation.h"
#include "scene/resources/mesh.h"
#include "scene/resources/shape.h"
#include "scene/resources/shape_3d.h"
class Material;
@ -147,7 +147,7 @@ public:
void _make_external_resources(Node *p_node, const String &p_base_path, bool p_make_animations, bool p_animations_as_text, bool p_keep_animations, bool p_make_materials, bool p_materials_as_text, bool p_keep_materials, bool p_make_meshes, bool p_meshes_as_text, Map<Ref<Animation>, Ref<Animation>> &p_animations, Map<Ref<Material>, Ref<Material>> &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh>> &p_meshes);
Node *_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>, List<Ref<Shape>>> &collision_map, LightBakeMode p_light_bake_mode);
Node *_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh>, List<Ref<Shape3D>>> &collision_map, LightBakeMode p_light_bake_mode);
void _create_clips(Node *scene, const Array &p_clips, bool p_bake_all);
void _filter_anim_tracks(Ref<Animation> anim, Set<String> &keep);

View File

@ -310,7 +310,7 @@ void InspectorDock::_property_keyed(const String &p_keyed, const Variant &p_valu
}
void InspectorDock::_transform_keyed(Object *sp, const String &p_sub, const Transform &p_key) {
Spatial *s = Object::cast_to<Spatial>(sp);
Node3D *s = Object::cast_to<Node3D>(sp);
if (!s)
return;
AnimationPlayerEditor::singleton->get_track_editor()->insert_transform_key(s, p_sub, p_key);

View File

@ -0,0 +1,434 @@
/*************************************************************************/
/* node_3d_editor_gizmos.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef SPATIAL_EDITOR_GIZMOS_H
#define SPATIAL_EDITOR_GIZMOS_H
#include "editor/plugins/node_3d_editor_plugin.h"
#include "scene/3d/camera_3d.h"
class Camera3D;
class LightNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(LightNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
bool has_gizmo(Node3D *p_spatial);
String get_name() const;
int get_priority() const;
String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const;
Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const;
void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point);
void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
void redraw(EditorNode3DGizmo *p_gizmo);
LightNode3DGizmoPlugin();
};
class AudioStreamPlayer3DNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(AudioStreamPlayer3DNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
bool has_gizmo(Node3D *p_spatial);
String get_name() const;
int get_priority() const;
String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const;
Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const;
void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point);
void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
void redraw(EditorNode3DGizmo *p_gizmo);
AudioStreamPlayer3DNode3DGizmoPlugin();
};
class CameraNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(CameraNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
bool has_gizmo(Node3D *p_spatial);
String get_name() const;
int get_priority() const;
String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const;
Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const;
void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point);
void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
void redraw(EditorNode3DGizmo *p_gizmo);
CameraNode3DGizmoPlugin();
};
class MeshInstanceNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(MeshInstanceNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
bool has_gizmo(Node3D *p_spatial);
String get_name() const;
int get_priority() const;
bool can_be_hidden() const;
void redraw(EditorNode3DGizmo *p_gizmo);
MeshInstanceNode3DGizmoPlugin();
};
class Sprite3DNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(Sprite3DNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
bool has_gizmo(Node3D *p_spatial);
String get_name() const;
int get_priority() const;
bool can_be_hidden() const;
void redraw(EditorNode3DGizmo *p_gizmo);
Sprite3DNode3DGizmoPlugin();
};
class Position3DNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(Position3DNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
Ref<ArrayMesh> pos3d_mesh;
Vector<Vector3> cursor_points;
public:
bool has_gizmo(Node3D *p_spatial);
String get_name() const;
int get_priority() const;
void redraw(EditorNode3DGizmo *p_gizmo);
Position3DNode3DGizmoPlugin();
};
class SkeletonNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(SkeletonNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
bool has_gizmo(Node3D *p_spatial);
String get_name() const;
int get_priority() const;
void redraw(EditorNode3DGizmo *p_gizmo);
SkeletonNode3DGizmoPlugin();
};
class PhysicalBoneNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(PhysicalBoneNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
bool has_gizmo(Node3D *p_spatial);
String get_name() const;
int get_priority() const;
void redraw(EditorNode3DGizmo *p_gizmo);
PhysicalBoneNode3DGizmoPlugin();
};
class RayCastNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(RayCastNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
bool has_gizmo(Node3D *p_spatial);
String get_name() const;
int get_priority() const;
void redraw(EditorNode3DGizmo *p_gizmo);
RayCastNode3DGizmoPlugin();
};
class SpringArmNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(SpringArmNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
bool has_gizmo(Node3D *p_spatial);
String get_name() const;
int get_priority() const;
void redraw(EditorNode3DGizmo *p_gizmo);
SpringArmNode3DGizmoPlugin();
};
class VehicleWheelNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(VehicleWheelNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
bool has_gizmo(Node3D *p_spatial);
String get_name() const;
int get_priority() const;
void redraw(EditorNode3DGizmo *p_gizmo);
VehicleWheelNode3DGizmoPlugin();
};
class SoftBodyNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(SoftBodyNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
bool has_gizmo(Node3D *p_spatial);
String get_name() const;
int get_priority() const;
bool is_selectable_when_hidden() const;
void redraw(EditorNode3DGizmo *p_gizmo);
String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const;
Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const;
void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel);
bool is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int idx) const;
SoftBodyNode3DGizmoPlugin();
};
class VisibilityNotifierGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(VisibilityNotifierGizmoPlugin, EditorNode3DGizmoPlugin);
public:
bool has_gizmo(Node3D *p_spatial);
String get_name() const;
int get_priority() const;
void redraw(EditorNode3DGizmo *p_gizmo);
String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const;
Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const;
void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point);
void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
VisibilityNotifierGizmoPlugin();
};
class CPUParticlesGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(CPUParticlesGizmoPlugin, EditorNode3DGizmoPlugin);
public:
bool has_gizmo(Node3D *p_spatial);
String get_name() const;
int get_priority() const;
bool is_selectable_when_hidden() const;
void redraw(EditorNode3DGizmo *p_gizmo);
CPUParticlesGizmoPlugin();
};
class ParticlesGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(ParticlesGizmoPlugin, EditorNode3DGizmoPlugin);
public:
bool has_gizmo(Node3D *p_spatial);
String get_name() const;
int get_priority() const;
bool is_selectable_when_hidden() const;
void redraw(EditorNode3DGizmo *p_gizmo);
String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const;
Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const;
void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point);
void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
ParticlesGizmoPlugin();
};
class ReflectionProbeGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(ReflectionProbeGizmoPlugin, EditorNode3DGizmoPlugin);
public:
bool has_gizmo(Node3D *p_spatial);
String get_name() const;
int get_priority() const;
void redraw(EditorNode3DGizmo *p_gizmo);
String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const;
Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const;
void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point);
void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
ReflectionProbeGizmoPlugin();
};
class GIProbeGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(GIProbeGizmoPlugin, EditorNode3DGizmoPlugin);
public:
bool has_gizmo(Node3D *p_spatial);
String get_name() const;
int get_priority() const;
void redraw(EditorNode3DGizmo *p_gizmo);
String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const;
Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const;
void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point);
void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
GIProbeGizmoPlugin();
};
#if 0
class BakedIndirectLightGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(BakedIndirectLightGizmoPlugin, EditorNode3DGizmoPlugin);
public:
bool has_gizmo(Spatial *p_spatial);
String get_name() const;
int get_priority() const;
void redraw(EditorNode3DGizmo *p_gizmo);
String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const;
Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const;
void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera *p_camera, const Point2 &p_point);
void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
BakedIndirectLightGizmoPlugin();
};
#endif
class CollisionShapeNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(CollisionShapeNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
bool has_gizmo(Node3D *p_spatial);
String get_name() const;
int get_priority() const;
void redraw(EditorNode3DGizmo *p_gizmo);
String get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const;
Variant get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const;
void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point);
void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false);
CollisionShapeNode3DGizmoPlugin();
};
class CollisionPolygonNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(CollisionPolygonNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
bool has_gizmo(Node3D *p_spatial);
String get_name() const;
int get_priority() const;
void redraw(EditorNode3DGizmo *p_gizmo);
CollisionPolygonNode3DGizmoPlugin();
};
class NavigationMeshNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(NavigationMeshNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
struct _EdgeKey {
Vector3 from;
Vector3 to;
bool operator<(const _EdgeKey &p_with) const { return from == p_with.from ? to < p_with.to : from < p_with.from; }
};
public:
bool has_gizmo(Node3D *p_spatial);
String get_name() const;
int get_priority() const;
void redraw(EditorNode3DGizmo *p_gizmo);
NavigationMeshNode3DGizmoPlugin();
};
class JointGizmosDrawer {
public:
static Basis look_body(const Transform &p_joint_transform, const Transform &p_body_transform);
static Basis look_body_toward(Vector3::Axis p_axis, const Transform &joint_transform, const Transform &body_transform);
static Basis look_body_toward_x(const Transform &p_joint_transform, const Transform &p_body_transform);
static Basis look_body_toward_y(const Transform &p_joint_transform, const Transform &p_body_transform);
/// Special function just used for physics joints, it returns a basis constrained toward Joint Z axis
/// with axis X and Y that are looking toward the body and oriented toward up
static Basis look_body_toward_z(const Transform &p_joint_transform, const Transform &p_body_transform);
// Draw circle around p_axis
static void draw_circle(Vector3::Axis p_axis, real_t p_radius, const Transform &p_offset, const Basis &p_base, real_t p_limit_lower, real_t p_limit_upper, Vector<Vector3> &r_points, bool p_inverse = false);
static void draw_cone(const Transform &p_offset, const Basis &p_base, real_t p_swing, real_t p_twist, Vector<Vector3> &r_points);
};
class JointNode3DGizmoPlugin : public EditorNode3DGizmoPlugin {
GDCLASS(JointNode3DGizmoPlugin, EditorNode3DGizmoPlugin);
public:
bool has_gizmo(Node3D *p_spatial);
String get_name() const;
int get_priority() const;
void redraw(EditorNode3DGizmo *p_gizmo);
static void CreatePinJointGizmo(const Transform &p_offset, Vector<Vector3> &r_cursor_points);
static void CreateHingeJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_limit_lower, real_t p_limit_upper, bool p_use_limit, Vector<Vector3> &r_common_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points);
static void CreateSliderJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_angular_limit_lower, real_t p_angular_limit_upper, real_t p_linear_limit_lower, real_t p_linear_limit_upper, Vector<Vector3> &r_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points);
static void CreateConeTwistJointGizmo(const Transform &p_offset, const Transform &p_trs_joint, const Transform &p_trs_body_a, const Transform &p_trs_body_b, real_t p_swing, real_t p_twist, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points);
static void CreateGeneric6DOFJointGizmo(
const Transform &p_offset,
const Transform &p_trs_joint,
const Transform &p_trs_body_a,
const Transform &p_trs_body_b,
real_t p_angular_limit_lower_x,
real_t p_angular_limit_upper_x,
real_t p_linear_limit_lower_x,
real_t p_linear_limit_upper_x,
bool p_enable_angular_limit_x,
bool p_enable_linear_limit_x,
real_t p_angular_limit_lower_y,
real_t p_angular_limit_upper_y,
real_t p_linear_limit_lower_y,
real_t p_linear_limit_upper_y,
bool p_enable_angular_limit_y,
bool p_enable_linear_limit_y,
real_t p_angular_limit_lower_z,
real_t p_angular_limit_upper_z,
real_t p_linear_limit_lower_z,
real_t p_linear_limit_upper_z,
bool p_enable_angular_limit_z,
bool p_enable_linear_limit_z,
Vector<Vector3> &r_points,
Vector<Vector3> *r_body_a_points,
Vector<Vector3> *r_body_b_points);
JointNode3DGizmoPlugin();
};
#endif // SPATIAL_EDITOR_GIZMOS_H

View File

@ -619,7 +619,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano
String concat = path.get_concatenated_subnames();
Skeleton *skeleton = Object::cast_to<Skeleton>(node);
Skeleton3D *skeleton = Object::cast_to<Skeleton3D>(node);
if (skeleton && skeleton->find_bone(concat) != -1) {
//path in skeleton
const String &bone = concat;
@ -643,7 +643,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano
ti->set_text(0, F->get());
ti->set_selectable(0, false);
ti->set_editable(0, false);
ti->set_icon(0, get_theme_icon("BoneAttachment", "EditorIcons"));
ti->set_icon(0, get_theme_icon("BoneAttachment3D", "EditorIcons"));
} else {
ti = parenthood[accum];
}
@ -654,7 +654,7 @@ bool AnimationNodeBlendTreeEditor::_update_filters(const Ref<AnimationNode> &ano
ti->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
ti->set_text(0, concat);
ti->set_checked(0, anode->is_path_filtered(path));
ti->set_icon(0, get_theme_icon("BoneAttachment", "EditorIcons"));
ti->set_icon(0, get_theme_icon("BoneAttachment3D", "EditorIcons"));
ti->set_metadata(0, path);
} else {

View File

@ -39,7 +39,7 @@
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/plugins/canvas_item_editor_plugin.h" // For onion skinning.
#include "editor/plugins/spatial_editor_plugin.h" // For onion skinning.
#include "editor/plugins/node_3d_editor_plugin.h" // For onion skinning.
#include "scene/main/window.h"
#include "servers/visual_server.h"
@ -1385,9 +1385,9 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
// Hide superfluous elements that would make the overlay unnecessary cluttered.
Dictionary canvas_edit_state;
Dictionary spatial_edit_state;
if (SpatialEditor::get_singleton()->is_visible()) {
if (Node3DEditor::get_singleton()->is_visible()) {
// 3D
spatial_edit_state = SpatialEditor::get_singleton()->get_state();
spatial_edit_state = Node3DEditor::get_singleton()->get_state();
Dictionary new_state = spatial_edit_state.duplicate();
new_state["show_grid"] = false;
new_state["show_origin"] = false;
@ -1404,7 +1404,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
}
new_state["viewports"] = vp;
// TODO: Save/restore only affected entries.
SpatialEditor::get_singleton()->set_state(new_state);
Node3DEditor::get_singleton()->set_state(new_state);
} else { // CanvasItemEditor
// 2D
canvas_edit_state = CanvasItemEditor::get_singleton()->get_state();
@ -1465,7 +1465,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
onion.captures_valid.write[cidx] = valid;
if (valid) {
player->seek(pos, true);
get_tree()->flush_transform_notifications(); // Needed for transforms of Spatials.
get_tree()->flush_transform_notifications(); // Needed for transforms of Node3Ds.
values_backup.update_skeletons(); // Needed for Skeletons (2D & 3D).
VS::get_singleton()->viewport_set_active(onion.captures[cidx], true);
@ -1489,9 +1489,9 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() {
player->restore_animated_values(values_backup);
// Restore state of main editors.
if (SpatialEditor::get_singleton()->is_visible()) {
if (Node3DEditor::get_singleton()->is_visible()) {
// 3D
SpatialEditor::get_singleton()->set_state(spatial_edit_state);
Node3DEditor::get_singleton()->set_state(spatial_edit_state);
} else { // CanvasItemEditor
// 2D
CanvasItemEditor::get_singleton()->set_state(canvas_edit_state);

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* camera_editor_plugin.cpp */
/* camera_3d_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,45 +28,45 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "camera_editor_plugin.h"
#include "camera_3d_editor_plugin.h"
#include "spatial_editor_plugin.h"
#include "node_3d_editor_plugin.h"
void CameraEditor::_node_removed(Node *p_node) {
void Camera3DEditor::_node_removed(Node *p_node) {
if (p_node == node) {
node = NULL;
SpatialEditor::get_singleton()->set_custom_camera(NULL);
Node3DEditor::get_singleton()->set_custom_camera(NULL);
hide();
}
}
void CameraEditor::_pressed() {
void Camera3DEditor::_pressed() {
Node *sn = (node && preview->is_pressed()) ? node : NULL;
SpatialEditor::get_singleton()->set_custom_camera(sn);
Node3DEditor::get_singleton()->set_custom_camera(sn);
}
void CameraEditor::_bind_methods() {
void Camera3DEditor::_bind_methods() {
}
void CameraEditor::edit(Node *p_camera) {
void Camera3DEditor::edit(Node *p_camera) {
node = p_camera;
if (!node) {
preview->set_pressed(false);
SpatialEditor::get_singleton()->set_custom_camera(NULL);
Node3DEditor::get_singleton()->set_custom_camera(NULL);
} else {
if (preview->is_pressed())
SpatialEditor::get_singleton()->set_custom_camera(p_camera);
Node3DEditor::get_singleton()->set_custom_camera(p_camera);
else
SpatialEditor::get_singleton()->set_custom_camera(NULL);
Node3DEditor::get_singleton()->set_custom_camera(NULL);
}
}
CameraEditor::CameraEditor() {
Camera3DEditor::Camera3DEditor() {
preview = memnew(Button);
add_child(preview);
@ -79,30 +79,30 @@ CameraEditor::CameraEditor() {
preview->set_margin(MARGIN_RIGHT, 0);
preview->set_margin(MARGIN_TOP, 0);
preview->set_margin(MARGIN_BOTTOM, 10);
preview->connect("pressed", callable_mp(this, &CameraEditor::_pressed));
preview->connect("pressed", callable_mp(this, &Camera3DEditor::_pressed));
}
void CameraEditorPlugin::edit(Object *p_object) {
void Camera3DEditorPlugin::edit(Object *p_object) {
SpatialEditor::get_singleton()->set_can_preview(Object::cast_to<Camera>(p_object));
Node3DEditor::get_singleton()->set_can_preview(Object::cast_to<Camera3D>(p_object));
//camera_editor->edit(Object::cast_to<Node>(p_object));
}
bool CameraEditorPlugin::handles(Object *p_object) const {
bool Camera3DEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("Camera");
return p_object->is_class("Camera3D");
}
void CameraEditorPlugin::make_visible(bool p_visible) {
void Camera3DEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
//SpatialEditor::get_singleton()->set_can_preview(Object::cast_to<Camera>(p_object));
//Node3DEditor::get_singleton()->set_can_preview(Object::cast_to<Camera>(p_object));
} else {
SpatialEditor::get_singleton()->set_can_preview(NULL);
Node3DEditor::get_singleton()->set_can_preview(NULL);
}
}
CameraEditorPlugin::CameraEditorPlugin(EditorNode *p_node) {
Camera3DEditorPlugin::Camera3DEditorPlugin(EditorNode *p_node) {
editor = p_node;
/* camera_editor = memnew( CameraEditor );
@ -120,5 +120,5 @@ CameraEditorPlugin::CameraEditorPlugin(EditorNode *p_node) {
*/
}
CameraEditorPlugin::~CameraEditorPlugin() {
Camera3DEditorPlugin::~Camera3DEditorPlugin() {
}

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* camera_editor_plugin.h */
/* camera_3d_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -33,11 +33,11 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/3d/camera.h"
#include "scene/3d/camera_3d.h"
class CameraEditor : public Control {
class Camera3DEditor : public Control {
GDCLASS(CameraEditor, Control);
GDCLASS(Camera3DEditor, Control);
Panel *panel;
Button *preview;
@ -51,25 +51,25 @@ protected:
public:
void edit(Node *p_camera);
CameraEditor();
Camera3DEditor();
};
class CameraEditorPlugin : public EditorPlugin {
class Camera3DEditorPlugin : public EditorPlugin {
GDCLASS(CameraEditorPlugin, EditorPlugin);
GDCLASS(Camera3DEditorPlugin, EditorPlugin);
//CameraEditor *camera_editor;
EditorNode *editor;
public:
virtual String get_name() const { return "Camera"; }
virtual String get_name() const { return "Camera3D"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_object);
virtual bool handles(Object *p_object) const;
virtual void make_visible(bool p_visible);
CameraEditorPlugin(EditorNode *p_node);
~CameraEditorPlugin();
Camera3DEditorPlugin(EditorNode *p_node);
~Camera3DEditorPlugin();
};
#endif // CAMERA_EDITOR_PLUGIN_H

View File

@ -40,11 +40,11 @@
#include "editor/editor_settings.h"
#include "editor/plugins/animation_player_editor_plugin.h"
#include "editor/plugins/script_editor_plugin.h"
#include "scene/2d/gpu_particles_2d.h"
#include "scene/2d/light_2d.h"
#include "scene/2d/particles_2d.h"
#include "scene/2d/polygon_2d.h"
#include "scene/2d/skeleton_2d.h"
#include "scene/2d/sprite.h"
#include "scene/2d/sprite_2d.h"
#include "scene/2d/touch_screen_button.h"
#include "scene/gui/grid_container.h"
#include "scene/gui/nine_patch_rect.h"
@ -5888,7 +5888,7 @@ void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) cons
Ref<PackedScene> scene = Ref<PackedScene>(Object::cast_to<PackedScene>(*res));
if (texture != NULL || scene != NULL) {
if (texture != NULL) {
Sprite *sprite = memnew(Sprite);
Sprite2D *sprite = memnew(Sprite2D);
sprite->set_texture(texture);
sprite->set_modulate(Color(1, 1, 1, 0.7f));
preview_node->add_child(sprite);
@ -6083,8 +6083,8 @@ void CanvasItemEditorViewport::_perform_drop_data() {
Node *child;
if (default_type == "Light2D")
child = memnew(Light2D);
else if (default_type == "Particles2D")
child = memnew(Particles2D);
else if (default_type == "GPUParticles2D")
child = memnew(GPUParticles2D);
else if (default_type == "Polygon2D")
child = memnew(Polygon2D);
else if (default_type == "TouchScreenButton")
@ -6094,7 +6094,7 @@ void CanvasItemEditorViewport::_perform_drop_data() {
else if (default_type == "NinePatchRect")
child = memnew(NinePatchRect);
else
child = memnew(Sprite); // default
child = memnew(Sprite2D); // default
_create_nodes(target_node, child, path, drop_pos);
}
@ -6247,11 +6247,11 @@ void CanvasItemEditorViewport::_bind_methods() {
}
CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasItemEditor *p_canvas_item_editor) {
default_type = "Sprite";
default_type = "Sprite2D";
// Node2D
types.push_back("Sprite");
types.push_back("Sprite2D");
types.push_back("Light2D");
types.push_back("Particles2D");
types.push_back("GPUParticles2D");
types.push_back("Polygon2D");
types.push_back("TouchScreenButton");
// Control

View File

@ -33,12 +33,12 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/2d/canvas_item.h"
#include "scene/gui/box_container.h"
#include "scene/gui/check_box.h"
#include "scene/gui/label.h"
#include "scene/gui/panel_container.h"
#include "scene/gui/spin_box.h"
#include "scene/main/canvas_item.h"
class CanvasItemEditorViewport;

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* collision_polygon_editor_plugin.cpp */
/* collision_polygon_3d_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,17 +28,17 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "collision_polygon_editor_plugin.h"
#include "collision_polygon_3d_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
#include "core/input/input_filter.h"
#include "core/os/file_access.h"
#include "core/os/keyboard.h"
#include "editor/editor_settings.h"
#include "scene/3d/camera.h"
#include "spatial_editor_plugin.h"
#include "node_3d_editor_plugin.h"
#include "scene/3d/camera_3d.h"
void Polygon3DEditor::_notification(int p_what) {
void CollisionPolygon3DEditor::_notification(int p_what) {
switch (p_what) {
@ -47,7 +47,7 @@ void Polygon3DEditor::_notification(int p_what) {
button_create->set_icon(get_theme_icon("Edit", "EditorIcons"));
button_edit->set_icon(get_theme_icon("MovePoint", "EditorIcons"));
button_edit->set_pressed(true);
get_tree()->connect("node_removed", callable_mp(this, &Polygon3DEditor::_node_removed));
get_tree()->connect("node_removed", callable_mp(this, &CollisionPolygon3DEditor::_node_removed));
} break;
case NOTIFICATION_PROCESS: {
@ -63,7 +63,7 @@ void Polygon3DEditor::_notification(int p_what) {
} break;
}
}
void Polygon3DEditor::_node_removed(Node *p_node) {
void CollisionPolygon3DEditor::_node_removed(Node *p_node) {
if (p_node == node) {
node = NULL;
@ -74,7 +74,7 @@ void Polygon3DEditor::_node_removed(Node *p_node) {
}
}
void Polygon3DEditor::_menu_option(int p_option) {
void CollisionPolygon3DEditor::_menu_option(int p_option) {
switch (p_option) {
@ -93,7 +93,7 @@ void Polygon3DEditor::_menu_option(int p_option) {
}
}
void Polygon3DEditor::_wip_close() {
void CollisionPolygon3DEditor::_wip_close() {
undo_redo->create_action(TTR("Create Polygon3D"));
undo_redo->add_undo_method(node, "set_polygon", node->call("get_polygon"));
@ -109,7 +109,7 @@ void Polygon3DEditor::_wip_close() {
undo_redo->commit_action();
}
bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) {
bool CollisionPolygon3DEditor::forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event) {
if (!node)
return false;
@ -346,10 +346,10 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
snap_ignore = false;
}
if (!snap_ignore && SpatialEditor::get_singleton()->is_snap_enabled()) {
if (!snap_ignore && Node3DEditor::get_singleton()->is_snap_enabled()) {
cpoint = cpoint.snapped(Vector2(
SpatialEditor::get_singleton()->get_translate_snap(),
SpatialEditor::get_singleton()->get_translate_snap()));
Node3DEditor::get_singleton()->get_translate_snap(),
Node3DEditor::get_singleton()->get_translate_snap()));
}
edited_point_pos = cpoint;
@ -360,7 +360,7 @@ bool Polygon3DEditor::forward_spatial_gui_input(Camera *p_camera, const Ref<Inpu
return false;
}
float Polygon3DEditor::_get_depth() {
float CollisionPolygon3DEditor::_get_depth() {
if (bool(node->call("_has_editable_3d_polygon_no_depth")))
return 0;
@ -368,7 +368,7 @@ float Polygon3DEditor::_get_depth() {
return float(node->call("get_depth"));
}
void Polygon3DEditor::_polygon_draw() {
void CollisionPolygon3DEditor::_polygon_draw() {
if (!node)
return;
@ -489,11 +489,11 @@ void Polygon3DEditor::_polygon_draw() {
m->surface_set_material(0, handle_material);
}
void Polygon3DEditor::edit(Node *p_collision_polygon) {
void CollisionPolygon3DEditor::edit(Node *p_collision_polygon) {
if (p_collision_polygon) {
node = Object::cast_to<Spatial>(p_collision_polygon);
node = Object::cast_to<Node3D>(p_collision_polygon);
//Enable the pencil tool if the polygon is empty
if (Vector<Vector2>(node->call("get_polygon")).size() == 0) {
_menu_option(MODE_CREATE);
@ -516,12 +516,12 @@ void Polygon3DEditor::edit(Node *p_collision_polygon) {
}
}
void Polygon3DEditor::_bind_methods() {
void CollisionPolygon3DEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_polygon_draw"), &Polygon3DEditor::_polygon_draw);
ClassDB::bind_method(D_METHOD("_polygon_draw"), &CollisionPolygon3DEditor::_polygon_draw);
}
Polygon3DEditor::Polygon3DEditor(EditorNode *p_editor) {
CollisionPolygon3DEditor::CollisionPolygon3DEditor(EditorNode *p_editor) {
node = NULL;
editor = p_editor;
@ -530,17 +530,17 @@ Polygon3DEditor::Polygon3DEditor(EditorNode *p_editor) {
add_child(memnew(VSeparator));
button_create = memnew(ToolButton);
add_child(button_create);
button_create->connect("pressed", callable_mp(this, &Polygon3DEditor::_menu_option), varray(MODE_CREATE));
button_create->connect("pressed", callable_mp(this, &CollisionPolygon3DEditor::_menu_option), varray(MODE_CREATE));
button_create->set_toggle_mode(true);
button_edit = memnew(ToolButton);
add_child(button_edit);
button_edit->connect("pressed", callable_mp(this, &Polygon3DEditor::_menu_option), varray(MODE_EDIT));
button_edit->connect("pressed", callable_mp(this, &CollisionPolygon3DEditor::_menu_option), varray(MODE_EDIT));
button_edit->set_toggle_mode(true);
mode = MODE_EDIT;
wip_active = false;
imgeom = memnew(ImmediateGeometry);
imgeom = memnew(ImmediateGeometry3D);
imgeom->set_transform(Transform(Basis(), Vector3(0, 0, 0.00001)));
line_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
@ -560,7 +560,7 @@ Polygon3DEditor::Polygon3DEditor(EditorNode *p_editor) {
handle_material->set_point_size(handle->get_width());
handle_material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, handle);
pointsm = memnew(MeshInstance);
pointsm = memnew(MeshInstance3D);
imgeom->add_child(pointsm);
m.instance();
pointsm->set_mesh(m);
@ -569,7 +569,7 @@ Polygon3DEditor::Polygon3DEditor(EditorNode *p_editor) {
snap_ignore = false;
}
Polygon3DEditor::~Polygon3DEditor() {
CollisionPolygon3DEditor::~CollisionPolygon3DEditor() {
memdelete(imgeom);
}
@ -581,7 +581,7 @@ void Polygon3DEditorPlugin::edit(Object *p_object) {
bool Polygon3DEditorPlugin::handles(Object *p_object) const {
return Object::cast_to<Spatial>(p_object) && bool(p_object->call("_is_editable_3d_polygon"));
return Object::cast_to<Node3D>(p_object) && bool(p_object->call("_is_editable_3d_polygon"));
}
void Polygon3DEditorPlugin::make_visible(bool p_visible) {
@ -598,8 +598,8 @@ void Polygon3DEditorPlugin::make_visible(bool p_visible) {
Polygon3DEditorPlugin::Polygon3DEditorPlugin(EditorNode *p_node) {
editor = p_node;
collision_polygon_editor = memnew(Polygon3DEditor(p_node));
SpatialEditor::get_singleton()->add_control_to_menu_panel(collision_polygon_editor);
collision_polygon_editor = memnew(CollisionPolygon3DEditor(p_node));
Node3DEditor::get_singleton()->add_control_to_menu_panel(collision_polygon_editor);
collision_polygon_editor->hide();
}

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* collision_polygon_editor_plugin.h */
/* collision_polygon_3d_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -33,16 +33,16 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/3d/collision_polygon.h"
#include "scene/3d/immediate_geometry.h"
#include "scene/3d/mesh_instance.h"
#include "scene/3d/collision_polygon_3d.h"
#include "scene/3d/immediate_geometry_3d.h"
#include "scene/3d/mesh_instance_3d.h"
#include "scene/gui/tool_button.h"
class CanvasItemEditor;
class Polygon3DEditor : public HBoxContainer {
class CollisionPolygon3DEditor : public HBoxContainer {
GDCLASS(Polygon3DEditor, HBoxContainer);
GDCLASS(CollisionPolygon3DEditor, HBoxContainer);
UndoRedo *undo_redo;
enum Mode {
@ -62,9 +62,9 @@ class Polygon3DEditor : public HBoxContainer {
EditorNode *editor;
Panel *panel;
Spatial *node;
ImmediateGeometry *imgeom;
MeshInstance *pointsm;
Node3D *node;
ImmediateGeometry3D *imgeom;
MeshInstance3D *pointsm;
Ref<ArrayMesh> m;
MenuButton *options;
@ -90,21 +90,21 @@ protected:
static void _bind_methods();
public:
virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event);
virtual bool forward_spatial_gui_input(Camera3D *p_camera, const Ref<InputEvent> &p_event);
void edit(Node *p_collision_polygon);
Polygon3DEditor(EditorNode *p_editor);
~Polygon3DEditor();
CollisionPolygon3DEditor(EditorNode *p_editor);
~CollisionPolygon3DEditor();
};
class Polygon3DEditorPlugin : public EditorPlugin {
GDCLASS(Polygon3DEditorPlugin, EditorPlugin);
Polygon3DEditor *collision_polygon_editor;
CollisionPolygon3DEditor *collision_polygon_editor;
EditorNode *editor;
public:
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 bool forward_spatial_gui_input(Camera3D *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 "Polygon3DEditor"; }
bool has_main_screen() const { return false; }

View File

@ -241,7 +241,7 @@ void CPUParticles2DEditorPlugin::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
menu->get_popup()->connect("id_pressed", callable_mp(this, &CPUParticles2DEditorPlugin::_menu_callback));
menu->set_icon(epoints->get_theme_icon("Particles2D", "EditorIcons"));
menu->set_icon(epoints->get_theme_icon("CPUParticles2D", "EditorIcons"));
file->connect("file_selected", callable_mp(this, &CPUParticles2DEditorPlugin::_file_selected));
}
}
@ -265,8 +265,7 @@ CPUParticles2DEditorPlugin::CPUParticles2DEditorPlugin(EditorNode *p_node) {
menu->get_popup()->add_item(TTR("Load Emission Mask"), MENU_LOAD_EMISSION_MASK);
menu->get_popup()->add_separator();
menu->get_popup()->add_item(TTR("Restart"), MENU_RESTART);
// menu->get_popup()->add_item(TTR("Clear Emission Mask"), MENU_CLEAR_EMISSION_MASK);
menu->set_text(TTR("Particles"));
menu->set_text(TTR("CPUParticles2D"));
menu->set_switch_on_hover(true);
toolbar->add_child(menu);

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* cpu_particles_editor_plugin.cpp */
/* cpu_particles_3d_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "cpu_particles_editor_plugin.h"
#include "cpu_particles_3d_editor_plugin.h"
#include "editor/plugins/spatial_editor_plugin.h"
#include "editor/plugins/node_3d_editor_plugin.h"
void CPUParticlesEditor::_node_removed(Node *p_node) {
void CPUParticles3DEditor::_node_removed(Node *p_node) {
if (p_node == node) {
node = NULL;
@ -40,14 +40,14 @@ void CPUParticlesEditor::_node_removed(Node *p_node) {
}
}
void CPUParticlesEditor::_notification(int p_notification) {
void CPUParticles3DEditor::_notification(int p_notification) {
if (p_notification == NOTIFICATION_ENTER_TREE) {
options->set_icon(get_theme_icon("CPUParticles", "EditorIcons"));
options->set_icon(get_theme_icon("CPUParticles3D", "EditorIcons"));
}
}
void CPUParticlesEditor::_menu_option(int p_option) {
void CPUParticles3DEditor::_menu_option(int p_option) {
switch (p_option) {
@ -65,13 +65,13 @@ void CPUParticlesEditor::_menu_option(int p_option) {
}
}
void CPUParticlesEditor::edit(CPUParticles *p_particles) {
void CPUParticles3DEditor::edit(CPUParticles3D *p_particles) {
base_node = p_particles;
node = p_particles;
}
void CPUParticlesEditor::_generate_emission_points() {
void CPUParticles3DEditor::_generate_emission_points() {
/// hacer codigo aca
Vector<Vector3> points;
@ -82,45 +82,45 @@ void CPUParticlesEditor::_generate_emission_points() {
}
if (normals.size() == 0) {
node->set_emission_shape(CPUParticles::EMISSION_SHAPE_POINTS);
node->set_emission_shape(CPUParticles3D::EMISSION_SHAPE_POINTS);
node->set_emission_points(points);
} else {
node->set_emission_shape(CPUParticles::EMISSION_SHAPE_DIRECTED_POINTS);
node->set_emission_shape(CPUParticles3D::EMISSION_SHAPE_DIRECTED_POINTS);
node->set_emission_points(points);
node->set_emission_normals(normals);
}
}
void CPUParticlesEditor::_bind_methods() {
void CPUParticles3DEditor::_bind_methods() {
}
CPUParticlesEditor::CPUParticlesEditor() {
CPUParticles3DEditor::CPUParticles3DEditor() {
particles_editor_hb = memnew(HBoxContainer);
SpatialEditor::get_singleton()->add_control_to_menu_panel(particles_editor_hb);
Node3DEditor::get_singleton()->add_control_to_menu_panel(particles_editor_hb);
options = memnew(MenuButton);
options->set_switch_on_hover(true);
particles_editor_hb->add_child(options);
particles_editor_hb->hide();
options->set_text(TTR("CPUParticles"));
options->set_text(TTR("CPUParticles3D"));
options->get_popup()->add_item(TTR("Create Emission Points From Node"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE);
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("Restart"), MENU_OPTION_RESTART);
options->get_popup()->connect("id_pressed", callable_mp(this, &CPUParticlesEditor::_menu_option));
options->get_popup()->connect("id_pressed", callable_mp(this, &CPUParticles3DEditor::_menu_option));
}
void CPUParticlesEditorPlugin::edit(Object *p_object) {
void CPUParticles3DEditorPlugin::edit(Object *p_object) {
particles_editor->edit(Object::cast_to<CPUParticles>(p_object));
particles_editor->edit(Object::cast_to<CPUParticles3D>(p_object));
}
bool CPUParticlesEditorPlugin::handles(Object *p_object) const {
bool CPUParticles3DEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("CPUParticles");
return p_object->is_class("CPUParticles3D");
}
void CPUParticlesEditorPlugin::make_visible(bool p_visible) {
void CPUParticles3DEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
particles_editor->show();
@ -132,14 +132,14 @@ void CPUParticlesEditorPlugin::make_visible(bool p_visible) {
}
}
CPUParticlesEditorPlugin::CPUParticlesEditorPlugin(EditorNode *p_node) {
CPUParticles3DEditorPlugin::CPUParticles3DEditorPlugin(EditorNode *p_node) {
editor = p_node;
particles_editor = memnew(CPUParticlesEditor);
particles_editor = memnew(CPUParticles3DEditor);
editor->get_viewport()->add_child(particles_editor);
particles_editor->hide();
}
CPUParticlesEditorPlugin::~CPUParticlesEditorPlugin() {
CPUParticles3DEditorPlugin::~CPUParticles3DEditorPlugin() {
}

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* cpu_particles_editor_plugin.h */
/* cpu_particles_3d_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -31,12 +31,12 @@
#ifndef CPU_PARTICLES_EDITOR_PLUGIN_H
#define CPU_PARTICLES_EDITOR_PLUGIN_H
#include "editor/plugins/particles_editor_plugin.h"
#include "scene/3d/cpu_particles.h"
#include "editor/plugins/gpu_particles_3d_editor_plugin.h"
#include "scene/3d/cpu_particles_3d.h"
class CPUParticlesEditor : public ParticlesEditorBase {
class CPUParticles3DEditor : public GPUParticles3DEditorBase {
GDCLASS(CPUParticlesEditor, ParticlesEditorBase);
GDCLASS(CPUParticles3DEditor, GPUParticles3DEditorBase);
enum Menu {
@ -46,11 +46,11 @@ class CPUParticlesEditor : public ParticlesEditorBase {
};
CPUParticles *node;
CPUParticles3D *node;
void _menu_option(int);
friend class CPUParticlesEditorPlugin;
friend class CPUParticles3DEditorPlugin;
virtual void _generate_emission_points();
@ -60,15 +60,15 @@ protected:
static void _bind_methods();
public:
void edit(CPUParticles *p_particles);
CPUParticlesEditor();
void edit(CPUParticles3D *p_particles);
CPUParticles3DEditor();
};
class CPUParticlesEditorPlugin : public EditorPlugin {
class CPUParticles3DEditorPlugin : public EditorPlugin {
GDCLASS(CPUParticlesEditorPlugin, EditorPlugin);
GDCLASS(CPUParticles3DEditorPlugin, EditorPlugin);
CPUParticlesEditor *particles_editor;
CPUParticles3DEditor *particles_editor;
EditorNode *editor;
public:
@ -78,8 +78,8 @@ public:
virtual bool handles(Object *p_object) const;
virtual void make_visible(bool p_visible);
CPUParticlesEditorPlugin(EditorNode *p_node);
~CPUParticlesEditorPlugin();
CPUParticles3DEditorPlugin(EditorNode *p_node);
~CPUParticles3DEditorPlugin();
};
#endif // CPU_PARTICLES_EDITOR_PLUGIN_H

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* particles_2d_editor_plugin.cpp */
/* gpu_particles_2d_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "particles_2d_editor_plugin.h"
#include "gpu_particles_2d_editor_plugin.h"
#include "canvas_item_editor_plugin.h"
#include "core/io/image_loader.h"
@ -36,17 +36,17 @@
#include "scene/gui/separator.h"
#include "scene/resources/particles_material.h"
void Particles2DEditorPlugin::edit(Object *p_object) {
void GPUParticles2DEditorPlugin::edit(Object *p_object) {
particles = Object::cast_to<Particles2D>(p_object);
particles = Object::cast_to<GPUParticles2D>(p_object);
}
bool Particles2DEditorPlugin::handles(Object *p_object) const {
bool GPUParticles2DEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("Particles2D");
return p_object->is_class("GPUParticles2D");
}
void Particles2DEditorPlugin::make_visible(bool p_visible) {
void GPUParticles2DEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
@ -57,13 +57,13 @@ void Particles2DEditorPlugin::make_visible(bool p_visible) {
}
}
void Particles2DEditorPlugin::_file_selected(const String &p_file) {
void GPUParticles2DEditorPlugin::_file_selected(const String &p_file) {
source_emission_file = p_file;
emission_mask->popup_centered();
}
void Particles2DEditorPlugin::_menu_callback(int p_idx) {
void GPUParticles2DEditorPlugin::_menu_callback(int p_idx) {
switch (p_idx) {
case MENU_GENERATE_VISIBILITY_RECT: {
@ -94,7 +94,7 @@ void Particles2DEditorPlugin::_menu_callback(int p_idx) {
cpu_particles->set_z_index(particles->get_z_index());
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
ur->create_action(TTR("Convert to CPUParticles"));
ur->create_action(TTR("Convert to CPUParticles2D"));
ur->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", particles, cpu_particles, true, false);
ur->add_do_reference(cpu_particles);
ur->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", cpu_particles, particles, false, false);
@ -109,7 +109,7 @@ void Particles2DEditorPlugin::_menu_callback(int p_idx) {
}
}
void Particles2DEditorPlugin::_generate_visibility_rect() {
void GPUParticles2DEditorPlugin::_generate_visibility_rect() {
float time = generate_seconds->get_value();
@ -149,7 +149,7 @@ void Particles2DEditorPlugin::_generate_visibility_rect() {
undo_redo->commit_action();
}
void Particles2DEditorPlugin::_generate_emission_mask() {
void GPUParticles2DEditorPlugin::_generate_emission_mask() {
Ref<ParticlesMaterial> pm = particles->get_process_material();
if (!pm.is_valid()) {
@ -345,20 +345,20 @@ void Particles2DEditorPlugin::_generate_emission_mask() {
}
}
void Particles2DEditorPlugin::_notification(int p_what) {
void GPUParticles2DEditorPlugin::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
menu->get_popup()->connect("id_pressed", callable_mp(this, &Particles2DEditorPlugin::_menu_callback));
menu->set_icon(menu->get_theme_icon("Particles2D", "EditorIcons"));
file->connect("file_selected", callable_mp(this, &Particles2DEditorPlugin::_file_selected));
menu->get_popup()->connect("id_pressed", callable_mp(this, &GPUParticles2DEditorPlugin::_menu_callback));
menu->set_icon(menu->get_theme_icon("GPUParticles2D", "EditorIcons"));
file->connect("file_selected", callable_mp(this, &GPUParticles2DEditorPlugin::_file_selected));
}
}
void Particles2DEditorPlugin::_bind_methods() {
void GPUParticles2DEditorPlugin::_bind_methods() {
}
Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) {
GPUParticles2DEditorPlugin::GPUParticles2DEditorPlugin(EditorNode *p_node) {
particles = NULL;
editor = p_node;
@ -376,10 +376,10 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) {
menu->get_popup()->add_item(TTR("Load Emission Mask"), MENU_LOAD_EMISSION_MASK);
// menu->get_popup()->add_item(TTR("Clear Emission Mask"), MENU_CLEAR_EMISSION_MASK);
menu->get_popup()->add_separator();
menu->get_popup()->add_item(TTR("Convert to CPUParticles"), MENU_OPTION_CONVERT_TO_CPU_PARTICLES);
menu->get_popup()->add_item(TTR("Convert to CPUParticles2D"), MENU_OPTION_CONVERT_TO_CPU_PARTICLES);
menu->get_popup()->add_separator();
menu->get_popup()->add_item(TTR("Restart"), MENU_RESTART);
menu->set_text(TTR("Particles"));
menu->set_text(TTR("GPUParticles2D"));
menu->set_switch_on_hover(true);
toolbar->add_child(menu);
@ -411,7 +411,7 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) {
toolbar->add_child(generate_visibility_rect);
generate_visibility_rect->connect("confirmed", callable_mp(this, &Particles2DEditorPlugin::_generate_visibility_rect));
generate_visibility_rect->connect("confirmed", callable_mp(this, &GPUParticles2DEditorPlugin::_generate_visibility_rect));
emission_mask = memnew(ConfirmationDialog);
emission_mask->set_title(TTR("Load Emission Mask"));
@ -428,8 +428,8 @@ Particles2DEditorPlugin::Particles2DEditorPlugin(EditorNode *p_node) {
toolbar->add_child(emission_mask);
emission_mask->connect("confirmed", callable_mp(this, &Particles2DEditorPlugin::_generate_emission_mask));
emission_mask->connect("confirmed", callable_mp(this, &GPUParticles2DEditorPlugin::_generate_emission_mask));
}
Particles2DEditorPlugin::~Particles2DEditorPlugin() {
GPUParticles2DEditorPlugin::~GPUParticles2DEditorPlugin() {
}

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* particles_2d_editor_plugin.h */
/* gpu_particles_2d_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -34,13 +34,13 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/2d/collision_polygon_2d.h"
#include "scene/2d/particles_2d.h"
#include "scene/2d/gpu_particles_2d.h"
#include "scene/gui/box_container.h"
#include "scene/gui/file_dialog.h"
class Particles2DEditorPlugin : public EditorPlugin {
class GPUParticles2DEditorPlugin : public EditorPlugin {
GDCLASS(Particles2DEditorPlugin, EditorPlugin);
GDCLASS(GPUParticles2DEditorPlugin, EditorPlugin);
enum {
@ -57,7 +57,7 @@ class Particles2DEditorPlugin : public EditorPlugin {
EMISSION_MODE_BORDER_DIRECTED
};
Particles2D *particles;
GPUParticles2D *particles;
EditorFileDialog *file;
EditorNode *editor;
@ -93,8 +93,8 @@ public:
virtual bool handles(Object *p_object) const;
virtual void make_visible(bool p_visible);
Particles2DEditorPlugin(EditorNode *p_node);
~Particles2DEditorPlugin();
GPUParticles2DEditorPlugin(EditorNode *p_node);
~GPUParticles2DEditorPlugin();
};
#endif // PARTICLES_2D_EDITOR_PLUGIN_H

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* particles_editor_plugin.cpp */
/* gpu_particles_3d_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "particles_editor_plugin.h"
#include "gpu_particles_3d_editor_plugin.h"
#include "core/io/resource_loader.h"
#include "editor/plugins/spatial_editor_plugin.h"
#include "scene/3d/cpu_particles.h"
#include "editor/plugins/node_3d_editor_plugin.h"
#include "scene/3d/cpu_particles_3d.h"
#include "scene/resources/particles_material.h"
bool ParticlesEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3> &normals) {
bool GPUParticles3DEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3> &normals) {
bool use_normals = emission_fill->get_selected() == 1;
@ -161,26 +161,26 @@ bool ParticlesEditorBase::_generate(Vector<Vector3> &points, Vector<Vector3> &no
return true;
}
void ParticlesEditorBase::_node_selected(const NodePath &p_path) {
void GPUParticles3DEditorBase::_node_selected(const NodePath &p_path) {
Node *sel = get_node(p_path);
if (!sel)
return;
if (!sel->is_class("Spatial")) {
if (!sel->is_class("Node3D")) {
EditorNode::get_singleton()->show_warning(vformat(TTR("\"%s\" doesn't inherit from Spatial."), sel->get_name()));
EditorNode::get_singleton()->show_warning(vformat(TTR("\"%s\" doesn't inherit from Node3D."), sel->get_name()));
return;
}
VisualInstance *vi = Object::cast_to<VisualInstance>(sel);
VisualInstance3D *vi = Object::cast_to<VisualInstance3D>(sel);
if (!vi) {
EditorNode::get_singleton()->show_warning(vformat(TTR("\"%s\" doesn't contain geometry."), sel->get_name()));
return;
}
geometry = vi->get_faces(VisualInstance::FACES_SOLID);
geometry = vi->get_faces(VisualInstance3D::FACES_SOLID);
if (geometry.size() == 0) {
@ -202,10 +202,10 @@ void ParticlesEditorBase::_node_selected(const NodePath &p_path) {
emission_dialog->popup_centered(Size2(300, 130));
}
void ParticlesEditorBase::_bind_methods() {
void GPUParticles3DEditorBase::_bind_methods() {
}
ParticlesEditorBase::ParticlesEditorBase() {
GPUParticles3DEditorBase::GPUParticles3DEditorBase() {
emission_dialog = memnew(ConfirmationDialog);
emission_dialog->set_title(TTR("Create Emitter"));
@ -226,14 +226,14 @@ ParticlesEditorBase::ParticlesEditorBase() {
emd_vb->add_margin_child(TTR("Emission Source: "), emission_fill);
emission_dialog->get_ok()->set_text(TTR("Create"));
emission_dialog->connect("confirmed", callable_mp(this, &ParticlesEditorBase::_generate_emission_points));
emission_dialog->connect("confirmed", callable_mp(this, &GPUParticles3DEditorBase::_generate_emission_points));
emission_tree_dialog = memnew(SceneTreeDialog);
add_child(emission_tree_dialog);
emission_tree_dialog->connect("selected", callable_mp(this, &ParticlesEditorBase::_node_selected));
emission_tree_dialog->connect("selected", callable_mp(this, &GPUParticles3DEditorBase::_node_selected));
}
void ParticlesEditor::_node_removed(Node *p_node) {
void GPUParticles3DEditor::_node_removed(Node *p_node) {
if (p_node == node) {
node = NULL;
@ -241,15 +241,15 @@ void ParticlesEditor::_node_removed(Node *p_node) {
}
}
void ParticlesEditor::_notification(int p_notification) {
void GPUParticles3DEditor::_notification(int p_notification) {
if (p_notification == NOTIFICATION_ENTER_TREE) {
options->set_icon(options->get_popup()->get_theme_icon("Particles", "EditorIcons"));
get_tree()->connect("node_removed", callable_mp(this, &ParticlesEditor::_node_removed));
options->set_icon(options->get_popup()->get_theme_icon("GPUParticles3D", "EditorIcons"));
get_tree()->connect("node_removed", callable_mp(this, &GPUParticles3DEditor::_node_removed));
}
}
void ParticlesEditor::_menu_option(int p_option) {
void GPUParticles3DEditor::_menu_option(int p_option) {
switch (p_option) {
@ -274,7 +274,7 @@ void ParticlesEditor::_menu_option(int p_option) {
} break;
case MENU_OPTION_CONVERT_TO_CPU_PARTICLES: {
CPUParticles *cpu_particles = memnew(CPUParticles);
CPUParticles3D *cpu_particles = memnew(CPUParticles3D);
cpu_particles->convert_from_particles(node);
cpu_particles->set_name(node->get_name());
cpu_particles->set_transform(node->get_transform());
@ -282,7 +282,7 @@ void ParticlesEditor::_menu_option(int p_option) {
cpu_particles->set_pause_mode(node->get_pause_mode());
UndoRedo *ur = EditorNode::get_singleton()->get_undo_redo();
ur->create_action(TTR("Convert to CPUParticles"));
ur->create_action(TTR("Convert to CPUParticles3D"));
ur->add_do_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", node, cpu_particles, true, false);
ur->add_do_reference(cpu_particles);
ur->add_undo_method(EditorNode::get_singleton()->get_scene_tree_dock(), "replace_node", cpu_particles, node, false, false);
@ -298,7 +298,7 @@ void ParticlesEditor::_menu_option(int p_option) {
}
}
void ParticlesEditor::_generate_aabb() {
void GPUParticles3DEditor::_generate_aabb() {
float time = generate_seconds->get_value();
@ -340,13 +340,13 @@ void ParticlesEditor::_generate_aabb() {
ur->commit_action();
}
void ParticlesEditor::edit(Particles *p_particles) {
void GPUParticles3DEditor::edit(GPUParticles3D *p_particles) {
base_node = p_particles;
node = p_particles;
}
void ParticlesEditor::_generate_emission_points() {
void GPUParticles3DEditor::_generate_emission_points() {
/// hacer codigo aca
Vector<Vector3> points;
@ -419,29 +419,29 @@ void ParticlesEditor::_generate_emission_points() {
}
}
void ParticlesEditor::_bind_methods() {
void GPUParticles3DEditor::_bind_methods() {
}
ParticlesEditor::ParticlesEditor() {
GPUParticles3DEditor::GPUParticles3DEditor() {
node = NULL;
particles_editor_hb = memnew(HBoxContainer);
SpatialEditor::get_singleton()->add_control_to_menu_panel(particles_editor_hb);
Node3DEditor::get_singleton()->add_control_to_menu_panel(particles_editor_hb);
options = memnew(MenuButton);
options->set_switch_on_hover(true);
particles_editor_hb->add_child(options);
particles_editor_hb->hide();
options->set_text(TTR("Particles"));
options->set_text(TTR("GPUParticles3D"));
options->get_popup()->add_item(TTR("Generate AABB"), MENU_OPTION_GENERATE_AABB);
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("Create Emission Points From Node"), MENU_OPTION_CREATE_EMISSION_VOLUME_FROM_NODE);
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("Convert to CPUParticles"), MENU_OPTION_CONVERT_TO_CPU_PARTICLES);
options->get_popup()->add_item(TTR("Convert to CPUParticles3D"), MENU_OPTION_CONVERT_TO_CPU_PARTICLES);
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("Restart"), MENU_OPTION_RESTART);
options->get_popup()->connect("id_pressed", callable_mp(this, &ParticlesEditor::_menu_option));
options->get_popup()->connect("id_pressed", callable_mp(this, &GPUParticles3DEditor::_menu_option));
generate_aabb = memnew(ConfirmationDialog);
generate_aabb->set_title(TTR("Generate Visibility AABB"));
@ -455,20 +455,20 @@ ParticlesEditor::ParticlesEditor() {
add_child(generate_aabb);
generate_aabb->connect("confirmed", callable_mp(this, &ParticlesEditor::_generate_aabb));
generate_aabb->connect("confirmed", callable_mp(this, &GPUParticles3DEditor::_generate_aabb));
}
void ParticlesEditorPlugin::edit(Object *p_object) {
void GPUParticles3DEditorPlugin::edit(Object *p_object) {
particles_editor->edit(Object::cast_to<Particles>(p_object));
particles_editor->edit(Object::cast_to<GPUParticles3D>(p_object));
}
bool ParticlesEditorPlugin::handles(Object *p_object) const {
bool GPUParticles3DEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("Particles");
return p_object->is_class("GPUParticles3D");
}
void ParticlesEditorPlugin::make_visible(bool p_visible) {
void GPUParticles3DEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
particles_editor->show();
@ -480,14 +480,14 @@ void ParticlesEditorPlugin::make_visible(bool p_visible) {
}
}
ParticlesEditorPlugin::ParticlesEditorPlugin(EditorNode *p_node) {
GPUParticles3DEditorPlugin::GPUParticles3DEditorPlugin(EditorNode *p_node) {
editor = p_node;
particles_editor = memnew(ParticlesEditor);
particles_editor = memnew(GPUParticles3DEditor);
editor->get_viewport()->add_child(particles_editor);
particles_editor->hide();
}
ParticlesEditorPlugin::~ParticlesEditorPlugin() {
GPUParticles3DEditorPlugin::~GPUParticles3DEditorPlugin() {
}

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* particles_editor_plugin.h */
/* gpu_particles_3d_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -33,15 +33,15 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/3d/particles.h"
#include "scene/3d/gpu_particles_3d.h"
#include "scene/gui/spin_box.h"
class ParticlesEditorBase : public Control {
class GPUParticles3DEditorBase : public Control {
GDCLASS(ParticlesEditorBase, Control);
GDCLASS(GPUParticles3DEditorBase, Control);
protected:
Spatial *base_node;
Node3D *base_node;
Panel *panel;
MenuButton *options;
HBoxContainer *particles_editor_hb;
@ -61,16 +61,16 @@ protected:
static void _bind_methods();
public:
ParticlesEditorBase();
GPUParticles3DEditorBase();
};
class ParticlesEditor : public ParticlesEditorBase {
class GPUParticles3DEditor : public GPUParticles3DEditorBase {
GDCLASS(ParticlesEditor, ParticlesEditorBase);
GDCLASS(GPUParticles3DEditor, GPUParticles3DEditorBase);
ConfirmationDialog *generate_aabb;
SpinBox *generate_seconds;
Particles *node;
GPUParticles3D *node;
enum Menu {
@ -86,7 +86,7 @@ class ParticlesEditor : public ParticlesEditorBase {
void _menu_option(int);
friend class ParticlesEditorPlugin;
friend class GPUParticles3DEditorPlugin;
virtual void _generate_emission_points();
@ -96,15 +96,15 @@ protected:
static void _bind_methods();
public:
void edit(Particles *p_particles);
ParticlesEditor();
void edit(GPUParticles3D *p_particles);
GPUParticles3DEditor();
};
class ParticlesEditorPlugin : public EditorPlugin {
class GPUParticles3DEditorPlugin : public EditorPlugin {
GDCLASS(ParticlesEditorPlugin, EditorPlugin);
GDCLASS(GPUParticles3DEditorPlugin, EditorPlugin);
ParticlesEditor *particles_editor;
GPUParticles3DEditor *particles_editor;
EditorNode *editor;
public:
@ -114,8 +114,8 @@ public:
virtual bool handles(Object *p_object) const;
virtual void make_visible(bool p_visible);
ParticlesEditorPlugin(EditorNode *p_node);
~ParticlesEditorPlugin();
GPUParticles3DEditorPlugin(EditorNode *p_node);
~GPUParticles3DEditorPlugin();
};
#endif // PARTICLES_EDITOR_PLUGIN_H

View File

@ -32,7 +32,7 @@
#include "canvas_item_editor_plugin.h"
#include "editor/editor_scale.h"
#include "spatial_editor_plugin.h"
#include "node_3d_editor_plugin.h"
Size2 GradientEditor::get_minimum_size() const {
return Size2(0, 60) * EDSCALE;

View File

@ -115,7 +115,7 @@ MaterialEditor::MaterialEditor() {
add_child(vc);
vc->set_anchors_and_margins_preset(PRESET_WIDE);
viewport = memnew(SubViewport);
Ref<World> world;
Ref<World3D> world;
world.instance();
viewport->set_world(world); //use own world
vc->add_child(viewport);
@ -123,25 +123,25 @@ MaterialEditor::MaterialEditor() {
viewport->set_transparent_background(true);
viewport->set_msaa(Viewport::MSAA_4X);
camera = memnew(Camera);
camera = memnew(Camera3D);
camera->set_transform(Transform(Basis(), Vector3(0, 0, 3)));
camera->set_perspective(45, 0.1, 10);
camera->make_current();
viewport->add_child(camera);
light1 = memnew(DirectionalLight);
light1 = memnew(DirectionalLight3D);
light1->set_transform(Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0)));
viewport->add_child(light1);
light2 = memnew(DirectionalLight);
light2 = memnew(DirectionalLight3D);
light2->set_transform(Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1)));
light2->set_color(Color(0.7, 0.7, 0.7));
viewport->add_child(light2);
sphere_instance = memnew(MeshInstance);
sphere_instance = memnew(MeshInstance3D);
viewport->add_child(sphere_instance);
box_instance = memnew(MeshInstance);
box_instance = memnew(MeshInstance3D);
viewport->add_child(box_instance);
Transform box_xform;

View File

@ -36,9 +36,9 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/3d/camera.h"
#include "scene/3d/light.h"
#include "scene/3d/mesh_instance.h"
#include "scene/3d/camera_3d.h"
#include "scene/3d/light_3d.h"
#include "scene/3d/mesh_instance_3d.h"
#include "scene/resources/material.h"
class ViewportContainer;
@ -49,11 +49,11 @@ class MaterialEditor : public Control {
ViewportContainer *vc;
SubViewport *viewport;
MeshInstance *sphere_instance;
MeshInstance *box_instance;
DirectionalLight *light1;
DirectionalLight *light2;
Camera *camera;
MeshInstance3D *sphere_instance;
MeshInstance3D *box_instance;
DirectionalLight3D *light1;
DirectionalLight3D *light2;
Camera3D *camera;
Ref<SphereMesh> sphere_mesh;
Ref<CubeMesh> box_mesh;

View File

@ -116,30 +116,30 @@ void MeshEditor::_bind_methods() {
MeshEditor::MeshEditor() {
viewport = memnew(SubViewport);
Ref<World> world;
Ref<World3D> world;
world.instance();
viewport->set_world(world); //use own world
add_child(viewport);
viewport->set_disable_input(true);
viewport->set_msaa(Viewport::MSAA_2X);
set_stretch(true);
camera = memnew(Camera);
camera = memnew(Camera3D);
camera->set_transform(Transform(Basis(), Vector3(0, 0, 1.1)));
camera->set_perspective(45, 0.1, 10);
viewport->add_child(camera);
light1 = memnew(DirectionalLight);
light1 = memnew(DirectionalLight3D);
light1->set_transform(Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0)));
viewport->add_child(light1);
light2 = memnew(DirectionalLight);
light2 = memnew(DirectionalLight3D);
light2->set_transform(Transform().looking_at(Vector3(0, 1, 0), Vector3(0, 0, 1)));
light2->set_color(Color(0.7, 0.7, 0.7));
viewport->add_child(light2);
rotation = memnew(Spatial);
rotation = memnew(Node3D);
viewport->add_child(rotation);
mesh_instance = memnew(MeshInstance);
mesh_instance = memnew(MeshInstance3D);
rotation->add_child(mesh_instance);
set_custom_minimum_size(Size2(1, 150) * EDSCALE);

View File

@ -33,9 +33,9 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/3d/camera.h"
#include "scene/3d/light.h"
#include "scene/3d/mesh_instance.h"
#include "scene/3d/camera_3d.h"
#include "scene/3d/light_3d.h"
#include "scene/3d/mesh_instance_3d.h"
#include "scene/gui/viewport_container.h"
#include "scene/resources/material.h"
@ -47,11 +47,11 @@ class MeshEditor : public ViewportContainer {
float rot_y;
SubViewport *viewport;
MeshInstance *mesh_instance;
Spatial *rotation;
DirectionalLight *light1;
DirectionalLight *light2;
Camera *camera;
MeshInstance3D *mesh_instance;
Node3D *rotation;
DirectionalLight3D *light1;
DirectionalLight3D *light2;
Camera3D *camera;
Ref<Mesh> mesh;

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* mesh_instance_editor_plugin.cpp */
/* mesh_instance_3d_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,16 +28,16 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "mesh_instance_editor_plugin.h"
#include "mesh_instance_3d_editor_plugin.h"
#include "editor/editor_scale.h"
#include "scene/3d/collision_shape.h"
#include "scene/3d/navigation_region.h"
#include "scene/3d/physics_body.h"
#include "node_3d_editor_plugin.h"
#include "scene/3d/collision_shape_3d.h"
#include "scene/3d/navigation_region_3d.h"
#include "scene/3d/physics_body_3d.h"
#include "scene/gui/box_container.h"
#include "spatial_editor_plugin.h"
void MeshInstanceEditor::_node_removed(Node *p_node) {
void MeshInstance3DEditor::_node_removed(Node *p_node) {
if (p_node == node) {
node = NULL;
@ -45,12 +45,12 @@ void MeshInstanceEditor::_node_removed(Node *p_node) {
}
}
void MeshInstanceEditor::edit(MeshInstance *p_mesh) {
void MeshInstance3DEditor::edit(MeshInstance3D *p_mesh) {
node = p_mesh;
}
void MeshInstanceEditor::_menu_option(int p_option) {
void MeshInstance3DEditor::_menu_option(int p_option) {
Ref<Mesh> mesh = node->get_mesh();
if (mesh.is_null()) {
@ -68,16 +68,16 @@ void MeshInstanceEditor::_menu_option(int p_option) {
List<Node *> selection = editor_selection->get_selected_node_list();
if (selection.empty()) {
Ref<Shape> shape = mesh->create_trimesh_shape();
Ref<Shape3D> shape = mesh->create_trimesh_shape();
if (shape.is_null()) {
err_dialog->set_text(TTR("Couldn't create a Trimesh collision shape."));
err_dialog->popup_centered();
return;
}
CollisionShape *cshape = memnew(CollisionShape);
CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(shape);
StaticBody *body = memnew(StaticBody);
StaticBody3D *body = memnew(StaticBody3D);
body->add_child(cshape);
Node *owner = node == get_tree()->get_edited_scene_root() ? node : node->get_owner();
@ -96,7 +96,7 @@ void MeshInstanceEditor::_menu_option(int p_option) {
for (List<Node *>::Element *E = selection.front(); E; E = E->next()) {
MeshInstance *instance = Object::cast_to<MeshInstance>(E->get());
MeshInstance3D *instance = Object::cast_to<MeshInstance3D>(E->get());
if (!instance)
continue;
@ -104,13 +104,13 @@ void MeshInstanceEditor::_menu_option(int p_option) {
if (m.is_null())
continue;
Ref<Shape> shape = m->create_trimesh_shape();
Ref<Shape3D> shape = m->create_trimesh_shape();
if (shape.is_null())
continue;
CollisionShape *cshape = memnew(CollisionShape);
CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(shape);
StaticBody *body = memnew(StaticBody);
StaticBody3D *body = memnew(StaticBody3D);
body->add_child(cshape);
Node *owner = instance == get_tree()->get_edited_scene_root() ? instance : instance->get_owner();
@ -134,11 +134,11 @@ void MeshInstanceEditor::_menu_option(int p_option) {
return;
}
Ref<Shape> shape = mesh->create_trimesh_shape();
Ref<Shape3D> shape = mesh->create_trimesh_shape();
if (shape.is_null())
return;
CollisionShape *cshape = memnew(CollisionShape);
CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(shape);
Node *owner = node->get_owner();
@ -162,7 +162,7 @@ void MeshInstanceEditor::_menu_option(int p_option) {
return;
}
Ref<Shape> shape = mesh->create_convex_shape();
Ref<Shape3D> shape = mesh->create_convex_shape();
if (shape.is_null()) {
err_dialog->set_text(TTR("Couldn't create a single convex collision shape."));
@ -173,7 +173,7 @@ void MeshInstanceEditor::_menu_option(int p_option) {
ur->create_action(TTR("Create Single Convex Shape"));
CollisionShape *cshape = memnew(CollisionShape);
CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(shape);
cshape->set_transform(node->get_transform());
@ -196,7 +196,7 @@ void MeshInstanceEditor::_menu_option(int p_option) {
return;
}
Vector<Ref<Shape>> shapes = mesh->convex_decompose();
Vector<Ref<Shape3D>> shapes = mesh->convex_decompose();
if (!shapes.size()) {
err_dialog->set_text(TTR("Couldn't create any collision shapes."));
@ -209,7 +209,7 @@ void MeshInstanceEditor::_menu_option(int p_option) {
for (int i = 0; i < shapes.size(); i++) {
CollisionShape *cshape = memnew(CollisionShape);
CollisionShape3D *cshape = memnew(CollisionShape3D);
cshape->set_shape(shapes[i]);
cshape->set_transform(node->get_transform());
@ -233,7 +233,7 @@ void MeshInstanceEditor::_menu_option(int p_option) {
return;
nmesh->create_from_mesh(mesh);
NavigationRegion *nmi = memnew(NavigationRegion);
NavigationRegion3D *nmi = memnew(NavigationRegion3D);
nmi->set_navigation_mesh(nmesh);
Node *owner = node == get_tree()->get_edited_scene_root() ? node : node->get_owner();
@ -291,20 +291,20 @@ void MeshInstanceEditor::_menu_option(int p_option) {
}
}
struct MeshInstanceEditorEdgeSort {
struct MeshInstance3DEditorEdgeSort {
Vector2 a;
Vector2 b;
bool operator<(const MeshInstanceEditorEdgeSort &p_b) const {
bool operator<(const MeshInstance3DEditorEdgeSort &p_b) const {
if (a == p_b.a)
return b < p_b.b;
else
return a < p_b.a;
}
MeshInstanceEditorEdgeSort() {}
MeshInstanceEditorEdgeSort(const Vector2 &p_a, const Vector2 &p_b) {
MeshInstance3DEditorEdgeSort() {}
MeshInstance3DEditorEdgeSort(const Vector2 &p_a, const Vector2 &p_b) {
if (p_a < p_b) {
a = p_a;
b = p_b;
@ -315,12 +315,12 @@ struct MeshInstanceEditorEdgeSort {
}
};
void MeshInstanceEditor::_create_uv_lines(int p_layer) {
void MeshInstance3DEditor::_create_uv_lines(int p_layer) {
Ref<Mesh> mesh = node->get_mesh();
ERR_FAIL_COND(!mesh.is_valid());
Set<MeshInstanceEditorEdgeSort> edges;
Set<MeshInstance3DEditorEdgeSort> edges;
uv_lines.clear();
for (int i = 0; i < mesh->get_surface_count(); i++) {
if (mesh->surface_get_primitive_type(i) != Mesh::PRIMITIVE_TRIANGLES)
@ -355,7 +355,7 @@ void MeshInstanceEditor::_create_uv_lines(int p_layer) {
for (int k = 0; k < 3; k++) {
MeshInstanceEditorEdgeSort edge;
MeshInstance3DEditorEdgeSort edge;
if (use_indices) {
edge.a = r[ri[j + k]];
edge.b = r[ri[j + ((k + 1) % 3)]];
@ -377,7 +377,7 @@ void MeshInstanceEditor::_create_uv_lines(int p_layer) {
debug_uv_dialog->popup_centered();
}
void MeshInstanceEditor::_debug_uv_draw() {
void MeshInstance3DEditor::_debug_uv_draw() {
if (uv_lines.size() == 0)
return;
@ -388,7 +388,7 @@ void MeshInstanceEditor::_debug_uv_draw() {
debug_uv->draw_multiline(uv_lines, Color(1.0, 0.8, 0.7));
}
void MeshInstanceEditor::_create_outline_mesh() {
void MeshInstance3DEditor::_create_outline_mesh() {
Ref<Mesh> mesh = node->get_mesh();
if (mesh.is_null()) {
@ -415,7 +415,7 @@ void MeshInstanceEditor::_create_outline_mesh() {
return;
}
MeshInstance *mi = memnew(MeshInstance);
MeshInstance3D *mi = memnew(MeshInstance3D);
mi->set_mesh(mesho);
Node *owner = node->get_owner();
if (get_tree()->get_edited_scene_root() == node) {
@ -434,17 +434,17 @@ void MeshInstanceEditor::_create_outline_mesh() {
ur->commit_action();
}
void MeshInstanceEditor::_bind_methods() {
void MeshInstance3DEditor::_bind_methods() {
}
MeshInstanceEditor::MeshInstanceEditor() {
MeshInstance3DEditor::MeshInstance3DEditor() {
options = memnew(MenuButton);
options->set_switch_on_hover(true);
SpatialEditor::get_singleton()->add_control_to_menu_panel(options);
Node3DEditor::get_singleton()->add_control_to_menu_panel(options);
options->set_text(TTR("Mesh"));
options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("MeshInstance", "EditorIcons"));
options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("MeshInstance3D", "EditorIcons"));
options->get_popup()->add_item(TTR("Create Trimesh Static Body"), MENU_OPTION_CREATE_STATIC_TRIMESH_BODY);
options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a StaticBody and assigns a polygon-based collision shape to it automatically.\nThis is the most accurate (but slowest) option for collision detection."));
@ -459,13 +459,13 @@ MeshInstanceEditor::MeshInstanceEditor() {
options->get_popup()->add_item(TTR("Create Navigation Mesh"), MENU_OPTION_CREATE_NAVMESH);
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("Create Outline Mesh..."), MENU_OPTION_CREATE_OUTLINE_MESH);
options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a static outline mesh. The outline mesh will have its normals flipped automatically.\nThis can be used instead of the SpatialMaterial Grow property when using that property isn't possible."));
options->get_popup()->set_item_tooltip(options->get_popup()->get_item_count() - 1, TTR("Creates a static outline mesh. The outline mesh will have its normals flipped automatically.\nThis can be used instead of the StandardMaterial Grow property when using that property isn't possible."));
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("View UV1"), MENU_OPTION_DEBUG_UV1);
options->get_popup()->add_item(TTR("View UV2"), MENU_OPTION_DEBUG_UV2);
options->get_popup()->add_item(TTR("Unwrap UV2 for Lightmap/AO"), MENU_OPTION_CREATE_UV2);
options->get_popup()->connect("id_pressed", callable_mp(this, &MeshInstanceEditor::_menu_option));
options->get_popup()->connect("id_pressed", callable_mp(this, &MeshInstance3DEditor::_menu_option));
outline_dialog = memnew(ConfirmationDialog);
outline_dialog->set_title(TTR("Create Outline Mesh"));
@ -483,7 +483,7 @@ MeshInstanceEditor::MeshInstanceEditor() {
outline_dialog_vbc->add_margin_child(TTR("Outline Size:"), outline_size);
add_child(outline_dialog);
outline_dialog->connect("confirmed", callable_mp(this, &MeshInstanceEditor::_create_outline_mesh));
outline_dialog->connect("confirmed", callable_mp(this, &MeshInstance3DEditor::_create_outline_mesh));
err_dialog = memnew(AcceptDialog);
add_child(err_dialog);
@ -493,21 +493,21 @@ MeshInstanceEditor::MeshInstanceEditor() {
add_child(debug_uv_dialog);
debug_uv = memnew(Control);
debug_uv->set_custom_minimum_size(Size2(600, 600) * EDSCALE);
debug_uv->connect("draw", callable_mp(this, &MeshInstanceEditor::_debug_uv_draw));
debug_uv->connect("draw", callable_mp(this, &MeshInstance3DEditor::_debug_uv_draw));
debug_uv_dialog->add_child(debug_uv);
}
void MeshInstanceEditorPlugin::edit(Object *p_object) {
void MeshInstance3DEditorPlugin::edit(Object *p_object) {
mesh_editor->edit(Object::cast_to<MeshInstance>(p_object));
mesh_editor->edit(Object::cast_to<MeshInstance3D>(p_object));
}
bool MeshInstanceEditorPlugin::handles(Object *p_object) const {
bool MeshInstance3DEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("MeshInstance");
return p_object->is_class("MeshInstance3D");
}
void MeshInstanceEditorPlugin::make_visible(bool p_visible) {
void MeshInstance3DEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
mesh_editor->options->show();
@ -518,14 +518,14 @@ void MeshInstanceEditorPlugin::make_visible(bool p_visible) {
}
}
MeshInstanceEditorPlugin::MeshInstanceEditorPlugin(EditorNode *p_node) {
MeshInstance3DEditorPlugin::MeshInstance3DEditorPlugin(EditorNode *p_node) {
editor = p_node;
mesh_editor = memnew(MeshInstanceEditor);
mesh_editor = memnew(MeshInstance3DEditor);
editor->get_viewport()->add_child(mesh_editor);
mesh_editor->options->hide();
}
MeshInstanceEditorPlugin::~MeshInstanceEditorPlugin() {
MeshInstance3DEditorPlugin::~MeshInstance3DEditorPlugin() {
}

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* mesh_instance_editor_plugin.h */
/* mesh_instance_3d_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -33,12 +33,12 @@
#include "editor/editor_node.h"
#include "editor/editor_plugin.h"
#include "scene/3d/mesh_instance.h"
#include "scene/3d/mesh_instance_3d.h"
#include "scene/gui/spin_box.h"
class MeshInstanceEditor : public Control {
class MeshInstance3DEditor : public Control {
GDCLASS(MeshInstanceEditor, Control);
GDCLASS(MeshInstance3DEditor, Control);
enum Menu {
@ -53,7 +53,7 @@ class MeshInstanceEditor : public Control {
MENU_OPTION_DEBUG_UV2,
};
MeshInstance *node;
MeshInstance3D *node;
MenuButton *options;
@ -70,7 +70,7 @@ class MeshInstanceEditor : public Control {
void _create_outline_mesh();
void _create_uv_lines(int p_layer);
friend class MeshInstanceEditorPlugin;
friend class MeshInstance3DEditorPlugin;
void _debug_uv_draw();
@ -79,26 +79,26 @@ protected:
static void _bind_methods();
public:
void edit(MeshInstance *p_mesh);
MeshInstanceEditor();
void edit(MeshInstance3D *p_mesh);
MeshInstance3DEditor();
};
class MeshInstanceEditorPlugin : public EditorPlugin {
class MeshInstance3DEditorPlugin : public EditorPlugin {
GDCLASS(MeshInstanceEditorPlugin, EditorPlugin);
GDCLASS(MeshInstance3DEditorPlugin, EditorPlugin);
MeshInstanceEditor *mesh_editor;
MeshInstance3DEditor *mesh_editor;
EditorNode *editor;
public:
virtual String get_name() const { return "MeshInstance"; }
virtual String get_name() const { return "MeshInstance3D"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_object);
virtual bool handles(Object *p_object) const;
virtual void make_visible(bool p_visible);
MeshInstanceEditorPlugin(EditorNode *p_node);
~MeshInstanceEditorPlugin();
MeshInstance3DEditorPlugin(EditorNode *p_node);
~MeshInstance3DEditorPlugin();
};
#endif // MESH_EDITOR_PLUGIN_H

View File

@ -33,12 +33,12 @@
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "main/main.h"
#include "scene/3d/mesh_instance.h"
#include "scene/3d/navigation_region.h"
#include "scene/3d/physics_body.h"
#include "node_3d_editor_plugin.h"
#include "scene/3d/mesh_instance_3d.h"
#include "scene/3d/navigation_region_3d.h"
#include "scene/3d/physics_body_3d.h"
#include "scene/main/window.h"
#include "scene/resources/packed_scene.h"
#include "spatial_editor_plugin.h"
void MeshLibraryEditor::edit(const Ref<MeshLibrary> &p_mesh_library) {
@ -71,16 +71,16 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
if (!p_merge)
p_library->clear();
Map<int, MeshInstance *> mesh_instances;
Map<int, MeshInstance3D *> mesh_instances;
for (int i = 0; i < p_scene->get_child_count(); i++) {
Node *child = p_scene->get_child(i);
if (!Object::cast_to<MeshInstance>(child)) {
if (!Object::cast_to<MeshInstance3D>(child)) {
if (child->get_child_count() > 0) {
child = child->get_child(0);
if (!Object::cast_to<MeshInstance>(child)) {
if (!Object::cast_to<MeshInstance3D>(child)) {
continue;
}
@ -88,7 +88,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
continue;
}
MeshInstance *mi = Object::cast_to<MeshInstance>(child);
MeshInstance3D *mi = Object::cast_to<MeshInstance3D>(child);
Ref<Mesh> mesh = mi->get_mesh();
if (mesh.is_null())
continue;
@ -118,10 +118,10 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
for (int j = 0; j < mi->get_child_count(); j++) {
Node *child2 = mi->get_child(j);
if (!Object::cast_to<StaticBody>(child2))
if (!Object::cast_to<StaticBody3D>(child2))
continue;
StaticBody *sb = Object::cast_to<StaticBody>(child2);
StaticBody3D *sb = Object::cast_to<StaticBody3D>(child2);
List<uint32_t> shapes;
sb->get_shape_owners(&shapes);
@ -135,7 +135,7 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
for (int k = 0; k < sb->shape_owner_get_shape_count(E->get()); k++) {
Ref<Shape> collision = sb->shape_owner_get_shape(E->get(), k);
Ref<Shape3D> collision = sb->shape_owner_get_shape(E->get(), k);
if (!collision.is_valid())
continue;
MeshLibrary::ShapeData shape_data;
@ -152,9 +152,9 @@ void MeshLibraryEditor::_import_scene(Node *p_scene, Ref<MeshLibrary> p_library,
Transform navmesh_transform;
for (int j = 0; j < mi->get_child_count(); j++) {
Node *child2 = mi->get_child(j);
if (!Object::cast_to<NavigationRegion>(child2))
if (!Object::cast_to<NavigationRegion3D>(child2))
continue;
NavigationRegion *sb = Object::cast_to<NavigationRegion>(child2);
NavigationRegion3D *sb = Object::cast_to<NavigationRegion3D>(child2);
navmesh = sb->get_navigation_mesh();
navmesh_transform = sb->get_transform();
if (!navmesh.is_null())
@ -267,7 +267,7 @@ MeshLibraryEditor::MeshLibraryEditor(EditorNode *p_editor) {
file->connect("file_selected", callable_mp(this, &MeshLibraryEditor::_import_scene_cbk));
menu = memnew(MenuButton);
SpatialEditor::get_singleton()->add_control_to_menu_panel(menu);
Node3DEditor::get_singleton()->add_control_to_menu_panel(menu);
menu->set_position(Point2(1, 1));
menu->set_text(TTR("Mesh Library"));
menu->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("MeshLibrary", "EditorIcons"));

View File

@ -30,9 +30,9 @@
#include "multimesh_editor_plugin.h"
#include "scene/3d/mesh_instance.h"
#include "node_3d_editor_plugin.h"
#include "scene/3d/mesh_instance_3d.h"
#include "scene/gui/box_container.h"
#include "spatial_editor_plugin.h"
void MultiMeshEditor::_node_removed(Node *p_node) {
@ -78,7 +78,7 @@ void MultiMeshEditor::_populate() {
return;
}
MeshInstance *ms_instance = Object::cast_to<MeshInstance>(ms_node);
MeshInstance3D *ms_instance = Object::cast_to<MeshInstance3D>(ms_node);
if (!ms_instance) {
@ -113,7 +113,7 @@ void MultiMeshEditor::_populate() {
return;
}
GeometryInstance *ss_instance = Object::cast_to<MeshInstance>(ss_node);
GeometryInstance3D *ss_instance = Object::cast_to<MeshInstance3D>(ss_node);
if (!ss_instance) {
@ -124,7 +124,7 @@ void MultiMeshEditor::_populate() {
Transform geom_xform = node->get_global_transform().affine_inverse() * ss_instance->get_global_transform();
Vector<Face3> geometry = ss_instance->get_faces(VisualInstance::FACES_SOLID);
Vector<Face3> geometry = ss_instance->get_faces(VisualInstance3D::FACES_SOLID);
if (geometry.size() == 0) {
@ -261,7 +261,7 @@ void MultiMeshEditor::_menu_option(int p_option) {
}
}
void MultiMeshEditor::edit(MultiMeshInstance *p_multimesh) {
void MultiMeshEditor::edit(MultiMeshInstance3D *p_multimesh) {
node = p_multimesh;
}
@ -284,10 +284,10 @@ MultiMeshEditor::MultiMeshEditor() {
options = memnew(MenuButton);
options->set_switch_on_hover(true);
SpatialEditor::get_singleton()->add_control_to_menu_panel(options);
Node3DEditor::get_singleton()->add_control_to_menu_panel(options);
options->set_text("MultiMesh");
options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("MultiMeshInstance", "EditorIcons"));
options->set_icon(EditorNode::get_singleton()->get_gui_base()->get_theme_icon("MultiMeshInstance3D", "EditorIcons"));
options->get_popup()->add_item(TTR("Populate Surface"));
options->get_popup()->connect("id_pressed", callable_mp(this, &MultiMeshEditor::_menu_option));
@ -379,12 +379,12 @@ MultiMeshEditor::MultiMeshEditor() {
void MultiMeshEditorPlugin::edit(Object *p_object) {
multimesh_editor->edit(Object::cast_to<MultiMeshInstance>(p_object));
multimesh_editor->edit(Object::cast_to<MultiMeshInstance3D>(p_object));
}
bool MultiMeshEditorPlugin::handles(Object *p_object) const {
return p_object->is_class("MultiMeshInstance");
return p_object->is_class("MultiMeshInstance3D");
}
void MultiMeshEditorPlugin::make_visible(bool p_visible) {

Some files were not shown because too many files have changed in this diff Show More